Skip to content

Add Swapter partner plugin#224

Open
j0ntz wants to merge 1 commit into
masterfrom
jon/add-swapter-reporting
Open

Add Swapter partner plugin#224
j0ntz wants to merge 1 commit into
masterfrom
jon/add-swapter-reporting

Conversation

@j0ntz

@j0ntz j0ntz commented Jul 14, 2026

Copy link
Copy Markdown
Contributor

CHANGELOG

Does this branch warrant an entry to the CHANGELOG?

  • Yes
  • No

Dependencies

none

Description

Adds the Swapter exchange partner integration to the reports server. Recreated under the EdgeApp org from the external contributor PR #219 so we own the branch and can ship it.

Changes:

  • New src/partners/swapter.ts: querySwapter pages the POST /personal/exchange/tool-history endpoint (200/page) with X-Api-Key auth, retryFetch + snooze-backoff retry handling, and latestIsoDate tracking to skip already-processed orders. processSwapterTx cleans each raw record and converts it into a StandardTx (deposit/withdraw coin+amount+address, deposit.actual ?? deposit.amount, usdValue from info.equivalent with the -1 unknown guard).
  • Swapter status → Edge Status mapping covering all nine documented statuses plus an other fallback for unknown values.
  • Registers the swapter plugin (pluginId: swapter) in src/queryEngine.ts.

Testing:

  • processSwapterTx output validated against the canonical asStandardTx cleaner on a representative order; all status mappings, the actual ?? amount fallback, and the usdValue guard verified.
  • querySwapter run against the live https://api.swapter.io/personal/exchange/tool-history API with a throwaway non-prod key: HTTP 200, response accepted by asSwapterResult, empty history for the key so it returns [] cleanly. Missing-apiKey path short-circuits to [] without throwing.
  • tsc (via prepare/build.*) and eslint on the changed files pass. The util.test suite is red both on this branch and on pristine master (pre-existing sevenDayDataMerge / createQuarterBuckets failures, unrelated to this change).

Asana: https://app.asana.com/0/1215088146871429/1216466181647587


Note

Low Risk
Additive partner integration following existing plugin patterns; no changes to core auth, storage semantics, or shared reporting logic beyond registering one more plugin.

Overview
Adds Swapter as a new exchange partner so the reports query loop can ingest swap history into StandardTx records.

The new plugin posts to Swapter’s tool-history API with X-Api-Key, paginates (200 per page), applies a 5-day lookback from latestIsoDate, and retries failed requests with backoff. Raw orders are normalized via cleaners and mapped to standard fields (deposit/withdraw amounts and addresses, exchangeType: 'swap', status mapping for all documented Swapter states). usdValue uses info.equivalent when positive, otherwise -1. Missing API key returns no transactions without calling the API.

swapter (pluginId: 'swapter') is registered in the query engine plugin list, and the unreleased CHANGELOG notes the addition.

Reviewed by Cursor Bugbot for commit f053610. Bugbot is set up for automated code reviews on this repo. Configure here.


Comment thread src/partners/swapter.ts Outdated
Comment thread src/partners/swapter.ts Outdated
Comment thread src/partners/swapter.ts Outdated
Adds the Swapter exchange partner integration: querySwapter pages the
/personal/exchange/tool-history endpoint with retry handling and
latestIsoDate tracking, and processSwapterTx converts Swapter deposit/
withdraw records into StandardTx. Registers the swapter plugin in the
query engine.
@j0ntz
j0ntz force-pushed the jon/add-swapter-reporting branch from 93d5700 to f053610 Compare July 14, 2026 18:14

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

Comment thread src/partners/swapter.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.

1 participant