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.
Goal
Expose deterministic position lookup and exact decoding for the current
Positionshape introduced by #304.Scope
Add pure
stablecoin_ffioperations for position and vault PDA derivationfrom
(owner_account_id, position_nonce)and for exactPositiondecoding.Add
positionAccount(request)toStablecoinModuleImpl, acceptingownerIdand exact decimal-stringpositionNonce.Derive the position and vault IDs internally, read the position account, and
validate:
Return derived IDs in base58 and hex plus
collateralAmount,normalizedDebtAmount, andopenedAtas exact decimal strings.Return the derived position/vault IDs with a stable
not_foundresult whenthat 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
nonce, or vault, malformed/truncated data, and trailing bytes.
Rust/C++/Logos boundary without precision loss.
nix build .#stablecoin-moduleand relevant Rust/module tests pass.Dependencies
Depends on the
stablecoin_modulescaffold andinitializeProgramsub-issueunder #321.
Out of scope
Submitting
open_position,withdraw_collateral, orrepay_debt; globalposition indexing; UI work.