Uniswap / v2-periphery

🎚 Peripheral smart contracts for interacting with Uniswap V2
https://uniswap.org/docs
GNU General Public License v3.0
1.11k stars 1.67k forks source link

unexpected amount of data error in UniswapV2Library.sol #134

Closed Samboy76 closed 1 year ago

Samboy76 commented 1 year ago

Hello,

When I execute the following function in UniswapV2Library.getReserves(address factory, address tokenA, address tokenB) it returns Error: Transaction reverted: function returned an unexpected amount of data Take note factory is Sushiswap factory address, token0 and token1 are 1INCH and WETH token addresses respectively on mainnet.

(reserve0, reserve1,) = IUniswapV2Pair(pairForSushiswap(factory, token0, token1)).getReserves();

function pairForSushiswap(address factory, address tokenA, address tokenB) internal pure returns (address pair) {
        (address token0, address token1) = sortTokens(tokenA, tokenB);
        pair = address(uint160(uint(keccak256(abi.encodePacked(
                hex'ff',
                factory,
                keccak256(abi.encodePacked(token0, token1)),
                hex'34a26ac00aeedff252c746538fd4d97e26d9bc7e1d5a32b31c6e3cdea7c6147d' // init code hash
            )))));
    }

_Error: Transaction reverted: function returned an unexpected amount of data at FlashloanArbitrage.getReserves (contracts/UniswapV2Library.sol:74) at FlashloanArbitrage.getAmountsIn (contracts/UniswapV2Library.sol:124) at FlashloanArbitrage.uniswapV2Call (contracts/FlashloanArbitrage.sol:110) at . (0x86f518368e0d49d5916e2bd9eb162e9952b7b04d) at FlashloanArbitrage.startArbitrage (contracts/FlashloanArbitrage.sol:50) at processTicksAndRejections (node:internal/process/task_queues:96:5) at EthModule._estimateGasAction (C:\Samuel\Blockchain\Flashloan-arbitrage-bot-uniswapV2_hardhat\node_modules\hardhat\src\internal\hardhat-network\provider\modules\eth.ts:429:7) at HardhatNetworkProvider._sendWithLogging (C:\Samuel\Blockchain\Flashloan-arbitrage-bot-uniswapV2_hardhat\node_modules\hardhat\src\internal\hardhat-network\provider\provider.ts:139:22) at HardhatNetworkProvider.request (C:\Samuel\Blockchain\Flashloan-arbitrage-bot-uniswapV2_hardhat\node_modules\hardhat\src\internal\hardhat-network\provider\provider.ts:116:18) at JsonRpcHandler._handleRequest (C:\Samuel\Blockchain\Flashloan-arbitrage-bot-uniswapV2_hardhat\node_modules\hardhat\src\internal\hardhat-network\jsonrpc\handler.ts:188:20) at JsonRpcHandler._handleSingleRequest (C:\Samuel\Blockchain\Flashloan-arbitrage-bot-uniswapV2_hardhat\node_modules\hardhat\src\internal\hardhat-network\jsonrpc\handler.ts:167:17) at Server.JsonRpcHandler.handleHttp (C:\Samuel\Blockchain\Flashloan-arbitrage-bot-uniswapV2_hardhat\nodemodules\hardhat\src\internal\hardhat-network\jsonrpc\handler.ts:52:21)

Any clues please?

Samboy76 commented 1 year ago

Closing issue as n/a