Skip to content

feat(external-match): v2 API migration with backwards-compatible v1 shims#266

Merged
akirillo merged 1 commit intomainfrom
andrew/v2-external-match-client
Feb 19, 2026
Merged

feat(external-match): v2 API migration with backwards-compatible v1 shims#266
akirillo merged 1 commit intomainfrom
andrew/v2-external-match-client

Conversation

@akirillo
Copy link
Contributor

Summary

Migrates the external-match package from v0 to v2 API routes internally, following the same pattern as the Rust SDK. All existing public types and methods are preserved via conversion layers (v1 order → v2, v2 response → v1), while malleable match types adopt breaking v2 input/output terminology. Adds new getMarkets(), getMarketDepth(), and getMarketDepthsAllPairs() methods; deprecated v1 methods (getSupportedTokens, getTokenPrices, getOrderBookDepth, getOrderBookDepthAllPairs) are shimmed through v2 endpoints.

Breaking changes

  • ExternalMatchClient constructor: 4 args → 3 (no separate relayerUrl)
  • MalleableExternalMatchResponse: rewritten with v2 input/output terminology (setInputAmount, inputBounds, outputBounds, etc.)
  • AssembleExternalMatchOptions: removed requestGasSponsorship and gasRefundAddress
  • Removed deprecated factory methods newSepoliaClient and newMainnetClient
  • SignedGasSponsorshipInfo.signature is now optional (v2 has no separate signature)

Test plan

  • pnpm typecheck passes
  • pnpm build produces valid dist/
  • pnpm lint passes
  • Conversion functions compared line-by-line against Rust SDK v1_conversions.rs

🤖 Generated with Claude Code

@akirillo akirillo requested a review from sehyunc February 17, 2026 23:16
@sehyunc
Copy link
Contributor

sehyunc commented Feb 18, 2026

Nice work — the conversion layer is faithful to the Rust SDK and the structure is clean. Two things worth looking at:

1. allow_shared is orphaned

AssembleExternalMatchOptions.allowShared still has a public field and builder method, but AssembleExternalMatchRequestV2 never includes it. Consumers will set it with no effect. Since this PR is already breaking, might be cleanest to just remove it — or at minimum mark @deprecated.

2. invertPriceString silently propagates NaN

The Rust version returns an error on parse failure. The TS version uses parseFloat which returns NaN on bad input, so you'd get 1/NaN → NaN → "NaN" flowing through as a price string. A quick guard would help:

function invertPriceString(priceStr: string): string {
    const price = Number.parseFloat(priceStr);
    if (Number.isNaN(price) || price === 0) {
        return "0";
    }
    return (1.0 / price).toString();
}

@akirillo akirillo force-pushed the andrew/v2-external-match-client branch from aee85d9 to 0be2750 Compare February 19, 2026 00:33
@akirillo akirillo merged commit 8b64d2a into main Feb 19, 2026
1 check failed
@akirillo akirillo deleted the andrew/v2-external-match-client branch February 19, 2026 01:20
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.

2 participants