Skip to content

Commit

Permalink
feat: remove from inner loop poc - costs more gas
Browse files Browse the repository at this point in the history
  • Loading branch information
johnnyonline committed Sep 27, 2024
1 parent 471afc7 commit 2918a37
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
2 changes: 2 additions & 0 deletions .gas-snapshot
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
ynLSDeDepositAdapterTest:testTotalAssetsGas() (gas: 760757)
ynLSDeWithdrawalsTest:testTotalAssetsGas() (gas: 760757)
11 changes: 7 additions & 4 deletions src/ynEIGEN/EigenStrategyManager.sol
Original file line number Diff line number Diff line change
Expand Up @@ -341,8 +341,9 @@ 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++ ) {
Expand All @@ -352,8 +353,9 @@ contract EigenStrategyManager is

(uint256 queuedShares, uint256 strategyWithdrawnBalance) = node.getQueuedSharesAndWithdrawn(strategy, asset);

if (queuedShares > 0) {
strategiesWithdrawalQueueBalance += strategy.sharesToUnderlyingView(queuedShares);
if (queuedShares > 0) { // @todo - remove from inner loop
// strategiesWithdrawalQueueBalance += strategy.sharesToUnderlyingView(queuedShares);
totalQueuedShares += queuedShares; // @note - this actually costs more gas!
}

strategiesWithdrawnBalance += strategyWithdrawnBalance;
Expand All @@ -362,7 +364,8 @@ contract EigenStrategyManager is
DynamicArrayLib.set(
stakedBalances,
j,
wrapper.toUserAssetAmount(asset, strategiesBalance + strategiesWithdrawalQueueBalance) + strategiesWithdrawnBalance
// wrapper.toUserAssetAmount(asset, strategiesBalance + strategiesWithdrawalQueueBalance) + strategiesWithdrawnBalance
wrapper.toUserAssetAmount(asset, strategiesBalance + strategy.sharesToUnderlyingView(totalQueuedShares)) + strategiesWithdrawnBalance
);
}

Expand Down

0 comments on commit 2918a37

Please sign in to comment.