LeverUp's funding fee is built to do two things at once: lower the cost of holding positions in normal markets, and keep the system balanced when positioning gets crowded on one side.

In typical conditions — when long and short open interest are reasonably balanced, or only mildly skewed — funding grows slowly. Traders pay less to carry positions than under older flat-rate models. When one side becomes heavily crowded, the rate rises more sharply, which helps discourage extreme imbalance and supports a more stable trading environment for everyone.

The formula is fully on-chain and deterministic. Same pair state, same funding config, same output. There is no external carry input, no discretionary setting, and no LP-side distortion in the structure.
HJ-FL-Ea0AAu9MM.jpeg


Calculation Path

For each trading pair, the contract reads three inputs:

  • L — total long quantity (in base asset units)
  • S — total short quantity (in base asset units)
  • P — current market price (oracle-referenced)

Step 1: Quantity skew

Q_skew = |L − S|

Step 2: Convert to USD notional

Skew_USD = Q_skew × P

In the contract, marketPrice is fixed-point scaled, so the implementation applies the matching divisor when calculating skewUsd. The economic meaning is unchanged: quantity imbalance becomes notional imbalance.

Step 3: Select the OI limit

The dominant side determines which OI limit is used as the normalization cap:

OI_limit = maxLongOiUsd   (when L > S)
OI_limit = maxShortOiUsd  (when S > L)

Step 4: Normalize utilization

u = min(Skew_USD, OI_limit) / OI_limit

This gives every market the same input range: 0 ≤ u ≤ 1. A BTC market with a large OI cap and a smaller altcoin market both feed the same cubic curve.


Cubic Signal

LeverUp applies a cubic response to the normalized utilization:

signal = u³

The cubic curve keeps small imbalance from dominating the rate, while making crowded books reprice faster as utilization approaches the configured cap:

Utilization Signal (u³)
10% 0.1%
50% 12.5%
80% 51.2%
100% 100%

At 10% utilization the signal is nearly zero — a modestly unbalanced book pays almost nothing extra. At 80% utilization the signal exceeds half of maximum — a crowded book pays real cost. At full utilization the signal reaches maximum and the rate is capped only by the pair's configured maxR.

These are raw signal values before pair-level min/max bounds are applied.
HJ-FaSragAEQwqr.jpeg


Rate, Direction, and Accrual

Each trading pair carries three funding configuration parameters:

  • ffundingFeePerSecondP (the full-utilization funding rate, per second)
  • minR — minimum per-second funding rate
  • maxR — maximum per-second funding rate

For readability, these values can be displayed as annualized rates in the UI or in examples. The contract stores and accrues per-second values.

Raw rate:

rawRate = f × u³

Effective rate (zero when the pair is balanced, otherwise):

rateAbs = clamp(rawRate, minR, maxR)
r = +rateAbs  (when L > S — longs pay)
r = −rateAbs  (when S > L — shorts pay)

The clamp prevents the rate from dropping below minR or exceeding maxR, regardless of how extreme the signal value becomes.

Accumulator advance (per elapsed second):

LongAcc_t = LongAcc_previous − r × Δt

State-changing actions (opens, closes, liquidations) update the stored accumulator. Reader functions can project the latest accumulator value from the last funding timestamp to the current block timestamp without a write.

Settlement (when a position is closed):

LongFee_USD  = PositionNotional_USD × (LongAcc_current − LongAcc_entry)
ShortFee_USD = −LongFee_USD

The final USD amount is converted into the position's margin token using token price and decimals.


Example: BTC/USD Long-Heavy Market

Assume the following pair state and configuration:

Parameter Value
Total long quantity 70 BTC
Total short quantity 30 BTC
BTC price 100,000 USDC
Long-side OI limit 5,000,000 USDC
Full-utilization rate 25% annualized
Funding bounds 5%–75% annualized

Skew calculation:

Q_skew   = |70 − 30| = 40 BTC
Skew_USD = 40 × 100,000 = 4,000,000 USDC

Utilization:

u = min(4,000,000, 5,000,000) / 5,000,000 = 0.80

Cubic signal and bounded rate:

u³ = 0.80³ = 0.512
rawRate       = 25% × 0.512 = 12.8% annualized
effectiveRate = 12.8% annualized  (within [5%, 75%] bounds)

Cost for a 10,000 USDC long position held 24 hours:

10,000 × 12.8% × (1 / 365) ≈ 3.51 USDC

Before margin-token conversion and any integer rounding, a 10,000 USDC long position pays approximately 3.51 USDC to hold for one day at this utilization level.


Why Traders Can Model It

The full input path is deterministic: quantity, price, OI limit, funding parameters, elapsed seconds. No oracle disputes, no discretionary adjustments, no LP-side variables.

Skew is normalized into USD notional, so the same utilization logic applies uniformly across crypto, FX, indices, and commodities. A market with a 5M USDC OI cap and a market with a 50M USDC OI cap both follow the same curve — the cap absorbs the scale difference, not the formula.

The cubic curve creates a deliberate asymmetry: funding is quiet near balance and increasingly expensive near the OI cap. This means the balancing incentive is strongest exactly when it is most needed — when one side has crowded the book and the protocol's risk exposure is highest.

The accumulator creates an audit trail from market state to settled funding. Every second of accrual is a reproducible calculation: r × Δt, added to the accumulator, multiplied by notional at settlement. The fee you pay is not a displayed estimate — it is a derivable output from on-chain state.


For rate display, fee breakdown, and pair-level configuration parameters, see the Fee Breakdown in the LeverUp docs.


Related reading


Start trading on LeverUp →