Skip to content

Commit

Permalink
added getAccountTotalQueuedWithdrawals
Browse files Browse the repository at this point in the history
  • Loading branch information
BkChoy committed Oct 24, 2024
1 parent 5b4449d commit 71d6967
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions contracts/core/priorityPool/WithdrawalPool.sol
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,27 @@ contract WithdrawalPool is UUPSUpgradeable, OwnableUpgradeable {
return _getStakeByShares(totalQueuedShareWithdrawals);
}

/**
* @notice Returns the total amount of liquid staking tokens queued for withdrawal by an account
* @param _account address of account
* @return total amount queued across all account's withdrawals
*/
function getAccountTotalQueuedWithdrawals(address _account) external view returns (uint256) {
uint256[] memory withdrawalIds = getWithdrawalIdsByOwner(_account);
uint256[] memory batchIds = getBatchIds(withdrawalIds);

uint256 totalUnfinalizedWithdrawals;
for (uint256 i = 0; i < batchIds.length; ++i) {
Withdrawal memory withdrawal = queuedWithdrawals[withdrawalIds[i]];

if (batchIds[i] == 0) {
totalUnfinalizedWithdrawals += uint256(withdrawal.sharesRemaining);
}
}

return _getStakeByShares(totalUnfinalizedWithdrawals);
}

/**
* @notice Returns a list of withdrawals
* @param _withdrawalIds list of withdrawal ids
Expand Down

0 comments on commit 71d6967

Please sign in to comment.