Search code examples
solidityhardhat

How do I test swap pair in Hardhat?


I used the factory contract to create the pair contract, how do I get an instance of the pair contract in Hardhat. Used to query the LP value of an account


Solution

  • The title of the question and the content is far different.

    If you're using the factory, then there's a function getPair, which returns you the address of the pair.

    function getPair(address tokenA, address tokenB) external view returns (address pair);
    

    When you have the pair address, you can fetch the number of tokens in the pair using getReserve function