Skip to content

Expose stablecoin position resolution and decoding #325

Description

@3esmit

Goal

Expose deterministic position lookup and exact decoding for the current
Position shape introduced by #304.

Scope

  • Add pure stablecoin_ffi operations for position and vault PDA derivation
    from (owner_account_id, position_nonce) and for exact Position decoding.

  • Add positionAccount(request) to StablecoinModuleImpl, accepting
    ownerId and exact decimal-string positionNonce.

  • Derive the position and vault IDs internally, read the position account, and
    validate:

    • stablecoin program ownership and expected position PDA
    • stored owner and nonce equal the request
    • stored vault equals the expected vault PDA
  • Return derived IDs in base58 and hex plus collateralAmount,
    normalizedDebtAmount, and openedAt as exact decimal strings.

  • Return the derived position/vault IDs with a stable not_found result when
    that owner/nonce has no position, allowing clients to distinguish absence
    from malformed state.

  • Do not claim global position enumeration. The on-chain program has no index;
    callers must know or manage owner nonces.

Acceptance criteria

  • Fixed-vector tests pin both PDA derivations and their domain separation.
  • Exact decoding rejects wrong owner, wrong program, mismatched stored owner,
    nonce, or vault, malformed/truncated data, and trailing bytes.
  • Full-range collateral, normalized debt, nonce, and timestamp values cross the
    Rust/C++/Logos boundary without precision loss.
  • Module tests cover valid, absent, malformed, and invariant-mismatch reads.
  • Public response/error maps remain stable and machine-readable.
  • nix build .#stablecoin-module and relevant Rust/module tests pass.

Dependencies

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

Out of scope

Submitting open_position, withdraw_collateral, or repay_debt; global
position indexing; UI work.

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