From e8fe618cd1aab6a3aaf510814635b7b8219d4306 Mon Sep 17 00:00:00 2001 From: 1marcghannam <1marc.ghannam@gmail.com> Date: Tue, 28 Jan 2025 09:34:43 -0500 Subject: [PATCH] feat: add pp helper read --- contracts/core/priorityPool/PriorityPool.sol | 24 ++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/contracts/core/priorityPool/PriorityPool.sol b/contracts/core/priorityPool/PriorityPool.sol index dcc9e9d..e413511 100644 --- a/contracts/core/priorityPool/PriorityPool.sol +++ b/contracts/core/priorityPool/PriorityPool.sol @@ -205,6 +205,30 @@ contract PriorityPool is UUPSUpgradeable, OwnableUpgradeable, PausableUpgradeabl return stakingPool.getStakeByShares(sharesToClaim); } + /** + * @notice Returns the current amount of withdrawable LSD tokens for multiple accounts + * @dev _distributionShareAmounts are stored on IPFS and should align with the provided accounts + * @param _accounts List of account addresses + * @param _distributionShareAmounts List of distribution share amounts corresponding to each account + * @return Array of withdrawable LSD token amounts for each account + */ + function getLSDTokensBatch( + address[] calldata _accounts, + uint256[] calldata _distributionShareAmounts + ) external view returns (uint256[] memory) { + require(_accounts.length == _distributionShareAmounts.length, "Input length mismatch"); + + uint256[] memory withdrawableAmounts = new uint256[](_accounts.length); + + for (uint256 i = 0; i < _accounts.length; i++) { + address account = _accounts[i]; + uint256 sharesToClaim = _distributionShareAmounts[i] - accountSharesClaimed[account]; + withdrawableAmounts[i] = stakingPool.getStakeByShares(sharesToClaim); + } + + return withdrawableAmounts; + } + /** * @notice Returns the total amount of asset tokens that an account can withdraw * @dev includes account's queued tokens and LST balance and checks both priority pool