# Funding Rate

Rules of deduction:

* We will deduct funding rate every 6 hrs
* One rate will be calculated for those 6 hrs by averaging smaller intervals
* Anyone with a position open during the deduction snapshot will be charged the fee
* Users will pay their share as per notional value of their position at the time of funding amount deduction
* It will be realized PNL deducted / added to user’s assets

Formula:

```jsx
funding_amount_per_user_per_position = direction * ob_price(t) * qty * funding_rate
ob_price(t) = (best_bid(t) + best_ask(t))/2
funding_rate = premium_rate + interest_rate
interest_rate = 0.01% (fixed across all markets)
```

Premium rate for the interval is calculated by calculating minute-wise values and doing a TWAP over the total minutes in the window

```jsx
premium_rate_minute = (Max(0, impact_bid_price - spot_price) - Max(0, spot_price - impact_ask_price)) / spot_price
impact_bid_price = execution price of SELL market order, 5000 USDC notional value
impact_ask_price = market BUY order
premium_rate = SUM(premium_rate_minute)/(60*8)
```
