feat(stablecoin): add collateral deposits

This commit is contained in:
Ricardo Guilherme Schmidt
2026-07-03 09:42:55 -03:00
parent 4a6192d84f
commit 2d486ed033
7 changed files with 513 additions and 4 deletions
@@ -46,6 +46,37 @@ mod stablecoin {
))
}
/// Deposit additional collateral tokens into an existing position vault.
///
/// # Errors
/// Returns the host program's panic-converted error if any precondition
/// fails (see
/// [`stablecoin_program::deposit_collateral::deposit_collateral`] for the
/// full list).
#[instruction]
pub fn deposit_collateral(
ctx: ProgramContext,
owner: AccountWithMetadata,
position: AccountWithMetadata,
vault: AccountWithMetadata,
user_holding: AccountWithMetadata,
amount: u128,
) -> SpelResult {
let (post_states, chained_calls) =
stablecoin_program::deposit_collateral::deposit_collateral(
owner,
position,
vault,
user_holding,
ctx.self_program_id,
amount,
);
Ok(spel_framework::SpelOutput::execute(
post_states,
chained_calls,
))
}
/// Withdraw `amount` collateral tokens from an existing position back to a
/// user-controlled holding.
///