# Funding Rates

Funding rates act as a final controller to ensure our final objective

While the AMM addresses the marginal risk from the change in inventory using premium and rebate, there remain some residual risks, one of which is caused by the change in the price process of the underlying asset. To cover for such risk, we charge funding periodically.

Given

$X_t$

is a function of an $n$

dimensional vector $\mathbf{q}$

, we need a way to define funding rate for each market such that the total funding accumulated across $n$

markets add up to $\rho(X_{t+\tau})-(P+L)$

. To achieve this, we use a risk attribution mechanism called Euler allocation. Let

$X_{t,i}$

be the liability arising from $i$

th market. Using Euler allocation, we calculate the amount of funding needed from $i$

th market as $\rho_{Euler}(X_{t+\tau,i}|X_{t+\tau})$

. Now, for each trader $j \in I_i$

with position size $q_{i_j} \in \mathbb{R}$

where $\sum_{j\in I_i}q_{i_j}=q_{i}$

, they are responsible for covering $\rho_{Euler}(X_{t+\tau,i}|X_{t+\tau})\frac{q_{i_j}}{q_{i}}$

For example, if the market is long-heavy (

$q_{i} > 0$

), traders with long position $(q_{i_j}>0)$

pays funding, while those with short position $(q_{i_j}< 0)$

receives funding. This way, the AMM accumulates $F=\sum_{i=1}^n\sum_{j\in I_i}\rho_{Euler}(X_{t+\tau,i}|X_{t+\tau})\frac{q_{i_j}}{q_{i}}=\rho(X_{t+\tau})-(P+L)$

, which is precisely the amount of funding needed to satisfy the invariant $X_{t+\tau}\leq P+L+F$

with high probability.Last modified 3mo ago