This commit is contained in:
Hardhat Chad
2025-10-01 18:46:49 -07:00
parent 236f166913
commit c745ed19e9
8 changed files with 75 additions and 17 deletions

View File

@@ -19,16 +19,12 @@ pub fn process_claim_sol(accounts: &[AccountInfo<'_>], data: &[u8]) -> ProgramRe
system_program.is_program(&system_program::ID)?;
// Normalize amount.
let total_claimable = miner.rewards_sol + miner.refund_sol;
let amount = total_claimable.min(amount);
let amount = miner.rewards_sol.min(amount);
sol_log(&format!("Claiming {} SOL", lamports_to_sol(amount)).as_str());
// Update miner. Deduct from refund first, then from rewards.
let from_refund = amount.min(miner.refund_sol);
miner.refund_sol -= from_refund;
let from_rewards = amount - from_refund;
miner.rewards_sol -= from_rewards;
// Update miner.
miner.rewards_sol -= amount;
// Transfer reward to recipient.
miner_info.send(amount, signer_info);