!5299odin/luvi-guards-fairprice → develop5d5b7ad96a

Oracle-priced fair LP unit value on pool queries

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
14files
3.5klines changed
290lines to read
40–45new proto fields
0state changes

Where the diff is

3-minute explainer

What changed

Fair vs spot

Value LP units at the oracle price, not the pool's own

spot 2R − S·R/Afair 2√(AR)·√P − S·P

Sandwich-proof

Swaps keep A·R, so only the spot value moves

spot ↑fair =

Integer math + overhang

big.Int at 1e36; synth liability ≥ fair clamps to zero

no floatsstrict decimal parseroverhang flag

Six query fields

Fields 40–45, only with both oracle prices this block

/pool/poolswasm Query/Pool

Risk

Query-only; wasm callers pay 1–2 extra price reads

State + upgrade

Proto fields added

QueryPoolResponse
+ lp_unit_fair_value_rune (40)+ lp_unit_fair_value_asset (41)+ lp_unit_spot_value_rune (42)+ lp_fair_spot_deviation_bps (43)+ fair_value_oracle_price_rune (44)+ lp_fair_value_overhang (45)

Line by line · every changed logic line, narrated

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

bps
Basis points: 1/100 of a percent.
Fair LP value
2·√(A·R)·√P − S·P: the LP side priced at an oracle price P, which swaps can't move. type_luvi_fair.go ↗
LUVI
LP unit value index: this branch's family of LP-side value metrics built from sqrt(A·R). type_luvi.go ↗
Oracle price P
RUNE per asset, from the oracle's asset USD price divided by its RUNE USD price. keeper_oracle.go ↗
Overhang
Synth liability worth at least the fair value: LP units are worth zero at the oracle price.
Sandwich
Swap in, act at the distorted pool price, swap back out.
Spot LP value
2R − S·R/A: the LP side priced at the pool's own price, movable by a swap.
Synth liability S
Synth supply of the asset; owed by LPs, so it is subtracted from LP value.