Cryo Explorer Ethereum Mainnet

Address Contract Verified

Address 0xADF5A8DB090627b153Ef0c5726ccfdc1c7aED7bd
Balance 0 ETH
Nonce 1
Code Size 8417 bytes
Indexed Transactions 0
External Etherscan · Sourcify

Contract Bytecode

8417 bytes
0x608060405234801561001057600080fd5b50600436106101005760003560e01c806380d570631161009757806397c0ac871161006657806397c0ac8714610205578063ac2594561461020d578063bd8e959a14610215578063f067cc111461021d57610100565b806380d57063146101b7578063893d20e8146101ca5780638aa740b4146101d25780638af6d89e146101f257610100565b806346790346116100d3578063467903461461016957806348f35209146101895780634ed28b3f1461019c5780636ea21143146101af57610100565b80630442bad5146101055780631bee801e1461011a578063248a2aab1461012d57806345d582e714610156575b600080fd5b6101186101133660046118a9565b610230565b005b6101186101283660046118dc565b610511565b61014061013b36600461185c565b610529565b60405161014d9190611ed6565b60405180910390f35b61011861016436600461178a565b610547565b61017c61017736600461174e565b6107ea565b60405161014d9190611e35565b6101186101973660046117c4565b61080b565b6101186101aa3660046117c4565b6109d0565b61017c610ae9565b6101186101c53660046119a3565b610bd9565b61017c610c22565b6101e56101e036600461182c565b610c7d565b60405161014d9190611ec5565b6101e561020036600461174e565b610d1f565b61017c610d74565b61017c610d98565b610118610dbc565b61011861022b3660046117c4565b610dbe565b606061023c8585610c7d565b905080516000141561024e575061050b565b336001600160a01b03861614806102e65750846001600160a01b031663e7c456906040518163ffffffff1660e01b815260040160206040518083038186803b15801561029957600080fd5b505afa1580156102ad573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906102d1919061176c565b6001600160a01b0316336001600160a01b0316145b806103725750846001600160a01b031663b3fc38e96040518163ffffffff1660e01b815260040160206040518083038186803b15801561032557600080fd5b505afa158015610339573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061035d919061176c565b6001600160a01b0316336001600160a01b0316145b6103975760405162461bcd60e51b815260040161038e90611f15565b60405180910390fd5b60005b8151811015610508578181815181106103af57fe5b60200260200101516001600160a01b031663579be718878787876040518563ffffffff1660e01b81526004016103e89493929190611e8d565b602060405180830381600087803b15801561040257600080fd5b505af1158015610416573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061043a91906119c1565b82828151811061044657fe5b60200260200101516001600160a01b0316637998a1c46040518163ffffffff1660e01b815260040160006040518083038186803b15801561048657600080fd5b505afa15801561049a573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f191682016040526104c291908101906119df565b6040516020016104d29190611e17565b604051602081830303815290604052906104ff5760405162461bcd60e51b815260040161038e9190611ee4565b5060010161039a565b50505b50505050565b60405162461bcd60e51b815260040161038e90611f25565b600061053f826105398686610c7d565b90610f14565b949350505050565b81610551816107ea565b6001600160a01b031663893d20e86040518163ffffffff1660e01b815260040160206040518083038186803b15801561058957600080fd5b505afa15801561059d573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906105c1919061176c565b6001600160a01b03166105d2610f6a565b6001600160a01b0316146105f85760405162461bcd60e51b815260040161038e90611f65565b816001600160a01b0316631ef925786040518163ffffffff1660e01b815260040160206040518083038186803b15801561063157600080fd5b505afa158015610645573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061066991906119c1565b6106855760405162461bcd60e51b815260040161038e90611f45565b6060826001600160a01b031663cbf54bb26040518163ffffffff1660e01b815260040160006040518083038186803b1580156106c057600080fd5b505afa1580156106d4573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f191682016040526106fc919081019061196e565b905060005b81518110156107e3576001600160a01b03851660009081526001602052604081208351610772918791849087908790811061073857fe5b6020026020010151600981111561074b57fe5b600981111561075657fe5b8152602001908152602001600020610fae90919063ffffffff16565b905080156107da5782828151811061078657fe5b6020026020010151600981111561079957fe5b856001600160a01b0316876001600160a01b03167f672fd0d75642b1e8875f32a1c3f8197c03288c7215329c9a99336feafb801c0260405160405180910390a45b50600101610701565b5050505050565b6001600160a01b03808216600090815260208190526040902054165b919050565b83610815816107ea565b6001600160a01b031663893d20e86040518163ffffffff1660e01b815260040160206040518083038186803b15801561084d57600080fd5b505afa158015610861573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610885919061176c565b6001600160a01b0316610896610f6a565b6001600160a01b0316146108bc5760405162461bcd60e51b815260040161038e90611f65565b6060846001600160a01b031663cbf54bb26040518163ffffffff1660e01b815260040160006040518083038186803b1580156108f757600080fd5b505afa15801561090b573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f19168201604052610933919081019061196e565b905060005b81518110156109825761095d82828151811061095057fe5b60200260200101516110a6565b1561097a5760405162461bcd60e51b815260040161038e90611ef5565b600101610938565b506109c6868686868080601f0160208091040260200160405190810160405280939291908181526020018383808284376000920191909152508792506110d2915050565b610508868661125f565b836109da816107ea565b6001600160a01b031663893d20e86040518163ffffffff1660e01b815260040160206040518083038186803b158015610a1257600080fd5b505afa158015610a26573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610a4a919061176c565b6001600160a01b0316610a5b610f6a565b6001600160a01b031614610a815760405162461bcd60e51b815260040161038e90611f65565b60405162d4d75160e41b81526001600160a01b03851690630d4d751090610ab090889087908790600401611e43565b600060405180830381600087803b158015610aca57600080fd5b505af1158015610ade573d6000803e3d6000fd5b505050505050505050565b6000610af3610d98565b6001600160a01b03166398a7c4c76040518163ffffffff1660e01b815260040160206040518083038186803b158015610b2b57600080fd5b505afa158015610b3f573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610b63919061176c565b6001600160a01b0316637da0a8776040518163ffffffff1660e01b815260040160206040518083038186803b158015610b9b57600080fd5b505afa158015610baf573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610bd3919061176c565b90505b90565b338115610c1e576060610beb82610d1f565b905060005b815181101561050b57610c1683838381518110610c0957fe5b602002602001015161125f565b600101610bf0565b5050565b60007f0000000000000000000000004f1c53f096533c04d8157efb6bca3eb22ddc63606001600160a01b031663893d20e86040518163ffffffff1660e01b815260040160206040518083038186803b158015610b9b57600080fd5b6001600160a01b0382166000908152600160205260408120606091836009811115610ca457fe5b6009811115610caf57fe5b8152602001908152602001600020805480602002602001604051908101604052809291908181526020018280548015610d1157602002820191906000526020600020905b81546001600160a01b03168152600190910190602001808311610cf3575b505050505090505b92915050565b6060610d296114c1565b610d316112b9565b905060005b600a811015610d6d57610d63610d5c858484600a8110610d5257fe5b6020020151610c7d565b8490611316565b9250600101610d36565b5050919050565b7f0000000000000000000000004f1c53f096533c04d8157efb6bca3eb22ddc636090565b7f000000000000000000000000846bbe1925047023651de7ec289f329c24ded3a890565b565b610dc6610d74565b6001600160a01b0316336001600160a01b031614610df65760405162461bcd60e51b815260040161038e90611f35565b610e00848461146a565b80610e0a5761050b565b606080610e198385018561190f565b915091508051825114610e3e5760405162461bcd60e51b815260040161038e90611f05565b60005b8251811015610f0b57610f0387848381518110610e5a57fe5b6020026020010151848481518110610e6e57fe5b6020026020010151868581518110610e8257fe5b60200260200101516001600160a01b031663cbf54bb26040518163ffffffff1660e01b815260040160006040518083038186803b158015610ec257600080fd5b505afa158015610ed6573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f19168201604052610efe919081019061196e565b6110d2565b600101610e41565b50505050505050565b6000805b8351811015610f6057838181518110610f2d57fe5b60200260200101516001600160a01b0316836001600160a01b03161415610f58576001915050610d19565b600101610f18565b5060009392505050565b600060183610801590610f955750610f80610ae9565b6001600160a01b0316336001600160a01b0316145b15610fa9575060131936013560601c610bd6565b503390565b8154600090815b8181101561109e57836001600160a01b0316858281548110610fd357fe5b6000918252602090912001546001600160a01b0316141561109657600182038110156110615784600183038154811061100857fe5b9060005260206000200160009054906101000a90046001600160a01b031685828154811061103257fe5b9060005260206000200160006101000a8154816001600160a01b0302191690836001600160a01b031602179055505b8480548061106b57fe5b600082815260209020810160001990810180546001600160a01b03191690550190556001925061109e565b600101610fb5565b505092915050565b600060028260098111156110b657fe5b1480610d19575060038260098111156110cb57fe5b1492915050565b81511561113a57604051630f5f6b4f60e01b81526001600160a01b03841690630f5f6b4f906111079087908690600401611e6d565b600060405180830381600087803b15801561112157600080fd5b505af1158015611135573d6000803e3d6000fd5b505050505b60005b815181101561120d576111648583838151811061115657fe5b602002602001015186610529565b156111815760405162461bcd60e51b815260040161038e90611f55565b6001600160a01b038516600090815260016020526040812083519091908490849081106111aa57fe5b602002602001015160098111156111bd57fe5b60098111156111c857fe5b815260208082019290925260400160009081208054600180820183559183529290912090910180546001600160a01b0319166001600160a01b0387161790550161113d565b50826001600160a01b0316846001600160a01b03167faa4df4fe117c520783cfff01c11283496ff2999c77c2a9b800808251a9a0332a846040516112519190611ee4565b60405180910390a350505050565b60405163ceb9a0ad60e01b81526001600160a01b0382169063ceb9a0ad9061128b908590600401611e35565b600060405180830381600087803b1580156112a557600080fd5b505af1158015610508573d6000803e3d6000fd5b6112c16114c1565b6040805161014081019091528060008152602001600181526020016002815260200160038152602001600481526020016005815260200160068152602001600781526020016008815260200160099052905090565b60606000805b8351811015611355576113428585838151811061133557fe5b6020026020010151610f14565b61134d576001909101905b60010161131c565b50806113645783915050610d19565b8084510167ffffffffffffffff8111801561137e57600080fd5b506040519080825280602002602001820160405280156113a8578160200160208202803683370190505b50915060005b84518110156113f7578481815181106113c357fe5b60200260200101518382815181106113d757fe5b6001600160a01b03909216602092830291909101909101526001016113ae565b50835160005b8451811015611461576114168686838151811061133557fe5b6114595784818151811061142657fe5b602002602001015184838151811061143a57fe5b6001600160a01b03909216602092830291909101909101526001909101905b6001016113fd565b50505092915050565b6001600160a01b0382811660008181526020819052604080822080546001600160a01b0319169486169485179055517f8852dcaa71340ea616a65ffac013450dfb238607481fb9d78346c667fe256c139190a35050565b604051806101400160405280600a906020820280368337509192915050565b8035610d1981612078565b8051610d1981612078565b600082601f83011261150757600080fd5b813561151a61151582611f9c565b611f75565b9150818183526020840193506020810190508385602084028201111561153f57600080fd5b60005b8381101561156b578161155588826114e0565b8452506020928301929190910190600101611542565b5050505092915050565b600082601f83011261158657600080fd5b813561159461151582611f9c565b81815260209384019390925082018360005b8381101561156b57813586016115bc88826116a1565b84525060209283019291909101906001016115a6565b600082601f8301126115e357600080fd5b81516115f161151582611f9c565b9150818183526020840193506020810190508385602084028201111561161657600080fd5b60005b8381101561156b578161162c88826116f2565b8452506020928301929190910190600101611619565b8035610d198161208c565b8051610d198161208c565b60008083601f84011261166a57600080fd5b50813567ffffffffffffffff81111561168257600080fd5b60208301915083600182028301111561169a57600080fd5b9250929050565b600082601f8301126116b257600080fd5b81356116c061151582611fbd565b915080825260208301602083018583830111156116dc57600080fd5b611461838284612029565b8035610d1981612095565b8051610d1981612095565b600082601f83011261170e57600080fd5b815161171c61151582611fbd565b9150808252602083016020830185838301111561173857600080fd5b611461838284612035565b8035610d19816120a2565b60006020828403121561176057600080fd5b600061053f84846114e0565b60006020828403121561177e57600080fd5b600061053f84846114eb565b6000806040838503121561179d57600080fd5b60006117a985856114e0565b92505060206117ba858286016114e0565b9150509250929050565b600080600080606085870312156117da57600080fd5b60006117e687876114e0565b94505060206117f7878288016114e0565b935050604085013567ffffffffffffffff81111561181457600080fd5b61182087828801611658565b95989497509550505050565b6000806040838503121561183f57600080fd5b600061184b85856114e0565b92505060206117ba858286016116e7565b60008060006060848603121561187157600080fd5b600061187d86866114e0565b935050602061188e868287016116e7565b925050604061189f868287016114e0565b9150509250925092565b600080600080606085870312156118bf57600080fd5b60006118cb87876114e0565b94505060206117f7878288016116e7565b600080600080606085870312156118f257600080fd5b60006118fe87876114e0565b94505060206117f787828801611743565b6000806040838503121561192257600080fd5b823567ffffffffffffffff81111561193957600080fd5b611945858286016114f6565b925050602083013567ffffffffffffffff81111561196257600080fd5b6117ba85828601611575565b60006020828403121561198057600080fd5b815167ffffffffffffffff81111561199757600080fd5b61053f848285016115d2565b6000602082840312156119b557600080fd5b600061053f8484611642565b6000602082840312156119d357600080fd5b600061053f848461164d565b6000602082840312156119f157600080fd5b815167ffffffffffffffff811115611a0857600080fd5b61053f848285016116fd565b6000611a208383611a28565b505060200190565b611a3181611ff8565b82525050565b6000611a4282611feb565b611a4c8185611fef565b9350611a5783611fe5565b8060005b83811015611a85578151611a6f8882611a14565b9750611a7a83611fe5565b925050600101611a5b565b509495945050505050565b611a3181612003565b6000611aa58385611fef565b9350611ab2838584612029565b611abb83612061565b9093019392505050565b6000611ad082611feb565b611ada8185611fef565b9350611aea818560208601612035565b611abb81612061565b611a318161201e565b6000611b0782611feb565b611b118185610806565b9350611b21818560208601612035565b9290920192915050565b6000611b38604383611fef565b7f656e61626c65506f6c696379466f7246756e643a205f706f6c6963792072657381527f74726963747320616374696f6e73206f662063757272656e7420696e766573746020820152626f727360e81b604082015260600192915050565b6000611ba3604183611fef565b7f736574436f6e666967466f7246756e643a20706f6c696369657320616e64207381527f657474696e677344617461206172726179206c656e6774687320756e657175616020820152601b60fa1b604082015260600192915050565b6000611c0c601983610806565b7f52756c65206576616c756174656420746f2066616c73653a2000000000000000815260190192915050565b6000611c45602483611fef565b7f76616c6964617465506f6c69636965733a2043616c6c6572206e6f7420616c6c8152631bddd95960e21b602082015260400192915050565b6000611c8b603783611fef565b7f7265636569766543616c6c46726f6d436f6d7074726f6c6c65723a20556e696d81527f706c656d656e74656420666f7220457874656e73696f6e000000000000000000602082015260400192915050565b6000611cea602883611fef565b7f4f6e6c79207468652046756e644465706c6f7965722063616e206d616b6520748152671a1a5cc818d85b1b60c21b602082015260400192915050565b6000611d34603083611fef565b7f64697361626c65506f6c696379466f7246756e643a205f706f6c69637920636181526f1b9b9bdd08189948191a5cd8589b195960821b602082015260400192915050565b6000611d86603083611fef565b7f5f5f656e61626c65506f6c696379466f7246756e643a20506f6c69637920697381526f08185b1c9958591e48195b98589b195960821b602082015260400192915050565b6000611dd8602a83611fef565b7f4f6e6c79207468652066756e64206f776e65722063616e2063616c6c207468698152693990333ab731ba34b7b760b11b602082015260400192915050565b6000611e2282611bff565b9150611e2e8284611afc565b9392505050565b60208101610d198284611a28565b60408101611e518286611a28565b8181036020830152611e64818486611a99565b95945050505050565b60408101611e7b8285611a28565b818103602083015261053f8184611ac5565b60608101611e9b8287611a28565b611ea86020830186611af3565b8181036040830152611ebb818486611a99565b9695505050505050565b60208082528101611e2e8184611a37565b60208101610d198284611a90565b60208082528101611e2e8184611ac5565b60208082528101610d1981611b2b565b60208082528101610d1981611b96565b60208082528101610d1981611c38565b60208082528101610d1981611c7e565b60208082528101610d1981611cdd565b60208082528101610d1981611d27565b60208082528101610d1981611d79565b60208082528101610d1981611dcb565b60405181810167ffffffffffffffff81118282101715611f9457600080fd5b604052919050565b600067ffffffffffffffff821115611fb357600080fd5b5060209081020190565b600067ffffffffffffffff821115611fd457600080fd5b506020601f91909101601f19160190565b60200190565b5190565b90815260200190565b6000610d1982612012565b151590565b806108068161206b565b6001600160a01b031690565b6000610d1982612008565b82818337506000910152565b60005b83811015612050578181015183820152602001612038565b8381111561050b5750506000910152565b601f01601f191690565b600a811061207557fe5b50565b61208181611ff8565b811461207557600080fd5b61208181612003565b600a811061207557600080fd5b61208181610bd656fea26469706673582212205246047eec4c50797fba8ac9e1bc1996a55dfb613e9664ec7cbb4cbdb516594d64736f6c634300060c0033

