From db66a6ce9efc5019b35a78213da43aab1ea86022 Mon Sep 17 00:00:00 2001 From: Matthias Kretschmann Date: Wed, 28 Oct 2020 11:59:48 +0100 Subject: [PATCH] fix remove liquidity --- src/balancer/Pool.ts | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/src/balancer/Pool.ts b/src/balancer/Pool.ts index 9a482766..665f278f 100644 --- a/src/balancer/Pool.ts +++ b/src/balancer/Pool.ts @@ -815,11 +815,14 @@ export class Pool extends PoolFactory { tokenAmountOut: string, maxPoolAmountIn: string ): Promise { + const gasLimitDefault = this.GASLIMIT_DEFAULT + const pool = new this.web3.eth.Contract(this.poolABI, poolAddress, { from: account }) let result = null let estGas + try { estGas = await pool.methods .exitswapExternAmountOut( @@ -827,16 +830,11 @@ export class Pool extends PoolFactory { this.web3.utils.toWei(tokenAmountOut), this.web3.utils.toWei(maxPoolAmountIn) ) - .estimateGas(function (err, estGas) { - if (err) { - // console.error('ERROR: OnChainMetadataCacheEstimateGas: ' + err) - return this.GASLIMIT_DEFAULT - } - return estGas - }) + .estimateGas((err, estGas) => (err ? gasLimitDefault : estGas)) } catch (e) { - estGas = this.GASLIMIT_DEFAULT + estGas = gasLimitDefault } + try { result = await pool.methods .exitswapExternAmountOut(