Skip to content

feat(dex): add Tessera-V (TesseraSwap) PropAMM trades on Base + BNB#9612

Merged
alicecha merged 8 commits intoduneanalytics:mainfrom
karimhass:feat/dex-tessera-v
May 4, 2026
Merged

feat(dex): add Tessera-V (TesseraSwap) PropAMM trades on Base + BNB#9612
alicecha merged 8 commits intoduneanalytics:mainfrom
karimhass:feat/dex-tessera-v

Conversation

@karimhass
Copy link
Copy Markdown
Contributor

@karimhass karimhass commented Apr 29, 2026

Summary

Adds the EVM Tessera-V (TesseraSwap) proprietary AMM as a new platform in dex.trades for both Base and BNB Chain, mirroring the existing Solana TesseraV spell (tessera_solana_trades).

Both chains share the same vanity-deployed router 0x55555522005bcae1c2424d474bfd5ed477749e3e emitting one Tesseratrade(address tokenIn, address tokenOut, uint256 amountIn, uint256 amountOut, address recipient) event per fill, ABI-decoded by Dune as tesseraswap_<chain>.tesseraswap_evt_tesseratrade.

The protocol architecture:

USER ──▶ aggregator / TesseraAdapter ──▶ 0x5555...749E3E (TesseraSwap router) ──▶ liquidity vault
                                                  │
                                                  ▼
                                  Tesseratrade event (decoded by Dune)

A separate keeper-driven inventory contract (0x3dBE077e7986657E95e1CC50089f17a5a4AF0AaE) handles off-chain rebalancing between operator and vault and is intentionally not included as a trades source — it would double-count aggregator volume already captured via other PMM/aggregator decoded events.

Changes

  • New platform models:
    • tessera_v_base_base_trades — sources tesseraswap_base.tesseraswap_evt_tesseratrade
    • tessera_v_bnb_base_trades — sources tesseraswap_bnb.tesseraswap_evt_tesseratrade
  • Wired into chain-level aggregators:
    • dex_base_base_trades
    • dex_bnb_base_trades
  • Registered the decoded sources:
    • sources/_sector/dex/trades/base/_sources.ymltesseraswap_base
    • sources/_sector/dex/trades/bnb/_sources.ymltesseraswap_bnb
  • Added _schema.yml entries with dbt_utils.unique_combination_of_columns + check_dex_base_trades_seed tests
  • Added one representative seed row per chain (tessera_v_base_base_trades_seed.csv, tessera_v_bnb_base_trades_seed.csv) and registered them in dbt_subprojects/dex/seeds/trades/_schema.yml
  • Added ('tessera_v', 'Tessera-V', 'Direct', 'tessera_v') to dex_info

Validation

Check Base BNB
Decoded source exists tesseraswap_base.tesseraswap_evt_tesseratrade tesseraswap_bnb.tesseraswap_evt_tesseratrade (currently backfilling)
Trades / 24h 16,498 1,392 (since backfill start)
Unique txs / 24h 14,334 1,341
Distinct recipients / 24h 477 99
Null token addresses 0 0
Null taker 0 0
Zero-amount rows 0 0
Compile passes

Test plan

  • dbt compile -s tessera_v_base_base_trades tessera_v_bnb_base_trades dex_base_base_trades dex_bnb_base_trades dex_info — passes locally
  • Decoded sources sanity-checked on Dune (row counts, null/zero distributions, sample row values match seeds exactly)
  • CI passes
  • Spot-check dex.trades row counts after merge once production tables build

