# Swaps

## Introduction

Token swaps are conducted by calling the router by calling for a specific input or output of a pair of tokens, or with native currency `AVAX | BNB | ETH`.

## Individual Swap

Swaps in Liquidity Book may cross one or mre bins inside a token pair contract called `LBPair`. Starting from the active bin, it will consume the liquidity of the bin until reaching the desired amount or emptying the bin. When a bin is empty, liquidity will be taken in the next closest bin at the exchange rate defined by the bin. This bin then becomes the active bin of the pair.

## Liquidity Book Router

Swaps on Liquidity Book can be executed through a router contract called `LBRouter`. This contract will abstract some of the complexity of the swap and allow chained swaps accross several pairs.

On Liquidity Book, it is possible for several `LBPair` with the same tokens to be created, differentiated only by the `binStep` parameter.

When asking the router to do a swap, every swap step will be described using `(tokenIn, tokenOut, binStep)`.

The `LBRouter` contract is also compatible with Joe V1 pairs. To swap on a V1 pair, `binStep` must be set to zero.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://developers.lfj.gg/concepts/swaps.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
