Skip to content

Add swaps.xyz swap provider - #480

Open
j0ntz wants to merge 8 commits into
masterfrom
jon/swapsxyz-integrate
Open

Add swaps.xyz swap provider#480
j0ntz wants to merge 8 commits into
masterfrom
jon/swapsxyz-integrate

Conversation

@j0ntz

@j0ntz j0ntz commented Jul 31, 2026

Copy link
Copy Markdown
Contributor

CHANGELOG

Does this branch warrant an entry to the CHANGELOG?

  • Yes
  • No

Dependencies

none

Description

Adds swaps.xyz (a MoonPay product) as a centralized swap provider, routing EVM, Solana and deposit-address chains through one plugin.

Asana Task: https://app.asana.com/0/1215088146871429/1217036054017879

Route models. getAction's payload shape depends on the SOURCE chain's vmId, so each gets its own cleaner and spend builder:

  • evm: router calldata. data is '0x' on a plain value send to a bridge contract, which must not become an empty hex memo.
  • solana: an unsigned v0 VersionedTransaction handed to the engine through otherParams.unsignedTx.
  • alt-vm: a deposit address on the source chain, with toExtra carrying the memo or tag when the chain needs one.

hypercore and any non-DEFAULT execution type are rejected. 26 non-EVM chains are mapped from a live getChainList, keyed on the reported vmId rather than on whether the chain id looks EVM: 314, 10000, 2000 are all real EVM chain ids AND all tagged alt-vm, confirmed by the deposit-address format each returns.

Order registration. Routes flagged requiresRegisterTransaction POST the broadcast hash back to swaps.xyz, wrapping the quote's approve since makeSwapPluginQuote has no post-broadcast hook. A registration failure is logged and swallowed: the swap is already on chain by then, so throwing would report a successful swap as failed.

Fixed-rate quotes. The quote publishes amountOutMin, the route's on-chain floor, and is marked isEstimate: false. The user may receive more and can never receive less, which is what a fixed quote asserts. This is swaps.xyz's own recommendation over quoting the expected amountOut and calling the route an estimate. minReceiveAmount is left unset because the quoted amount IS the minimum.

Tiered slippage. 10 bps when both legs are stablecoins, 50 bps when both are stable or major, 100 bps otherwise; a route takes its looser leg. Because the quote publishes the floor, a tighter band directly raises the amount the user is guaranteed. The tiers are overridable at runtime from the info server through opts.infoPayload.slippageBps, so they can be retuned per asset class with no app release.

Testing. One real in-app swap per route model driven to the Congratulations! scene on the iOS sim: EVM source into an alt-vm destination, an alt-vm source (deposit spend plus the registration callback), a Solana source, and Base USDC to Arbitrum USDC for the fixed-quote change. That last one quoted 3.493 USDC with no variable marker, sat under the Fixed Quotes section, and delivered 3.494 USDC against the 3.493 floor. Unit suite covers both quote shapes and every slippage tier; screenshots are attached in the comments.

@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

@j0ntz

j0ntz commented Jul 31, 2026

Copy link
Copy Markdown
Contributor Author

📸 Test evidence (iOS sim — real swaps.xyz swap)

swapsxyz quote

swapsxyz quote

swapsxyz success

swapsxyz success

Captured by the agent's in-app test run (build-and-test).

@j0ntz
j0ntz marked this pull request as draft July 31, 2026 18:35
@j0ntz
j0ntz marked this pull request as ready for review July 31, 2026 18:35
@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

@j0ntz

j0ntz commented Aug 3, 2026

Copy link
Copy Markdown
Contributor Author

bugbot run

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Bugbot reviewed your changes and found no new issues!

Comment @cursor review or bugbot run to trigger another review on this PR

Reviewed by Cursor Bugbot for commit 9541abd. Configure here.

Comment thread src/mappings/swapsxyz.ts
Comment thread src/swap/central/swapsxyz.ts
@j0ntz
j0ntz force-pushed the jon/swapsxyz-integrate branch from 9541abd to c5ba82e Compare August 3, 2026 23:19
Comment thread src/swap/central/swapsxyz.ts
@j0ntz

j0ntz commented Aug 3, 2026

Copy link
Copy Markdown
Contributor Author

📸 Test evidence (after review fixes): swaps.xyz swap executed on the iOS sim

swapsxyz quote

swapsxyz quote

swap success

swap success

tx details

tx details

tx list row

tx list row

Captured by the agent's in-app test run (build-and-test).

@j0ntz
j0ntz force-pushed the jon/swapsxyz-integrate branch from c5ba82e to e1fae89 Compare August 3, 2026 23:42
Comment thread src/swap/defi/swapsxyz.ts Outdated
Comment thread src/swap/central/swapsxyz.ts
Comment thread src/swap/central/swapsxyz.ts
@j0ntz
j0ntz force-pushed the jon/swapsxyz-integrate branch from e1fae89 to 97ab5c4 Compare August 4, 2026 00:01
Comment thread src/swap/central/swapsxyz.ts Outdated
@j0ntz
j0ntz force-pushed the jon/swapsxyz-integrate branch from 97ab5c4 to 731100b Compare August 4, 2026 00:15
Integrate swaps.xyz (a MoonPay cross-chain DEX/bridge aggregator) as a new
DEX swap plugin. The provider's getAction endpoint returns executable EVM
calldata plus amountOut/amountOutMin and a token-approval flag, so the plugin
builds an EVM spend (calldata memo + optional ERC20 approval pre-tx) modeled on
the existing lifi plugin. Supports the EVM chains swaps.xyz confirms live;
non-EVM VMs and unmapped chains are rejected with SwapCurrencyError.
@j0ntz
j0ntz force-pushed the jon/swapsxyz-integrate branch 2 times, most recently from c19f45c to 2414049 Compare August 4, 2026 18:32
@j0ntz

j0ntz commented Aug 4, 2026

Copy link
Copy Markdown
Contributor Author

📸 Test evidence (decimal-limit fix, limit-publishing route)

sonic quote decimal limits

sonic quote decimal limits

sonic swap success

sonic swap success

Captured by the agent's in-app test run (build-and-test).

@j0ntz
j0ntz force-pushed the jon/swapsxyz-integrate branch from 2414049 to 92f4d7b Compare August 5, 2026 01:21
@j0ntz

j0ntz commented Aug 5, 2026

Copy link
Copy Markdown
Contributor Author

📸 Test evidence: one in-app swap per route model (CEX reclass + solana/alt-vm dispatch)

evm to altvm quote

evm to altvm quote

evm to altvm success

evm to altvm success

altvm source quote

altvm source quote

altvm source success

altvm source success

solana quote

solana quote

solana success

solana success

Captured by the agent's in-app test run (build-and-test).

Comment thread src/swap/central/swapsxyz.ts
Comment thread src/swap/central/swapsxyz.ts
Comment thread src/swap/central/swapsxyz.ts Outdated
Comment thread src/swap/central/swapsxyz.ts
j0ntz added 2 commits August 4, 2026 18:31
Cover the plugin's typed swap errors end to end: drive fetchSwapQuote with a
faked io and wallets and assert SwapCurrencyError, SwapBelowLimitError and
SwapAboveLimitError for the guard, getAction-error and success-response paths,
plus one happy-path quote and a check that an unrecognized error code stays a
plain Error rather than a mis-ranked swap error.
j0ntz added 3 commits August 4, 2026 18:31
Top-level orientation for coding agents: build/test/verify commands, the
central-vs-defi plugin split, the fetchSwapQuote pipeline, the typed-error
ranking contract (and when a plain Error is correct), chain mappings, the
pure-and-end-to-end testing patterns, and pointers to the docs/ guides and
the .cursor/agents review sub-agents.
@j0ntz
j0ntz force-pushed the jon/swapsxyz-integrate branch from 92f4d7b to 151ec8e Compare August 5, 2026 01:40
@j0ntz

j0ntz commented Aug 5, 2026

Copy link
Copy Markdown
Contributor Author

📸 Test evidence (after review fixes)

retest after review fixes

retest after review fixes

Captured by the agent's in-app test run (build-and-test).

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes using high effort and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 151ec8e. Configure here.

Comment thread src/mappings/swapsxyz.ts
@j0ntz

j0ntz commented Aug 19, 2026

Copy link
Copy Markdown
Contributor Author

📸 Test evidence (fixed-rate quotes + tiered slippage)

fixed quote no tilde

fixed quote no tilde

fixed quotes section

fixed quotes section

swap success

swap success

delivered balance

delivered balance

Captured by the agent's in-app test run (build-and-test).

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