1

Is there a simple way to get a list of LP-holders for a particular Uniswap/Pancakeswap pair? I need to know the addresses of people who has provided liquidity for my token (which has been already added to UNI/PAN)

Since the Pair contract has only balanceOf() function which is mapping, it's impossible to read the whole list without knowing the mapping keys

The only somehow humane way I think to do this - is to use Infura (or some other node), subscribe to 'Pair.mint()' event and trigger some of my contract functions when this event occurs. But I find this method pretty ugly

Maybe there are some better ways? Thanks

PS. leaving the link to 'Pair' contract of Pancakeswap here, just in case

fewrandom
  • 13
  • 4

1 Answers1

0

Getting the list of LP token holders is not different from getting a list of any ERC-20 token holders. The LP token is not different from other tokens: it has its own ERC-20 contract, contract address, methods, etc.

The recommended method is to build a database of all ERC-20 Transfer events, keep it updated in real-time and then from this database extract your snapshots.

Here is one generic get ERC-20 token holders answer.

You could also try to solve the problem with TheGraph subquery. You can also construct a Dune Analytics query like this one. In both of these cases, there is a third party that maintains an existing large database with efficient indexing that you can query against.

Mikko Ohtamaa
  • 22,269
  • 6
  • 62
  • 127