Skip to content

feat(dex): add Agra DEX (ethereum, hyperevm) - #1

Closed
cxheng315 wants to merge 9 commits into
nyx-discochuck:combined-pharaoh-odos-ramsesfrom
cxheng315:agra-into-9833
Closed

feat(dex): add Agra DEX (ethereum, hyperevm)#1
cxheng315 wants to merge 9 commits into
nyx-discochuck:combined-pharaoh-odos-ramsesfrom
cxheng315:agra-into-9833

Conversation

@cxheng315

Copy link
Copy Markdown

Add Agra DEX on top of the combined branch

This PR stacks onto combined-pharaoh-odos-ramses (the branch behind duneanalytics#9833) and adds the
Agra integration, so it can be folded into the combined review alongside Pharaoh / Odos /
Ramses. The base of this PR is intentionally the combined branch, not main, so the diff shows
only the Agra delta (14 files, +252 lines). It is the same content as my standalone PR duneanalytics#9839,
rebased onto the combined branch.

What Agra is

Agra is a Seaport-fork order-settlement (direct) DEX. This integrates it into the DEX sector
for ethereum and hyperevm.

What's included

  • New source agra_multichain (sources/_sector/dex/trades/ethereum/_sources.yml) with
    settlement_evt_orderfulfilled and settlement_evt_ordersmatched — one multichain source
    serves both chains.
  • Platform base trades for both chains, generated from a shared
    agra_base_trades(blockchain, start_date) macro; each chain model is config + a one-line call.
  • Registered agra in dex_ethereum_base_trades / dex_hyperevm_base_trades and in dex_info.
  • Schema tests (unique_combination_of_columns, check_dex_base_trades_seed) + per-chain seeds.
  • Branded agra.trades project view via dex_project_trades('agra'); inherits amount_usd from
    the sector enrichment.

Overlap with the combined branch

Agra overlaps 9833 on exactly 4 files, all purely additive (kept both sides — nothing from
Pharaoh/Odos/Ramses/Nest dropped): dex_info.sql,
trades/hyperevm/dex_hyperevm_base_trades.sql, trades/hyperevm/_schema.yml, and
seeds/trades/_schema.yml. Everything else is new Agra-only files.

Notes

  • Decodes Seaport OrderFulfilled (offer → token_bought, consideration → token_sold) and dedupes
    the aggregate taker leg of matchOrders settlements.
  • volume_usd comes from the standard sector enrichment in dex.trades.
  • Start date: 2026-03-01.

🤖 Generated with Claude Code

cxheng315 and others added 9 commits July 9, 2026 11:34
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Drop the duplicated taker aggregate leg of Seaport matchOrders settlements
using settlement_evt_ordersmatched; set agra_start_date to 2026-03-01.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Collapse the near-identical agra_ethereum/agra_hyperevm base_trades models
(105 lines each, differing only by chain) into a parameterized
agra_base_trades(blockchain, start_date) macro. Each chain model is now
config + a one-line macro call. Compiled SQL is unchanged.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Add a branded agra.trades view via dex_project_trades('agra'), unioning the
enriched dex_<chain>_trades filtered to project = 'agra'. Inherits amount_usd
from the sector enrichment; currently covers ethereum and hyperevm. Register
the view in dex_trades_views_schema.yml.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Collapse offer/consideration to one deterministic row per (tx_hash,
evt_index) via row_number, so a malformed multi-token Agra order cannot
break the unique key or the incremental merge. Agra is a CLOB (1:1
settlement), so this is a no-op on all real data; verified output is
byte-identical to before. Uses a row_number subquery rather than QUALIFY,
which DuneSQL/Trino does not support.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@cxheng315

Copy link
Copy Markdown
Author

Closing — re-targeting to duneanalytics/spellbook main instead.

@cxheng315 cxheng315 closed this Jul 9, 2026
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