Skip to content

test(risk-core): derive the fork test's mark from live state, not a constant - #28

Merged
robertleifke merged 1 commit into
mainfrom
fix/derive-fork-test-mark-from-live
Sep 9, 2026
Merged

test(risk-core): derive the fork test's mark from live state, not a constant#28
robertleifke merged 1 commit into
mainfrom
fix/derive-fork-test-mark-from-live

Conversation

@robertleifke

Copy link
Copy Markdown
Contributor

DeliverableFXManagerBaseFork.t.sol hardcoded SETTLEMENT_PRICE = 1400e18, with a comment acknowledging it "must stay within the 5% mark-deviation bound of the live series' birth mark (1379.64)". But the guard compares against the current mark, not the birth mark — and the current mark tracks NGN/USD. The rate drifted and both tests started failing DFXF_MarkDeviationExceeded at 5.90%.

Nothing was wrong on chain

Numo cNGN feed 1322012964000000114688
Stored markPrice 1322012964000000114688 — identical
Chainlink NGN/USD on Base (0xdfbb5Cbc…) 0.00075574 USD/NGN → 1,323.21 inverted
Divergence 0.09%

Two independent oracles agreeing to a tenth of a percent, both fresh. The guard was doing its job by refusing a 5.9% jump; 1400 simply is not where the rate is, and is 5.80% from Chainlink too.

Proven, not inferred

Simulating the test's own call against live state:

setMarkPrice(subId, now, 1400e18)  → revert 0xccb26314
setMarkPrice(subId, now, 1330e18)  → 0x   (succeeds)

0xccb26314 is cast sig 'DFXF_MarkDeviationExceeded()'.

The change

settlementPrice is derived in setUp as the live mark +1%, rounded onto the series' tick, and quotePerIncrement18 follows from it through the existing BASE_PER_INCREMENT_18 × price relation. The test then exercises the guard at whatever the rate happens to be, rather than at one rate with an expiry date.

Untouched deliberately: the second series is created by the test with birth mark 1550e18 and settled at 1550e18, so its 15_500e18 quote is self-consistent with no live dependency. MANAGER_CNGN_FUND stays constant — a funding amount with ~500× slack, not an assertion.

Result

Both tests pass. 986 of 988 in the suite.

Not in scope: four tests in CNGNSpotResumeFork.t.sol now fail — they assert the batch has not been applied ("nothing should read as done", "no prefix before the last action permits a deposit"), and the batch was executed on Base yesterday. They've served their purpose and need reframing or a guard, which is a separate judgement call and a separate change.

🤖 Generated with Claude Code

https://claude.ai/code/session_01JN98Sjs2zHG8Z6jXkpHX7Q

…onstant

SETTLEMENT_PRICE was hardcoded to 1400e18 with a comment noting it "must stay
within the 5% mark-deviation bound of the live series' birth mark (1379.64)".
The bound is against the CURRENT mark, not the birth mark, and the current
mark tracks NGN/USD. The rate drifted to 1322.01 and both tests began failing
DFXF_MarkDeviationExceeded at 5.90%.

Nothing was wrong on chain. The live mark equals the feed exactly
(1322012964000000114688 both), and Chainlink's NGN/USD on Base agrees to
0.09% -- 0.00075574 USD/NGN inverts to 1323.21. The guard was doing its job
by refusing a 5.9% jump; 1400 simply is not where the rate is.

Proven by simulating the test's own call against live state:

  setMarkPrice(subId, now, 1400e18) -> revert 0xccb26314  (the selector for
                                       DFXF_MarkDeviationExceeded)
  setMarkPrice(subId, now, 1330e18) -> 0x                 (succeeds)

So the mark is now derived in setUp as the live mark +1%, rounded onto the
series' tick, and quotePerIncrement18 derives from it via the existing
BASE_PER_INCREMENT_18 * price relation. The test exercises the guard's
behaviour at whatever the rate happens to be, instead of at one rate that
expires.

The second series is untouched: the test creates it with birth mark 1550e18
and settles it at 1550e18, so its 15_500e18 quote is self-consistent and has
no live dependency. MANAGER_CNGN_FUND stays constant -- it is a funding
amount with ~500x slack, not an assertion.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01JN98Sjs2zHG8Z6jXkpHX7Q
@robertleifke
robertleifke merged commit 3bc71d5 into main Sep 9, 2026
1 of 2 checks passed
@robertleifke
robertleifke deleted the fix/derive-fork-test-mark-from-live branch September 9, 2026 14:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant