I'm trying to implement 1inch exchange's getExpectedReturnWithGasMulti
method in ethers.js. The contract is deployed at: https://etherscan.io/address/0x6e858ea1015e1c8da176f057d74dae0f35675aeb
When I try and call the getExpectedReturnWithGasMulti
using the etherscan contract interface with the following parameters:
tokens: [0x6B175474E89094C44Da98b954EedeAC495271d0F,0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48,0x6B175474E89094C44Da98b954EedeAC495271d0F]
amount: 100000000000000
parts: [100,100]
flags: [0,0]
destTokenEthPriceTimesGasPrices: [10000000000,10000000000]
The contract returns a logical, valid response:
[ getExpectedReturnWithGasMulti method Response ] returnAmounts uint256[] : 1833,3544684228302442 estimateGasAmount uint256 : 600000 distribution uint256[] : 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,25700,0,0,0,0,0,0,0,0,0
Now when I try to call the method using ethers.js
with the same parameters:
require("dotenv").config();
const { ethers } = require("ethers");
const BN = require("bn.js");
const oneInchAbi = require("./abis/1inch.json"); // copied from etherscan
const httpProvider = new ethers.providers.JsonRpcProvider("https://mainnet.infura.io/v3/" + process.env.INFURA_KEY);
let wallet = ethers.Wallet.fromMnemonic(process.env.MNEMONIC)
wallet = wallet.connect(httpProvider);
const onesplitContract = new ethers.Contract("0x6E858eA1015E1C8da176F057D74dae0f35675aEb", oneInchAbi, wallet.provider);
(async () => {
const resMulti = await onesplitContract.functions.getExpectedReturnWithGasMulti(
["0x6B175474E89094C44Da98b954EedeAC495271d0F", "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48", "0x6B175474E89094C44Da98b954EedeAC495271d0F"],
"100000000000000",
["100", "100"],
["0","0"],
["10000000000","10000000000"]
);
})()
The transaction is reverted
Error: call revert exception (method="getExpectedReturnWithGasMulti(address[],uint256,uint256[],uint256[],uint256[])", errorSignature=null, errorArgs=[null], reason=null, code=CALL_EXCEPTION, version=abi/5.0.2)