Skip to content

Add SimpleSwap swap support - #481

Open
andreykr-simpleswap wants to merge 3 commits into
EdgeApp:masterfrom
andreykr-simpleswap:simpleswap/plugin
Open

Add SimpleSwap swap support#481
andreykr-simpleswap wants to merge 3 commits into
EdgeApp:masterfrom
andreykr-simpleswap:simpleswap/plugin

Conversation

@andreykr-simpleswap

@andreykr-simpleswap andreykr-simpleswap commented Aug 4, 2026

Copy link
Copy Markdown

CHANGELOG

Does this branch warrant an entry to the CHANGELOG?

  • Yes

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-rate
    quote 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. max quotes use
    a local probe for fee estimation, so no orders are created and
    abandoned along the way.
  • Chain mappings under src/mappings/ and a synchronizer under
    scripts/, generated from our live currency list with mapctl.
  • Plugin registration in src/index.ts.
  • test/simpleswap.test.ts — covers the mapping for every
    EdgeCurrencyPluginId, both quote directions, limit errors, the
    fixed-to-float fallback, currency code transcription, and the max
    path.

Init options: SIMPLESWAP_INIT: { "apiKey": "..." }. The factory
throws on an empty key, so builds without the key just skip the plugin.

Verification

  • npm run verify passes.
  • Quotes and order creation tested end to end against our sandbox in
    both directions: deposit addresses and order URIs come back correct.
  • Ran the full app from edge-react-gui in the iOS simulator: the plugin
    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) with x-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 becomes SwapPermissionError, and 404/422 become SwapCurrencyError. 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), large simpleswapMappings / auto-generated src/mappings/simpleswap.ts, CHANGELOG entry, and test/simpleswap.test.ts for 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.

Comment thread src/swap/central/simpleswap.ts
Comment thread src/swap/central/simpleswap.ts Outdated
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.

@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 f74bd87. Configure here.

Comment thread src/swap/central/simpleswap.ts
Pass the estimate's validUntil through ensureInFuture so a stale or
  clock-skewed timestamp can't produce an already-expired quote.
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.

1 participant