Skip to content

RFP-004: DEX ecosystem behaviour appendix and vault accounting recommendation#41

Merged
fryorcraken merged 10 commits into
masterfrom
rfp/dex-vault-accounting-appendix
May 29, 2026
Merged

RFP-004: DEX ecosystem behaviour appendix and vault accounting recommendation#41
fryorcraken merged 10 commits into
masterfrom
rfp/dex-vault-accounting-appendix

Conversation

@fryorcraken
Copy link
Copy Markdown
Collaborator

@fryorcraken fryorcraken commented Apr 10, 2026

Summary

  • Add appendix/dex-ecosystem-behaviour.md surveying how 7 production DEX protocols (Uniswap V2/V4, Balancer V3, Curve StableSwapNG, CoW Protocol, Raydium, Orca Whirlpools) implement behaviours required by RFP-004.
  • Update RFP-004:
    • F.8 reframed: the DEX must be compatible with ATAs (accept a user-supplied ATA per (owner, mint)) without forcing them; pool-side vaults may use PDAs.
    • F.9 added: a permissionless sync() that folds surplus vault balances into the pool for the benefit of LPs.
    • Out of Scope: a skim()/recoverSurplus(to) instruction that extracts surplus to a caller-specified address. Among surveyed protocols only Uniswap V2 exposes this; reconciliation is handled exclusively by sync().
    • Align with template: CLI requirement, IDL via SPEL, CLI doc packet, Figma, soft multi-hop routing requirement, and compute-unit benchmarking promoted to a hard Performance requirement.
  • Platform Dependencies section added to RFP-004 (prose + structured frontmatter), matching the convention in RFPs 008/012-017/019/020. Statuses verified against logos-co/lambda-prize:
    • LP-0013 (token authorities) — open, hard blocker: the DEX custodies pool reserves, pays swap output, returns LP deposits, routes fees.
    • LP-0015 (general cross-program calls), LP-0014 (ATAs), LP-0012 (events) — closed, delivered.
  • Fact-checked the appendix against primary sources (~35 claims; core thesis that Uniswap V2 is the only surveyed protocol with sync()/skim() confirmed). Corrected: Orca fee tiers (9, not 6), Curve LP positions (LP token balances, not admin_balances), UNIfication date (2025-12-25), Uniswap V4 chain count (~12), and qualified the Uniswap V2 cumulative volume figure.
  • Formatted both files with mdformat per the repo README.

Research source: marclawclaw/research-dex

Test plan

  • Review appendix sections 1-10 for accuracy against research vault
  • Review section 10 recommendation (sync() vs skim()) with implementor
  • Confirm F.8/F.9 wording aligns with implementation
  • Confirm Platform Dependencies LP statuses are current at merge time

Fix logos-co/ecosystem#111

fryorcraken and others added 8 commits May 29, 2026 15:29
Add appendix documenting how existing DEX protocols implement
behaviours required by RFP-004: constant-product AMM, immutable fee
tiers, slippage protection, fee distribution, pool creation, single
transaction operations, pool analytics, ATA usage, and vault
accounting patterns.

Recommend implementing sync() (permissionless) and recoverSurplus()
(restricted to zero-liquidity pools) based on ecosystem analysis.
Add requirement F.9 to RFP-004 referencing the appendix.

Research source: github.com/marclawclaw/research-dex

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Remove recoverSurplus() recommendation. F.9 now requires only
  permissionless sync(); appendix section 10 describes ecosystem
  practice (Uniswap V2 sync/skim, V4/Balancer/Curve alternatives)
  without prescribing LEZ behaviour.
- Reframe F.8: the DEX program must be compatible with ATAs but
  must not force them. Pool vaults may use PDAs (matching Raydium
  and Orca); user-side accepts any valid SPL token account owned
  by the caller.
- Restructure appendix to describe what ecosystem DEXes do, not
  what LEZ should do. Recommendations belong in the RFP body.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
- Refresh Protocols Considered table from DeFiLlama (snapshot
  2026-04-27): V2 ~$970M, V4 ~$720M (~16 chains, was >$1B/17),
  Balancer V3 ~$80M post 2025-11 V2 exploit, Curve ~$1.7B,
  Raydium ~$1.0B, Orca ~$255M. Replace unsourced ">$300B" Orca
  cumulative with "$36B+ all-time" from Orca's own dashboards.
- Soften "over 100 forks" of V2 to a sourced characterisation.
- Clarify V2 protocol fee: UNIfication passed 2025-12-26; LPs
  receive 0.25%, protocol takes 0.05% (1/6 of 0.3%).
- Replace "98% gas reduction" round-number claim with the
  underlying TSTORE-vs-SSTORE gas costs (100 vs 20,000) per
  EIP-1153.
