!5102odin-dyn-fee-improvements → developc9d58dd20c

Dynamic L1 fee rework: gate, signal, bracket search, modes

AI-generatedEverything on this page was written by an AI agent from the diff: the summaries, the narration, the diagrams, the flags and the glossary. It can be wrong or incomplete, so check it against the code before you rely on it.

29commits
58files
27.0klines changed
1.6klines to read
v21→22consensus version

Where the diff is

5-minute explainer

What changed

Why

Controller stepped on noise: ~4 swaps/epoch vs ~70 needed.

Liquidity gate

Seal only with enough data; cap rolling at ~7 days.

epoch end ≥ 30 swaps≥ $100k vol seal ✓ roll ↻ ≥ 7 days rolling?seal · capped ↓ only

Signal

Revenue measured against everyone else's volume.

fees ÷ (pool − own) own volumeothers ✓ others < 10% of pool → recorded, not measured

Bracket search

Big jumps first, then ±1 tracking.

120101557869→ 8

try it ↓

Modes + reset

Whitelist value picks the mode.

0off1per-pair 2global *|*3monitor4monitor *|*

any value change ⟶ wipe state ⟶ fresh search

Accounting fixes

Counting and attribution bugs.

  • stream / limit order counts once
  • global double swap counts once
  • largest affiliate only
  • idle epochs fold pool volume
  • Migrate21to22 clears accumulators

Bracket search · live, same rule as nextSearchBps

State + upgrade

Migration

v21→v22

Clears in-flight dynamic-fee accumulators; sets every record's span_start_height to the upgrade height. Renumbered after develop took 20→21.

Mimirs

  • new…MinSwaps30
  • new…MinVolumeUSD100,000
  • new…MaxEpochBlocks100,800
  • new…MinOtherFlowBPS1000
  • new…ProbeEpochs1

Proto fields added

DynamicFeeRecord
+ search_done+ probes+ span_start_height+ pairs
DynamicFeeEpochRecord
+ swap_count+ pool_volume_tor+ own_pool_volume_tor+ blocks+ capped
DynamicFeeAccumulator
+ swap_count+ pool_volume_tor+ own_pool_volume_tor+ pairs
DynamicFeeProbe (new)
+ bps+ signal_sum+ epochs+ capped
DynamicFeePoolAccumulator (new)
+ pair_asset_a+ pair_asset_b+ volume_tor
GenesisState
+ dynamic_fee_pool_accumulators
Query entries (REST)
+ phase+ probes+ blocks+ capped+ swap_count+ pool_volume_tor+ own_pool_volume_tor+ span_blocks

Line by line · every changed logic line, narrated

14:26runtime
17code chapters
100%logic lines narrated (1353/1353)
7flagged spots
speed

Chapters

What to check

Ask an AI about this change

Chat assistantClaude, ChatGPT, … (reads a link)

Coding agentClaude Code, Cursor, … (reads the repo)

The context file is context.md. Use Copy with context for an AI that can't open links; it pastes the whole file in.

Glossary

ADR-026
The design record for the dynamic L1 minimum fee per thorname. This MR reworks its controller: liquidity gate, normalized signal, bracket search and modes. ADR-026 ↗
Affiliate
The integrator credited with a swap's affiliate fee. The controller attributes a swap to the largest affiliate only. affiliate fee guide ↗
bps
Basis points: one hundredth of a percent. The dynamic floor moves between 1 and 20 bps.
Epoch / span
An epoch is the controller's measurement interval. A span is the run of epochs rolled together until the liquidity gate or the ~7-day cap seals it. constants_v1.go ↗
Liquidity gate
A span seals only with at least 30 swaps and $100k of affiliate volume; below that it rolls into the next epoch. manager_dynamic_fee_current.go ↗
Mimir
Node-voted runtime settings that override protocol constants. Here they tune the controller and enrol thornames via the whitelist key. docs/mimir.md ↗
POL
Protocol-owned liquidity. Its volume is left out of the signal's denominator. ADR-006 ↗
Streaming swap
A swap executed in sub-swaps over several blocks. This MR counts it as one swap for the liquidity gate. streaming swaps ↗ ADR-010 ↗
Thorname
A registered THORChain name that integrators use as their affiliate. Each enrolled thorname gets its own dynamic fee records and accumulators. thorname guide ↗