<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: ssadek1976</title>
    <description>The latest articles on DEV Community by ssadek1976 (@ssadek1976).</description>
    <link>https://dev.to/ssadek1976</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F926853%2F6bd75382-fd83-4b7f-b0a8-8ab6946f64b6.png</url>
      <title>DEV Community: ssadek1976</title>
      <link>https://dev.to/ssadek1976</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/ssadek1976"/>
    <language>en</language>
    <item>
      <title>Output value from getAmountsIn &gt; getAmountsIn in arbitrage price difference opportunity</title>
      <dc:creator>ssadek1976</dc:creator>
      <pubDate>Sun, 30 Oct 2022 08:41:45 +0000</pubDate>
      <link>https://dev.to/ssadek1976/output-value-from-getamountsin-getamountsin-in-arbitrage-price-difference-opportunity-309k</link>
      <guid>https://dev.to/ssadek1976/output-value-from-getamountsin-getamountsin-in-arbitrage-price-difference-opportunity-309k</guid>
      <description>&lt;p&gt;Hello,&lt;/p&gt;

&lt;p&gt;For a given pair in a flashloan arbitrage operation, taking the example of uniswap and sushiswap as the selected DEX´s for executing an arbitrage opportunity, and for 1INCH/WETH token pair, sushiswap WETH price is cheaper than uniswap (despite having larger reserve volumes in comparison).&lt;/p&gt;

&lt;p&gt;The problem lies when I execute the following two lines of code in my &lt;code&gt;uniswapV2call&lt;/code&gt;method:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;uint amountToRepay = UniswapV2Library.getAmountsIn(factory, _amount, path)[0];
uint amountReceived = router.swapExactTokensForTokens(
                    _amount,
                    amountToRepay, 
                    path,
                    msg.sender,
                    (block.timestamp + 300))[1];
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;and it returns &lt;strong&gt;amountToRepay &amp;gt; amountReceived&lt;/strong&gt; when I was expecting the result to be other way round owing to spotted price difference opportunity under arbitrage operation.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Output console.log (from my back-end smart contract)&lt;/strong&gt;&lt;br&gt;
    &lt;em&gt;getAmountsIn() results.......&lt;br&gt;
    path[0]  0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2&lt;br&gt;
    path[1]  0x111111111117dc0aa78b770fa6a738034120c302&lt;br&gt;
    amountBorrowed  2497817866881194385864&lt;br&gt;
    &lt;strong&gt;amountToRepay   964334905750628563&lt;/strong&gt;&lt;br&gt;
    getAmountsOut() results.......&lt;br&gt;
    path[0]  0x111111111117dc0aa78b770fa6a738034120c302&lt;br&gt;
    path[1]  0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2&lt;br&gt;
    &lt;strong&gt;amountReceived  950114205093874394&lt;/strong&gt;&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Output error message&lt;/strong&gt;&lt;br&gt;
  Error: VM Exception while processing transaction: &lt;strong&gt;reverted with reason string 'UniswapV2Router: INSUFFICIENT_OUTPUT_AMOUNT'&lt;/strong&gt;&lt;br&gt;
      at . (0x7a250d5630b4cf539739df2c5dacb4c659f2488d)&lt;br&gt;
      at FlashloanerArbitrage.uniswapV2Call (contracts/FlashloanerArbitrage.sol:261)&lt;br&gt;
      at . (0x86f518368e0d49d5916e2bd9eb162e9952b7b04d)&lt;br&gt;
      at FlashloanerArbitrage.startSwap (contracts/FlashloanerArbitrage.sol:180)&lt;br&gt;
      at processTicksAndRejections (node:internal/process/task_queues:96:5)&lt;br&gt;
      at EthModule._estimateGasAction (C:\Samuel\Blockchain\Flashloan-arbitrage-bot-uniswapV2_hardhat\node_modules\hardhat\src\internal\hardhat-network\provider\modules\eth.ts:429:7)&lt;br&gt;
      at HardhatNetworkProvider._sendWithLogging (C:\Samuel\Blockchain\Flashloan-arbitrage-bot-uniswapV2_hardhat\node_modules\hardhat\src\internal\hardhat-network\provider\provider.ts:139:22)&lt;br&gt;
      at HardhatNetworkProvider.request (C:\Samuel\Blockchain\Flashloan-arbitrage-bot-uniswapV2_hardhat\node_modules\hardhat\src\internal\hardhat-network\provider\provider.ts:116:18)&lt;br&gt;
      at JsonRpcHandler._handleRequest (C:\Samuel\Blockchain\Flashloan-arbitrage-bot-uniswapV2_hardhat\node_modules\hardhat\src\internal\hardhat-network\jsonrpc\handler.ts:188:20)&lt;br&gt;
      at JsonRpcHandler._handleSingleRequest (C:\Samuel\Blockchain\Flashloan-arbitrage-bot-uniswapV2_hardhat\node_modules\hardhat\src\internal\hardhat-network\jsonrpc\handler.ts:167:17)&lt;br&gt;
      at Server.JsonRpcHandler.handleHttp (C:\Samuel\Blockchain\Flashloan-arbitrage-bot-uniswapV2_hardhat\node_modules\hardhat\src\internal\hardhat-network\jsonrpc\handler.ts:52:21)&lt;/p&gt;

&lt;p&gt;Where am I going wrong here as this issue has been troubling me for several weeks now.&lt;br&gt;
I have tried implementing other_ pricing oracle methods but it comes back to this very same issue.&lt;/p&gt;

&lt;p&gt;Any help or suggestions would be greatly appreciated.&lt;/p&gt;

&lt;p&gt;Thank you&lt;/p&gt;

</description>
    </item>
    <item>
      <title>UNPREDICTABLE_GAS_LIMIT when calling estimateGas function</title>
      <dc:creator>ssadek1976</dc:creator>
      <pubDate>Sun, 18 Sep 2022 07:41:37 +0000</pubDate>
      <link>https://dev.to/ssadek1976/unpredictablegaslimit-when-calling-estimategas-function-599m</link>
      <guid>https://dev.to/ssadek1976/unpredictablegaslimit-when-calling-estimategas-function-599m</guid>
      <description>&lt;p&gt;Hello,&lt;/p&gt;

&lt;p&gt;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 &lt;strong&gt;UNPREDICTABLE_GAS_LIMIT&lt;/strong&gt; error (see below output error log #1).&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;`const gasLimit = await sushiEthDai.estimateGas.swap(
            !shouldStartEth ? DAI_TRADE : 0,
            shouldStartEth ? ETH_TRADE : 0,
            flashLoanerAddress,
            ethers.utils.toUtf8Bytes('1')
          );`
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;&lt;strong&gt;Output Error Log #1&lt;/strong&gt;&lt;br&gt;
&lt;em&gt;Error: cannot estimate gas; transaction may fail or may require manual gas limit &lt;a href="reason="&gt; See: https://links.ethers.org/v5-errors-UNPREDICTABLE_GAS_LIMIT &lt;/a&gt;&lt;br&gt;
    at Logger.makeError (C:\Samuel\Blockchain\Flashloan-arbitrage-bot-uniswap-v2\node_modules\@ethersproject\logger\src.ts\index.ts:269:28)&lt;br&gt;
    at Logger.throwError (C:\Samuel\Blockchain\Flashloan-arbitrage-bot-uniswap-v2\node_modules\@ethersproject\logger\src.ts\index.ts:281:20)&lt;br&gt;
    at checkError (C:\Samuel\Blockchain\Flashloan-arbitrage-bot-uniswap-v2\node_modules\@ethersproject\providers\src.ts\json-rpc-provider.ts:78:20)&lt;br&gt;
    at JsonRpcProvider. (C:\Samuel\Blockchain\Flashloan-arbitrage-bot-uniswap-v2\node_modules\@ethersproject\providers\src.ts\json-rpc-provider.ts:642:20)&lt;br&gt;
    at step (C:\Samuel\Blockchain\Flashloan-arbitrage-bot-uniswap-v2\node_modules\@ethersproject\providers\lib\json-rpc-provider.js:48:23)&lt;br&gt;
    at Object.throw (C:\Samuel\Blockchain\Flashloan-arbitrage-bot-uniswap-v2\node_modules\@ethersproject\providers\lib\json-rpc-provider.js:29:53)&lt;br&gt;
    at rejected (C:\Samuel\Blockchain\Flashloan-arbitrage-bot-uniswap-v2\node_modules\@ethersproject\providers\lib\json-rpc-provider.js:21:65)&lt;br&gt;
    at processTicksAndRejections (node:internal/process/task_queues:96:5) {&lt;br&gt;
  reason: 'execution reverted',&lt;br&gt;
  &lt;strong&gt;code: 'UNPREDICTABLE_GAS_LIMIT',&lt;/strong&gt;&lt;br&gt;
  &lt;strong&gt;method: 'estimateGas',&lt;/strong&gt;&lt;br&gt;
  transaction: {&lt;br&gt;
    from: 'xxxxxxxxxxxxxxxxxxxxxxxxxx',&lt;br&gt;
    to: '0xC3D03e4F041Fd4cD388c549Ee2A29a9E5075882f',&lt;br&gt;
    data: '0x022c0d9f0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000a000000000000000000000000a7564f968608ad09236b794836f93a5b76dfd53d000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000000013100000000000000000000000000000000000000000000000000000000000000',&lt;br&gt;
    accessList: null&lt;br&gt;
  },&lt;br&gt;
  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="&lt;a href="https://mainnet.infura.io/v3/xxxxxxxxxxxxxxxx"&gt;https://mainnet.infura.io/v3/xxxxxxxxxxxxxxxx&lt;/a&gt;", code=SERVER_ERROR, version=web/5.7.1)&lt;br&gt;
      at Logger.makeError (C:\Samuel\Blockchain\Flashloan-arbitrage-bot-uniswap-v2\node_modules\@ethersproject\logger\src.ts\index.ts:269:28)&lt;br&gt;
      at Logger.throwError (C:\Samuel\Blockchain\Flashloan-arbitrage-bot-uniswap-v2\node_modules\@ethersproject\logger\src.ts\index.ts:281:20)&lt;br&gt;
      at C:\Samuel\Blockchain\Flashloan-arbitrage-bot-uniswap-v2\node_modules\@ethersproject\web\src.ts\index.ts:341:28&lt;br&gt;
      at step (C:\Samuel\Blockchain\Flashloan-arbitrage-bot-uniswap-v2\node_modules\@ethersproject\web\lib\index.js:33:23)&lt;br&gt;&lt;br&gt;
      at Object.next (C:\Samuel\Blockchain\Flashloan-arbitrage-bot-uniswap-v2\node_modules\@ethersproject\web\lib\index.js:14:53)&lt;br&gt;
      at fulfilled (C:\Samuel\Blockchain\Flashloan-arbitrage-bot-uniswap-v2\node_modules\@ethersproject\web\lib\index.js:5:58)&lt;br&gt;&lt;br&gt;
      at processTicksAndRejections (node:internal/process/task_queues:96:5) {&lt;br&gt;
    reason: 'processing response error',&lt;br&gt;
    code: 'SERVER_ERROR',&lt;br&gt;
    body: '{"jsonrpc":"2.0","id":56,"error":{"code":-32000,"message":"execution reverted"}}',&lt;br&gt;
    error: Error: execution reverted&lt;br&gt;
        at getResult (C:\Samuel\Blockchain\Flashloan-arbitrage-bot-uniswap-v2\node_modules\@ethersproject\providers\src.ts\json-rpc-provider.ts:142:28)&lt;br&gt;
        at processJsonFunc (C:\Samuel\Blockchain\Flashloan-arbitrage-bot-uniswap-v2\node_modules\@ethersproject\web\src.ts\index.ts:383:22)&lt;br&gt;
        at C:\Samuel\Blockchain\Flashloan-arbitrage-bot-uniswap-v2\node_modules\@ethersproject\web\src.ts\index.ts:320:42&lt;br&gt;&lt;br&gt;
        at step (C:\Samuel\Blockchain\Flashloan-arbitrage-bot-uniswap-v2\node_modules\@ethersproject\web\lib\index.js:33:23)&lt;br&gt;&lt;br&gt;
        at Object.next (C:\Samuel\Blockchain\Flashloan-arbitrage-bot-uniswap-v2\node_modules\@ethersproject\web\lib\index.js:14:53)&lt;br&gt;
        at fulfilled (C:\Samuel\Blockchain\Flashloan-arbitrage-bot-uniswap-v2\node_modules\@ethersproject\web\lib\index.js:5:58)&lt;br&gt;
        at processTicksAndRejections (node:internal/process/task_queues:96:5) {&lt;br&gt;
      code: -32000,&lt;br&gt;
      data: undefined&lt;br&gt;
    },&lt;br&gt;
    requestBody: '{"method":"eth_estimateGas","params":[{"from":"xxxxxxxxxxxxxxxxxxxxxxxx","to":"0xc3d03e4f041fd4cd388c549ee2a29a9e5075882f","data":"0x022c0d9f0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000a000000000000000000000000a7564f968608ad09236b794836f93a5b76dfd53d000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000000013100000000000000000000000000000000000000000000000000000000000000"}],"id":56,"jsonrpc":"2.0"}',&lt;br&gt;
    requestMethod: 'POST',&lt;br&gt;
    url: '&lt;a href="https://mainnet.infura.io/v3/xxxxxxxxxxxxxxxxxxxxx"&gt;https://mainnet.infura.io/v3/xxxxxxxxxxxxxxxxxxxxx&lt;/a&gt;'&lt;br&gt;
  }&lt;br&gt;
}&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;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 &lt;strong&gt;Error: cannot override "gas"&lt;/strong&gt; (see below output error log #2).&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;`const gasLimit = await sushiEthDai.estimateGas.swap(
            !shouldStartEth ? DAI_TRADE : 0,
            shouldStartEth ? ETH_TRADE : 0,
            flashLoanerAddress,
            ethers.utils.toUtf8Bytes('1'), {
                gas: 6721975
            }
          );`
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;&lt;strong&gt;Output Error Log #2&lt;/strong&gt;&lt;br&gt;
&lt;em&gt;Error: cannot estimate gas; transaction may fail or may require manual gas limit &lt;a href="reason="&gt; See: https://links.ethers.org/v5-errors-UNPREDICTABLE_GAS_LIMIT &lt;/a&gt;&lt;br&gt;
    at Logger.makeError (C:\Samuel\Blockchain\Flashloan-arbitrage-bot-uniswap-v2\node_modules\@ethersproject\logger\src.ts\index.ts:269:28)&lt;br&gt;
    at Logger.throwError (C:\Samuel\Blockchain\Flashloan-arbitrage-bot-uniswap-v2\node_modules\@ethersproject\logger\src.ts\index.ts:281:20)&lt;br&gt;
    at checkError (C:\Samuel\Blockchain\Flashloan-arbitrage-bot-uniswap-v2\node_modules\@ethersproject\providers\src.ts\json-rpc-provider.ts:78:20)&lt;br&gt;
    at JsonRpcProvider. (C:\Samuel\Blockchain\Flashloan-arbitrage-bot-uniswap-v2\node_modules\@ethersproject\providers\src.ts\json-rpc-provider.ts:642:20)&lt;br&gt;
    at step (C:\Samuel\Blockchain\Flashloan-arbitrage-bot-uniswap-v2\node_modules\@ethersproject\providers\lib\json-rpc-provider.js:48:23)&lt;br&gt;
    at Object.throw (C:\Samuel\Blockchain\Flashloan-arbitrage-bot-uniswap-v2\node_modules\@ethersproject\providers\lib\json-rpc-provider.js:29:53)&lt;br&gt;
    at rejected (C:\Samuel\Blockchain\Flashloan-arbitrage-bot-uniswap-v2\node_modules\@ethersproject\providers\lib\json-rpc-provider.js:21:65)&lt;br&gt;
    at processTicksAndRejections (node:internal/process/task_queues:96:5) {&lt;br&gt;
  reason: 'execution reverted',&lt;br&gt;
  code: 'UNPREDICTABLE_GAS_LIMIT',&lt;br&gt;
  method: 'estimateGas',&lt;br&gt;
  transaction: {&lt;br&gt;
    from: 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx',&lt;br&gt;
    to: '0xC3D03e4F041Fd4cD388c549Ee2A29a9E5075882f',&lt;br&gt;
    data: '0x022c0d9f0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000a000000000000000000000000a7564f968608ad09236b794836f93a5b76dfd53d000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000000013100000000000000000000000000000000000000000000000000000000000000',&lt;br&gt;
    accessList: null&lt;br&gt;
  },&lt;br&gt;
  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="&lt;a href="https://mainnet.infura.io/v3/xxxxxxxxxxxxxxxxxxxxxxxxxxxxx"&gt;https://mainnet.infura.io/v3/xxxxxxxxxxxxxxxxxxxxxxxxxxxxx&lt;/a&gt;", code=SERVER_ERROR, version=web/5.7.1)&lt;br&gt;
      at Logger.makeError (C:\Samuel\Blockchain\Flashloan-arbitrage-bot-uniswap-v2\node_modules\@ethersproject\logger\src.ts\index.ts:269:28)&lt;br&gt;
      at Logger.throwError (C:\Samuel\Blockchain\Flashloan-arbitrage-bot-uniswap-v2\node_modules\@ethersproject\logger\src.ts\index.ts:281:20)&lt;br&gt;
      at C:\Samuel\Blockchain\Flashloan-arbitrage-bot-uniswap-v2\node_modules\@ethersproject\web\src.ts\index.ts:341:28&lt;br&gt;
      at step (C:\Samuel\Blockchain\Flashloan-arbitrage-bot-uniswap-v2\node_modules\@ethersproject\web\lib\index.js:33:23)&lt;br&gt;&lt;br&gt;
      at Object.next (C:\Samuel\Blockchain\Flashloan-arbitrage-bot-uniswap-v2\node_modules\@ethersproject\web\lib\index.js:14:53)&lt;br&gt;
      at fulfilled (C:\Samuel\Blockchain\Flashloan-arbitrage-bot-uniswap-v2\node_modules\@ethersproject\web\lib\index.js:5:58)&lt;br&gt;&lt;br&gt;
      at processTicksAndRejections (node:internal/process/task_queues:96:5) {&lt;br&gt;
    reason: 'processing response error',&lt;br&gt;
    code: 'SERVER_ERROR',&lt;br&gt;
    body: '{"jsonrpc":"2.0","id":56,"error":{"code":-32000,"message":"execution reverted"}}',&lt;br&gt;
    error: Error: execution reverted&lt;br&gt;
        at getResult (C:\Samuel\Blockchain\Flashloan-arbitrage-bot-uniswap-v2\node_modules\@ethersproject\providers\src.ts\json-rpc-provider.ts:142:28)&lt;br&gt;
        at processJsonFunc (C:\Samuel\Blockchain\Flashloan-arbitrage-bot-uniswap-v2\node_modules\@ethersproject\web\src.ts\index.ts:383:22)&lt;br&gt;
        at C:\Samuel\Blockchain\Flashloan-arbitrage-bot-uniswap-v2\node_modules\@ethersproject\web\src.ts\index.ts:320:42&lt;br&gt;&lt;br&gt;
        at step (C:\Samuel\Blockchain\Flashloan-arbitrage-bot-uniswap-v2\node_modules\@ethersproject\web\lib\index.js:33:23)&lt;br&gt;&lt;br&gt;
        at Object.next (C:\Samuel\Blockchain\Flashloan-arbitrage-bot-uniswap-v2\node_modules\@ethersproject\web\lib\index.js:14:53)&lt;br&gt;
        at fulfilled (C:\Samuel\Blockchain\Flashloan-arbitrage-bot-uniswap-v2\node_modules\@ethersproject\web\lib\index.js:5:58)&lt;br&gt;
        at processTicksAndRejections (node:internal/process/task_queues:96:5) {&lt;br&gt;
      code: -32000,&lt;br&gt;
      data: undefined&lt;br&gt;
    },&lt;br&gt;
    requestBody: '{"method":"eth_estimateGas","params":[{"from":"xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx","to":"0xc3d03e4f041fd4cd388c549ee2a29a9e5075882f","data":"0x022c0d9f0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000a000000000000000000000000a7564f968608ad09236b794836f93a5b76dfd53d000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000000013100000000000000000000000000000000000000000000000000000000000000"}],"id":56,"jsonrpc":"2.0"}',&lt;br&gt;
    requestMethod: 'POST',&lt;br&gt;
    url: '&lt;a href="https://mainnet.infura.io/v3/xxxxxxxxxxxxxxxxxxxxxxxxxx"&gt;https://mainnet.infura.io/v3/xxxxxxxxxxxxxxxxxxxxxxxxxx&lt;/a&gt;'&lt;br&gt;
  }&lt;br&gt;
}&lt;br&gt;
&lt;strong&gt;Error: cannot override "gas"&lt;/strong&gt; (operation="overrides", overrides=["gas"], code=UNSUPPORTED_OPERATION, version=contracts/5.7.0)&lt;br&gt;
    at Logger.makeError (C:\Samuel\Blockchain\Flashloan-arbitrage-bot-uniswap-v2\node_modules\@ethersproject\logger\src.ts\index.ts:269:28)&lt;br&gt;
    at Logger.throwError (C:\Samuel\Blockchain\Flashloan-arbitrage-bot-uniswap-v2\node_modules\@ethersproject\logger\src.ts\index.ts:281:20)&lt;br&gt;
    at C:\Samuel\Blockchain\Flashloan-arbitrage-bot-uniswap-v2\node_modules\@ethersproject\contracts\src.ts\index.ts:304:16&lt;br&gt;&lt;br&gt;
    at step (C:\Samuel\Blockchain\Flashloan-arbitrage-bot-uniswap-v2\node_modules\@ethersproject\contracts\lib\index.js:48:23)&lt;br&gt;&lt;br&gt;
    at Object.next (C:\Samuel\Blockchain\Flashloan-arbitrage-bot-uniswap-v2\node_modules\@ethersproject\contracts\lib\index.js:29:53)&lt;br&gt;
    at fulfilled (C:\Samuel\Blockchain\Flashloan-arbitrage-bot-uniswap-v2\node_modules\@ethersproject\contracts\lib\index.js:20:58)&lt;br&gt;
    at processTicksAndRejections (node:internal/process/task_queues:96:5) {&lt;br&gt;
  &lt;strong&gt;reason: 'cannot override "gas"',&lt;br&gt;
  code: 'UNSUPPORTED_OPERATION',&lt;/strong&gt;&lt;br&gt;
  operation: 'overrides',&lt;br&gt;
  overrides: [ 'gas' ]&lt;br&gt;
}&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;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.&lt;/p&gt;

&lt;p&gt;Any help would be greatly appreciated.&lt;/p&gt;

&lt;p&gt;Thank you,&lt;br&gt;
Samuel&lt;/p&gt;

</description>
      <category>typescript</category>
      <category>node</category>
    </item>
    <item>
      <title>Ethereum contract call methods do not return any values</title>
      <dc:creator>ssadek1976</dc:creator>
      <pubDate>Thu, 15 Sep 2022 14:03:29 +0000</pubDate>
      <link>https://dev.to/ssadek1976/ethereum-contract-call-methods-do-not-return-any-values-5b91</link>
      <guid>https://dev.to/ssadek1976/ethereum-contract-call-methods-do-not-return-any-values-5b91</guid>
      <description>&lt;p&gt;Hi there,&lt;/p&gt;

&lt;p&gt;I have a problem when running the following 4 lines of code from the main JS script (see below):&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;await uniswapFactory.getPair(daiAddress, wethAddress)&lt;/li&gt;
&lt;li&gt;await sushiFactory.getPair(daiAddress, wethAddress),&lt;/li&gt;
&lt;li&gt;const uniswapReserves = await uniswapDaiEth.getReserves();&lt;/li&gt;
&lt;li&gt;const sushiReserves = await sushiEthDai.getReserves();&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;For the first two, if I substituted them with hardcoded token pair addresses from Etherscan into the code it works. If I run the first two directly into Truffle console it resolves the pair addresses but strangely enough it doesn´t resolve when I execute the JS script!&lt;/p&gt;

&lt;p&gt;For the above two .getReserves() function calls it doesn´t retrieve any of the reserve values unless if I ran them as they are under Truffle console environment then it retrieves them OK.&lt;/p&gt;

&lt;p&gt;I appreciate your assistance here as it´s been bugging me for the full last two days and am running out of options to resolve this.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Full JS script&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;`require('dotenv').config();&lt;br&gt;
const { INFURA_API_KEY, PRIVATE_KEY } = process.env;&lt;br&gt;
const { ethers } = require('ethers');&lt;/p&gt;

