Skip to content

Track Layerswap transactions through the explorer API - #502

Open
babgev wants to merge 1 commit into
DefiLlama:masterfrom
babgev:layerswap-explorer-feed
Open

Track Layerswap transactions through the explorer API#502
babgev wants to merge 1 commit into
DefiLlama:masterfrom
babgev:layerswap-explorer-feed

Conversation

@babgev

@babgev babgev commented Jul 31, 2026

Copy link
Copy Markdown

Summary

Replace Layerswap's solver-address/on-chain transfer tracking with ingestion from the public Layerswap explorer API.

Each swap is recorded as:

  • a deposit on the source chain using the input transaction
  • a withdrawal on the destination chain using the output transaction

Both legs are stored as USD-volume transactions using their individual transaction hashes and timestamps.

Why

The previous implementation inferred Layerswap activity by scanning transfers involving a maintained list of solver addresses.

The new implementation reads swap and transaction information directly from the Layerswap explorer API.

Implementation

  • Add a dedicated scheduled Layerswap handler.
  • Fetch completed swaps from /api/v2/explorer.
  • Paginate using the starting_after cursor and stop using the close_date cutoff.
  • Use the latest stored transaction as a checkpoint with a one-hour overlap.
  • Process pages oldest-first and upsert rows to keep retries idempotent.
  • Use each transaction's own timestamp and amount_in_usd.
  • Omit legs without a valid positive USD amount.
  • Map Layerswap API network identifiers to bridges-server chain keys.
  • Update the advertised Layerswap network list, including EVM and non-EVM networks.
  • Retry rate limits and server errors with backoff.
  • Handle cancellation, invalid responses, invalid cursors, and missing configuration explicitly.
  • Report unknown API networks as a degraded run without dropping recognized networks.
  • Exclude Layerswap from the generic on-chain adapter scheduler.

Cutover behavior

When no API-ingestion checkpoint exists, processing starts from the deployment cutover instead of backfilling historical API data. This avoids overlapping with the period covered by the previous on-chain adapter.

Test plan

  • npm run ts
  • npm run build
  • npm run test:server
    • 106 tests passed
    • Covers the full server, handler, helper, and utility test suite, including Layerswap API parameters, pagination, cursor handling, oldest-first processing, chain mappings, USD amounts, transaction timestamps, invalid data, and cancellation

@babgev
babgev force-pushed the layerswap-explorer-feed branch from 557c6c6 to 62bbaf1 Compare July 31, 2026 18:50
@babgev
babgev marked this pull request as ready for review July 31, 2026 18:55
@babgev
babgev force-pushed the layerswap-explorer-feed branch from 62bbaf1 to 28c39ab Compare August 4, 2026 12:13
@arkoc

arkoc commented Aug 12, 2026

Copy link
Copy Markdown
Contributor

Hey @vrtnd can you please merge this PR, this is updated on top of this one: #297

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