Verified Source Code Full Match

Compiler: v0.6.12+commit.27d51765 EVM: istanbul
IGsnTypes.sol 35 lines
// SPDX-License-Identifier: GPL-3.0

/*
    This file is part of the Enzyme Protocol.

    (c) Enzyme Council <[email protected]>

    For the full license information, please view the LICENSE
    file that was distributed with this source code.
*/

pragma solidity 0.6.12;
pragma experimental ABIEncoderV2;

import "./IGsnForwarder.sol";

/// @title IGsnTypes Interface
/// @author Enzyme Council <[email protected]>
interface IGsnTypes {
    struct RelayData {
        uint256 gasPrice;
        uint256 pctRelayFee;
        uint256 baseRelayFee;
        address relayWorker;
        address paymaster;
        address forwarder;
        bytes paymasterData;
        uint256 clientId;
    }

    struct RelayRequest {
        IGsnForwarder.ForwardRequest request;
        RelayData relayData;
    }
}
IExtension.sol 33 lines
// SPDX-License-Identifier: GPL-3.0

/*
    This file is part of the Enzyme Protocol.

    (c) Enzyme Council <[email protected]>

    For the full license information, please view the LICENSE
    file that was distributed with this source code.
*/

pragma solidity 0.6.12;

/// @title IExtension Interface
/// @author Enzyme Council <[email protected]>
/// @notice Interface for all extensions
interface IExtension {
    function activateForFund(bool _isMigration) external;

    function deactivateForFund() external;

    function receiveCallFromComptroller(
        address _caller,
        uint256 _actionId,
        bytes calldata _callArgs
    ) external;

    function setConfigForFund(
        address _comptrollerProxy,
        address _vaultProxy,
        bytes calldata _configData
    ) external;
}
AddressArrayLib.sol 176 lines
// SPDX-License-Identifier: GPL-3.0

/*
    This file is part of the Enzyme Protocol.

    (c) Enzyme Council <[email protected]>

    For the full license information, please view the LICENSE
    file that was distributed with this source code.
*/

pragma solidity 0.6.12;

/// @title AddressArray Library
/// @author Enzyme Council <[email protected]>
/// @notice A library to extend the address array data type
library AddressArrayLib {
    /////////////
    // STORAGE //
    /////////////

    /// @dev Helper to remove an item from a storage array
    function removeStorageItem(address[] storage _self, address _itemToRemove)
        internal
        returns (bool removed_)
    {
        uint256 itemCount = _self.length;
        for (uint256 i; i < itemCount; i++) {
            if (_self[i] == _itemToRemove) {
                if (i < itemCount - 1) {
                    _self[i] = _self[itemCount - 1];
                }
                _self.pop();
                removed_ = true;
                break;
            }
        }

        return removed_;
    }

    ////////////
    // MEMORY //
    ////////////

    /// @dev Helper to add an item to an array. Does not assert uniqueness of the new item.
    function addItem(address[] memory _self, address _itemToAdd)
        internal
        pure
        returns (address[] memory nextArray_)
    {
        nextArray_ = new address[](_self.length + 1);
        for (uint256 i; i < _self.length; i++) {
            nextArray_[i] = _self[i];
        }
        nextArray_[_self.length] = _itemToAdd;

        return nextArray_;
    }

    /// @dev Helper to add an item to an array, only if it is not already in the array.
    function addUniqueItem(address[] memory _self, address _itemToAdd)
        internal
        pure
        returns (address[] memory nextArray_)
    {
        if (contains(_self, _itemToAdd)) {
            return _self;
        }

        return addItem(_self, _itemToAdd);
    }

    /// @dev Helper to verify if an array contains a particular value
    function contains(address[] memory _self, address _target)
        internal
        pure
        returns (bool doesContain_)
    {
        for (uint256 i; i < _self.length; i++) {
            if (_target == _self[i]) {
                return true;
            }
        }
        return false;
    }

    /// @dev Helper to merge the unique items of a second array.
    /// Does not consider uniqueness of either array, only relative uniqueness.
    /// Preserves ordering.
    function mergeArray(address[] memory _self, address[] memory _arrayToMerge)
        internal
        pure
        returns (address[] memory nextArray_)
    {
        uint256 newUniqueItemCount;
        for (uint256 i; i < _arrayToMerge.length; i++) {
            if (!contains(_self, _arrayToMerge[i])) {
                newUniqueItemCount++;
            }
        }

        if (newUniqueItemCount == 0) {
            return _self;
        }

        nextArray_ = new address[](_self.length + newUniqueItemCount);
        for (uint256 i; i < _self.length; i++) {
            nextArray_[i] = _self[i];
        }
        uint256 nextArrayIndex = _self.length;
        for (uint256 i; i < _arrayToMerge.length; i++) {
            if (!contains(_self, _arrayToMerge[i])) {
                nextArray_[nextArrayIndex] = _arrayToMerge[i];
                nextArrayIndex++;
            }
        }

        return nextArray_;
    }

    /// @dev Helper to verify if array is a set of unique values.
    /// Does not assert length > 0.
    function isUniqueSet(address[] memory _self) internal pure returns (bool isUnique_) {
        if (_self.length <= 1) {
            return true;
        }

        uint256 arrayLength = _self.length;
        for (uint256 i; i < arrayLength; i++) {
            for (uint256 j = i + 1; j < arrayLength; j++) {
                if (_self[i] == _self[j]) {
                    return false;
                }
            }
        }

        return true;
    }

    /// @dev Helper to remove items from an array. Removes all matching occurrences of each item.
    /// Does not assert uniqueness of either array.
    function removeItems(address[] memory _self, address[] memory _itemsToRemove)
        internal
        pure
        returns (address[] memory nextArray_)
    {
        if (_itemsToRemove.length == 0) {
            return _self;
        }

        bool[] memory indexesToRemove = new bool[](_self.length);
        uint256 remainingItemsCount = _self.length;
        for (uint256 i; i < _self.length; i++) {
            if (contains(_itemsToRemove, _self[i])) {
                indexesToRemove[i] = true;
                remainingItemsCount--;
            }
        }

        if (remainingItemsCount == _self.length) {
            nextArray_ = _self;
        } else if (remainingItemsCount > 0) {
            nextArray_ = new address[](remainingItemsCount);
            uint256 nextArrayIndex;
            for (uint256 i; i < _self.length; i++) {
                if (!indexesToRemove[i]) {
                    nextArray_[nextArrayIndex] = _self[i];
                    nextArrayIndex++;
                }
            }
        }

        return nextArray_;
    }
}
IVault.sol 87 lines
// SPDX-License-Identifier: GPL-3.0

