fn claim_redeemed_stake_for_batch_pending_withdrawal(
            contract: &mut Contract,
            account: &mut Account,
            account_batch: &mut domain::RedeemStakeBatch,
            mut receipt: domain::RedeemStakeBatchReceipt,
        ) {
            // how much STAKE did the account redeem in the batch
            let redeemed_stake = account_batch.balance().amount();

            let redeemed_stake_near_value =
                receipt.stake_token_value().stake_to_near(redeemed_stake);
            let claimed_near = if contract.near_liquidity_pool >= redeemed_stake_near_value {
                redeemed_stake_near_value
            } else {
                contract.near_liquidity_pool
            };
            let redeemable_stake = receipt.stake_token_value().near_to_stake(claimed_near);
            account_batch.remove(redeemable_stake);

            // claim the STAKE tokens for the account
            // let near = receipt.stake_token_value().stake_to_near(redeemable_stake);
            account.apply_near_credit(claimed_near);
            contract.near_liquidity_pool -= claimed_near;
            contract.total_near.credit(claimed_near);

            // track that the STAKE tokens were claimed
            receipt.stake_tokens_redeemed(redeemable_stake);
            if receipt.all_claimed() {
                // this means that effectively all funds have been withdrawn
                // which means we need to finalize the redeem workflow
                contract
                    .redeem_stake_batch_receipts
                    .remove(&account_batch.id());
                contract.redeem_stake_batch_lock = None;
                contract.pop_redeem_stake_batch();
            } else {
                contract
                    .redeem_stake_batch_receipts
                    .insert(&account_batch.id(), &receipt);
            }
        }
/// for a pending withdrawal, funds can also be claimed against the liquidity pool
for a pending withdrawal, funds can also be claimed against the liquidity pool
for a pending withdrawal funds can also be claimed against the liquidity pool
fn claim_redeemed_stake_for_batch_pending_withdrawal(
            contract: &mut Contract,
            account: &mut Account,
            account_batch: &mut domain::RedeemStakeBatch,
            mut receipt: domain::RedeemStakeBatchReceipt,
        ) {
            // how much STAKE did the account redeem in the batch
            let redeemed_stake = account_batch.balance().amount();
            let redeemed_stake_near_value =
                receipt.stake_token_value().stake_to_near(redeemed_stake);
            let claimed_near = if contract.near_liquidity_pool >= redeemed_stake_near_value {
                redeemed_stake_near_value
            } else {
                contract.near_liquidity_pool
            };
            let redeemable_stake = receipt.stake_token_value().near_to_stake(claimed_near);
            account_batch.remove(redeemable_stake);
            // claim the STAKE tokens for the account
            // let near = receipt.stake_token_value().stake_to_near(redeemable_stake);
            account.apply_near_credit(claimed_near);
            contract.near_liquidity_pool -= claimed_near;
            contract.total_near.credit(claimed_near);
            // track that the STAKE tokens were claimed
            receipt.stake_tokens_redeemed(redeemable_stake);
            if receipt.all_claimed() {
                // this means that effectively all funds have been withdrawn
                // which means we need to finalize the redeem workflow
                contract
                    .redeem_stake_batch_receipts
                    .remove(&account_batch.id());
                contract.redeem_stake_batch_lock = None;
                contract.pop_redeem_stake_batch();
            } else {
                contract
                    .redeem_stake_batch_receipts
                    .insert(&account_batch.id(), &receipt);
            }
        }
fn claim_redeemed_stake_for_batch_pending_withdrawal ( contract : & mut Contract , account : & mut Account , account_batch : & mut domain :: RedeemStakeBatch , mut receipt : domain :: RedeemStakeBatchReceipt , ) { // how much STAKE did the account redeem in the batch let redeemed_stake = account_batch . balance ( ) . amount ( ) ; let redeemed_stake_near_value = receipt . stake_token_value ( ) . stake_to_near ( redeemed_stake ) ; let claimed_near = if contract . near_liquidity_pool >= redeemed_stake_near_value { redeemed_stake_near_value } else { contract . near_liquidity_pool } ; let redeemable_stake = receipt . stake_token_value ( ) . near_to_stake ( claimed_near ) ; account_batch . remove ( redeemable_stake ) ; // claim the STAKE tokens for the account // let near = receipt.stake_token_value().stake_to_near(redeemable_stake); account . apply_near_credit ( claimed_near ) ; contract . near_liquidity_pool -= claimed_near ; contract . total_near . credit ( claimed_near ) ; // track that the STAKE tokens were claimed receipt . stake_tokens_redeemed ( redeemable_stake ) ; if receipt . all_claimed ( ) { // this means that effectively all funds have been withdrawn // which means we need to finalize the redeem workflow contract . redeem_stake_batch_receipts . remove ( & account_batch . id ( ) ) ; contract . redeem_stake_batch_lock = None ; contract . pop_redeem_stake_batch ( ) ; } else { contract . redeem_stake_batch_receipts . insert ( & account_batch . id ( ) , & receipt ) ; } }
for a pending withdrawal, funds can also be claimed against the liquidity pool
for a pending withdrawal funds can also be claimed against the liquidity pool
contract
&mut Contract
account
&mut Account
account_batch
&mut domain::RedeemStakeBatch
receipt
domain::RedeemStakeBatchReceipt