Add SimpleSwap swap support - #481
Open
andreykr-simpleswap wants to merge 3 commits into
Open
Conversation
1 task
A fixed-rate quote that failed the range check never tried the float flow, whose limits can be wider, so users were blocked from a possible swap. Float is now attempted after any currency or limit error from the fixed flow; if the float flow lacks the pair entirely, the more actionable fixed-rate limit error is surfaced instead. Also types the catch clauses as unknown.
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 f74bd87. Configure here.
Pass the estimate's validUntil through ensureInFuture so a stale or clock-skewed timestamp can't produce an already-expired quote.
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.

CHANGELOG
Does this branch warrant an entry to the CHANGELOG?
Dependencies
none
Description
Context
This PR adds SimpleSwap (https://simpleswap.io) as a centralized swap
provider. We're the SimpleSwap engineering team — the plugin is built
against our public API v3, following CREATING_AN_EXCHANGE_PLUGIN.md and
the central template.
Changes
src/swap/central/simpleswap.ts— the plugin. Tries a fixed-ratequote first and falls back to a float rate. Supports both quote
directions, checks limits via our ranges endpoint before creating an
order, and maps API errors to the Edge error types.
maxquotes usea local probe for fee estimation, so no orders are created and
abandoned along the way.
src/mappings/and a synchronizer underscripts/, generated from our live currency list with mapctl.src/index.ts.test/simpleswap.test.ts— covers the mapping for everyEdgeCurrencyPluginId, both quote directions, limit errors, the
fixed-to-float fallback, currency code transcription, and the
maxpath.
Init options:
SIMPLESWAP_INIT: { "apiKey": "..." }. The factorythrows on an empty key, so builds without the key just skip the plugin.
Verification
npm run verifypasses.both directions: deposit addresses and order URIs come back correct.
builds, shows up in Exchange Settings, quotes btc->eth and creates
live orders on the sandbox.
Note
Medium Risk
New third-party swap path handles real deposits, refunds, and memos; mistakes in mappings or amount handling could misroute funds, though patterns match existing CEX plugins and tests cover key flows.
Overview
Adds SimpleSwap as a new centralized swap provider (
simpleswap), wired into the plugin registry and mapctl tooling.The plugin calls SimpleSwap API v3 (
ranges,estimates,exchanges) withx-api-key, maps Edge chains via generated mappings, and transcribes tickers where they differ (e.g. BNB →bnb-bsc). Quotes prefer fixed rates and fall back to float when fixed fails with currency/limit errors; API 403 becomesSwapPermissionError, and 404/422 becomeSwapCurrencyError. Max swaps use a local fee probe (skipChecks, spend-to-self) so only one live order is created.Also adds a mapctl synchronizer (
SIMPLESWAP_API_KEY, live/v3/currencies), largesimpleswapMappings/ auto-generatedsrc/mappings/simpleswap.ts, CHANGELOG entry, andtest/simpleswap.test.tsfor mappings, quote flows, limits, fallbacks, and max-quote behavior.Reviewed by Cursor Bugbot for commit 6528d19. Bugbot is set up for automated code reviews on this repo. Configure here.