@@ -303,6 +303,8 @@ contract WithdrawalQueue is AccessControlEnumerableUpgradeable, FeaturePausable
303303 * @param _stvToWithdraw Array of amounts of stv to withdraw
304304 * @param _stethSharesToRebalance Array of amounts of stETH shares to rebalance if supported by the pool, array of 0 otherwise
305305 * @return requestIds the created withdrawal request ids
306+ * @dev Transfers stv and liability shares from the requester to the withdrawal queue
307+ * @dev Requires fresh oracle report to price stv accurately
306308 */
307309 function requestWithdrawalBatch (
308310 address _owner ,
@@ -311,6 +313,7 @@ contract WithdrawalQueue is AccessControlEnumerableUpgradeable, FeaturePausable
311313 ) external returns (uint256 [] memory requestIds ) {
312314 _checkFeatureNotPaused (WITHDRAWALS_FEATURE);
313315 _checkArrayLength (_stvToWithdraw.length , _stethSharesToRebalance.length );
316+ _checkFreshReport ();
314317
315318 requestIds = new uint256 [](_stvToWithdraw.length );
316319 for (uint256 i = 0 ; i < _stvToWithdraw.length ; ++ i) {
@@ -325,12 +328,15 @@ contract WithdrawalQueue is AccessControlEnumerableUpgradeable, FeaturePausable
325328 * @param _stethSharesToRebalance Amount of steth shares to rebalance if supported by the pool, 0 otherwise
326329 * @return requestId The created withdrawal request id
327330 * @dev Transfers stv and liability shares from the requester to the withdrawal queue
331+ * @dev Requires fresh oracle report to price stv accurately
328332 */
329333 function requestWithdrawal (address _owner , uint256 _stvToWithdraw , uint256 _stethSharesToRebalance )
330334 external
331335 returns (uint256 requestId )
332336 {
333337 _checkFeatureNotPaused (WITHDRAWALS_FEATURE);
338+ _checkFreshReport ();
339+
334340 requestId = _requestWithdrawal (_owner, _stvToWithdraw, _stethSharesToRebalance);
335341 }
336342
@@ -562,15 +568,15 @@ contract WithdrawalQueue is AccessControlEnumerableUpgradeable, FeaturePausable
562568
563569 // Stv burning is limited at this point by maxStvToRebalance calculated above
564570 // to make sure that only stv of finalized requests is used for rebalancing
565- totalStvRebalanced = POOL.rebalanceMintedStethShares (totalStethShares, maxStvToRebalance);
571+ totalStvRebalanced = POOL.rebalanceMintedStethSharesForWithdrawalQueue (totalStethShares, maxStvToRebalance);
566572 }
567573
568574 // 3. Burn any remaining stv that was not used for rebalancing
569575 // The rebalancing may burn less stv than maxStvToRebalance because of:
570576 // - the changed stv rate after the first step
571577 // - accumulated rounding errors in maxStvToRebalance
572578 //
573- // It's guaranteed by POOL.rebalanceMintedStethShares () that maxStvToRebalance >= totalStvRebalanced
579+ // It's guaranteed by POOL.rebalanceMintedStethSharesForWithdrawalQueue () that maxStvToRebalance >= totalStvRebalanced
574580 uint256 remainingStvForRebalance = maxStvToRebalance - totalStvRebalanced;
575581 if (remainingStvForRebalance > 0 ) {
576582 POOL.burnStvForWithdrawalQueue (remainingStvForRebalance);
@@ -959,7 +965,7 @@ contract WithdrawalQueue is AccessControlEnumerableUpgradeable, FeaturePausable
959965 function _calcRequestAmounts (
960966 WithdrawalRequest memory _prevRequest ,
961967 WithdrawalRequest memory _request ,
962- Checkpoint memory checkpoint
968+ Checkpoint memory _checkpoint
963969 )
964970 internal
965971 pure
@@ -979,21 +985,21 @@ contract WithdrawalQueue is AccessControlEnumerableUpgradeable, FeaturePausable
979985 uint256 requestStvRate = (assetsToClaim * E36_PRECISION_BASE) / stv;
980986
981987 // Apply discount if the request stv rate is above the finalization stv rate
982- if (requestStvRate > checkpoint .stvRate) {
983- assetsToClaim = Math.mulDiv (stv, checkpoint .stvRate, E36_PRECISION_BASE, Math.Rounding.Floor);
988+ if (requestStvRate > _checkpoint .stvRate) {
989+ assetsToClaim = Math.mulDiv (stv, _checkpoint .stvRate, E36_PRECISION_BASE, Math.Rounding.Floor);
984990 }
985991
986992 if (stethSharesToRebalance > 0 ) {
987993 assetsToRebalance =
988- Math.mulDiv (stethSharesToRebalance, checkpoint .stethShareRate, E27_PRECISION_BASE, Math.Rounding.Ceil);
994+ Math.mulDiv (stethSharesToRebalance, _checkpoint .stethShareRate, E27_PRECISION_BASE, Math.Rounding.Ceil);
989995
990996 // Decrease assets to claim by the amount of assets to rebalance
991997 assetsToClaim = Math.saturatingSub (assetsToClaim, assetsToRebalance);
992998 }
993999
9941000 // Apply request finalization gas cost coverage
995- if (checkpoint .gasCostCoverage > 0 ) {
996- gasCostCoverage = Math.min (assetsToClaim, checkpoint .gasCostCoverage);
1001+ if (_checkpoint .gasCostCoverage > 0 ) {
1002+ gasCostCoverage = Math.min (assetsToClaim, _checkpoint .gasCostCoverage);
9971003 assetsToClaim -= gasCostCoverage;
9981004 }
9991005 }
@@ -1064,8 +1070,10 @@ contract WithdrawalQueue is AccessControlEnumerableUpgradeable, FeaturePausable
10641070 // CHECKS
10651071 // =================================================================================
10661072
1067- function _checkArrayLength (uint256 firstArrayLength , uint256 secondArrayLength ) internal pure {
1068- if (firstArrayLength != secondArrayLength) revert ArraysLengthMismatch (firstArrayLength, secondArrayLength);
1073+ function _checkArrayLength (uint256 _firstArrayLength , uint256 _secondArrayLength ) internal pure {
1074+ if (_firstArrayLength != _secondArrayLength) {
1075+ revert ArraysLengthMismatch (_firstArrayLength, _secondArrayLength);
1076+ }
10691077 }
10701078
10711079 function _checkFreshReport () internal view {
0 commit comments