# Fees

Sai charges some of the lowest trading fees in the perpetual futures market. Taker fees start at a 0.05% base rate, and no fee is taken out for deposits or withdrawals. When factoring in zero gas costs and available discounts, Sai is one of the most competitive exchanges for active futures traders.

## Trading Fee Reference

| Fee Type                | Rate              | Description                                                                                     |
| ----------------------- | ----------------- | ----------------------------------------------------------------------------------------------- |
| Taker Fee               | 0.05% (Base Rate) | Charged on the total position size for taker orders.                                            |
| Taker Fee with Referral | 0.0425%           | The default and minimum referral code discount on Sai is 15% of trading fees.                   |
| Gas Fees for Trading    | 0 (Free)          | Always zero on Sai's L1, Nibiru.                                                                |
| Trigger Fee             | 0.01%             | Charged only on automated orders (Limit, Stop Loss, Take Profit) to pay for the execution cost. |
| Deposits & Withdrawals  | 0 (\*)            | Always zero on Sai's L1, Nibiru. However, gas is required to bridge before depositing.          |
| Maker Fee               | 0 (Free)          | No fee is charged for maker orders.                                                             |

Standard trading fees are calculated based on your total **position size** (leverage × collateral), not just your wallet balance.

#### Contents

* [Fees on Sai](#fees-on-sai)
* [Trading Fee Reference](#trading-fee-reference)
* [Key Concepts](#key-concepts)
* [Where Fees are Distributed](#where-fees-are-distributed)
* [Fee Lifecycle](#fee-lifecycle)
  * [1. Opening a Trade](#1-opening-a-trade)
  * [2. Closing a Trade](#2-closing-a-trade)
* [Liquidation Mechanics](#liquidation-mechanics)
  * [Key Difference: Collateral vs. Position](#key-difference-collateral-vs-position)
  * [The Liquidation Penalty](#the-liquidation-penalty)
  * [Priority of Payments (The "Waterfall")](#priority-of-payments-the-waterfall)
  * [Liquidation Example](#liquidation-example)
* [Insufficient Collateral](#insufficient-collateral)

## Key Concepts

* **Base Fees:** Every trade has base percentages for taker, maker, and conditional (trigger) orders.
* **Fee Multipliers:** The base fees are adjusted by two multipliers:
  1. **Tier-based:** High-volume traders earn points, which unlock a lower fee multiplier.
  2. **Referral:** Referred traders receive a discount multiplier.
* **Effective Multiplier:** The lowest of the applicable multipliers is used to calculate the final fee.
* **Liquidation Fees:** These are a fixed percentage of the collateral and are not subject to the multipliers.

## Where Fees are Distributed

* **The Vault (LPs):** Receives 25% of all Closing Fees to support platform stability and reward Liquidity Providers for their risk.
* **The Protocol (Gov):** Receives the remaining 75% of Closing Fees and 100% of Open Fees. A portion of these fees is allocated to a pool for governance stakers.
* **Referrers:** Earn a percentage of the fees generated by their referees from the governance staker portion.
* **Keepers (Bots):** Receive 20% of the Trigger Fee for executing automated orders (Limit, Stop Loss, Take Profit); the remaining 80% goes to the Protocol.

## Fee Lifecycle

### 1. Opening a Trade

When a user opens a trade, the system performs the following steps to calculate and process fees:

1. **Determine Multiplier:** It fetches the trader's fee tier and checks for a referral discount to find the **effective fee multiplier**.
2. **Calculate Fees:** The system calculates the adjusted open and trigger fees by applying the effective multiplier to the base fees.
3. **Deduct and Distribute:** The total fee is deducted from the trader's collateral and distributed. A portion goes to the trigger service provider (if applicable), a cut is allocated to the referrer, and the net amount is added to a pool for governance stakers.

### 2. Closing a Trade

When a user closes a trade, fees are handled differently depending on whether it's a normal closure or a liquidation.

* **Normal Closure:** The system determines the effective multiplier, calculates adjusted close fees, and distributes them.
* **Liquidation:** The fee is a fixed percentage of the trader's collateral, bypassing any fee tier or referral discounts. This fee is then split between the vault and governance stakers.

## Liquidation Mechanics

Liquidation occurs when your remaining collateral can no longer safely support your open position. At that point, the protocol force-closes the trade to protect the vault from bad debt.

### Key Difference: Collateral vs. Position

Standard trading fees are based on position size. Liquidation fees are different: they are calculated from your **remaining collateral** at the time the position is liquidated. Fee-tier and referral discounts do not apply.

### The Liquidation Penalty

When a position is liquidated, a **10% liquidation penalty** is applied to the remaining collateral. The penalty is split into two equal components:

1. **Closing Component (5% of Collateral):**
   * Compensates the system for closing the position.
   * Split: 20% goes to the Vault; 80% goes to the Protocol.
2. **Trigger Component (5% of Collateral):**
   * Rewards the liquidator or keeper that triggered the liquidation.
   * Split: 20% goes to the Liquidator; 80% goes to the Protocol.

### Priority of Payments (The "Waterfall")

If a user is liquidated and their collateral is nearly empty (insufficient to cover the full fees), the smart contract pays out in a specific priority order to protect the system:

1. **First Priority → The Vault:** The Vault gets its share first to ensure Liquidity Providers are protected.
2. **Second Priority → The Liquidator:** The bot gets its reward next.
3. **Third Priority → The Protocol:** The Government receives whatever is left.

### Liquidation Example

You are liquidated while you have $100 of collateral remaining.

* **Total Penalty Calculation:** $10.00 (10% of $100).
* **Distribution:**
  * $1.00 goes to the Vault (20% of the Closing portion).
  * $1.00 goes to the Liquidator (20% of the Trigger portion).
  * $8.00 goes to the Protocol.
* **Outcome:** The liquidation fee is paid from your remaining collateral. The rest of your collateral is used to settle the forced closure, and your position collateral is zeroed.

## Insufficient Collateral

If a trader's collateral is not sufficient to cover fees and losses, the fees are still accounted for in the internal ledgers (e.g., for governance and referrers) but are not physically transferred from the trader's collateral. The losses are absorbed by the Protocol Vault.

## Verifying Info Onchain

### Claim: Default referral code discount on trading is 15%.

Query the perp contract's raw state for the storage key `referree_base_fee_multiplier`:

```
# Sai Mainnet Perp Smart Contract
PERP='nibi1ntmw2dfvd0qnw5fnwdu9pev2hsnqfdj9ny9n0nzh2a5u8v0scflq930mph'
NODE='https://rpc.nibiru.fi:443'

KEY_HEX="$(printf referree_base_fee_multiplier | xxd -p -c 256)"

nibid query wasm contract-state raw "$PERP" "$KEY_HEX" \
  --node "$NODE" \
  --output json
```

Result:

```js
{"data":"IjAuMTUi"}
```

Then decode the base64 value:

```bash
printf 'IjAuMTUi' | base64 -d
```

Output:

```
"0.15"
```

The storage item is the referral discount amount. Here "0.15" means a 15% discount.


---

# 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.sai.fun/learn/trading/fees.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.
