From 9803beb4d9654676e094f308ca55421752411f7a Mon Sep 17 00:00:00 2001 From: johnnyonline Date: Sat, 28 Sep 2024 13:21:43 +0900 Subject: [PATCH] fix: revert last poc --- .gas-snapshot | 2 -- src/ynEIGEN/EigenStrategyManager.sol | 11 ++++------- src/ynEIGEN/TokenStakingNode.sol | 4 ++-- 3 files changed, 6 insertions(+), 11 deletions(-) delete mode 100644 .gas-snapshot diff --git a/.gas-snapshot b/.gas-snapshot deleted file mode 100644 index 00f008411..000000000 --- a/.gas-snapshot +++ /dev/null @@ -1,2 +0,0 @@ -ynLSDeDepositAdapterTest:testTotalAssetsGas() (gas: 760757) -ynLSDeWithdrawalsTest:testTotalAssetsGas() (gas: 760757) \ No newline at end of file diff --git a/src/ynEIGEN/EigenStrategyManager.sol b/src/ynEIGEN/EigenStrategyManager.sol index e1ff98756..ee64cf6e6 100644 --- a/src/ynEIGEN/EigenStrategyManager.sol +++ b/src/ynEIGEN/EigenStrategyManager.sol @@ -341,9 +341,8 @@ contract EigenStrategyManager is for (uint256 j = 0; j < assetsCount; j++) { uint256 strategiesBalance; - // uint256 strategiesWithdrawalQueueBalance; + uint256 strategiesWithdrawalQueueBalance; uint256 strategiesWithdrawnBalance; - uint256 totalQueuedShares; IERC20 asset = assets[j]; IStrategy strategy = strategies[asset]; for (uint256 i; i < nodesCount; i++ ) { @@ -353,9 +352,8 @@ contract EigenStrategyManager is (uint256 queuedShares, uint256 strategyWithdrawnBalance) = node.getQueuedSharesAndWithdrawn(strategy, asset); - if (queuedShares > 0) { // @todo - remove from inner loop - // strategiesWithdrawalQueueBalance += strategy.sharesToUnderlyingView(queuedShares); - totalQueuedShares += queuedShares; // @note - this actually costs more gas! + if (queuedShares > 0) { + strategiesWithdrawalQueueBalance += strategy.sharesToUnderlyingView(queuedShares); } strategiesWithdrawnBalance += strategyWithdrawnBalance; @@ -364,8 +362,7 @@ contract EigenStrategyManager is DynamicArrayLib.set( stakedBalances, j, - // wrapper.toUserAssetAmount(asset, strategiesBalance + strategiesWithdrawalQueueBalance) + strategiesWithdrawnBalance - wrapper.toUserAssetAmount(asset, strategiesBalance + strategy.sharesToUnderlyingView(totalQueuedShares)) + strategiesWithdrawnBalance + wrapper.toUserAssetAmount(asset, strategiesBalance + strategiesWithdrawalQueueBalance) + strategiesWithdrawnBalance ); } diff --git a/src/ynEIGEN/TokenStakingNode.sol b/src/ynEIGEN/TokenStakingNode.sol index 4818c11a0..7eef752d1 100644 --- a/src/ynEIGEN/TokenStakingNode.sol +++ b/src/ynEIGEN/TokenStakingNode.sol @@ -204,13 +204,13 @@ contract TokenStakingNode is uint256 _delta = _actualAmountOut > _expectedAmountOut ? _actualAmountOut - _expectedAmountOut : _expectedAmountOut - _actualAmountOut; - if (_delta > 2) revert WithdrawalAmountMismatch(); // @todo - might be a footgun + if (_delta > 2) revert WithdrawalAmountMismatch(); // @todo - remove this (bc of slashing) IWrapper _wrapper = IYieldNestStrategyManager(tokenStakingNodesManager.yieldNestStrategyManager()).wrapper(); IERC20(_token).forceApprove(address(_wrapper), _actualAmountOut); // NOTE: approving also token that will not be transferred (_actualAmountOut, _token) = _wrapper.wrap(_actualAmountOut, _token); - queuedShares[_strategy] -= _shares; + queuedShares[_strategy] -= _shares; // @todo - how to account for slashing (where we have less shares than what was originally recorded)? withdrawn[_token] += _actualAmountOut; emit CompletedQueuedWithdrawals(_shares, _actualAmountOut, address(_strategy));