> For the complete documentation index, see [llms.txt](https://myxfinance.gitbook.io/myx.finance-v2/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://myxfinance.gitbook.io/myx.finance-v2/trader-guide/trading-rules/funding.md).

# Funding

### Overview

Funding is the mechanism MYX uses to keep long and short exposure balanced over time.

The basic idea is simple:

* when longs dominate, **longs pay shorts**
* when shorts dominate, **shorts pay longs**

Funding is not a trading fee.\
It is a **holding cost or holding income** that depends on market imbalance.

***

### What Funding Is For

Perpetual futures do not expire, so the market needs a way to discourage one-sided crowding.

Funding does this by making the crowded side pay the less crowded side.

This means:

* if too many users are long, holding a long becomes more expensive
* if too many users are short, holding a short becomes more expensive

Funding helps push the market back toward balance.

***

### How Funding Updates on MYX V2

On MYX V2, funding is **not continuously written on-chain every block**.

Instead, funding is updated **when users interact with the market**.

That means the funding tracker is refreshed whenever a user:

* opens a position
* increases a position
* reduces a position
* closes a position

This keeps the system efficient while still calculating funding on a per-second basis.

***

### How the Funding Tracker Works

Each market maintains a global **funding tracker**.

Whenever a user performs a position-changing action, MYX does two things:

#### 1. Update the market funding tracker

The system first looks at:

* the time elapsed since the last funding update
* the market imbalance during that period

It then adds the accrued funding for that elapsed time to the global tracker.

#### 2. Settle the user against their entry tracker

Each user position stores its own **entry tracker**.

When the user changes the position, the protocol compares:

* the current global tracker
* the user’s stored entry tracker

The difference determines how much funding the user must pay or receive.

After that, the user’s entry tracker is updated to the latest tracker value.

***

### Why This Matters

This means funding on MYX V2 is:

* **calculated continuously by time**
* but **settled only when users interact**

So the market does not need to write a new funding state every second on-chain.

Instead, elapsed time is measured from timestamps, and funding is applied only when needed.

***

### Funding Direction

Funding direction depends on the market’s **imbalance ratio**, `R`.

In trader terms:

* if the market is net long, **longs pay shorts**
* if the market is net short, **shorts pay longs**

MYX measures this imbalance using long and short position sizes in USD terms.

A useful mental model is:

> the more one-sided the market becomes, the more expensive it is to remain on the crowded side.

***

### Current Funding Parameters

The current funding model uses the same parameter set across markets.

| Parameter       | Meaning                                    | Current Value |
| --------------- | ------------------------------------------ | ------------- |
| `r1`            | Base daily rate                            | 0.03% / day   |
| `r2`            | Maximum daily funding rate cap             | 0.30% / day   |
| `X`             | Equilibrium range                          | ±20%          |
| `g1`            | Low growth rate inside equilibrium range   | 1% / day      |
| `g2`            | High growth rate outside equilibrium range | 3% / day      |
| `epochDuration` | Funding accrual unit                       | 1 second      |

***

### How to Read These Parameters

#### Base Rate: `r1`

Funding starts from a low base level.

This ensures the market has a minimum carrying cost even when imbalance is mild.

#### Max Rate: `r2`

Funding cannot grow indefinitely.

Even if the market becomes highly skewed, the daily funding rate is capped at **0.30% per day**.

#### Equilibrium Range: `±20%`

As long as imbalance remains within **±20%**, funding grows more slowly.

This creates a “normal range” where mild crowding does not immediately become too expensive.

#### Growth Rates: `g1` and `g2`

Funding grows at:

* **1% / day** inside the equilibrium range
* **3% / day** outside the equilibrium range

So funding accelerates once imbalance moves far enough away from normal.

***

### Practical Funding Logic

Funding on MYX behaves like this:

#### Mild imbalance

If the market is only slightly one-sided:

* funding remains relatively low
* holding the crowded side is not heavily penalized yet

#### Strong imbalance

If the market moves clearly outside the equilibrium range:

* funding rises faster
* the crowded side starts paying more aggressively

#### Extreme imbalance

Funding keeps increasing, but never beyond the maximum daily cap.

This ensures funding remains bounded and predictable.

***

### Simple Example

Suppose:

* the market is clearly net long
* you are holding a long
* time passes before your next action
* the market remains long-heavy during that time

When you next open, reduce, or close:

* the global funding tracker is first updated for the elapsed time
* your position is then settled against that updated tracker
* you pay funding because you were on the crowded side

If instead you had been short during that same period, you would receive funding.

***

### Funding Is Settled Before Position Changes

A key detail:

Before any new position change is applied, MYX first settles funding using the **pre-action market state**.

That means:

* funding for the elapsed period is calculated using the imbalance that existed before the user’s new action is merged in
* only after that does the protocol update the user’s position and tracker

This avoids mixing old funding accrual with new exposure.

***

### Formula Reference

For readers who want the exact shape of the funding curve:

### Formula Reference

#### Funding rate formula

1. **When the imbalance ratio is within the equilibrium range ±X%:**

   a. **When `R >= 0`**, longs dominate, so longs pay shorts:

   $$
   \text{funding fee} = \min\left(\frac{R^2}{2} \times g1 + r1,\ r2\right)
   $$

   b. **When `R < 0`**, shorts dominate, so shorts pay longs:

   $$
   \text{funding fee} = \max\left(-\frac{R^2}{2} \times g1 + r1,\ -r2\right)
   $$
2. **When the imbalance ratio is outside the equilibrium range ±X%:**

   a. **When `R >= 0`**, longs dominate, so longs pay shorts:

   $$
   \text{funding fee} = \min\left(\frac{R^2}{2} \times g2 + r1,\ r2\right)
   $$

   b. **When `R < 0`**, shorts dominate, so shorts pay longs:

   $$
   \text{funding fee} = \max\left(-\frac{R^2}{2} \times g2 + r1,\ -r2\right)
   $$

***

### What Traders Should Watch

When holding a position for longer periods, funding can matter as much as price movement.

You should pay attention to:

* whether your side of the market is crowded
* how long you plan to hold
* whether the market is still within the equilibrium range
* whether your trade is in a highly one-sided market

A profitable position can still lose net return if funding remains expensive long enough.
