Skip to content

Commit

Permalink
refactor: consolidate external positions in release dirs
Browse files Browse the repository at this point in the history
  • Loading branch information
SeanJCasey authored Oct 6, 2023
1 parent 9851130 commit 32b84c8
Show file tree
Hide file tree
Showing 70 changed files with 88 additions and 83 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
pragma solidity 0.6.12;

import "../vault/interfaces/IExternalPositionVault.sol";
import "./IExternalPosition.sol";
import "./IExternalPositionLibCore.sol";
import "./IExternalPositionProxy.sol";

/// @title ExternalPositionProxy Contract
Expand Down Expand Up @@ -49,12 +49,13 @@ contract ExternalPositionProxy is IExternalPositionProxy {

/// @notice Delegates call to IExternalPosition.receiveCallFromVault
/// @param _data The bytes data variable to be decoded at the External Position
function receiveCallFromVault(bytes calldata _data) external {
function receiveCallFromVault(bytes calldata _data) external override {
require(msg.sender == getVaultProxy(), "receiveCallFromVault: Only the vault can make this call");
address contractLogic =
IExternalPositionVault(getVaultProxy()).getExternalPositionLibForType(getExternalPositionType());
(bool success, bytes memory returnData) =
contractLogic.delegatecall(abi.encodeWithSelector(IExternalPosition.receiveCallFromVault.selector, _data));
(bool success, bytes memory returnData) = contractLogic.delegatecall(
abi.encodeWithSelector(IExternalPositionLibCore.receiveCallFromVault.selector, _data)
);

require(success, string(returnData));
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
// SPDX-License-Identifier: GPL-3.0

/*
This file is part of the Enzyme Protocol.
(c) Enzyme Council <council@enzyme.finance>
For the full license information, please view the LICENSE
file that was distributed with this source code.
*/

pragma solidity >=0.6.0 <0.9.0;

/// @title IExternalPositionLibCore interface
/// @author Enzyme Council <security@enzyme.finance>
/// @notice An interface for core required functions of an IExternalPositionLib instance
interface IExternalPositionLibCore {
function receiveCallFromVault(bytes memory _data) external;
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,9 @@ pragma solidity >=0.6.0 <0.9.0;
/// @author Enzyme Council <security@enzyme.finance>
/// @notice An interface for publicly accessible functions on the ExternalPositionProxy
interface IExternalPositionProxy {
function getExternalPositionType() external view returns (uint256);
function getExternalPositionType() external view returns (uint256 typeId_);

function getVaultProxy() external view returns (address);
function getVaultProxy() external view returns (address vaultProxy_);

function receiveCallFromVault(bytes memory _data) external;
}
2 changes: 1 addition & 1 deletion contracts/release/core/fund/comptroller/ComptrollerLib.sol
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@ 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 {IExternalPosition} from "../../../extensions/external-position-manager/IExternalPosition.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";
Expand Down
2 changes: 1 addition & 1 deletion contracts/release/core/fund/vault/VaultLib.sol
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@ 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 {IExternalPosition} from "../../../extensions/external-position-manager/IExternalPosition.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";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,15 @@

pragma solidity 0.6.12;

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 {IExternalPosition} from "./IExternalPosition.sol";
import {IExternalPositionManager} from "./IExternalPositionManager.sol";
import {IExternalPositionParser} from "./IExternalPositionParser.sol";

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

pragma solidity >=0.6.0 <0.9.0;

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

/// @title IExternalPosition Contract
/// @author Enzyme Council <security@enzyme.finance>
interface IExternalPosition {
function getDebtAssets() external returns (address[] memory, uint256[] memory);

function getManagedAssets() external returns (address[] memory, uint256[] memory);
interface IExternalPosition is IExternalPositionLibCore {
function getDebtAssets() external returns (address[] memory assets_, uint256[] memory amounts_);

function init(bytes memory) external;
function getManagedAssets() external returns (address[] memory assets_, uint256[] memory amounts_);

function receiveCallFromVault(bytes memory) external;
function init(bytes memory _data) external;
}
Original file line number Diff line number Diff line change
Expand Up @@ -27,5 +27,5 @@ interface IExternalPositionManager {
ReactivateExternalPosition
}

function getExternalPositionLibForType(uint256) external view returns (address);
function getExternalPositionLibForType(uint256 _typeId) external view returns (address lib_);
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,9 @@ import {IAaveV2LendingPool} from "../../../../../external-interfaces/IAaveV2Lend
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 {AaveDebtPositionLibBase1} from "./bases/AaveDebtPositionLibBase1.sol";
import {AaveDebtPositionDataDecoder} from "./AaveDebtPositionDataDecoder.sol";
import {IAaveDebtPosition} from "./IAaveDebtPosition.sol";

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

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 {IExternalPositionParser} from "../../IExternalPositionParser.sol";
import {AaveDebtPositionDataDecoder} from "./AaveDebtPositionDataDecoder.sol";
import {IAaveDebtPosition} from "./IAaveDebtPosition.sol";

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 {IExternalPosition} from "../../../../../persistent/external-positions/IExternalPosition.sol";
import {IExternalPosition} from "../../IExternalPosition.sol";

pragma solidity >=0.6.0 <0.9.0;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,9 @@ import {IAaveAToken} from "../../../../../external-interfaces/IAaveAToken.sol";
import {IAaveV3Pool} from "../../../../../external-interfaces/IAaveV3Pool.sol";
import {IAaveV3PoolAddressProvider} from "../../../../../external-interfaces/IAaveV3PoolAddressProvider.sol";
import {IAaveV3ProtocolDataProvider} from "../../../../../external-interfaces/IAaveV3ProtocolDataProvider.sol";
import {AaveV3DebtPositionLibBase1} from
"../../../../../persistent/external-positions/aave-v3-debt/AaveV3DebtPositionLibBase1.sol";
import {AddressArrayLib} from "../../../../../utils/0.8.19/AddressArrayLib.sol";
import {AssetHelpers} from "../../../../../utils/0.8.19/AssetHelpers.sol";
import {AaveV3DebtPositionLibBase1} from "./bases/AaveV3DebtPositionLibBase1.sol";
import {AaveV3DebtPositionDataDecoder} from "./AaveV3DebtPositionDataDecoder.sol";
import {IAaveV3DebtPosition} from "./IAaveV3DebtPosition.sol";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import {ERC20} from "openzeppelin-solc-0.8/token/ERC20/ERC20.sol";
import {IAaveAToken} from "../../../../../external-interfaces/IAaveAToken.sol";
import {AddOnlyAddressListOwnerConsumerMixin} from
"../../../../../persistent/address-list-registry/address-list-owners/utils/0.8.19/AddOnlyAddressListOwnerConsumerMixin.sol";
import {IExternalPositionParser} from "../IExternalPositionParser.sol";
import {IExternalPositionParser} from "../../IExternalPositionParser.sol";
import {AaveV3DebtPositionDataDecoder} from "./AaveV3DebtPositionDataDecoder.sol";
import {IAaveV3DebtPosition} from "./IAaveV3DebtPosition.sol";

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 {IExternalPosition} from "../../../../../persistent/external-positions/IExternalPosition.sol";
import {IExternalPosition} from "../../IExternalPosition.sol";

pragma solidity 0.8.19;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,11 @@ import {ERC20} from "openzeppelin-solc-0.6/token/ERC20/ERC20.sol";
import {SafeERC20} from "openzeppelin-solc-0.6/token/ERC20/SafeERC20.sol";
import {SafeCast} from "openzeppelin-solc-0.6/utils/SafeCast.sol";
import {IWETH} from "../../../../../external-interfaces/IWETH.sol";
import {ArbitraryLoanPositionLibBase1} from
"../../../../../persistent/external-positions/arbitrary-loan/ArbitraryLoanPositionLibBase1.sol";
import {IExternalPositionProxy} from "../../../../../persistent/external-positions/IExternalPositionProxy.sol";
import {AddressArrayLib} from "../../../../../utils/0.6.12/AddressArrayLib.sol";
import {AssetHelpers} from "../../../../../utils/0.6.12/AssetHelpers.sol";
import {MathHelpers} from "../../../../../utils/0.6.12/MathHelpers.sol";
import {ArbitraryLoanPositionLibBase1} from "./bases/ArbitraryLoanPositionLibBase1.sol";
import {IArbitraryLoanAccountingModule} from "./modules/IArbitraryLoanAccountingModule.sol";
import {IArbitraryLoanPosition} from "./IArbitraryLoanPosition.sol";
import {ArbitraryLoanPositionDataDecoder} from "./ArbitraryLoanPositionDataDecoder.sol";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

import {ERC20} from "openzeppelin-solc-0.6/token/ERC20/ERC20.sol";
import {AddressArrayLib} from "../../../../../utils/0.6.12/AddressArrayLib.sol";
import {IExternalPositionParser} from "../IExternalPositionParser.sol";
import {IExternalPositionParser} from "../../IExternalPositionParser.sol";
import {IArbitraryLoanPosition} from "./IArbitraryLoanPosition.sol";
import {ArbitraryLoanPositionDataDecoder} from "./ArbitraryLoanPositionDataDecoder.sol";

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 {IExternalPosition} from "../../../../../persistent/external-positions/IExternalPosition.sol";
import {IExternalPosition} from "../../IExternalPosition.sol";

pragma solidity >=0.6.0 <0.9.0;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ pragma experimental ABIEncoderV2;

import {SafeMath} from "openzeppelin-solc-0.6/math/SafeMath.sol";
import {SignedSafeMath} from "openzeppelin-solc-0.6/math/SignedSafeMath.sol";
import {IArbitraryLoanAccountingModule} from "./IArbitraryLoanAccountingModule.sol";
import {IArbitraryValueOracle} from "../../../../../../persistent/arbitrary-value-oracles/IArbitraryValueOracle.sol";
import {IArbitraryLoanAccountingModule} from "./IArbitraryLoanAccountingModule.sol";

/// @title ArbitraryLoanTotalNominalDeltaOracleModule Contract
/// @author Enzyme Council <security@enzyme.finance>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,8 @@ import {ICERC20} from "../../../../../external-interfaces/ICERC20.sol";
import {ICEther} from "../../../../../external-interfaces/ICEther.sol";
import {ICompoundComptroller} from "../../../../../external-interfaces/ICompoundComptroller.sol";
import {IWETH} from "../../../../../external-interfaces/IWETH.sol";
import {CompoundDebtPositionLibBase1} from
"../../../../../persistent/external-positions/compound-debt/CompoundDebtPositionLibBase1.sol";
import {AddressArrayLib} from "../../../../../utils/0.6.12/AddressArrayLib.sol";
import {CompoundDebtPositionLibBase1} from "./bases/CompoundDebtPositionLibBase1.sol";
import {ICompoundDebtPosition} from "./ICompoundDebtPosition.sol";

/// @title CompoundDebtPositionLib Contract
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
import {ICERC20} from "../../../../../external-interfaces/ICERC20.sol";
import {CompoundPriceFeed} from "../../../../infrastructure/price-feeds/derivatives/feeds/CompoundPriceFeed.sol";
import {IValueInterpreter} from "../../../../infrastructure/value-interpreter/IValueInterpreter.sol";
import {IExternalPositionParser} from "../IExternalPositionParser.sol";
import {IExternalPositionParser} from "../../IExternalPositionParser.sol";
import {ICompoundDebtPosition} from "./ICompoundDebtPosition.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 {IExternalPosition} from "../../../../../persistent/external-positions/IExternalPosition.sol";
import {IExternalPosition} from "../../IExternalPosition.sol";

pragma solidity >=0.6.0 <0.9.0;

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

import {IExternalPositionParser} from "../IExternalPositionParser.sol";
import {IExternalPositionParser} from "../../IExternalPositionParser.sol";
import {ConvexVotingPositionDataDecoder} from "./ConvexVotingPositionDataDecoder.sol";
import {IConvexVotingPosition} from "./IConvexVotingPosition.sol";

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 {IExternalPosition} from "../../../../../persistent/external-positions/IExternalPosition.sol";
import {IExternalPosition} from "../../IExternalPosition.sol";

pragma solidity >=0.6.0 <0.9.0;

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 {IExternalPosition} from "../../../../../persistent/external-positions/IExternalPosition.sol";
import {IExternalPosition} from "../../IExternalPosition.sol";

pragma solidity >=0.6.0 <0.9.0;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,9 @@ pragma solidity 0.8.19;
import {ERC20} from "openzeppelin-solc-0.8/token/ERC20/ERC20.sol";
import {SafeERC20} from "openzeppelin-solc-0.8/token/ERC20/utils/SafeERC20.sol";
import {Math} from "openzeppelin-solc-0.8/utils/math/Math.sol";
import {KilnStakingPositionLibBase2} from
"../../../../../persistent/external-positions/kiln-staking/KilnStakingPositionLibBase2.sol";
import {IKilnStakingContract} from "../../../../../external-interfaces/IKilnStakingContract.sol";
import {IWETH} from "../../../../../external-interfaces/IWETH.sol";
import {KilnStakingPositionLibBase2} from "./bases/KilnStakingPositionLibBase2.sol";
import {IKilnStakingPosition} from "./IKilnStakingPosition.sol";
import {KilnStakingPositionDataDecoder} from "./KilnStakingPositionDataDecoder.sol";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
*/

import {IAddressListRegistry} from "../../../../../persistent/address-list-registry/IAddressListRegistry.sol";
import {IExternalPositionParser} from "../IExternalPositionParser.sol";
import {IExternalPositionParser} from "../../IExternalPositionParser.sol";
import {IKilnStakingPosition} from "./IKilnStakingPosition.sol";
import {KilnStakingPositionDataDecoder} from "./KilnStakingPositionDataDecoder.sol";

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

import {IExternalPosition} from "../../../../../persistent/external-positions/IExternalPosition.sol";
import {LidoWithdrawalsPositionLibBase1} from
"../../../../../persistent/external-positions/lido-withdrawals/LidoWithdrawalsPositionLibBase1.sol";
import {IExternalPosition} from "../../IExternalPosition.sol";
import {LidoWithdrawalsPositionLibBase1} from "./bases/LidoWithdrawalsPositionLibBase1.sol";

pragma solidity 0.8.19;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,7 @@ pragma solidity 0.8.19;

import {ERC20} from "openzeppelin-solc-0.8/token/ERC20/ERC20.sol";
import {ILidoWithdrawalQueue} from "../../../../../external-interfaces/ILidoWithdrawalQueue.sol";
import {LidoWithdrawalsPositionLibBase1} from
"../../../../../persistent/external-positions/lido-withdrawals/LidoWithdrawalsPositionLibBase1.sol";
import {LidoWithdrawalsPositionLibBase1} from "./bases/LidoWithdrawalsPositionLibBase1.sol";
import {ILidoWithdrawalsPosition} from "./ILidoWithdrawalsPosition.sol";
import {LidoWithdrawalsPositionDataDecoder} from "./LidoWithdrawalsPositionDataDecoder.sol";

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

import {IExternalPositionParser} from "../IExternalPositionParser.sol";
import {IExternalPositionParser} from "../../IExternalPositionParser.sol";
import {ILidoWithdrawalsPosition} from "./ILidoWithdrawalsPosition.sol";
import {LidoWithdrawalsPositionDataDecoder} from "./LidoWithdrawalsPositionDataDecoder.sol";

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 {IExternalPosition} from "../../../../../persistent/external-positions/IExternalPosition.sol";
import {IExternalPosition} from "../../IExternalPosition.sol";

pragma solidity >=0.6.0 <0.9.0;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
*/

import {ILiquityTroveManager} from "../../../../../external-interfaces/ILiquityTroveManager.sol";
import {IExternalPositionParser} from "../IExternalPositionParser.sol";
import {IExternalPositionParser} from "../../IExternalPositionParser.sol";
import {ILiquityDebtPosition} from "./ILiquityDebtPosition.sol";
import {LiquityDebtPositionDataDecoder} from "./LiquityDebtPositionDataDecoder.sol";

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 {IExternalPosition} from "../../../../../persistent/external-positions/IExternalPosition.sol";
import {IExternalPosition} from "../../IExternalPosition.sol";

pragma solidity >=0.6.0 <0.9.0;

Expand Down
Loading

0 comments on commit 32b84c8

Please sign in to comment.