Create Pool
Now let's create a new pool utilizing Router. First of all, deploy your new own coin just for test:
Test coin for new pool
Extend the example from the previous guide and add a new function:
Create a new pool
The function above creates a new pool for your coin:
MyCoin/AptosCoin
. As Uncorrelated generic provided, the formula for the pool would be standard one: x*y=k
.It's very important to follow the rule about generic sorting as otherwise, the function would abort.
In the same way, you can create a stable pool by use
Stable
generic:Create stable pool
Let's add liquidity to new pool:
Adding liquidity to our new pool
As you can see above,
add_liquidity
allows to add liquidity to the newly created pool and then deposit the remainders of both X
and Y
coins back in the account, together with the new LP
coins.Similarly, you can add liquidity to any other pool: replace
MyCoin
and AptosCoin
with other coins.When working with real-world examples, it's better to deposit liquidity immediately during the same transaction with which you create a pool. We also recommend using slippage values for the amount of the LP tokens you'll get in exchange for your liquidity.
Let's say we want to add liquidity to an existing
BTC/Aptos
pool created by the Pontem team:Adding liquidity to an existing pool
When working with real-world examples, it's better to deposit liquidity immediately during the same transaction with which you create a pool. We also recommend using slippage values for the amount of the LP tokens you'll get in exchange for your liquidity.
Last modified 8mo ago