Skip to main content

Overview

Flow: Swapping tokens

The swap flow is executed when a user intends to swap one token for another through a pool. This token can either be a jetton or native TON. There are three ways a user can swap tokens.

The first way is possible only when the pool is a native pool (that is, the second token in the pool is native TON). In this case, users are able to directly execute an op::swap operation on the pool to swap TON for the other token in the pool (which will always be a jetton).

The second way is possible for both native and non-native pools. This method is used if the user wants to swap a jetton for native TON or a jetton for another jetton. They must send an op::transfer_notification operation from their jetton wallet with a specifically formatted payload. If this jetton is not one of the tokens in this pool, then it is refunded. Assuming the correct jetton was sent, Pool will forward swap operation to active Range contract.

Flow: Add liquidity

The add-liquidity flow is executed when a user intends to provide liquidity to the pool. The user can choose to provide one or two assets at a time and receive LP tokens in return. There are three ways to provide liquidity.

The first way is possible only when the pool is a native pool. The user is able to directly execute an op::add_liquidity operation on the pool to provide one-side liquidity in TON.

The second way is to forward TON and the op::add_both_liquidity operation with the op::transfer_notification operation to deposit a jetton and TON. If the jetton is not one of the tokens in this pool or if the pool is not native, the assets will be refunded.

The last way is to forward the op::add_liquidity operation with the op::transfer_notification operation to deposit a jetton. If the jetton is not one of the tokens in this pool, it will be refunded.