From e63d09f793fed47dc640a58518de6d652ae734e2 Mon Sep 17 00:00:00 2001 From: Ricardo Guilherme Schmidt <3esmit@gmail.com> Date: Mon, 11 May 2026 17:32:47 -0300 Subject: [PATCH] docs(stablecoin): list all five `OpenPosition` accounts and qualify `size_of_val` MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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. --- stablecoin/core/src/lib.rs | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/stablecoin/core/src/lib.rs b/stablecoin/core/src/lib.rs index ad96cc7..35be9e3 100644 --- a/stablecoin/core/src/lib.rs +++ b/stablecoin/core/src/lib.rs @@ -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"