LpProvide examples

This section contains example schemes for liquidity provision

Deposit liquidity (both tokens)

Liquidity provision is done via 2 transactions: deposit of the first token and deposit of the second token.

Deposit of the first token

The amount of the first token sent is stored on a user's lp account awaiting a transaction of the second token.

Deposit of the second token

When the second token is sent, lp account automatically initiates liquidity addition into the pool. As a result, full amounts of deposited tokens are used as new liquidity and the user receives lp tokens.


  • the Lp Account contract is deleted on cb_add_liquidity in order to not pay storage fees (each deposit sends state init so it will be redeployed as soon as any new deposit occurs)

  • when depositing initial liquidity 0.000001001 lp tokens will be reserved on pool, the rest of liquidity will be sent to the user

Deposit liquidity (single side provision)

It is possible to deposit liquidity by sending just 1 type of token, the pool will automatically perform a swap and use the resulting amount to mint lp tokens

Deposit liquidity (with payload)

It is possible to specify who will receive lp tokens and to include a payload which will be sent as transfer_notification (e.g. Farm contract)

Chain liquidity swap and provision

Custom payload allows a user to chain swap operation and lp provision in a single transaction

Refund deposited liquidity

In the event that the issued amount of lp tokens doesn't match the specified minimum value, all deposited liquidity is returned to lp account and can be withdrawn by user.

Liquidity is refunded to lp account

Withdraw refunded liquidity

Withdraw liquidly

Liquidly is withdrawn from a pool by burning lp tokens, a user then receives both pool tokens based on the current exchange rate.

Providing already deposited liquidity

A user can deposit liquidity after it was refunded to lp account without doing a withdraw.

Last updated