noramlize amount

This commit is contained in:
Hardhat Chad
2025-07-14 15:38:47 -07:00
parent 31c4da1d6d
commit ed0c994aab

View File

@@ -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;