From 871a6f584812316fa6671d95ec972ce59178e76c Mon Sep 17 00:00:00 2001 From: sdgoh Date: Thu, 17 Dec 2020 12:03:22 +0800 Subject: [PATCH] (fix) No pool http 500 error code. Fixate gas to prevent default value --- src/routes/balancer.route.js | 6 ++---- src/services/eth.js | 6 ++++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/routes/balancer.route.js b/src/routes/balancer.route.js index ae8347f..1de67c9 100644 --- a/src/routes/balancer.route.js +++ b/src/routes/balancer.route.js @@ -84,9 +84,8 @@ router.post('/sell-price', async (req, res) => { maxSwaps, ) - const gasLimit = estimateGasLimit(swaps.length) - if (swaps != null && expectedOut != null) { + const gasLimit = estimateGasLimit(swaps.length) res.status(200).json({ network: balancer.network, timestamp: initTime, @@ -145,9 +144,8 @@ router.post('/buy-price', async (req, res) => { maxSwaps, ) - const gasLimit = estimateGasLimit(swaps.length) - if (swaps != null && expectedIn != null) { + const gasLimit = estimateGasLimit(swaps.length) res.status(200).json({ network: balancer.network, timestamp: initTime, diff --git a/src/services/eth.js b/src/services/eth.js index cb3151a..2bbbe5b 100644 --- a/src/services/eth.js +++ b/src/services/eth.js @@ -65,15 +65,17 @@ export default class Ethereum { } // approve a spender to transfer tokens from a wallet address - async approveERC20 (wallet, spender, tokenAddress, amount, gasPrice = this.gasPrice, gasLimit = 50000) { + async approveERC20 (wallet, spender, tokenAddress, amount, gasPrice = this.gasPrice, gasLimit) { try { + // fixate gas limit to prevent overwriting + const approvalGasLimit = 50000 // instantiate a contract and pass in wallet, which act on behalf of that signer const contract = new ethers.Contract(tokenAddress, abi.ERC20Abi, wallet) return await contract.approve( spender, amount, { gasPrice: gasPrice * 1e9, - gasLimit: gasLimit + gasLimit: approvalGasLimit } ) } catch (err) {