Concepts

The fee formula

Gap, premium and stress, then a clamp.

Three signals on top of a base fee, then a clamp. Fees are in pips: 1,000,000 = 100%.

fee
raw = baseFee
    + (arb          ? gapBps × gapWeight            : 0)
    + (withPressure ? |premiumBps| × premiumWeight  : 0)
    + (moveBps > stressThresholdBps ? (moveBps − stressThresholdBps) × stressWeight : 0)

fee = clamp(raw, minFee, maxFee)      // bad read → fallbackFee

The signals#

Gap

How far the pool is from the oracle, in basis points. Only the swap that moves the pool toward the oracle pays it: that is the arbitrage. The top-of-block price counts too, so an arb split across swaps in one block keeps paying the full gap.

Premium

Mark versus oracle. Trading the way the perp market leans costs a little more.

Stress

How far the mark moved against a time-weighted anchor. Above the threshold, every swap pays more.

Parameters#

ParameterValueMeaning
baseFee0.05%Calm-market fee and floor
maxFee1.00%Cap
fallbackFee0.30%Charged when a read fails or the gap is implausible
gapWeight50 pips / bpWeight of the gap term
premiumWeight50 pips / bpWeight of the premium term
stressThresholdBps50 bpMark move before stress applies
stressWeight20 pips / bpWeight above the threshold
maxGapBps2000 bpAbove this, use the fallback
precompileGas30,000Gas forwarded to each read

Worked example#

Pool 1.50% above the oracle, mark 0.20% below the oracle, mark moved 0.30% against its anchor.

  • Seller (the arb): gap 150 bp × 50 = 7,500; selling with a negative premium 20 × 50 = 1,000; stress 30 < 50 → 0. Fee = 500 + 7,500 + 1,000 = 9,000 pips (0.90%).
  • Buyer, same state: not the arb, no pressure. Fee = 500 pips (0.05%).
The exact code is AvenFairValue.sol. The TypeScript port in @aven/core matches it on 10,000 random vectors.
Aven · MIT · ETHGlobal MumbaiEdit on GitHub ↗