fix(deposit_handler): TokenMismatch error + exchange-router-api.md accuracy fixes (#661-664) - #674
Merged
abayomicornelius merged 2 commits intoAug 24, 2026
Conversation
… wrong-token config mismatch Closes SO4-Markets#661 create_deposit's two wrong-token checks (initial_long_token/ initial_short_token not matching the market's configured tokens) were reusing Error::Unauthorized, the same code raised for an actual caller-permission failure elsewhere in the contract. A client distinguishing failures by typed try_* error code couldn't tell "you aren't allowed to do this" apart from "the tokens you specified don't match this market's configuration". docs/exchange-router-api.md's create_deposit error table already documented TokenMismatch as if it existed; add that variant to deposit_handler's Error enum and raise it at both sites instead.
…n-event payloads, and Overview example Closes SO4-Markets#662 Closes SO4-Markets#663 Closes SO4-Markets#664 - SO4-Markets#662: §8 claim_funding_fees stated its event as fee_clm (FeeClaimed, emitted by claim_fees). It actually publishes fnd_clm (FundingFeeClaimed) — a different fee_handler event entirely. An indexer filtering on the documented topic would silently miss every claim_funding_fees call. - SO4-Markets#663: §2/§4/§6's "Events emitted" lines for create_order/ create_deposit/create_withdrawal still showed the pre-SO4-Markets#442 (key, caller, market) shape. All three were enriched by SO4-Markets#442 to include size/collateral/amount fields specifically so indexers could read pending-order details off the creation event without an extra RPC round-trip; updated all three to the current payload. - SO4-Markets#664: the Overview's "direct single-action helpers are also exposed" claim used create_order as its example — the one RouterAction variant (alongside send_tokens) that has no standalone entrypoint at all. Swapped in cancel_order/create_deposit as accurate examples and called out the exceptions explicitly.
|
@circleboyslimited Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits. You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀 |
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.
Summary
deposit_handler::create_depositraisedError::Unauthorizedfor a wrong-token/market-config mismatch (nothing to do with caller permissions), making that failure indistinguishable from an actual auth failure via typed error code. Added a dedicatedError::TokenMismatchvariant and raised it at both check sites instead — matching whatdocs/exchange-router-api.md's error table already (incorrectly) documented as existing.docs/exchange-router-api.md§8claim_funding_feesnamed the wrong event topic (fee_clm/FeeClaimed, actually emitted byclaim_fees) instead of the topicclaim_funding_feesreally publishes (fnd_clm/FundingFeeClaimed).create_order/create_deposit/create_withdrawalstill showed the pre-Order/deposit/withdrawal "created" events omit the amount/size being requested #442 3-field(key, caller, market)shape. Updated all three to the actual enriched payloads (size_delta_usd/collateral_delta_amount/order_type,long_token_amount/short_token_amount,market_token_amountrespectively).create_orderas its example — the oneRouterActionvariant (besidessend_tokens) that has no standalone entrypoint at all. Swapped in accurate examples (cancel_order,create_deposit) and called out the exceptions explicitly.Test plan
cargo build -p deposit-handler— compiles cleancargo test -p deposit-handler— 36 passed, 1 ignored (pre-existing, unrelated), 0 failed — includingcreate_deposit_wrong_long_token_reverts/create_deposit_wrong_short_token_revertsenv.events().publish(...)call sites in each handler,exchange_router's standalone entrypoint list)Closes #661
Closes #662
Closes #663
Closes #664