mirror of
https://github.com/d0zingcat/ore.git
synced 2026-05-13 15:09:57 +00:00
fix widthdraw
This commit is contained in:
@@ -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);
|
||||
|
||||
@@ -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.
|
||||
|
||||
Reference in New Issue
Block a user