/*
    This file is part of the Enzyme Protocol.

    (c) Enzyme Council <[email protected]>

    For the full license information, please view the LICENSE
    file that was distributed with this source code.
*/

pragma solidity 0.6.12;

import "../../../../persistent/vault/interfaces/IExternalPositionVault.sol";
import "../../../../persistent/vault/interfaces/IFreelyTransferableSharesVault.sol";
import "../../../../persistent/vault/interfaces/IMigratableVault.sol";

/// @title IVault Interface
/// @author Enzyme Council <[email protected]>
interface IVault is IMigratableVault, IFreelyTransferableSharesVault, IExternalPositionVault {
    enum VaultAction {
        None,
        // Shares management
        BurnShares,
        MintShares,
        TransferShares,
        // Asset management
        AddTrackedAsset,
        ApproveAssetSpender,
        RemoveTrackedAsset,
        WithdrawAssetTo,
        // External position management
        AddExternalPosition,
        CallOnExternalPosition,
        RemoveExternalPosition
    }

    function addTrackedAsset(address) external;

    function burnShares(address, uint256) external;

    function buyBackProtocolFeeShares(
        uint256,
        uint256,
        uint256
    ) external;

    function callOnContract(address, bytes calldata) external returns (bytes memory);

    function canManageAssets(address) external view returns (bool);

    function canRelayCalls(address) external view returns (bool);

    function getAccessor() external view returns (address);

    function getOwner() external view returns (address);

    function getActiveExternalPositions() external view returns (address[] memory);

    function getTrackedAssets() external view returns (address[] memory);

    function isActiveExternalPosition(address) external view returns (bool);

    function isTrackedAsset(address) external view returns (bool);

    function mintShares(address, uint256) external;

    function payProtocolFee() external;

    function receiveValidatedVaultAction(VaultAction, bytes calldata) external;

    function setAccessorForFundReconfiguration(address) external;

    function setSymbol(string calldata) external;

    function transferShares(
        address,
        address,
        uint256
    ) external;

    function withdrawAssetTo(
        address,
        address,
        uint256
    ) external;
}
IGsnForwarder.sol 26 lines
// SPDX-License-Identifier: GPL-3.0

/*
    This file is part of the Enzyme Protocol.

    (c) Enzyme Council <[email protected]>

    For the full license information, please view the LICENSE
    file that was distributed with this source code.
*/

pragma solidity 0.6.12;

/// @title IGsnForwarder interface
/// @author Enzyme Council <[email protected]>
interface IGsnForwarder {
    struct ForwardRequest {
        address from;
        address to;
        uint256 value;
        uint256 gas;
        uint256 nonce;
        bytes data;
        uint256 validUntil;
    }
}
IGsnPaymaster.sol 50 lines
// SPDX-License-Identifier: GPL-3.0

/*
    This file is part of the Enzyme Protocol.

    (c) Enzyme Council <[email protected]>

    For the full license information, please view the LICENSE
    file that was distributed with this source code.
*/

pragma solidity 0.6.12;
pragma experimental ABIEncoderV2;

import "./IGsnTypes.sol";

/// @title IGsnPaymaster interface
/// @author Enzyme Council <[email protected]>
interface IGsnPaymaster {
    struct GasAndDataLimits {
        uint256 acceptanceBudget;
        uint256 preRelayedCallGasLimit;
        uint256 postRelayedCallGasLimit;
        uint256 calldataSizeLimit;
    }

    function getGasAndDataLimits() external view returns (GasAndDataLimits memory limits);

    function getHubAddr() external view returns (address);

    function getRelayHubDeposit() external view returns (uint256);

