Swaps

Token swaps within the Liquidity Book are facilitated through the router, allowing users to specify either the input or output of a pair of tokens, or utilize native currencies like AVAX, APT, or ETH.

Individual Swap

In Liquidity Book, swaps can traverse one or multiple bins within a token pair contract known as LBPair. Beginning from the active bin, liquidity is utilized from the bin until the desired amount is reached or the bin is depleted. If a bin becomes empty, liquidity is sourced from the nearest available bin at the exchange rate defined by that bin. Subsequently, this bin becomes the active bin for the pair.

Liquidity Book Router

Swaps on the Liquidity Book platform are executed via a router contract named LBRouter. This contract abstracts some of the intricacies of the swap process and facilitates chained swaps across multiple pairs.

Multiple LBPair contracts with the same tokens can exist on Liquidity Book, differentiated solely by the binStep parameter.

When requesting a swap through the router, each step of the swap is defined by the tokens involved and the binStep parameter.

The LBRouter contract is compatible with Lyd V1 pairs as well. To swap on a V1 pair, the binStep must be set to zero.

Last updated