docs(stablecoin): list all five OpenPosition accounts and qualify size_of_val

The `Instruction::OpenPosition` doc claimed four required accounts but the
handler and IDL take five — the collateral token definition was missing.
Update the list to match the actual contract.

Also fully qualify `std::mem::size_of_val` in `From<&Position> for Data`
so the call no longer relies on Rust 1.80+ prelude additions for the
2021 edition.
This commit is contained in:
Ricardo Guilherme Schmidt 2026-05-11 17:32:47 -03:00 committed by r4bbit
parent f4f7b45bd4
commit e63d09f793

View File

@ -21,15 +21,16 @@ pub enum Instruction {
/// Open a new collateral-only [`Position`] for the calling owner.
///
/// Required accounts (4):
/// Required accounts (5):
/// - Owner account (authorized)
/// - Position account (uninitialized, address must match
/// `compute_position_pda(stablecoin_program_id, owner)`)
/// - Position vault token holding account (uninitialized, address must match
/// `compute_position_vault_pda(stablecoin_program_id, position_id)`)
/// - Owner's source token holding for the collateral (authorized, initialized)
///
/// `token_program_id` is derived from the owner's collateral holding `program_owner`.
/// - Token definition account for the collateral (matches the user holding's
/// `definition_id`; its `program_owner` determines the Token Program used by the
/// chained `InitializeAccount` / `Transfer` calls)
OpenPosition {
/// `ProgramId` under which the [`Position`] and vault PDAs are derived.
stablecoin_program_id: ProgramId,
@ -64,7 +65,7 @@ impl TryFrom<&Data> for Position {
impl From<&Position> for Data {
fn from(position: &Position) -> Self {
let mut data = Vec::with_capacity(size_of_val(position));
let mut data = Vec::with_capacity(std::mem::size_of_val(position));
#[allow(
clippy::expect_used,
reason = "BorshSerialize::serialize is infallible when writing to a Vec"