    function preRelayedCall(
        IGsnTypes.RelayRequest calldata relayRequest,
        bytes calldata signature,
        bytes calldata approvalData,
        uint256 maxPossibleGas
    ) external returns (bytes memory context, bool rejectOnRecipientRevert);

    function postRelayedCall(
        bytes calldata context,
        bool success,
        uint256 gasUseWithoutPost,
        IGsnTypes.RelayData calldata relayData
    ) external;

    function trustedForwarder() external view returns (address);

    function versionPaymaster() external view returns (string memory);
}
IBeacon.sol 18 lines
// SPDX-License-Identifier: GPL-3.0

/*
    This file is part of the Enzyme Protocol.

    (c) Enzyme Council <[email protected]>

    For the full license information, please view the LICENSE
    file that was distributed with this source code.
*/

pragma solidity 0.6.12;

/// @title IBeacon interface
/// @author Enzyme Council <[email protected]>
interface IBeacon {
    function getCanonicalLib() external view returns (address);
}
FundDeployerOwnerMixin.sol 50 lines
// SPDX-License-Identifier: GPL-3.0

/*
    This file is part of the Enzyme Protocol.

    (c) Enzyme Council <[email protected]>

    For the full license information, please view the LICENSE
    file that was distributed with this source code.
*/

pragma solidity 0.6.12;

import "../core/fund-deployer/IFundDeployer.sol";

/// @title FundDeployerOwnerMixin Contract
/// @author Enzyme Council <[email protected]>
/// @notice A mixin contract that defers ownership to the owner of FundDeployer
abstract contract FundDeployerOwnerMixin {
    address internal immutable FUND_DEPLOYER;

    modifier onlyFundDeployerOwner() {
        require(
            msg.sender == getOwner(),
            "onlyFundDeployerOwner: Only the FundDeployer owner can call this function"
        );
        _;
    }

    constructor(address _fundDeployer) public {
        FUND_DEPLOYER = _fundDeployer;
    }

    /// @notice Gets the owner of this contract
    /// @return owner_ The owner
    /// @dev Ownership is deferred to the owner of the FundDeployer contract
    function getOwner() public view returns (address owner_) {
        return IFundDeployer(FUND_DEPLOYER).getOwner();
    }

    ///////////////////
    // STATE GETTERS //
    ///////////////////

    /// @notice Gets the `FUND_DEPLOYER` variable
    /// @return fundDeployer_ The `FUND_DEPLOYER` variable value
    function getFundDeployer() public view returns (address fundDeployer_) {
        return FUND_DEPLOYER;
    }
}
ExtensionBase.sol 89 lines
// SPDX-License-Identifier: GPL-3.0

/*
    This file is part of the Enzyme Protocol.

    (c) Enzyme Council <[email protected]>

    For the full license information, please view the LICENSE
    file that was distributed with this source code.
*/

pragma solidity 0.6.12;

import "../../utils/FundDeployerOwnerMixin.sol";
import "../IExtension.sol";

/// @title ExtensionBase Contract
/// @author Enzyme Council <[email protected]>
/// @notice Base class for an extension
abstract contract ExtensionBase is IExtension, FundDeployerOwnerMixin {
    event ValidatedVaultProxySetForFund(
        address indexed comptrollerProxy,
        address indexed vaultProxy
    );

    mapping(address => address) internal comptrollerProxyToVaultProxy;

    modifier onlyFundDeployer() {
        require(msg.sender == getFundDeployer(), "Only the FundDeployer can make this call");
        _;
    }

    constructor(address _fundDeployer) public FundDeployerOwnerMixin(_fundDeployer) {}

    /// @notice Allows extension to run logic during fund activation
    /// @dev Unimplemented by default, may be overridden.
    function activateForFund(bool) external virtual override {
        return;
    }

    /// @notice Allows extension to run logic during fund deactivation (destruct)
    /// @dev Unimplemented by default, may be overridden.
    function deactivateForFund() external virtual override {
        return;
    }

    /// @notice Receives calls from ComptrollerLib.callOnExtension()
    /// and dispatches the appropriate action
    /// @dev Unimplemented by default, may be overridden.
    function receiveCallFromComptroller(
        address,
        uint256,
        bytes calldata
    ) external virtual override {
        revert("receiveCallFromComptroller: Unimplemented for Extension");
    }

    /// @notice Allows extension to run logic during fund configuration
    /// @dev Unimplemented by default, may be overridden.
    function setConfigForFund(
        address,
        address,
        bytes calldata
    ) external virtual override {
        return;
    }

    /// @dev Helper to store the validated ComptrollerProxy-VaultProxy relation
    function __setValidatedVaultProxy(address _comptrollerProxy, address _vaultProxy) internal {
        comptrollerProxyToVaultProxy[_comptrollerProxy] = _vaultProxy;

        emit ValidatedVaultProxySetForFund(_comptrollerProxy, _vaultProxy);
    }

    ///////////////////
    // STATE GETTERS //
    ///////////////////

    /// @notice Gets the verified VaultProxy for a given ComptrollerProxy
    /// @param _comptrollerProxy The ComptrollerProxy of the fund
    /// @return vaultProxy_ The VaultProxy of the fund
    function getVaultProxyForFund(address _comptrollerProxy)
        public
        view
        returns (address vaultProxy_)
    {
        return comptrollerProxyToVaultProxy[_comptrollerProxy];
    }
}
IFundDeployer.sol 28 lines
// SPDX-License-Identifier: GPL-3.0

/*
    This file is part of the Enzyme Protocol.

    (c) Enzyme Council <[email protected]>

    For the full license information, please view the LICENSE
    file that was distributed with this source code.
*/

pragma solidity 0.6.12;

/// @title IFundDeployer Interface
/// @author Enzyme Council <[email protected]>
interface IFundDeployer {
    function getOwner() external view returns (address);

    function hasReconfigurationRequest(address) external view returns (bool);

    function isAllowedBuySharesOnBehalfCaller(address) external view returns (bool);

    function isAllowedVaultCall(
        address,
        bytes4,
        bytes32
    ) external view returns (bool);
}
IPolicy.sol 40 lines
// SPDX-License-Identifier: GPL-3.0

/*
    This file is part of the Enzyme Protocol.

    (c) Enzyme Council <[email protected]>

    For the full license information, please view the LICENSE
    file that was distributed with this source code.
*/

pragma solidity 0.6.12;

import "./IPolicyManager.sol";

/// @title Policy Interface
/// @author Enzyme Council <[email protected]>
interface IPolicy {
    function activateForFund(address _comptrollerProxy) external;

    function addFundSettings(address _comptrollerProxy, bytes calldata _encodedSettings) external;

    function canDisable() external pure returns (bool canDisable_);

    function identifier() external pure returns (string memory identifier_);

    function implementedHooks()
        external
        pure
        returns (IPolicyManager.PolicyHook[] memory implementedHooks_);

    function updateFundSettings(address _comptrollerProxy, bytes calldata _encodedSettings)
        external;

    function validateRule(
        address _comptrollerProxy,
        IPolicyManager.PolicyHook _hook,
        bytes calldata _encodedArgs
    ) external returns (bool isValid_);
}
IComptroller.sol 66 lines
// SPDX-License-Identifier: GPL-3.0

