Add NYM swap provider#457
Open
j0ntz wants to merge 1 commit into
Open
Conversation
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes 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 5cc72ff. Configure here.
Integrate NYM as a centralized swap provider. NYM provides its own liquidity, so every swap must have the NYM asset on one side; the plugin gates this locally before calling the API. NYM exposes an Edge-shaped partner API: native-unit amounts (no denomination conversion) and asset references of chainNetwork + optional EVM chainId + 0x contract-address tokenId. Sepolia is represented as chainNetwork 'ethereum' with chainId 11155111. The plugin enforces the min/max limits returned by the quote endpoint and parses NYM's JSON error bodies into the appropriate swap errors. Testnet-only for now. Validated end-to-end (quote + order) against the NYM testnet API.
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
Asana task
Integrate NYM as a centralized swap provider (
pluginId: nym).Asana: https://app.asana.com/1/9976422036640/project/1213880789473005/task/1215306512581867
NYM provides its own swap liquidity, so every swap must have the NYM asset on one side. The plugin gates this locally before hitting the API to avoid offering NYM (and rate-limiting it) on unrelated pairs.
NYM exposes an Edge-shaped partner API, which keeps the plugin thin:
sourceAmount/destinationAmountare already in the chain's smallest unit (matching Edge'snativeAmount), so no denomination conversion is needed in either direction.{ chainNetwork, chainId?, tokenId? }.chainNetworkis the network-family name (mapped from the EdgepluginId),chainIdcomes from the wallet'sevmChainId, andtokenIdis the 0x contract address (not the Edge tokenId). Sepolia is represented aschainNetwork: 'ethereum'+chainId: 11155111.SwapBelowLimitError/SwapAboveLimitError.{ errors: [{ error, message }] }and{ error }) are parsed intoSwapCurrencyError/SwapPermissionError, with rate-limit/other failures surfaced as transient errors.Files:
src/swap/central/nym.ts— the provider.src/mappings/nym.ts—EdgeCurrencyPluginId → chainNetwork, scoped to the current testnet asset list (BTC, LTC, ZEC, DASH, Sepolia ETH/USDC, ADA, NYM).src/index.ts— registersnym: makeNymPlugin.Testnet-only for now. Base URL points at the NYM testnet API; the mapping (and base URL) should be expanded when NYM launches mainnet. The init option is
{ apiKey }(headerx-api-key); GUI wiring is a separate follow-up.Validated end-to-end against the live NYM testnet API:
GET /currencies, andPOST /quote→POST /orderfor both buy-NYM (e.g. USDC→NYM) and sell-NYM (e.g. NYM→Sepolia ETH, NYM→ADA) directions, plus the unsupported-pair / wrong-tokenId-format error paths.Note
Medium Risk
New third-party swap path that sets pay-in addresses and amounts; mitigated by testnet-only endpoints and patterns shared with other CEX plugins, but still user-fund flow if misconfigured.
Overview
Adds a testnet-only centralized swap provider (
nym) wired into the plugin registry and documented in the CHANGELOG.The new plugin talks to NYM’s partner API (
quotethenorder) withx-api-keyauth. It only offers pairs where NYM is on one side, rejects unmapped chains locally, and maps Edge wallets to NYM asset refs (chainNetwork, optionalchainId, 0xtokenId). Quotes use native amounts with min/max enforcement, then build depositspendInfo(including Zcash transparent payout/refund) and swap metadata. Order tracking URLs are built from a fixedORDER_URIprefix, not the API’sstatusUrl. API errors are mapped toSwapCurrencyError/SwapPermissionErrorwhere appropriate.src/mappings/nym.tsdefines the current testnetpluginId→chainNetworktable (BTC, LTC, ZEC, DASH, ADA, Sepolia-as-ethereum, NYM sandbox).Reviewed by Cursor Bugbot for commit e721125. Bugbot is set up for automated code reviews on this repo. Configure here.