Swap examples
This section contains example schemes for swap operations
Simple swap with referral
Simple swap of one token to another.
Bob
is user doing the swap, Alice
is referral, Send
is send token, Receive
is receive token.
Cross-swap on the same Router
Swap of one token to another using an intermediary token. This method is used if there's no available pool for a pair of tokens but there're pools for each token and some other (the same for both) intermediary token. This type of swap is not limited to 1 intermediary: in practice an arbitrary amount of intermediaries can be used. This type of swap can be combined with cross-swap using multiple Routers
.
Bob
is user doing the swap, Send
is send token, Mid
is intermediary token, Receive
is receive token.
Cross-swap using multiple Routers
Swap of one token to another using different Routers
. This method is used if there's no available pool for a pair of tokens on the same Router but there're pools for each token and some other (the same for both) intermediary token on both Routers
. This type of swap is not limited to 1 intermediary: in practice an arbitrary amount of intermediaries can be used. This type of swap can be combined with cross-swap on the same Router
.
Bob
is user doing the swap, Send
is send token, Mid
is intermediary token, Receive
is receive token.
Refund swap
Refund swap if there's not enough liquidity in the pool or the expected amount of receive tokens is less than expected minimum. Since multi-contract transactions in TON are not atomic it is not possible to fully refund cross swap (on the same router or multiple), in such event the user will receive some intermediate token based on the pool used to route the swap.
Bob
is user doing the swap, Send
is send token, Receive
is receive token.
Last updated