i created a contract in Remix to get the reserves of a pair on Uniswap, and it works fine, but when i try to do the same thing using the Sushiswap factory address the function gives me a "LiquidityValueCalculator.pairInfo errored: execution reverted" error. Up to now using other contracts i have created a pair and added/removed liquidity in Uniswap and Sushiswap by changing only the factory address, but when it comes to get reserves it doesn't work. Where am i wrong?
Addresses used:
UniswapV2Factory: 0x5C69bEe701ef814a2B6a3EDD4B1652CB9cc5aA6f
SushiV2Factory: 0xc35DADB65012eC5796536bD9864eD8773aBc74C4
// SPDX-License-Identifier: MIT
pragma solidity =0.6.6;
import "@uniswap/v2-periphery/contracts/libraries/UniswapV2Library.sol";
import "@uniswap/v2-core/contracts/interfaces/IUniswapV2Pair.sol";
contract LiquidityValueCalculator {
address public factory;
constructor(address factory_) public {
factory = factory_;
}
function pairInfo(address tokenA, address tokenB) public view returns (uint reserveA, uint reserveB, uint totalSupply) {
IUniswapV2Pair pair = IUniswapV2Pair(UniswapV2Library.pairFor(factory, tokenA, tokenB));
totalSupply = pair.totalSupply();
(uint reserves0, uint reserves1,) = pair.getReserves();
(reserveA, reserveB) = tokenA == pair.token0() ? (reserves0, reserves1) : (reserves1, reserves0);
}
}