Skip to content

Add SimpleSwap swap support - #481

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

Add SimpleSwap swap support#481
andreykr-simpleswap wants to merge 5 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 controls deposit amounts and addresses; mistakes could misquote or strand orders, though behavior mirrors other central plugins and is heavily tested.

Overview
Adds SimpleSwap as a new centralized swap provider, wired into the plugin registry and documented in the changelog.

The new plugin talks to SimpleSwap API v3: it checks ranges, fetches estimates, then creates an exchange and builds the deposit spendInfo (including deposit memos when extraIdFrom is present). Quotes prefer fixed rates and fall back to floating when fixed fails, with error ranking so limit/permission/pair errors are not masked by transient failures. Max swaps use a local fee probe (skipChecks spend to the user’s own address) so only one live order is created. Chain and ticker mapping comes from generated simpleswap maps plus a small currency-code transcription table; mapctl gains a synchronizer and SIMPLESWAP_API_KEY config.

Tests cover mappings for every EdgeCurrencyPluginId, both quote directions, limits, fixed→float fallback, max-quote behavior, and amount rounding guards.

Reviewed by Cursor Bugbot for commit e4ce498. 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.
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.

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

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