- Tighten section-10 table: V4 has `PoolManager.sync()` for
  flash-accounting balance checkpointing (not reserve
  reconciliation); previous wording read as "no sync at all".

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Brings RFP-004 in line with RFP-000-template.md and the structure
established by RFP-008:

- Usability: add CLI requirement (template item 3); reorder so SDK,
  mini-app, CLI, IDL come first as standard items, RFP-specific items
  follow.
- Supportability: split CI/test items, add doc packets for SDK and
  CLI, add Figma designs requirement.
- Add Soft Requirements section with multi-hop routing,
  recoverSurplus() (moved from F.9 to a soft requirement), and
  compute-unit benchmarking.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Remove the soft requirement and add an Out of Scope note. Among
surveyed protocols only Uniswap V2 implements a skim()-style
instruction; Uniswap V4, Balancer V3, Curve StableSwapNG, Raydium,
and Orca Whirlpools do not. Surplus reconciliation is handled
exclusively by the permissionless sync().

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
The template lists compute-unit documentation as a hard Performance
requirement. Consolidate it with the existing transaction-size
documentation requirement and drop the redundant soft item.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Align RFP-004 with the Dependencies convention now used across RFPs
008, 012-017, 019, and 020. Document LP-0013 (token authorities, open)
as the hard blocker for on-chain custody, and LP-0015/LP-0014/LP-0012
(all closed) as resolved dependencies, plus privacy primitives and the
compute-budget risk.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
- Orca Whirlpools has 9 tick spacings / fee tiers, not 6
  (tick spacings 1,2,4,8,16,32,64,128,256).
- Curve LP positions are tracked by LP token balances, not
  admin_balances[] (which holds accrued admin fees, per section 9).
- UNIfication proposal passed 2025-12-25 (on-chain vote close), not -26.
- Uniswap V4: ~12 mainnet deployments, not ~16.
- Qualify Uniswap V2 cumulative volume as V2-only DeFiLlama figure.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@fryorcraken fryorcraken force-pushed the rfp/dex-vault-accounting-appendix branch from 1c5ff49 to 1357d55 Compare May 29, 2026 05:33
@fryorcraken
Copy link
Copy Markdown
Collaborator Author

Rebased onto current master (conflict-free; master had not touched either file since the branch point) and made two additions:

1. Standardized Platform Dependencies section added to RFP-004. Aligns with the convention now used across RFPs 008, 012-017, 019, 020 (introduced in #64). RFP-004 was the last DeFi RFP missing it.

  • Hard blocker: LP-0013 (token authorities, open) — the DEX is a token custodian (holds pool reserves, pays swap output, returns LP deposits, routes fees), same gate as the lending RFP.
  • Resolved: LP-0015 (general CPC), LP-0014 (ATAs), LP-0012 (events), all closed (statuses verified against logos-co/lambda-prize).
  • Plus a Privacy primitives subsection (core LEE, not an LP) and a compute-budget Risk.

2. Fact-check pass on the appendix. Ran an independent verification of every claim against primary sources (protocol GitHub, official docs, EIP specs, DeFiLlama, governance records). ~35 claims checked; core thesis (Uniswap V2 is the only surveyed protocol with sync()/skim()) fully confirmed. Fixed:

  • Orca Whirlpools: 9 tick spacings / fee tiers, not 6 (tick spacings 1,2,4,8,16,32,64,128,256).
  • Curve LP positions tracked by LP token balances, not admin_balances[] (which holds accrued admin fees, consistent with the appendix's own section 9).
  • UNIfication proposal passed 2025-12-25 (on-chain vote close), not -26.
  • Uniswap V4: ~12 mainnet deployments, not ~16.
  • Qualified the Uniswap V2 cumulative volume figure as V2-only (DeFiLlama).

fryorcraken and others added 2 commits May 29, 2026 15:34
Per README formatting instructions (mdformat + mdformat-gfm +
mdformat-frontmatter, config in .mdformat.toml).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Mirror the structured dependencies list used in RFP-008 (id + reason).
Statuses verified against logos-co/lambda-prize: LP-0013 open (hard
blocker), LP-0015/LP-0014/LP-0012 closed (delivered).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@fryorcraken
Copy link
Copy Markdown
Collaborator Author

Follow-up to the above: also added the structured dependencies: list to the RFP-004 frontmatter (matching RFP-008's id + reason format; LP-0013 open, LP-0015/0014/0012 closed), and refreshed the PR description to match the final branch content.

All of the above is now consolidated into the PR description, so this thread is fully reflected there. Nothing outstanding.

@fryorcraken fryorcraken merged commit cd4dff9 into master May 29, 2026
@fryorcraken fryorcraken deleted the rfp/dex-vault-accounting-appendix branch May 29, 2026 05:43
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.

[RFP] Add appendix to dex and update

1 participant