Skip to content

Commit

Permalink
feat: various
Browse files Browse the repository at this point in the history
  • Loading branch information
totomanov committed May 28, 2024
1 parent cb734f6 commit ce64f73
Showing 1 changed file with 6 additions and 8 deletions.
14 changes: 6 additions & 8 deletions src/FourSixTwoSixAgg.sol
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,6 @@ contract FourSixTwoSixAgg is BalanceForwarder, EVCUtil, ERC4626, AccessControlEn

error Reentrancy();
error ArrayLengthMismatch();
error AddressesOutOfOrder();
error DuplicateInitialStrategy();
error InitialAllocationPointsZero();
error NotEnoughAssets();
error NegativeYield();
Expand Down Expand Up @@ -181,9 +179,8 @@ contract FourSixTwoSixAgg is BalanceForwarder, EVCUtil, ERC4626, AccessControlEn
function harvestMultipleStrategies(address[] calldata _strategies) external nonReentrant {
for (uint256 i; i < _strategies.length; ++i) {
_harvest(_strategies[i]);

_gulp();
}
_gulp();
}

/// @notice Adjust a certain strategy's allocation points.
Expand Down Expand Up @@ -420,7 +417,8 @@ contract FourSixTwoSixAgg is BalanceForwarder, EVCUtil, ERC4626, AccessControlEn
totalAssetsDeposited -= assets;

uint256 assetsRetrieved = IERC20(asset()).balanceOf(address(this));
for (uint256 i; i < withdrawalQueue.length; ++i) {
uint256 numStrategies = withdrawalQueue.length;
for (uint256 i; i < numStrategies; ++i) {
if (assetsRetrieved >= assets) {
break;
}
Expand All @@ -430,16 +428,16 @@ contract FourSixTwoSixAgg is BalanceForwarder, EVCUtil, ERC4626, AccessControlEn
_harvest(address(strategy));
_gulp();

Strategy memory strategyData = strategies[withdrawalQueue[i]];
Strategy storage strategyStorage = strategies[address(strategy)];

uint256 sharesBalance = strategy.balanceOf(address(this));
uint256 underlyingBalance = strategy.convertToAssets(sharesBalance);

uint256 desiredAssets = assets - assetsRetrieved;
uint256 withdrawAmount = (underlyingBalance >= desiredAssets) ? desiredAssets : underlyingBalance;
uint256 withdrawAmount = (underlyingBalance > desiredAssets) ? desiredAssets : underlyingBalance;

// Update allocated assets
strategies[withdrawalQueue[i]].allocated = strategyData.allocated - uint120(withdrawAmount);
strategyStorage.allocated -= uint120(withdrawAmount);
totalAllocated -= withdrawAmount;

// update assetsRetrieved
Expand Down

0 comments on commit ce64f73

Please sign in to comment.