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 → fallbackFeeThe 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#
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 ↗