Skip to content

Expose redemption price state through stablecoin_module #324

Description

@3esmit

Goal

Expose the singleton RedemptionPriceState account through
stablecoin_module, using the signed controller state and PDA contract added
by #303.

Scope

  • Add a pure stablecoin_ffi operation that derives the redemption-price-state
    PDA and exactly decodes stablecoin_core::RedemptionPriceState from a
    validated public-account read.
  • Add redemptionPriceState() to StablecoinModuleImpl. It must derive and
    read the singleton account rather than accept an arbitrary account ID.
  • Return both account-ID encodings plus
    redemptionPriceAtLastUpdate, redemptionRatePerMillisecond,
    controllerIntegralTerm, and lastUpdatedAt.
  • Preserve u128, signed i128, and u64 values as exact decimal strings.
  • Reject an absent account, wrong PDA, wrong program owner, malformed/truncated
    data, trailing bytes, or backend read failure with stable error codes.
  • Keep current-price projection and controller simulation out of this raw-state
    read; those are covered by the feat(stablecoin): add current value projection helpers #311 and feat(stablecoin): add redemption rate controller + clamp constants #312 API sub-issues.

Acceptance criteria

  • PDA derivation matches
    compute_redemption_price_state_pda(stablecoin_program_id) for fixed vectors
    and the configured deployed program.
  • Positive, zero, negative, minimum, and maximum controllerIntegralTerm
    values round-trip without sign or precision loss.
  • Decoder tests cover valid state, uninitialized state, wrong owner, wrong PDA,
    truncated data, trailing data, and boundary integer values.
  • Module tests prove one live read of the derived account and stable public
    response/error shapes.
  • nix build .#stablecoin-module and relevant Rust/module tests pass.

Dependencies

Depends on the stablecoin_module scaffold and initializeProgram sub-issue
under #321.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

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