fix widthdraw

This commit is contained in:
Hardhat Chad
2025-07-15 17:39:46 -07:00
parent 1a7dd8867f
commit 4a3f61bc71
2 changed files with 5 additions and 3 deletions

View File

@@ -94,7 +94,7 @@ pub fn process_commit(accounts: &[AccountInfo<'_>], data: &[u8]) -> ProgramResul
// Send lamports to permit account to pay for fee.
if permit.fee > 0 {
let rent_exempt_balance = Rent::get()?.minimum_balance(size_of::<Permit>());
let rent_exempt_balance = Rent::get()?.minimum_balance(std::mem::size_of::<Permit>());
let surplus_balance = permit_info.lamports().saturating_sub(rent_exempt_balance);
let total_fees = permit.commitment * permit.fee;
let required_fees = total_fees.saturating_sub(surplus_balance);

View File

@@ -22,7 +22,8 @@ pub fn process_withdraw(accounts: &[AccountInfo<'_>], data: &[u8]) -> ProgramRes
let stake = stake_info
.as_account_mut::<Stake>(&ore_api::ID)?
.assert_mut(|p| p.authority == *signer_info.key)?;
block_info.has_seeds(&[BLOCK, &stake.block_id.to_le_bytes()], &ore_api::ID)?;
let block_pda = block_pda(stake.block_id);
block_info.has_address(&block_pda.0)?;
collateral_info
.is_writable()?
.has_address(&collateral_pda(stake.block_id).0)?
@@ -46,13 +47,14 @@ pub fn process_withdraw(accounts: &[AccountInfo<'_>], data: &[u8]) -> ProgramRes
stake.collateral -= amount;
// Transfer collateral.
transfer_signed(
transfer_signed_with_bump(
block_info,
collateral_info,
recipient_info,
token_program,
amount,
&[BLOCK, &stake.block_id.to_le_bytes()],
block_pda.1,
)?;
// Close stake account, if empty.