/*
    This file is part of the Enzyme Protocol.

    (c) Enzyme Council <[email protected]>

    For the full license information, please view the LICENSE
    file that was distributed with this source code.
*/

pragma solidity 0.6.12;

import "../vault/IVault.sol";

/// @title IComptroller Interface
/// @author Enzyme Council <[email protected]>
interface IComptroller {
    function activate(bool) external;

    function calcGav() external returns (uint256);

    function calcGrossShareValue() external returns (uint256);

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

    function destructActivated(uint256, uint256) external;

    function destructUnactivated() external;

    function getDenominationAsset() external view returns (address);

    function getExternalPositionManager() external view returns (address);

    function getFeeManager() external view returns (address);

    function getFundDeployer() external view returns (address);

    function getGasRelayPaymaster() external view returns (address);

    function getIntegrationManager() external view returns (address);

    function getPolicyManager() external view returns (address);

    function getVaultProxy() external view returns (address);

    function init(address, uint256) external;

    function permissionedVaultAction(IVault.VaultAction, bytes calldata) external;

    function preTransferSharesHook(
        address,
        address,
        uint256
    ) external;

    function preTransferSharesHookFreelyTransferable(address) external view;

    function setGasRelayPaymaster(address) external;

    function setVaultProxy(address) external;
}
IMigratableVault.sol 29 lines
// SPDX-License-Identifier: GPL-3.0

/*
    This file is part of the Enzyme Protocol.

    (c) Enzyme Council <[email protected]>

    For the full license information, please view the LICENSE
    file that was distributed with this source code.
*/

pragma solidity 0.6.12;

/// @title IMigratableVault Interface
/// @author Enzyme Council <[email protected]>
/// @dev DO NOT EDIT CONTRACT
interface IMigratableVault {
    function canMigrate(address _who) external view returns (bool canMigrate_);

    function init(
        address _owner,
        address _accessor,
        string calldata _fundName
    ) external;

    function setAccessor(address _nextAccessor) external;

    function setVaultLib(address _nextVaultLib) external;
}
IBeaconProxyFactory.sol 22 lines
// SPDX-License-Identifier: GPL-3.0

/*
    This file is part of the Enzyme Protocol.

    (c) Enzyme Council <[email protected]>

    For the full license information, please view the LICENSE
    file that was distributed with this source code.
*/

import "./IBeacon.sol";

pragma solidity 0.6.12;

/// @title IBeaconProxyFactory interface
/// @author Enzyme Council <[email protected]>
interface IBeaconProxyFactory is IBeacon {
    function deployProxy(bytes memory _constructData) external returns (address proxy_);

    function setCanonicalLib(address _canonicalLib) external;
}
PolicyManager.sol 326 lines
// SPDX-License-Identifier: GPL-3.0

/*
    This file is part of the Enzyme Protocol.

    (c) Enzyme Council <[email protected]>

    For the full license information, please view the LICENSE
    file that was distributed with this source code.
*/

pragma solidity 0.6.12;
pragma experimental ABIEncoderV2;

import "../../core/fund/comptroller/IComptroller.sol";
import "../../core/fund/vault/IVault.sol";
import "../../infrastructure/gas-relayer/GasRelayRecipientMixin.sol";
import "../../utils/AddressArrayLib.sol";
import "../utils/ExtensionBase.sol";
import "./IPolicy.sol";
import "./IPolicyManager.sol";

