1

I am new to the DEX development. Am using pancakeswap router contract https://testnet.bscscan.com/address/0xd99d1c33f9fc3444f8101754abc46c52416550d1

Using ethers.js to call contracts.

addLiquidityETH is working to add the liquidity in the DEX. I need to display a list. Which method I need to call in router or in factory contract to display the liquidity added details like below image

Liquidity List

Need to display the list while loading. We don't have any pairaddress to call IERC20(pair).balanceOf(address). I didnt understand what was the logic behind to display the list by getting pairaddress first and then get the balance

Thanks in Advance

1 Answer 1

0

As per the docs, the amount of tokens representing the liquidity you have added are returned under the liquidity parameter

If it wasn't your first time adding liquidity for the pair, then you can calculate the overall balance by using

IERC20(pair).balanceOf(your_address);

7
  • Thanks. Need to display the list while loading. We don't have any pairaddress to call this code. I didnt understand what was the logic behind to display the list by getting pairadress and then get the balance. Jul 5, 2021 at 15:00
  • Oh, I misunderstood then. If you want to get the list of LP tokens for a given address, then you need to somehow keep track of the event logs like Transfer. Some API's like Covalent/Etherscan will do this for you, and you can just then filter them out.
    – Smye
    Jul 5, 2021 at 16:22
  • Thanks @Smye Do you know whether the BSCscan will give these information in BSC? Jul 5, 2021 at 16:41
  • I believe so as it is essentially the same as Etherscan - but you will need to double check
    – Smye
    Jul 5, 2021 at 16:42
  • Ok. If we want to find LP-Tokens in Etherscan. We have to call Get a list of "ERC20 - Token Transfer Events" by Address API right? Jul 5, 2021 at 16:56

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.