!5295odin/luvi-guards-overhang → developa1dfc9a6e7

LP unit overflow returns an error; overhang pools refuse adds

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.

1commits
8files
489lines changed
117lines to read
1new mimir (default on)
0migrations

Where the diff is

2-minute explainer

What changed

Why

Overhang POL deposits grow LP units until LegacyDec panics in EndBlock.

S ≥ 2AP = L·(1+S)×(1+(1+S)f)2^256 → panic

Overflow → error

Exact big.Int pre-checks; in-range math unchanged.

  • empty-pool branch: product + sum
  • checkPoolUnitsRange: 15 intermediates
  • P + liquidityUnits
  • post-add LPUnits·S

LUVIOverhangGuard

Adds into overhang pools are refunded while the mimir > 0.

S > 0S ≥ 2Amimir > 0refund

withdrawals and savers adds unaffected

POL skips

POLCycle logs and skips; POLReserveCycle picks another pool.

POLCycle: skip + logPOLReserveCycle: next pool

State + upgrade

Mimirs

  • newLUVIOverhangGuard1

Line by line · every changed logic line, narrated

4:21runtime
7code chapters
100%logic lines narrated (89/89)
5flagged 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

CalcUnits
Pool method that derives synth units from LP units and synth supply; multiplies them as Uint.
EndBlock
Per-block hook; a panic there halts the chain rather than failing one transaction.
LegacyDec
Cosmos SDK 18-decimal fixed-point type; it panics when a result leaves its ~2^256 range. Cosmos SDK docs ↗
LUVI
Liquidity unit value index: the per-unit pool value tracked by LuviState; this MR uses its IsOverhang check. type_luvi.go ↗
Mimir
On-chain node-voted parameter overrides; LUVIOverhangGuard is a new one, default 1. docs/mimir.md ↗
POL
Protocol-owned liquidity: the reserve adds RUNE to pools in EndBlock via POLCycle and POLReserveCycle. manager_network_current.go ↗
Synth overhang
Synth supply S at least twice the pool's asset depth A; pool units are clamped to L·(1+S) in this state. type_luvi.go ↗