diff --git a/src/EVault/modules/Dispatch.sol b/src/EVault/Dispatch.sol similarity index 83% rename from src/EVault/modules/Dispatch.sol rename to src/EVault/Dispatch.sol index 42542b12..fc425819 100644 --- a/src/EVault/modules/Dispatch.sol +++ b/src/EVault/Dispatch.sol @@ -2,18 +2,18 @@ pragma solidity ^0.8.0; -import {Base} from "../shared/Base.sol"; +import {Base} from "./shared/Base.sol"; -import {TokenModule} from "./Token.sol"; -import {VaultModule} from "./Vault.sol"; -import {BorrowingModule} from "./Borrowing.sol"; -import {LiquidationModule} from "./Liquidation.sol"; -import {InitializeModule} from "./Initialize.sol"; -import {BalanceForwarderModule} from "./BalanceForwarder.sol"; -import {GovernanceModule} from "./Governance.sol"; -import {RiskManagerModule} from "./RiskManager.sol"; +import {TokenModule} from "./modules/Token.sol"; +import {VaultModule} from "./modules/Vault.sol"; +import {BorrowingModule} from "./modules/Borrowing.sol"; +import {LiquidationModule} from "./modules/Liquidation.sol"; +import {InitializeModule} from "./modules/Initialize.sol"; +import {BalanceForwarderModule} from "./modules/BalanceForwarder.sol"; +import {GovernanceModule} from "./modules/Governance.sol"; +import {RiskManagerModule} from "./modules/RiskManager.sol"; -import "../shared/Constants.sol"; +import "./shared/Constants.sol"; abstract contract Dispatch is Base, @@ -26,14 +26,14 @@ abstract contract Dispatch is BalanceForwarderModule, GovernanceModule { - address immutable MODULE_INITIALIZE; - address immutable MODULE_TOKEN; - address immutable MODULE_VAULT; - address immutable MODULE_BORROWING; - address immutable MODULE_LIQUIDATION; - address immutable MODULE_RISKMANAGER; - address immutable MODULE_BALANCE_FORWARDER; - address immutable MODULE_GOVERNANCE; + address public immutable MODULE_INITIALIZE; + address public immutable MODULE_TOKEN; + address public immutable MODULE_VAULT; + address public immutable MODULE_BORROWING; + address public immutable MODULE_LIQUIDATION; + address public immutable MODULE_RISKMANAGER; + address public immutable MODULE_BALANCE_FORWARDER; + address public immutable MODULE_GOVERNANCE; struct DeployedModules { address initialize; diff --git a/src/EVault/EVault.sol b/src/EVault/EVault.sol index 358ffa87..b3504bd1 100644 --- a/src/EVault/EVault.sol +++ b/src/EVault/EVault.sol @@ -2,7 +2,7 @@ pragma solidity ^0.8.0; -import {Dispatch} from "./modules/Dispatch.sol"; +import {Dispatch} from "./Dispatch.sol"; contract EVault is Dispatch { constructor(Integrations memory integrations, DeployedModules memory modules) Dispatch(integrations, modules) {} diff --git a/src/EVault/IEVault.sol b/src/EVault/IEVault.sol index 3370399a..bb4cb9cb 100644 --- a/src/EVault/IEVault.sol +++ b/src/EVault/IEVault.sol @@ -415,4 +415,21 @@ interface IEVault is IRiskManager, IBalanceForwarder, IGovernance -{} +{ + /// @notice Fetch address of the `Initialize` module + function MODULE_INITIALIZE() external view returns (address); + /// @notice Fetch address of the `Token` module + function MODULE_TOKEN() external view returns (address); + /// @notice Fetch address of the `Vault` module + function MODULE_VAULT() external view returns (address); + /// @notice Fetch address of the `Borrowing` module + function MODULE_BORROWING() external view returns (address); + /// @notice Fetch address of the `Liquidation` module + function MODULE_LIQUIDATION() external view returns (address); + /// @notice Fetch address of the `RiskManager` module + function MODULE_RISKMANAGER() external view returns (address); + /// @notice Fetch address of the `BalanceForwarder` module + function MODULE_BALANCE_FORWARDER() external view returns (address); + /// @notice Fetch address of the `Governance` module + function MODULE_GOVERNANCE() external view returns (address); +} diff --git a/test/unit/evault/Dispatch.t.sol b/test/unit/evault/Dispatch.t.sol new file mode 100644 index 00000000..013b3177 --- /dev/null +++ b/test/unit/evault/Dispatch.t.sol @@ -0,0 +1,18 @@ +// SPDX-License-Identifier: GPL-2.0-or-later + +pragma solidity ^0.8.0; + +import "./EVaultTestBase.t.sol"; + +contract DispatchTest is EVaultTestBase { + function test_Dispatch_moduleGetters() public view { + assertEq(eTST.MODULE_INITIALIZE(), initializeModule); + assertEq(eTST.MODULE_TOKEN(), tokenModule); + assertEq(eTST.MODULE_VAULT(), vaultModule); + assertEq(eTST.MODULE_BORROWING(), borrowingModule); + assertEq(eTST.MODULE_LIQUIDATION(), liquidationModule); + assertEq(eTST.MODULE_RISKMANAGER(), riskManagerModule); + assertEq(eTST.MODULE_BALANCE_FORWARDER(), balanceForwarderModule); + assertEq(eTST.MODULE_GOVERNANCE(), governanceModule); + } +} diff --git a/test/unit/evault/EVaultTestBase.t.sol b/test/unit/evault/EVaultTestBase.t.sol index c8647693..a0bf6ed3 100644 --- a/test/unit/evault/EVaultTestBase.t.sol +++ b/test/unit/evault/EVaultTestBase.t.sol @@ -9,7 +9,7 @@ import {GenericFactory} from "src/GenericFactory/GenericFactory.sol"; import {EVault} from "src/EVault/EVault.sol"; import {ProtocolConfig} from "src/ProtocolConfig/ProtocolConfig.sol"; -import {Dispatch} from "src/EVault/modules/Dispatch.sol"; +import {Dispatch} from "src/EVault/Dispatch.sol"; import {Initialize} from "src/EVault/modules/Initialize.sol"; import {Token} from "src/EVault/modules/Token.sol"; @@ -55,6 +55,15 @@ contract EVaultTestBase is AssertionsCustomTypes, Test, DeployPermit2 { IEVault public eTST; IEVault public eTST2; + address initializeModule; + address tokenModule; + address vaultModule; + address borrowingModule; + address liquidationModule; + address riskManagerModule; + address balanceForwarderModule; + address governanceModule; + function setUp() public virtual { admin = vm.addr(1000); feeReceiver = makeAddr("feeReceiver"); @@ -68,15 +77,24 @@ contract EVaultTestBase is AssertionsCustomTypes, Test, DeployPermit2 { permit2 = deployPermit2(); integrations = Base.Integrations(address(evc), address(protocolConfig), balanceTracker, permit2); + initializeModule = address(new Initialize(integrations)); + tokenModule = address(new Token(integrations)); + vaultModule = address(new Vault(integrations)); + borrowingModule = address(new Borrowing(integrations)); + liquidationModule = address(new Liquidation(integrations)); + riskManagerModule = address(new RiskManager(integrations)); + balanceForwarderModule = address(new BalanceForwarder(integrations)); + governanceModule = address(new Governance(integrations)); + modules = Dispatch.DeployedModules({ - initialize: address(new Initialize(integrations)), - token: address(new Token(integrations)), - vault: address(new Vault(integrations)), - borrowing: address(new Borrowing(integrations)), - liquidation: address(new Liquidation(integrations)), - riskManager: address(new RiskManager(integrations)), - balanceForwarder: address(new BalanceForwarder(integrations)), - governance: address(new Governance(integrations)) + initialize: initializeModule, + token: tokenModule, + vault: vaultModule, + borrowing: borrowingModule, + liquidation: liquidationModule, + riskManager: riskManagerModule, + balanceForwarder: balanceForwarderModule, + governance: governanceModule }); address evaultImpl = address(new EVault(integrations, modules)); diff --git a/test/unit/evault/modules/Vault/skim.t.sol b/test/unit/evault/modules/Vault/skim.t.sol index 84d376dc..448e8b0d 100644 --- a/test/unit/evault/modules/Vault/skim.t.sol +++ b/test/unit/evault/modules/Vault/skim.t.sol @@ -2,7 +2,6 @@ pragma solidity ^0.8.0; -import {console2} from "forge-std/Test.sol"; import {EVaultTestBase} from "../../EVaultTestBase.t.sol"; import "src/EVault/shared/types/Types.sol"; diff --git a/test/unit/evault/modules/Vault/withdraw.t.sol b/test/unit/evault/modules/Vault/withdraw.t.sol index 8c8b90b8..6045667e 100644 --- a/test/unit/evault/modules/Vault/withdraw.t.sol +++ b/test/unit/evault/modules/Vault/withdraw.t.sol @@ -2,7 +2,6 @@ pragma solidity ^0.8.0; -import {console2} from "forge-std/Test.sol"; import {EVaultTestBase} from "../../EVaultTestBase.t.sol"; import {Events} from "src/EVault/shared/Events.sol"; import {SafeERC20Lib} from "src/EVault/shared/lib/SafeERC20Lib.sol";