fix(kuru): read MarketStateError as a market that is not trading - #205
ShadowOfTime1 wants to merge 1 commit into
Conversation
|
@ShadowOfTime1 before I take Could you establish, on chain, what changed: is the market paused or migrated under the new template ( |
…rderBook surface Address review on nishuzumi#199: - Derive every Router selector from the vendored ABI entry (toFunctionSelector on the artifact) and keep the human-readable signature only as a cross-check, so a parameter-list drift between the ABI and the bytecode cannot pass. - Add the OrderBook counterpart the header only narrated: read the market template bytecode and assert the two dispatcher selectors and three event topics, each derived from KuruOrderbookAbi. Record the read block as verifiedAtBlock in abis.json and pin the bytecode reads to it. - Drop the header's claim to exercise live behaviour: that leg is red (the MON/USDC native-swap smoke fails with MarketStateError on one of four verified markets; tracked in nishuzumi#194/nishuzumi#205), so the record states the fact instead.
|
You are right on both counts — the premise was wrong and
So, to your three questions: Proposed fix, and I think it belongs in the quote classifier rather than discovery. Discovery cannot cheaply know a market is stuck — If that direction is right I will rework #205 into the classifier change plus an offline fixture (a market stubbed to revert |
The native-swap live test has failed since 2026-09-08 because one of the four verified MON/USDC markets (0x764b...29D5) reverts every quote probe with MarketStateError() while the other three, on the same template, fill. The adapter kept that revert as an unmeasured route, so swap refused the pair as an incomplete comparison. The market names itself as the cause and refuses at every size, which is an answer rather than a gap. Decode it against the vendored OrderBook ABI and price that leg at zero, so the route is measured and the comparison stays exhaustive. Any other revert, with or without data, is unchanged and still reported as unavailable. A market that answered this way is remembered for the rest of the request, so the reverse search does not pay to hear it again. The live native-swap test keeps its exhaustive default; two offline cases cover the decoded refusal (routed around even when it is the better-priced market) and the single call it costs the reverse search.
f984962 to
eeca714
Compare
|
Reworked as proposed: |
|
Closing this to free my claim slot for other pool work. The branch stays on my fork and the change is ready on my side, so it can be reopened as is if it's still wanted. |
Second half of #194: the native-swap live test (
Kuru mainnet > simulates a native swap into an exhaustive typed Receipt) has failed since 2026-09-08 withROUTE_QUOTE_UNAVAILABLE.What is on chain. MON/USDC has four Router-verified markets, all running the current template
0x5e3446c600524Be453bbCEFD46a9E4C9bE8899a0. Three fill a 1 MONplaceAndExecuteMarketSellprobe;0x764b4c2AF968c97b4ae95490d264c14d955129D5reverts every probe withMarketStateError()(0x004b65ba).verifiedMarket()is still true for it and discovery still lists it, so it is not migrated or replaced — it is one market that has stopped accepting orders.Why the test failed. The adapter kept that revert as an unmeasured route, the same as a bare revert, so the exhaustive default on
swaprefused the pair even though three routes priced.The fix.
MarketStateError()is the market naming itself as the cause, and it refuses at every size, so it is an answer rather than a gap.#quoteFillnow decodes it against the vendored OrderBook ABI (decodeErrorResult, not a hand-typed selector) and prices that leg at zero: the route is measured, excluded from the winner, and the comparison stays exhaustive. Every other revert, with or without data, is unchanged and still lands inunavailable, so this does not hide an unmeasured route. A market that answered this way is remembered for the rest of the request, so the reverse search spends one call on it instead of one per size.The live test keeps
requireExhaustiveat its default; the earlierrequireExhaustive: falseversion of this PR is gone.Tests. Two offline cases: a native swap whose better-priced MON/USDC market answers
MarketStateError(nested the way viem wraps it) quotes withunavailable: []and routes through the live market; and a pair whose only market answers it resolves toTARGET_OUTPUT_UNSATISFIABLE/NO_POSITIVE_QUOTEwith no unavailable routes, after exactly one call. Both fail on current main.Verify.
pnpm lint,pnpm build,pnpm typecheck; the Kuru suite is 88/88 including the live native swap against Monad mainnet, exhaustive. Patch changeset added.Refs #194.