/// @title PolicyManager Contract
/// @author Enzyme Council <[email protected]>
/// @notice Manages policies for funds
/// @dev Any arbitrary fee is allowed by default, so all participants must be aware of
/// their fund's configuration, especially whether they use official policies only.
/// Policies that restrict current investors can only be added upon fund setup, migration, or reconfiguration.
/// Policies that restrict new investors or asset management actions can be added at any time.
/// Policies themselves specify whether or not they are allowed to be updated or removed.
contract PolicyManager is IPolicyManager, ExtensionBase, GasRelayRecipientMixin {
    using AddressArrayLib for address[];

    event PolicyDisabledOnHookForFund(
        address indexed comptrollerProxy,
        address indexed policy,
        PolicyHook indexed hook
    );

    event PolicyEnabledForFund(
        address indexed comptrollerProxy,
        address indexed policy,
        bytes settingsData
    );

    uint256 private constant POLICY_HOOK_COUNT = 10;

    mapping(address => mapping(PolicyHook => address[])) private comptrollerProxyToHookToPolicies;

    modifier onlyFundOwner(address _comptrollerProxy) {
        require(
            __msgSender() == IVault(getVaultProxyForFund(_comptrollerProxy)).getOwner(),
            "Only the fund owner can call this function"
        );
        _;
    }

    constructor(address _fundDeployer, address _gasRelayPaymasterFactory)
        public
        ExtensionBase(_fundDeployer)
        GasRelayRecipientMixin(_gasRelayPaymasterFactory)
    {}

    // EXTERNAL FUNCTIONS

    /// @notice Validates and initializes policies as necessary prior to fund activation
    /// @param _isMigratedFund True if the fund is migrating to this release
    /// @dev There will be no enabledPolicies if the caller is not a valid ComptrollerProxy
    function activateForFund(bool _isMigratedFund) external override {
        address comptrollerProxy = msg.sender;

        // Policies must assert that they are congruent with migrated vault state
        if (_isMigratedFund) {
            address[] memory enabledPolicies = getEnabledPoliciesForFund(comptrollerProxy);
            for (uint256 i; i < enabledPolicies.length; i++) {
                __activatePolicyForFund(comptrollerProxy, enabledPolicies[i]);
            }
        }
    }

    /// @notice Disables a policy for a fund
    /// @param _comptrollerProxy The ComptrollerProxy of the fund
    /// @param _policy The policy address to disable
    /// @dev If an arbitrary policy changes its `implementedHooks()` return values after it is
    /// already enabled on a fund, then this will not correctly disable the policy from any
    /// removed hook values.
    function disablePolicyForFund(address _comptrollerProxy, address _policy)
        external
        onlyFundOwner(_comptrollerProxy)
    {
        require(IPolicy(_policy).canDisable(), "disablePolicyForFund: _policy cannot be disabled");

        PolicyHook[] memory implementedHooks = IPolicy(_policy).implementedHooks();
        for (uint256 i; i < implementedHooks.length; i++) {

                bool disabled
             = comptrollerProxyToHookToPolicies[_comptrollerProxy][implementedHooks[i]]
                .removeStorageItem(_policy);
            if (disabled) {
                emit PolicyDisabledOnHookForFund(_comptrollerProxy, _policy, implementedHooks[i]);
            }
        }
    }

    /// @notice Enables a policy for a fund
    /// @param _comptrollerProxy The ComptrollerProxy of the fund
    /// @param _policy The policy address to enable
    /// @param _settingsData The encoded settings data with which to configure the policy
    /// @dev Disabling a policy does not delete fund config on the policy, so if a policy is
    /// disabled and then enabled again, its initial state will be the previous config. It is the
    /// policy's job to determine how to merge that config with the _settingsData param in this function.
    function enablePolicyForFund(
        address _comptrollerProxy,
        address _policy,
        bytes calldata _settingsData
    ) external onlyFundOwner(_comptrollerProxy) {
        PolicyHook[] memory implementedHooks = IPolicy(_policy).implementedHooks();
        for (uint256 i; i < implementedHooks.length; i++) {
            require(
                !__policyHookRestrictsCurrentInvestorActions(implementedHooks[i]),
                "enablePolicyForFund: _policy restricts actions of current investors"
            );
        }

        __enablePolicyForFund(_comptrollerProxy, _policy, _settingsData, implementedHooks);

        __activatePolicyForFund(_comptrollerProxy, _policy);
    }

    /// @notice Enable policies for use in a fund
    /// @param _comptrollerProxy The ComptrollerProxy of the fund
    /// @param _vaultProxy The VaultProxy of the fund
    /// @param _configData Encoded config data
    function setConfigForFund(
        address _comptrollerProxy,
        address _vaultProxy,
        bytes calldata _configData
    ) external override onlyFundDeployer {
        __setValidatedVaultProxy(_comptrollerProxy, _vaultProxy);

        // In case there are no policies yet
        if (_configData.length == 0) {
            return;
        }

        (address[] memory policies, bytes[] memory settingsData) = abi.decode(
            _configData,
            (address[], bytes[])
        );

        // Sanity check
        require(
            policies.length == settingsData.length,
            "setConfigForFund: policies and settingsData array lengths unequal"
        );

        // Enable each policy with settings
        for (uint256 i; i < policies.length; i++) {
            __enablePolicyForFund(
                _comptrollerProxy,
                policies[i],
                settingsData[i],
                IPolicy(policies[i]).implementedHooks()
            );
        }
    }

    /// @notice Updates policy settings for a fund
    /// @param _comptrollerProxy The ComptrollerProxy of the fund
    /// @param _policy The Policy contract to update
    /// @param _settingsData The encoded settings data with which to update the policy config
    function updatePolicySettingsForFund(
        address _comptrollerProxy,
        address _policy,
        bytes calldata _settingsData
    ) external onlyFundOwner(_comptrollerProxy) {
        IPolicy(_policy).updateFundSettings(_comptrollerProxy, _settingsData);
    }

    /// @notice Validates all policies that apply to a given hook for a fund
    /// @param _comptrollerProxy The ComptrollerProxy of the fund
    /// @param _hook The PolicyHook for which to validate policies
    /// @param _validationData The encoded data with which to validate the filtered policies
    function validatePolicies(
        address _comptrollerProxy,
        PolicyHook _hook,
        bytes calldata _validationData
    ) external override {
        // Return as quickly as possible if no policies to run
        address[] memory policies = getEnabledPoliciesOnHookForFund(_comptrollerProxy, _hook);
        if (policies.length == 0) {
            return;
        }

        // Limit calls to trusted components, in case policies update local storage upon runs
        require(
            msg.sender == _comptrollerProxy ||
                msg.sender == IComptroller(_comptrollerProxy).getIntegrationManager() ||
                msg.sender == IComptroller(_comptrollerProxy).getExternalPositionManager(),
            "validatePolicies: Caller not allowed"
        );

        for (uint256 i; i < policies.length; i++) {
            require(
                IPolicy(policies[i]).validateRule(_comptrollerProxy, _hook, _validationData),
                string(
                    abi.encodePacked(
                        "Rule evaluated to false: ",
                        IPolicy(policies[i]).identifier()
                    )
                )
            );
        }
    }

    // PRIVATE FUNCTIONS

    /// @dev Helper to activate a policy for a fund
    function __activatePolicyForFund(address _comptrollerProxy, address _policy) private {
        IPolicy(_policy).activateForFund(_comptrollerProxy);
    }

    /// @dev Helper to set config and enable policies for a fund
    function __enablePolicyForFund(
        address _comptrollerProxy,
        address _policy,
        bytes memory _settingsData,
        PolicyHook[] memory _hooks
    ) private {
        // Set fund config on policy
        if (_settingsData.length > 0) {
            IPolicy(_policy).addFundSettings(_comptrollerProxy, _settingsData);
        }

        // Add policy
        for (uint256 i; i < _hooks.length; i++) {
            require(
                !policyIsEnabledOnHookForFund(_comptrollerProxy, _hooks[i], _policy),
                "__enablePolicyForFund: Policy is already enabled"
            );
            comptrollerProxyToHookToPolicies[_comptrollerProxy][_hooks[i]].push(_policy);
        }

        emit PolicyEnabledForFund(_comptrollerProxy, _policy, _settingsData);
    }

    /// @dev Helper to get all the hooks available to policies
    function __getAllPolicyHooks()
        private
        pure
        returns (PolicyHook[POLICY_HOOK_COUNT] memory hooks_)
    {
        return [
            PolicyHook.PostBuyShares,
            PolicyHook.PostCallOnIntegration,
            PolicyHook.PreTransferShares,
            PolicyHook.RedeemSharesForSpecificAssets,
            PolicyHook.AddTrackedAssets,
            PolicyHook.RemoveTrackedAssets,
            PolicyHook.CreateExternalPosition,
            PolicyHook.PostCallOnExternalPosition,
            PolicyHook.RemoveExternalPosition,
            PolicyHook.ReactivateExternalPosition
        ];
    }

    /// @dev Helper to check if a policy hook restricts the actions of current investors.
    /// These hooks should not allow policy additions post-deployment or post-migration.
    function __policyHookRestrictsCurrentInvestorActions(PolicyHook _hook)
        private
        pure
        returns (bool restrictsActions_)
    {
        return
            _hook == PolicyHook.PreTransferShares ||
            _hook == PolicyHook.RedeemSharesForSpecificAssets;
    }

    ///////////////////
    // STATE GETTERS //
    ///////////////////

    /// @notice Get a list of enabled policies for the given fund
    /// @param _comptrollerProxy The ComptrollerProxy
    /// @return enabledPolicies_ The array of enabled policy addresses
    function getEnabledPoliciesForFund(address _comptrollerProxy)
        public
        view
        returns (address[] memory enabledPolicies_)
    {
        PolicyHook[POLICY_HOOK_COUNT] memory hooks = __getAllPolicyHooks();

        for (uint256 i; i < hooks.length; i++) {
            enabledPolicies_ = enabledPolicies_.mergeArray(
                getEnabledPoliciesOnHookForFund(_comptrollerProxy, hooks[i])
            );
        }

        return enabledPolicies_;
    }

    /// @notice Get a list of enabled policies that run on a given hook for the given fund
    /// @param _comptrollerProxy The ComptrollerProxy
    /// @param _hook The PolicyHook
    /// @return enabledPolicies_ The array of enabled policy addresses
    function getEnabledPoliciesOnHookForFund(address _comptrollerProxy, PolicyHook _hook)
        public
        view
        returns (address[] memory enabledPolicies_)
    {
        return comptrollerProxyToHookToPolicies[_comptrollerProxy][_hook];
    }

    /// @notice Check whether a given policy runs on a given hook for a given fund
    /// @param _comptrollerProxy The ComptrollerProxy
    /// @param _hook The PolicyHook
    /// @param _policy The policy
    /// @return isEnabled_ True if the policy is enabled
    function policyIsEnabledOnHookForFund(
        address _comptrollerProxy,
        PolicyHook _hook,
        address _policy
    ) public view returns (bool isEnabled_) {
        return getEnabledPoliciesOnHookForFund(_comptrollerProxy, _hook).contains(_policy);
    }
}
IPolicyManager.sol 40 lines
// SPDX-License-Identifier: GPL-3.0

