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:

Δy=P×Δx\Delta y = P \times \Delta x Where:

  • PP: Active bin price (1002 USDC/NAD).

  • Δx\Delta x : Amount of NAD being sold (2 ).

  • Δy\Delta y: Amount of USDC received.

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

Swap fees, if applied, are deducted from the final output, slightly reducing the amount received.

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.

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 9000 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

Last updated