> ## Documentation Index
> Fetch the complete documentation index at: https://docs.meteora.ag/llms.txt
> Use this file to discover all available pages before exploring further.

# Rate Limiter Math

Rate Limiter is a configurable fee slope that can charge fees ranging from the configured `base_fee` up to 99% fee (`MAX_FEE`).

# Rate Limiter Formula

The rate limiter uses a progressive fee calculation with the following key components:

Parameters:

* `reference_amount` (x₀): The base reference amount
* `cliff_fee_numerator` (c): The base fee rate
* `fee_increment_bps` (i): The fee increment in basis points
* `max_limiter_duration`: Duration for which the rate limiter is active

The formula depends on the relationship between input\_amount and reference\_amount:

**Case 1: `input_amount ≤ reference_amount`**

```math theme={"system"}
\text{Fee} = \text{Input Amount} \times \text{c}
```

**Case 2: `input_amount > reference_amount`**

First, decompose the excess amount:

```math theme={"system"}
\text{Input Amount} = x_0 + (a \times x_0 + b)
```

where:

* `a`: floor division of `(Input Amount - x₀) / x₀`
* `b`: remainder of `(Input Amount - x₀) mod x₀`

Then calculate fees based on whether we exceed the maximum index:

Max Index can be calculated as:

```math theme={"system"}
\text{Max Index} = \frac{\text{MAX\_FEE\_NUMERATOR} - c}{\text{fee\_increment\_numerator}}
```

where:

* `fee_increment_numerator = (fee_increment_bps * FEE_DENOMINATOR) / 10_000`

**If `a < max_index`**

<div style={{ fontSize: "0.88em" }}>
  ```math theme={"system"}
  \text{Fee} = x_0 \times (c + c \times a + i \times a \times (a+1) / 2) + b \times (c + i \times (a+1))
  ```
</div>

**If `a ≥ max_index`**

<div style={{ fontSize: "0.88em" }}>
  ```math theme={"system"}
  d = a - \text{Max Index}
  ```
</div>

<div style={{ fontSize: "0.88em" }}>
  ```math theme={"system"}
  \text{Fee} = x_0 \times (c + c \times \text{Max Index} + i \times \text{Max Index} \times (\text{Max Index}+1) / 2) + (d \times x_0 + b) \times \text{Max Fee}
  ```
</div>
