Rate Limiter
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 amountcliff_fee_numerator
(c): The base fee ratefee_increment_bps
(i): The fee increment in basis pointsmax_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
Case 2: input_amount > reference_amount
First, decompose the excess amount:
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
If a ≥ max_index