UNPREDICTABLE_GAS_LIMIT when calling estimateGas function

When I issue npx ts-node .ts and attempt to call out estimateGas function on sushiswap router as shown in below code snippet it triggers UNPREDICTABLE_GAS_LIMIT error (see below output error log #1).

const gasLimit = await sushiEthDai.estimateGas.swap(
			!shouldStartEth ? DAI_TRADE : 0,
			shouldStartEth ? ETH_TRADE : 0,
			flashLoanerAddress,
			ethers.utils.toUtf8Bytes('1')
		  );

Output Error Log #1
Error: cannot estimate gas; transaction may fail or may require manual gas limit (reason=“execution reverted”, method=“estimateGas”, transaction={“from”:“0x825c5e7d385F9f07e2312154B0Cf3CDd06396869”,“to”:“0xC3D03e4F041Fd4cD388c549Ee2A29a9E5075882f”,“data”:“0x022c0d9f0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000a000000000000000000000000a7564f968608ad09236b794836f93a5b76dfd53d000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000000013100000000000000000000000000000000000000000000000000000000000000”,“accessList”:null}, error={“reason”:“processing response error”,“code”:“SERVER_ERROR”,“body”:“{"jsonrpc":"2.0","id":56,"error":{"code":-32000,"message":"execution reverted"}}”,“error”:{“code”:-32000},“requestBody”:“{"method":"eth_estimateGas","params":[{"from":"xxxxx","to":"0xc3d03e4f041fd4cd388c549ee2a29a9e5075882f","data":"0x022c0d9f0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000a000000000000000000000000a7564f968608ad09236b794836f93a5b76dfd53d000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000000013100000000000000000000000000000000000000000000000000000000000000"}],"id":56,"jsonrpc":"2.0"}”,“requestMethod”:“POST”,“url”:“xxxxxx”}, code=UNPREDICTABLE_GAS_LIMIT, version=providers/5.7.1)
at Logger.makeError (C:\Samuel\Blockchain\Flashloan-arbitrage-bot-uniswap-v2\node_modules@ethersproject\logger\src.ts\index.ts:269:28)
at Logger.throwError (C:\Samuel\Blockchain\Flashloan-arbitrage-bot-uniswap-v2\node_modules@ethersproject\logger\src.ts\index.ts:281:20)
at checkError (C:\Samuel\Blockchain\Flashloan-arbitrage-bot-uniswap-v2\node_modules@ethersproject\providers\src.ts\json-rpc-provider.ts:78:20)
at JsonRpcProvider. (C:\Samuel\Blockchain\Flashloan-arbitrage-bot-uniswap-v2\node_modules@ethersproject\providers\src.ts\json-rpc-provider.ts:642:20)
at step (C:\Samuel\Blockchain\Flashloan-arbitrage-bot-uniswap-v2\node_modules@ethersproject\providers\lib\json-rpc-provider.js:48:23)
at Object.throw (C:\Samuel\Blockchain\Flashloan-arbitrage-bot-uniswap-v2\node_modules@ethersproject\providers\lib\json-rpc-provider.js:29:53)
at rejected (C:\Samuel\Blockchain\Flashloan-arbitrage-bot-uniswap-v2\node_modules@ethersproject\providers\lib\json-rpc-provider.js:21:65)
at processTicksAndRejections (node:internal/process/task_queues:96:5) {
reason: ‘execution reverted’,
code: ‘UNPREDICTABLE_GAS_LIMIT’,
method: ‘estimateGas’,
transaction: {
from: ‘xxxxxxxxxxxxxxxxxxxxxxxxxx’,
to: ‘0xC3D03e4F041Fd4cD388c549Ee2A29a9E5075882f’,
data: ‘0x022c0d9f0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000a000000000000000000000000a7564f968608ad09236b794836f93a5b76dfd53d000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000000013100000000000000000000000000000000000000000000000000000000000000’,
accessList: null
},
error: Error: processing response error (body=“{"jsonrpc":"2.0","id":56,"error":{"code":-32000,"message":"execution reverted"}}”, error={“code”:-32000}, requestBody=“{"method":"eth_estimateGas","params":[{"from":"0x825c5e7d385f9f07e2312154b0cf3cdd06396869","to":"0xc3d03e4f041fd4cd388c549ee2a29a9e5075882f","data":"0x022c0d9f0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000a000000000000000000000000a7564f968608ad09236b794836f93a5b76dfd53d000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000000013100000000000000000000000000000000000000000000000000000000000000"}],"id":56,"jsonrpc":"2.0"}”, requestMethod=“POST”, url=“xxxxxxxxxxxxxxxxxxxx”, code=SERVER_ERROR, version=web/5.7.1)
at Logger.makeError (C:\Samuel\Blockchain\Flashloan-arbitrage-bot-uniswap-v2\node_modules@ethersproject\logger\src.ts\index.ts:269:28)
at Logger.throwError (C:\Samuel\Blockchain\Flashloan-arbitrage-bot-uniswap-v2\node_modules@ethersproject\logger\src.ts\index.ts:281:20)
at C:\Samuel\Blockchain\Flashloan-arbitrage-bot-uniswap-v2\node_modules@ethersproject\web\src.ts\index.ts:341:28
at step (C:\Samuel\Blockchain\Flashloan-arbitrage-bot-uniswap-v2\node_modules@ethersproject\web\lib\index.js:33:23)
at Object.next (C:\Samuel\Blockchain\Flashloan-arbitrage-bot-uniswap-v2\node_modules@ethersproject\web\lib\index.js:14:53)
at fulfilled (C:\Samuel\Blockchain\Flashloan-arbitrage-bot-uniswap-v2\node_modules@ethersproject\web\lib\index.js:5:58)
at processTicksAndRejections (node:internal/process/task_queues:96:5) {
reason: ‘processing response error’,
code: ‘SERVER_ERROR’,
body: ‘{“jsonrpc”:“2.0”,“id”:56,“error”:{“code”:-32000,“message”:“execution reverted”}}’,
error: Error: execution reverted
at getResult (C:\Samuel\Blockchain\Flashloan-arbitrage-bot-uniswap-v2\node_modules@ethersproject\providers\src.ts\json-rpc-provider.ts:142:28)
at processJsonFunc (C:\Samuel\Blockchain\Flashloan-arbitrage-bot-uniswap-v2\node_modules@ethersproject\web\src.ts\index.ts:383:22)
at C:\Samuel\Blockchain\Flashloan-arbitrage-bot-uniswap-v2\node_modules@ethersproject\web\src.ts\index.ts:320:42
at step (C:\Samuel\Blockchain\Flashloan-arbitrage-bot-uniswap-v2\node_modules@ethersproject\web\lib\index.js:33:23)
at Object.next (C:\Samuel\Blockchain\Flashloan-arbitrage-bot-uniswap-v2\node_modules@ethersproject\web\lib\index.js:14:53)
at fulfilled (C:\Samuel\Blockchain\Flashloan-arbitrage-bot-uniswap-v2\node_modules@ethersproject\web\lib\index.js:5:58)
at processTicksAndRejections (node:internal/process/task_queues:96:5) {
code: -32000,
data: undefined
},
requestBody: ‘{“method”:“eth_estimateGas”,“params”:[{“from”:“xxxxxxxxxxxxxxxxxxxxxxxx”,“to”:“0xc3d03e4f041fd4cd388c549ee2a29a9e5075882f”,“data”:“0x022c0d9f0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000a000000000000000000000000a7564f968608ad09236b794836f93a5b76dfd53d000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000000013100000000000000000000000000000000000000000000000000000000000000”}],“id”:56,“jsonrpc”:“2.0”}’,
requestMethod: ‘POST’,
url: xxxxxxxxxxxxxxxxxxxxxxxx’
}
}

I also tried overriding the gas limit when passing it as a parameter into the same function shown below but it returns this time a slightly different error Error: cannot override “gas” (see below output error log #2).

const gasLimit = await sushiEthDai.estimateGas.swap(
			!shouldStartEth ? DAI_TRADE : 0,
			shouldStartEth ? ETH_TRADE : 0,
			flashLoanerAddress,
			ethers.utils.toUtf8Bytes('1'), {
				gas: 6721975
			}
		  );

Output Error Log #2
Error: cannot estimate gas; transaction may fail or may require manual gas limit (reason=“execution reverted”, method=“estimateGas”, transaction={“from”:“xxxxxxxxxxxxxxxxxxxxxxxxxxxxx”,“to”:“0xC3D03e4F041Fd4cD388c549Ee2A29a9E5075882f”,“data”:“0x022c0d9f0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000a000000000000000000000000a7564f968608ad09236b794836f93a5b76dfd53d000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000000013100000000000000000000000000000000000000000000000000000000000000”,“accessList”:null}, error={“reason”:“processing response error”,“code”:“SERVER_ERROR”,“body”:“{"jsonrpc":"2.0","id":56,"error":{"code":-32000,"message":"execution reverted"}}”,“error”:{“code”:-32000},“requestBody”:“{"method":"eth_estimateGas","params":[{"from":"xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx","to":"0xc3d03e4f041fd4cd388c549ee2a29a9e5075882f","data":"0x022c0d9f0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000a000000000000000000000000a7564f968608ad09236b794836f93a5b76dfd53d000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000000013100000000000000000000000000000000000000000000000000000000000000"}],"id":56,"jsonrpc":"2.0"}”,“requestMethod”:“POST”,“url”:“xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx”}, code=UNPREDICTABLE_GAS_LIMIT, version=providers/5.7.1)
at Logger.makeError (C:\Samuel\Blockchain\Flashloan-arbitrage-bot-uniswap-v2\node_modules@ethersproject\logger\src.ts\index.ts:269:28)
at Logger.throwError (C:\Samuel\Blockchain\Flashloan-arbitrage-bot-uniswap-v2\node_modules@ethersproject\logger\src.ts\index.ts:281:20)
at checkError (C:\Samuel\Blockchain\Flashloan-arbitrage-bot-uniswap-v2\node_modules@ethersproject\providers\src.ts\json-rpc-provider.ts:78:20)
at JsonRpcProvider. (C:\Samuel\Blockchain\Flashloan-arbitrage-bot-uniswap-v2\node_modules@ethersproject\providers\src.ts\json-rpc-provider.ts:642:20)
at step (C:\Samuel\Blockchain\Flashloan-arbitrage-bot-uniswap-v2\node_modules@ethersproject\providers\lib\json-rpc-provider.js:48:23)
at Object.throw (C:\Samuel\Blockchain\Flashloan-arbitrage-bot-uniswap-v2\node_modules@ethersproject\providers\lib\json-rpc-provider.js:29:53)
at rejected (C:\Samuel\Blockchain\Flashloan-arbitrage-bot-uniswap-v2\node_modules@ethersproject\providers\lib\json-rpc-provider.js:21:65)
at processTicksAndRejections (node:internal/process/task_queues:96:5) {
reason: ‘execution reverted’,
code: ‘UNPREDICTABLE_GAS_LIMIT’,
method: ‘estimateGas’,
transaction: {
from: ‘xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx’,
to: ‘0xC3D03e4F041Fd4cD388c549Ee2A29a9E5075882f’,
data: ‘0x022c0d9f0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000a000000000000000000000000a7564f968608ad09236b794836f93a5b76dfd53d000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000000013100000000000000000000000000000000000000000000000000000000000000’,
accessList: null
},
error: Error: processing response error (body=“{"jsonrpc":"2.0","id":56,"error":{"code":-32000,"message":"execution reverted"}}”, error={“code”:-32000}, requestBody=“{"method":"eth_estimateGas","params":[{"from":"xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx","to":"0xc3d03e4f041fd4cd388c549ee2a29a9e5075882f","data":"0x022c0d9f0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000a000000000000000000000000a7564f968608ad09236b794836f93a5b76dfd53d000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000000013100000000000000000000000000000000000000000000000000000000000000"}],"id":56,"jsonrpc":"2.0"}”, requestMethod=“POST”, url=“xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx”, code=SERVER_ERROR, version=web/5.7.1)
at Logger.makeError (C:\Samuel\Blockchain\Flashloan-arbitrage-bot-uniswap-v2\node_modules@ethersproject\logger\src.ts\index.ts:269:28)
at Logger.throwError (C:\Samuel\Blockchain\Flashloan-arbitrage-bot-uniswap-v2\node_modules@ethersproject\logger\src.ts\index.ts:281:20)
at C:\Samuel\Blockchain\Flashloan-arbitrage-bot-uniswap-v2\node_modules@ethersproject\web\src.ts\index.ts:341:28
at step (C:\Samuel\Blockchain\Flashloan-arbitrage-bot-uniswap-v2\node_modules@ethersproject\web\lib\index.js:33:23)
at Object.next (C:\Samuel\Blockchain\Flashloan-arbitrage-bot-uniswap-v2\node_modules@ethersproject\web\lib\index.js:14:53)
at fulfilled (C:\Samuel\Blockchain\Flashloan-arbitrage-bot-uniswap-v2\node_modules@ethersproject\web\lib\index.js:5:58)
at processTicksAndRejections (node:internal/process/task_queues:96:5) {
reason: ‘processing response error’,
code: ‘SERVER_ERROR’,
body: ‘{“jsonrpc”:“2.0”,“id”:56,“error”:{“code”:-32000,“message”:“execution reverted”}}’,
error: Error: execution reverted
at getResult (C:\Samuel\Blockchain\Flashloan-arbitrage-bot-uniswap-v2\node_modules@ethersproject\providers\src.ts\json-rpc-provider.ts:142:28)
at processJsonFunc (C:\Samuel\Blockchain\Flashloan-arbitrage-bot-uniswap-v2\node_modules@ethersproject\web\src.ts\index.ts:383:22)
at C:\Samuel\Blockchain\Flashloan-arbitrage-bot-uniswap-v2\node_modules@ethersproject\web\src.ts\index.ts:320:42
at step (C:\Samuel\Blockchain\Flashloan-arbitrage-bot-uniswap-v2\node_modules@ethersproject\web\lib\index.js:33:23)
at Object.next (C:\Samuel\Blockchain\Flashloan-arbitrage-bot-uniswap-v2\node_modules@ethersproject\web\lib\index.js:14:53)
at fulfilled (C:\Samuel\Blockchain\Flashloan-arbitrage-bot-uniswap-v2\node_modules@ethersproject\web\lib\index.js:5:58)
at processTicksAndRejections (node:internal/process/task_queues:96:5) {
code: -32000,
data: undefined
},
requestBody: ‘{“method”:“eth_estimateGas”,“params”:[{“from”:“xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx”,“to”:“0xc3d03e4f041fd4cd388c549ee2a29a9e5075882f”,“data”:“0x022c0d9f0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000a000000000000000000000000a7564f968608ad09236b794836f93a5b76dfd53d000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000000013100000000000000000000000000000000000000000000000000000000000000”}],“id”:56,“jsonrpc”:“2.0”}’,
requestMethod: ‘POST’,
url: ‘xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx’
}
}
Error: cannot override “gas” (operation=“overrides”, overrides=[“gas”], code=UNSUPPORTED_OPERATION, version=contracts/5.7.0)
at Logger.makeError (C:\Samuel\Blockchain\Flashloan-arbitrage-bot-uniswap-v2\node_modules@ethersproject\logger\src.ts\index.ts:269:28)
at Logger.throwError (C:\Samuel\Blockchain\Flashloan-arbitrage-bot-uniswap-v2\node_modules@ethersproject\logger\src.ts\index.ts:281:20)
at C:\Samuel\Blockchain\Flashloan-arbitrage-bot-uniswap-v2\node_modules@ethersproject\contracts\src.ts\index.ts:304:16
at step (C:\Samuel\Blockchain\Flashloan-arbitrage-bot-uniswap-v2\node_modules@ethersproject\contracts\lib\index.js:48:23)
at Object.next (C:\Samuel\Blockchain\Flashloan-arbitrage-bot-uniswap-v2\node_modules@ethersproject\contracts\lib\index.js:29:53)
at fulfilled (C:\Samuel\Blockchain\Flashloan-arbitrage-bot-uniswap-v2\node_modules@ethersproject\contracts\lib\index.js:20:58)
at processTicksAndRejections (node:internal/process/task_queues:96:5) {
reason: ‘cannot override “gas”’,
code: ‘UNSUPPORTED_OPERATION’,

operation: ‘overrides’,
overrides: [ ‘gas’ ]
}

Not sure if tsnode accepts command line options for setting gas limits or directly within tsconfig.json. This last case, I have consulted the tsconfig docs but it says nothing or no mention about gas limits. So I´m stuck here.

Any help would be greatly appreciated.

Thank you,
Samuel

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.