TRANCHE EXECUTION WORKS
This commit is contained in:
@@ -24,7 +24,7 @@
|
||||
{{pairSymbol}} {{r.fee/10000}}%
|
||||
</v-chip>
|
||||
|
||||
<div v-if="routeFinder.pending()">
|
||||
<div v-if="routesPending">
|
||||
<v-progress-circular indeterminate/> Searching for {{pairSymbol}} pools...
|
||||
</div>
|
||||
|
||||
@@ -97,8 +97,8 @@ import {pendOrder} from "@/blockchain/wallet.js";
|
||||
|
||||
const s = useStore()
|
||||
const buy = ref(false)
|
||||
let _tokenA = ref(s.tokens && s.tokens.length >= 1 ? s.tokens[0] : null)
|
||||
let _tokenB = ref(s.tokens && s.tokens.length >= 2 ? s.tokens[1] : null)
|
||||
let _tokenA = ref(s.tokens !== undefined && s.tokens.length >= 1 ? s.tokens[0] : null)
|
||||
let _tokenB = ref(s.tokens !== undefined && s.tokens.length >= 2 ? s.tokens[1] : null)
|
||||
const tokenA = computed({
|
||||
get() {
|
||||
return _tokenA.value
|
||||
@@ -132,6 +132,7 @@ const quote = computed(()=>{
|
||||
return !token?{}:token
|
||||
})
|
||||
const routes = ref([])
|
||||
const routesPending = ref(false)
|
||||
const amount = ref(100) // todo 0
|
||||
const amountIsTokenA = ref(false)
|
||||
const amountIsTotal = ref(true)
|
||||
@@ -140,26 +141,28 @@ const inverted = ref(false)
|
||||
const minPrice = ref(null)
|
||||
const maxPrice = ref(null)
|
||||
const limitPrice = ref(null)
|
||||
const interval = ref(1)
|
||||
const interval = ref(10)
|
||||
const intervalIsTotal = ref(true)
|
||||
const timeUnits = ['minutes', 'hours', 'days']
|
||||
const timeUnitIndex = ref(0)
|
||||
const timeUnitIndex = ref(1)
|
||||
const limitIsMinimum = computed(() => !(buy.value ^ inverted.value))
|
||||
const validOrder = computed(()=>amount.value > 0 && routes.value.length > 0 )
|
||||
|
||||
async function findRoute() {
|
||||
if( !_tokenA.value || !_tokenB.value ) {
|
||||
routes.value = []
|
||||
routes.value = []
|
||||
if( !_tokenA.value || !_tokenB.value )
|
||||
return
|
||||
}
|
||||
const helper = await queryHelperContract()
|
||||
if( !helper )
|
||||
return
|
||||
routesPending.value = true
|
||||
let rawRoutes
|
||||
try {
|
||||
rawRoutes = await helper.getRoutes(tokenA.value.address, tokenB.value.address)
|
||||
}
|
||||
catch (e) {
|
||||
routes.value = []
|
||||
console.log('routes exception', e)
|
||||
// console.log('routes exception', e)
|
||||
routesPending.value = false
|
||||
return
|
||||
}
|
||||
// todo expose all available pools
|
||||
@@ -178,6 +181,7 @@ async function findRoute() {
|
||||
}
|
||||
}
|
||||
routes.value = [result]
|
||||
routesPending.value = false
|
||||
console.log('found route', result)
|
||||
}
|
||||
|
||||
@@ -244,7 +248,7 @@ async function placeOrder() {
|
||||
const tokenIn = buy.value ? tb.address : ta.address
|
||||
const tokenOut = buy.value ? ta.address : tb.address
|
||||
const route = routes.value[0];
|
||||
const amountToken = amountIsTokenA ? ta : tb
|
||||
const amountToken = amountIsTokenA.value ? ta : tb
|
||||
const amt = FixedNumber.fromString(amount.value.toString(), {decimals: amountToken.decimals}).value
|
||||
const amountIsInput = amountIsTokenA.value !== buy.value
|
||||
|
||||
|
||||
Reference in New Issue
Block a user