Pangolin — how are Liquidity Pools created through smart contracts?

hariseldon
3 min readFeb 25, 2021

--

Pangolin is a DEX on the Avalanche blockchain. It’s based on Uniswap and in this post I’ll go through how you can explore how it works.

Since Pangolin is based on Uniswap you can read the original white paper here if you’d like to understand more about some of the underlying concepts.

This post is going to detail how you can explore what’s happening behind the scenes when you interact with Pangolin through the front end.

The Uniswap whitepaper explains how the smart contracts will work rather well:

If you take Uniswap’s direction, you’ll see they use a factory contract. Pangolin has this factory contract live on the C Chain which you can view below:

The source code, for anyone interested, can be found here.

Within the source code you can see that an event is exposed called PairCreated This event can then be viewed within the Avax explorer to see all the Pairs that have been created.

It’s important to note that this appears to be different from Uniswap v1, which has a separate contract for each ERC20 token. Whereas Pangolin appears to have a contract for each Pair which then holds the token’s balances.

So if we look at the Pangolin Factory contract we can navigate to the logs to see what’s happening under the hood

We can now open the contracts associated with token0 and token1

We can now see that the Pair created was between Pangolin (PNG) and yearn.finance (YFI)

Let’s now take a look at the pair:

Important to take note that under the Address appears the text “Pangolin Liquidity (PGL)”. This indicates that this address holds a Pangolin exchange liquidity pair and if we navigate to Tokens we can actually see this is the case.

And that’s how we can view the audit trail of a Pangolin Liquidity Pool. We can see the locked/vested Tokens balances of PNG at 5,923 and YFI at 0.835.

In the next post, we’ll go through programmatically interacting with the Pangolin Factory on the Fuji testnet.

If you’re anxious to get started and can’t wait, you can find the Pangolin Factory on Fuji below:

Please let me know in the comments if I’ve gotten anything wrong :)

--

--

hariseldon
hariseldon

Responses (1)