/*
    This file is part of the Enzyme Protocol.

    (c) Enzyme Council <[email protected]>

    For the full license information, please view the LICENSE
    file that was distributed with this source code.
*/

pragma solidity 0.6.12;
pragma experimental ABIEncoderV2;

/// @title PolicyManager Interface
/// @author Enzyme Council <[email protected]>
/// @notice Interface for the PolicyManager
interface IPolicyManager {
    // When updating PolicyHook, also update these functions in PolicyManager:
    // 1. __getAllPolicyHooks()
    // 2. __policyHookRestrictsCurrentInvestorActions()
    enum PolicyHook {
        PostBuyShares,
        PostCallOnIntegration,
        PreTransferShares,
        RedeemSharesForSpecificAssets,
        AddTrackedAssets,
        RemoveTrackedAssets,
        CreateExternalPosition,
        PostCallOnExternalPosition,
        RemoveExternalPosition,
        ReactivateExternalPosition
    }

    function validatePolicies(
        address,
        PolicyHook,
        bytes calldata
    ) external;
}
IExternalPositionVault.sol 19 lines
// SPDX-License-Identifier: GPL-3.0

/*
    This file is part of the Enzyme Protocol.

    (c) Enzyme Council <[email protected]>

    For the full license information, please view the LICENSE
    file that was distributed with this source code.
*/

pragma solidity 0.6.12;

/// @title IExternalPositionVault interface
/// @author Enzyme Council <[email protected]>
/// Provides an interface to get the externalPositionLib for a given type from the Vault
interface IExternalPositionVault {
    function getExternalPositionLibForType(uint256) external view returns (address);
}
IGasRelayPaymaster.sol 23 lines
// SPDX-License-Identifier: GPL-3.0

/*
    This file is part of the Enzyme Protocol.

    (c) Enzyme Council <[email protected]>

    For the full license information, please view the LICENSE
    file that was distributed with this source code.
*/

pragma solidity 0.6.12;
pragma experimental ABIEncoderV2;

import "../../interfaces/IGsnPaymaster.sol";

/// @title IGasRelayPaymaster Interface
/// @author Enzyme Council <[email protected]>
interface IGasRelayPaymaster is IGsnPaymaster {
    function deposit() external;

    function withdrawBalance() external;
}
GasRelayRecipientMixin.sol 65 lines
// SPDX-License-Identifier: GPL-3.0

/*
    This file is part of the Enzyme Protocol.

    (c) Enzyme Council <[email protected]>

    For the full license information, please view the LICENSE
    file that was distributed with this source code.
*/

import "../../utils/beacon-proxy/IBeaconProxyFactory.sol";
import "./IGasRelayPaymaster.sol";

pragma solidity 0.6.12;

/// @title GasRelayRecipientMixin Contract
/// @author Enzyme Council <[email protected]>
/// @notice A mixin that enables receiving GSN-relayed calls
/// @dev IMPORTANT: Do not use storage var in this contract,
/// unless it is no longer inherited by the VaultLib
abstract contract GasRelayRecipientMixin {
    address internal immutable GAS_RELAY_PAYMASTER_FACTORY;

    constructor(address _gasRelayPaymasterFactory) internal {
        GAS_RELAY_PAYMASTER_FACTORY = _gasRelayPaymasterFactory;
    }

    /// @dev Helper to parse the canonical sender of a tx based on whether it has been relayed
    function __msgSender() internal view returns (address payable canonicalSender_) {
        if (msg.data.length >= 24 && msg.sender == getGasRelayTrustedForwarder()) {
            assembly {
                canonicalSender_ := shr(96, calldataload(sub(calldatasize(), 20)))
            }

            return canonicalSender_;
        }

        return msg.sender;
    }

    ///////////////////
    // STATE GETTERS //
    ///////////////////

    /// @notice Gets the `GAS_RELAY_PAYMASTER_FACTORY` variable
    /// @return gasRelayPaymasterFactory_ The `GAS_RELAY_PAYMASTER_FACTORY` variable value
    function getGasRelayPaymasterFactory()
        public
        view
        returns (address gasRelayPaymasterFactory_)
    {
        return GAS_RELAY_PAYMASTER_FACTORY;
    }

    /// @notice Gets the trusted forwarder for GSN relaying
    /// @return trustedForwarder_ The trusted forwarder
    function getGasRelayTrustedForwarder() public view returns (address trustedForwarder_) {
        return
            IGasRelayPaymaster(
                IBeaconProxyFactory(getGasRelayPaymasterFactory()).getCanonicalLib()
            )
                .trustedForwarder();
    }
}
IFreelyTransferableSharesVault.sol 24 lines
// SPDX-License-Identifier: GPL-3.0

/*
    This file is part of the Enzyme Protocol.

    (c) Enzyme Council <[email protected]>

    For the full license information, please view the LICENSE
    file that was distributed with this source code.
*/

pragma solidity 0.6.12;

/// @title IFreelyTransferableSharesVault Interface
/// @author Enzyme Council <[email protected]>
/// @notice Provides the interface for determining whether a vault's shares
/// are guaranteed to be freely transferable.
/// @dev DO NOT EDIT CONTRACT
interface IFreelyTransferableSharesVault {
    function sharesAreFreelyTransferable()
        external
        view
        returns (bool sharesAreFreelyTransferable_);
}

Read Contract

getEnabledPoliciesForFund 0x8af6d89e → address[]
getEnabledPoliciesOnHookForFund 0x8aa740b4 → address[]
getFundDeployer 0x97c0ac87 → address
getGasRelayPaymasterFactory 0xac259456 → address
getGasRelayTrustedForwarder 0x6ea21143 → address
getOwner 0x893d20e8 → address
getVaultProxyForFund 0x46790346 → address
policyIsEnabledOnHookForFund 0x248a2aab → bool

Write Contract 8 functions

These functions modify contract state and require a wallet transaction to execute.

activateForFund 0x80d57063
bool _isMigratedFund
deactivateForFund 0xbd8e959a
No parameters
disablePolicyForFund 0x45d582e7
address _comptrollerProxy
address _policy
enablePolicyForFund 0x48f35209
address _comptrollerProxy
address _policy
bytes _settingsData
receiveCallFromComptroller 0x1bee801e
address
uint256
bytes
setConfigForFund 0xf067cc11
address _comptrollerProxy
address _vaultProxy
bytes _configData
updatePolicySettingsForFund 0x4ed28b3f
address _comptrollerProxy
address _policy
bytes _settingsData
validatePolicies 0x0442bad5
address _comptrollerProxy
uint8 _hook
bytes _validationData

Recent Transactions

No transactions found for this address