DCABuilder slippage parameter fix
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import {nav, uuid} from "@/misc.js";
|
||||
import {nav, sleep, uuid} from "@/misc.js";
|
||||
import {vaultContract} from "@/blockchain/contract.js";
|
||||
import {ensureVault, provider, switchChain, useWalletStore} from "@/blockchain/wallet.js";
|
||||
import {toRaw} from "vue";
|
||||
@@ -128,9 +128,15 @@ export class Transaction {
|
||||
this.failed('vault contract was null while sending order transaction')
|
||||
return null
|
||||
}
|
||||
const tx = toRaw(await this.createTx(contract))
|
||||
this.signed(tx)
|
||||
console.log(`sent transaction`, tx)
|
||||
try {
|
||||
const tx = toRaw(await this.createTx(contract))
|
||||
this.signed(tx)
|
||||
console.log(`sent transaction`, tx)
|
||||
}
|
||||
catch (e) {
|
||||
this.failed(e)
|
||||
return null
|
||||
}
|
||||
tx.wait().then(this.mined.bind(this)).catch(this.failed.bind(this))
|
||||
return this.tx
|
||||
}
|
||||
@@ -159,7 +165,20 @@ export class PlaceOrderTransaction extends Transaction {
|
||||
|
||||
|
||||
async createTx(vaultContract) {
|
||||
this.fee = await placementFee(this.vault, this.order)
|
||||
const tries = 3;
|
||||
let i;
|
||||
for (i=0; i<tries; i++ ) {
|
||||
try {
|
||||
this.fee = await placementFee(vaultContract, this.order)
|
||||
break
|
||||
}
|
||||
catch (e) {
|
||||
console.warn('failed to get placement fee', e)
|
||||
await sleep(1000)
|
||||
}
|
||||
}
|
||||
if (i===tries)
|
||||
throw Error('failed to get placement fee')
|
||||
console.log('placing order', this.id, this.fee, this.order)
|
||||
return await vaultContract.placeDexorder(this.order, {value: this.fee.reduce((a, b) => a + b)})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user