# Swaps & Pricing

Swapping is the process of exchanging tokens, where one token is exchanged for a proportional amount of the desired token, minus the swap fee. This is one of the primary ways to interact with the Nitro Fused Trade Ledger.

## **How it works**

* Users initiate a trade, specifying the token they wish to sell and the token they wish to receive.
* The system computes the output based on the active bin’s price and available reserves.
* If liquidity in the active bin is depleted, the protocol activates the nearest bin with available reserves, ensuring uninterrupted trading.

### **Example:**

* A user sells 2 NAD to receive USDC.
* **Active Bin Price**: 1002 USDC/NAD.
* **Active Bin Reserves**: 7 NAD and 8000 USDC.

**Calculation**:&#x20;

$$\Delta y = P \times \Delta x$$\
\
**Where:**

* $$P$$: Active bin price (1002 USDC/NAD).
* $$\Delta x$$: Amount of NAD being sold (2 ).
* $$\Delta y$$: Amount of USDC received.

$$\Delta y = 1002 \times 2 = 2004 , \text{USDC}$$

{% hint style="success" %}
Swap fees, if applied, are deducted from the final output, slightly reducing the amount received.
{% endhint %}

## **Swap Pricing Dynamics**

Nitro’s bin-based pricing mechanism ensures efficient price adjustments during swaps. Each bin corresponds to a unique price point, and prices adjust as bins are activated through trades.

<figure><img src="/files/Wo2PrCDSbyTWfXyZVxa3" alt="" width="375"><figcaption></figcaption></figure>

### **Case 1: Price Decrease**

**Example: USDC/NAD Pool Setup:**

* **Active Bin**: 1002 USDC/NAD, Reserves: 7 NAD and 8000 USDC.
* **Nearest Bin Below**: 1000 USDC/NAD, Reserves: 0 NAD and 5000 USDC.

A user sells **8 NAD**, depleting all USDC in the active bin before the trade is fully filled.

**Outcome**:

* The protocol activates the nearest bin below (1000 USDC/NAD), which contains USDC reserves to complete the trade.
* This results in a **price decrease** for NAD, reflecting the increased market demand for USDC.

### **Case 2: Price Increase**

**Example: USDC/NAD Pool Setup:**

* **Active Bin**: 1002 USDC/NAD, Reserves: 7 NAD and 8000 USDC.
* **Nearest Bin Above**: 1005 USDC/NAD, Reserves: 12 NAD and 0 USDC.

A user sells 9**000 USDC**, depleting all NAD in the active bin before the trade is fully filled.

**Outcome**:

* The protocol activates the nearest bin above (1005 USDC/NAD), which contains NAD reserves to complete the trade.
* This results in a **price increase** for NAD, reflecting the market demand for NAD.

## SWAP ARCHITECTURE

<figure><img src="/files/Rv2ohL053VCI0ZjKJ6Gi" alt=""><figcaption></figcaption></figure>


---

# 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://nitro-finance.gitbook.io/ftl/core-interactions/swaps-and-pricing.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.
