test(risk-core): derive the fork test's mark from live state, not a constant - #28
Merged
Merged
Conversation
…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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
DeliverableFXManagerBaseFork.t.solhardcodedSETTLEMENT_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 failingDFXF_MarkDeviationExceededat 5.90%.Nothing was wrong on chain
1322012964000000114688markPrice1322012964000000114688— identical0xdfbb5Cbc…)0.00075574USD/NGN → 1,323.21 invertedTwo independent oracles agreeing to a tenth of a percent, both fresh. The guard was doing its job by refusing a 5.9% jump;
1400simply 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:
0xccb26314iscast sig 'DFXF_MarkDeviationExceeded()'.The change
settlementPriceis derived insetUpas the live mark +1%, rounded onto the series' tick, andquotePerIncrement18follows from it through the existingBASE_PER_INCREMENT_18 × pricerelation. 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
1550e18and settled at1550e18, so its15_500e18quote is self-consistent with no live dependency.MANAGER_CNGN_FUNDstays 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.solnow 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