Add swaps.xyz swap provider - #480
Conversation
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
3d2bdb3 to
9541abd
Compare
|
bugbot run |
There was a problem hiding this comment.
✅ 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.
9541abd to
c5ba82e
Compare
c5ba82e to
e1fae89
Compare
e1fae89 to
97ab5c4
Compare
97ab5c4 to
731100b
Compare
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.
c19f45c to
2414049
Compare
2414049 to
92f4d7b
Compare
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.
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.
92f4d7b to
151ec8e
Compare
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes using high effort and found 1 potential issue.
❌ 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.




















CHANGELOG
Does this branch warrant an entry to the CHANGELOG?
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'svmId, so each gets its own cleaner and spend builder:evm: router calldata.datais'0x'on a plain value send to a bridge contract, which must not become an empty hex memo.solana: an unsigned v0VersionedTransactionhanded to the engine throughotherParams.unsignedTx.alt-vm: a deposit address on the source chain, withtoExtracarrying the memo or tag when the chain needs one.hypercoreand any non-DEFAULTexecution type are rejected. 26 non-EVM chains are mapped from a livegetChainList, keyed on the reportedvmIdrather than on whether the chain id looks EVM: 314, 10000, 2000 are all real EVM chain ids AND all taggedalt-vm, confirmed by the deposit-address format each returns.Order registration. Routes flagged
requiresRegisterTransactionPOST the broadcast hash back to swaps.xyz, wrapping the quote'sapprovesincemakeSwapPluginQuotehas 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 markedisEstimate: 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 expectedamountOutand calling the route an estimate.minReceiveAmountis 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.