&lt;p&gt;const UniswapV2Pair = require(".././build/contracts/IUniswapV2Pair.json");&lt;br&gt;
const UniswapV2Factory = require('.././build/contracts/IUniswapV2Factory.json');&lt;/p&gt;

&lt;p&gt;const daiAddress = "0x6B175474E89094C44Da98b954EedeAC495271d0F";&lt;br&gt;
const wethAddress = "0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2";&lt;/p&gt;

&lt;p&gt;const privateKey = process.env.PRIVATE_KEY;&lt;br&gt;
const infuraProvider = new ethers.providers.InfuraProvider('mainnet', process.env.INFURA_API_KEY);&lt;br&gt;
const wallet = new ethers.Wallet(privateKey, infuraProvider);&lt;/p&gt;

&lt;p&gt;const testBasic = async () =&amp;gt; {&lt;br&gt;
  const uniswapFactory = new ethers.Contract(&lt;br&gt;
    "0x5C69bEe701ef814a2B6a3EDD4B1652CB9cc5aA6f",&lt;br&gt;
    UniswapV2Factory.abi, &lt;br&gt;
    wallet&lt;br&gt;
  );&lt;/p&gt;

&lt;p&gt;const sushiFactory = new ethers.Contract(&lt;br&gt;
    "0xC0AEe478e3658e2610c5F7A4A2E1777cE9e4f2Ac",&lt;br&gt;
    UniswapV2Factory.abi, &lt;br&gt;
    wallet&lt;br&gt;
  );&lt;/p&gt;

&lt;p&gt;let uniswapDaiEth;&lt;br&gt;
  let sushiEthDai;&lt;/p&gt;

&lt;p&gt;const loadPairs = async () =&amp;gt; {&lt;br&gt;
    uniswapDaiEth = new ethers.Contract(&lt;br&gt;
      await uniswapFactory.getPair(daiAddress, wethAddress),&lt;br&gt;
      UniswapV2Pair.abi, &lt;br&gt;
      wallet&lt;br&gt;
    );&lt;br&gt;
    sushiEthDai = new ethers.Contract(&lt;br&gt;
      await sushiFactory.getPair(daiAddress, wethAddress),&lt;br&gt;
      UniswapV2Pair.abi, &lt;br&gt;
      wallet&lt;br&gt;
    );&lt;br&gt;
  };&lt;br&gt;
  await loadPairs();&lt;/p&gt;

&lt;p&gt;infuraProvider.on('block', async (blockNumber) =&amp;gt; {&lt;br&gt;
    try {&lt;br&gt;
      const uniswapReserves = await uniswapDaiEth.getReserves();&lt;br&gt;
      const sushiReserves = await sushiEthDai.getReserves();&lt;br&gt;
    } catch (err) {&lt;br&gt;
      console.error(err);&lt;br&gt;
    }&lt;br&gt;
  });&lt;br&gt;
};&lt;/p&gt;

&lt;p&gt;testBasic();`&lt;/p&gt;

&lt;p&gt;Thank you very much for your help!&lt;/p&gt;

&lt;p&gt;Best, Samuel&lt;/p&gt;

</description>
    </item>
  </channel>
</rss>
