fix(quoter-bot): ignore matured configured markets - #186
Conversation
Allow configured post-maturity markets to remain in MARKET_IDS without failing the setup readiness gate. Co-authored-by: Julien Thomas <61523188+julien-devatom@users.noreply.github.com>
|
<@U09LHAWUK3M> review |
|
Addressed in 88b210d. Maturity is now detected before offer generation, so |
|
Addressed in 88b210d. The latest-timestamp readiness dependency is gone end to end: |
|
Addressed in 88b210d — the timestamp read, parameter, failure propagation, and its transient-retry classification are all removed (including |
|
Good catch — addressed in 88b210d. |
|
Addressed in 88b210d. Rather than filtering at setup, the writer workflows now handle the lifecycle state, which also covers markets that mature while the bot runs: the ladder invalidates owned groups for a matured market ( |
There was a problem hiding this comment.
Devin Review found 1 new potential issue.
1 flag not posted on this PR by your GitHub settings — view it in Devin Review. (Configure)
Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
a7fdaf7 to
3f71ab0
Compare
Why
A market ID can stay configured after its Midnight market reaches maturity. Treating that expected lifecycle state as a setup invariant failure stopped the quoter, instead of letting the other configured markets keep quoting while the matured one is cleaned up.
What changed
Setup no longer treats maturity as an invariant (identity, allowlisting, loan asset, and tick spacing are still checked), and the latest-block timestamp — whose only use was the maturity comparison — is removed end to end, so an RPC timestamp outage can no longer fail readiness:
Production setup reads market metadata instead of active books.
/v0/midnight/booksexcludes past maturities even when IDs are requested, so a matured configured market could never be found;ViemSetupStateService.getBooknow reads/v0/midnight/markets(chain_ids+market_ids) concurrently with the on-chaintoMarket/tickSpacingreads.Both writer workflows recognize maturity from a fresh read and stop before offer arithmetic. Maturity and the timestamp it is compared against come from the same read, so no workflow owns a clock:
runOncesettles a matured market before reference-rate and ladder generation —make.reconcile({ desired: undefined, reason: 'market-matured' })invalidates the owned groups and the market reports the non-failingmaturedaction.buildLadderTreetherefore never throwsLadderAdapterError('market-matured'), so a cycle is not failed andrunContinuouslydoes not halt every other market.maturedaction right after the position read, before any reference read or time-to-maturity arithmetic (no negative durations). Its groups can no longer be filled and are cancelled by the monitor's shutdown cleanup.midnight.getMarketData(marketId)plus the fresh block, replacing the group-derivedladderMarketMaturityhelper (deleted), which returned nothing for a market with no owned groups.Verification
pnpm --filter @morpho-org/quoter-bot run typecheck,pnpm lint,pnpm format,pnpm knip,pnpm --filter @morpho-org/quoter-bot run jsdoc:build— all cleanpnpm --filter @morpho-org/quoter-bot exec vitest run --exclude 'test/e2e/**'— 1170 passed (e2e suites needRPC_URL_8453; the remaining repo-widepnpm testfailures are the unbuilt@repo/contractsentry, both preexisting locally)maturedwhile another market publishes, and later-cycle continuation (bootstrap); adapter-level matured-market metadata read with an empty/booksresponseCloses MKT-2187
Link to Devin session: https://app.devin.ai/sessions/56a26bd3b0bc412eb931ea282d3c8036
Open in Devin Desktop: https://app.devin.ai/desktop/session/56a26bd3b0bc412eb931ea282d3c8036?variant=devin
Requested by: @haydenshively