order cancels
This commit is contained in:
@@ -53,10 +53,11 @@ const Tranche = `(uint64,${Constraint}[])`
|
||||
const SwapOrder = `(address,address,${Route},uint256,bool,bool,uint64,${Tranche}[])`
|
||||
|
||||
export const vaultAbi = [
|
||||
'function withdraw(uint256) public',
|
||||
'function withdrawTo(address payable,uint256) public',
|
||||
'function withdraw(address,uint256) public',
|
||||
'function withdrawTo(address,address,uint256) public',
|
||||
'function placeOrder((address,address,(uint8,uint24),uint256,bool,bool,uint64,(uint16,(uint8,bytes)[])[])) public',
|
||||
'function placeOrders((address,address,(uint8,uint24),uint256,bool,bool,uint64,(uint16,(uint8,bytes)[])[])[],uint8) public',
|
||||
'function withdraw(uint256)',
|
||||
'function withdrawTo(address payable,uint256)',
|
||||
'function withdraw(address,uint256)',
|
||||
'function withdrawTo(address,address,uint256)',
|
||||
'function placeOrder((address,address,(uint8,uint24),uint256,bool,bool,uint64,(uint16,(uint8,bytes)[])[]))',
|
||||
'function placeOrders((address,address,(uint8,uint24),uint256,bool,bool,uint64,(uint16,(uint8,bytes)[])[])[],uint8)',
|
||||
'function cancelOrder(uint64)',
|
||||
]
|
||||
|
||||
@@ -157,6 +157,18 @@ export async function pendOrder(order) {
|
||||
}
|
||||
|
||||
|
||||
export async function cancelOrder(vault, orderIndex) {
|
||||
pendTransaction(async (signer)=> {
|
||||
const contract = contractOrNull(vault, vaultAbi, signer)
|
||||
if( contract === null ) {
|
||||
console.error('vault contract was null while canceling order', vault, orderIndex)
|
||||
return null
|
||||
}
|
||||
return await contract.cancelOrder(orderIndex)
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
export function flushOrders(vault) {
|
||||
for( const order of pendingOrders )
|
||||
pendOrderAsTransaction(vault, order)
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<template>
|
||||
<v-btn variant="outlined">
|
||||
<v-icon v-if="icon" :icon="icon" :color="color"></v-icon>
|
||||
<v-icon v-if="icon" :icon="icon" :color="color"></v-icon>
|
||||
<slot/>
|
||||
</v-btn>
|
||||
</template>
|
||||
|
||||
@@ -24,6 +24,7 @@
|
||||
<td>
|
||||
{{pairPrice(inTokenAddr, outTokenAddr, vaultAddr, index, avgPrice)}}
|
||||
<btn v-if="pairPrice(inTokenAddr, outTokenAddr, vaultAddr, index, avgPrice)!==''" size="small"
|
||||
variant="plain"
|
||||
@click="inverted[[vaultAddr,index]] = !inverted[[vaultAddr,index]]">
|
||||
{{pair(inTokenAddr, outTokenAddr, vaultAddr,index)}}
|
||||
</btn>
|
||||
@@ -31,10 +32,13 @@
|
||||
<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===1" prepend-icon="mdi-cancel" 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>
|
||||
<td>
|
||||
<btn v-if="state===0" icon="mdi-cancel" color="red" @click="cancelOrder(vaultAddr,index)">Cancel</btn>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</v-table>
|
||||
@@ -46,6 +50,7 @@ import {useStore} from "@/store/store";
|
||||
import {computed, reactive} from "vue";
|
||||
import {token} from "@/blockchain/token.js";
|
||||
import Btn from "@/components/Btn.vue"
|
||||
import {cancelOrder} from "@/blockchain/wallet.js";
|
||||
|
||||
const s = useStore()
|
||||
const props = defineProps(['vault'])
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
<td>
|
||||
<v-menu>
|
||||
<template v-slot:activator="{ props }">
|
||||
<v-btn variant="plain" v-bind="props" icon="mdi-menu"/> <!-- mdi-dots-vertical -->
|
||||
<v-btn variant="plain" v-bind="props" icon="mdi-dots-vertical"/>
|
||||
</template>
|
||||
<v-list>
|
||||
<v-list-subheader :title="token.symbol"/>
|
||||
|
||||
@@ -1,8 +1,12 @@
|
||||
<template>
|
||||
<needs-provider>
|
||||
<needs-signer>
|
||||
<btn icon="mdi-plus" color="green" class="mb-6" @click="$router.push('/twap')">New Dexorder</btn>
|
||||
<orders/>
|
||||
<v-card title="Orders">
|
||||
<v-card-item>
|
||||
<btn icon="mdi-plus" color="green" class="mb-6" @click="$router.push('/twap')">New Dexorder</btn>
|
||||
<orders/>
|
||||
</v-card-item>
|
||||
</v-card>
|
||||
</needs-signer>
|
||||
</needs-provider>
|
||||
</template>
|
||||
@@ -12,6 +16,7 @@ import Orders from "@/components/Orders.vue";
|
||||
import NeedsSigner from "@/components/NeedsSigner.vue";
|
||||
import NeedsProvider from "@/components/NeedsProvider.vue";
|
||||
import Btn from "@/components/Btn.vue";
|
||||
import PhoneCard from "@/components/PhoneCard.vue";
|
||||
</script>
|
||||
|
||||
<style scoped lang="scss">
|
||||
|
||||
Reference in New Issue
Block a user