Title
[BFT-A][R8] Collapse CBE curve math to one canonical piecewise-linear engine
Category
- R8 Invariants & Observability
Authoritative Inputs
CBE Bonding Curve — Complete Formula Reference
CBE Bonding Curve — Rust Implementation Specification section 4
- Team decision: represent each band with
p_start, not signed intercept b
Problem
The current issue incorrectly excluded sell-path math. The new docs require one canonical piecewise-linear engine that supports:
price_at
cost_single_band
- multi-band mint traversal
inverse_mint
- redemption-value computation for
SELL_CBE
- flat-band special-case minting
Current Behavior
The branch still carries duplicate curve implementations, approximation paths, and inconsistent band logic across canonical.rs, pricing.rs, and token.rs.
Required Behavior
Create exactly one canonical curve math engine with:
- one band table
- one lookup rule
- one marginal price function using band-local form
m_i * (S - S_start_i) + p_start_i
- one exact single-band cost integral using the documented factored form in band-local coordinates
- one exact multi-band traversal algorithm for buys
- one exact multi-band redemption traversal for sells
- one exact inverse mint function
- one flat-band special-case path
The engine must be pure math only. No state access, no transaction parsing, no runtime dependencies.
Safety Impact
Multiple curve engines or mismatched buy/sell math create deterministic replay risk and break solvency/accounting invariants.
Proposed Fix
Replace the current parallel curve math paths with a single pure module built directly from the p_start-based band/cost/inverse formulas.
Dependencies
Acceptance Criteria
Test Plan
- Band continuity tests
- Band boundary lookup tests
- Cross-band mint-cost equality tests
- Inverse normalization vectors
- Multi-band sell/redemption vectors
- Flat-band vectors
Cleanup After
- Remove native authority from duplicate curve math in
pricing.rs and token.rs
- Remove comments/tests that still describe spot-price minting shortcuts or signed intercept storage
Title
[BFT-A][R8] Collapse CBE curve math to one canonical piecewise-linear engine
Category
Authoritative Inputs
CBE Bonding Curve — Complete Formula ReferenceCBE Bonding Curve — Rust Implementation Specificationsection 4p_start, not signed interceptbProblem
The current issue incorrectly excluded sell-path math. The new docs require one canonical piecewise-linear engine that supports:
price_atcost_single_bandinverse_mintSELL_CBECurrent Behavior
The branch still carries duplicate curve implementations, approximation paths, and inconsistent band logic across
canonical.rs,pricing.rs, andtoken.rs.Required Behavior
Create exactly one canonical curve math engine with:
m_i * (S - S_start_i) + p_start_iThe engine must be pure math only. No state access, no transaction parsing, no runtime dependencies.
Safety Impact
Multiple curve engines or mismatched buy/sell math create deterministic replay risk and break solvency/accounting invariants.
Proposed Fix
Replace the current parallel curve math paths with a single pure module built directly from the
p_start-based band/cost/inverse formulas.Dependencies
Acceptance Criteria
p_startformcost_single_bandimplementation matches the documented order of operations and band-local factored formulaSELL_CBEis implementedTest Plan
Cleanup After
pricing.rsandtoken.rs