improved order statuses
This commit is contained in:
@@ -9,11 +9,12 @@
|
||||
<th>Filled</th>
|
||||
<th>Remaining</th>
|
||||
<th>Average Price</th>
|
||||
<th>Status</th>
|
||||
<th> </th> <!-- actions -->
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr v-for="[index, inTokenAddr, outTokenAddr, amount, amountTokenAddr, filled, avgPrice] in orders">
|
||||
<tr v-for="[index, inTokenAddr, outTokenAddr, amount, amountTokenAddr, filled, avgPrice, state] in orders">
|
||||
<td>{{parseInt(index)+1}}</td>
|
||||
<td>{{tokenSymbol(inTokenAddr)}}</td>
|
||||
<td>{{tokenSymbol(outTokenAddr)}}</td>
|
||||
@@ -27,6 +28,13 @@
|
||||
{{pair(inTokenAddr, outTokenAddr, vaultAddr,index)}}
|
||||
</btn>
|
||||
</td>
|
||||
<td>
|
||||
<v-chip v-if="state===-1" prepend-icon="mdi-signature" color="yellow">Signing</v-chip>
|
||||
<v-chip v-if="state===0" prepend-icon="mdi-dots-horizontal" color="green">Open</v-chip>
|
||||
<v-chip v-if="state===1" prepend-icon="mdi-close" color="red">Canceled</v-chip>
|
||||
<v-chip v-if="state===2" prepend-icon="mdi-check-circle-outline" color="green">Completed</v-chip>
|
||||
<v-chip v-if="state===3" prepend-icon="mdi-progress-check" color="grey-darken-1">Expired</v-chip>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</v-table>
|
||||
@@ -87,32 +95,46 @@ function pair(inTokenAddr, outTokenAddr, vaultAddr, index) {
|
||||
const inToken = token(inTokenAddr)
|
||||
const outToken = token(outTokenAddr)
|
||||
return !inToken || !outToken ? null : inverted[[vaultAddr,index]] ?
|
||||
outToken.symbol+'/'+inToken.symbol : inToken.symbol+'/'+outToken.symbol
|
||||
outToken.symbol+'\\'+inToken.symbol : inToken.symbol+'\\'+outToken.symbol
|
||||
}
|
||||
|
||||
const orders = computed(()=>{
|
||||
if( !(vaultAddr.value in s.orders) )
|
||||
return {}
|
||||
const result = []
|
||||
for( const [index,status] of Object.entries(s.orders[vaultAddr.value]) ) {
|
||||
console.log('order status', status)
|
||||
// [index, symbolA, symbolB, amount, amountSymbol, filled]
|
||||
const inTokenAddr = status[0][0]
|
||||
const outTokenAddr = status[0][1]
|
||||
const amountIsInput = !!(status[0][4])
|
||||
const amountTokenAddr = amountIsInput ? inTokenAddr : outTokenAddr
|
||||
console.log('getamount', status[0][3])
|
||||
const amount = status[0][3]
|
||||
console.log('amount', amount)
|
||||
console.log('getfilled', amountIsInput ? status[4] : status[5])
|
||||
const filled = amountIsInput ? status[4] : status[5]
|
||||
console.log('filled', filled)
|
||||
const amountIn = BigInt(status[4])
|
||||
const amountOut = BigInt(status[5])
|
||||
const fmtX18 = {decimals:18, width: 256, signed:false};
|
||||
const avg = !amountIn || !amountOut ? null :
|
||||
FixedNumber.fromValue(status[5],0, fmtX18).div(FixedNumber.fromValue(status[4], 0, fmtX18))
|
||||
result.push([index, inTokenAddr, outTokenAddr, amount, amountTokenAddr, filled, avg])
|
||||
console.log('computing orders')
|
||||
// for( const [status] of pendingOrders.reverse() ) {
|
||||
// console.log('adding pended order')
|
||||
// const inTokenAddr = status[0]
|
||||
// const outTokenAddr = status[1]
|
||||
// const amountIsInput = !!(status[4])
|
||||
// const amountTokenAddr = amountIsInput ? inTokenAddr : outTokenAddr
|
||||
// const amount = 0
|
||||
// const filled = 0
|
||||
// const avg = ''
|
||||
// const state = -1 // pending
|
||||
// result.push(['...', inTokenAddr, outTokenAddr, amount, amountTokenAddr, filled, avg, state])
|
||||
// }
|
||||
if( vaultAddr.value in s.orders ) {
|
||||
for (const [index, status] of Object.entries(s.orders[vaultAddr.value]).reverse()) {
|
||||
console.log('order status', status)
|
||||
// [index, symbolA, symbolB, amount, amountSymbol, filled]
|
||||
const inTokenAddr = status[0][0]
|
||||
const outTokenAddr = status[0][1]
|
||||
const amountIsInput = !!(status[0][4])
|
||||
const amountTokenAddr = amountIsInput ? inTokenAddr : outTokenAddr
|
||||
console.log('getamount', status[0][3])
|
||||
const amount = status[0][3]
|
||||
console.log('amount', amount)
|
||||
console.log('getfilled', amountIsInput ? status[4] : status[5])
|
||||
const filled = amountIsInput ? status[4] : status[5]
|
||||
console.log('filled', filled)
|
||||
const amountIn = BigInt(status[4])
|
||||
const amountOut = BigInt(status[5])
|
||||
const fmtX18 = {decimals: 18, width: 256, signed: false};
|
||||
const avg = !amountIn || !amountOut ? null :
|
||||
FixedNumber.fromValue(status[5], 0, fmtX18).div(FixedNumber.fromValue(status[4], 0, fmtX18))
|
||||
const state = status[1]
|
||||
result.push([index, inTokenAddr, outTokenAddr, amount, amountTokenAddr, filled, avg, state])
|
||||
}
|
||||
}
|
||||
console.log('result', result)
|
||||
return result
|
||||
|
||||
Reference in New Issue
Block a user