feat(replay): pool-state tape covers every exact-curve venue#415
Merged
Conversation
The tape's replay was limited to constant-product and CLMM venues; the StableSwap, Weighted, Cryptoswap, and Meteora DLMM curves existed for backtests but their pool history could not be recorded or replayed. - PoolVenue grows StableSwap / Weighted / Cryptoswap / MeteoraDlmm, each with a venue-shaped Descriptor and Checkpoint: the full balance vector for the n-token pools (Cryptoswap also re-anchors its price scale, which the chain repegs), and the bin book + volatility state for DLMM. - An n-token SwapDelta names its (i, j) pair explicitly; a swap off the connector's presented pair still moves the shared pool state and republishes the book, without printing a trade on the symbol. - MeteoraDlmmCurve::applySwap now moves the bin reserves it quotes from (each filled bin gains its net input and loses its output; the fee part is not compounded, so an on-chain checkpoint re-anchors it as drift), and the curve exposes the checkpoint surface (activeId, bins, volatility, timestamp) a recorder needs. - The drift check compares every balance entry, not just the first two. Round-trip, off-pair, and drift tests for each new venue; the tape docs describe the new checkpoint shapes.
Verified against the lb_clmm program source (Bin::swap): the bin gains amount_into_bin = amount_in_with_fees - fee -- the entire fee, LP share included, is tracked outside amount_x/amount_y as claimable. The replayed bin reserves therefore match an on-chain readback exactly; the earlier comments framed this as an unmodelled compounding, which was wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Extends the pool-state tape (#399, #400, #404) to the remaining exact-curve venues, so a StableSwap, Weighted, Cryptoswap, or Meteora DLMM pool can be recorded and replayed as a delta log too — until now those curves were backtest-only and their pool history had no tape format.
What changed:
Validation:
MCP impact
None. No public binding surface change; docs FTS index regenerated.
W23-T001