Liquidity

To be able to swap 2 tokens at any time we need liquidity and to add liquidity we need to send a "proof of deposit" to users (Liquidity Pool token)

    #[only_owner]
    #[payable("EGLD")]
    #[endpoint(issueLpToken)]
    
    issueLpToken@first_token(mid)@second_token(mex)@LPname@LpTicker

At this stage only the owner of the contract (us) can call the function to create a new liquidity pool. If you want to enable swap on our application please contact us.

Must send 0,05 EGLD to pay ESDT creation

The resulting esdt ticker will be saved in pool information

#[endpoint(setLocalRoles)]

setLocalRoles@first_token(mid)@second_token(mex)

We need to call this function once to allow the SC to mint and burn the LP token

   #[payable("*")]
   #[endpoint(addLp)]
   fn add_lp(&self)
   
   MultiESDTNFTTransfer
   @erd1qqqqqqqqqqqqqpgqgdf6vk43c2jxk4a6nw2adv8vmnpqagegtxfqmf8et2(SC)
   @2(2 tokens)
   @MID-ecb7bf(first ticker)
   @0(nonce)
   @4000000000000000000000 (first token qty)
   @MEX-455c57 (second token)
   @0(nonce)
   @12000000000000000000000000 (second token qty)
   @addLp

Exemple: https://explorer.multiversx.com/transactions/3b58877b00280ee5ff5c7d02423dfc0f0d42a726c1682aaac38f94163a6e5589

If this is the very first deposit, the SC will consider the two amounts as the exchange ratio to be applied

If it is an addition of liquidity, the contract will calculate the maximum possible ratio and return the surplus to the user.

In both cases, the user will receive an amount of LP tokens corresponding to his participation rate in the liquidity provision

    #[payable("*")]
    #[endpoint(removeLp)]
    fn remove_lp(&self, first_token: TokenIdentifier, second_token: TokenIdentifier)

The user can send his LP tokens to the SC by specifying the pairs concerned, he will receive in exchange his shares of the liquidity in place.

Last updated