diff --git a/src/Dispatch.sol b/src/core/Dispatch.sol similarity index 80% rename from src/Dispatch.sol rename to src/core/Dispatch.sol index 9d94fe20..78534a08 100644 --- a/src/Dispatch.sol +++ b/src/core/Dispatch.sol @@ -2,7 +2,7 @@ pragma solidity ^0.8.0; //contracts -import {Shared} from "./Shared.sol"; +import {Shared} from "./common/Shared.sol"; import {HooksModule} from "./module/Hooks.sol"; import {RewardsModule} from "./module/Rewards.sol"; @@ -17,6 +17,11 @@ abstract contract Dispatch is RewardsModule, HooksModule { address public immutable MODULE_FEE; address public immutable MODULE_ALLOCATION_POINTS; + /// @dev Constructor. + /// @param _rewardsModule Address of Rewards module. + /// @param _hooksModule Address of Hooks module. + /// @param _feeModule Address of Fee module. + /// @param _allocationPointsModule Address of AllocationPoints module. constructor(address _rewardsModule, address _hooksModule, address _feeModule, address _allocationPointsModule) Shared() { @@ -29,10 +34,10 @@ abstract contract Dispatch is RewardsModule, HooksModule { // Modifier proxies the function call to a module and low-level returns the result modifier use(address module) { _; // when using the modifier, it is assumed the function body is empty. - delegateToModule(module); + _delegateToModule(module); } - function delegateToModule(address module) private { + function _delegateToModule(address module) private { assembly { calldatacopy(0, 0, calldatasize()) let result := delegatecall(gas(), module, 0, calldatasize(), 0, 0) diff --git a/src/AggregationLayerVault.sol b/src/core/EulerAggregationLayer.sol similarity index 97% rename from src/AggregationLayerVault.sol rename to src/core/EulerAggregationLayer.sol index d2b0168a..ed321133 100644 --- a/src/AggregationLayerVault.sol +++ b/src/core/EulerAggregationLayer.sol @@ -5,7 +5,7 @@ pragma solidity ^0.8.0; import {IERC4626} from "@openzeppelin/contracts/interfaces/IERC4626.sol"; import {IERC20} from "@openzeppelin/contracts/token/ERC20/ERC20.sol"; import {IBalanceTracker} from "reward-streams/interfaces/IBalanceTracker.sol"; -import {IAggregationLayerVault} from "./interface/IAggregationLayerVault.sol"; +import {IEulerAggregationLayer} from "./interface/IEulerAggregationLayer.sol"; import {IWithdrawalQueue} from "./interface/IWithdrawalQueue.sol"; // contracts import {Dispatch} from "./Dispatch.sol"; @@ -15,7 +15,7 @@ import { } from "@openzeppelin-upgradeable/token/ERC20/extensions/ERC4626Upgradeable.sol"; import {AccessControlEnumerableUpgradeable} from "@openzeppelin-upgradeable/access/extensions/AccessControlEnumerableUpgradeable.sol"; -import {Shared} from "./Shared.sol"; +import {Shared} from "./common/Shared.sol"; import {ContextUpgradeable} from "@openzeppelin-upgradeable/utils/ContextUpgradeable.sol"; // libs import {SafeERC20} from "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol"; @@ -25,17 +25,17 @@ import {StorageLib, AggregationVaultStorage} from "./lib/StorageLib.sol"; import {ErrorsLib as Errors} from "./lib/ErrorsLib.sol"; import {EventsLib as Events} from "./lib/EventsLib.sol"; -/// @title AggregationLayerVault contract +/// @title EulerAggregationLayer contract /// @custom:security-contact security@euler.xyz /// @author Euler Labs (https://www.eulerlabs.com/) /// @dev Do NOT use with fee on transfer tokens /// @dev Do NOT use with rebasing tokens /// @dev inspired by Yearn v3 ❤️ -contract AggregationLayerVault is +contract EulerAggregationLayer is ERC4626Upgradeable, AccessControlEnumerableUpgradeable, Dispatch, - IAggregationLayerVault + IEulerAggregationLayer { using SafeERC20 for IERC20; using SafeCast for uint256; @@ -59,7 +59,7 @@ contract AggregationLayerVault is Dispatch(_rewardsModule, _hooksModule, _feeModule, _allocationPointsModule) {} - /// @notice Initialize the AggregationLayerVault. + /// @notice Initialize the EulerAggregationLayer. /// @param _initParams InitParams struct. function init(InitParams calldata _initParams) external initializer { __ERC4626_init_unchained(IERC20(_initParams.asset)); @@ -69,8 +69,8 @@ contract AggregationLayerVault is AggregationVaultStorage storage $ = StorageLib._getAggregationVaultStorage(); $.locked = REENTRANCYLOCK__UNLOCKED; - $.withdrawalQueue = _initParams.withdrawalQueuePeriphery; - $.strategies[address(0)] = IAggregationLayerVault.Strategy({ + $.withdrawalQueue = _initParams.withdrawalQueuePlugin; + $.strategies[address(0)] = IEulerAggregationLayer.Strategy({ allocated: 0, allocationPoints: _initParams.initialCashAllocationPoints.toUint120(), active: true, @@ -82,8 +82,6 @@ contract AggregationLayerVault is // Setup DEFAULT_ADMIN _grantRole(DEFAULT_ADMIN_ROLE, _initParams.aggregationVaultOwner); - // By default, the Rebalancer contract is assigned the REBALANCER role - _grantRole(REBALANCER, _initParams.rebalancerPerihpery); // Setup role admins _setRoleAdmin(ALLOCATIONS_MANAGER, ALLOCATIONS_MANAGER_ADMIN); @@ -91,6 +89,9 @@ contract AggregationLayerVault is _setRoleAdmin(STRATEGY_REMOVER, STRATEGY_REMOVER_ADMIN); _setRoleAdmin(AGGREGATION_VAULT_MANAGER, AGGREGATION_VAULT_MANAGER_ADMIN); _setRoleAdmin(REBALANCER, REBALANCER_ADMIN); + + // By default, the Rebalancer contract is assigned the REBALANCER role + _grantRole(REBALANCER, _initParams.rebalancerPlugin); } /// @dev See {FeeModule-setFeeRecipient}. @@ -189,7 +190,7 @@ contract AggregationLayerVault is { AggregationVaultStorage storage $ = StorageLib._getAggregationVaultStorage(); - IAggregationLayerVault.Strategy memory strategyData = $.strategies[_strategy]; + IEulerAggregationLayer.Strategy memory strategyData = $.strategies[_strategy]; if (_isDeposit) { // Do required approval (safely) and deposit @@ -269,7 +270,7 @@ contract AggregationLayerVault is /// @notice Get strategy params. /// @param _strategy strategy's address /// @return Strategy struct - function getStrategy(address _strategy) external view returns (IAggregationLayerVault.Strategy memory) { + function getStrategy(address _strategy) external view returns (IEulerAggregationLayer.Strategy memory) { AggregationVaultStorage storage $ = StorageLib._getAggregationVaultStorage(); return $.strategies[_strategy]; diff --git a/src/AggregationLayerVaultFactory.sol b/src/core/EulerAggregationLayerFactory.sol similarity index 81% rename from src/AggregationLayerVaultFactory.sol rename to src/core/EulerAggregationLayerFactory.sol index 4167ef58..3d0c06e2 100644 --- a/src/AggregationLayerVaultFactory.sol +++ b/src/core/EulerAggregationLayerFactory.sol @@ -5,15 +5,15 @@ pragma solidity ^0.8.0; import {Rewards} from "./module/Rewards.sol"; import {Hooks} from "./module/Hooks.sol"; import {Fee} from "./module/Fee.sol"; -import {WithdrawalQueue} from "./plugin/WithdrawalQueue.sol"; -import {AggregationLayerVault, IAggregationLayerVault} from "./AggregationLayerVault.sol"; +import {WithdrawalQueue} from "../plugin/WithdrawalQueue.sol"; +import {EulerAggregationLayer, IEulerAggregationLayer} from "./EulerAggregationLayer.sol"; // libs import {Clones} from "@openzeppelin/contracts/proxy/Clones.sol"; -/// @title AggregationLayerVaultFactory contract +/// @title EulerAggregationLayerFactory contract /// @custom:security-contact security@euler.xyz /// @author Euler Labs (https://www.eulerlabs.com/) -contract AggregationLayerVaultFactory { +contract EulerAggregationLayerFactory { /// core dependencies address public immutable evc; address public immutable balanceTracker; @@ -62,7 +62,7 @@ contract AggregationLayerVaultFactory { /// @param _name Vaut name. /// @param _symbol Vault symbol. /// @param _initialCashAllocationPoints The amount of points to initally allocate for cash reserve. - /// @return aggregationLayerVault The address of the new deployed aggregation layer vault. + /// @return eulerAggregationLayer The address of the new deployed aggregation layer vault. function deployEulerAggregationLayer( address _asset, string memory _name, @@ -79,14 +79,14 @@ contract AggregationLayerVaultFactory { WithdrawalQueue withdrawalQueue = WithdrawalQueue(Clones.clone(withdrawalQueueImpl)); // deploy new aggregation vault - AggregationLayerVault aggregationLayerVault = - new AggregationLayerVault(rewardsModuleAddr, hooksModuleAddr, feeModuleAddr, allocationpointsModuleAddr); + EulerAggregationLayer eulerAggregationLayer = + new EulerAggregationLayer(rewardsModuleAddr, hooksModuleAddr, feeModuleAddr, allocationpointsModuleAddr); - IAggregationLayerVault.InitParams memory aggregationVaultInitParams = IAggregationLayerVault.InitParams({ + IEulerAggregationLayer.InitParams memory aggregationVaultInitParams = IEulerAggregationLayer.InitParams({ evc: evc, balanceTracker: balanceTracker, - withdrawalQueuePeriphery: address(withdrawalQueue), - rebalancerPerihpery: rebalancer, + withdrawalQueuePlugin: address(withdrawalQueue), + rebalancerPlugin: rebalancer, aggregationVaultOwner: msg.sender, asset: _asset, name: _name, @@ -94,9 +94,9 @@ contract AggregationLayerVaultFactory { initialCashAllocationPoints: _initialCashAllocationPoints }); - withdrawalQueue.init(msg.sender, address(aggregationLayerVault)); - aggregationLayerVault.init(aggregationVaultInitParams); + withdrawalQueue.init(msg.sender, address(eulerAggregationLayer)); + eulerAggregationLayer.init(aggregationVaultInitParams); - return address(aggregationLayerVault); + return address(eulerAggregationLayer); } } diff --git a/src/Shared.sol b/src/core/common/Shared.sol similarity index 95% rename from src/Shared.sol rename to src/core/common/Shared.sol index 22a2411a..cd45771f 100644 --- a/src/Shared.sol +++ b/src/core/common/Shared.sol @@ -5,9 +5,9 @@ pragma solidity ^0.8.0; import {IEVC} from "ethereum-vault-connector/utils/EVCUtil.sol"; import {IHookTarget} from "evk/src/interfaces/IHookTarget.sol"; // libs -import {StorageLib, AggregationVaultStorage} from "./lib/StorageLib.sol"; -import {HooksLib} from "./lib/HooksLib.sol"; -import {ErrorsLib as Errors} from "./lib/ErrorsLib.sol"; +import {StorageLib, AggregationVaultStorage} from "../lib/StorageLib.sol"; +import {HooksLib} from "../lib/HooksLib.sol"; +import {ErrorsLib as Errors} from "../lib/ErrorsLib.sol"; /// @title Shared contract /// @custom:security-contact security@euler.xyz diff --git a/src/interface/IBalanceForwarder.sol b/src/core/interface/IBalanceForwarder.sol similarity index 100% rename from src/interface/IBalanceForwarder.sol rename to src/core/interface/IBalanceForwarder.sol diff --git a/src/interface/IAggregationLayerVault.sol b/src/core/interface/IEulerAggregationLayer.sol similarity index 94% rename from src/interface/IAggregationLayerVault.sol rename to src/core/interface/IEulerAggregationLayer.sol index 9d37ae7d..cbabbb13 100644 --- a/src/interface/IAggregationLayerVault.sol +++ b/src/core/interface/IEulerAggregationLayer.sol @@ -1,13 +1,13 @@ // SPDX-License-Identifier: GPL-2.0-or-later pragma solidity ^0.8.0; -interface IAggregationLayerVault { +interface IEulerAggregationLayer { /// @dev Struct to pass init() call params. struct InitParams { address evc; address balanceTracker; - address withdrawalQueuePeriphery; - address rebalancerPerihpery; + address withdrawalQueuePlugin; + address rebalancerPlugin; address aggregationVaultOwner; address asset; string name; diff --git a/src/interface/IWithdrawalQueue.sol b/src/core/interface/IWithdrawalQueue.sol similarity index 100% rename from src/interface/IWithdrawalQueue.sol rename to src/core/interface/IWithdrawalQueue.sol diff --git a/src/lib/ErrorsLib.sol b/src/core/lib/ErrorsLib.sol similarity index 100% rename from src/lib/ErrorsLib.sol rename to src/core/lib/ErrorsLib.sol diff --git a/src/lib/EventsLib.sol b/src/core/lib/EventsLib.sol similarity index 97% rename from src/lib/EventsLib.sol rename to src/core/lib/EventsLib.sol index 199e9707..024b6915 100644 --- a/src/lib/EventsLib.sol +++ b/src/core/lib/EventsLib.sol @@ -2,7 +2,7 @@ pragma solidity ^0.8.0; library EventsLib { - /// @dev AggregationLayerVault events + /// @dev EulerAggregationLayer events event Gulp(uint256 interestLeft, uint256 interestSmearEnd); event AccruePerformanceFee(address indexed feeRecipient, uint256 yield, uint256 feeAssets); event Rebalance(address indexed strategy, uint256 amountToRebalance, bool isDeposit); diff --git a/src/lib/HooksLib.sol b/src/core/lib/HooksLib.sol similarity index 100% rename from src/lib/HooksLib.sol rename to src/core/lib/HooksLib.sol diff --git a/src/lib/StorageLib.sol b/src/core/lib/StorageLib.sol similarity index 89% rename from src/lib/StorageLib.sol rename to src/core/lib/StorageLib.sol index 8b4f3907..4577cc0d 100644 --- a/src/lib/StorageLib.sol +++ b/src/core/lib/StorageLib.sol @@ -2,13 +2,13 @@ pragma solidity ^0.8.0; // interfaces -import {IAggregationLayerVault} from "../interface/IAggregationLayerVault.sol"; +import {IEulerAggregationLayer} from "../interface/IEulerAggregationLayer.sol"; /// @custom:storage-location erc7201:euler_aggregation_vault.storage.AggregationVault struct AggregationVaultStorage { /// EVC address address evc; - /// Total amount of _asset deposited into AggregationLayerVault contract + /// Total amount of _asset deposited into EulerAggregationLayer contract uint256 totalAssetsDeposited; /// Total amount of _asset deposited across all strategies. uint256 totalAllocated; @@ -21,9 +21,7 @@ struct AggregationVaultStorage { /// Withdrawal queue contract's address address withdrawalQueue; /// Mapping between strategy address and it's allocation config - mapping(address => IAggregationLayerVault.Strategy) strategies; - - + mapping(address => IEulerAggregationLayer.Strategy) strategies; /// lastInterestUpdate: last timestamo where interest was updated. uint40 lastInterestUpdate; /// interestSmearEnd: timestamp when the smearing of interest end. @@ -32,13 +30,10 @@ struct AggregationVaultStorage { uint168 interestLeft; /// locked: if locked or not for update. uint8 locked; - /// Address of balance tracker contract for reward streams integration. address balanceTracker; /// A mapping to check if a user address enabled balance forwarding for reward streams integration. mapping(address => bool) isBalanceForwarderEnabled; - - /// @dev storing the hooks target and kooked functions. uint256 hooksConfig; } diff --git a/src/module/AllocationPoints.sol b/src/core/module/AllocationPoints.sol similarity index 93% rename from src/module/AllocationPoints.sol rename to src/core/module/AllocationPoints.sol index c88baca4..24d34f62 100644 --- a/src/module/AllocationPoints.sol +++ b/src/core/module/AllocationPoints.sol @@ -4,9 +4,9 @@ pragma solidity ^0.8.0; // interfaces import {IERC4626} from "@openzeppelin-upgradeable/token/ERC20/extensions/ERC4626Upgradeable.sol"; import {IWithdrawalQueue} from "../interface/IWithdrawalQueue.sol"; -import {IAggregationLayerVault} from "../interface/IAggregationLayerVault.sol"; +import {IEulerAggregationLayer} from "../interface/IEulerAggregationLayer.sol"; // contracts -import {Shared} from "../Shared.sol"; +import {Shared} from "../common/Shared.sol"; // libs import {SafeCast} from "@openzeppelin/contracts/utils/math/SafeCast.sol"; import {StorageLib, AggregationVaultStorage} from "../lib/StorageLib.sol"; @@ -26,7 +26,7 @@ abstract contract AllocationPointsModule is Shared { function adjustAllocationPoints(address _strategy, uint256 _newPoints) external virtual nonReentrant { AggregationVaultStorage storage $ = StorageLib._getAggregationVaultStorage(); - IAggregationLayerVault.Strategy memory strategyDataCache = $.strategies[_strategy]; + IEulerAggregationLayer.Strategy memory strategyDataCache = $.strategies[_strategy]; if (!strategyDataCache.active) { revert Errors.InactiveStrategy(); @@ -71,7 +71,7 @@ abstract contract AllocationPointsModule is Shared { _callHooksTarget(ADD_STRATEGY, _msgSender()); - $.strategies[_strategy] = IAggregationLayerVault.Strategy({ + $.strategies[_strategy] = IEulerAggregationLayer.Strategy({ allocated: 0, allocationPoints: _allocationPoints.toUint120(), active: true, @@ -93,7 +93,7 @@ abstract contract AllocationPointsModule is Shared { AggregationVaultStorage storage $ = StorageLib._getAggregationVaultStorage(); - IAggregationLayerVault.Strategy storage strategyStorage = $.strategies[_strategy]; + IEulerAggregationLayer.Strategy storage strategyStorage = $.strategies[_strategy]; if (!strategyStorage.active) { revert Errors.AlreadyRemoved(); diff --git a/src/module/Fee.sol b/src/core/module/Fee.sol similarity index 97% rename from src/module/Fee.sol rename to src/core/module/Fee.sol index 1cec2773..8afa58e3 100644 --- a/src/module/Fee.sol +++ b/src/core/module/Fee.sol @@ -7,7 +7,7 @@ import {IBalanceTracker} from "reward-streams/interfaces/IBalanceTracker.sol"; import {IRewardStreams} from "reward-streams/interfaces/IRewardStreams.sol"; import {IERC20} from "@openzeppelin/contracts/token/ERC20/ERC20.sol"; // contracts -import {Shared} from "../Shared.sol"; +import {Shared} from "../common/Shared.sol"; // libs import {StorageLib, AggregationVaultStorage} from "../lib/StorageLib.sol"; import {ErrorsLib as Errors} from "../lib/ErrorsLib.sol"; diff --git a/src/module/Hooks.sol b/src/core/module/Hooks.sol similarity index 96% rename from src/module/Hooks.sol rename to src/core/module/Hooks.sol index 0c8c06a8..45d0f1a8 100644 --- a/src/module/Hooks.sol +++ b/src/core/module/Hooks.sol @@ -4,7 +4,7 @@ pragma solidity ^0.8.0; // interfaces import {IHookTarget} from "evk/src/interfaces/IHookTarget.sol"; // contracts -import {Shared} from "../Shared.sol"; +import {Shared} from "../common/Shared.sol"; // libs import {StorageLib, AggregationVaultStorage} from "../lib/StorageLib.sol"; import {HooksLib} from "../lib/HooksLib.sol"; diff --git a/src/module/Rewards.sol b/src/core/module/Rewards.sol similarity index 99% rename from src/module/Rewards.sol rename to src/core/module/Rewards.sol index ae80ee88..c5bacc06 100644 --- a/src/module/Rewards.sol +++ b/src/core/module/Rewards.sol @@ -7,7 +7,7 @@ import {IBalanceTracker} from "reward-streams/interfaces/IBalanceTracker.sol"; import {IRewardStreams} from "reward-streams/interfaces/IRewardStreams.sol"; import {IERC20} from "@openzeppelin/contracts/token/ERC20/ERC20.sol"; // contracts -import {Shared} from "../Shared.sol"; +import {Shared} from "../common/Shared.sol"; // libs import {StorageLib, AggregationVaultStorage} from "../lib/StorageLib.sol"; import {ErrorsLib as Errors} from "../lib/ErrorsLib.sol"; diff --git a/src/plugin/Rebalancer.sol b/src/plugin/Rebalancer.sol index 302de564..57fea7d8 100644 --- a/src/plugin/Rebalancer.sol +++ b/src/plugin/Rebalancer.sol @@ -2,13 +2,13 @@ pragma solidity ^0.8.0; // interfaces -import {IAggregationLayerVault} from "../interface/IAggregationLayerVault.sol"; +import {IEulerAggregationLayer} from "../core/interface/IEulerAggregationLayer.sol"; import {IERC4626} from "@openzeppelin/contracts/token/ERC20/extensions/ERC4626.sol"; /// @title Rebalancer plugin /// @custom:security-contact security@euler.xyz /// @author Euler Labs (https://www.eulerlabs.com/) -/// @notice A contract to execute rebalance() on the AggregationLayerVault. +/// @notice A contract to execute rebalance() on the EulerAggregationLayer. /// @dev Usually this contract will hold the `REBALANCER` role. contract Rebalancer { event ExecuteRebalance( @@ -23,7 +23,7 @@ contract Rebalancer { /// @param _curatedVault Curated vault address. /// @param _strategies Strategies addresses. function executeRebalance(address _curatedVault, address[] calldata _strategies) external { - IAggregationLayerVault(_curatedVault).gulp(); + IEulerAggregationLayer(_curatedVault).gulp(); for (uint256 i; i < _strategies.length; ++i) { _rebalance(_curatedVault, _strategies[i]); @@ -41,11 +41,11 @@ contract Rebalancer { return; //nothing to rebalance as that's the cash reserve } - IAggregationLayerVault.Strategy memory strategyData = - IAggregationLayerVault(_curatedVault).getStrategy(_strategy); + IEulerAggregationLayer.Strategy memory strategyData = + IEulerAggregationLayer(_curatedVault).getStrategy(_strategy); - uint256 totalAllocationPointsCache = IAggregationLayerVault(_curatedVault).totalAllocationPoints(); - uint256 totalAssetsAllocatableCache = IAggregationLayerVault(_curatedVault).totalAssetsAllocatable(); + uint256 totalAllocationPointsCache = IEulerAggregationLayer(_curatedVault).totalAllocationPoints(); + uint256 totalAssetsAllocatableCache = IEulerAggregationLayer(_curatedVault).totalAssetsAllocatable(); uint256 targetAllocation = totalAssetsAllocatableCache * strategyData.allocationPoints / totalAllocationPointsCache; @@ -66,9 +66,9 @@ contract Rebalancer { } else if (strategyData.allocated < targetAllocation) { // Deposit uint256 targetCash = totalAssetsAllocatableCache - * IAggregationLayerVault(_curatedVault).getStrategy(address(0)).allocationPoints + * IEulerAggregationLayer(_curatedVault).getStrategy(address(0)).allocationPoints / totalAllocationPointsCache; - uint256 currentCash = totalAssetsAllocatableCache - IAggregationLayerVault(_curatedVault).totalAllocated(); + uint256 currentCash = totalAssetsAllocatableCache - IEulerAggregationLayer(_curatedVault).totalAllocated(); // Calculate available cash to put in strategies uint256 cashAvailable = (currentCash > targetCash) ? currentCash - targetCash : 0; @@ -90,7 +90,7 @@ contract Rebalancer { isDeposit = true; } - IAggregationLayerVault(_curatedVault).rebalance(_strategy, amountToRebalance, isDeposit); + IEulerAggregationLayer(_curatedVault).rebalance(_strategy, amountToRebalance, isDeposit); emit ExecuteRebalance(_curatedVault, _strategy, strategyData.allocated, targetAllocation, amountToRebalance); } diff --git a/src/plugin/WithdrawalQueue.sol b/src/plugin/WithdrawalQueue.sol index 118b63b4..fa122a92 100644 --- a/src/plugin/WithdrawalQueue.sol +++ b/src/plugin/WithdrawalQueue.sol @@ -3,8 +3,8 @@ pragma solidity ^0.8.0; // interfaces import {IERC4626} from "@openzeppelin/contracts/token/ERC20/extensions/ERC4626.sol"; -import {IAggregationLayerVault} from "../interface/IAggregationLayerVault.sol"; -import {IWithdrawalQueue} from "../interface/IWithdrawalQueue.sol"; +import {IEulerAggregationLayer} from "../core/interface/IEulerAggregationLayer.sol"; +import {IWithdrawalQueue} from "../core/interface/IWithdrawalQueue.sol"; // contracts import {AccessControlEnumerableUpgradeable} from "@openzeppelin-upgradeable/access/extensions/AccessControlEnumerableUpgradeable.sol"; @@ -14,7 +14,7 @@ import {AccessControlEnumerableUpgradeable} from /// @author Euler Labs (https://www.eulerlabs.com/) /// @notice This contract manage the withdrawalQueue aray(add/remove strategy to the queue, re-order queue). /// Also it handles finishing the withdraw execution flow through the `callWithdrawalQueue()` function -/// that will be called by the AggregationLayerVault. +/// that will be called by the EulerAggregationLayer. contract WithdrawalQueue is AccessControlEnumerableUpgradeable, IWithdrawalQueue { error OutOfBounds(); error SameIndexes(); @@ -132,7 +132,7 @@ contract WithdrawalQueue is AccessControlEnumerableUpgradeable, IWithdrawalQueue uint256 desiredAssets = _assets - _availableAssets; uint256 withdrawAmount = (underlyingBalance > desiredAssets) ? desiredAssets : underlyingBalance; - IAggregationLayerVault(eulerAggregationVaultCached).executeStrategyWithdraw( + IEulerAggregationLayer(eulerAggregationVaultCached).executeStrategyWithdraw( address(strategy), withdrawAmount ); @@ -149,7 +149,7 @@ contract WithdrawalQueue is AccessControlEnumerableUpgradeable, IWithdrawalQueue revert NotEnoughAssets(); } - IAggregationLayerVault(eulerAggregationVaultCached).executeAggregationVaultWithdraw( + IEulerAggregationLayer(eulerAggregationVaultCached).executeAggregationVaultWithdraw( _caller, _receiver, _owner, _assets, _shares ); } diff --git a/test/common/AggregationLayerVaultBase.t.sol b/test/common/EulerAggregationLayerBase.t.sol similarity index 53% rename from test/common/AggregationLayerVaultBase.t.sol rename to test/common/EulerAggregationLayerBase.t.sol index 4c343a47..ca699396 100644 --- a/test/common/AggregationLayerVaultBase.t.sol +++ b/test/common/EulerAggregationLayerBase.t.sol @@ -3,21 +3,21 @@ pragma solidity ^0.8.0; // interfaces import {IHookTarget} from "evk/src/interfaces/IHookTarget.sol"; -import {IWithdrawalQueue} from "../../src/interface/IWithdrawalQueue.sol"; +import {IWithdrawalQueue} from "../../src/core/interface/IWithdrawalQueue.sol"; // contracts import "evk/test/unit/evault/EVaultTestBase.t.sol"; -import {AggregationLayerVault, IAggregationLayerVault} from "../../src/AggregationLayerVault.sol"; +import {EulerAggregationLayer, IEulerAggregationLayer} from "../../src/core/EulerAggregationLayer.sol"; import {Rebalancer} from "../../src/plugin/Rebalancer.sol"; -import {Hooks, HooksModule} from "../../src/module/Hooks.sol"; -import {Rewards} from "../../src/module/Rewards.sol"; -import {Fee} from "../../src/module/Fee.sol"; -import {AggregationLayerVaultFactory} from "../../src/AggregationLayerVaultFactory.sol"; +import {Hooks, HooksModule} from "../../src/core/module/Hooks.sol"; +import {Rewards} from "../../src/core/module/Rewards.sol"; +import {Fee} from "../../src/core/module/Fee.sol"; +import {EulerAggregationLayerFactory} from "../../src/core/EulerAggregationLayerFactory.sol"; import {WithdrawalQueue} from "../../src/plugin/WithdrawalQueue.sol"; -import {AllocationPoints} from "../../src/module/AllocationPoints.sol"; +import {AllocationPoints} from "../../src/core/module/AllocationPoints.sol"; // libs -import {ErrorsLib} from "../../src/lib/ErrorsLib.sol"; +import {ErrorsLib} from "../../src/core/lib/ErrorsLib.sol"; -contract AggregationLayerVaultBase is EVaultTestBase { +contract EulerAggregationLayerBase is EVaultTestBase { uint256 public constant CASH_RESERVE_ALLOCATION_POINTS = 1000e18; address deployer; @@ -34,8 +34,8 @@ contract AggregationLayerVaultBase is EVaultTestBase { Rebalancer rebalancer; WithdrawalQueue withdrawalQueueImpl; - AggregationLayerVaultFactory aggregationLayerVaultFactory; - AggregationLayerVault aggregationLayerVault; + EulerAggregationLayerFactory eulerAggregationLayerFactory; + EulerAggregationLayer eulerAggregationLayer; WithdrawalQueue withdrawalQueue; function setUp() public virtual override { @@ -54,7 +54,7 @@ contract AggregationLayerVaultBase is EVaultTestBase { rebalancer = new Rebalancer(); withdrawalQueueImpl = new WithdrawalQueue(); - AggregationLayerVaultFactory.FactoryParams memory factoryParams = AggregationLayerVaultFactory.FactoryParams({ + EulerAggregationLayerFactory.FactoryParams memory factoryParams = EulerAggregationLayerFactory.FactoryParams({ evc: address(evc), balanceTracker: address(0), rewardsModuleImpl: address(rewardsImpl), @@ -64,77 +64,77 @@ contract AggregationLayerVaultBase is EVaultTestBase { rebalancer: address(rebalancer), withdrawalQueueImpl: address(withdrawalQueueImpl) }); - aggregationLayerVaultFactory = new AggregationLayerVaultFactory(factoryParams); + eulerAggregationLayerFactory = new EulerAggregationLayerFactory(factoryParams); - aggregationLayerVault = AggregationLayerVault( - aggregationLayerVaultFactory.deployEulerAggregationLayer( + eulerAggregationLayer = EulerAggregationLayer( + eulerAggregationLayerFactory.deployEulerAggregationLayer( address(assetTST), "assetTST_Agg", "assetTST_Agg", CASH_RESERVE_ALLOCATION_POINTS ) ); - withdrawalQueue = WithdrawalQueue(aggregationLayerVault.withdrawalQueue()); + withdrawalQueue = WithdrawalQueue(eulerAggregationLayer.withdrawalQueue()); // grant admin roles to deployer - aggregationLayerVault.grantRole(aggregationLayerVault.ALLOCATIONS_MANAGER_ADMIN(), deployer); - aggregationLayerVault.grantRole(aggregationLayerVault.STRATEGY_ADDER_ADMIN(), deployer); - aggregationLayerVault.grantRole(aggregationLayerVault.STRATEGY_REMOVER_ADMIN(), deployer); - aggregationLayerVault.grantRole(aggregationLayerVault.AGGREGATION_VAULT_MANAGER_ADMIN(), deployer); - aggregationLayerVault.grantRole(aggregationLayerVault.REBALANCER_ADMIN(), deployer); + eulerAggregationLayer.grantRole(eulerAggregationLayer.ALLOCATIONS_MANAGER_ADMIN(), deployer); + eulerAggregationLayer.grantRole(eulerAggregationLayer.STRATEGY_ADDER_ADMIN(), deployer); + eulerAggregationLayer.grantRole(eulerAggregationLayer.STRATEGY_REMOVER_ADMIN(), deployer); + eulerAggregationLayer.grantRole(eulerAggregationLayer.AGGREGATION_VAULT_MANAGER_ADMIN(), deployer); + eulerAggregationLayer.grantRole(eulerAggregationLayer.REBALANCER_ADMIN(), deployer); withdrawalQueue.grantRole(withdrawalQueue.WITHDRAW_QUEUE_MANAGER_ADMIN(), deployer); // grant roles to manager - aggregationLayerVault.grantRole(aggregationLayerVault.ALLOCATIONS_MANAGER(), manager); - aggregationLayerVault.grantRole(aggregationLayerVault.STRATEGY_ADDER(), manager); - aggregationLayerVault.grantRole(aggregationLayerVault.STRATEGY_REMOVER(), manager); - aggregationLayerVault.grantRole(aggregationLayerVault.AGGREGATION_VAULT_MANAGER(), manager); + eulerAggregationLayer.grantRole(eulerAggregationLayer.ALLOCATIONS_MANAGER(), manager); + eulerAggregationLayer.grantRole(eulerAggregationLayer.STRATEGY_ADDER(), manager); + eulerAggregationLayer.grantRole(eulerAggregationLayer.STRATEGY_REMOVER(), manager); + eulerAggregationLayer.grantRole(eulerAggregationLayer.AGGREGATION_VAULT_MANAGER(), manager); withdrawalQueue.grantRole(withdrawalQueue.WITHDRAW_QUEUE_MANAGER(), manager); vm.stopPrank(); } function testInitialParams() public { - AggregationLayerVault.Strategy memory cashReserve = aggregationLayerVault.getStrategy(address(0)); + EulerAggregationLayer.Strategy memory cashReserve = eulerAggregationLayer.getStrategy(address(0)); assertEq(cashReserve.allocated, 0); assertEq(cashReserve.allocationPoints, CASH_RESERVE_ALLOCATION_POINTS); assertEq(cashReserve.active, true); assertEq( - aggregationLayerVault.getRoleAdmin(aggregationLayerVault.ALLOCATIONS_MANAGER()), - aggregationLayerVault.ALLOCATIONS_MANAGER_ADMIN() + eulerAggregationLayer.getRoleAdmin(eulerAggregationLayer.ALLOCATIONS_MANAGER()), + eulerAggregationLayer.ALLOCATIONS_MANAGER_ADMIN() ); assertEq( - aggregationLayerVault.getRoleAdmin(aggregationLayerVault.STRATEGY_ADDER()), - aggregationLayerVault.STRATEGY_ADDER_ADMIN() + eulerAggregationLayer.getRoleAdmin(eulerAggregationLayer.STRATEGY_ADDER()), + eulerAggregationLayer.STRATEGY_ADDER_ADMIN() ); assertEq( - aggregationLayerVault.getRoleAdmin(aggregationLayerVault.STRATEGY_REMOVER()), - aggregationLayerVault.STRATEGY_REMOVER_ADMIN() + eulerAggregationLayer.getRoleAdmin(eulerAggregationLayer.STRATEGY_REMOVER()), + eulerAggregationLayer.STRATEGY_REMOVER_ADMIN() ); assertEq( - aggregationLayerVault.getRoleAdmin(aggregationLayerVault.AGGREGATION_VAULT_MANAGER()), - aggregationLayerVault.AGGREGATION_VAULT_MANAGER_ADMIN() + eulerAggregationLayer.getRoleAdmin(eulerAggregationLayer.AGGREGATION_VAULT_MANAGER()), + eulerAggregationLayer.AGGREGATION_VAULT_MANAGER_ADMIN() ); assertEq( withdrawalQueue.getRoleAdmin(withdrawalQueue.WITHDRAW_QUEUE_MANAGER()), withdrawalQueue.WITHDRAW_QUEUE_MANAGER_ADMIN() ); - assertTrue(aggregationLayerVault.hasRole(aggregationLayerVault.ALLOCATIONS_MANAGER_ADMIN(), deployer)); - assertTrue(aggregationLayerVault.hasRole(aggregationLayerVault.STRATEGY_ADDER_ADMIN(), deployer)); - assertTrue(aggregationLayerVault.hasRole(aggregationLayerVault.STRATEGY_REMOVER_ADMIN(), deployer)); - assertTrue(aggregationLayerVault.hasRole(aggregationLayerVault.AGGREGATION_VAULT_MANAGER_ADMIN(), deployer)); + assertTrue(eulerAggregationLayer.hasRole(eulerAggregationLayer.ALLOCATIONS_MANAGER_ADMIN(), deployer)); + assertTrue(eulerAggregationLayer.hasRole(eulerAggregationLayer.STRATEGY_ADDER_ADMIN(), deployer)); + assertTrue(eulerAggregationLayer.hasRole(eulerAggregationLayer.STRATEGY_REMOVER_ADMIN(), deployer)); + assertTrue(eulerAggregationLayer.hasRole(eulerAggregationLayer.AGGREGATION_VAULT_MANAGER_ADMIN(), deployer)); assertTrue(withdrawalQueue.hasRole(withdrawalQueue.WITHDRAW_QUEUE_MANAGER_ADMIN(), deployer)); - assertTrue(aggregationLayerVault.hasRole(aggregationLayerVault.ALLOCATIONS_MANAGER(), manager)); - assertTrue(aggregationLayerVault.hasRole(aggregationLayerVault.STRATEGY_ADDER(), manager)); - assertTrue(aggregationLayerVault.hasRole(aggregationLayerVault.STRATEGY_REMOVER(), manager)); - assertTrue(aggregationLayerVault.hasRole(aggregationLayerVault.AGGREGATION_VAULT_MANAGER(), manager)); + assertTrue(eulerAggregationLayer.hasRole(eulerAggregationLayer.ALLOCATIONS_MANAGER(), manager)); + assertTrue(eulerAggregationLayer.hasRole(eulerAggregationLayer.STRATEGY_ADDER(), manager)); + assertTrue(eulerAggregationLayer.hasRole(eulerAggregationLayer.STRATEGY_REMOVER(), manager)); + assertTrue(eulerAggregationLayer.hasRole(eulerAggregationLayer.AGGREGATION_VAULT_MANAGER(), manager)); assertTrue(withdrawalQueue.hasRole(withdrawalQueue.WITHDRAW_QUEUE_MANAGER(), manager)); } function _addStrategy(address from, address strategy, uint256 allocationPoints) internal { vm.prank(from); - aggregationLayerVault.addStrategy(strategy, allocationPoints); + eulerAggregationLayer.addStrategy(strategy, allocationPoints); } function _getWithdrawalQueueLength() internal view returns (uint256) { diff --git a/test/e2e/BalanceForwarderE2ETest.t.sol b/test/e2e/BalanceForwarderE2ETest.t.sol index 7ae48d56..25d07165 100644 --- a/test/e2e/BalanceForwarderE2ETest.t.sol +++ b/test/e2e/BalanceForwarderE2ETest.t.sol @@ -3,18 +3,18 @@ pragma solidity ^0.8.0; import {TrackingRewardStreams} from "reward-streams/TrackingRewardStreams.sol"; import { - AggregationLayerVaultBase, - AggregationLayerVault, + EulerAggregationLayerBase, + EulerAggregationLayer, console2, EVault, IEVault, IRMTestDefault, TestERC20, - AggregationLayerVaultFactory, + EulerAggregationLayerFactory, Rewards -} from "../common/AggregationLayerVaultBase.t.sol"; +} from "../common/EulerAggregationLayerBase.t.sol"; -contract BalanceForwarderE2ETest is AggregationLayerVaultBase { +contract BalanceForwarderE2ETest is EulerAggregationLayerBase { uint256 user1InitialBalance = 100000e18; address trackingReward; @@ -25,7 +25,7 @@ contract BalanceForwarderE2ETest is AggregationLayerVaultBase { vm.startPrank(deployer); trackingReward = address(new TrackingRewardStreams(address(evc), 2 weeks)); - AggregationLayerVaultFactory.FactoryParams memory factoryParams = AggregationLayerVaultFactory.FactoryParams({ + EulerAggregationLayerFactory.FactoryParams memory factoryParams = EulerAggregationLayerFactory.FactoryParams({ evc: address(evc), balanceTracker: trackingReward, rewardsModuleImpl: address(rewardsImpl), @@ -35,26 +35,26 @@ contract BalanceForwarderE2ETest is AggregationLayerVaultBase { rebalancer: address(rebalancer), withdrawalQueueImpl: address(withdrawalQueueImpl) }); - aggregationLayerVaultFactory = new AggregationLayerVaultFactory(factoryParams); - aggregationLayerVault = AggregationLayerVault( - aggregationLayerVaultFactory.deployEulerAggregationLayer( + eulerAggregationLayerFactory = new EulerAggregationLayerFactory(factoryParams); + eulerAggregationLayer = EulerAggregationLayer( + eulerAggregationLayerFactory.deployEulerAggregationLayer( address(assetTST), "assetTST_Agg", "assetTST_Agg", CASH_RESERVE_ALLOCATION_POINTS ) ); // grant admin roles to deployer - aggregationLayerVault.grantRole(aggregationLayerVault.ALLOCATIONS_MANAGER_ADMIN(), deployer); - // aggregationLayerVault.grantRole(aggregationLayerVault.WITHDRAW_QUEUE_MANAGER_ADMIN(), deployer); - aggregationLayerVault.grantRole(aggregationLayerVault.STRATEGY_ADDER_ADMIN(), deployer); - aggregationLayerVault.grantRole(aggregationLayerVault.STRATEGY_REMOVER_ADMIN(), deployer); - aggregationLayerVault.grantRole(aggregationLayerVault.AGGREGATION_VAULT_MANAGER_ADMIN(), deployer); + eulerAggregationLayer.grantRole(eulerAggregationLayer.ALLOCATIONS_MANAGER_ADMIN(), deployer); + // eulerAggregationLayer.grantRole(eulerAggregationLayer.WITHDRAW_QUEUE_MANAGER_ADMIN(), deployer); + eulerAggregationLayer.grantRole(eulerAggregationLayer.STRATEGY_ADDER_ADMIN(), deployer); + eulerAggregationLayer.grantRole(eulerAggregationLayer.STRATEGY_REMOVER_ADMIN(), deployer); + eulerAggregationLayer.grantRole(eulerAggregationLayer.AGGREGATION_VAULT_MANAGER_ADMIN(), deployer); // grant roles to manager - aggregationLayerVault.grantRole(aggregationLayerVault.ALLOCATIONS_MANAGER(), manager); - // aggregationLayerVault.grantRole(aggregationLayerVault.WITHDRAW_QUEUE_MANAGER(), manager); - aggregationLayerVault.grantRole(aggregationLayerVault.STRATEGY_ADDER(), manager); - aggregationLayerVault.grantRole(aggregationLayerVault.STRATEGY_REMOVER(), manager); - aggregationLayerVault.grantRole(aggregationLayerVault.AGGREGATION_VAULT_MANAGER(), manager); + eulerAggregationLayer.grantRole(eulerAggregationLayer.ALLOCATIONS_MANAGER(), manager); + // eulerAggregationLayer.grantRole(eulerAggregationLayer.WITHDRAW_QUEUE_MANAGER(), manager); + eulerAggregationLayer.grantRole(eulerAggregationLayer.STRATEGY_ADDER(), manager); + eulerAggregationLayer.grantRole(eulerAggregationLayer.STRATEGY_REMOVER(), manager); + eulerAggregationLayer.grantRole(eulerAggregationLayer.AGGREGATION_VAULT_MANAGER(), manager); vm.stopPrank(); uint256 initialStrategyAllocationPoints = 500e18; @@ -64,125 +64,125 @@ contract BalanceForwarderE2ETest is AggregationLayerVaultBase { // deposit into aggregator uint256 amountToDeposit = 10000e18; { - uint256 balanceBefore = aggregationLayerVault.balanceOf(user1); - uint256 totalSupplyBefore = aggregationLayerVault.totalSupply(); - uint256 totalAssetsDepositedBefore = aggregationLayerVault.totalAssetsDeposited(); + uint256 balanceBefore = eulerAggregationLayer.balanceOf(user1); + uint256 totalSupplyBefore = eulerAggregationLayer.totalSupply(); + uint256 totalAssetsDepositedBefore = eulerAggregationLayer.totalAssetsDeposited(); uint256 userAssetBalanceBefore = assetTST.balanceOf(user1); vm.startPrank(user1); - assetTST.approve(address(aggregationLayerVault), amountToDeposit); - aggregationLayerVault.deposit(amountToDeposit, user1); + assetTST.approve(address(eulerAggregationLayer), amountToDeposit); + eulerAggregationLayer.deposit(amountToDeposit, user1); vm.stopPrank(); - assertEq(aggregationLayerVault.balanceOf(user1), balanceBefore + amountToDeposit); - assertEq(aggregationLayerVault.totalSupply(), totalSupplyBefore + amountToDeposit); - assertEq(aggregationLayerVault.totalAssetsDeposited(), totalAssetsDepositedBefore + amountToDeposit); + assertEq(eulerAggregationLayer.balanceOf(user1), balanceBefore + amountToDeposit); + assertEq(eulerAggregationLayer.totalSupply(), totalSupplyBefore + amountToDeposit); + assertEq(eulerAggregationLayer.totalAssetsDeposited(), totalAssetsDepositedBefore + amountToDeposit); assertEq(assetTST.balanceOf(user1), userAssetBalanceBefore - amountToDeposit); } } function testBalanceForwarderrAddress_Integrity() public view { - assertEq(aggregationLayerVault.balanceTrackerAddress(), trackingReward); + assertEq(eulerAggregationLayer.balanceTrackerAddress(), trackingReward); } function testEnableBalanceForwarder() public { vm.prank(user1); - aggregationLayerVault.enableBalanceForwarder(); + eulerAggregationLayer.enableBalanceForwarder(); - assertTrue(aggregationLayerVault.balanceForwarderEnabled(user1)); + assertTrue(eulerAggregationLayer.balanceForwarderEnabled(user1)); assertEq( - TrackingRewardStreams(trackingReward).balanceOf(user1, address(aggregationLayerVault)), - aggregationLayerVault.balanceOf(user1) + TrackingRewardStreams(trackingReward).balanceOf(user1, address(eulerAggregationLayer)), + eulerAggregationLayer.balanceOf(user1) ); } function testDisableBalanceForwarder() public { vm.prank(user1); - aggregationLayerVault.enableBalanceForwarder(); + eulerAggregationLayer.enableBalanceForwarder(); - assertTrue(aggregationLayerVault.balanceForwarderEnabled(user1)); + assertTrue(eulerAggregationLayer.balanceForwarderEnabled(user1)); vm.prank(user1); - aggregationLayerVault.disableBalanceForwarder(); + eulerAggregationLayer.disableBalanceForwarder(); - assertFalse(aggregationLayerVault.balanceForwarderEnabled(user1)); - assertEq(TrackingRewardStreams(trackingReward).balanceOf(user1, address(aggregationLayerVault)), 0); + assertFalse(eulerAggregationLayer.balanceForwarderEnabled(user1)); + assertEq(TrackingRewardStreams(trackingReward).balanceOf(user1, address(eulerAggregationLayer)), 0); } function testHookWhenReceiverEnabled() public { vm.prank(user1); - aggregationLayerVault.enableBalanceForwarder(); + eulerAggregationLayer.enableBalanceForwarder(); // deposit into aggregator uint256 amountToDeposit = 10000e18; { - uint256 balanceBefore = aggregationLayerVault.balanceOf(user1); - uint256 totalSupplyBefore = aggregationLayerVault.totalSupply(); - uint256 totalAssetsDepositedBefore = aggregationLayerVault.totalAssetsDeposited(); + uint256 balanceBefore = eulerAggregationLayer.balanceOf(user1); + uint256 totalSupplyBefore = eulerAggregationLayer.totalSupply(); + uint256 totalAssetsDepositedBefore = eulerAggregationLayer.totalAssetsDeposited(); uint256 userAssetBalanceBefore = assetTST.balanceOf(user1); vm.startPrank(user1); - assetTST.approve(address(aggregationLayerVault), amountToDeposit); - aggregationLayerVault.deposit(amountToDeposit, user1); + assetTST.approve(address(eulerAggregationLayer), amountToDeposit); + eulerAggregationLayer.deposit(amountToDeposit, user1); vm.stopPrank(); - assertEq(aggregationLayerVault.balanceOf(user1), balanceBefore + amountToDeposit); - assertEq(aggregationLayerVault.totalSupply(), totalSupplyBefore + amountToDeposit); - assertEq(aggregationLayerVault.totalAssetsDeposited(), totalAssetsDepositedBefore + amountToDeposit); + assertEq(eulerAggregationLayer.balanceOf(user1), balanceBefore + amountToDeposit); + assertEq(eulerAggregationLayer.totalSupply(), totalSupplyBefore + amountToDeposit); + assertEq(eulerAggregationLayer.totalAssetsDeposited(), totalAssetsDepositedBefore + amountToDeposit); assertEq(assetTST.balanceOf(user1), userAssetBalanceBefore - amountToDeposit); assertEq( - TrackingRewardStreams(trackingReward).balanceOf(user1, address(aggregationLayerVault)), - aggregationLayerVault.balanceOf(user1) + TrackingRewardStreams(trackingReward).balanceOf(user1, address(eulerAggregationLayer)), + eulerAggregationLayer.balanceOf(user1) ); } } function testHookWhenSenderEnabled() public { vm.prank(user1); - aggregationLayerVault.enableBalanceForwarder(); + eulerAggregationLayer.enableBalanceForwarder(); // deposit into aggregator uint256 amountToDeposit = 10000e18; { - uint256 balanceBefore = aggregationLayerVault.balanceOf(user1); - uint256 totalSupplyBefore = aggregationLayerVault.totalSupply(); - uint256 totalAssetsDepositedBefore = aggregationLayerVault.totalAssetsDeposited(); + uint256 balanceBefore = eulerAggregationLayer.balanceOf(user1); + uint256 totalSupplyBefore = eulerAggregationLayer.totalSupply(); + uint256 totalAssetsDepositedBefore = eulerAggregationLayer.totalAssetsDeposited(); uint256 userAssetBalanceBefore = assetTST.balanceOf(user1); vm.startPrank(user1); - assetTST.approve(address(aggregationLayerVault), amountToDeposit); - aggregationLayerVault.deposit(amountToDeposit, user1); + assetTST.approve(address(eulerAggregationLayer), amountToDeposit); + eulerAggregationLayer.deposit(amountToDeposit, user1); vm.stopPrank(); - assertEq(aggregationLayerVault.balanceOf(user1), balanceBefore + amountToDeposit); - assertEq(aggregationLayerVault.totalSupply(), totalSupplyBefore + amountToDeposit); - assertEq(aggregationLayerVault.totalAssetsDeposited(), totalAssetsDepositedBefore + amountToDeposit); + assertEq(eulerAggregationLayer.balanceOf(user1), balanceBefore + amountToDeposit); + assertEq(eulerAggregationLayer.totalSupply(), totalSupplyBefore + amountToDeposit); + assertEq(eulerAggregationLayer.totalAssetsDeposited(), totalAssetsDepositedBefore + amountToDeposit); assertEq(assetTST.balanceOf(user1), userAssetBalanceBefore - amountToDeposit); assertEq( - TrackingRewardStreams(trackingReward).balanceOf(user1, address(aggregationLayerVault)), - aggregationLayerVault.balanceOf(user1) + TrackingRewardStreams(trackingReward).balanceOf(user1, address(eulerAggregationLayer)), + eulerAggregationLayer.balanceOf(user1) ); } { - uint256 amountToWithdraw = aggregationLayerVault.balanceOf(user1); - uint256 totalAssetsDepositedBefore = aggregationLayerVault.totalAssetsDeposited(); - uint256 aggregatorTotalSupplyBefore = aggregationLayerVault.totalSupply(); + uint256 amountToWithdraw = eulerAggregationLayer.balanceOf(user1); + uint256 totalAssetsDepositedBefore = eulerAggregationLayer.totalAssetsDeposited(); + uint256 aggregatorTotalSupplyBefore = eulerAggregationLayer.totalSupply(); uint256 user1AssetTSTBalanceBefore = assetTST.balanceOf(user1); vm.prank(user1); - aggregationLayerVault.redeem(amountToWithdraw, user1, user1); + eulerAggregationLayer.redeem(amountToWithdraw, user1, user1); - assertEq(eTST.balanceOf(address(aggregationLayerVault)), 0); - assertEq(aggregationLayerVault.totalAssetsDeposited(), totalAssetsDepositedBefore - amountToWithdraw); - assertEq(aggregationLayerVault.totalSupply(), aggregatorTotalSupplyBefore - amountToWithdraw); + assertEq(eTST.balanceOf(address(eulerAggregationLayer)), 0); + assertEq(eulerAggregationLayer.totalAssetsDeposited(), totalAssetsDepositedBefore - amountToWithdraw); + assertEq(eulerAggregationLayer.totalSupply(), aggregatorTotalSupplyBefore - amountToWithdraw); assertEq( assetTST.balanceOf(user1), - user1AssetTSTBalanceBefore + aggregationLayerVault.convertToAssets(amountToWithdraw) + user1AssetTSTBalanceBefore + eulerAggregationLayer.convertToAssets(amountToWithdraw) ); - assertEq(TrackingRewardStreams(trackingReward).balanceOf(user1, address(aggregationLayerVault)), 0); + assertEq(TrackingRewardStreams(trackingReward).balanceOf(user1, address(eulerAggregationLayer)), 0); } } } diff --git a/test/e2e/DepositRebalanceHarvestWithdrawE2ETest.t.sol b/test/e2e/DepositRebalanceHarvestWithdrawE2ETest.t.sol index 5c4ae3d8..0c6f7f8b 100644 --- a/test/e2e/DepositRebalanceHarvestWithdrawE2ETest.t.sol +++ b/test/e2e/DepositRebalanceHarvestWithdrawE2ETest.t.sol @@ -2,18 +2,18 @@ pragma solidity ^0.8.0; import { - AggregationLayerVaultBase, - AggregationLayerVault, + EulerAggregationLayerBase, + EulerAggregationLayer, console2, EVault, IEVault, IRMTestDefault, TestERC20, WithdrawalQueue, - IAggregationLayerVault -} from "../common/AggregationLayerVaultBase.t.sol"; + IEulerAggregationLayer +} from "../common/EulerAggregationLayerBase.t.sol"; -contract DepositRebalanceHarvestWithdrawE2ETest is AggregationLayerVaultBase { +contract DepositRebalanceHarvestWithdrawE2ETest is EulerAggregationLayerBase { uint256 user1InitialBalance = 100000e18; function setUp() public virtual override { @@ -30,41 +30,41 @@ contract DepositRebalanceHarvestWithdrawE2ETest is AggregationLayerVaultBase { // deposit into aggregator { - uint256 balanceBefore = aggregationLayerVault.balanceOf(user1); - uint256 totalSupplyBefore = aggregationLayerVault.totalSupply(); - uint256 totalAssetsDepositedBefore = aggregationLayerVault.totalAssetsDeposited(); + uint256 balanceBefore = eulerAggregationLayer.balanceOf(user1); + uint256 totalSupplyBefore = eulerAggregationLayer.totalSupply(); + uint256 totalAssetsDepositedBefore = eulerAggregationLayer.totalAssetsDeposited(); uint256 userAssetBalanceBefore = assetTST.balanceOf(user1); vm.startPrank(user1); - assetTST.approve(address(aggregationLayerVault), amountToDeposit); - aggregationLayerVault.deposit(amountToDeposit, user1); + assetTST.approve(address(eulerAggregationLayer), amountToDeposit); + eulerAggregationLayer.deposit(amountToDeposit, user1); vm.stopPrank(); - assertEq(aggregationLayerVault.balanceOf(user1), balanceBefore + amountToDeposit); - assertEq(aggregationLayerVault.totalSupply(), totalSupplyBefore + amountToDeposit); - assertEq(aggregationLayerVault.totalAssetsDeposited(), totalAssetsDepositedBefore + amountToDeposit); + assertEq(eulerAggregationLayer.balanceOf(user1), balanceBefore + amountToDeposit); + assertEq(eulerAggregationLayer.totalSupply(), totalSupplyBefore + amountToDeposit); + assertEq(eulerAggregationLayer.totalAssetsDeposited(), totalAssetsDepositedBefore + amountToDeposit); assertEq(assetTST.balanceOf(user1), userAssetBalanceBefore - amountToDeposit); } // rebalance into strategy vm.warp(block.timestamp + 86400); { - IAggregationLayerVault.Strategy memory strategyBefore = aggregationLayerVault.getStrategy(address(eTST)); + IEulerAggregationLayer.Strategy memory strategyBefore = eulerAggregationLayer.getStrategy(address(eTST)); - assertEq(eTST.convertToAssets(eTST.balanceOf(address(aggregationLayerVault))), strategyBefore.allocated); + assertEq(eTST.convertToAssets(eTST.balanceOf(address(eulerAggregationLayer))), strategyBefore.allocated); - uint256 expectedStrategyCash = aggregationLayerVault.totalAssetsAllocatable() - * strategyBefore.allocationPoints / aggregationLayerVault.totalAllocationPoints(); + uint256 expectedStrategyCash = eulerAggregationLayer.totalAssetsAllocatable() + * strategyBefore.allocationPoints / eulerAggregationLayer.totalAllocationPoints(); vm.prank(user1); address[] memory strategiesToRebalance = new address[](1); strategiesToRebalance[0] = address(eTST); - rebalancer.executeRebalance(address(aggregationLayerVault), strategiesToRebalance); + rebalancer.executeRebalance(address(eulerAggregationLayer), strategiesToRebalance); - assertEq(aggregationLayerVault.totalAllocated(), expectedStrategyCash); - assertEq(eTST.convertToAssets(eTST.balanceOf(address(aggregationLayerVault))), expectedStrategyCash); + assertEq(eulerAggregationLayer.totalAllocated(), expectedStrategyCash); + assertEq(eTST.convertToAssets(eTST.balanceOf(address(eulerAggregationLayer))), expectedStrategyCash); assertEq( - (aggregationLayerVault.getStrategy(address(eTST))).allocated, + (eulerAggregationLayer.getStrategy(address(eTST))).allocated, strategyBefore.allocated + expectedStrategyCash ); } @@ -73,37 +73,37 @@ contract DepositRebalanceHarvestWithdrawE2ETest is AggregationLayerVaultBase { // partial withdraw, no need to withdraw from strategy as cash reserve is enough uint256 amountToWithdraw = 6000e18; { - IAggregationLayerVault.Strategy memory strategyBefore = aggregationLayerVault.getStrategy(address(eTST)); - uint256 strategyShareBalanceBefore = eTST.balanceOf(address(aggregationLayerVault)); - uint256 totalAssetsDepositedBefore = aggregationLayerVault.totalAssetsDeposited(); - uint256 aggregatorTotalSupplyBefore = aggregationLayerVault.totalSupply(); + IEulerAggregationLayer.Strategy memory strategyBefore = eulerAggregationLayer.getStrategy(address(eTST)); + uint256 strategyShareBalanceBefore = eTST.balanceOf(address(eulerAggregationLayer)); + uint256 totalAssetsDepositedBefore = eulerAggregationLayer.totalAssetsDeposited(); + uint256 aggregatorTotalSupplyBefore = eulerAggregationLayer.totalSupply(); uint256 user1AssetTSTBalanceBefore = assetTST.balanceOf(user1); vm.prank(user1); - aggregationLayerVault.withdraw(amountToWithdraw, user1, user1); + eulerAggregationLayer.withdraw(amountToWithdraw, user1, user1); - assertEq(eTST.balanceOf(address(aggregationLayerVault)), strategyShareBalanceBefore); - assertEq(aggregationLayerVault.totalAssetsDeposited(), totalAssetsDepositedBefore - amountToWithdraw); - assertEq(aggregationLayerVault.totalSupply(), aggregatorTotalSupplyBefore - amountToWithdraw); + assertEq(eTST.balanceOf(address(eulerAggregationLayer)), strategyShareBalanceBefore); + assertEq(eulerAggregationLayer.totalAssetsDeposited(), totalAssetsDepositedBefore - amountToWithdraw); + assertEq(eulerAggregationLayer.totalSupply(), aggregatorTotalSupplyBefore - amountToWithdraw); assertEq(assetTST.balanceOf(user1), user1AssetTSTBalanceBefore + amountToWithdraw); - assertEq((aggregationLayerVault.getStrategy(address(eTST))).allocated, strategyBefore.allocated); + assertEq((eulerAggregationLayer.getStrategy(address(eTST))).allocated, strategyBefore.allocated); } // full withdraw, will have to withdraw from strategy as cash reserve is not enough { amountToWithdraw = amountToDeposit - amountToWithdraw; - uint256 totalAssetsDepositedBefore = aggregationLayerVault.totalAssetsDeposited(); - uint256 aggregatorTotalSupplyBefore = aggregationLayerVault.totalSupply(); + uint256 totalAssetsDepositedBefore = eulerAggregationLayer.totalAssetsDeposited(); + uint256 aggregatorTotalSupplyBefore = eulerAggregationLayer.totalSupply(); uint256 user1AssetTSTBalanceBefore = assetTST.balanceOf(user1); vm.prank(user1); - aggregationLayerVault.withdraw(amountToWithdraw, user1, user1); + eulerAggregationLayer.withdraw(amountToWithdraw, user1, user1); - assertEq(eTST.balanceOf(address(aggregationLayerVault)), 0); - assertEq(aggregationLayerVault.totalAssetsDeposited(), totalAssetsDepositedBefore - amountToWithdraw); - assertEq(aggregationLayerVault.totalSupply(), aggregatorTotalSupplyBefore - amountToWithdraw); + assertEq(eTST.balanceOf(address(eulerAggregationLayer)), 0); + assertEq(eulerAggregationLayer.totalAssetsDeposited(), totalAssetsDepositedBefore - amountToWithdraw); + assertEq(eulerAggregationLayer.totalSupply(), aggregatorTotalSupplyBefore - amountToWithdraw); assertEq(assetTST.balanceOf(user1), user1AssetTSTBalanceBefore + amountToWithdraw); - assertEq((aggregationLayerVault.getStrategy(address(eTST))).allocated, 0); + assertEq((eulerAggregationLayer.getStrategy(address(eTST))).allocated, 0); } } @@ -112,67 +112,67 @@ contract DepositRebalanceHarvestWithdrawE2ETest is AggregationLayerVaultBase { // deposit into aggregator { - uint256 balanceBefore = aggregationLayerVault.balanceOf(user1); - uint256 totalSupplyBefore = aggregationLayerVault.totalSupply(); - uint256 totalAssetsDepositedBefore = aggregationLayerVault.totalAssetsDeposited(); + uint256 balanceBefore = eulerAggregationLayer.balanceOf(user1); + uint256 totalSupplyBefore = eulerAggregationLayer.totalSupply(); + uint256 totalAssetsDepositedBefore = eulerAggregationLayer.totalAssetsDeposited(); uint256 userAssetBalanceBefore = assetTST.balanceOf(user1); vm.startPrank(user1); - assetTST.approve(address(aggregationLayerVault), amountToDeposit); - aggregationLayerVault.deposit(amountToDeposit, user1); + assetTST.approve(address(eulerAggregationLayer), amountToDeposit); + eulerAggregationLayer.deposit(amountToDeposit, user1); vm.stopPrank(); - assertEq(aggregationLayerVault.balanceOf(user1), balanceBefore + amountToDeposit); - assertEq(aggregationLayerVault.totalSupply(), totalSupplyBefore + amountToDeposit); - assertEq(aggregationLayerVault.totalAssetsDeposited(), totalAssetsDepositedBefore + amountToDeposit); + assertEq(eulerAggregationLayer.balanceOf(user1), balanceBefore + amountToDeposit); + assertEq(eulerAggregationLayer.totalSupply(), totalSupplyBefore + amountToDeposit); + assertEq(eulerAggregationLayer.totalAssetsDeposited(), totalAssetsDepositedBefore + amountToDeposit); assertEq(assetTST.balanceOf(user1), userAssetBalanceBefore - amountToDeposit); } // rebalance into strategy vm.warp(block.timestamp + 86400); { - IAggregationLayerVault.Strategy memory strategyBefore = aggregationLayerVault.getStrategy(address(eTST)); + IEulerAggregationLayer.Strategy memory strategyBefore = eulerAggregationLayer.getStrategy(address(eTST)); - assertEq(eTST.convertToAssets(eTST.balanceOf(address(aggregationLayerVault))), strategyBefore.allocated); + assertEq(eTST.convertToAssets(eTST.balanceOf(address(eulerAggregationLayer))), strategyBefore.allocated); - uint256 expectedStrategyCash = aggregationLayerVault.totalAssetsAllocatable() - * strategyBefore.allocationPoints / aggregationLayerVault.totalAllocationPoints(); + uint256 expectedStrategyCash = eulerAggregationLayer.totalAssetsAllocatable() + * strategyBefore.allocationPoints / eulerAggregationLayer.totalAllocationPoints(); vm.prank(user1); address[] memory strategiesToRebalance = new address[](1); strategiesToRebalance[0] = address(eTST); - rebalancer.executeRebalance(address(aggregationLayerVault), strategiesToRebalance); + rebalancer.executeRebalance(address(eulerAggregationLayer), strategiesToRebalance); - assertEq(aggregationLayerVault.totalAllocated(), expectedStrategyCash); - assertEq(eTST.convertToAssets(eTST.balanceOf(address(aggregationLayerVault))), expectedStrategyCash); - assertEq((aggregationLayerVault.getStrategy(address(eTST))).allocated, expectedStrategyCash); + assertEq(eulerAggregationLayer.totalAllocated(), expectedStrategyCash); + assertEq(eTST.convertToAssets(eTST.balanceOf(address(eulerAggregationLayer))), expectedStrategyCash); + assertEq((eulerAggregationLayer.getStrategy(address(eTST))).allocated, expectedStrategyCash); } vm.warp(block.timestamp + 86400); // mock an increase of strategy balance by 10% - uint256 aggrCurrentStrategyShareBalance = eTST.balanceOf(address(aggregationLayerVault)); + uint256 aggrCurrentStrategyShareBalance = eTST.balanceOf(address(eulerAggregationLayer)); uint256 aggrCurrentStrategyUnderlyingBalance = eTST.convertToAssets(aggrCurrentStrategyShareBalance); uint256 aggrNewStrategyUnderlyingBalance = aggrCurrentStrategyUnderlyingBalance * 11e17 / 1e18; uint256 yield = aggrNewStrategyUnderlyingBalance - aggrCurrentStrategyUnderlyingBalance; assetTST.mint(address(eTST), yield); - eTST.skim(type(uint256).max, address(aggregationLayerVault)); + eTST.skim(type(uint256).max, address(eulerAggregationLayer)); // full withdraw, will have to withdraw from strategy as cash reserve is not enough { - uint256 amountToWithdraw = aggregationLayerVault.balanceOf(user1); - uint256 totalAssetsDepositedBefore = aggregationLayerVault.totalAssetsDeposited(); - uint256 aggregatorTotalSupplyBefore = aggregationLayerVault.totalSupply(); + uint256 amountToWithdraw = eulerAggregationLayer.balanceOf(user1); + uint256 totalAssetsDepositedBefore = eulerAggregationLayer.totalAssetsDeposited(); + uint256 aggregatorTotalSupplyBefore = eulerAggregationLayer.totalSupply(); uint256 user1AssetTSTBalanceBefore = assetTST.balanceOf(user1); vm.prank(user1); - aggregationLayerVault.redeem(amountToWithdraw, user1, user1); + eulerAggregationLayer.redeem(amountToWithdraw, user1, user1); - assertEq(eTST.balanceOf(address(aggregationLayerVault)), yield); - assertEq(aggregationLayerVault.totalAssetsDeposited(), totalAssetsDepositedBefore - amountToWithdraw); - assertEq(aggregationLayerVault.totalSupply(), aggregatorTotalSupplyBefore - amountToWithdraw); + assertEq(eTST.balanceOf(address(eulerAggregationLayer)), yield); + assertEq(eulerAggregationLayer.totalAssetsDeposited(), totalAssetsDepositedBefore - amountToWithdraw); + assertEq(eulerAggregationLayer.totalSupply(), aggregatorTotalSupplyBefore - amountToWithdraw); assertEq( assetTST.balanceOf(user1), - user1AssetTSTBalanceBefore + aggregationLayerVault.convertToAssets(amountToWithdraw) + user1AssetTSTBalanceBefore + eulerAggregationLayer.convertToAssets(amountToWithdraw) ); } } @@ -197,19 +197,19 @@ contract DepositRebalanceHarvestWithdrawE2ETest is AggregationLayerVaultBase { // deposit into aggregator { - uint256 balanceBefore = aggregationLayerVault.balanceOf(user1); - uint256 totalSupplyBefore = aggregationLayerVault.totalSupply(); - uint256 totalAssetsDepositedBefore = aggregationLayerVault.totalAssetsDeposited(); + uint256 balanceBefore = eulerAggregationLayer.balanceOf(user1); + uint256 totalSupplyBefore = eulerAggregationLayer.totalSupply(); + uint256 totalAssetsDepositedBefore = eulerAggregationLayer.totalAssetsDeposited(); uint256 userAssetBalanceBefore = assetTST.balanceOf(user1); vm.startPrank(user1); - assetTST.approve(address(aggregationLayerVault), amountToDeposit); - aggregationLayerVault.deposit(amountToDeposit, user1); + assetTST.approve(address(eulerAggregationLayer), amountToDeposit); + eulerAggregationLayer.deposit(amountToDeposit, user1); vm.stopPrank(); - assertEq(aggregationLayerVault.balanceOf(user1), balanceBefore + amountToDeposit); - assertEq(aggregationLayerVault.totalSupply(), totalSupplyBefore + amountToDeposit); - assertEq(aggregationLayerVault.totalAssetsDeposited(), totalAssetsDepositedBefore + amountToDeposit); + assertEq(eulerAggregationLayer.balanceOf(user1), balanceBefore + amountToDeposit); + assertEq(eulerAggregationLayer.totalSupply(), totalSupplyBefore + amountToDeposit); + assertEq(eulerAggregationLayer.totalAssetsDeposited(), totalAssetsDepositedBefore + amountToDeposit); assertEq(assetTST.balanceOf(user1), userAssetBalanceBefore - amountToDeposit); } @@ -218,20 +218,20 @@ contract DepositRebalanceHarvestWithdrawE2ETest is AggregationLayerVaultBase { // 10k deposited; 4000 for reserve, 2000 for eTST, 4000 for eTSTsecondary vm.warp(block.timestamp + 86400); { - IAggregationLayerVault.Strategy memory eTSTstrategyBefore = aggregationLayerVault.getStrategy(address(eTST)); - IAggregationLayerVault.Strategy memory eTSTsecondarystrategyBefore = - aggregationLayerVault.getStrategy(address(eTSTsecondary)); + IEulerAggregationLayer.Strategy memory eTSTstrategyBefore = eulerAggregationLayer.getStrategy(address(eTST)); + IEulerAggregationLayer.Strategy memory eTSTsecondarystrategyBefore = + eulerAggregationLayer.getStrategy(address(eTSTsecondary)); - assertEq(eTST.convertToAssets(eTST.balanceOf(address(aggregationLayerVault))), eTSTstrategyBefore.allocated); + assertEq(eTST.convertToAssets(eTST.balanceOf(address(eulerAggregationLayer))), eTSTstrategyBefore.allocated); assertEq( - eTSTsecondary.convertToAssets(eTSTsecondary.balanceOf(address(aggregationLayerVault))), + eTSTsecondary.convertToAssets(eTSTsecondary.balanceOf(address(eulerAggregationLayer))), eTSTsecondarystrategyBefore.allocated ); - uint256 expectedeTSTStrategyCash = aggregationLayerVault.totalAssetsAllocatable() - * eTSTstrategyBefore.allocationPoints / aggregationLayerVault.totalAllocationPoints(); - uint256 expectedeTSTsecondaryStrategyCash = aggregationLayerVault.totalAssetsAllocatable() - * eTSTsecondarystrategyBefore.allocationPoints / aggregationLayerVault.totalAllocationPoints(); + uint256 expectedeTSTStrategyCash = eulerAggregationLayer.totalAssetsAllocatable() + * eTSTstrategyBefore.allocationPoints / eulerAggregationLayer.totalAllocationPoints(); + uint256 expectedeTSTsecondaryStrategyCash = eulerAggregationLayer.totalAssetsAllocatable() + * eTSTsecondarystrategyBefore.allocationPoints / eulerAggregationLayer.totalAllocationPoints(); assertTrue(expectedeTSTStrategyCash != 0); assertTrue(expectedeTSTsecondaryStrategyCash != 0); @@ -240,31 +240,31 @@ contract DepositRebalanceHarvestWithdrawE2ETest is AggregationLayerVaultBase { strategiesToRebalance[0] = address(eTST); strategiesToRebalance[1] = address(eTSTsecondary); vm.prank(user1); - rebalancer.executeRebalance(address(aggregationLayerVault), strategiesToRebalance); + rebalancer.executeRebalance(address(eulerAggregationLayer), strategiesToRebalance); assertEq( - aggregationLayerVault.totalAllocated(), expectedeTSTStrategyCash + expectedeTSTsecondaryStrategyCash + eulerAggregationLayer.totalAllocated(), expectedeTSTStrategyCash + expectedeTSTsecondaryStrategyCash ); - assertEq(eTST.convertToAssets(eTST.balanceOf(address(aggregationLayerVault))), expectedeTSTStrategyCash); + assertEq(eTST.convertToAssets(eTST.balanceOf(address(eulerAggregationLayer))), expectedeTSTStrategyCash); assertEq( - eTSTsecondary.convertToAssets(eTSTsecondary.balanceOf(address(aggregationLayerVault))), + eTSTsecondary.convertToAssets(eTSTsecondary.balanceOf(address(eulerAggregationLayer))), expectedeTSTsecondaryStrategyCash ); - assertEq((aggregationLayerVault.getStrategy(address(eTST))).allocated, expectedeTSTStrategyCash); + assertEq((eulerAggregationLayer.getStrategy(address(eTST))).allocated, expectedeTSTStrategyCash); assertEq( - (aggregationLayerVault.getStrategy(address(eTSTsecondary))).allocated, expectedeTSTsecondaryStrategyCash + (eulerAggregationLayer.getStrategy(address(eTSTsecondary))).allocated, expectedeTSTsecondaryStrategyCash ); assertEq( - assetTST.balanceOf(address(aggregationLayerVault)), + assetTST.balanceOf(address(eulerAggregationLayer)), amountToDeposit - (expectedeTSTStrategyCash + expectedeTSTsecondaryStrategyCash) ); } vm.warp(block.timestamp + 86400); // mock an increase of aggregator balance due to yield - uint256 aggrCurrenteTSTShareBalance = eTST.balanceOf(address(aggregationLayerVault)); + uint256 aggrCurrenteTSTShareBalance = eTST.balanceOf(address(eulerAggregationLayer)); uint256 aggrCurrenteTSTUnderlyingBalance = eTST.convertToAssets(aggrCurrenteTSTShareBalance); - uint256 aggrCurrenteTSTsecondaryShareBalance = eTSTsecondary.balanceOf(address(aggregationLayerVault)); + uint256 aggrCurrenteTSTsecondaryShareBalance = eTSTsecondary.balanceOf(address(eulerAggregationLayer)); uint256 aggrCurrenteTSTsecondaryUnderlyingBalance = eTST.convertToAssets(aggrCurrenteTSTsecondaryShareBalance); uint256 aggrNeweTSTUnderlyingBalance = aggrCurrenteTSTUnderlyingBalance * 11e17 / 1e18; uint256 aggrNeweTSTsecondaryUnderlyingBalance = aggrCurrenteTSTsecondaryUnderlyingBalance * 11e17 / 1e18; @@ -273,25 +273,25 @@ contract DepositRebalanceHarvestWithdrawE2ETest is AggregationLayerVaultBase { assetTST.mint(address(eTST), eTSTYield); assetTST.mint(address(eTSTsecondary), eTSTsecondaryYield); - eTST.skim(type(uint256).max, address(aggregationLayerVault)); - eTSTsecondary.skim(type(uint256).max, address(aggregationLayerVault)); + eTST.skim(type(uint256).max, address(eulerAggregationLayer)); + eTSTsecondary.skim(type(uint256).max, address(eulerAggregationLayer)); // full withdraw, will have to withdraw from strategy as cash reserve is not enough { - uint256 amountToWithdraw = aggregationLayerVault.balanceOf(user1); - uint256 totalAssetsDepositedBefore = aggregationLayerVault.totalAssetsDeposited(); - uint256 aggregatorTotalSupplyBefore = aggregationLayerVault.totalSupply(); + uint256 amountToWithdraw = eulerAggregationLayer.balanceOf(user1); + uint256 totalAssetsDepositedBefore = eulerAggregationLayer.totalAssetsDeposited(); + uint256 aggregatorTotalSupplyBefore = eulerAggregationLayer.totalSupply(); uint256 user1AssetTSTBalanceBefore = assetTST.balanceOf(user1); vm.prank(user1); - aggregationLayerVault.redeem(amountToWithdraw, user1, user1); + eulerAggregationLayer.redeem(amountToWithdraw, user1, user1); - assertEq(eTST.balanceOf(address(aggregationLayerVault)), 0); - assertEq(aggregationLayerVault.totalAssetsDeposited(), totalAssetsDepositedBefore - amountToWithdraw); - assertEq(aggregationLayerVault.totalSupply(), aggregatorTotalSupplyBefore - amountToWithdraw); + assertEq(eTST.balanceOf(address(eulerAggregationLayer)), 0); + assertEq(eulerAggregationLayer.totalAssetsDeposited(), totalAssetsDepositedBefore - amountToWithdraw); + assertEq(eulerAggregationLayer.totalSupply(), aggregatorTotalSupplyBefore - amountToWithdraw); assertEq( assetTST.balanceOf(user1), - user1AssetTSTBalanceBefore + aggregationLayerVault.convertToAssets(amountToWithdraw) + user1AssetTSTBalanceBefore + eulerAggregationLayer.convertToAssets(amountToWithdraw) ); } } @@ -301,72 +301,72 @@ contract DepositRebalanceHarvestWithdrawE2ETest is AggregationLayerVaultBase { // deposit into aggregator { - uint256 balanceBefore = aggregationLayerVault.balanceOf(user1); - uint256 totalSupplyBefore = aggregationLayerVault.totalSupply(); - uint256 totalAssetsDepositedBefore = aggregationLayerVault.totalAssetsDeposited(); + uint256 balanceBefore = eulerAggregationLayer.balanceOf(user1); + uint256 totalSupplyBefore = eulerAggregationLayer.totalSupply(); + uint256 totalAssetsDepositedBefore = eulerAggregationLayer.totalAssetsDeposited(); uint256 userAssetBalanceBefore = assetTST.balanceOf(user1); vm.startPrank(user1); - assetTST.approve(address(aggregationLayerVault), amountToDeposit); - aggregationLayerVault.deposit(amountToDeposit, user1); + assetTST.approve(address(eulerAggregationLayer), amountToDeposit); + eulerAggregationLayer.deposit(amountToDeposit, user1); vm.stopPrank(); - assertEq(aggregationLayerVault.balanceOf(user1), balanceBefore + amountToDeposit); - assertEq(aggregationLayerVault.totalSupply(), totalSupplyBefore + amountToDeposit); - assertEq(aggregationLayerVault.totalAssetsDeposited(), totalAssetsDepositedBefore + amountToDeposit); + assertEq(eulerAggregationLayer.balanceOf(user1), balanceBefore + amountToDeposit); + assertEq(eulerAggregationLayer.totalSupply(), totalSupplyBefore + amountToDeposit); + assertEq(eulerAggregationLayer.totalAssetsDeposited(), totalAssetsDepositedBefore + amountToDeposit); assertEq(assetTST.balanceOf(user1), userAssetBalanceBefore - amountToDeposit); } // rebalance into strategy vm.warp(block.timestamp + 86400); { - IAggregationLayerVault.Strategy memory strategyBefore = aggregationLayerVault.getStrategy(address(eTST)); + IEulerAggregationLayer.Strategy memory strategyBefore = eulerAggregationLayer.getStrategy(address(eTST)); - assertEq(eTST.convertToAssets(eTST.balanceOf(address(aggregationLayerVault))), strategyBefore.allocated); + assertEq(eTST.convertToAssets(eTST.balanceOf(address(eulerAggregationLayer))), strategyBefore.allocated); - uint256 expectedStrategyCash = aggregationLayerVault.totalAssetsAllocatable() - * strategyBefore.allocationPoints / aggregationLayerVault.totalAllocationPoints(); + uint256 expectedStrategyCash = eulerAggregationLayer.totalAssetsAllocatable() + * strategyBefore.allocationPoints / eulerAggregationLayer.totalAllocationPoints(); vm.prank(user1); address[] memory strategiesToRebalance = new address[](1); strategiesToRebalance[0] = address(eTST); - rebalancer.executeRebalance(address(aggregationLayerVault), strategiesToRebalance); + rebalancer.executeRebalance(address(eulerAggregationLayer), strategiesToRebalance); - assertEq(aggregationLayerVault.totalAllocated(), expectedStrategyCash); - assertEq(eTST.convertToAssets(eTST.balanceOf(address(aggregationLayerVault))), expectedStrategyCash); - assertEq((aggregationLayerVault.getStrategy(address(eTST))).allocated, expectedStrategyCash); + assertEq(eulerAggregationLayer.totalAllocated(), expectedStrategyCash); + assertEq(eTST.convertToAssets(eTST.balanceOf(address(eulerAggregationLayer))), expectedStrategyCash); + assertEq((eulerAggregationLayer.getStrategy(address(eTST))).allocated, expectedStrategyCash); } vm.warp(block.timestamp + 86400); // mock an increase of strategy balance by 10% - uint256 aggrCurrentStrategyShareBalance = eTST.balanceOf(address(aggregationLayerVault)); + uint256 aggrCurrentStrategyShareBalance = eTST.balanceOf(address(eulerAggregationLayer)); uint256 aggrCurrentStrategyUnderlyingBalance = eTST.convertToAssets(aggrCurrentStrategyShareBalance); uint256 aggrNewStrategyUnderlyingBalance = aggrCurrentStrategyUnderlyingBalance * 11e17 / 1e18; uint256 yield = aggrNewStrategyUnderlyingBalance - aggrCurrentStrategyUnderlyingBalance; assetTST.mint(address(eTST), yield); - eTST.skim(type(uint256).max, address(aggregationLayerVault)); + eTST.skim(type(uint256).max, address(eulerAggregationLayer)); // harvest vm.prank(user1); - aggregationLayerVault.harvest(); + eulerAggregationLayer.harvest(); vm.warp(block.timestamp + 2 weeks); // full withdraw, will have to withdraw from strategy as cash reserve is not enough { - uint256 amountToWithdraw = aggregationLayerVault.balanceOf(user1); - uint256 totalAssetsDepositedBefore = aggregationLayerVault.totalAssetsDeposited(); - uint256 aggregatorTotalSupplyBefore = aggregationLayerVault.totalSupply(); + uint256 amountToWithdraw = eulerAggregationLayer.balanceOf(user1); + uint256 totalAssetsDepositedBefore = eulerAggregationLayer.totalAssetsDeposited(); + uint256 aggregatorTotalSupplyBefore = eulerAggregationLayer.totalSupply(); uint256 user1AssetTSTBalanceBefore = assetTST.balanceOf(user1); vm.prank(user1); - aggregationLayerVault.redeem(amountToWithdraw, user1, user1); + eulerAggregationLayer.redeem(amountToWithdraw, user1, user1); // all yield is distributed - assertApproxEqAbs(eTST.balanceOf(address(aggregationLayerVault)), 0, 1); + assertApproxEqAbs(eTST.balanceOf(address(eulerAggregationLayer)), 0, 1); assertApproxEqAbs( - aggregationLayerVault.totalAssetsDeposited(), totalAssetsDepositedBefore - amountToWithdraw, 1 + eulerAggregationLayer.totalAssetsDeposited(), totalAssetsDepositedBefore - amountToWithdraw, 1 ); - assertEq(aggregationLayerVault.totalSupply(), aggregatorTotalSupplyBefore - amountToWithdraw); + assertEq(eulerAggregationLayer.totalSupply(), aggregatorTotalSupplyBefore - amountToWithdraw); assertApproxEqAbs(assetTST.balanceOf(user1), user1AssetTSTBalanceBefore + amountToDeposit + yield, 1); } } @@ -391,19 +391,19 @@ contract DepositRebalanceHarvestWithdrawE2ETest is AggregationLayerVaultBase { // deposit into aggregator { - uint256 balanceBefore = aggregationLayerVault.balanceOf(user1); - uint256 totalSupplyBefore = aggregationLayerVault.totalSupply(); - uint256 totalAssetsDepositedBefore = aggregationLayerVault.totalAssetsDeposited(); + uint256 balanceBefore = eulerAggregationLayer.balanceOf(user1); + uint256 totalSupplyBefore = eulerAggregationLayer.totalSupply(); + uint256 totalAssetsDepositedBefore = eulerAggregationLayer.totalAssetsDeposited(); uint256 userAssetBalanceBefore = assetTST.balanceOf(user1); vm.startPrank(user1); - assetTST.approve(address(aggregationLayerVault), amountToDeposit); - aggregationLayerVault.deposit(amountToDeposit, user1); + assetTST.approve(address(eulerAggregationLayer), amountToDeposit); + eulerAggregationLayer.deposit(amountToDeposit, user1); vm.stopPrank(); - assertEq(aggregationLayerVault.balanceOf(user1), balanceBefore + amountToDeposit); - assertEq(aggregationLayerVault.totalSupply(), totalSupplyBefore + amountToDeposit); - assertEq(aggregationLayerVault.totalAssetsDeposited(), totalAssetsDepositedBefore + amountToDeposit); + assertEq(eulerAggregationLayer.balanceOf(user1), balanceBefore + amountToDeposit); + assertEq(eulerAggregationLayer.totalSupply(), totalSupplyBefore + amountToDeposit); + assertEq(eulerAggregationLayer.totalAssetsDeposited(), totalAssetsDepositedBefore + amountToDeposit); assertEq(assetTST.balanceOf(user1), userAssetBalanceBefore - amountToDeposit); } @@ -412,20 +412,20 @@ contract DepositRebalanceHarvestWithdrawE2ETest is AggregationLayerVaultBase { // 10k deposited; 4000 for reserve, 2000 for eTST, 4000 for eTSTsecondary vm.warp(block.timestamp + 86400); { - IAggregationLayerVault.Strategy memory eTSTstrategyBefore = aggregationLayerVault.getStrategy(address(eTST)); - IAggregationLayerVault.Strategy memory eTSTsecondarystrategyBefore = - aggregationLayerVault.getStrategy(address(eTSTsecondary)); + IEulerAggregationLayer.Strategy memory eTSTstrategyBefore = eulerAggregationLayer.getStrategy(address(eTST)); + IEulerAggregationLayer.Strategy memory eTSTsecondarystrategyBefore = + eulerAggregationLayer.getStrategy(address(eTSTsecondary)); - assertEq(eTST.convertToAssets(eTST.balanceOf(address(aggregationLayerVault))), eTSTstrategyBefore.allocated); + assertEq(eTST.convertToAssets(eTST.balanceOf(address(eulerAggregationLayer))), eTSTstrategyBefore.allocated); assertEq( - eTSTsecondary.convertToAssets(eTSTsecondary.balanceOf(address(aggregationLayerVault))), + eTSTsecondary.convertToAssets(eTSTsecondary.balanceOf(address(eulerAggregationLayer))), eTSTsecondarystrategyBefore.allocated ); - uint256 expectedeTSTStrategyCash = aggregationLayerVault.totalAssetsAllocatable() - * eTSTstrategyBefore.allocationPoints / aggregationLayerVault.totalAllocationPoints(); - uint256 expectedeTSTsecondaryStrategyCash = aggregationLayerVault.totalAssetsAllocatable() - * eTSTsecondarystrategyBefore.allocationPoints / aggregationLayerVault.totalAllocationPoints(); + uint256 expectedeTSTStrategyCash = eulerAggregationLayer.totalAssetsAllocatable() + * eTSTstrategyBefore.allocationPoints / eulerAggregationLayer.totalAllocationPoints(); + uint256 expectedeTSTsecondaryStrategyCash = eulerAggregationLayer.totalAssetsAllocatable() + * eTSTsecondarystrategyBefore.allocationPoints / eulerAggregationLayer.totalAllocationPoints(); assertTrue(expectedeTSTStrategyCash != 0); assertTrue(expectedeTSTsecondaryStrategyCash != 0); @@ -434,22 +434,22 @@ contract DepositRebalanceHarvestWithdrawE2ETest is AggregationLayerVaultBase { strategiesToRebalance[0] = address(eTST); strategiesToRebalance[1] = address(eTSTsecondary); vm.prank(user1); - rebalancer.executeRebalance(address(aggregationLayerVault), strategiesToRebalance); + rebalancer.executeRebalance(address(eulerAggregationLayer), strategiesToRebalance); assertEq( - aggregationLayerVault.totalAllocated(), expectedeTSTStrategyCash + expectedeTSTsecondaryStrategyCash + eulerAggregationLayer.totalAllocated(), expectedeTSTStrategyCash + expectedeTSTsecondaryStrategyCash ); - assertEq(eTST.convertToAssets(eTST.balanceOf(address(aggregationLayerVault))), expectedeTSTStrategyCash); + assertEq(eTST.convertToAssets(eTST.balanceOf(address(eulerAggregationLayer))), expectedeTSTStrategyCash); assertEq( - eTSTsecondary.convertToAssets(eTSTsecondary.balanceOf(address(aggregationLayerVault))), + eTSTsecondary.convertToAssets(eTSTsecondary.balanceOf(address(eulerAggregationLayer))), expectedeTSTsecondaryStrategyCash ); - assertEq((aggregationLayerVault.getStrategy(address(eTST))).allocated, expectedeTSTStrategyCash); + assertEq((eulerAggregationLayer.getStrategy(address(eTST))).allocated, expectedeTSTStrategyCash); assertEq( - (aggregationLayerVault.getStrategy(address(eTSTsecondary))).allocated, expectedeTSTsecondaryStrategyCash + (eulerAggregationLayer.getStrategy(address(eTSTsecondary))).allocated, expectedeTSTsecondaryStrategyCash ); assertEq( - assetTST.balanceOf(address(aggregationLayerVault)), + assetTST.balanceOf(address(eulerAggregationLayer)), amountToDeposit - (expectedeTSTStrategyCash + expectedeTSTsecondaryStrategyCash) ); } @@ -459,9 +459,9 @@ contract DepositRebalanceHarvestWithdrawE2ETest is AggregationLayerVaultBase { uint256 eTSTsecondaryYield; { // mock an increase of aggregator balance due to yield - uint256 aggrCurrenteTSTShareBalance = eTST.balanceOf(address(aggregationLayerVault)); + uint256 aggrCurrenteTSTShareBalance = eTST.balanceOf(address(eulerAggregationLayer)); uint256 aggrCurrenteTSTUnderlyingBalance = eTST.convertToAssets(aggrCurrenteTSTShareBalance); - uint256 aggrCurrenteTSTsecondaryShareBalance = eTSTsecondary.balanceOf(address(aggregationLayerVault)); + uint256 aggrCurrenteTSTsecondaryShareBalance = eTSTsecondary.balanceOf(address(eulerAggregationLayer)); uint256 aggrCurrenteTSTsecondaryUnderlyingBalance = eTST.convertToAssets(aggrCurrenteTSTsecondaryShareBalance); uint256 aggrNeweTSTUnderlyingBalance = aggrCurrenteTSTUnderlyingBalance * 11e17 / 1e18; @@ -471,30 +471,30 @@ contract DepositRebalanceHarvestWithdrawE2ETest is AggregationLayerVaultBase { assetTST.mint(address(eTST), eTSTYield); assetTST.mint(address(eTSTsecondary), eTSTsecondaryYield); - eTST.skim(type(uint256).max, address(aggregationLayerVault)); - eTSTsecondary.skim(type(uint256).max, address(aggregationLayerVault)); + eTST.skim(type(uint256).max, address(eulerAggregationLayer)); + eTSTsecondary.skim(type(uint256).max, address(eulerAggregationLayer)); } // harvest vm.prank(user1); - aggregationLayerVault.harvest(); + eulerAggregationLayer.harvest(); vm.warp(block.timestamp + 2 weeks); // full withdraw, will have to withdraw from strategy as cash reserve is not enough { - uint256 amountToWithdraw = aggregationLayerVault.balanceOf(user1); - uint256 totalAssetsDepositedBefore = aggregationLayerVault.totalAssetsDeposited(); - uint256 aggregatorTotalSupplyBefore = aggregationLayerVault.totalSupply(); + uint256 amountToWithdraw = eulerAggregationLayer.balanceOf(user1); + uint256 totalAssetsDepositedBefore = eulerAggregationLayer.totalAssetsDeposited(); + uint256 aggregatorTotalSupplyBefore = eulerAggregationLayer.totalSupply(); uint256 user1AssetTSTBalanceBefore = assetTST.balanceOf(user1); vm.prank(user1); - aggregationLayerVault.redeem(amountToWithdraw, user1, user1); + eulerAggregationLayer.redeem(amountToWithdraw, user1, user1); - assertApproxEqAbs(eTST.balanceOf(address(aggregationLayerVault)), 0, 0); + assertApproxEqAbs(eTST.balanceOf(address(eulerAggregationLayer)), 0, 0); assertApproxEqAbs( - aggregationLayerVault.totalAssetsDeposited(), totalAssetsDepositedBefore - amountToWithdraw, 1 + eulerAggregationLayer.totalAssetsDeposited(), totalAssetsDepositedBefore - amountToWithdraw, 1 ); - assertEq(aggregationLayerVault.totalSupply(), aggregatorTotalSupplyBefore - amountToWithdraw); + assertEq(eulerAggregationLayer.totalSupply(), aggregatorTotalSupplyBefore - amountToWithdraw); assertApproxEqAbs( assetTST.balanceOf(user1), user1AssetTSTBalanceBefore + amountToDeposit + eTSTYield + eTSTsecondaryYield, @@ -523,19 +523,19 @@ contract DepositRebalanceHarvestWithdrawE2ETest is AggregationLayerVaultBase { // deposit into aggregator { - uint256 balanceBefore = aggregationLayerVault.balanceOf(user1); - uint256 totalSupplyBefore = aggregationLayerVault.totalSupply(); - uint256 totalAssetsDepositedBefore = aggregationLayerVault.totalAssetsDeposited(); + uint256 balanceBefore = eulerAggregationLayer.balanceOf(user1); + uint256 totalSupplyBefore = eulerAggregationLayer.totalSupply(); + uint256 totalAssetsDepositedBefore = eulerAggregationLayer.totalAssetsDeposited(); uint256 userAssetBalanceBefore = assetTST.balanceOf(user1); vm.startPrank(user1); - assetTST.approve(address(aggregationLayerVault), amountToDeposit); - aggregationLayerVault.deposit(amountToDeposit, user1); + assetTST.approve(address(eulerAggregationLayer), amountToDeposit); + eulerAggregationLayer.deposit(amountToDeposit, user1); vm.stopPrank(); - assertEq(aggregationLayerVault.balanceOf(user1), balanceBefore + amountToDeposit); - assertEq(aggregationLayerVault.totalSupply(), totalSupplyBefore + amountToDeposit); - assertEq(aggregationLayerVault.totalAssetsDeposited(), totalAssetsDepositedBefore + amountToDeposit); + assertEq(eulerAggregationLayer.balanceOf(user1), balanceBefore + amountToDeposit); + assertEq(eulerAggregationLayer.totalSupply(), totalSupplyBefore + amountToDeposit); + assertEq(eulerAggregationLayer.totalAssetsDeposited(), totalAssetsDepositedBefore + amountToDeposit); assertEq(assetTST.balanceOf(user1), userAssetBalanceBefore - amountToDeposit); } @@ -544,20 +544,20 @@ contract DepositRebalanceHarvestWithdrawE2ETest is AggregationLayerVaultBase { // 10k deposited; 4000 for reserve, 2000 for eTST, 4000 for eTSTsecondary vm.warp(block.timestamp + 86400); { - IAggregationLayerVault.Strategy memory eTSTstrategyBefore = aggregationLayerVault.getStrategy(address(eTST)); - IAggregationLayerVault.Strategy memory eTSTsecondarystrategyBefore = - aggregationLayerVault.getStrategy(address(eTSTsecondary)); + IEulerAggregationLayer.Strategy memory eTSTstrategyBefore = eulerAggregationLayer.getStrategy(address(eTST)); + IEulerAggregationLayer.Strategy memory eTSTsecondarystrategyBefore = + eulerAggregationLayer.getStrategy(address(eTSTsecondary)); - assertEq(eTST.convertToAssets(eTST.balanceOf(address(aggregationLayerVault))), eTSTstrategyBefore.allocated); + assertEq(eTST.convertToAssets(eTST.balanceOf(address(eulerAggregationLayer))), eTSTstrategyBefore.allocated); assertEq( - eTSTsecondary.convertToAssets(eTSTsecondary.balanceOf(address(aggregationLayerVault))), + eTSTsecondary.convertToAssets(eTSTsecondary.balanceOf(address(eulerAggregationLayer))), eTSTsecondarystrategyBefore.allocated ); - uint256 expectedeTSTStrategyCash = aggregationLayerVault.totalAssetsAllocatable() - * eTSTstrategyBefore.allocationPoints / aggregationLayerVault.totalAllocationPoints(); - uint256 expectedeTSTsecondaryStrategyCash = aggregationLayerVault.totalAssetsAllocatable() - * eTSTsecondarystrategyBefore.allocationPoints / aggregationLayerVault.totalAllocationPoints(); + uint256 expectedeTSTStrategyCash = eulerAggregationLayer.totalAssetsAllocatable() + * eTSTstrategyBefore.allocationPoints / eulerAggregationLayer.totalAllocationPoints(); + uint256 expectedeTSTsecondaryStrategyCash = eulerAggregationLayer.totalAssetsAllocatable() + * eTSTsecondarystrategyBefore.allocationPoints / eulerAggregationLayer.totalAllocationPoints(); assertTrue(expectedeTSTStrategyCash != 0); assertTrue(expectedeTSTsecondaryStrategyCash != 0); @@ -566,22 +566,22 @@ contract DepositRebalanceHarvestWithdrawE2ETest is AggregationLayerVaultBase { strategiesToRebalance[0] = address(eTST); strategiesToRebalance[1] = address(eTSTsecondary); vm.prank(user1); - rebalancer.executeRebalance(address(aggregationLayerVault), strategiesToRebalance); + rebalancer.executeRebalance(address(eulerAggregationLayer), strategiesToRebalance); assertEq( - aggregationLayerVault.totalAllocated(), expectedeTSTStrategyCash + expectedeTSTsecondaryStrategyCash + eulerAggregationLayer.totalAllocated(), expectedeTSTStrategyCash + expectedeTSTsecondaryStrategyCash ); - assertEq(eTST.convertToAssets(eTST.balanceOf(address(aggregationLayerVault))), expectedeTSTStrategyCash); + assertEq(eTST.convertToAssets(eTST.balanceOf(address(eulerAggregationLayer))), expectedeTSTStrategyCash); assertEq( - eTSTsecondary.convertToAssets(eTSTsecondary.balanceOf(address(aggregationLayerVault))), + eTSTsecondary.convertToAssets(eTSTsecondary.balanceOf(address(eulerAggregationLayer))), expectedeTSTsecondaryStrategyCash ); - assertEq((aggregationLayerVault.getStrategy(address(eTST))).allocated, expectedeTSTStrategyCash); + assertEq((eulerAggregationLayer.getStrategy(address(eTST))).allocated, expectedeTSTStrategyCash); assertEq( - (aggregationLayerVault.getStrategy(address(eTSTsecondary))).allocated, expectedeTSTsecondaryStrategyCash + (eulerAggregationLayer.getStrategy(address(eTSTsecondary))).allocated, expectedeTSTsecondaryStrategyCash ); assertEq( - assetTST.balanceOf(address(aggregationLayerVault)), + assetTST.balanceOf(address(eulerAggregationLayer)), amountToDeposit - (expectedeTSTStrategyCash + expectedeTSTsecondaryStrategyCash) ); } @@ -591,9 +591,9 @@ contract DepositRebalanceHarvestWithdrawE2ETest is AggregationLayerVaultBase { uint256 eTSTsecondaryYield; { // mock an increase of aggregator balance due to yield - uint256 aggrCurrenteTSTShareBalance = eTST.balanceOf(address(aggregationLayerVault)); + uint256 aggrCurrenteTSTShareBalance = eTST.balanceOf(address(eulerAggregationLayer)); uint256 aggrCurrenteTSTUnderlyingBalance = eTST.convertToAssets(aggrCurrenteTSTShareBalance); - uint256 aggrCurrenteTSTsecondaryShareBalance = eTSTsecondary.balanceOf(address(aggregationLayerVault)); + uint256 aggrCurrenteTSTsecondaryShareBalance = eTSTsecondary.balanceOf(address(eulerAggregationLayer)); uint256 aggrCurrenteTSTsecondaryUnderlyingBalance = eTST.convertToAssets(aggrCurrenteTSTsecondaryShareBalance); uint256 aggrNeweTSTUnderlyingBalance = aggrCurrenteTSTUnderlyingBalance * 11e17 / 1e18; @@ -603,24 +603,24 @@ contract DepositRebalanceHarvestWithdrawE2ETest is AggregationLayerVaultBase { assetTST.mint(address(eTST), eTSTYield); assetTST.mint(address(eTSTsecondary), eTSTsecondaryYield); - eTST.skim(type(uint256).max, address(aggregationLayerVault)); - eTSTsecondary.skim(type(uint256).max, address(aggregationLayerVault)); + eTST.skim(type(uint256).max, address(eulerAggregationLayer)); + eTSTsecondary.skim(type(uint256).max, address(eulerAggregationLayer)); } // harvest vm.prank(user1); - aggregationLayerVault.harvest(); + eulerAggregationLayer.harvest(); vm.warp(block.timestamp + 2 weeks); vm.prank(manager); - aggregationLayerVault.removeStrategy(address(eTSTsecondary)); + eulerAggregationLayer.removeStrategy(address(eTSTsecondary)); { - uint256 amountToWithdraw = aggregationLayerVault.balanceOf(user1); + uint256 amountToWithdraw = eulerAggregationLayer.balanceOf(user1); vm.prank(user1); vm.expectRevert(WithdrawalQueue.NotEnoughAssets.selector); - aggregationLayerVault.redeem(amountToWithdraw, user1, user1); + eulerAggregationLayer.redeem(amountToWithdraw, user1, user1); } } } diff --git a/test/e2e/HarvestRedeemE2ETest.t.sol b/test/e2e/HarvestRedeemE2ETest.t.sol index 1a3a43c4..54634721 100644 --- a/test/e2e/HarvestRedeemE2ETest.t.sol +++ b/test/e2e/HarvestRedeemE2ETest.t.sol @@ -2,14 +2,14 @@ pragma solidity ^0.8.0; import { - AggregationLayerVaultBase, - AggregationLayerVault, + EulerAggregationLayerBase, + EulerAggregationLayer, console2, EVault, - IAggregationLayerVault -} from "../common/AggregationLayerVaultBase.t.sol"; + IEulerAggregationLayer +} from "../common/EulerAggregationLayerBase.t.sol"; -contract HarvestRedeemE2ETest is AggregationLayerVaultBase { +contract HarvestRedeemE2ETest is EulerAggregationLayerBase { uint256 user1InitialBalance = 100000e18; uint256 amountToDeposit = 10000e18; @@ -23,40 +23,40 @@ contract HarvestRedeemE2ETest is AggregationLayerVaultBase { // deposit into aggregator { - uint256 balanceBefore = aggregationLayerVault.balanceOf(user1); - uint256 totalSupplyBefore = aggregationLayerVault.totalSupply(); - uint256 totalAssetsDepositedBefore = aggregationLayerVault.totalAssetsDeposited(); + uint256 balanceBefore = eulerAggregationLayer.balanceOf(user1); + uint256 totalSupplyBefore = eulerAggregationLayer.totalSupply(); + uint256 totalAssetsDepositedBefore = eulerAggregationLayer.totalAssetsDeposited(); uint256 userAssetBalanceBefore = assetTST.balanceOf(user1); vm.startPrank(user1); - assetTST.approve(address(aggregationLayerVault), amountToDeposit); - aggregationLayerVault.deposit(amountToDeposit, user1); + assetTST.approve(address(eulerAggregationLayer), amountToDeposit); + eulerAggregationLayer.deposit(amountToDeposit, user1); vm.stopPrank(); - assertEq(aggregationLayerVault.balanceOf(user1), balanceBefore + amountToDeposit); - assertEq(aggregationLayerVault.totalSupply(), totalSupplyBefore + amountToDeposit); - assertEq(aggregationLayerVault.totalAssetsDeposited(), totalAssetsDepositedBefore + amountToDeposit); + assertEq(eulerAggregationLayer.balanceOf(user1), balanceBefore + amountToDeposit); + assertEq(eulerAggregationLayer.totalSupply(), totalSupplyBefore + amountToDeposit); + assertEq(eulerAggregationLayer.totalAssetsDeposited(), totalAssetsDepositedBefore + amountToDeposit); assertEq(assetTST.balanceOf(user1), userAssetBalanceBefore - amountToDeposit); } // rebalance into strategy vm.warp(block.timestamp + 86400); { - IAggregationLayerVault.Strategy memory strategyBefore = aggregationLayerVault.getStrategy(address(eTST)); + IEulerAggregationLayer.Strategy memory strategyBefore = eulerAggregationLayer.getStrategy(address(eTST)); - assertEq(eTST.convertToAssets(eTST.balanceOf(address(aggregationLayerVault))), strategyBefore.allocated); + assertEq(eTST.convertToAssets(eTST.balanceOf(address(eulerAggregationLayer))), strategyBefore.allocated); - uint256 expectedStrategyCash = aggregationLayerVault.totalAssetsAllocatable() - * strategyBefore.allocationPoints / aggregationLayerVault.totalAllocationPoints(); + uint256 expectedStrategyCash = eulerAggregationLayer.totalAssetsAllocatable() + * strategyBefore.allocationPoints / eulerAggregationLayer.totalAllocationPoints(); vm.prank(user1); address[] memory strategiesToRebalance = new address[](1); strategiesToRebalance[0] = address(eTST); - rebalancer.executeRebalance(address(aggregationLayerVault), strategiesToRebalance); + rebalancer.executeRebalance(address(eulerAggregationLayer), strategiesToRebalance); - assertEq(aggregationLayerVault.totalAllocated(), expectedStrategyCash); - assertEq(eTST.convertToAssets(eTST.balanceOf(address(aggregationLayerVault))), expectedStrategyCash); - assertEq((aggregationLayerVault.getStrategy(address(eTST))).allocated, expectedStrategyCash); + assertEq(eulerAggregationLayer.totalAllocated(), expectedStrategyCash); + assertEq(eTST.convertToAssets(eTST.balanceOf(address(eulerAggregationLayer))), expectedStrategyCash); + assertEq((eulerAggregationLayer.getStrategy(address(eTST))).allocated, expectedStrategyCash); } } @@ -64,36 +64,36 @@ contract HarvestRedeemE2ETest is AggregationLayerVaultBase { vm.warp(block.timestamp + 86400); // mock a decrease of strategy balance by 10% - uint256 aggrCurrentStrategyBalance = eTST.balanceOf(address(aggregationLayerVault)); + uint256 aggrCurrentStrategyBalance = eTST.balanceOf(address(eulerAggregationLayer)); uint256 aggrCurrentStrategyBalanceAfterNegYield = aggrCurrentStrategyBalance * 9e17 / 1e18; vm.mockCall( address(eTST), - abi.encodeWithSelector(EVault.maxWithdraw.selector, address(aggregationLayerVault)), + abi.encodeWithSelector(EVault.maxWithdraw.selector, address(eulerAggregationLayer)), abi.encode(aggrCurrentStrategyBalanceAfterNegYield) ); - uint256 expectedAllocated = eTST.maxWithdraw(address(aggregationLayerVault)); - IAggregationLayerVault.Strategy memory strategyBefore = aggregationLayerVault.getStrategy(address(eTST)); + uint256 expectedAllocated = eTST.maxWithdraw(address(eulerAggregationLayer)); + IEulerAggregationLayer.Strategy memory strategyBefore = eulerAggregationLayer.getStrategy(address(eTST)); assertTrue(expectedAllocated < strategyBefore.allocated); - uint256 negativeYield = strategyBefore.allocated - eTST.maxWithdraw(address(aggregationLayerVault)); + uint256 negativeYield = strategyBefore.allocated - eTST.maxWithdraw(address(eulerAggregationLayer)); - uint256 user1SharesBefore = aggregationLayerVault.balanceOf(user1); - uint256 user1SocializedLoss = user1SharesBefore * negativeYield / aggregationLayerVault.totalSupply(); + uint256 user1SharesBefore = eulerAggregationLayer.balanceOf(user1); + uint256 user1SocializedLoss = user1SharesBefore * negativeYield / eulerAggregationLayer.totalSupply(); uint256 expectedUser1Assets = - user1SharesBefore * amountToDeposit / aggregationLayerVault.totalSupply() - user1SocializedLoss; + user1SharesBefore * amountToDeposit / eulerAggregationLayer.totalSupply() - user1SocializedLoss; uint256 user1AssetTSTBalanceBefore = assetTST.balanceOf(user1); vm.startPrank(user1); - aggregationLayerVault.harvest(); - aggregationLayerVault.redeem(user1SharesBefore, user1, user1); + eulerAggregationLayer.harvest(); + eulerAggregationLayer.redeem(user1SharesBefore, user1, user1); vm.stopPrank(); - uint256 user1SharesAfter = aggregationLayerVault.balanceOf(user1); + uint256 user1SharesAfter = eulerAggregationLayer.balanceOf(user1); assertEq(user1SharesAfter, 0); assertApproxEqAbs(assetTST.balanceOf(user1), user1AssetTSTBalanceBefore + expectedUser1Assets, 1); - assertEq(aggregationLayerVault.totalAssetsDeposited(), 0); + assertEq(eulerAggregationLayer.totalAssetsDeposited(), 0); } function testHarvestNegativeYieldAndRedeemMultipleUser() public { @@ -102,55 +102,55 @@ contract HarvestRedeemE2ETest is AggregationLayerVaultBase { // deposit into aggregator { vm.startPrank(user2); - assetTST.approve(address(aggregationLayerVault), user2InitialBalance); - aggregationLayerVault.deposit(user2InitialBalance, user2); + assetTST.approve(address(eulerAggregationLayer), user2InitialBalance); + eulerAggregationLayer.deposit(user2InitialBalance, user2); vm.stopPrank(); } vm.warp(block.timestamp + 86400); // mock a decrease of strategy balance by 10% - uint256 aggrCurrentStrategyBalance = eTST.balanceOf(address(aggregationLayerVault)); + uint256 aggrCurrentStrategyBalance = eTST.balanceOf(address(eulerAggregationLayer)); uint256 aggrCurrentStrategyBalanceAfterNegYield = aggrCurrentStrategyBalance * 9e17 / 1e18; vm.mockCall( address(eTST), - abi.encodeWithSelector(EVault.maxWithdraw.selector, address(aggregationLayerVault)), + abi.encodeWithSelector(EVault.maxWithdraw.selector, address(eulerAggregationLayer)), abi.encode(aggrCurrentStrategyBalanceAfterNegYield) ); - IAggregationLayerVault.Strategy memory strategyBefore = aggregationLayerVault.getStrategy(address(eTST)); - uint256 expectedAllocated = eTST.maxWithdraw(address(aggregationLayerVault)); + IEulerAggregationLayer.Strategy memory strategyBefore = eulerAggregationLayer.getStrategy(address(eTST)); + uint256 expectedAllocated = eTST.maxWithdraw(address(eulerAggregationLayer)); assertTrue(expectedAllocated < strategyBefore.allocated); - uint256 negativeYield = strategyBefore.allocated - eTST.maxWithdraw(address(aggregationLayerVault)); - uint256 user1SharesBefore = aggregationLayerVault.balanceOf(user1); - uint256 user1SocializedLoss = user1SharesBefore * negativeYield / aggregationLayerVault.totalSupply(); - uint256 user2SharesBefore = aggregationLayerVault.balanceOf(user2); - uint256 user2SocializedLoss = user2SharesBefore * negativeYield / aggregationLayerVault.totalSupply(); + uint256 negativeYield = strategyBefore.allocated - eTST.maxWithdraw(address(eulerAggregationLayer)); + uint256 user1SharesBefore = eulerAggregationLayer.balanceOf(user1); + uint256 user1SocializedLoss = user1SharesBefore * negativeYield / eulerAggregationLayer.totalSupply(); + uint256 user2SharesBefore = eulerAggregationLayer.balanceOf(user2); + uint256 user2SocializedLoss = user2SharesBefore * negativeYield / eulerAggregationLayer.totalSupply(); uint256 expectedUser1Assets = user1SharesBefore * (amountToDeposit + user2InitialBalance) - / aggregationLayerVault.totalSupply() - user1SocializedLoss; + / eulerAggregationLayer.totalSupply() - user1SocializedLoss; uint256 expectedUser2Assets = user2SharesBefore * (amountToDeposit + user2InitialBalance) - / aggregationLayerVault.totalSupply() - user2SocializedLoss; + / eulerAggregationLayer.totalSupply() - user2SocializedLoss; uint256 user1AssetTSTBalanceBefore = assetTST.balanceOf(user1); uint256 user2AssetTSTBalanceBefore = assetTST.balanceOf(user2); vm.startPrank(user1); - aggregationLayerVault.harvest(); - aggregationLayerVault.redeem(user1SharesBefore, user1, user1); + eulerAggregationLayer.harvest(); + eulerAggregationLayer.redeem(user1SharesBefore, user1, user1); vm.stopPrank(); vm.prank(user2); - aggregationLayerVault.redeem(user2SharesBefore, user2, user2); + eulerAggregationLayer.redeem(user2SharesBefore, user2, user2); - uint256 user1SharesAfter = aggregationLayerVault.balanceOf(user1); - uint256 user2SharesAfter = aggregationLayerVault.balanceOf(user2); + uint256 user1SharesAfter = eulerAggregationLayer.balanceOf(user1); + uint256 user2SharesAfter = eulerAggregationLayer.balanceOf(user2); assertEq(user1SharesAfter, 0); assertEq(user2SharesAfter, 0); assertApproxEqAbs(assetTST.balanceOf(user1), user1AssetTSTBalanceBefore + expectedUser1Assets, 1); assertApproxEqAbs(assetTST.balanceOf(user2), user2AssetTSTBalanceBefore + expectedUser2Assets, 1); - assertEq(aggregationLayerVault.totalAssetsDeposited(), 0); + assertEq(eulerAggregationLayer.totalAssetsDeposited(), 0); } } diff --git a/test/e2e/HooksE2ETest.t.sol b/test/e2e/HooksE2ETest.t.sol index 0d33f8fd..04a87aee 100644 --- a/test/e2e/HooksE2ETest.t.sol +++ b/test/e2e/HooksE2ETest.t.sol @@ -2,8 +2,8 @@ pragma solidity ^0.8.0; import { - AggregationLayerVaultBase, - AggregationLayerVault, + EulerAggregationLayerBase, + EulerAggregationLayer, console2, EVault, IEVault, @@ -11,9 +11,9 @@ import { TestERC20, IHookTarget, ErrorsLib -} from "../common/AggregationLayerVaultBase.t.sol"; +} from "../common/EulerAggregationLayerBase.t.sol"; -contract HooksE2ETest is AggregationLayerVaultBase { +contract HooksE2ETest is EulerAggregationLayerBase { uint256 user1InitialBalance = 100000e18; function setUp() public virtual override { @@ -26,38 +26,38 @@ contract HooksE2ETest is AggregationLayerVaultBase { } function testSetHooksConfig() public { - uint32 expectedHookedFns = aggregationLayerVault.DEPOSIT() | aggregationLayerVault.WITHDRAW() - | aggregationLayerVault.ADD_STRATEGY() | aggregationLayerVault.REMOVE_STRATEGY(); + uint32 expectedHookedFns = eulerAggregationLayer.DEPOSIT() | eulerAggregationLayer.WITHDRAW() + | eulerAggregationLayer.ADD_STRATEGY() | eulerAggregationLayer.REMOVE_STRATEGY(); vm.startPrank(manager); address hooksContract = address(new HooksContract()); - aggregationLayerVault.setHooksConfig(hooksContract, expectedHookedFns); + eulerAggregationLayer.setHooksConfig(hooksContract, expectedHookedFns); vm.stopPrank(); - (address hookTarget, uint32 hookedFns) = aggregationLayerVault.getHooksConfig(); + (address hookTarget, uint32 hookedFns) = eulerAggregationLayer.getHooksConfig(); assertEq(hookTarget, hooksContract); assertEq(hookedFns, expectedHookedFns); } function testSetHooksConfigWithAddressZero() public { - uint32 expectedHookedFns = aggregationLayerVault.DEPOSIT() | aggregationLayerVault.WITHDRAW() - | aggregationLayerVault.ADD_STRATEGY() | aggregationLayerVault.REMOVE_STRATEGY(); + uint32 expectedHookedFns = eulerAggregationLayer.DEPOSIT() | eulerAggregationLayer.WITHDRAW() + | eulerAggregationLayer.ADD_STRATEGY() | eulerAggregationLayer.REMOVE_STRATEGY(); vm.startPrank(manager); vm.expectRevert(ErrorsLib.InvalidHooksTarget.selector); - aggregationLayerVault.setHooksConfig(address(0), expectedHookedFns); + eulerAggregationLayer.setHooksConfig(address(0), expectedHookedFns); vm.stopPrank(); } function testSetHooksConfigWithNotHooksContract() public { - uint32 expectedHookedFns = aggregationLayerVault.DEPOSIT() | aggregationLayerVault.WITHDRAW() - | aggregationLayerVault.ADD_STRATEGY() | aggregationLayerVault.REMOVE_STRATEGY(); + uint32 expectedHookedFns = eulerAggregationLayer.DEPOSIT() | eulerAggregationLayer.WITHDRAW() + | eulerAggregationLayer.ADD_STRATEGY() | eulerAggregationLayer.REMOVE_STRATEGY(); vm.startPrank(manager); address hooksContract = address(new NotHooksContract()); vm.expectRevert(ErrorsLib.NotHooksContract.selector); - aggregationLayerVault.setHooksConfig(hooksContract, expectedHookedFns); + eulerAggregationLayer.setHooksConfig(hooksContract, expectedHookedFns); vm.stopPrank(); } @@ -66,33 +66,33 @@ contract HooksE2ETest is AggregationLayerVaultBase { vm.startPrank(manager); address hooksContract = address(new HooksContract()); vm.expectRevert(ErrorsLib.InvalidHookedFns.selector); - aggregationLayerVault.setHooksConfig(hooksContract, expectedHookedFns); + eulerAggregationLayer.setHooksConfig(hooksContract, expectedHookedFns); vm.stopPrank(); } function testHookedDeposit() public { - uint32 expectedHookedFns = aggregationLayerVault.DEPOSIT(); + uint32 expectedHookedFns = eulerAggregationLayer.DEPOSIT(); vm.startPrank(manager); address hooksContract = address(new HooksContract()); - aggregationLayerVault.setHooksConfig(hooksContract, expectedHookedFns); + eulerAggregationLayer.setHooksConfig(hooksContract, expectedHookedFns); vm.stopPrank(); uint256 amountToDeposit = 10000e18; // deposit into aggregator { - uint256 balanceBefore = aggregationLayerVault.balanceOf(user1); - uint256 totalSupplyBefore = aggregationLayerVault.totalSupply(); - uint256 totalAssetsDepositedBefore = aggregationLayerVault.totalAssetsDeposited(); + uint256 balanceBefore = eulerAggregationLayer.balanceOf(user1); + uint256 totalSupplyBefore = eulerAggregationLayer.totalSupply(); + uint256 totalAssetsDepositedBefore = eulerAggregationLayer.totalAssetsDeposited(); uint256 userAssetBalanceBefore = assetTST.balanceOf(user1); vm.startPrank(user1); - assetTST.approve(address(aggregationLayerVault), amountToDeposit); - aggregationLayerVault.deposit(amountToDeposit, user1); + assetTST.approve(address(eulerAggregationLayer), amountToDeposit); + eulerAggregationLayer.deposit(amountToDeposit, user1); vm.stopPrank(); - assertEq(aggregationLayerVault.balanceOf(user1), balanceBefore + amountToDeposit); - assertEq(aggregationLayerVault.totalSupply(), totalSupplyBefore + amountToDeposit); - assertEq(aggregationLayerVault.totalAssetsDeposited(), totalAssetsDepositedBefore + amountToDeposit); + assertEq(eulerAggregationLayer.balanceOf(user1), balanceBefore + amountToDeposit); + assertEq(eulerAggregationLayer.totalSupply(), totalSupplyBefore + amountToDeposit); + assertEq(eulerAggregationLayer.totalAssetsDeposited(), totalAssetsDepositedBefore + amountToDeposit); assertEq(assetTST.balanceOf(user1), userAssetBalanceBefore - amountToDeposit); } } diff --git a/test/e2e/PerformanceFeeE2ETest.t.sol b/test/e2e/PerformanceFeeE2ETest.t.sol index 46593036..731c1c96 100644 --- a/test/e2e/PerformanceFeeE2ETest.t.sol +++ b/test/e2e/PerformanceFeeE2ETest.t.sol @@ -2,17 +2,17 @@ pragma solidity ^0.8.0; import { - AggregationLayerVaultBase, - AggregationLayerVault, + EulerAggregationLayerBase, + EulerAggregationLayer, console2, EVault, IEVault, IRMTestDefault, TestERC20, - IAggregationLayerVault -} from "../common/AggregationLayerVaultBase.t.sol"; + IEulerAggregationLayer +} from "../common/EulerAggregationLayerBase.t.sol"; -contract PerformanceFeeE2ETest is AggregationLayerVaultBase { +contract PerformanceFeeE2ETest is EulerAggregationLayerBase { uint256 user1InitialBalance = 100000e18; address feeRecipient; @@ -29,19 +29,18 @@ contract PerformanceFeeE2ETest is AggregationLayerVaultBase { } function testSetPerformanceFee() public { - { - (, uint256 fee) = aggregationLayerVault.performanceFeeConfig(); - assertEq(fee, 0); - } + (address feeRecipientAddr, uint256 fee) = eulerAggregationLayer.performanceFeeConfig(); + assertEq(fee, 0); + assertEq(feeRecipientAddr, address(0)); uint256 newPerformanceFee = 3e17; vm.startPrank(manager); - aggregationLayerVault.setFeeRecipient(feeRecipient); - aggregationLayerVault.setPerformanceFee(newPerformanceFee); + eulerAggregationLayer.setFeeRecipient(feeRecipient); + eulerAggregationLayer.setPerformanceFee(newPerformanceFee); vm.stopPrank(); - (address feeRecipientAddr, uint256 fee) = aggregationLayerVault.performanceFeeConfig(); + (feeRecipientAddr, fee) = eulerAggregationLayer.performanceFeeConfig(); assertEq(fee, newPerformanceFee); assertEq(feeRecipientAddr, feeRecipient); } @@ -50,111 +49,111 @@ contract PerformanceFeeE2ETest is AggregationLayerVaultBase { uint256 newPerformanceFee = 3e17; vm.startPrank(manager); - aggregationLayerVault.setFeeRecipient(feeRecipient); - aggregationLayerVault.setPerformanceFee(newPerformanceFee); + eulerAggregationLayer.setFeeRecipient(feeRecipient); + eulerAggregationLayer.setPerformanceFee(newPerformanceFee); vm.stopPrank(); uint256 amountToDeposit = 10000e18; // deposit into aggregator { - uint256 balanceBefore = aggregationLayerVault.balanceOf(user1); - uint256 totalSupplyBefore = aggregationLayerVault.totalSupply(); - uint256 totalAssetsDepositedBefore = aggregationLayerVault.totalAssetsDeposited(); + uint256 balanceBefore = eulerAggregationLayer.balanceOf(user1); + uint256 totalSupplyBefore = eulerAggregationLayer.totalSupply(); + uint256 totalAssetsDepositedBefore = eulerAggregationLayer.totalAssetsDeposited(); uint256 userAssetBalanceBefore = assetTST.balanceOf(user1); vm.startPrank(user1); - assetTST.approve(address(aggregationLayerVault), amountToDeposit); - aggregationLayerVault.deposit(amountToDeposit, user1); + assetTST.approve(address(eulerAggregationLayer), amountToDeposit); + eulerAggregationLayer.deposit(amountToDeposit, user1); vm.stopPrank(); - assertEq(aggregationLayerVault.balanceOf(user1), balanceBefore + amountToDeposit); - assertEq(aggregationLayerVault.totalSupply(), totalSupplyBefore + amountToDeposit); - assertEq(aggregationLayerVault.totalAssetsDeposited(), totalAssetsDepositedBefore + amountToDeposit); + assertEq(eulerAggregationLayer.balanceOf(user1), balanceBefore + amountToDeposit); + assertEq(eulerAggregationLayer.totalSupply(), totalSupplyBefore + amountToDeposit); + assertEq(eulerAggregationLayer.totalAssetsDeposited(), totalAssetsDepositedBefore + amountToDeposit); assertEq(assetTST.balanceOf(user1), userAssetBalanceBefore - amountToDeposit); } // rebalance into strategy vm.warp(block.timestamp + 86400); { - IAggregationLayerVault.Strategy memory strategyBefore = aggregationLayerVault.getStrategy(address(eTST)); + IEulerAggregationLayer.Strategy memory strategyBefore = eulerAggregationLayer.getStrategy(address(eTST)); - assertEq(eTST.convertToAssets(eTST.balanceOf(address(aggregationLayerVault))), strategyBefore.allocated); + assertEq(eTST.convertToAssets(eTST.balanceOf(address(eulerAggregationLayer))), strategyBefore.allocated); - uint256 expectedStrategyCash = aggregationLayerVault.totalAssetsAllocatable() - * strategyBefore.allocationPoints / aggregationLayerVault.totalAllocationPoints(); + uint256 expectedStrategyCash = eulerAggregationLayer.totalAssetsAllocatable() + * strategyBefore.allocationPoints / eulerAggregationLayer.totalAllocationPoints(); vm.prank(user1); address[] memory strategiesToRebalance = new address[](1); strategiesToRebalance[0] = address(eTST); - rebalancer.executeRebalance(address(aggregationLayerVault), strategiesToRebalance); + rebalancer.executeRebalance(address(eulerAggregationLayer), strategiesToRebalance); - assertEq(aggregationLayerVault.totalAllocated(), expectedStrategyCash); - assertEq(eTST.convertToAssets(eTST.balanceOf(address(aggregationLayerVault))), expectedStrategyCash); - assertEq((aggregationLayerVault.getStrategy(address(eTST))).allocated, expectedStrategyCash); + assertEq(eulerAggregationLayer.totalAllocated(), expectedStrategyCash); + assertEq(eTST.convertToAssets(eTST.balanceOf(address(eulerAggregationLayer))), expectedStrategyCash); + assertEq((eulerAggregationLayer.getStrategy(address(eTST))).allocated, expectedStrategyCash); } vm.warp(block.timestamp + 86400); // mock an increase of strategy balance by 10% uint256 yield; { - uint256 aggrCurrentStrategyShareBalance = eTST.balanceOf(address(aggregationLayerVault)); + uint256 aggrCurrentStrategyShareBalance = eTST.balanceOf(address(eulerAggregationLayer)); uint256 aggrCurrentStrategyUnderlyingBalance = eTST.convertToAssets(aggrCurrentStrategyShareBalance); uint256 aggrNewStrategyUnderlyingBalance = aggrCurrentStrategyUnderlyingBalance * 11e17 / 1e18; yield = aggrNewStrategyUnderlyingBalance - aggrCurrentStrategyUnderlyingBalance; assetTST.mint(address(eTST), yield); - eTST.skim(type(uint256).max, address(aggregationLayerVault)); + eTST.skim(type(uint256).max, address(eulerAggregationLayer)); } - (, uint256 performanceFee) = aggregationLayerVault.performanceFeeConfig(); + (, uint256 performanceFee) = eulerAggregationLayer.performanceFeeConfig(); uint256 expectedPerformanceFee = yield * performanceFee / 1e18; - IAggregationLayerVault.Strategy memory strategyBeforeHarvest = aggregationLayerVault.getStrategy(address(eTST)); - uint256 totalAllocatedBefore = aggregationLayerVault.totalAllocated(); + IEulerAggregationLayer.Strategy memory strategyBeforeHarvest = eulerAggregationLayer.getStrategy(address(eTST)); + uint256 totalAllocatedBefore = eulerAggregationLayer.totalAllocated(); // harvest vm.prank(user1); - aggregationLayerVault.harvest(); + eulerAggregationLayer.harvest(); assertEq(assetTST.balanceOf(feeRecipient), expectedPerformanceFee); assertEq( - aggregationLayerVault.getStrategy(address(eTST)).allocated, + eulerAggregationLayer.getStrategy(address(eTST)).allocated, strategyBeforeHarvest.allocated + yield - expectedPerformanceFee ); - assertEq(aggregationLayerVault.totalAllocated(), totalAllocatedBefore + yield - expectedPerformanceFee); + assertEq(eulerAggregationLayer.totalAllocated(), totalAllocatedBefore + yield - expectedPerformanceFee); // full withdraw, will have to withdraw from strategy as cash reserve is not enough { - uint256 amountToWithdraw = aggregationLayerVault.balanceOf(user1); - uint256 totalAssetsDepositedBefore = aggregationLayerVault.totalAssetsDeposited(); - uint256 aggregatorTotalSupplyBefore = aggregationLayerVault.totalSupply(); + uint256 amountToWithdraw = eulerAggregationLayer.balanceOf(user1); + uint256 totalAssetsDepositedBefore = eulerAggregationLayer.totalAssetsDeposited(); + uint256 aggregatorTotalSupplyBefore = eulerAggregationLayer.totalSupply(); uint256 user1AssetTSTBalanceBefore = assetTST.balanceOf(user1); - uint256 expectedAssetTST = aggregationLayerVault.convertToAssets(aggregationLayerVault.balanceOf(user1)); + uint256 expectedAssetTST = eulerAggregationLayer.convertToAssets(eulerAggregationLayer.balanceOf(user1)); vm.prank(user1); - aggregationLayerVault.redeem(amountToWithdraw, user1, user1); + eulerAggregationLayer.redeem(amountToWithdraw, user1, user1); assertApproxEqAbs( - aggregationLayerVault.totalAssetsDeposited(), totalAssetsDepositedBefore - expectedAssetTST, 1 + eulerAggregationLayer.totalAssetsDeposited(), totalAssetsDepositedBefore - expectedAssetTST, 1 ); - assertEq(aggregationLayerVault.totalSupply(), aggregatorTotalSupplyBefore - amountToWithdraw); + assertEq(eulerAggregationLayer.totalSupply(), aggregatorTotalSupplyBefore - amountToWithdraw); assertApproxEqAbs(assetTST.balanceOf(user1), user1AssetTSTBalanceBefore + expectedAssetTST, 1); } // full withdraw of recipient fees { - uint256 totalAssetsDepositedBefore = aggregationLayerVault.totalAssetsDeposited(); + uint256 totalAssetsDepositedBefore = eulerAggregationLayer.totalAssetsDeposited(); uint256 assetTSTBalanceBefore = assetTST.balanceOf(feeRecipient); - uint256 feeShares = aggregationLayerVault.balanceOf(feeRecipient); - uint256 expectedAssets = aggregationLayerVault.convertToAssets(feeShares); + uint256 feeShares = eulerAggregationLayer.balanceOf(feeRecipient); + uint256 expectedAssets = eulerAggregationLayer.convertToAssets(feeShares); vm.prank(feeRecipient); - aggregationLayerVault.redeem(feeShares, feeRecipient, feeRecipient); + eulerAggregationLayer.redeem(feeShares, feeRecipient, feeRecipient); assertApproxEqAbs( - aggregationLayerVault.totalAssetsDeposited(), totalAssetsDepositedBefore - expectedAssets, 1 + eulerAggregationLayer.totalAssetsDeposited(), totalAssetsDepositedBefore - expectedAssets, 1 ); - assertEq(aggregationLayerVault.totalSupply(), 0); + assertEq(eulerAggregationLayer.totalSupply(), 0); assertApproxEqAbs(assetTST.balanceOf(feeRecipient), assetTSTBalanceBefore + expectedAssets, 1); } } diff --git a/test/e2e/StrategyCapE2ETest.t.sol b/test/e2e/StrategyCapE2ETest.t.sol index 88bf5b6b..d2d4a4c5 100644 --- a/test/e2e/StrategyCapE2ETest.t.sol +++ b/test/e2e/StrategyCapE2ETest.t.sol @@ -2,18 +2,18 @@ pragma solidity ^0.8.0; import { - AggregationLayerVaultBase, - AggregationLayerVault, + EulerAggregationLayerBase, + EulerAggregationLayer, console2, EVault, IEVault, IRMTestDefault, TestERC20, - IAggregationLayerVault, + IEulerAggregationLayer, ErrorsLib -} from "../common/AggregationLayerVaultBase.t.sol"; +} from "../common/EulerAggregationLayerBase.t.sol"; -contract StrategyCapE2ETest is AggregationLayerVaultBase { +contract StrategyCapE2ETest is EulerAggregationLayerBase { uint256 user1InitialBalance = 100000e18; function setUp() public virtual override { @@ -28,12 +28,12 @@ contract StrategyCapE2ETest is AggregationLayerVaultBase { function testSetCap() public { uint256 cap = 1000000e18; - assertEq((aggregationLayerVault.getStrategy(address(eTST))).cap, 0); + assertEq((eulerAggregationLayer.getStrategy(address(eTST))).cap, 0); vm.prank(manager); - aggregationLayerVault.setStrategyCap(address(eTST), cap); + eulerAggregationLayer.setStrategyCap(address(eTST), cap); - IAggregationLayerVault.Strategy memory strategy = aggregationLayerVault.getStrategy(address(eTST)); + IEulerAggregationLayer.Strategy memory strategy = eulerAggregationLayer.getStrategy(address(eTST)); assertEq(strategy.cap, cap); } @@ -43,53 +43,54 @@ contract StrategyCapE2ETest is AggregationLayerVaultBase { vm.prank(manager); vm.expectRevert(ErrorsLib.InactiveStrategy.selector); - aggregationLayerVault.setStrategyCap(address(0x2), cap); + eulerAggregationLayer.setStrategyCap(address(0x2), cap); } function testRebalanceAfterHittingCap() public { + address[] memory strategiesToRebalance = new address[](1); + uint256 cap = 3333333333333333333333; vm.prank(manager); - aggregationLayerVault.setStrategyCap(address(eTST), cap); + eulerAggregationLayer.setStrategyCap(address(eTST), cap); uint256 amountToDeposit = 10000e18; // deposit into aggregator { - uint256 balanceBefore = aggregationLayerVault.balanceOf(user1); - uint256 totalSupplyBefore = aggregationLayerVault.totalSupply(); - uint256 totalAssetsDepositedBefore = aggregationLayerVault.totalAssetsDeposited(); + uint256 balanceBefore = eulerAggregationLayer.balanceOf(user1); + uint256 totalSupplyBefore = eulerAggregationLayer.totalSupply(); + uint256 totalAssetsDepositedBefore = eulerAggregationLayer.totalAssetsDeposited(); uint256 userAssetBalanceBefore = assetTST.balanceOf(user1); vm.startPrank(user1); - assetTST.approve(address(aggregationLayerVault), amountToDeposit); - aggregationLayerVault.deposit(amountToDeposit, user1); + assetTST.approve(address(eulerAggregationLayer), amountToDeposit); + eulerAggregationLayer.deposit(amountToDeposit, user1); vm.stopPrank(); - assertEq(aggregationLayerVault.balanceOf(user1), balanceBefore + amountToDeposit); - assertEq(aggregationLayerVault.totalSupply(), totalSupplyBefore + amountToDeposit); - assertEq(aggregationLayerVault.totalAssetsDeposited(), totalAssetsDepositedBefore + amountToDeposit); + assertEq(eulerAggregationLayer.balanceOf(user1), balanceBefore + amountToDeposit); + assertEq(eulerAggregationLayer.totalSupply(), totalSupplyBefore + amountToDeposit); + assertEq(eulerAggregationLayer.totalAssetsDeposited(), totalAssetsDepositedBefore + amountToDeposit); assertEq(assetTST.balanceOf(user1), userAssetBalanceBefore - amountToDeposit); } // rebalance into strategy vm.warp(block.timestamp + 86400); { - IAggregationLayerVault.Strategy memory strategyBefore = aggregationLayerVault.getStrategy(address(eTST)); + IEulerAggregationLayer.Strategy memory strategyBefore = eulerAggregationLayer.getStrategy(address(eTST)); - assertEq(eTST.convertToAssets(eTST.balanceOf(address(aggregationLayerVault))), strategyBefore.allocated); + assertEq(eTST.convertToAssets(eTST.balanceOf(address(eulerAggregationLayer))), strategyBefore.allocated); - uint256 expectedStrategyCash = aggregationLayerVault.totalAssetsAllocatable() - * strategyBefore.allocationPoints / aggregationLayerVault.totalAllocationPoints(); + uint256 expectedStrategyCash = eulerAggregationLayer.totalAssetsAllocatable() + * strategyBefore.allocationPoints / eulerAggregationLayer.totalAllocationPoints(); vm.prank(user1); - address[] memory strategiesToRebalance = new address[](1); strategiesToRebalance[0] = address(eTST); - rebalancer.executeRebalance(address(aggregationLayerVault), strategiesToRebalance); + rebalancer.executeRebalance(address(eulerAggregationLayer), strategiesToRebalance); - assertEq(aggregationLayerVault.totalAllocated(), expectedStrategyCash); - assertEq(eTST.convertToAssets(eTST.balanceOf(address(aggregationLayerVault))), expectedStrategyCash); + assertEq(eulerAggregationLayer.totalAllocated(), expectedStrategyCash); + assertEq(eTST.convertToAssets(eTST.balanceOf(address(eulerAggregationLayer))), expectedStrategyCash); assertEq( - (aggregationLayerVault.getStrategy(address(eTST))).allocated, + (eulerAggregationLayer.getStrategy(address(eTST))).allocated, strategyBefore.allocated + expectedStrategyCash ); } @@ -98,17 +99,16 @@ contract StrategyCapE2ETest is AggregationLayerVaultBase { vm.warp(block.timestamp + 86400); vm.startPrank(user1); - assetTST.approve(address(aggregationLayerVault), amountToDeposit); - aggregationLayerVault.deposit(amountToDeposit, user1); + assetTST.approve(address(eulerAggregationLayer), amountToDeposit); + eulerAggregationLayer.deposit(amountToDeposit, user1); - uint256 strategyAllocatedBefore = (aggregationLayerVault.getStrategy(address(eTST))).allocated; + uint256 strategyAllocatedBefore = (eulerAggregationLayer.getStrategy(address(eTST))).allocated; - address[] memory strategiesToRebalance = new address[](1); strategiesToRebalance[0] = address(eTST); - rebalancer.executeRebalance(address(aggregationLayerVault), strategiesToRebalance); + rebalancer.executeRebalance(address(eulerAggregationLayer), strategiesToRebalance); vm.stopPrank(); - assertEq(strategyAllocatedBefore, (aggregationLayerVault.getStrategy(address(eTST))).allocated); + assertEq(strategyAllocatedBefore, (eulerAggregationLayer.getStrategy(address(eTST))).allocated); } function testRebalanceWhentargetAllocationGreaterThanCap() public { @@ -116,45 +116,45 @@ contract StrategyCapE2ETest is AggregationLayerVaultBase { // deposit into aggregator { - uint256 balanceBefore = aggregationLayerVault.balanceOf(user1); - uint256 totalSupplyBefore = aggregationLayerVault.totalSupply(); - uint256 totalAssetsDepositedBefore = aggregationLayerVault.totalAssetsDeposited(); + uint256 balanceBefore = eulerAggregationLayer.balanceOf(user1); + uint256 totalSupplyBefore = eulerAggregationLayer.totalSupply(); + uint256 totalAssetsDepositedBefore = eulerAggregationLayer.totalAssetsDeposited(); uint256 userAssetBalanceBefore = assetTST.balanceOf(user1); vm.startPrank(user1); - assetTST.approve(address(aggregationLayerVault), amountToDeposit); - aggregationLayerVault.deposit(amountToDeposit, user1); + assetTST.approve(address(eulerAggregationLayer), amountToDeposit); + eulerAggregationLayer.deposit(amountToDeposit, user1); vm.stopPrank(); - assertEq(aggregationLayerVault.balanceOf(user1), balanceBefore + amountToDeposit); - assertEq(aggregationLayerVault.totalSupply(), totalSupplyBefore + amountToDeposit); - assertEq(aggregationLayerVault.totalAssetsDeposited(), totalAssetsDepositedBefore + amountToDeposit); + assertEq(eulerAggregationLayer.balanceOf(user1), balanceBefore + amountToDeposit); + assertEq(eulerAggregationLayer.totalSupply(), totalSupplyBefore + amountToDeposit); + assertEq(eulerAggregationLayer.totalAssetsDeposited(), totalAssetsDepositedBefore + amountToDeposit); assertEq(assetTST.balanceOf(user1), userAssetBalanceBefore - amountToDeposit); } // rebalance into strategy vm.warp(block.timestamp + 86400); { - IAggregationLayerVault.Strategy memory strategyBefore = aggregationLayerVault.getStrategy(address(eTST)); + IEulerAggregationLayer.Strategy memory strategyBefore = eulerAggregationLayer.getStrategy(address(eTST)); - assertEq(eTST.convertToAssets(eTST.balanceOf(address(aggregationLayerVault))), strategyBefore.allocated); + assertEq(eTST.convertToAssets(eTST.balanceOf(address(eulerAggregationLayer))), strategyBefore.allocated); - uint256 expectedStrategyCash = aggregationLayerVault.totalAssetsAllocatable() - * strategyBefore.allocationPoints / aggregationLayerVault.totalAllocationPoints(); + uint256 expectedStrategyCash = eulerAggregationLayer.totalAssetsAllocatable() + * strategyBefore.allocationPoints / eulerAggregationLayer.totalAllocationPoints(); // set cap 10% less than target allocation uint256 cap = expectedStrategyCash * 9e17 / 1e18; vm.prank(manager); - aggregationLayerVault.setStrategyCap(address(eTST), cap); + eulerAggregationLayer.setStrategyCap(address(eTST), cap); vm.prank(user1); address[] memory strategiesToRebalance = new address[](1); strategiesToRebalance[0] = address(eTST); - rebalancer.executeRebalance(address(aggregationLayerVault), strategiesToRebalance); + rebalancer.executeRebalance(address(eulerAggregationLayer), strategiesToRebalance); - assertEq(aggregationLayerVault.totalAllocated(), cap); - assertEq(eTST.convertToAssets(eTST.balanceOf(address(aggregationLayerVault))), cap); - assertEq((aggregationLayerVault.getStrategy(address(eTST))).allocated, strategyBefore.allocated + cap); + assertEq(eulerAggregationLayer.totalAllocated(), cap); + assertEq(eTST.convertToAssets(eTST.balanceOf(address(eulerAggregationLayer))), cap); + assertEq((eulerAggregationLayer.getStrategy(address(eTST))).allocated, strategyBefore.allocated + cap); } } } diff --git a/test/e2e/StrategyRewardsE2ETest.t.sol b/test/e2e/StrategyRewardsE2ETest.t.sol index 91303088..d43b89b1 100644 --- a/test/e2e/StrategyRewardsE2ETest.t.sol +++ b/test/e2e/StrategyRewardsE2ETest.t.sol @@ -2,17 +2,17 @@ pragma solidity ^0.8.0; import { - AggregationLayerVaultBase, - AggregationLayerVault, + EulerAggregationLayerBase, + EulerAggregationLayer, console2, EVault, IEVault, IRMTestDefault, TestERC20 -} from "../common/AggregationLayerVaultBase.t.sol"; +} from "../common/EulerAggregationLayerBase.t.sol"; import {TrackingRewardStreams} from "reward-streams/TrackingRewardStreams.sol"; -contract StrategyRewardsE2ETest is AggregationLayerVaultBase { +contract StrategyRewardsE2ETest is EulerAggregationLayerBase { uint256 user1InitialBalance = 100000e18; function setUp() public virtual override { @@ -26,19 +26,19 @@ contract StrategyRewardsE2ETest is AggregationLayerVaultBase { function testOptInStrategyRewards() public { vm.prank(manager); - aggregationLayerVault.optInStrategyRewards(address(eTST)); + eulerAggregationLayer.optInStrategyRewards(address(eTST)); - assertTrue(eTST.balanceForwarderEnabled(address(aggregationLayerVault))); + assertTrue(eTST.balanceForwarderEnabled(address(eulerAggregationLayer))); } function testOptOutStrategyRewards() public { vm.prank(manager); - aggregationLayerVault.optInStrategyRewards(address(eTST)); - assertTrue(eTST.balanceForwarderEnabled(address(aggregationLayerVault))); + eulerAggregationLayer.optInStrategyRewards(address(eTST)); + assertTrue(eTST.balanceForwarderEnabled(address(eulerAggregationLayer))); vm.prank(manager); - aggregationLayerVault.optOutStrategyRewards(address(eTST)); + eulerAggregationLayer.optOutStrategyRewards(address(eTST)); - assertFalse(eTST.balanceForwarderEnabled(address(aggregationLayerVault))); + assertFalse(eTST.balanceForwarderEnabled(address(eulerAggregationLayer))); } } diff --git a/test/fuzz/AdjustAllocationPointsFuzzTest.t.sol b/test/fuzz/AdjustAllocationPointsFuzzTest.t.sol index d363c4db..531d7253 100644 --- a/test/fuzz/AdjustAllocationPointsFuzzTest.t.sol +++ b/test/fuzz/AdjustAllocationPointsFuzzTest.t.sol @@ -2,12 +2,12 @@ pragma solidity ^0.8.0; import { - AggregationLayerVaultBase, - AggregationLayerVault, - IAggregationLayerVault -} from "../common/AggregationLayerVaultBase.t.sol"; + EulerAggregationLayerBase, + EulerAggregationLayer, + IEulerAggregationLayer +} from "../common/EulerAggregationLayerBase.t.sol"; -contract AdjustAllocationsPointsFuzzTest is AggregationLayerVaultBase { +contract AdjustAllocationsPointsFuzzTest is EulerAggregationLayerBase { function setUp() public virtual override { super.setUp(); @@ -18,23 +18,23 @@ contract AdjustAllocationsPointsFuzzTest is AggregationLayerVaultBase { function testFuzzAdjustAllocationPoints(uint256 _newAllocationPoints) public { _newAllocationPoints = bound(_newAllocationPoints, 0, type(uint120).max); - uint256 strategyAllocationPoints = (aggregationLayerVault.getStrategy(address(eTST))).allocationPoints; - uint256 totalAllocationPointsBefore = aggregationLayerVault.totalAllocationPoints(); + uint256 strategyAllocationPoints = (eulerAggregationLayer.getStrategy(address(eTST))).allocationPoints; + uint256 totalAllocationPointsBefore = eulerAggregationLayer.totalAllocationPoints(); uint256 withdrawalQueueLengthBefore = _getWithdrawalQueueLength(); vm.prank(manager); - aggregationLayerVault.adjustAllocationPoints(address(eTST), _newAllocationPoints); + eulerAggregationLayer.adjustAllocationPoints(address(eTST), _newAllocationPoints); - IAggregationLayerVault.Strategy memory strategy = aggregationLayerVault.getStrategy(address(eTST)); + IEulerAggregationLayer.Strategy memory strategy = eulerAggregationLayer.getStrategy(address(eTST)); if (_newAllocationPoints < strategyAllocationPoints) { assertEq( - aggregationLayerVault.totalAllocationPoints(), + eulerAggregationLayer.totalAllocationPoints(), totalAllocationPointsBefore - (strategyAllocationPoints - _newAllocationPoints) ); } else { assertEq( - aggregationLayerVault.totalAllocationPoints(), + eulerAggregationLayer.totalAllocationPoints(), totalAllocationPointsBefore + (_newAllocationPoints - strategyAllocationPoints) ); } diff --git a/test/fuzz/DepositWithdrawMintBurnFuzzTest.t.sol b/test/fuzz/DepositWithdrawMintBurnFuzzTest.t.sol index dea9b6df..fd18fcc0 100644 --- a/test/fuzz/DepositWithdrawMintBurnFuzzTest.t.sol +++ b/test/fuzz/DepositWithdrawMintBurnFuzzTest.t.sol @@ -1,9 +1,9 @@ // SPDX-License-Identifier: GPL-2.0-or-later pragma solidity ^0.8.0; -import {console2, AggregationLayerVaultBase, AggregationLayerVault} from "../common/AggregationLayerVaultBase.t.sol"; +import {console2, EulerAggregationLayerBase, EulerAggregationLayer} from "../common/EulerAggregationLayerBase.t.sol"; -contract DepositWithdrawMintBurnFuzzTest is AggregationLayerVaultBase { +contract DepositWithdrawMintBurnFuzzTest is EulerAggregationLayerBase { uint256 constant MAX_ALLOWED = type(uint256).max; function setUp() public virtual override { @@ -14,16 +14,16 @@ contract DepositWithdrawMintBurnFuzzTest is AggregationLayerVaultBase { // moch the scenario of _assets ownership assetTST.mint(user1, _assets); - uint256 balanceBefore = aggregationLayerVault.balanceOf(user1); - uint256 totalSupplyBefore = aggregationLayerVault.totalSupply(); - uint256 totalAssetsDepositedBefore = aggregationLayerVault.totalAssetsDeposited(); + uint256 balanceBefore = eulerAggregationLayer.balanceOf(user1); + uint256 totalSupplyBefore = eulerAggregationLayer.totalSupply(); + uint256 totalAssetsDepositedBefore = eulerAggregationLayer.totalAssetsDeposited(); uint256 userAssetBalanceBefore = assetTST.balanceOf(user1); _deposit(user1, _assets); - assertEq(aggregationLayerVault.balanceOf(user1), balanceBefore + _assets); - assertEq(aggregationLayerVault.totalSupply(), totalSupplyBefore + _assets); - assertEq(aggregationLayerVault.totalAssetsDeposited(), totalAssetsDepositedBefore + _assets); + assertEq(eulerAggregationLayer.balanceOf(user1), balanceBefore + _assets); + assertEq(eulerAggregationLayer.totalSupply(), totalSupplyBefore + _assets); + assertEq(eulerAggregationLayer.totalAssetsDeposited(), totalAssetsDepositedBefore + _assets); assertEq(assetTST.balanceOf(user1), userAssetBalanceBefore - _assets); } @@ -45,36 +45,36 @@ contract DepositWithdrawMintBurnFuzzTest is AggregationLayerVaultBase { vm.warp(block.timestamp + _timestampAfterDeposit); // fuzz partial & full withdraws - uint256 balanceBefore = aggregationLayerVault.balanceOf(user1); - uint256 totalSupplyBefore = aggregationLayerVault.totalSupply(); - uint256 totalAssetsDepositedBefore = aggregationLayerVault.totalAssetsDeposited(); + uint256 balanceBefore = eulerAggregationLayer.balanceOf(user1); + uint256 totalSupplyBefore = eulerAggregationLayer.totalSupply(); + uint256 totalAssetsDepositedBefore = eulerAggregationLayer.totalAssetsDeposited(); uint256 receiverAssetBalanceBefore = assetTST.balanceOf(_receiver); vm.startPrank(user1); - aggregationLayerVault.withdraw(_assetsToWithdraw, _receiver, user1); + eulerAggregationLayer.withdraw(_assetsToWithdraw, _receiver, user1); vm.stopPrank(); - assertEq(aggregationLayerVault.balanceOf(user1), balanceBefore - _assetsToWithdraw); - assertEq(aggregationLayerVault.totalSupply(), totalSupplyBefore - _assetsToWithdraw); - assertEq(aggregationLayerVault.totalAssetsDeposited(), totalAssetsDepositedBefore - _assetsToWithdraw); + assertEq(eulerAggregationLayer.balanceOf(user1), balanceBefore - _assetsToWithdraw); + assertEq(eulerAggregationLayer.totalSupply(), totalSupplyBefore - _assetsToWithdraw); + assertEq(eulerAggregationLayer.totalAssetsDeposited(), totalAssetsDepositedBefore - _assetsToWithdraw); assertEq(assetTST.balanceOf(_receiver), receiverAssetBalanceBefore + _assetsToWithdraw); } function testFuzzMint(uint256 _shares) public { // moch the scenario of _assets ownership - uint256 assets = aggregationLayerVault.previewMint(_shares); + uint256 assets = eulerAggregationLayer.previewMint(_shares); assetTST.mint(user1, assets); - uint256 balanceBefore = aggregationLayerVault.balanceOf(user1); - uint256 totalSupplyBefore = aggregationLayerVault.totalSupply(); - uint256 totalAssetsDepositedBefore = aggregationLayerVault.totalAssetsDeposited(); + uint256 balanceBefore = eulerAggregationLayer.balanceOf(user1); + uint256 totalSupplyBefore = eulerAggregationLayer.totalSupply(); + uint256 totalAssetsDepositedBefore = eulerAggregationLayer.totalAssetsDeposited(); uint256 userAssetBalanceBefore = assetTST.balanceOf(user1); _mint(user1, assets, _shares); - assertEq(aggregationLayerVault.balanceOf(user1), balanceBefore + _shares); - assertEq(aggregationLayerVault.totalSupply(), totalSupplyBefore + _shares); - assertEq(aggregationLayerVault.totalAssetsDeposited(), totalAssetsDepositedBefore + assets); + assertEq(eulerAggregationLayer.balanceOf(user1), balanceBefore + _shares); + assertEq(eulerAggregationLayer.totalSupply(), totalSupplyBefore + _shares); + assertEq(eulerAggregationLayer.totalAssetsDeposited(), totalAssetsDepositedBefore + assets); assertEq(assetTST.balanceOf(user1), userAssetBalanceBefore - assets); } @@ -91,38 +91,38 @@ contract DepositWithdrawMintBurnFuzzTest is AggregationLayerVaultBase { _timestampAfterDeposit = bound(_timestampAfterDeposit, 0, 86400); // deposit - uint256 assetsToDeposit = aggregationLayerVault.previewMint(_sharesToMint); + uint256 assetsToDeposit = eulerAggregationLayer.previewMint(_sharesToMint); assetTST.mint(user1, assetsToDeposit); _mint(user1, assetsToDeposit, _sharesToMint); vm.warp(block.timestamp + _timestampAfterDeposit); // fuzz partial & full redeem - uint256 balanceBefore = aggregationLayerVault.balanceOf(user1); - uint256 totalSupplyBefore = aggregationLayerVault.totalSupply(); - uint256 totalAssetsDepositedBefore = aggregationLayerVault.totalAssetsDeposited(); + uint256 balanceBefore = eulerAggregationLayer.balanceOf(user1); + uint256 totalSupplyBefore = eulerAggregationLayer.totalSupply(); + uint256 totalAssetsDepositedBefore = eulerAggregationLayer.totalAssetsDeposited(); uint256 receiverAssetBalanceBefore = assetTST.balanceOf(_receiver); vm.startPrank(user1); - uint256 assetsToWithdraw = aggregationLayerVault.redeem(_sharesToRedeem, _receiver, user1); + uint256 assetsToWithdraw = eulerAggregationLayer.redeem(_sharesToRedeem, _receiver, user1); vm.stopPrank(); - assertEq(aggregationLayerVault.balanceOf(user1), balanceBefore - _sharesToRedeem); - assertEq(aggregationLayerVault.totalSupply(), totalSupplyBefore - _sharesToRedeem); - assertEq(aggregationLayerVault.totalAssetsDeposited(), totalAssetsDepositedBefore - assetsToWithdraw); + assertEq(eulerAggregationLayer.balanceOf(user1), balanceBefore - _sharesToRedeem); + assertEq(eulerAggregationLayer.totalSupply(), totalSupplyBefore - _sharesToRedeem); + assertEq(eulerAggregationLayer.totalAssetsDeposited(), totalAssetsDepositedBefore - assetsToWithdraw); assertEq(assetTST.balanceOf(_receiver), receiverAssetBalanceBefore + assetsToWithdraw); } function _deposit(address _from, uint256 _assets) private { vm.startPrank(_from); - assetTST.approve(address(aggregationLayerVault), _assets); - aggregationLayerVault.deposit(_assets, _from); + assetTST.approve(address(eulerAggregationLayer), _assets); + eulerAggregationLayer.deposit(_assets, _from); vm.stopPrank(); } function _mint(address _from, uint256 _assets, uint256 _shares) private { vm.startPrank(_from); - assetTST.approve(address(aggregationLayerVault), _assets); - aggregationLayerVault.mint(_shares, _from); + assetTST.approve(address(eulerAggregationLayer), _assets); + eulerAggregationLayer.mint(_shares, _from); vm.stopPrank(); } } diff --git a/test/unit/AddStrategyTest.t.sol b/test/unit/AddStrategyTest.t.sol index 0efc9e8c..0e00a089 100644 --- a/test/unit/AddStrategyTest.t.sol +++ b/test/unit/AddStrategyTest.t.sol @@ -1,22 +1,22 @@ // SPDX-License-Identifier: GPL-2.0-or-later pragma solidity ^0.8.0; -import {AggregationLayerVaultBase, AggregationLayerVault} from "../common/AggregationLayerVaultBase.t.sol"; +import {EulerAggregationLayerBase, EulerAggregationLayer} from "../common/EulerAggregationLayerBase.t.sol"; -contract AddStrategyTest is AggregationLayerVaultBase { +contract AddStrategyTest is EulerAggregationLayerBase { function setUp() public virtual override { super.setUp(); } function testAddStrategy() public { uint256 allocationPoints = 500e18; - uint256 totalAllocationPointsBefore = aggregationLayerVault.totalAllocationPoints(); + uint256 totalAllocationPointsBefore = eulerAggregationLayer.totalAllocationPoints(); assertEq(_getWithdrawalQueueLength(), 0); _addStrategy(manager, address(eTST), allocationPoints); - assertEq(aggregationLayerVault.totalAllocationPoints(), allocationPoints + totalAllocationPointsBefore); + assertEq(eulerAggregationLayer.totalAllocationPoints(), allocationPoints + totalAllocationPointsBefore); assertEq(_getWithdrawalQueueLength(), 1); } @@ -40,13 +40,13 @@ contract AddStrategyTest is AggregationLayerVaultBase { function testAddStrategy_AlreadyAddedStrategy() public { uint256 allocationPoints = 500e18; - uint256 totalAllocationPointsBefore = aggregationLayerVault.totalAllocationPoints(); + uint256 totalAllocationPointsBefore = eulerAggregationLayer.totalAllocationPoints(); assertEq(_getWithdrawalQueueLength(), 0); _addStrategy(manager, address(eTST), allocationPoints); - assertEq(aggregationLayerVault.totalAllocationPoints(), allocationPoints + totalAllocationPointsBefore); + assertEq(eulerAggregationLayer.totalAllocationPoints(), allocationPoints + totalAllocationPointsBefore); assertEq(_getWithdrawalQueueLength(), 1); vm.expectRevert(); diff --git a/test/unit/AdjustAllocationPointsTest.t.sol b/test/unit/AdjustAllocationPointsTest.t.sol index 54824568..2b76fc00 100644 --- a/test/unit/AdjustAllocationPointsTest.t.sol +++ b/test/unit/AdjustAllocationPointsTest.t.sol @@ -2,13 +2,13 @@ pragma solidity ^0.8.0; import { - AggregationLayerVaultBase, - AggregationLayerVault, - IAggregationLayerVault, + EulerAggregationLayerBase, + EulerAggregationLayer, + IEulerAggregationLayer, ErrorsLib -} from "../common/AggregationLayerVaultBase.t.sol"; +} from "../common/EulerAggregationLayerBase.t.sol"; -contract AdjustAllocationsPointsTest is AggregationLayerVaultBase { +contract AdjustAllocationsPointsTest is EulerAggregationLayerBase { uint256 initialStrategyAllocationPoints = 500e18; function setUp() public virtual override { @@ -19,16 +19,16 @@ contract AdjustAllocationsPointsTest is AggregationLayerVaultBase { function testAdjustAllocationPoints() public { uint256 newAllocationPoints = 859e18; - uint256 totalAllocationPointsBefore = aggregationLayerVault.totalAllocationPoints(); + uint256 totalAllocationPointsBefore = eulerAggregationLayer.totalAllocationPoints(); uint256 withdrawalQueueLengthBefore = _getWithdrawalQueueLength(); vm.prank(manager); - aggregationLayerVault.adjustAllocationPoints(address(eTST), newAllocationPoints); + eulerAggregationLayer.adjustAllocationPoints(address(eTST), newAllocationPoints); - IAggregationLayerVault.Strategy memory strategy = aggregationLayerVault.getStrategy(address(eTST)); + IEulerAggregationLayer.Strategy memory strategy = eulerAggregationLayer.getStrategy(address(eTST)); assertEq( - aggregationLayerVault.totalAllocationPoints(), + eulerAggregationLayer.totalAllocationPoints(), totalAllocationPointsBefore + (newAllocationPoints - initialStrategyAllocationPoints) ); assertEq(_getWithdrawalQueueLength(), withdrawalQueueLengthBefore); @@ -40,7 +40,7 @@ contract AdjustAllocationsPointsTest is AggregationLayerVaultBase { vm.startPrank(deployer); vm.expectRevert(); - aggregationLayerVault.adjustAllocationPoints(address(eTST), newAllocationPoints); + eulerAggregationLayer.adjustAllocationPoints(address(eTST), newAllocationPoints); vm.stopPrank(); } @@ -49,7 +49,7 @@ contract AdjustAllocationsPointsTest is AggregationLayerVaultBase { vm.startPrank(manager); vm.expectRevert(ErrorsLib.InactiveStrategy.selector); - aggregationLayerVault.adjustAllocationPoints(address(eTST2), newAllocationPoints); + eulerAggregationLayer.adjustAllocationPoints(address(eTST2), newAllocationPoints); vm.stopPrank(); } } diff --git a/test/unit/GulpTest.t.sol b/test/unit/GulpTest.t.sol index 0924e0f6..40dd9f8e 100644 --- a/test/unit/GulpTest.t.sol +++ b/test/unit/GulpTest.t.sol @@ -2,14 +2,14 @@ pragma solidity ^0.8.0; import { - AggregationLayerVaultBase, - AggregationLayerVault, + EulerAggregationLayerBase, + EulerAggregationLayer, console2, EVault, - IAggregationLayerVault -} from "../common/AggregationLayerVaultBase.t.sol"; + IEulerAggregationLayer +} from "../common/EulerAggregationLayerBase.t.sol"; -contract GulpTest is AggregationLayerVaultBase { +contract GulpTest is EulerAggregationLayerBase { uint256 user1InitialBalance = 100000e18; uint256 amountToDeposit = 10000e18; @@ -23,142 +23,142 @@ contract GulpTest is AggregationLayerVaultBase { // deposit into aggregator { - uint256 balanceBefore = aggregationLayerVault.balanceOf(user1); - uint256 totalSupplyBefore = aggregationLayerVault.totalSupply(); - uint256 totalAssetsDepositedBefore = aggregationLayerVault.totalAssetsDeposited(); + uint256 balanceBefore = eulerAggregationLayer.balanceOf(user1); + uint256 totalSupplyBefore = eulerAggregationLayer.totalSupply(); + uint256 totalAssetsDepositedBefore = eulerAggregationLayer.totalAssetsDeposited(); uint256 userAssetBalanceBefore = assetTST.balanceOf(user1); vm.startPrank(user1); - assetTST.approve(address(aggregationLayerVault), amountToDeposit); - aggregationLayerVault.deposit(amountToDeposit, user1); + assetTST.approve(address(eulerAggregationLayer), amountToDeposit); + eulerAggregationLayer.deposit(amountToDeposit, user1); vm.stopPrank(); - assertEq(aggregationLayerVault.balanceOf(user1), balanceBefore + amountToDeposit); - assertEq(aggregationLayerVault.totalSupply(), totalSupplyBefore + amountToDeposit); - assertEq(aggregationLayerVault.totalAssetsDeposited(), totalAssetsDepositedBefore + amountToDeposit); + assertEq(eulerAggregationLayer.balanceOf(user1), balanceBefore + amountToDeposit); + assertEq(eulerAggregationLayer.totalSupply(), totalSupplyBefore + amountToDeposit); + assertEq(eulerAggregationLayer.totalAssetsDeposited(), totalAssetsDepositedBefore + amountToDeposit); assertEq(assetTST.balanceOf(user1), userAssetBalanceBefore - amountToDeposit); } // rebalance into strategy vm.warp(block.timestamp + 86400); { - IAggregationLayerVault.Strategy memory strategyBefore = aggregationLayerVault.getStrategy(address(eTST)); + IEulerAggregationLayer.Strategy memory strategyBefore = eulerAggregationLayer.getStrategy(address(eTST)); - assertEq(eTST.convertToAssets(eTST.balanceOf(address(aggregationLayerVault))), strategyBefore.allocated); + assertEq(eTST.convertToAssets(eTST.balanceOf(address(eulerAggregationLayer))), strategyBefore.allocated); - uint256 expectedStrategyCash = aggregationLayerVault.totalAssetsAllocatable() - * strategyBefore.allocationPoints / aggregationLayerVault.totalAllocationPoints(); + uint256 expectedStrategyCash = eulerAggregationLayer.totalAssetsAllocatable() + * strategyBefore.allocationPoints / eulerAggregationLayer.totalAllocationPoints(); vm.prank(user1); address[] memory strategiesToRebalance = new address[](1); strategiesToRebalance[0] = address(eTST); - rebalancer.executeRebalance(address(aggregationLayerVault), strategiesToRebalance); + rebalancer.executeRebalance(address(eulerAggregationLayer), strategiesToRebalance); - assertEq(aggregationLayerVault.totalAllocated(), expectedStrategyCash); - assertEq(eTST.convertToAssets(eTST.balanceOf(address(aggregationLayerVault))), expectedStrategyCash); - assertEq((aggregationLayerVault.getStrategy(address(eTST))).allocated, expectedStrategyCash); + assertEq(eulerAggregationLayer.totalAllocated(), expectedStrategyCash); + assertEq(eTST.convertToAssets(eTST.balanceOf(address(eulerAggregationLayer))), expectedStrategyCash); + assertEq((eulerAggregationLayer.getStrategy(address(eTST))).allocated, expectedStrategyCash); } } function testGulpAfterNegativeYieldEqualToInterestLeft() public { - aggregationLayerVault.gulp(); - AggregationLayerVault.AggregationVaultSavingRate memory ers = - aggregationLayerVault.getAggregationVaultSavingRate(); - assertEq(aggregationLayerVault.interestAccrued(), 0); + eulerAggregationLayer.gulp(); + EulerAggregationLayer.AggregationVaultSavingRate memory ers = + eulerAggregationLayer.getAggregationVaultSavingRate(); + assertEq(eulerAggregationLayer.interestAccrued(), 0); assertEq(ers.interestLeft, 0); vm.warp(block.timestamp + 2 days); - aggregationLayerVault.gulp(); - assertEq(aggregationLayerVault.interestAccrued(), 0); + eulerAggregationLayer.gulp(); + assertEq(eulerAggregationLayer.interestAccrued(), 0); vm.warp(block.timestamp + 1 days); - assertEq(aggregationLayerVault.interestAccrued(), 0); + assertEq(eulerAggregationLayer.interestAccrued(), 0); uint256 yield; { - uint256 aggrCurrentStrategyShareBalance = eTST.balanceOf(address(aggregationLayerVault)); + uint256 aggrCurrentStrategyShareBalance = eTST.balanceOf(address(eulerAggregationLayer)); uint256 aggrCurrentStrategyUnderlyingBalance = eTST.convertToAssets(aggrCurrentStrategyShareBalance); uint256 aggrNewStrategyUnderlyingBalance = aggrCurrentStrategyUnderlyingBalance * 11e17 / 1e18; yield = aggrNewStrategyUnderlyingBalance - aggrCurrentStrategyUnderlyingBalance; assetTST.mint(address(eTST), yield); - eTST.skim(type(uint256).max, address(aggregationLayerVault)); + eTST.skim(type(uint256).max, address(eulerAggregationLayer)); } vm.prank(user1); - aggregationLayerVault.harvest(); + eulerAggregationLayer.harvest(); - assertEq(aggregationLayerVault.interestAccrued(), 0); + assertEq(eulerAggregationLayer.interestAccrued(), 0); vm.warp(block.timestamp + 1 days); // interest per day 23.809523809523 - assertEq(aggregationLayerVault.interestAccrued(), 23809523809523809523); - aggregationLayerVault.gulp(); - ers = aggregationLayerVault.getAggregationVaultSavingRate(); + assertEq(eulerAggregationLayer.interestAccrued(), 23809523809523809523); + eulerAggregationLayer.gulp(); + ers = eulerAggregationLayer.getAggregationVaultSavingRate(); assertEq(ers.interestLeft, yield - 23809523809523809523); // move close to end of smearing vm.warp(block.timestamp + 11 days); - aggregationLayerVault.gulp(); - ers = aggregationLayerVault.getAggregationVaultSavingRate(); + eulerAggregationLayer.gulp(); + ers = eulerAggregationLayer.getAggregationVaultSavingRate(); // mock a decrease of strategy balance by ers.interestLeft - uint256 aggrCurrentStrategyBalance = eTST.balanceOf(address(aggregationLayerVault)); + uint256 aggrCurrentStrategyBalance = eTST.balanceOf(address(eulerAggregationLayer)); uint256 aggrCurrentStrategyBalanceAfterNegYield = aggrCurrentStrategyBalance - ers.interestLeft; vm.mockCall( address(eTST), - abi.encodeWithSelector(EVault.balanceOf.selector, address(aggregationLayerVault)), + abi.encodeWithSelector(EVault.balanceOf.selector, address(eulerAggregationLayer)), abi.encode(aggrCurrentStrategyBalanceAfterNegYield) ); vm.prank(user1); - aggregationLayerVault.harvest(); + eulerAggregationLayer.harvest(); } function testGulpAfterNegativeYieldBiggerThanInterestLeft() public { - aggregationLayerVault.gulp(); - AggregationLayerVault.AggregationVaultSavingRate memory ers = - aggregationLayerVault.getAggregationVaultSavingRate(); - assertEq(aggregationLayerVault.interestAccrued(), 0); + eulerAggregationLayer.gulp(); + EulerAggregationLayer.AggregationVaultSavingRate memory ers = + eulerAggregationLayer.getAggregationVaultSavingRate(); + assertEq(eulerAggregationLayer.interestAccrued(), 0); assertEq(ers.interestLeft, 0); vm.warp(block.timestamp + 2 days); - aggregationLayerVault.gulp(); - assertEq(aggregationLayerVault.interestAccrued(), 0); + eulerAggregationLayer.gulp(); + assertEq(eulerAggregationLayer.interestAccrued(), 0); vm.warp(block.timestamp + 1 days); - assertEq(aggregationLayerVault.interestAccrued(), 0); + assertEq(eulerAggregationLayer.interestAccrued(), 0); uint256 yield; { - uint256 aggrCurrentStrategyShareBalance = eTST.balanceOf(address(aggregationLayerVault)); + uint256 aggrCurrentStrategyShareBalance = eTST.balanceOf(address(eulerAggregationLayer)); uint256 aggrCurrentStrategyUnderlyingBalance = eTST.convertToAssets(aggrCurrentStrategyShareBalance); uint256 aggrNewStrategyUnderlyingBalance = aggrCurrentStrategyUnderlyingBalance * 11e17 / 1e18; yield = aggrNewStrategyUnderlyingBalance - aggrCurrentStrategyUnderlyingBalance; assetTST.mint(address(eTST), yield); - eTST.skim(type(uint256).max, address(aggregationLayerVault)); + eTST.skim(type(uint256).max, address(eulerAggregationLayer)); } vm.prank(user1); - aggregationLayerVault.harvest(); + eulerAggregationLayer.harvest(); - assertEq(aggregationLayerVault.interestAccrued(), 0); + assertEq(eulerAggregationLayer.interestAccrued(), 0); vm.warp(block.timestamp + 1 days); // interest per day 23.809523809523 - assertEq(aggregationLayerVault.interestAccrued(), 23809523809523809523); - aggregationLayerVault.gulp(); - ers = aggregationLayerVault.getAggregationVaultSavingRate(); + assertEq(eulerAggregationLayer.interestAccrued(), 23809523809523809523); + eulerAggregationLayer.gulp(); + ers = eulerAggregationLayer.getAggregationVaultSavingRate(); assertEq(ers.interestLeft, yield - 23809523809523809523); // move close to end of smearing vm.warp(block.timestamp + 11 days); - aggregationLayerVault.gulp(); - ers = aggregationLayerVault.getAggregationVaultSavingRate(); + eulerAggregationLayer.gulp(); + ers = eulerAggregationLayer.getAggregationVaultSavingRate(); // mock a decrease of strategy balance by ers.interestLeft - uint256 aggrCurrentStrategyBalance = eTST.balanceOf(address(aggregationLayerVault)); + uint256 aggrCurrentStrategyBalance = eTST.balanceOf(address(eulerAggregationLayer)); uint256 aggrCurrentStrategyBalanceAfterNegYield = aggrCurrentStrategyBalance - (ers.interestLeft * 2); vm.mockCall( address(eTST), - abi.encodeWithSelector(EVault.balanceOf.selector, address(aggregationLayerVault)), + abi.encodeWithSelector(EVault.balanceOf.selector, address(eulerAggregationLayer)), abi.encode(aggrCurrentStrategyBalanceAfterNegYield) ); vm.prank(user1); - aggregationLayerVault.harvest(); + eulerAggregationLayer.harvest(); } } diff --git a/test/unit/HarvestTest.t.sol b/test/unit/HarvestTest.t.sol index 34803cab..2a864a23 100644 --- a/test/unit/HarvestTest.t.sol +++ b/test/unit/HarvestTest.t.sol @@ -2,14 +2,14 @@ pragma solidity ^0.8.0; import { - AggregationLayerVaultBase, - AggregationLayerVault, + EulerAggregationLayerBase, + EulerAggregationLayer, console2, EVault, - IAggregationLayerVault -} from "../common/AggregationLayerVaultBase.t.sol"; + IEulerAggregationLayer +} from "../common/EulerAggregationLayerBase.t.sol"; -contract HarvestTest is AggregationLayerVaultBase { +contract HarvestTest is EulerAggregationLayerBase { uint256 user1InitialBalance = 100000e18; uint256 amountToDeposit = 10000e18; @@ -23,74 +23,74 @@ contract HarvestTest is AggregationLayerVaultBase { // deposit into aggregator { - uint256 balanceBefore = aggregationLayerVault.balanceOf(user1); - uint256 totalSupplyBefore = aggregationLayerVault.totalSupply(); - uint256 totalAssetsDepositedBefore = aggregationLayerVault.totalAssetsDeposited(); + uint256 balanceBefore = eulerAggregationLayer.balanceOf(user1); + uint256 totalSupplyBefore = eulerAggregationLayer.totalSupply(); + uint256 totalAssetsDepositedBefore = eulerAggregationLayer.totalAssetsDeposited(); uint256 userAssetBalanceBefore = assetTST.balanceOf(user1); vm.startPrank(user1); - assetTST.approve(address(aggregationLayerVault), amountToDeposit); - aggregationLayerVault.deposit(amountToDeposit, user1); + assetTST.approve(address(eulerAggregationLayer), amountToDeposit); + eulerAggregationLayer.deposit(amountToDeposit, user1); vm.stopPrank(); - assertEq(aggregationLayerVault.balanceOf(user1), balanceBefore + amountToDeposit); - assertEq(aggregationLayerVault.totalSupply(), totalSupplyBefore + amountToDeposit); - assertEq(aggregationLayerVault.totalAssetsDeposited(), totalAssetsDepositedBefore + amountToDeposit); + assertEq(eulerAggregationLayer.balanceOf(user1), balanceBefore + amountToDeposit); + assertEq(eulerAggregationLayer.totalSupply(), totalSupplyBefore + amountToDeposit); + assertEq(eulerAggregationLayer.totalAssetsDeposited(), totalAssetsDepositedBefore + amountToDeposit); assertEq(assetTST.balanceOf(user1), userAssetBalanceBefore - amountToDeposit); } // rebalance into strategy vm.warp(block.timestamp + 86400); { - IAggregationLayerVault.Strategy memory strategyBefore = aggregationLayerVault.getStrategy(address(eTST)); + IEulerAggregationLayer.Strategy memory strategyBefore = eulerAggregationLayer.getStrategy(address(eTST)); - assertEq(eTST.convertToAssets(eTST.balanceOf(address(aggregationLayerVault))), strategyBefore.allocated); + assertEq(eTST.convertToAssets(eTST.balanceOf(address(eulerAggregationLayer))), strategyBefore.allocated); - uint256 expectedStrategyCash = aggregationLayerVault.totalAssetsAllocatable() - * strategyBefore.allocationPoints / aggregationLayerVault.totalAllocationPoints(); + uint256 expectedStrategyCash = eulerAggregationLayer.totalAssetsAllocatable() + * strategyBefore.allocationPoints / eulerAggregationLayer.totalAllocationPoints(); vm.prank(user1); address[] memory strategiesToRebalance = new address[](1); strategiesToRebalance[0] = address(eTST); - rebalancer.executeRebalance(address(aggregationLayerVault), strategiesToRebalance); + rebalancer.executeRebalance(address(eulerAggregationLayer), strategiesToRebalance); - assertEq(aggregationLayerVault.totalAllocated(), expectedStrategyCash); - assertEq(eTST.convertToAssets(eTST.balanceOf(address(aggregationLayerVault))), expectedStrategyCash); - assertEq((aggregationLayerVault.getStrategy(address(eTST))).allocated, expectedStrategyCash); + assertEq(eulerAggregationLayer.totalAllocated(), expectedStrategyCash); + assertEq(eTST.convertToAssets(eTST.balanceOf(address(eulerAggregationLayer))), expectedStrategyCash); + assertEq((eulerAggregationLayer.getStrategy(address(eTST))).allocated, expectedStrategyCash); } } function testHarvestWithPositiveYield() public { // no yield increase - IAggregationLayerVault.Strategy memory strategyBefore = aggregationLayerVault.getStrategy(address(eTST)); - uint256 totalAllocatedBefore = aggregationLayerVault.totalAllocated(); + IEulerAggregationLayer.Strategy memory strategyBefore = eulerAggregationLayer.getStrategy(address(eTST)); + uint256 totalAllocatedBefore = eulerAggregationLayer.totalAllocated(); - assertTrue(eTST.convertToAssets(eTST.balanceOf(address(aggregationLayerVault))) == strategyBefore.allocated); + assertTrue(eTST.convertToAssets(eTST.balanceOf(address(eulerAggregationLayer))) == strategyBefore.allocated); vm.prank(user1); - aggregationLayerVault.harvest(); + eulerAggregationLayer.harvest(); - assertEq((aggregationLayerVault.getStrategy(address(eTST))).allocated, strategyBefore.allocated); - assertEq(aggregationLayerVault.totalAllocated(), totalAllocatedBefore); + assertEq((eulerAggregationLayer.getStrategy(address(eTST))).allocated, strategyBefore.allocated); + assertEq(eulerAggregationLayer.totalAllocated(), totalAllocatedBefore); vm.warp(block.timestamp + 86400); // mock an increase of strategy balance by 10% - uint256 aggrCurrentStrategyBalance = eTST.balanceOf(address(aggregationLayerVault)); + uint256 aggrCurrentStrategyBalance = eTST.balanceOf(address(eulerAggregationLayer)); vm.mockCall( address(eTST), - abi.encodeWithSelector(EVault.maxWithdraw.selector, address(aggregationLayerVault)), + abi.encodeWithSelector(EVault.maxWithdraw.selector, address(eulerAggregationLayer)), abi.encode(aggrCurrentStrategyBalance * 11e17 / 1e18) ); - uint256 expectedAllocated = eTST.maxWithdraw(address(aggregationLayerVault)); + uint256 expectedAllocated = eTST.maxWithdraw(address(eulerAggregationLayer)); assertTrue(expectedAllocated > strategyBefore.allocated); vm.prank(user1); - aggregationLayerVault.harvest(); + eulerAggregationLayer.harvest(); - assertEq((aggregationLayerVault.getStrategy(address(eTST))).allocated, expectedAllocated); + assertEq((eulerAggregationLayer.getStrategy(address(eTST))).allocated, expectedAllocated); assertEq( - aggregationLayerVault.totalAllocated(), + eulerAggregationLayer.totalAllocated(), totalAllocatedBefore + (expectedAllocated - strategyBefore.allocated) ); } @@ -99,58 +99,57 @@ contract HarvestTest is AggregationLayerVaultBase { vm.warp(block.timestamp + 86400); // mock a decrease of strategy balance by 10% - uint256 aggrCurrentStrategyBalance = eTST.balanceOf(address(aggregationLayerVault)); + uint256 aggrCurrentStrategyBalance = eTST.balanceOf(address(eulerAggregationLayer)); vm.mockCall( address(eTST), - abi.encodeWithSelector(EVault.maxWithdraw.selector, address(aggregationLayerVault)), + abi.encodeWithSelector(EVault.maxWithdraw.selector, address(eulerAggregationLayer)), abi.encode(aggrCurrentStrategyBalance * 9e17 / 1e18) ); - IAggregationLayerVault.Strategy memory strategyBefore = aggregationLayerVault.getStrategy(address(eTST)); + IEulerAggregationLayer.Strategy memory strategyBefore = eulerAggregationLayer.getStrategy(address(eTST)); - uint256 expectedAllocated = eTST.maxWithdraw(address(aggregationLayerVault)); + uint256 expectedAllocated = eTST.maxWithdraw(address(eulerAggregationLayer)); assertTrue(expectedAllocated < strategyBefore.allocated); uint256 expectedLoss = strategyBefore.allocated - expectedAllocated; - uint256 totalAssetsDepositedBefore = aggregationLayerVault.totalAssetsDeposited(); + uint256 totalAssetsDepositedBefore = eulerAggregationLayer.totalAssetsDeposited(); vm.prank(user1); - aggregationLayerVault.harvest(); + eulerAggregationLayer.harvest(); // check that loss socialized from the deposits - assertEq(aggregationLayerVault.totalAssetsDeposited(), totalAssetsDepositedBefore - expectedLoss); + assertEq(eulerAggregationLayer.totalAssetsDeposited(), totalAssetsDepositedBefore - expectedLoss); } function testHarvestNegativeYieldSingleUser() public { vm.warp(block.timestamp + 86400); // mock a decrease of strategy balance by 10% - uint256 aggrCurrentStrategyBalance = eTST.balanceOf(address(aggregationLayerVault)); + uint256 aggrCurrentStrategyBalance = eTST.balanceOf(address(eulerAggregationLayer)); uint256 aggrCurrentStrategyBalanceAfterNegYield = aggrCurrentStrategyBalance * 9e17 / 1e18; vm.mockCall( address(eTST), - abi.encodeWithSelector(EVault.maxWithdraw.selector, address(aggregationLayerVault)), + abi.encodeWithSelector(EVault.maxWithdraw.selector, address(eulerAggregationLayer)), abi.encode(aggrCurrentStrategyBalanceAfterNegYield) ); - uint256 expectedAllocated = eTST.maxWithdraw(address(aggregationLayerVault)); - IAggregationLayerVault.Strategy memory strategyBefore = aggregationLayerVault.getStrategy(address(eTST)); + uint256 expectedAllocated = eTST.maxWithdraw(address(eulerAggregationLayer)); + IEulerAggregationLayer.Strategy memory strategyBefore = eulerAggregationLayer.getStrategy(address(eTST)); assertTrue(expectedAllocated < strategyBefore.allocated); - uint256 negativeYield = strategyBefore.allocated - eTST.maxWithdraw(address(aggregationLayerVault)); + uint256 negativeYield = strategyBefore.allocated - eTST.maxWithdraw(address(eulerAggregationLayer)); - uint256 user1SharesBefore = aggregationLayerVault.balanceOf(user1); - uint256 user1SocializedLoss = user1SharesBefore * negativeYield / aggregationLayerVault.totalSupply(); + uint256 user1SharesBefore = eulerAggregationLayer.balanceOf(user1); + uint256 user1SocializedLoss = user1SharesBefore * negativeYield / eulerAggregationLayer.totalSupply(); uint256 expectedUser1Assets = - user1SharesBefore * amountToDeposit / aggregationLayerVault.totalSupply() - user1SocializedLoss; - uint256 user1AssetTSTBalanceBefore = assetTST.balanceOf(user1); + user1SharesBefore * amountToDeposit / eulerAggregationLayer.totalSupply() - user1SocializedLoss; vm.startPrank(user1); - aggregationLayerVault.harvest(); + eulerAggregationLayer.harvest(); vm.stopPrank(); - uint256 user1SharesAfter = aggregationLayerVault.balanceOf(user1); - uint256 user1AssetsAfter = aggregationLayerVault.convertToAssets(user1SharesAfter); + uint256 user1SharesAfter = eulerAggregationLayer.balanceOf(user1); + uint256 user1AssetsAfter = eulerAggregationLayer.convertToAssets(user1SharesAfter); assertApproxEqAbs(user1AssetsAfter, expectedUser1Assets, 1); } @@ -161,71 +160,71 @@ contract HarvestTest is AggregationLayerVaultBase { // deposit into aggregator { vm.startPrank(user2); - assetTST.approve(address(aggregationLayerVault), user2InitialBalance); - aggregationLayerVault.deposit(user2InitialBalance, user2); + assetTST.approve(address(eulerAggregationLayer), user2InitialBalance); + eulerAggregationLayer.deposit(user2InitialBalance, user2); vm.stopPrank(); } vm.warp(block.timestamp + 86400); // mock a decrease of strategy balance by 10% - uint256 aggrCurrentStrategyBalance = eTST.balanceOf(address(aggregationLayerVault)); + uint256 aggrCurrentStrategyBalance = eTST.balanceOf(address(eulerAggregationLayer)); uint256 aggrCurrentStrategyBalanceAfterNegYield = aggrCurrentStrategyBalance * 9e17 / 1e18; vm.mockCall( address(eTST), - abi.encodeWithSelector(EVault.maxWithdraw.selector, address(aggregationLayerVault)), + abi.encodeWithSelector(EVault.maxWithdraw.selector, address(eulerAggregationLayer)), abi.encode(aggrCurrentStrategyBalanceAfterNegYield) ); - IAggregationLayerVault.Strategy memory strategyBefore = aggregationLayerVault.getStrategy(address(eTST)); - uint256 expectedAllocated = eTST.maxWithdraw(address(aggregationLayerVault)); + IEulerAggregationLayer.Strategy memory strategyBefore = eulerAggregationLayer.getStrategy(address(eTST)); + uint256 expectedAllocated = eTST.maxWithdraw(address(eulerAggregationLayer)); assertTrue(expectedAllocated < strategyBefore.allocated); - uint256 negativeYield = strategyBefore.allocated - eTST.maxWithdraw(address(aggregationLayerVault)); - uint256 user1SharesBefore = aggregationLayerVault.balanceOf(user1); - uint256 user1SocializedLoss = user1SharesBefore * negativeYield / aggregationLayerVault.totalSupply(); - uint256 user2SharesBefore = aggregationLayerVault.balanceOf(user2); - uint256 user2SocializedLoss = user2SharesBefore * negativeYield / aggregationLayerVault.totalSupply(); + uint256 negativeYield = strategyBefore.allocated - eTST.maxWithdraw(address(eulerAggregationLayer)); + uint256 user1SharesBefore = eulerAggregationLayer.balanceOf(user1); + uint256 user1SocializedLoss = user1SharesBefore * negativeYield / eulerAggregationLayer.totalSupply(); + uint256 user2SharesBefore = eulerAggregationLayer.balanceOf(user2); + uint256 user2SocializedLoss = user2SharesBefore * negativeYield / eulerAggregationLayer.totalSupply(); uint256 expectedUser1Assets = user1SharesBefore * (amountToDeposit + user2InitialBalance) - / aggregationLayerVault.totalSupply() - user1SocializedLoss; + / eulerAggregationLayer.totalSupply() - user1SocializedLoss; uint256 expectedUser2Assets = user2SharesBefore * (amountToDeposit + user2InitialBalance) - / aggregationLayerVault.totalSupply() - user2SocializedLoss; + / eulerAggregationLayer.totalSupply() - user2SocializedLoss; vm.prank(user1); - aggregationLayerVault.harvest(); + eulerAggregationLayer.harvest(); - uint256 user1SharesAfter = aggregationLayerVault.balanceOf(user1); - uint256 user1AssetsAfter = aggregationLayerVault.convertToAssets(user1SharesAfter); - uint256 user2SharesAfter = aggregationLayerVault.balanceOf(user2); - uint256 user2AssetsAfter = aggregationLayerVault.convertToAssets(user2SharesAfter); + uint256 user1SharesAfter = eulerAggregationLayer.balanceOf(user1); + uint256 user1AssetsAfter = eulerAggregationLayer.convertToAssets(user1SharesAfter); + uint256 user2SharesAfter = eulerAggregationLayer.balanceOf(user2); + uint256 user2AssetsAfter = eulerAggregationLayer.convertToAssets(user2SharesAfter); assertApproxEqAbs(user1AssetsAfter, expectedUser1Assets, 1); assertApproxEqAbs(user2AssetsAfter, expectedUser2Assets, 1); } function testHarvestWhenInteresetLeftGreaterThanLoss() public { - IAggregationLayerVault.Strategy memory strategyBefore = aggregationLayerVault.getStrategy(address(eTST)); - uint256 totalAllocatedBefore = aggregationLayerVault.totalAllocated(); + IEulerAggregationLayer.Strategy memory strategyBefore = eulerAggregationLayer.getStrategy(address(eTST)); + uint256 totalAllocatedBefore = eulerAggregationLayer.totalAllocated(); vm.warp(block.timestamp + 86400); // mock an increase of strategy balance by 10% - uint256 aggrCurrentStrategyBalance = eTST.balanceOf(address(aggregationLayerVault)); + uint256 aggrCurrentStrategyBalance = eTST.balanceOf(address(eulerAggregationLayer)); vm.mockCall( address(eTST), - abi.encodeWithSelector(EVault.maxWithdraw.selector, address(aggregationLayerVault)), + abi.encodeWithSelector(EVault.maxWithdraw.selector, address(eulerAggregationLayer)), abi.encode(aggrCurrentStrategyBalance * 11e17 / 1e18) ); - uint256 expectedAllocated = eTST.maxWithdraw(address(aggregationLayerVault)); + uint256 expectedAllocated = eTST.maxWithdraw(address(eulerAggregationLayer)); assertTrue(expectedAllocated > strategyBefore.allocated); vm.prank(user1); - aggregationLayerVault.harvest(); + eulerAggregationLayer.harvest(); - assertEq((aggregationLayerVault.getStrategy(address(eTST))).allocated, expectedAllocated); + assertEq((eulerAggregationLayer.getStrategy(address(eTST))).allocated, expectedAllocated); assertEq( - aggregationLayerVault.totalAllocated(), + eulerAggregationLayer.totalAllocated(), totalAllocatedBefore + (expectedAllocated - strategyBefore.allocated) ); @@ -235,27 +234,27 @@ contract HarvestTest is AggregationLayerVaultBase { uint256 aggrCurrentStrategyBalanceAfterNegYield = expectedAllocated * 98e16 / 1e18; vm.mockCall( address(eTST), - abi.encodeWithSelector(EVault.maxWithdraw.selector, address(aggregationLayerVault)), + abi.encodeWithSelector(EVault.maxWithdraw.selector, address(eulerAggregationLayer)), abi.encode(aggrCurrentStrategyBalanceAfterNegYield) ); - strategyBefore = aggregationLayerVault.getStrategy(address(eTST)); - expectedAllocated = eTST.maxWithdraw(address(aggregationLayerVault)); + strategyBefore = eulerAggregationLayer.getStrategy(address(eTST)); + expectedAllocated = eTST.maxWithdraw(address(eulerAggregationLayer)); assertTrue(expectedAllocated < strategyBefore.allocated); - uint256 user1SharesBefore = aggregationLayerVault.balanceOf(user1); - uint256 expectedUser1Assets = user1SharesBefore * amountToDeposit / aggregationLayerVault.totalSupply(); - uint256 totalAssetsDepositedBefore = aggregationLayerVault.totalAssetsDeposited(); - uint256 interestToBeAccrued = aggregationLayerVault.interestAccrued(); + uint256 user1SharesBefore = eulerAggregationLayer.balanceOf(user1); + uint256 expectedUser1Assets = user1SharesBefore * amountToDeposit / eulerAggregationLayer.totalSupply(); + uint256 totalAssetsDepositedBefore = eulerAggregationLayer.totalAssetsDeposited(); + uint256 interestToBeAccrued = eulerAggregationLayer.interestAccrued(); vm.startPrank(user1); - aggregationLayerVault.harvest(); + eulerAggregationLayer.harvest(); vm.stopPrank(); - uint256 user1SharesAfter = aggregationLayerVault.balanceOf(user1); - uint256 user1AssetsAfter = aggregationLayerVault.convertToAssets(user1SharesAfter); + uint256 user1SharesAfter = eulerAggregationLayer.balanceOf(user1); + uint256 user1AssetsAfter = eulerAggregationLayer.convertToAssets(user1SharesAfter); assertApproxEqAbs(user1AssetsAfter, expectedUser1Assets + interestToBeAccrued, 1); - assertEq(aggregationLayerVault.totalAssetsDeposited(), totalAssetsDepositedBefore + interestToBeAccrued); + assertEq(eulerAggregationLayer.totalAssetsDeposited(), totalAssetsDepositedBefore + interestToBeAccrued); } } diff --git a/test/unit/RebalanceTest.t.sol b/test/unit/RebalanceTest.t.sol index 4abbfe55..4f7cb421 100644 --- a/test/unit/RebalanceTest.t.sol +++ b/test/unit/RebalanceTest.t.sol @@ -2,17 +2,17 @@ pragma solidity ^0.8.0; import { - AggregationLayerVaultBase, - AggregationLayerVault, + EulerAggregationLayerBase, + EulerAggregationLayer, console2, EVault, IEVault, IRMTestDefault, TestERC20, - IAggregationLayerVault -} from "../common/AggregationLayerVaultBase.t.sol"; + IEulerAggregationLayer +} from "../common/EulerAggregationLayerBase.t.sol"; -contract RebalanceTest is AggregationLayerVaultBase { +contract RebalanceTest is EulerAggregationLayerBase { uint256 user1InitialBalance = 100000e18; function setUp() public virtual override { @@ -29,40 +29,40 @@ contract RebalanceTest is AggregationLayerVaultBase { // deposit into aggregator { - uint256 balanceBefore = aggregationLayerVault.balanceOf(user1); - uint256 totalSupplyBefore = aggregationLayerVault.totalSupply(); - uint256 totalAssetsDepositedBefore = aggregationLayerVault.totalAssetsDeposited(); + uint256 balanceBefore = eulerAggregationLayer.balanceOf(user1); + uint256 totalSupplyBefore = eulerAggregationLayer.totalSupply(); + uint256 totalAssetsDepositedBefore = eulerAggregationLayer.totalAssetsDeposited(); uint256 userAssetBalanceBefore = assetTST.balanceOf(user1); vm.startPrank(user1); - assetTST.approve(address(aggregationLayerVault), amountToDeposit); - aggregationLayerVault.deposit(amountToDeposit, user1); + assetTST.approve(address(eulerAggregationLayer), amountToDeposit); + eulerAggregationLayer.deposit(amountToDeposit, user1); vm.stopPrank(); - assertEq(aggregationLayerVault.balanceOf(user1), balanceBefore + amountToDeposit); - assertEq(aggregationLayerVault.totalSupply(), totalSupplyBefore + amountToDeposit); - assertEq(aggregationLayerVault.totalAssetsDeposited(), totalAssetsDepositedBefore + amountToDeposit); + assertEq(eulerAggregationLayer.balanceOf(user1), balanceBefore + amountToDeposit); + assertEq(eulerAggregationLayer.totalSupply(), totalSupplyBefore + amountToDeposit); + assertEq(eulerAggregationLayer.totalAssetsDeposited(), totalAssetsDepositedBefore + amountToDeposit); assertEq(assetTST.balanceOf(user1), userAssetBalanceBefore - amountToDeposit); } // rebalance into strategy vm.warp(block.timestamp + 86400); - IAggregationLayerVault.Strategy memory strategyBefore = aggregationLayerVault.getStrategy(address(eTST)); + IEulerAggregationLayer.Strategy memory strategyBefore = eulerAggregationLayer.getStrategy(address(eTST)); - assertEq(eTST.convertToAssets(eTST.balanceOf(address(aggregationLayerVault))), strategyBefore.allocated); + assertEq(eTST.convertToAssets(eTST.balanceOf(address(eulerAggregationLayer))), strategyBefore.allocated); - uint256 expectedStrategyCash = aggregationLayerVault.totalAssetsAllocatable() * strategyBefore.allocationPoints - / aggregationLayerVault.totalAllocationPoints(); + uint256 expectedStrategyCash = eulerAggregationLayer.totalAssetsAllocatable() * strategyBefore.allocationPoints + / eulerAggregationLayer.totalAllocationPoints(); vm.prank(user1); address[] memory strategiesToRebalance = new address[](1); strategiesToRebalance[0] = address(eTST); - rebalancer.executeRebalance(address(aggregationLayerVault), strategiesToRebalance); + rebalancer.executeRebalance(address(eulerAggregationLayer), strategiesToRebalance); - assertEq(aggregationLayerVault.totalAllocated(), expectedStrategyCash); - assertEq(eTST.convertToAssets(eTST.balanceOf(address(aggregationLayerVault))), expectedStrategyCash); + assertEq(eulerAggregationLayer.totalAllocated(), expectedStrategyCash); + assertEq(eTST.convertToAssets(eTST.balanceOf(address(eulerAggregationLayer))), expectedStrategyCash); assertEq( - (aggregationLayerVault.getStrategy(address(eTST))).allocated, + (eulerAggregationLayer.getStrategy(address(eTST))).allocated, strategyBefore.allocated + expectedStrategyCash ); } @@ -72,76 +72,76 @@ contract RebalanceTest is AggregationLayerVaultBase { // deposit into aggregator { - uint256 balanceBefore = aggregationLayerVault.balanceOf(user1); - uint256 totalSupplyBefore = aggregationLayerVault.totalSupply(); - uint256 totalAssetsDepositedBefore = aggregationLayerVault.totalAssetsDeposited(); + uint256 balanceBefore = eulerAggregationLayer.balanceOf(user1); + uint256 totalSupplyBefore = eulerAggregationLayer.totalSupply(); + uint256 totalAssetsDepositedBefore = eulerAggregationLayer.totalAssetsDeposited(); uint256 userAssetBalanceBefore = assetTST.balanceOf(user1); vm.startPrank(user1); - assetTST.approve(address(aggregationLayerVault), amountToDeposit); - aggregationLayerVault.deposit(amountToDeposit, user1); + assetTST.approve(address(eulerAggregationLayer), amountToDeposit); + eulerAggregationLayer.deposit(amountToDeposit, user1); vm.stopPrank(); - assertEq(aggregationLayerVault.balanceOf(user1), balanceBefore + amountToDeposit); - assertEq(aggregationLayerVault.totalSupply(), totalSupplyBefore + amountToDeposit); - assertEq(aggregationLayerVault.totalAssetsDeposited(), totalAssetsDepositedBefore + amountToDeposit); + assertEq(eulerAggregationLayer.balanceOf(user1), balanceBefore + amountToDeposit); + assertEq(eulerAggregationLayer.totalSupply(), totalSupplyBefore + amountToDeposit); + assertEq(eulerAggregationLayer.totalAssetsDeposited(), totalAssetsDepositedBefore + amountToDeposit); assertEq(assetTST.balanceOf(user1), userAssetBalanceBefore - amountToDeposit); } // rebalance into strategy vm.warp(block.timestamp + 86400); - IAggregationLayerVault.Strategy memory strategyBefore = aggregationLayerVault.getStrategy(address(eTST)); + IEulerAggregationLayer.Strategy memory strategyBefore = eulerAggregationLayer.getStrategy(address(eTST)); - assertEq(eTST.convertToAssets(eTST.balanceOf(address(aggregationLayerVault))), strategyBefore.allocated); + assertEq(eTST.convertToAssets(eTST.balanceOf(address(eulerAggregationLayer))), strategyBefore.allocated); - uint256 expectedStrategyCash = aggregationLayerVault.totalAssetsAllocatable() * strategyBefore.allocationPoints - / aggregationLayerVault.totalAllocationPoints(); + uint256 expectedStrategyCash = eulerAggregationLayer.totalAssetsAllocatable() * strategyBefore.allocationPoints + / eulerAggregationLayer.totalAllocationPoints(); uint256 expectedToDeposit = expectedStrategyCash - strategyBefore.allocated; uint256 eTSTMaxDeposit = expectedToDeposit * 7e17 / 1e18; // mock max deposit vm.mockCall( - address(eTST), abi.encodeCall(eTST.maxDeposit, (address(aggregationLayerVault))), abi.encode(eTSTMaxDeposit) + address(eTST), abi.encodeCall(eTST.maxDeposit, (address(eulerAggregationLayer))), abi.encode(eTSTMaxDeposit) ); vm.prank(user1); address[] memory strategiesToRebalance = new address[](1); strategiesToRebalance[0] = address(eTST); - rebalancer.executeRebalance(address(aggregationLayerVault), strategiesToRebalance); + rebalancer.executeRebalance(address(eulerAggregationLayer), strategiesToRebalance); - assertEq(aggregationLayerVault.totalAllocated(), eTSTMaxDeposit); - assertEq(eTST.convertToAssets(eTST.balanceOf(address(aggregationLayerVault))), eTSTMaxDeposit); + assertEq(eulerAggregationLayer.totalAllocated(), eTSTMaxDeposit); + assertEq(eTST.convertToAssets(eTST.balanceOf(address(eulerAggregationLayer))), eTSTMaxDeposit); assertEq( - (aggregationLayerVault.getStrategy(address(eTST))).allocated, strategyBefore.allocated + eTSTMaxDeposit + (eulerAggregationLayer.getStrategy(address(eTST))).allocated, strategyBefore.allocated + eTSTMaxDeposit ); } function testRebalanceByDepositingWhenToDepositIsGreaterThanCashAvailable() public { + address[] memory strategiesToRebalance = new address[](1); uint256 amountToDeposit = 10000e18; // deposit into aggregator { - uint256 balanceBefore = aggregationLayerVault.balanceOf(user1); - uint256 totalSupplyBefore = aggregationLayerVault.totalSupply(); - uint256 totalAssetsDepositedBefore = aggregationLayerVault.totalAssetsDeposited(); + uint256 balanceBefore = eulerAggregationLayer.balanceOf(user1); + uint256 totalSupplyBefore = eulerAggregationLayer.totalSupply(); + uint256 totalAssetsDepositedBefore = eulerAggregationLayer.totalAssetsDeposited(); uint256 userAssetBalanceBefore = assetTST.balanceOf(user1); vm.startPrank(user1); - assetTST.approve(address(aggregationLayerVault), amountToDeposit); - aggregationLayerVault.deposit(amountToDeposit, user1); + assetTST.approve(address(eulerAggregationLayer), amountToDeposit); + eulerAggregationLayer.deposit(amountToDeposit, user1); vm.stopPrank(); - assertEq(aggregationLayerVault.balanceOf(user1), balanceBefore + amountToDeposit); - assertEq(aggregationLayerVault.totalSupply(), totalSupplyBefore + amountToDeposit); - assertEq(aggregationLayerVault.totalAssetsDeposited(), totalAssetsDepositedBefore + amountToDeposit); + assertEq(eulerAggregationLayer.balanceOf(user1), balanceBefore + amountToDeposit); + assertEq(eulerAggregationLayer.totalSupply(), totalSupplyBefore + amountToDeposit); + assertEq(eulerAggregationLayer.totalAssetsDeposited(), totalAssetsDepositedBefore + amountToDeposit); assertEq(assetTST.balanceOf(user1), userAssetBalanceBefore - amountToDeposit); } // rebalance into first strategy vm.warp(block.timestamp + 86400); vm.prank(user1); - address[] memory strategiesToRebalance = new address[](1); strategiesToRebalance[0] = address(eTST); - rebalancer.executeRebalance(address(aggregationLayerVault), strategiesToRebalance); + rebalancer.executeRebalance(address(eulerAggregationLayer), strategiesToRebalance); // create new strategy & add it IEVault eTSTsecondary; @@ -158,33 +158,32 @@ contract RebalanceTest is AggregationLayerVaultBase { // rebalance into eTSTsecondary vm.warp(block.timestamp + 86400); { - IAggregationLayerVault.Strategy memory strategyBefore = - aggregationLayerVault.getStrategy(address(eTSTsecondary)); + IEulerAggregationLayer.Strategy memory strategyBefore = + eulerAggregationLayer.getStrategy(address(eTSTsecondary)); assertEq( - eTSTsecondary.convertToAssets(eTSTsecondary.balanceOf(address(aggregationLayerVault))), + eTSTsecondary.convertToAssets(eTSTsecondary.balanceOf(address(eulerAggregationLayer))), strategyBefore.allocated ); - uint256 targetCash = aggregationLayerVault.totalAssetsAllocatable() - * aggregationLayerVault.getStrategy(address(0)).allocationPoints - / aggregationLayerVault.totalAllocationPoints(); + uint256 targetCash = eulerAggregationLayer.totalAssetsAllocatable() + * eulerAggregationLayer.getStrategy(address(0)).allocationPoints + / eulerAggregationLayer.totalAllocationPoints(); uint256 currentCash = - aggregationLayerVault.totalAssetsAllocatable() - aggregationLayerVault.totalAllocated(); + eulerAggregationLayer.totalAssetsAllocatable() - eulerAggregationLayer.totalAllocated(); uint256 expectedStrategyCash = currentCash - targetCash; vm.prank(user1); - address[] memory strategiesToRebalance = new address[](1); strategiesToRebalance[0] = address(eTSTsecondary); - rebalancer.executeRebalance(address(aggregationLayerVault), strategiesToRebalance); + rebalancer.executeRebalance(address(eulerAggregationLayer), strategiesToRebalance); - // assertEq(aggregationLayerVault.totalAllocated(), eTSTsecondaryMaxDeposit); + // assertEq(eulerAggregationLayer.totalAllocated(), eTSTsecondaryMaxDeposit); assertEq( - eTSTsecondary.convertToAssets(eTSTsecondary.balanceOf(address(aggregationLayerVault))), + eTSTsecondary.convertToAssets(eTSTsecondary.balanceOf(address(eulerAggregationLayer))), expectedStrategyCash ); assertEq( - (aggregationLayerVault.getStrategy(address(eTSTsecondary))).allocated, + (eulerAggregationLayer.getStrategy(address(eTSTsecondary))).allocated, strategyBefore.allocated + expectedStrategyCash ); } @@ -195,42 +194,42 @@ contract RebalanceTest is AggregationLayerVaultBase { // deposit into aggregator { - uint256 balanceBefore = aggregationLayerVault.balanceOf(user1); - uint256 totalSupplyBefore = aggregationLayerVault.totalSupply(); - uint256 totalAssetsDepositedBefore = aggregationLayerVault.totalAssetsDeposited(); + uint256 balanceBefore = eulerAggregationLayer.balanceOf(user1); + uint256 totalSupplyBefore = eulerAggregationLayer.totalSupply(); + uint256 totalAssetsDepositedBefore = eulerAggregationLayer.totalAssetsDeposited(); uint256 userAssetBalanceBefore = assetTST.balanceOf(user1); vm.startPrank(user1); - assetTST.approve(address(aggregationLayerVault), amountToDeposit); - aggregationLayerVault.deposit(amountToDeposit, user1); + assetTST.approve(address(eulerAggregationLayer), amountToDeposit); + eulerAggregationLayer.deposit(amountToDeposit, user1); vm.stopPrank(); - assertEq(aggregationLayerVault.balanceOf(user1), balanceBefore + amountToDeposit); - assertEq(aggregationLayerVault.totalSupply(), totalSupplyBefore + amountToDeposit); - assertEq(aggregationLayerVault.totalAssetsDeposited(), totalAssetsDepositedBefore + amountToDeposit); + assertEq(eulerAggregationLayer.balanceOf(user1), balanceBefore + amountToDeposit); + assertEq(eulerAggregationLayer.totalSupply(), totalSupplyBefore + amountToDeposit); + assertEq(eulerAggregationLayer.totalAssetsDeposited(), totalAssetsDepositedBefore + amountToDeposit); assertEq(assetTST.balanceOf(user1), userAssetBalanceBefore - amountToDeposit); } // rebalance into strategy vm.warp(block.timestamp + 86400); - IAggregationLayerVault.Strategy memory strategyBefore = aggregationLayerVault.getStrategy(address(eTST)); + IEulerAggregationLayer.Strategy memory strategyBefore = eulerAggregationLayer.getStrategy(address(eTST)); - assertEq(eTST.convertToAssets(eTST.balanceOf(address(aggregationLayerVault))), strategyBefore.allocated); + assertEq(eTST.convertToAssets(eTST.balanceOf(address(eulerAggregationLayer))), strategyBefore.allocated); uint256 eTSTMaxDeposit = 0; // mock max deposit vm.mockCall( - address(eTST), abi.encodeCall(eTST.maxDeposit, (address(aggregationLayerVault))), abi.encode(eTSTMaxDeposit) + address(eTST), abi.encodeCall(eTST.maxDeposit, (address(eulerAggregationLayer))), abi.encode(eTSTMaxDeposit) ); vm.prank(user1); address[] memory strategiesToRebalance = new address[](1); strategiesToRebalance[0] = address(eTST); - rebalancer.executeRebalance(address(aggregationLayerVault), strategiesToRebalance); + rebalancer.executeRebalance(address(eulerAggregationLayer), strategiesToRebalance); - assertEq(aggregationLayerVault.totalAllocated(), strategyBefore.allocated); - assertEq(eTST.convertToAssets(eTST.balanceOf(address(aggregationLayerVault))), strategyBefore.allocated); - assertEq((aggregationLayerVault.getStrategy(address(eTST))).allocated, strategyBefore.allocated); + assertEq(eulerAggregationLayer.totalAllocated(), strategyBefore.allocated); + assertEq(eTST.convertToAssets(eTST.balanceOf(address(eulerAggregationLayer))), strategyBefore.allocated); + assertEq((eulerAggregationLayer.getStrategy(address(eTST))).allocated, strategyBefore.allocated); } function testRebalanceByWithdrawing() public { @@ -238,19 +237,19 @@ contract RebalanceTest is AggregationLayerVaultBase { // deposit into aggregator { - uint256 balanceBefore = aggregationLayerVault.balanceOf(user1); - uint256 totalSupplyBefore = aggregationLayerVault.totalSupply(); - uint256 totalAssetsDepositedBefore = aggregationLayerVault.totalAssetsDeposited(); + uint256 balanceBefore = eulerAggregationLayer.balanceOf(user1); + uint256 totalSupplyBefore = eulerAggregationLayer.totalSupply(); + uint256 totalAssetsDepositedBefore = eulerAggregationLayer.totalAssetsDeposited(); uint256 userAssetBalanceBefore = assetTST.balanceOf(user1); vm.startPrank(user1); - assetTST.approve(address(aggregationLayerVault), amountToDeposit); - aggregationLayerVault.deposit(amountToDeposit, user1); + assetTST.approve(address(eulerAggregationLayer), amountToDeposit); + eulerAggregationLayer.deposit(amountToDeposit, user1); vm.stopPrank(); - assertEq(aggregationLayerVault.balanceOf(user1), balanceBefore + amountToDeposit); - assertEq(aggregationLayerVault.totalSupply(), totalSupplyBefore + amountToDeposit); - assertEq(aggregationLayerVault.totalAssetsDeposited(), totalAssetsDepositedBefore + amountToDeposit); + assertEq(eulerAggregationLayer.balanceOf(user1), balanceBefore + amountToDeposit); + assertEq(eulerAggregationLayer.totalSupply(), totalSupplyBefore + amountToDeposit); + assertEq(eulerAggregationLayer.totalAssetsDeposited(), totalAssetsDepositedBefore + amountToDeposit); assertEq(assetTST.balanceOf(user1), userAssetBalanceBefore - amountToDeposit); } @@ -259,30 +258,30 @@ contract RebalanceTest is AggregationLayerVaultBase { vm.prank(user1); address[] memory strategiesToRebalance = new address[](1); strategiesToRebalance[0] = address(eTST); - rebalancer.executeRebalance(address(aggregationLayerVault), strategiesToRebalance); + rebalancer.executeRebalance(address(eulerAggregationLayer), strategiesToRebalance); // decrease allocation points uint256 newAllocationPoints = 300e18; vm.prank(manager); - aggregationLayerVault.adjustAllocationPoints(address(eTST), newAllocationPoints); + eulerAggregationLayer.adjustAllocationPoints(address(eTST), newAllocationPoints); vm.warp(block.timestamp + 86400); - IAggregationLayerVault.Strategy memory strategyBefore = aggregationLayerVault.getStrategy(address(eTST)); + IEulerAggregationLayer.Strategy memory strategyBefore = eulerAggregationLayer.getStrategy(address(eTST)); - assertEq(eTST.convertToAssets(eTST.balanceOf(address(aggregationLayerVault))), strategyBefore.allocated); + assertEq(eTST.convertToAssets(eTST.balanceOf(address(eulerAggregationLayer))), strategyBefore.allocated); - uint256 expectedStrategyCash = aggregationLayerVault.totalAssetsAllocatable() * strategyBefore.allocationPoints - / aggregationLayerVault.totalAllocationPoints(); + uint256 expectedStrategyCash = eulerAggregationLayer.totalAssetsAllocatable() * strategyBefore.allocationPoints + / eulerAggregationLayer.totalAllocationPoints(); vm.prank(user1); strategiesToRebalance[0] = address(eTST); - rebalancer.executeRebalance(address(aggregationLayerVault), strategiesToRebalance); + rebalancer.executeRebalance(address(eulerAggregationLayer), strategiesToRebalance); - assertEq(aggregationLayerVault.totalAllocated(), expectedStrategyCash); - assertEq(eTST.convertToAssets(eTST.balanceOf(address(aggregationLayerVault))), expectedStrategyCash); + assertEq(eulerAggregationLayer.totalAllocated(), expectedStrategyCash); + assertEq(eTST.convertToAssets(eTST.balanceOf(address(eulerAggregationLayer))), expectedStrategyCash); assertEq( - (aggregationLayerVault.getStrategy(address(eTST))).allocated, + (eulerAggregationLayer.getStrategy(address(eTST))).allocated, strategyBefore.allocated - (strategyBefore.allocated - expectedStrategyCash) ); } @@ -292,19 +291,19 @@ contract RebalanceTest is AggregationLayerVaultBase { // deposit into aggregator { - uint256 balanceBefore = aggregationLayerVault.balanceOf(user1); - uint256 totalSupplyBefore = aggregationLayerVault.totalSupply(); - uint256 totalAssetsDepositedBefore = aggregationLayerVault.totalAssetsDeposited(); + uint256 balanceBefore = eulerAggregationLayer.balanceOf(user1); + uint256 totalSupplyBefore = eulerAggregationLayer.totalSupply(); + uint256 totalAssetsDepositedBefore = eulerAggregationLayer.totalAssetsDeposited(); uint256 userAssetBalanceBefore = assetTST.balanceOf(user1); vm.startPrank(user1); - assetTST.approve(address(aggregationLayerVault), amountToDeposit); - aggregationLayerVault.deposit(amountToDeposit, user1); + assetTST.approve(address(eulerAggregationLayer), amountToDeposit); + eulerAggregationLayer.deposit(amountToDeposit, user1); vm.stopPrank(); - assertEq(aggregationLayerVault.balanceOf(user1), balanceBefore + amountToDeposit); - assertEq(aggregationLayerVault.totalSupply(), totalSupplyBefore + amountToDeposit); - assertEq(aggregationLayerVault.totalAssetsDeposited(), totalAssetsDepositedBefore + amountToDeposit); + assertEq(eulerAggregationLayer.balanceOf(user1), balanceBefore + amountToDeposit); + assertEq(eulerAggregationLayer.totalSupply(), totalSupplyBefore + amountToDeposit); + assertEq(eulerAggregationLayer.totalAssetsDeposited(), totalAssetsDepositedBefore + amountToDeposit); assertEq(assetTST.balanceOf(user1), userAssetBalanceBefore - amountToDeposit); } @@ -313,38 +312,38 @@ contract RebalanceTest is AggregationLayerVaultBase { vm.prank(user1); address[] memory strategiesToRebalance = new address[](1); strategiesToRebalance[0] = address(eTST); - rebalancer.executeRebalance(address(aggregationLayerVault), strategiesToRebalance); + rebalancer.executeRebalance(address(eulerAggregationLayer), strategiesToRebalance); // decrease allocation points uint256 newAllocationPoints = 300e18; vm.prank(manager); - aggregationLayerVault.adjustAllocationPoints(address(eTST), newAllocationPoints); + eulerAggregationLayer.adjustAllocationPoints(address(eTST), newAllocationPoints); vm.warp(block.timestamp + 86400); - IAggregationLayerVault.Strategy memory strategyBefore = aggregationLayerVault.getStrategy(address(eTST)); + IEulerAggregationLayer.Strategy memory strategyBefore = eulerAggregationLayer.getStrategy(address(eTST)); - assertEq(eTST.convertToAssets(eTST.balanceOf(address(aggregationLayerVault))), strategyBefore.allocated); + assertEq(eTST.convertToAssets(eTST.balanceOf(address(eulerAggregationLayer))), strategyBefore.allocated); - uint256 expectedStrategyCash = aggregationLayerVault.totalAssetsAllocatable() * strategyBefore.allocationPoints - / aggregationLayerVault.totalAllocationPoints(); + uint256 expectedStrategyCash = eulerAggregationLayer.totalAssetsAllocatable() * strategyBefore.allocationPoints + / eulerAggregationLayer.totalAllocationPoints(); uint256 expectedToWithdraw = strategyBefore.allocated - expectedStrategyCash; uint256 eTSTMaxWithdraw = expectedToWithdraw * 7e17 / 1e18; // mock max withdraw vm.mockCall( address(eTST), - abi.encodeCall(eTST.maxWithdraw, (address(aggregationLayerVault))), + abi.encodeCall(eTST.maxWithdraw, (address(eulerAggregationLayer))), abi.encode(eTSTMaxWithdraw) ); vm.prank(user1); strategiesToRebalance[0] = address(eTST); - rebalancer.executeRebalance(address(aggregationLayerVault), strategiesToRebalance); + rebalancer.executeRebalance(address(eulerAggregationLayer), strategiesToRebalance); - // assertEq(aggregationLayerVault.totalAllocated(), strategyBefore.allocated - eTSTMaxWithdraw); + // assertEq(eulerAggregationLayer.totalAllocated(), strategyBefore.allocated - eTSTMaxWithdraw); // assertEq( - // eTST.convertToAssets(eTST.balanceOf(address(aggregationLayerVault))), strategyBefore.allocated - eTSTMaxWithdraw + // eTST.convertToAssets(eTST.balanceOf(address(eulerAggregationLayer))), strategyBefore.allocated - eTSTMaxWithdraw // ); - // assertEq((aggregationLayerVault.getStrategy(address(eTST))).allocated, strategyBefore.allocated - eTSTMaxWithdraw); + // assertEq((eulerAggregationLayer.getStrategy(address(eTST))).allocated, strategyBefore.allocated - eTSTMaxWithdraw); } } diff --git a/test/unit/RemoveStrategy.t.sol b/test/unit/RemoveStrategy.t.sol index e92cb8c8..6dfb15ab 100644 --- a/test/unit/RemoveStrategy.t.sol +++ b/test/unit/RemoveStrategy.t.sol @@ -2,13 +2,13 @@ pragma solidity ^0.8.0; import { - AggregationLayerVaultBase, - AggregationLayerVault, + EulerAggregationLayerBase, + EulerAggregationLayer, IEVault, - IAggregationLayerVault -} from "../common/AggregationLayerVaultBase.t.sol"; + IEulerAggregationLayer +} from "../common/EulerAggregationLayerBase.t.sol"; -contract RemoveStrategyTest is AggregationLayerVaultBase { +contract RemoveStrategyTest is EulerAggregationLayerBase { uint256 strategyAllocationPoints; IEVault anotherStrategy; @@ -21,17 +21,17 @@ contract RemoveStrategyTest is AggregationLayerVaultBase { } function testRemoveStrategy() public { - uint256 totalAllocationPointsBefore = aggregationLayerVault.totalAllocationPoints(); + uint256 totalAllocationPointsBefore = eulerAggregationLayer.totalAllocationPoints(); uint256 withdrawalQueueLengthBefore = _getWithdrawalQueueLength(); vm.prank(manager); - aggregationLayerVault.removeStrategy(address(eTST)); + eulerAggregationLayer.removeStrategy(address(eTST)); - IAggregationLayerVault.Strategy memory strategyAfter = aggregationLayerVault.getStrategy(address(eTST)); + IEulerAggregationLayer.Strategy memory strategyAfter = eulerAggregationLayer.getStrategy(address(eTST)); assertEq(strategyAfter.active, false); assertEq(strategyAfter.allocationPoints, 0); - assertEq(aggregationLayerVault.totalAllocationPoints(), totalAllocationPointsBefore - strategyAllocationPoints); + assertEq(eulerAggregationLayer.totalAllocationPoints(), totalAllocationPointsBefore - strategyAllocationPoints); assertEq(_getWithdrawalQueueLength(), withdrawalQueueLengthBefore - 1); } @@ -41,17 +41,17 @@ contract RemoveStrategyTest is AggregationLayerVaultBase { ); _addStrategy(manager, address(anotherStrategy), strategyAllocationPoints); - uint256 totalAllocationPointsBefore = aggregationLayerVault.totalAllocationPoints(); + uint256 totalAllocationPointsBefore = eulerAggregationLayer.totalAllocationPoints(); uint256 withdrawalQueueLengthBefore = _getWithdrawalQueueLength(); vm.prank(manager); - aggregationLayerVault.removeStrategy(address(eTST)); + eulerAggregationLayer.removeStrategy(address(eTST)); - IAggregationLayerVault.Strategy memory strategyAfter = aggregationLayerVault.getStrategy(address(eTST)); + IEulerAggregationLayer.Strategy memory strategyAfter = eulerAggregationLayer.getStrategy(address(eTST)); assertEq(strategyAfter.active, false); assertEq(strategyAfter.allocationPoints, 0); - assertEq(aggregationLayerVault.totalAllocationPoints(), totalAllocationPointsBefore - strategyAllocationPoints); + assertEq(eulerAggregationLayer.totalAllocationPoints(), totalAllocationPointsBefore - strategyAllocationPoints); assertEq(_getWithdrawalQueueLength(), withdrawalQueueLengthBefore - 1); } @@ -75,7 +75,7 @@ contract RemoveStrategyTest is AggregationLayerVaultBase { assertEq(withdrawalQueue[3], strategy3); vm.prank(manager); - aggregationLayerVault.removeStrategy(strategy2); + eulerAggregationLayer.removeStrategy(strategy2); withdrawalQueue = _getWithdrawalQueue(); assertEq(withdrawalQueue.length, 3); @@ -84,7 +84,7 @@ contract RemoveStrategyTest is AggregationLayerVaultBase { assertEq(withdrawalQueue[2], strategy3); vm.prank(manager); - aggregationLayerVault.removeStrategy(strategy3); + eulerAggregationLayer.removeStrategy(strategy3); withdrawalQueue = _getWithdrawalQueue(); assertEq(withdrawalQueue.length, 2); @@ -92,14 +92,14 @@ contract RemoveStrategyTest is AggregationLayerVaultBase { assertEq(withdrawalQueue[1], strategy1); vm.prank(manager); - aggregationLayerVault.removeStrategy(address(eTST)); + eulerAggregationLayer.removeStrategy(address(eTST)); withdrawalQueue = _getWithdrawalQueue(); assertEq(withdrawalQueue.length, 1); assertEq(withdrawalQueue[0], strategy1); vm.prank(manager); - aggregationLayerVault.removeStrategy(strategy1); + eulerAggregationLayer.removeStrategy(strategy1); withdrawalQueue = _getWithdrawalQueue(); assertEq(withdrawalQueue.length, 0); @@ -108,12 +108,12 @@ contract RemoveStrategyTest is AggregationLayerVaultBase { function testRemoveStrategy_fromUnauthorized() public { vm.prank(deployer); vm.expectRevert(); - aggregationLayerVault.removeStrategy(address(eTST)); + eulerAggregationLayer.removeStrategy(address(eTST)); } function testRemoveStrategy_AlreadyRemoved() public { vm.prank(manager); vm.expectRevert(); - aggregationLayerVault.removeStrategy(address(eTST2)); + eulerAggregationLayer.removeStrategy(address(eTST2)); } } diff --git a/test/unit/ReorderWithdrawalQueueTest.t.sol b/test/unit/ReorderWithdrawalQueueTest.t.sol index 3251194e..5f684df6 100644 --- a/test/unit/ReorderWithdrawalQueueTest.t.sol +++ b/test/unit/ReorderWithdrawalQueueTest.t.sol @@ -2,13 +2,13 @@ pragma solidity ^0.8.0; import { - AggregationLayerVaultBase, - AggregationLayerVault, + EulerAggregationLayerBase, + EulerAggregationLayer, IEVault, WithdrawalQueue -} from "../common/AggregationLayerVaultBase.t.sol"; +} from "../common/EulerAggregationLayerBase.t.sol"; -contract ReorderWithdrawalQueueTest is AggregationLayerVaultBase { +contract ReorderWithdrawalQueueTest is EulerAggregationLayerBase { uint256 eTSTAllocationPoints = 500e18; uint256 eTSTsecondaryAllocationPoints = 700e18; @@ -30,18 +30,18 @@ contract ReorderWithdrawalQueueTest is AggregationLayerVaultBase { } function testReorderWithdrawalQueue() public { - assertEq(aggregationLayerVault.getStrategy(_getWithdrawalQueue()[0]).allocationPoints, eTSTAllocationPoints); + assertEq(eulerAggregationLayer.getStrategy(_getWithdrawalQueue()[0]).allocationPoints, eTSTAllocationPoints); assertEq( - aggregationLayerVault.getStrategy(_getWithdrawalQueue()[1]).allocationPoints, eTSTsecondaryAllocationPoints + eulerAggregationLayer.getStrategy(_getWithdrawalQueue()[1]).allocationPoints, eTSTsecondaryAllocationPoints ); vm.prank(manager); withdrawalQueue.reorderWithdrawalQueue(0, 1); assertEq( - aggregationLayerVault.getStrategy(_getWithdrawalQueue()[0]).allocationPoints, eTSTsecondaryAllocationPoints + eulerAggregationLayer.getStrategy(_getWithdrawalQueue()[0]).allocationPoints, eTSTsecondaryAllocationPoints ); - assertEq(aggregationLayerVault.getStrategy(_getWithdrawalQueue()[1]).allocationPoints, eTSTAllocationPoints); + assertEq(eulerAggregationLayer.getStrategy(_getWithdrawalQueue()[1]).allocationPoints, eTSTAllocationPoints); } function testReorderWithdrawalQueueWhenOutOfBounds() public {