updated SwapOrderStatus with Andrew's changes

This commit is contained in:
tim
2024-08-25 21:02:29 -04:00
parent 2cf5f14b0d
commit e0f42f80e7
5 changed files with 35 additions and 24 deletions

View File

@@ -102,8 +102,8 @@
<td class="text-center w-33">
<suspense>
<span v-if="item.state > OrderState.Signing">
<pulse :touch="item.trancheFilled[i]">
<token-amount :chain-id="item.chainId" :addr="item.amountToken" :amount="item.trancheFilled[i]" :raw="true"/>
<pulse :touch="item.trancheStatus[i].filled">
<token-amount :chain-id="item.chainId" :addr="item.amountToken" :amount="item.trancheStatus[i].filled" :raw="true"/>
</pulse>
/
</span>
@@ -198,10 +198,8 @@ const orders = computed(()=>{
// 0, rateLimitPeriod
// 0, start time
// 20, end time
// 730643660, min intercept
// 0, min slope
// 0, max intercept
// 0 max slope
// [730643660, 0], [min intercept, slope]
// [0, 0], [max intercept, slope]
// ],
// [...],
// [...],
@@ -258,9 +256,8 @@ const orders = computed(()=>{
st.avg = null
else {
st.avg = FixedNumber.fromValue(status.filledOut, 0, fmtX18)
.div(FixedNumber.fromValue(status.filledIn, 0, fmtX18)).toUnsafeFloat();
.div(FixedNumber.fromValue(status.filledIn, 0, fmtX18)).toUnsafeFloat() * (1+st.order.route.fee/1_000_000);
}
st.trancheFilled = o.amountIsInput ? st.trancheFilledIn : st.trancheFilledOut
st.amountToken = o.amountIsInput ? o.tokenIn : o.tokenOut
st.input = o.amountIsInput ? o.amount : 0
st.output = !o.amountIsInput ? o.amount : 0
@@ -268,6 +265,11 @@ const orders = computed(()=>{
st.selectable = st.state===OrderState.Open
st.token0 = o.tokenIn < o.tokenOut ? o.tokenIn : o.tokenOut
st.token1 = o.tokenIn < o.tokenOut ? o.tokenOut : o.tokenIn
for( const ts of st.trancheStatus ) {
ts.filledIn = BigInt(ts.filledIn)
ts.filledOut = BigInt(ts.filledOut)
ts.filled = o.amountIsInput ? ts.filledIn : ts.filledOut
}
}
}
result.sort((a,b)=>b.startTime-a.startTime)
@@ -279,14 +281,16 @@ function describeTrancheTime(st, isStart, t) {
let result = ''
if( t.minIsBarrier || t.maxIsBarrier )
return 'barrier'
const now = Math.round(Date.now()/1000)
if( isStart && t.startTime > 0 ) {
const started = t.startTimeIsRelative ? st.startTime + t.startTime : t.startTime
result += started*1000 < Date.now() ? 'Activated ' : 'Activates '
result += timestampString(started) + ' '
const start = t.startTimeIsRelative ? st.startTime + t.startTime : t.startTime
result += now < start ? 'Activates ' :
st.trancheStatus.activationTime < now ? 'Rate Limited ' : 'Activated '
result += timestampString(st.trancheStatus.activationTime) + ' '
}
if( !isStart && t.endTime < 4294967295 ) {
const ended = t.endTimeIsRelative ? st.startTime + t.endTime : t.endTime
result += ended*1000 < Date.now() ? 'Ended ' : 'Ending '
result += ended < now ? 'Ended ' : 'Ending '
result += timestampString(ended)
}
return result