From 0acd8fc1b89fe773125a150ed388db8d71bccc2a Mon Sep 17 00:00:00 2001
From: Fricoben
+ The RAMM never sells NXM below book value, and never buys it back
+ above book value.
+
+
+ {source}
+
+ {children}
+ Nexus Mutual's RAMM (Risk-Adjusted Market Maker) prices NXM
+ token trades against a book value anchor: the protocol's
+ total capital divided by NXM supply. Buy and sell prices are
+ derived from virtual reserves that converge toward book value
+ ±1% via a time-based ratchet. During convergence the spread can
+ be wider than 1%, but the invariant always holds: sell price
+ never exceeds book value, and buy price never drops below it.
+
+
+ If the sell price exceeded book value, anyone could buy NXM
+ cheap and sell it back to the RAMM at a profit, draining the
+ RAMM's ETH reserve.
+
+ The damage wouldn't stop there. When the RAMM's
+ reserve drops below its 5,000 ETH target,{' '}
+
+ This proof covers the price band arithmetic in both branches of{' '}
+
+ Several parts of the RAMM are not modeled because they
+ don't affect price computation.{' '}
+ TWAP oracle observes prices but never feeds
+ back into{' '}
+
+
+
+ Oracle correctness, whether{' '}
+
+ The{' '}
+
+ The contract logic was modeled in{' '}
+
+ The proof is checked by Lean 4's kernel, a small program
+ that accepts or rejects proofs deterministically. If the proof
+ were wrong, it would not compile.
+
+ If the build succeeds, the proof is correct.{' '}
+
+ Note: the proof required discovering a tight threshold for the
+ sell-side invariant. Integer division truncation means the
+ property only holds when eth × supply / capital ≥ 99. Below that
+ (at 98), a machine-checked counterexample exists.
+
+ The proof uses zero axioms. The theorem requires these
+ hypotheses, which encode assumptions about valid protocol states:
+
+ The theorem also requires{' '}
+
+
+
+ What is a formal proof?
+ {' '}
+ A short explanation for non-specialists.
+
+ {detail}
+
+
+
+ )
+}
+
+export default function NexusMutualGuarantee() {
+ const [showEnglish, setShowEnglish] = useState(true)
+ const timerRef = useRef(null)
+
+ useEffect(() => {
+ timerRef.current = setTimeout(() => setShowEnglish(false), 5000)
+ return () => clearTimeout(timerRef.current)
+ }, [])
+
+ const handleToggle = () => {
+ if (timerRef.current) {
+ clearTimeout(timerRef.current)
+ timerRef.current = null
+ }
+ setShowEnglish((prev) => !prev)
+ }
+
+ return (
+
+
+
+ {name}
+ {constraint}
+
+ Nexus Mutual Book Value Invariant
+
+
+ Why this matters
+
+ adjustEth{' '}
+ automatically refills it from the capital pool at up to 100 ETH
+ per day. A sustained arbitrage would therefore drain not just the
+ RAMM, but the capital pool that backs every insurance claim on
+ the protocol.
+ calculateNxm:
+ when the ratchet has converged (BV branch) and when it's
+ still converging (ratchet branch).
+ calculateNxm.{' '}
+ Circuit breakers limit trade volume per period
+ but don't change how prices are calculated.{' '}
+ Access control (
+ whenNotPaused,{' '}
+ nonReentrant)
+ are on/off guards on a permissionless function, not price
+ logic.
+ adjustEth
+ {' '}
+ and swap execution are already covered: the
+ proof takes{' '}
+ eth,{' '}
+ oldEth, and old
+ NXM reserves as free parameters, so any post-swap or
+ post-adjustment state is included.
+
+ pool.getPoolValueInEth()
+ {' '}
+ returns the true pool value, is the main thing not covered. It
+ requires modeling{' '}
+ Pool.sol,
+ Chainlink feeds, and multi-asset conversion: a different proof
+ scope entirely.
+
+ How this was proven
+
+ calculateNxm{' '}
+ function uses branching logic with non-linear{' '}
+ uint256{' '}
+ arithmetic: scaling reserves, computing ratchet convergence
+ terms, and comparing products to decide between book-value pricing
+ and ratchet pricing. Standard testing cannot cover all input
+ combinations.
+ calculateNxm for
+ buy and sell sides, matching the Solidity's division ordering
+ exactly. The theorem was given to AI agents as a benchmark task
+ and solved.
+
+ Hypotheses
+
+
+
+ calculateNxm{' '}
+ is positive. Both buy and sell spot prices are computed as{' '}
+
+ 1e18 × eth / nxmReserve
+
+ , so a zero ETH reserve would make pricing undefined. The RAMM
+ targets ~5,000 ETH via{' '}
+ adjustEth.
+
+ calculateBuyReserve
+ {' '}
+ and{' '}
+
+ calculateSellReserve
+ {' '}
+ begin by scaling the old NXM reserve to the current ETH level:{' '}
+
+ scaledReserve = oldNxm × eth / oldEth
+
+ . Division by zero here would make the scaled reserve
+ undefined.
+
+ 1e18 × capital / supply
+
+ , and the convergence check in both branches compares against{' '}
+
+ eth × supply
+
+ . Always true after NXM's initial distribution.
+
+ capital × 10100 / 10000
+ {' '}
+ for buy (BV + 1%) and{' '}
+
+ capital × 9900 / 10000
+ {' '}
+ for sell (BV − 1%). A zero capital would collapse both price
+ targets to zero.
+
+ eth=20, capital=13, supply=4
+
+ . These thresholds are the tightest bounds where the invariant
+ still holds: 100 wei is ~10−16 ETH. With real
+ values (capital ~200k ETH, supply ~7M NXM), these ratios are
+ on the order of 1018.
+ hNoOverflow{' '}
+ hypotheses (not listed individually). Solidity's{' '}
+ uint256 wraps
+ around at 2256. If an intermediate multiplication
+ overflowed, the wrapped result would be meaningless and the
+ invariant could break. These hypotheses assert that every
+ intermediate product in{' '}
+ calculateNxm{' '}
+ stays below 2256. With Nexus Mutual's capital
+ pool at ~200k ETH (~288 wei), the largest products
+ reach ~2176, far below the limit.
+
+ Learn more
+
+
+ More research
+
+
- This proof covers the price band arithmetic in both branches of{' '}
+ The proof covers every code path through{' '}
calculateNxm:
- when the ratchet has converged (BV branch) and when it's
- still converging (ratchet branch).
-
- Several parts of the RAMM are not modeled because they
- don't affect price computation.{' '}
- TWAP oracle observes prices but never feeds
- back into{' '}
- calculateNxm.{' '}
- Circuit breakers limit trade volume per period
- but don't change how prices are calculated.{' '}
- Access control (
- whenNotPaused,{' '}
- nonReentrant)
- are on/off guards on a permissionless function, not price
- logic.
-
-
- adjustEth
- {' '}
- and swap execution are already covered: the
- proof takes{' '}
- eth,{' '}
- oldEth, and old
- NXM reserves as free parameters, so any post-swap or
- post-adjustment state is included.
+ both the BV branch (ratchet has converged, prices snap to book
+ value ±1%) and the ratchet branch (still converging, prices
+ move gradually). It holds for any value of the reserve and
+ timing inputs, which means any sequence of swaps, ETH
+ adjustments, or elapsed time is included.
- Oracle correctness, whether{' '}
+ The guarantee depends on{' '}
+ capital and{' '}
+ supply being
+ correct. These come from{' '}
pool.getPoolValueInEth()
{' '}
- returns the true pool value, is the main thing not covered. It
- requires modeling{' '}
- Pool.sol,
- Chainlink feeds, and multi-asset conversion: a different proof
- scope entirely.
+ and{' '}
+
+ tokenController.totalSupply()
+
+ , which the proof takes as trusted inputs. If those values were
+ wrong (e.g. a Chainlink oracle returning a stale price), the
+ book value itself would be wrong, and the price band would
+ anchor to the wrong number. Oracle correctness is a separate
+ verification scope.
- The proof uses zero axioms. The theorem requires these
- hypotheses, which encode assumptions about valid protocol states:
+ Trust assumption:{' '}
+ capital and{' '}
+ supply are correct.
+ These come from onchain oracles and token accounting. The proof
+ takes them as given inputs and does not verify oracle
+ correctness.
+
+ Given that, the theorem requires these hypotheses:
- The RAMM never sells NXM below book value, and never buys it back - above book value. + The Nexus Mutual liquidity pool never sells NXM below book value, + and never buys it back above book value.
diff --git a/pages/research/nexus-mutual-book-value.jsx b/pages/research/nexus-mutual-book-value.jsx index 087e27d..8297a48 100644 --- a/pages/research/nexus-mutual-book-value.jsx +++ b/pages/research/nexus-mutual-book-value.jsx @@ -87,13 +87,21 @@ export default function NexusMutualBookValuePage() {- Nexus Mutual's RAMM (Risk-Adjusted Market Maker) prices NXM - token trades against a book value anchor: the protocol's - total capital divided by NXM supply. Buy and sell prices are - derived from virtual reserves that converge toward book value - ±1% via a time-based ratchet. During convergence the spread can - be wider than 1%, but the invariant always holds: sell price - never exceeds book value, and buy price never drops below it. + Nexus Mutual is a decentralized insurance protocol. Members pool + ETH into a shared capital pool, and that pool pays out claims + when covered smart contracts are exploited. The NXM token + represents membership and a share of the pool's value. +
++ The RAMM (Risk-Adjusted Market Maker) is a separate on-chain + pool that handles NXM trading. It holds its own ETH reserve + (target: 5,000 ETH), distinct from the capital pool, and prices + trades against book value: the capital pool's total + capital divided by NXM supply. Buy and sell prices are derived + from virtual reserves that converge toward book value ±1% via a + time-based ratchet. During convergence the spread can be wider + than 1%, but the invariant always holds: sell price never exceeds + book value, and buy price never drops below it.
If the sell price exceeded book value, anyone could buy NXM
- cheap and sell it back to the RAMM at a profit, draining the
- RAMM's ETH reserve.
+ cheap and sell it back at a profit, draining the RAMM's own
+ ETH reserve (the trading pool).
- The damage wouldn't stop there. When the RAMM's
- reserve drops below its 5,000 ETH target,{' '}
+ The damage wouldn't stop at the trading pool. When the
+ RAMM's reserve drops below its 5,000 ETH target,{' '}
adjustEth{' '}
- automatically refills it from the capital pool at up to 100 ETH
- per day. A sustained arbitrage would therefore drain not just the
- RAMM, but the capital pool that backs every insurance claim on
- the protocol.
+ automatically refills it from the capital pool (the insurance
+ pool) at up to 100 ETH per day. A sustained arbitrage would
+ therefore drain not just the RAMM, but the capital pool that
+ pays out members' insurance claims.