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

Fee=Input Amount×c\text{Fee} = \text{Input Amount} \times \text{c}

Case 2: input_amount > reference_amount

First, decompose the excess amount:

Input Amount=x0+(a×x0+b)\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:

If a < max_index

Fee=x0×(c+c×a+i×a×(a+1)/2)+b×(c+i×(a+1))\text{Fee} = x_0 \times (c + c \times a + i \times a \times (a+1) / 2) + b \times (c + i \times (a+1))

If a ≥ max_index

d=aMax Indexd = a - \text{Max Index}
Fee=x0×(c+c×Max Index+i×Max Index×(Max Index+1)/2)+(d×x0+b)×Max Fee\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}