Notes for reviewers

  • BNB decoding is a brand-new submission and is currently backfilling (started ~3h before this PR was opened). The BNB seed row was deliberately picked from the already-backfilled window (block_date = 2026-04-28). If the backfill has not progressed past the seed-row block by the time CI runs the seed test, please re-run CI once Dune confirms the BNB table is fully populated.
  • Project string is tessera_v (matching the user request and distinct from the Solana spell's tessera); marketplace_type is Direct.
  • Solana spell stays untouched.

Made with Cursor

Adds the EVM Tessera-V PropAMM as a new platform feeding dex.trades on
both Base and BNB Chain. Mirrors the Solana TesseraV spell architecture
(TessVdML9pBGgG9yGks7o4HewRaXVAMuoVj4x83GLQH).

Both chains share the same vanity-deployed TesseraSwap router
(0x55555522005bcae1c2424d474bfd5ed477749e3e) emitting one Tesseratrade
event per fill, ABI-decoded by Dune as
tesseraswap_<chain>.tesseraswap_evt_tesseratrade.

Changes
- new platform models tessera_v_base_base_trades and
  tessera_v_bnb_base_trades sourced from the decoded Tesseratrade event
- wired into dex_base_base_trades and dex_bnb_base_trades
- registered tesseraswap_base and tesseraswap_bnb in sector sources
- added unique-combo + seed tests for both models with one representative
  seed row per chain
- registered project in dex.dex_info

Validation
- decoded source row counts healthy (Base 16k+ trades/day, BNB 1.4k+
  during initial backfill window), zero null addresses, zero
  zero-amount rows
- compiled dex_base_base_trades and dex_bnb_base_trades successfully

Made-with: Cursor
@github-actions github-actions Bot marked this pull request as draft April 29, 2026 00:32
@cursor
Copy link
Copy Markdown

cursor Bot commented Apr 29, 2026

PR Summary

Medium Risk
Adds a new DEX trade source into the Base and BNB dex_*_base_trades unions; correctness depends on the decoded tesseraswap_* event schema/backfill and could impact reported volumes if mappings are wrong or incomplete.

Overview
Adds Tessera-V (TesseraSwap) PropAMM trade ingestion for Base and BNB by introducing new incremental platform models (tessera_v_*_base_trades) sourced from decoded tesseraswap_*.tesseraswap_evt_tesseratrade events.

Wires these models into the chain-level dex_base_base_trades/dex_bnb_base_trades unions, registers the new sources in _sources.yml, and adds schema metadata + seed-backed uniqueness/tests (plus new seed CSVs). Also registers tessera_v in dex_info for project lookup.

Reviewed by Cursor Bugbot for commit 3accccf. Configure here.

@github-actions github-actions Bot added WIP work in progress dbt: dex covers the DEX dbt subproject labels Apr 29, 2026
- Extract `tessera_v_compatible_trades` macro mirroring native_compatible_trades / clipper_compatible_trades pattern; reduces both per-chain models to thin macro wrappers
- Drop non-standard 'propamm'/'pmm' tags; use canonical [chain, dex, trades, project] tag set
- Set contributors to actual PR author
- Match short-form description style used by other dex.trades models

Made-with: Cursor
@karimhass karimhass marked this pull request as ready for review April 29, 2026 00:37
@github-actions github-actions Bot added ready-for-review this PR development is complete, please review and removed WIP work in progress labels Apr 29, 2026
karimhass and others added 3 commits April 29, 2026 13:21
…des OOM

Temporarily set dev_dates=true so the chain-level dex_<chain>_base_trades
UNIONs scan only the last 3 days during CI, sidestepping the transient
EXCEEDED_LOCAL_MEMORY_LIMIT (348GB) caused by the macro's ROW_NUMBER()
dedup over BNB's full historical UNION.

Platform models (tessera_v_base/bnb_base_trades) still build fully, so
their seed tests retain real signal. Maintainer to run `--full-refresh`
post-merge to backfill chain-level base_trades, or revert this flag
before merging.

Made-with: Cursor
@karimhass
Copy link
Copy Markdown
Contributor Author

Note for reviewer — temporary CI workaround applied

The previous CI run failed not because of the new Tessera-V models (both built fine: Base 4.76M rows / 8.7s, BNB 1.4K rows / 12.7s) but because the downstream chain-level model dex_bnb_base_trades OOM'd during full-refresh. The 332GB consumer was Trino's TopNRankingOperator from the existing ROW_NUMBER() OVER (...) = 1 deduplication step in dex_base_trades_macro.sql — the same macro that successfully built dex_base_base_trades (1.7B rows) on the same CI run. BNB just happens to sit at the cluster's per-node memory ceiling on full-refresh; recent merged PRs against this same model (#9525, #9552, #9558) have hit it without issue, so this is a transient capacity issue, not something the new models introduced.

To unblock CI, I've flipped dev_dates: true in dbt_subprojects/dex/dbt_project.yml (the standard escape hatch documented in the build-model skill). This restricts the chain-level UNIONs to a 3-day window during CI:

  • ✅ Both platform models (tessera_v_base/bnb_base_trades) still build fully and run their seed tests against real data.
  • ✅ Chain unions execute at ~0.01% of historical volume → no OOM, real CI signal.
  • ⚠️ Action required at merge: either revert dev_dates to false before merging, OR run --full-refresh on dex_bnb_base_trades and dex_base_base_trades post-merge to backfill the historical scans. Leaving the flag on silently caps production at 3 days.

Happy to revert in a final commit before merge — just let me know which path you prefer.

Maintainer to run --full-refresh on dex_<chain>_base_trades models
post-merge to backfill BNB chain history (skipped during dev_dates CI run).

Made-with: Cursor
@karimhass
Copy link
Copy Markdown
Contributor Author

Reverted dev_dates back to false in 8157b0d so this PR doesn't ship the temporary CI knob.

The validating CI signal is the prior green run on commit 8b3ffae: both new models built and passed all tests (Base 4.76M rows, BNB 1.4K rows, all seed + uniqueness tests green). The chain-level dex_bnb_base_trades is expected to OOM again on this push — that failure is unrelated to this PR (transient capacity issue in the existing ROW_NUMBER() dedup, see earlier comment) and should not block merge.

If a green check is required for merge, happy to re-flip dev_dates: true as a final commit. Otherwise, the maintainer can --full-refresh dex_bnb_base_trades post-merge as usual.

@karimhass
Copy link
Copy Markdown
Contributor Author

BNB backfill update — decoded source is now full-history

The Tessera-V backfill on BNB is essentially complete. Compared to the snapshot at PR open (1,401 rows, single day):

Chain Rows First trade Last trade Last 24h Last 7d Distinct days NULLs / zero-amount
base 4,775,102 2025-10-30 2026-04-29 15,803 107,605 179 0
bnb 2,833,155 2025-11-13 2026-04-29 23,435 100,525 118 0

Per-day breakdown for BNB shows steady activity (~5K–28K trades/day) with zero null fields and zero zero-amount rows across all 168 backfilled days — confirming the decoded tesseraswap_bnb.tesseraswap_evt_tesseratrade event is producing clean, production-ready output. Distinct in/out token counts (5–13/day) are consistent with PMM behavior on a curated set of pairs.

Once merged + --full-refresh'd, BNB Tessera-V will land in dex.trades with ~2.83M historical trades back to mid-November 2025.

Copy link
Copy Markdown
Contributor

@alicecha alicecha left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Verified against decoded sources — seed rows reconcile 1:1 on both chains, no nulls/zeros, no (tx_hash, evt_index) duplicates, single shared router 0x55555522…749e3e on both chains. The BNB backfill caveat in the description is now stale: tesseraswap_bnb.tesseraswap_evt_tesseratrade is fully caught up (last event ~minutes ago), so the seed-row block is safely covered and CI should pass without a re-run.

…solve

# Conflicts:
#	dbt_subprojects/dex/models/dex_info.sql
#	dbt_subprojects/dex/models/trades/base/_schema.yml
#	dbt_subprojects/dex/models/trades/bnb/_schema.yml
@alicecha alicecha merged commit 6066717 into duneanalytics:main May 4, 2026
2 of 3 checks passed
@github-actions github-actions Bot locked and limited conversation to collaborators May 4, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

dbt: dex covers the DEX dbt subproject ready-for-review this PR development is complete, please review

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants