Skip to content

Commit

Permalink
refactor: deconstruct imports and use interfaces for sys contracts
Browse files Browse the repository at this point in the history
  • Loading branch information
SeanJCasey authored Oct 5, 2023
1 parent 1edbcfc commit 0392d20
Show file tree
Hide file tree
Showing 171 changed files with 849 additions and 694 deletions.
24 changes: 12 additions & 12 deletions contracts/release/core/fund-deployer/FundDeployer.sol
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,15 @@
pragma solidity 0.6.12;
pragma experimental ABIEncoderV2;

import "../../../persistent/dispatcher/IDispatcher.sol";
import "../../../persistent/dispatcher/IMigrationHookHandler.sol";
import "../../extensions/IExtension.sol";
import "../../infrastructure/gas-relayer/GasRelayRecipientMixin.sol";
import "../../infrastructure/protocol-fees/IProtocolFeeTracker.sol";
import "../fund/comptroller/ComptrollerProxy.sol";
import "../fund/comptroller/IComptroller.sol";
import "../fund/vault/IVault.sol";
import "./IFundDeployer.sol";
import {IDispatcher} from "../../../persistent/dispatcher/IDispatcher.sol";
import {IMigrationHookHandler} from "../../../persistent/dispatcher/IMigrationHookHandler.sol";
import {IExtension} from "../../extensions/IExtension.sol";
import {GasRelayRecipientMixin} from "../../infrastructure/gas-relayer/GasRelayRecipientMixin.sol";
import {IProtocolFeeTracker} from "../../infrastructure/protocol-fees/IProtocolFeeTracker.sol";
import {ComptrollerProxy} from "../fund/comptroller/ComptrollerProxy.sol";
import {IComptroller} from "../fund/comptroller/IComptroller.sol";
import {IVault} from "../fund/vault/IVault.sol";
import {IFundDeployer} from "./IFundDeployer.sol";

/// @title FundDeployer Contract
/// @author Enzyme Council <security@enzyme.finance>
Expand Down Expand Up @@ -339,7 +339,7 @@ contract FundDeployer is IFundDeployer, IMigrationHookHandler, GasRelayRecipient
uint256 _sharesActionTimelock,
bytes calldata _feeManagerConfigData,
bytes calldata _policyManagerConfigData
) external returns (address comptrollerProxy_) {
) external override returns (address comptrollerProxy_) {
address canonicalSender = __msgSender();
__assertIsMigrator(_vaultProxy, canonicalSender);
require(
Expand Down Expand Up @@ -433,7 +433,7 @@ contract FundDeployer is IFundDeployer, IMigrationHookHandler, GasRelayRecipient

/// @notice Cancels a pending reconfiguration request
/// @param _vaultProxy The VaultProxy contract for which to cancel the reconfiguration request
function cancelReconfiguration(address _vaultProxy) external onlyMigrator(_vaultProxy) {
function cancelReconfiguration(address _vaultProxy) external override onlyMigrator(_vaultProxy) {
address nextComptrollerProxy = vaultProxyToReconfigurationRequest[_vaultProxy].nextComptrollerProxy;
require(
nextComptrollerProxy != address(0),
Expand All @@ -453,7 +453,7 @@ contract FundDeployer is IFundDeployer, IMigrationHookHandler, GasRelayRecipient
/// @param _vaultProxy The VaultProxy contract for which to execute the reconfiguration request
/// @dev ProtocolFeeTracker.initializeForVault() does not need to be included in a reconfiguration,
/// as it refers to the vault and not the new ComptrollerProxy
function executeReconfiguration(address _vaultProxy) external onlyMigrator(_vaultProxy) {
function executeReconfiguration(address _vaultProxy) external override onlyMigrator(_vaultProxy) {
ReconfigurationRequest memory request = getReconfigurationRequestForVaultProxy(_vaultProxy);
require(
request.nextComptrollerProxy != address(0),
Expand Down
12 changes: 12 additions & 0 deletions contracts/release/core/fund-deployer/IFundDeployer.sol
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,18 @@ pragma solidity >=0.6.0 <0.9.0;
/// @title IFundDeployer Interface
/// @author Enzyme Council <security@enzyme.finance>
interface IFundDeployer {
function cancelReconfiguration(address _vaultProxy) external;

function createReconfigurationRequest(
address _vaultProxy,
address _denominationAsset,
uint256 _sharesActionTimelock,
bytes calldata _feeManagerConfigData,
bytes calldata _policyManagerConfigData
) external returns (address comptrollerProxy_);

function executeReconfiguration(address _vaultProxy) external;

function getOwner() external view returns (address);

function hasReconfigurationRequest(address) external view returns (bool);
Expand Down
44 changes: 23 additions & 21 deletions contracts/release/core/fund/comptroller/ComptrollerLib.sol
Original file line number Diff line number Diff line change
Expand Up @@ -11,23 +11,23 @@

pragma solidity 0.6.12;

import "openzeppelin-solc-0.6/math/SafeMath.sol";
import "openzeppelin-solc-0.6/token/ERC20/ERC20.sol";
import "openzeppelin-solc-0.6/token/ERC20/SafeERC20.sol";
import "../../../../persistent/dispatcher/IDispatcher.sol";
import "../../../../persistent/external-positions/IExternalPosition.sol";
import "../../../../utils/0.6.12/beacon-proxy/IBeaconProxyFactory.sol";
import "../../../../utils/0.6.12/AddressArrayLib.sol";
import "../../../extensions/IExtension.sol";
import "../../../extensions/fee-manager/IFeeManager.sol";
import "../../../extensions/policy-manager/IPolicyManager.sol";
import "../../../infrastructure/gas-relayer/GasRelayRecipientMixin.sol";
import "../../../infrastructure/gas-relayer/IGasRelayPaymaster.sol";
import "../../../infrastructure/gas-relayer/IGasRelayPaymasterDepositor.sol";
import "../../../infrastructure/value-interpreter/IValueInterpreter.sol";
import "../../fund-deployer/IFundDeployer.sol";
import "../vault/IVault.sol";
import "./IComptroller.sol";
import {SafeMath} from "openzeppelin-solc-0.6/math/SafeMath.sol";
import {ERC20} from "openzeppelin-solc-0.6/token/ERC20/ERC20.sol";
import {SafeERC20} from "openzeppelin-solc-0.6/token/ERC20/SafeERC20.sol";
import {IDispatcher} from "../../../../persistent/dispatcher/IDispatcher.sol";
import {IExternalPosition} from "../../../../persistent/external-positions/IExternalPosition.sol";
import {IBeaconProxyFactory} from "../../../../utils/0.6.12/beacon-proxy/IBeaconProxyFactory.sol";
import {AddressArrayLib} from "../../../../utils/0.6.12/AddressArrayLib.sol";
import {IExtension} from "../../../extensions/IExtension.sol";
import {IFeeManager} from "../../../extensions/fee-manager/IFeeManager.sol";
import {IPolicyManager} from "../../../extensions/policy-manager/IPolicyManager.sol";
import {GasRelayRecipientMixin} from "../../../infrastructure/gas-relayer/GasRelayRecipientMixin.sol";
import {IGasRelayPaymaster} from "../../../infrastructure/gas-relayer/IGasRelayPaymaster.sol";
import {IGasRelayPaymasterDepositor} from "../../../infrastructure/gas-relayer/IGasRelayPaymasterDepositor.sol";
import {IValueInterpreter} from "../../../infrastructure/value-interpreter/IValueInterpreter.sol";
import {IFundDeployer} from "../../fund-deployer/IFundDeployer.sol";
import {IVault} from "../vault/IVault.sol";
import {IComptroller} from "./IComptroller.sol";

/// @title ComptrollerLib Contract
/// @author Enzyme Council <security@enzyme.finance>
Expand Down Expand Up @@ -237,6 +237,7 @@ contract ComptrollerLib is IComptroller, IGasRelayPaymasterDepositor, GasRelayRe
/// @return returnData_ The data returned by the call
function vaultCallOnContract(address _contract, bytes4 _selector, bytes calldata _encodedArgs)
external
override
onlyOwner
returns (bytes memory returnData_)
{
Expand Down Expand Up @@ -264,7 +265,7 @@ contract ComptrollerLib is IComptroller, IGasRelayPaymasterDepositor, GasRelayRe

/// @notice Buys back shares collected as protocol fee at a discounted shares price, using MLN
/// @param _sharesAmount The amount of shares to buy back
function buyBackProtocolFeeShares(uint256 _sharesAmount) external {
function buyBackProtocolFeeShares(uint256 _sharesAmount) external override {
address vaultProxyCopy = vaultProxy;
require(IVault(vaultProxyCopy).canManageAssets(__msgSender()), "buyBackProtocolFeeShares: Unauthorized");

Expand All @@ -278,7 +279,7 @@ contract ComptrollerLib is IComptroller, IGasRelayPaymasterDepositor, GasRelayRe
/// @notice Sets whether to attempt to buyback protocol fee shares immediately when collected
/// @param _nextAutoProtocolFeeSharesBuyback True if protocol fee shares should be attempted
/// to be bought back immediately when collected
function setAutoProtocolFeeSharesBuyback(bool _nextAutoProtocolFeeSharesBuyback) external onlyOwner {
function setAutoProtocolFeeSharesBuyback(bool _nextAutoProtocolFeeSharesBuyback) external override onlyOwner {
autoProtocolFeeSharesBuyback = _nextAutoProtocolFeeSharesBuyback;

emit AutoProtocolFeeSharesBuybackSet(_nextAutoProtocolFeeSharesBuyback);
Expand Down Expand Up @@ -599,6 +600,7 @@ contract ComptrollerLib is IComptroller, IGasRelayPaymasterDepositor, GasRelayRe
/// @return sharesReceived_ The actual amount of shares received
function buyShares(uint256 _investmentAmount, uint256 _minSharesQuantity)
external
override
returns (uint256 sharesReceived_)
{
bool hasSharesActionTimelock = getSharesActionTimelock() > 0;
Expand Down Expand Up @@ -788,7 +790,7 @@ contract ComptrollerLib is IComptroller, IGasRelayPaymasterDepositor, GasRelayRe
uint256 _sharesQuantity,
address[] calldata _additionalAssets,
address[] calldata _assetsToSkip
) external locksReentrance returns (address[] memory payoutAssets_, uint256[] memory payoutAmounts_) {
) external override locksReentrance returns (address[] memory payoutAssets_, uint256[] memory payoutAmounts_) {
address canonicalSender = __msgSender();
require(_additionalAssets.isUniqueSet(), "redeemSharesInKind: _additionalAssets contains duplicates");
require(_assetsToSkip.isUniqueSet(), "redeemSharesInKind: _assetsToSkip contains duplicates");
Expand Down Expand Up @@ -1029,7 +1031,7 @@ contract ComptrollerLib is IComptroller, IGasRelayPaymasterDepositor, GasRelayRe
}

/// @notice Tops up the gas relay paymaster deposit
function depositToGasRelayPaymaster() external onlyOwner {
function depositToGasRelayPaymaster() external override onlyOwner {
__depositToGasRelayPaymaster(getGasRelayPaymaster());
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

pragma solidity 0.6.12;

import "../../../../utils/0.6.12/NonUpgradableProxy.sol";
import {NonUpgradableProxy} from "../../../../utils/0.6.12/NonUpgradableProxy.sol";

/// @title ComptrollerProxy Contract
/// @author Enzyme Council <security@enzyme.finance>
Expand Down
23 changes: 22 additions & 1 deletion contracts/release/core/fund/comptroller/IComptroller.sol
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,19 @@

pragma solidity >=0.6.0 <0.9.0;

import "../vault/IVault.sol";
import {IVault} from "../vault/IVault.sol";

/// @title IComptroller Interface
/// @author Enzyme Council <security@enzyme.finance>
interface IComptroller {
function activate(bool) external;

function buyBackProtocolFeeShares(uint256 _sharesAmount) external;

function buyShares(uint256 _investmentAmount, uint256 _minSharesQuantity)
external
returns (uint256 sharesReceived_);

function buySharesOnBehalf(address _buyer, uint256 _investmentAmount, uint256 _minSharesQuantity)
external
returns (uint256 sharesReceived_);
Expand All @@ -28,6 +34,8 @@ interface IComptroller {

function callOnExtension(address, uint256, bytes calldata) external;

function depositToGasRelayPaymaster() external;

function destructActivated(uint256, uint256) external;

function destructUnactivated() external;
Expand Down Expand Up @@ -56,7 +64,20 @@ interface IComptroller {

function preTransferSharesHookFreelyTransferable(address) external view;

function redeemSharesInKind(
address _recipient,
uint256 _sharesQuantity,
address[] calldata _additionalAssets,
address[] calldata _assetsToSkip
) external returns (address[] memory payoutAssets_, uint256[] memory payoutAmounts_);

function setAutoProtocolFeeSharesBuyback(bool _nextAutoProtocolFeeSharesBuyback) external;

function setGasRelayPaymaster(address) external;

function setVaultProxy(address) external;

function vaultCallOnContract(address _contract, bytes4 _selector, bytes calldata _encodedArgs)
external
returns (bytes memory returnData_);
}
9 changes: 5 additions & 4 deletions contracts/release/core/fund/vault/IVault.sol
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,11 @@

pragma solidity >=0.6.0 <0.9.0;

import "../../../../persistent/vault/interfaces/IExternalPositionVault.sol";
import "../../../../persistent/vault/interfaces/IFreelyTransferableSharesVault.sol";
import "../../../../persistent/vault/interfaces/IMigratableVault.sol";
import "../../../../persistent/vault/interfaces/IVaultCore.sol";
import {IExternalPositionVault} from "../../../../persistent/vault/interfaces/IExternalPositionVault.sol";
import {IFreelyTransferableSharesVault} from
"../../../../persistent/vault/interfaces/IFreelyTransferableSharesVault.sol";
import {IMigratableVault} from "../../../../persistent/vault/interfaces/IMigratableVault.sol";
import {IVaultCore} from "../../../../persistent/vault/interfaces/IVaultCore.sol";

/// @title IVault Interface
/// @author Enzyme Council <security@enzyme.finance>
Expand Down
28 changes: 14 additions & 14 deletions contracts/release/core/fund/vault/VaultLib.sol
Original file line number Diff line number Diff line change
Expand Up @@ -11,20 +11,20 @@

pragma solidity 0.6.12;

import "openzeppelin-solc-0.6/token/ERC20/ERC20.sol";
import "openzeppelin-solc-0.6/token/ERC20/ERC20Burnable.sol";
import "openzeppelin-solc-0.6/token/ERC20/SafeERC20.sol";
import "../../../../external-interfaces/IWETH.sol";
import "../../../../persistent/dispatcher/IDispatcher.sol";
import "../../../../persistent/external-positions/IExternalPosition.sol";
import "../../../../persistent/protocol-fee-reserve/interfaces/IProtocolFeeReserve1.sol";
import "../../../../persistent/vault/VaultLibBase2.sol";
import "../../../../utils/0.6.12/AddressArrayLib.sol";
import "../../../infrastructure/gas-relayer/GasRelayRecipientMixin.sol";
import "../../../infrastructure/protocol-fees/IProtocolFeeTracker.sol";
import "../../../extensions/external-position-manager/IExternalPositionManager.sol";
import "../comptroller/IComptroller.sol";
import "./IVault.sol";
import {ERC20} from "openzeppelin-solc-0.6/token/ERC20/ERC20.sol";
import {ERC20Burnable} from "openzeppelin-solc-0.6/token/ERC20/ERC20Burnable.sol";
import {SafeERC20} from "openzeppelin-solc-0.6/token/ERC20/SafeERC20.sol";
import {IWETH} from "../../../../external-interfaces/IWETH.sol";
import {IDispatcher} from "../../../../persistent/dispatcher/IDispatcher.sol";
import {IExternalPosition} from "../../../../persistent/external-positions/IExternalPosition.sol";
import {IProtocolFeeReserve1} from "../../../../persistent/protocol-fee-reserve/interfaces/IProtocolFeeReserve1.sol";
import {VaultLibBase2} from "../../../../persistent/vault/VaultLibBase2.sol";
import {AddressArrayLib} from "../../../../utils/0.6.12/AddressArrayLib.sol";
import {GasRelayRecipientMixin} from "../../../infrastructure/gas-relayer/GasRelayRecipientMixin.sol";
import {IProtocolFeeTracker} from "../../../infrastructure/protocol-fees/IProtocolFeeTracker.sol";
import {IExternalPositionManager} from "../../../extensions/external-position-manager/IExternalPositionManager.sol";
import {IComptroller} from "../comptroller/IComptroller.sol";
import {IVault} from "./IVault.sol";

/// @title VaultLib Contract
/// @author Enzyme Council <security@enzyme.finance>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,15 @@

pragma solidity 0.6.12;

import "../../../persistent/external-positions/IExternalPosition.sol";
import "../../../persistent/external-positions/IExternalPositionFactory.sol";
import "../../../persistent/external-positions/IExternalPositionProxy.sol";
import "../policy-manager/IPolicyManager.sol";
import "../utils/ExtensionBase.sol";
import "../utils/PermissionedVaultActionMixin.sol";
import "./external-positions/IExternalPositionParser.sol";
import "./IExternalPositionManager.sol";
import {IExternalPosition} from "../../../persistent/external-positions/IExternalPosition.sol";
import {IExternalPositionFactory} from "../../../persistent/external-positions/IExternalPositionFactory.sol";
import {IExternalPositionProxy} from "../../../persistent/external-positions/IExternalPositionProxy.sol";
import {IVault} from "../../core/fund/vault/IVault.sol";
import {IPolicyManager} from "../policy-manager/IPolicyManager.sol";
import {ExtensionBase} from "../utils/ExtensionBase.sol";
import {PermissionedVaultActionMixin} from "../utils/PermissionedVaultActionMixin.sol";
import {IExternalPositionParser} from "./external-positions/IExternalPositionParser.sol";
import {IExternalPositionManager} from "./IExternalPositionManager.sol";

/// @title ExternalPositionManager
/// @author Enzyme Council <security@enzyme.finance>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,19 @@

pragma solidity 0.6.12;

import "openzeppelin-solc-0.6/token/ERC20/ERC20.sol";
import "openzeppelin-solc-0.6/token/ERC20/SafeERC20.sol";
import "../../../../../external-interfaces/IAaveV2IncentivesController.sol";
import "../../../../../external-interfaces/IAaveV2LendingPool.sol";
import "../../../../../external-interfaces/IAaveV2LendingPoolAddressProvider.sol";
import "../../../../../external-interfaces/IAaveV2ProtocolDataProvider.sol";
import "../../../../../persistent/external-positions/aave-v2-debt/AaveDebtPositionLibBase1.sol";
import "../../../../../utils/0.6.12/AddressArrayLib.sol";
import "../../../../../utils/0.6.12/AssetHelpers.sol";
import "./AaveDebtPositionDataDecoder.sol";
import "./IAaveDebtPosition.sol";
import {ERC20} from "openzeppelin-solc-0.6/token/ERC20/ERC20.sol";
import {SafeERC20} from "openzeppelin-solc-0.6/token/ERC20/SafeERC20.sol";
import {IAaveV2IncentivesController} from "../../../../../external-interfaces/IAaveV2IncentivesController.sol";
import {IAaveV2LendingPool} from "../../../../../external-interfaces/IAaveV2LendingPool.sol";
import {IAaveV2LendingPoolAddressProvider} from
"../../../../../external-interfaces/IAaveV2LendingPoolAddressProvider.sol";
import {IAaveV2ProtocolDataProvider} from "../../../../../external-interfaces/IAaveV2ProtocolDataProvider.sol";
import {AaveDebtPositionLibBase1} from
"../../../../../persistent/external-positions/aave-v2-debt/AaveDebtPositionLibBase1.sol";
import {AddressArrayLib} from "../../../../../utils/0.6.12/AddressArrayLib.sol";
import {AssetHelpers} from "../../../../../utils/0.6.12/AssetHelpers.sol";
import {AaveDebtPositionDataDecoder} from "./AaveDebtPositionDataDecoder.sol";
import {IAaveDebtPosition} from "./IAaveDebtPosition.sol";

/// @title AaveDebtPositionLib Contract
/// @author Enzyme Council <security@enzyme.finance>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,11 @@
file that was distributed with this source code.
*/

import "../../../../infrastructure/value-interpreter/ValueInterpreter.sol";
import "../IExternalPositionParser.sol";
import "./AaveDebtPositionDataDecoder.sol";
import "./IAaveDebtPosition.sol";
import {ERC20} from "openzeppelin-solc-0.6/token/ERC20/ERC20.sol";
import {IValueInterpreter} from "../../../../infrastructure/value-interpreter/IValueInterpreter.sol";
import {IExternalPositionParser} from "../IExternalPositionParser.sol";
import {AaveDebtPositionDataDecoder} from "./AaveDebtPositionDataDecoder.sol";
import {IAaveDebtPosition} from "./IAaveDebtPosition.sol";

pragma solidity 0.6.12;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
file that was distributed with this source code.
*/

import "../../../../../persistent/external-positions/IExternalPosition.sol";
import {IExternalPosition} from "../../../../../persistent/external-positions/IExternalPosition.sol";

pragma solidity >=0.6.0 <0.9.0;

Expand Down
Loading

0 comments on commit 0392d20

Please sign in to comment.