Skip to content

[BFT-A][R8] Establish canonical CBE curve types and fixed-point state model #1923

@umwelt

Description

@umwelt

Title

[BFT-A][R8] Establish canonical CBE curve types and fixed-point state model

Category

  • R8 Invariants & Observability

Authoritative Inputs

  • CBE Bonding Curve — Complete Formula Reference
  • CBE Bonding Curve — Rust Implementation Specification
  • Team decision: band storage uses p_start (price at band start), not algebraic signed intercept b

Problem

The current issue assumed a broader native economics model with approved assets, oracle price records, and treasury-valued SOV issuance. The new curve docs define a narrower and stricter consensus surface for the CBE bonding curve.

Current Behavior

There is no single canonical type layer for the exact curve-state model described by the new docs. The repo still spreads shape information across bonding-curve modules, pricing code, transaction code, and runtime assumptions.

Required Behavior

Create one canonical type layer in lib-types for the curve protocol described by the docs:

  • BandConfig
  • EconomicState
  • AccountState
  • fixed-width u48 nonce representation
  • BuyCbeTx payload shape
  • SellCbeTx payload shape
  • immutable curve constants/config shape

Band storage must use positive p_start (price at s_start) rather than algebraic signed intercept b.

The canonical mutable curve state for this epic is:

  • s_c: u128
  • reserve_balance: u128
  • treasury_balance: u128
  • graduated: bool

The curve also integrates with an external SOV sink for fee collection (dao_treasury_sov in the execution spec), but that does not create a second authoritative curve-state model.

This issue is not about approved-asset registries, oracle price records, or treasury-valued BUY_SOV.

Safety Impact

Without a canonical type boundary, the implementation will drift away from the transaction layout, arithmetic rules, and state transition model required by the new spec.

Proposed Fix

Move pure curve protocol data types into lib-types. Keep behavior in domain crates through extension traits/helpers only.

Dependencies

None

Acceptance Criteria

  • Canonical curve types exist in lib-types
  • Canonical band record uses unsigned u128 p_start
  • Canonical mutable state matches the new docs exactly
  • u48 nonce representation is defined and serialization-stable
  • No duplicate authoritative type definitions remain outside lib-types
  • Type architecture rule is followed

Test Plan

  • Type serialization round-trip tests
  • u48 packing/unpacking tests
  • Band record invariant tests
  • State shape regression tests against the spec examples

Cleanup After

  • Stop introducing new authoritative curve types in lib-blockchain
  • Remove issue text and code comments that still describe the broader pre-doc native economics model or signed intercept storage

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions