# Swap

## What is Swap?

Swap is **AMM**(automated market maker) for providing liquidity and trading EOSIO tokens on EOS. It eliminates trusted intermediaries and unnecessary forms of rent extraction, allowing for safe, accessible, and efficient exchange activity. The protocol is non-upgradable and designed to be censorship resistant.

## How swap works?

![](/files/irio8QfgclFAxytSFUBP)

Swap is an *automated liquidity protocol* powered by a [constant product formula](https://docs.uniswap.org/protocol/V2/concepts/protocol-overview/glossary#constant-product-formula) and implemented in a system of non-upgradeable smart contracts on the [EOSIO](https://eos.io/) blockchain. It obviates the need for trusted intermediaries, prioritizing **decentralization**, **censorship resistance**, and **security**.&#x20;

Smart contract manages a liquidity pools made up of reserves of two EOSIO tokens.

Anyone can become a liquidity provider (LP) for a pool by depositing an equivalent value of each underlying token in return for pool tokens. These tokens track pro-rata LP shares of the total reserves and can be redeemed for the underlying assets at any time.<br>

![](/files/r7sHB47ZDN8aeO6fZf2X)

Pairs act as automated market makers, standing ready to accept one token for the other as long as the “constant product” formula is preserved. This formula, most simply expressed as `x * y = k`, states that trades must not change the product (`k`) of a pair’s reserve balances (`x` and `y`). Because `k` remains unchanged from the reference frame of a trade, it is often referred to as the invariant. This formula has the desirable property that larger trades (relative to reserves) execute at exponentially worse rates than smaller ones.\
\
In practice, Swap applies a 0.25% fee to trades, 0.20% is added to reserves and the remaning 0.05% withheld as a protocol-wide charge. As a result, each trade actually increases `k`. This functions as a payout to LPs, which is realized when they burn their pool tokens to withdraw their portion of total reserves.

![](/files/ren5GA3yZSLApE91arFc)

Because the relative price of the two pair assets can only be changed through trading, divergences between the Swap price and external prices create arbitrage opportunities. This mechanism ensures that Swap prices always trend toward the market-clearing price.

## Further reading

\ <br>


---

# 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://docs.a-dex.io/products/swap.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.
