From ed0c994aab2c77e0a84add6e56d0be3c7f9c45b2 Mon Sep 17 00:00:00 2001 From: Hardhat Chad Date: Mon, 14 Jul 2025 15:38:47 -0700 Subject: [PATCH] noramlize amount --- program/src/withdraw.rs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/program/src/withdraw.rs b/program/src/withdraw.rs index 5f0ba22..df70436 100644 --- a/program/src/withdraw.rs +++ b/program/src/withdraw.rs @@ -39,6 +39,9 @@ pub fn process_withdraw(accounts: &[AccountInfo<'_>], data: &[u8]) -> ProgramRes return Err(ProgramError::InvalidArgument); } + // Normalize amount + let amount = amount.min(stake.collateral); + // Update stake state. stake.collateral -= amount;