Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add public getters for module addresses #57

Merged
merged 3 commits into from
Mar 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 18 additions & 18 deletions src/EVault/modules/Dispatch.sol → src/EVault/Dispatch.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion src/EVault/EVault.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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) {}
Expand Down
19 changes: 18 additions & 1 deletion src/EVault/IEVault.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
18 changes: 18 additions & 0 deletions test/unit/evault/Dispatch.t.sol
Original file line number Diff line number Diff line change
@@ -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);
}
}
36 changes: 27 additions & 9 deletions test/unit/evault/EVaultTestBase.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down Expand Up @@ -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");
Expand All @@ -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));
Expand Down
1 change: 0 additions & 1 deletion test/unit/evault/modules/Vault/skim.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down
1 change: 0 additions & 1 deletion test/unit/evault/modules/Vault/withdraw.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down
Loading