Cryo Explorer Ethereum Mainnet

Address Contract Verified

Address 0xe2d60463dE3a0221276D737b87C605e0BB5451E9
Balance 0 ETH
Nonce 1
Code Size 8378 bytes
Indexed Transactions 0
External Etherscan · Sourcify

Contract Bytecode

8378 bytes
0x608060405234801561000f575f80fd5b5060043610610179575f3560e01c806379ba5097116100d2578063cfe7dc6111610088578063e30c397811610063578063e30c3978146103e7578063e55dc76d14610405578063f2fde38b14610418575f80fd5b8063cfe7dc61146103ae578063d561882e146103c1578063dba24786146103d4575f80fd5b80638da5cb5b116100b85780638da5cb5b1461032a578063a9cf7c2c14610347578063b66d56251461039b575f80fd5b806379ba50971461030f57806387f174dd14610317575f80fd5b806345b78f171161013257806369e182f51161010d57806369e182f5146102bf578063715018a6146102d2578063796607be146102da575f80fd5b806345b78f171461021357806356dc958b146102485780636069f1f91461025b575f80fd5b80631ae5afef116101625780631ae5afef146101bb57806332c2a8b3146101dc57806342584195146101fe575f80fd5b806304ff6bec1461017d57806311e4bd1f14610192575b5f80fd5b61019061018b3660046118e1565b61042b565b005b6101a56101a03660046118e1565b6104fc565b6040516101b29190611973565b60405180910390f35b6101ce6101c9366004611985565b61059e565b6040516101b292919061199e565b6101ef6101ea366004611985565b61066c565b6040516101b2939291906119d4565b610206610742565b6040516101b29190611a13565b61023a7fdb1a87ea9bc84f87a099b745816785d81d746623217d6faed99a2548366ff53081565b6040519081526020016101b2565b610190610256366004611a60565b6107d9565b61029a610269366004611985565b6001600160e01b0319165f9081526002602052604090205473ffffffffffffffffffffffffffffffffffffffff1690565b60405173ffffffffffffffffffffffffffffffffffffffff90911681526020016101b2565b6101906102cd366004611ab1565b6108e4565b610190610b19565b61029a6102e8366004611985565b60036020525f908152604090205473ffffffffffffffffffffffffffffffffffffffff1681565b610190610b2c565b610190610325366004611a60565b610ba3565b5f5473ffffffffffffffffffffffffffffffffffffffff1661029a565b61038b610355366004611985565b6001600160e01b0319165f9081526002602052604090205474010000000000000000000000000000000000000000900460ff1690565b60405190151581526020016101b2565b6101906103a9366004611ab1565b610c43565b6102066103bc366004611b38565b610db2565b6101906103cf366004611985565b610e9c565b6101a56103e23660046118e1565b61103a565b60015473ffffffffffffffffffffffffffffffffffffffff1661029a565b61023a610413366004611b51565b611184565b610190610426366004611b38565b611515565b6104336115c4565b73ffffffffffffffffffffffffffffffffffffffff82165f90815260066020526040902061046b906001600160e01b03198316611616565b15155f036104b6576040517fb4c0abc10000000000000000000000000000000000000000000000000000000081526001600160e01b0319821660048201526024015b60405180910390fd5b73ffffffffffffffffffffffffffffffffffffffff82165f9081526005602090815260408083206001600160e01b03198516845290915281206104f891611858565b5050565b600560209081525f92835260408084209091529082529020805461051f90611bd0565b80601f016020809104026020016040519081016040528092919081815260200182805461054b90611bd0565b80156105965780601f1061056d57610100808354040283529160200191610596565b820191905f5260205f20905b81548152906001019060200180831161057957829003601f168201915b505050505081565b6001600160e01b031981165f90815260026020526040812080546001909101805460609273ffffffffffffffffffffffffffffffffffffffff16919081906105e590611bd0565b80601f016020809104026020016040519081016040528092919081815260200182805461061190611bd0565b801561065c5780601f106106335761010080835404028352916020019161065c565b820191905f5260205f20905b81548152906001019060200180831161063f57829003601f168201915b5050505050905091509150915091565b60026020525f90815260409020805460018201805473ffffffffffffffffffffffffffffffffffffffff8316937401000000000000000000000000000000000000000090930460ff169291906106c190611bd0565b80601f01602080910402602001604051908101604052809291908181526020018280546106ed90611bd0565b80156107385780601f1061070f57610100808354040283529160200191610738565b820191905f5260205f20905b81548152906001019060200180831161071b57829003601f168201915b5050505050905083565b606060048054806020026020016040519081016040528092919081815260200182805480156107cf57602002820191905f5260205f20905f905b82829054906101000a900460e01b7bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19168152602001906004019060208260030104928301926001038202915080841161077c5790505b5050505050905090565b6107e16115c4565b6108256107f16020830183611985565b73ffffffffffffffffffffffffffffffffffffffff84165f908152600660205260409020906001600160e01b031916611628565b15155f036108795761083a6020820182611985565b6040517fb4c0abc10000000000000000000000000000000000000000000000000000000081526001600160e01b031990911660048201526024016104ad565b6108866020820182611c21565b73ffffffffffffffffffffffffffffffffffffffff84165f908152600560209081526040822091906108ba90860186611985565b6001600160e01b031916815260208101919091526040015f20916108df919083611d01565b505050565b6108ec6115c4565b6001600160e01b031984165f9081526002602052604090205474010000000000000000000000000000000000000000900460ff1615610963576040517f484513e90000000000000000000000000000000000000000000000000000000081526001600160e01b0319851660048201526024016104ad565b60405180606001604052808473ffffffffffffffffffffffffffffffffffffffff16815260200160011515815260200183838080601f0160208091040260200160405190810160405280939291908181526020018383808284375f9201829052509390945250506001600160e01b031987168152600260209081526040918290208451815492860151151574010000000000000000000000000000000000000000027fffffffffffffffffffffff00000000000000000000000000000000000000000090931673ffffffffffffffffffffffffffffffffffffffff90911617919091178155908301519091506001820190610a5e9082611dd9565b5050600480546001810182555f8290527f8a35acfbc15ff81a39ae7d344fd709f28e8600b4aa8c65c6b64bfe7fe36bd19b6008820401805463ffffffff60079093169093026101000a9182021990921660e088901c9190910217905550604080516001600160e01b03198616815273ffffffffffffffffffffffffffffffffffffffff851660208201527f1139291f4f693738c57e89c3371d43961722b153a9561a9287284a1c4090fe6e910160405180910390a150505050565b610b216115c4565b610b2a5f61163f565b565b600154339073ffffffffffffffffffffffffffffffffffffffff168114610b97576040517f118cdaa700000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff821660048201526024016104ad565b610ba08161163f565b50565b610bab6115c4565b610bef610bbb6020830183611985565b73ffffffffffffffffffffffffffffffffffffffff84165f908152600660205260409020906001600160e01b031916611670565b15155f0361087957610c046020820182611985565b6040517fc22d93fd0000000000000000000000000000000000000000000000000000000081526001600160e01b031990911660048201526024016104ad565b610c4b6115c4565b6001600160e01b031984165f9081526002602052604090205474010000000000000000000000000000000000000000900460ff16610cc1576040517fe23b1fcd0000000000000000000000000000000000000000000000000000000081526001600160e01b0319851660048201526024016104ad565b6001600160e01b031984165f9081526002602081815260408084208054600384529190942080547fffffffffffffffffffffffff000000000000000000000000000000000000000090811673ffffffffffffffffffffffffffffffffffffffff938416908117909255939092528354908716921691909117825590600101610d4a838583611d01565b50604080516001600160e01b03198716815273ffffffffffffffffffffffffffffffffffffffff868116602083015283168183015290517f6b6ba216a08620f1f685734c07270b115a5bcf1b08f8f30d754602fa25a3c9479181900360600190a15050505050565b73ffffffffffffffffffffffffffffffffffffffff81165f90815260066020526040812060609190610de39061167b565b90508067ffffffffffffffff811115610dfe57610dfe611c89565b604051908082528060200260200182016040528015610e27578160200160208202803683370190505b5091505f5b81811015610e955773ffffffffffffffffffffffffffffffffffffffff84165f908152600660205260409020610e629082611684565b838281518110610e7457610e74611eb7565b6001600160e01b031990921660209283029190910190910152600101610e2c565b5050919050565b610ea46115c4565b6001600160e01b031981165f9081526002602052604090205474010000000000000000000000000000000000000000900460ff16610f1a576040517fe23b1fcd0000000000000000000000000000000000000000000000000000000081526001600160e01b0319821660048201526024016104ad565b6001600160e01b031981165f9081526003602052604090205473ffffffffffffffffffffffffffffffffffffffff16610f8b576040517f19b164cb0000000000000000000000000000000000000000000000000000000081526001600160e01b0319821660048201526024016104ad565b6001600160e01b031981165f818152600260208181526040808420805460038452948290205493835273ffffffffffffffffffffffffffffffffffffffff9384167fffffffffffffffffffffffff0000000000000000000000000000000000000000861681179091558151958652918501919091529116908201819052907f45b8ec297eabc75422f5f5d8134c08efb6a5bc6aaad342ac6de21001cc5265ac9060600160405180910390a15050565b73ffffffffffffffffffffffffffffffffffffffff82165f908152600660205260409020606090611075906001600160e01b03198416611628565b15155f036110bb576040517fb4c0abc10000000000000000000000000000000000000000000000000000000081526001600160e01b0319831660048201526024016104ad565b73ffffffffffffffffffffffffffffffffffffffff83165f9081526005602090815260408083206001600160e01b031986168452909152902080546110ff90611bd0565b80601f016020809104026020016040519081016040528092919081815260200182805461112b90611bd0565b80156111765780601f1061114d57610100808354040283529160200191611176565b820191905f5260205f20905b81548152906001019060200180831161115957829003601f168201915b505050505090505b92915050565b73ffffffffffffffffffffffffffffffffffffffff83165f90815260066020526040812081906111b39061167b565b90505f5b8181101561150c5773ffffffffffffffffffffffffffffffffffffffff86165f9081526006602052604081206111ed9083611684565b73ffffffffffffffffffffffffffffffffffffffff88165f9081526005602090815260408083206001600160e01b03198516845290915290209091507fdb1a87ea9bc84f87a099b745816785d81d746623217d6faed99a2548366ff5309061125490611ee4565b1461134e576001600160e01b031981165f8181526002602090815260408083205473ffffffffffffffffffffffffffffffffffffffff8c8116855260058452828520958552949092528083209051929384939216916112b39190611f21565b5f60405180830381855afa9150503d805f81146112eb576040519150601f19603f3d011682016040523d82523d5f602084013e6112f0565b606091505b509150915081611338576040517fe452453d0000000000000000000000000000000000000000000000000000000081526001600160e01b0319841660048201526024016104ad565b61134181611fb1565b5f1c860195505050611503565b5f805b868110156114bd576001600160e01b0319831688888381811061137657611376611eb7565b90506020028101906113889190611fd4565b611396906020810190611985565b6001600160e01b031916036114b5576001600160e01b031983165f90815260026020526040812054819073ffffffffffffffffffffffffffffffffffffffff168a8a858181106113e8576113e8611eb7565b90506020028101906113fa9190611fd4565b611408906020810190611c21565b604051611416929190612010565b5f60405180830381855afa9150503d805f811461144e576040519150601f19603f3d011682016040523d82523d5f602084013e611453565b606091505b50915091508161149b576040517fe452453d0000000000000000000000000000000000000000000000000000000081526001600160e01b0319861660048201526024016104ad565b6114a481611fb1565b5f1c880197506001935050506114bd565b600101611351565b5080611501576040517fca24f6b20000000000000000000000000000000000000000000000000000000081526001600160e01b0319831660048201526024016104ad565b505b506001016111b7565b50509392505050565b61151d6115c4565b6001805473ffffffffffffffffffffffffffffffffffffffff83167fffffffffffffffffffffffff0000000000000000000000000000000000000000909116811790915561157f5f5473ffffffffffffffffffffffffffffffffffffffff1690565b73ffffffffffffffffffffffffffffffffffffffff167f38d16b8cac22d99fc7c124b9cd0de2d3fa1faef420bfe791d8c362d765e2270060405160405180910390a350565b5f5473ffffffffffffffffffffffffffffffffffffffff163314610b2a576040517f118cdaa70000000000000000000000000000000000000000000000000000000081523360048201526024016104ad565b5f611621838361168f565b9392505050565b5f8181526001830160205260408120541515611621565b600180547fffffffffffffffffffffffff0000000000000000000000000000000000000000169055610ba081611772565b5f61162183836117e6565b5f61117e825490565b5f6116218383611832565b5f8181526001830160205260408120548015611769575f6116b160018361201f565b85549091505f906116c49060019061201f565b9050808214611723575f865f0182815481106116e2576116e2611eb7565b905f5260205f200154905080875f01848154811061170257611702611eb7565b5f918252602080832090910192909255918252600188019052604090208390555b855486908061173457611734612057565b600190038181905f5260205f20015f90559055856001015f8681526020019081526020015f205f90556001935050505061117e565b5f91505061117e565b5f805473ffffffffffffffffffffffffffffffffffffffff8381167fffffffffffffffffffffffff0000000000000000000000000000000000000000831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b5f81815260018301602052604081205461182b57508154600181810184555f84815260208082209093018490558454848252828601909352604090209190915561117e565b505f61117e565b5f825f01828154811061184757611847611eb7565b905f5260205f200154905092915050565b50805461186490611bd0565b5f825580601f10611873575050565b601f0160209004905f5260205f2090810190610ba091905b8082111561189e575f815560010161188b565b5090565b803573ffffffffffffffffffffffffffffffffffffffff811681146118c5575f80fd5b919050565b80356001600160e01b0319811681146118c5575f80fd5b5f80604083850312156118f2575f80fd5b6118fb836118a2565b9150611909602084016118ca565b90509250929050565b5f81518084525f5b818110156119365760208185018101518683018201520161191a565b505f6020828601015260207fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0601f83011685010191505092915050565b602081525f6116216020830184611912565b5f60208284031215611995575f80fd5b611621826118ca565b73ffffffffffffffffffffffffffffffffffffffff83168152604060208201525f6119cc6040830184611912565b949350505050565b73ffffffffffffffffffffffffffffffffffffffff841681528215156020820152606060408201525f611a0a6060830184611912565b95945050505050565b602080825282518282018190525f9190848201906040850190845b81811015611a545783516001600160e01b03191683529284019291840191600101611a2e565b50909695505050505050565b5f8060408385031215611a71575f80fd5b611a7a836118a2565b9150602083013567ffffffffffffffff811115611a95575f80fd5b830160408186031215611aa6575f80fd5b809150509250929050565b5f805f8060608587031215611ac4575f80fd5b611acd856118ca565b9350611adb602086016118a2565b9250604085013567ffffffffffffffff80821115611af7575f80fd5b818701915087601f830112611b0a575f80fd5b813581811115611b18575f80fd5b886020828501011115611b29575f80fd5b95989497505060200194505050565b5f60208284031215611b48575f80fd5b611621826118a2565b5f805f60408486031215611b63575f80fd5b611b6c846118a2565b9250602084013567ffffffffffffffff80821115611b88575f80fd5b818601915086601f830112611b9b575f80fd5b813581811115611ba9575f80fd5b8760208260051b8501011115611bbd575f80fd5b6020830194508093505050509250925092565b600181811c90821680611be457607f821691505b602082108103611c1b577f4e487b71000000000000000000000000000000000000000000000000000000005f52602260045260245ffd5b50919050565b5f8083357fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe1843603018112611c54575f80fd5b83018035915067ffffffffffffffff821115611c6e575f80fd5b602001915036819003821315611c82575f80fd5b9250929050565b7f4e487b71000000000000000000000000000000000000000000000000000000005f52604160045260245ffd5b601f8211156108df57805f5260205f20601f840160051c81016020851015611cdb5750805b601f840160051c820191505b81811015611cfa575f8155600101611ce7565b5050505050565b67ffffffffffffffff831115611d1957611d19611c89565b611d2d83611d278354611bd0565b83611cb6565b5f601f841160018114611d5e575f8515611d475750838201355b5f19600387901b1c1916600186901b178355611cfa565b5f838152602081207fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe08716915b82811015611dab5786850135825560209485019460019092019101611d8b565b5086821015611dc7575f1960f88860031b161c19848701351681555b505060018560011b0183555050505050565b815167ffffffffffffffff811115611df357611df3611c89565b611e0781611e018454611bd0565b84611cb6565b602080601f831160018114611e3a575f8415611e235750858301515b5f19600386901b1c1916600185901b178555611eaf565b5f858152602081207fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe08616915b82811015611e8657888601518255948401946001909101908401611e67565b5085821015611ea357878501515f19600388901b60f8161c191681555b505060018460011b0185555b505050505050565b7f4e487b71000000000000000000000000000000000000000000000000000000005f52603260045260245ffd5b5f611eef8254611bd0565b82601f821115611f0357835f5260205f2090505b5491506020811015611c1b575f1960209190910360031b1b16919050565b5f808354611f2e81611bd0565b60018281168015611f465760018114611f7957611fa5565b7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0084168752821515830287019450611fa5565b875f526020805f205f5b85811015611f9c5781548a820152908401908201611f83565b50505082870194505b50929695505050505050565b80516020808301519190811015611c1b575f1960209190910360031b1b16919050565b5f82357fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc1833603018112612006575f80fd5b9190910192915050565b818382375f9101908152919050565b8181038181111561117e577f4e487b71000000000000000000000000000000000000000000000000000000005f52601160045260245ffd5b7f4e487b71000000000000000000000000000000000000000000000000000000005f52603160045260245ffdfea26469706673582212207eb5f639152ddd1ad60b9de9798ea15ad0728fb02f42e8933836ac738b5aac9064736f6c63430008180033

Verified Source Code Full Match

Compiler: v0.8.24+commit.e11b9ed9 EVM: cancun Optimization: Yes (10000 runs)
Ownable.sol 100 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (access/Ownable.sol)

pragma solidity ^0.8.20;

import {Context} from "../utils/Context.sol";

/**
 * @dev Contract module which provides a basic access control mechanism, where
 * there is an account (an owner) that can be granted exclusive access to
 * specific functions.
 *
 * The initial owner is set to the address provided by the deployer. This can
 * later be changed with {transferOwnership}.
 *
 * This module is used through inheritance. It will make available the modifier
 * `onlyOwner`, which can be applied to your functions to restrict their use to
 * the owner.
 */
abstract contract Ownable is Context {
    address private _owner;

    /**
     * @dev The caller account is not authorized to perform an operation.
     */
    error OwnableUnauthorizedAccount(address account);

    /**
     * @dev The owner is not a valid owner account. (eg. `address(0)`)
     */
    error OwnableInvalidOwner(address owner);

    event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);

    /**
     * @dev Initializes the contract setting the address provided by the deployer as the initial owner.
     */
    constructor(address initialOwner) {
        if (initialOwner == address(0)) {
            revert OwnableInvalidOwner(address(0));
        }
        _transferOwnership(initialOwner);
    }

    /**
     * @dev Throws if called by any account other than the owner.
     */
    modifier onlyOwner() {
        _checkOwner();
        _;
    }

    /**
     * @dev Returns the address of the current owner.
     */
    function owner() public view virtual returns (address) {
        return _owner;
    }

    /**
     * @dev Throws if the sender is not the owner.
     */
    function _checkOwner() internal view virtual {
        if (owner() != _msgSender()) {
            revert OwnableUnauthorizedAccount(_msgSender());
        }
    }

    /**
     * @dev Leaves the contract without owner. It will not be possible to call
     * `onlyOwner` functions. Can only be called by the current owner.
     *
     * NOTE: Renouncing ownership will leave the contract without an owner,
     * thereby disabling any functionality that is only available to the owner.
     */
    function renounceOwnership() public virtual onlyOwner {
        _transferOwnership(address(0));
    }

    /**
     * @dev Transfers ownership of the contract to a new account (`newOwner`).
     * Can only be called by the current owner.
     */
    function transferOwnership(address newOwner) public virtual onlyOwner {
        if (newOwner == address(0)) {
            revert OwnableInvalidOwner(address(0));
        }
        _transferOwnership(newOwner);
    }

    /**
     * @dev Transfers ownership of the contract to a new account (`newOwner`).
     * Internal function without access restriction.
     */
    function _transferOwnership(address newOwner) internal virtual {
        address oldOwner = _owner;
        _owner = newOwner;
        emit OwnershipTransferred(oldOwner, newOwner);
    }
}
Ownable2Step.sol 59 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (access/Ownable2Step.sol)

pragma solidity ^0.8.20;

import {Ownable} from "./Ownable.sol";

/**
 * @dev Contract module which provides access control mechanism, where
 * there is an account (an owner) that can be granted exclusive access to
 * specific functions.
 *
 * The initial owner is specified at deployment time in the constructor for `Ownable`. This
 * can later be changed with {transferOwnership} and {acceptOwnership}.
 *
 * This module is used through inheritance. It will make available all functions
 * from parent (Ownable).
 */
abstract contract Ownable2Step is Ownable {
    address private _pendingOwner;

    event OwnershipTransferStarted(address indexed previousOwner, address indexed newOwner);

    /**
     * @dev Returns the address of the pending owner.
     */
    function pendingOwner() public view virtual returns (address) {
        return _pendingOwner;
    }

    /**
     * @dev Starts the ownership transfer of the contract to a new account. Replaces the pending transfer if there is one.
     * Can only be called by the current owner.
     */
    function transferOwnership(address newOwner) public virtual override onlyOwner {
        _pendingOwner = newOwner;
        emit OwnershipTransferStarted(owner(), newOwner);
    }

    /**
     * @dev Transfers ownership of the contract to a new account (`newOwner`) and deletes any pending owner.
     * Internal function without access restriction.
     */
    function _transferOwnership(address newOwner) internal virtual override {
        delete _pendingOwner;
        super._transferOwnership(newOwner);
    }

    /**
     * @dev The new owner accepts the ownership transfer.
     */
    function acceptOwnership() public virtual {
        address sender = _msgSender();
        if (pendingOwner() != sender) {
            revert OwnableUnauthorizedAccount(sender);
        }
        _transferOwnership(sender);
    }
}
Context.sol 28 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.1) (utils/Context.sol)

pragma solidity ^0.8.20;

/**
 * @dev Provides information about the current execution context, including the
 * sender of the transaction and its data. While these are generally available
 * via msg.sender and msg.data, they should not be accessed in such a direct
 * manner, since when dealing with meta-transactions the account sending and
 * paying for execution may not be the actual sender (as far as an application
 * is concerned).
 *
 * This contract is only required for intermediate, library-like contracts.
 */
abstract contract Context {
    function _msgSender() internal view virtual returns (address) {
        return msg.sender;
    }

    function _msgData() internal view virtual returns (bytes calldata) {
        return msg.data;
    }

    function _contextSuffixLength() internal view virtual returns (uint256) {
        return 0;
    }
}
EnumerableSet.sol 378 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (utils/structs/EnumerableSet.sol)
// This file was procedurally generated from scripts/generate/templates/EnumerableSet.js.

pragma solidity ^0.8.20;

/**
 * @dev Library for managing
 * https://en.wikipedia.org/wiki/Set_(abstract_data_type)[sets] of primitive
 * types.
 *
 * Sets have the following properties:
 *
 * - Elements are added, removed, and checked for existence in constant time
 * (O(1)).
 * - Elements are enumerated in O(n). No guarantees are made on the ordering.
 *
 * ```solidity
 * contract Example {
 *     // Add the library methods
 *     using EnumerableSet for EnumerableSet.AddressSet;
 *
 *     // Declare a set state variable
 *     EnumerableSet.AddressSet private mySet;
 * }
 * ```
 *
 * As of v3.3.0, sets of type `bytes32` (`Bytes32Set`), `address` (`AddressSet`)
 * and `uint256` (`UintSet`) are supported.
 *
 * [WARNING]
 * ====
 * Trying to delete such a structure from storage will likely result in data corruption, rendering the structure
 * unusable.
 * See https://github.com/ethereum/solidity/pull/11843[ethereum/solidity#11843] for more info.
 *
 * In order to clean an EnumerableSet, you can either remove all elements one by one or create a fresh instance using an
 * array of EnumerableSet.
 * ====
 */
library EnumerableSet {
    // To implement this library for multiple types with as little code
    // repetition as possible, we write it in terms of a generic Set type with
    // bytes32 values.
    // The Set implementation uses private functions, and user-facing
    // implementations (such as AddressSet) are just wrappers around the
    // underlying Set.
    // This means that we can only create new EnumerableSets for types that fit
    // in bytes32.

    struct Set {
        // Storage of set values
        bytes32[] _values;
        // Position is the index of the value in the `values` array plus 1.
        // Position 0 is used to mean a value is not in the set.
        mapping(bytes32 value => uint256) _positions;
    }

    /**
     * @dev Add a value to a set. O(1).
     *
     * Returns true if the value was added to the set, that is if it was not
     * already present.
     */
    function _add(Set storage set, bytes32 value) private returns (bool) {
        if (!_contains(set, value)) {
            set._values.push(value);
            // The value is stored at length-1, but we add 1 to all indexes
            // and use 0 as a sentinel value
            set._positions[value] = set._values.length;
            return true;
        } else {
            return false;
        }
    }

    /**
     * @dev Removes a value from a set. O(1).
     *
     * Returns true if the value was removed from the set, that is if it was
     * present.
     */
    function _remove(Set storage set, bytes32 value) private returns (bool) {
        // We cache the value's position to prevent multiple reads from the same storage slot
        uint256 position = set._positions[value];

        if (position != 0) {
            // Equivalent to contains(set, value)
            // To delete an element from the _values array in O(1), we swap the element to delete with the last one in
            // the array, and then remove the last element (sometimes called as 'swap and pop').
            // This modifies the order of the array, as noted in {at}.

            uint256 valueIndex = position - 1;
            uint256 lastIndex = set._values.length - 1;

            if (valueIndex != lastIndex) {
                bytes32 lastValue = set._values[lastIndex];

                // Move the lastValue to the index where the value to delete is
                set._values[valueIndex] = lastValue;
                // Update the tracked position of the lastValue (that was just moved)
                set._positions[lastValue] = position;
            }

            // Delete the slot where the moved value was stored
            set._values.pop();

            // Delete the tracked position for the deleted slot
            delete set._positions[value];

            return true;
        } else {
            return false;
        }
    }

    /**
     * @dev Returns true if the value is in the set. O(1).
     */
    function _contains(Set storage set, bytes32 value) private view returns (bool) {
        return set._positions[value] != 0;
    }

    /**
     * @dev Returns the number of values on the set. O(1).
     */
    function _length(Set storage set) private view returns (uint256) {
        return set._values.length;
    }

    /**
     * @dev Returns the value stored at position `index` in the set. O(1).
     *
     * Note that there are no guarantees on the ordering of values inside the
     * array, and it may change when more values are added or removed.
     *
     * Requirements:
     *
     * - `index` must be strictly less than {length}.
     */
    function _at(Set storage set, uint256 index) private view returns (bytes32) {
        return set._values[index];
    }

    /**
     * @dev Return the entire set in an array
     *
     * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed
     * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that
     * this function has an unbounded cost, and using it as part of a state-changing function may render the function
     * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.
     */
    function _values(Set storage set) private view returns (bytes32[] memory) {
        return set._values;
    }

    // Bytes32Set

    struct Bytes32Set {
        Set _inner;
    }

    /**
     * @dev Add a value to a set. O(1).
     *
     * Returns true if the value was added to the set, that is if it was not
     * already present.
     */
    function add(Bytes32Set storage set, bytes32 value) internal returns (bool) {
        return _add(set._inner, value);
    }

    /**
     * @dev Removes a value from a set. O(1).
     *
     * Returns true if the value was removed from the set, that is if it was
     * present.
     */
    function remove(Bytes32Set storage set, bytes32 value) internal returns (bool) {
        return _remove(set._inner, value);
    }

    /**
     * @dev Returns true if the value is in the set. O(1).
     */
    function contains(Bytes32Set storage set, bytes32 value) internal view returns (bool) {
        return _contains(set._inner, value);
    }

    /**
     * @dev Returns the number of values in the set. O(1).
     */
    function length(Bytes32Set storage set) internal view returns (uint256) {
        return _length(set._inner);
    }

    /**
     * @dev Returns the value stored at position `index` in the set. O(1).
     *
     * Note that there are no guarantees on the ordering of values inside the
     * array, and it may change when more values are added or removed.
     *
     * Requirements:
     *
     * - `index` must be strictly less than {length}.
     */
    function at(Bytes32Set storage set, uint256 index) internal view returns (bytes32) {
        return _at(set._inner, index);
    }

    /**
     * @dev Return the entire set in an array
     *
     * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed
     * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that
     * this function has an unbounded cost, and using it as part of a state-changing function may render the function
     * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.
     */
    function values(Bytes32Set storage set) internal view returns (bytes32[] memory) {
        bytes32[] memory store = _values(set._inner);
        bytes32[] memory result;

        /// @solidity memory-safe-assembly
        assembly {
            result := store
        }

        return result;
    }

    // AddressSet

    struct AddressSet {
        Set _inner;
    }

    /**
     * @dev Add a value to a set. O(1).
     *
     * Returns true if the value was added to the set, that is if it was not
     * already present.
     */
    function add(AddressSet storage set, address value) internal returns (bool) {
        return _add(set._inner, bytes32(uint256(uint160(value))));
    }

    /**
     * @dev Removes a value from a set. O(1).
     *
     * Returns true if the value was removed from the set, that is if it was
     * present.
     */
    function remove(AddressSet storage set, address value) internal returns (bool) {
        return _remove(set._inner, bytes32(uint256(uint160(value))));
    }

    /**
     * @dev Returns true if the value is in the set. O(1).
     */
    function contains(AddressSet storage set, address value) internal view returns (bool) {
        return _contains(set._inner, bytes32(uint256(uint160(value))));
    }

    /**
     * @dev Returns the number of values in the set. O(1).
     */
    function length(AddressSet storage set) internal view returns (uint256) {
        return _length(set._inner);
    }

    /**
     * @dev Returns the value stored at position `index` in the set. O(1).
     *
     * Note that there are no guarantees on the ordering of values inside the
     * array, and it may change when more values are added or removed.
     *
     * Requirements:
     *
     * - `index` must be strictly less than {length}.
     */
    function at(AddressSet storage set, uint256 index) internal view returns (address) {
        return address(uint160(uint256(_at(set._inner, index))));
    }

    /**
     * @dev Return the entire set in an array
     *
     * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed
     * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that
     * this function has an unbounded cost, and using it as part of a state-changing function may render the function
     * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.
     */
    function values(AddressSet storage set) internal view returns (address[] memory) {
        bytes32[] memory store = _values(set._inner);
        address[] memory result;

        /// @solidity memory-safe-assembly
        assembly {
            result := store
        }

        return result;
    }

    // UintSet

    struct UintSet {
        Set _inner;
    }

    /**
     * @dev Add a value to a set. O(1).
     *
     * Returns true if the value was added to the set, that is if it was not
     * already present.
     */
    function add(UintSet storage set, uint256 value) internal returns (bool) {
        return _add(set._inner, bytes32(value));
    }

    /**
     * @dev Removes a value from a set. O(1).
     *
     * Returns true if the value was removed from the set, that is if it was
     * present.
     */
    function remove(UintSet storage set, uint256 value) internal returns (bool) {
        return _remove(set._inner, bytes32(value));
    }

    /**
     * @dev Returns true if the value is in the set. O(1).
     */
    function contains(UintSet storage set, uint256 value) internal view returns (bool) {
        return _contains(set._inner, bytes32(value));
    }

    /**
     * @dev Returns the number of values in the set. O(1).
     */
    function length(UintSet storage set) internal view returns (uint256) {
        return _length(set._inner);
    }

    /**
     * @dev Returns the value stored at position `index` in the set. O(1).
     *
     * Note that there are no guarantees on the ordering of values inside the
     * array, and it may change when more values are added or removed.
     *
     * Requirements:
     *
     * - `index` must be strictly less than {length}.
     */
    function at(UintSet storage set, uint256 index) internal view returns (uint256) {
        return uint256(_at(set._inner, index));
    }

    /**
     * @dev Return the entire set in an array
     *
     * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed
     * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that
     * this function has an unbounded cost, and using it as part of a state-changing function may render the function
     * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.
     */
    function values(UintSet storage set) internal view returns (uint256[] memory) {
        bytes32[] memory store = _values(set._inner);
        uint256[] memory result;

        /// @solidity memory-safe-assembly
        assembly {
            result := store
        }

        return result;
    }
}
NavRegistry.sol 264 lines
// SPDX-License-Identifier: MIT
pragma solidity =0.8.24;
import '@openzeppelin/contracts/access/Ownable2Step.sol';
import '@openzeppelin/contracts/utils/structs/EnumerableSet.sol';

interface INavRegistry {
  struct ModuleParams {
    bytes4 moduleId;
    bytes cd;
  }

  struct Enumerable {
    EnumerableSet.Bytes32Set moduleIds;
  }

  // modules
  function getModuleIds() external view returns (bytes4[] memory);

  function getModuleDetails(bytes4 moduleId) external view returns (address, string memory);

  function getModuleAddress(bytes4 moduleId) external view returns (address);

  function isModuleRegistered(bytes4 moduleId) external view returns (bool);

  // nav
  function getStrategyModules(address strategy) external view returns (bytes4[] memory moduleIds);

  function getStrategyModuleCalldata(address strategy, bytes4 moduleId) external view returns (bytes memory);

  function getStrategyNav(
    address strategy,
    ModuleParams[] calldata dynamicModuleParams
  ) external view returns (uint navInUnderlying);
}

contract NavRegistry is INavRegistry, Ownable2Step {
  using EnumerableSet for EnumerableSet.Bytes32Set;

  bytes32 public constant DYNAMIC = keccak256('NavRegistry.dynamic');

  error EntryAlreadyExistsError(bytes4);
  error EntryNonExistentError(bytes4);
  error EmptyPrevAddrError(bytes4);
  error GetNavFailed(bytes4);
  error AlreadyAttached(bytes4);
  error NotAttached(bytes4);
  error MissingDynamicModule(bytes4);

  event AddNewContract(bytes4, address);
  event UpdateContract(bytes4, address active, address old);
  event RevertToPreviousAddress(bytes4, address active, address old);

  struct Entry {
    address addr;
    bool exists;
    string name;
  }

  mapping(bytes4 moduleId => Entry entries) public modules;
  mapping(bytes4 moduleId => address) public previousModuleAddresses;
  bytes4[] private _moduleIds;

  mapping(address strategy => mapping(bytes4 moduleId => bytes cd)) public strategyModuleCd;
  mapping(address strategy => Enumerable moduleIds) private _strategyModuleIds;

  constructor() Ownable(msg.sender) {}

  //////////////////////////// Modules ////////////////////////////
  /**
   * @notice Returns list of module ids
   */
  function getModuleIds() external view returns (bytes4[] memory) {
    return _moduleIds;
  }

  /**
   * @notice Returns registered contract details
   * @param id id of contract
   * @return address and name of contract
   */
  function getModuleDetails(bytes4 id) external view returns (address, string memory) {
    return (modules[id].addr, modules[id].name);
  }

  /**
   * @notice Returns registered contract given id
   * @param id id of contract
   * @return address of contract
   */
  function getModuleAddress(bytes4 id) external view returns (address) {
    return modules[id].addr;
  }

  /**
   * @notice Helper function to query if id is registered
   * @param id 1st 4 bytes of keccak256 of the contract name
   * @return is id registered
   */
  function isModuleRegistered(bytes4 id) public view returns (bool) {
    return modules[id].exists;
  }

  /**
   * @notice Adds a new contract to the registry
   * @param id id of contract
   * @param addr address of contract to register
   * @param name human readable module name
   */
  function registerModule(bytes4 id, address addr, string calldata name) external onlyOwner {
    if (modules[id].exists) {
      revert EntryAlreadyExistsError(id);
    }

    modules[id] = Entry({ addr: addr, exists: true, name: name });
    _moduleIds.push(id);

    emit AddNewContract(id, addr);
  }

  /**
   * @notice Starts an address change for an existing entry
   * @param id Id of contract
   * @param newAddr address of the new contract
   * @param name human readable module name
   */
  function updateModule(bytes4 id, address newAddr, string calldata name) external onlyOwner {
    if (!modules[id].exists) {
      revert EntryNonExistentError(id);
    }
    address _oldAddr = modules[id].addr;
    previousModuleAddresses[id] = _oldAddr;
    modules[id].addr = newAddr;
    modules[id].name = name;

    emit UpdateContract(id, newAddr, _oldAddr);
  }

  /**
   * @notice reverts to the previous address immediately
   * @dev In case the new version has a fault, a quick way to fallback to the old contract
   * @param id Id of contract
   */
  function revertModule(bytes4 id) external onlyOwner {
    if (!(modules[id].exists)) {
      revert EntryNonExistentError(id);
    }
    if (previousModuleAddresses[id] == address(0)) {
      revert EmptyPrevAddrError(id);
    }

    address currentAddr = modules[id].addr;
    modules[id].addr = previousModuleAddresses[id];

    emit RevertToPreviousAddress(id, modules[id].addr, currentAddr);
  }

  //////////////////////////// Strategies ////////////////////////////

  /**
   * @notice Attaches a module to a strategy
   * @param strategy strategy address to attach module
   * @param params module parameters
   */
  function attachTo(address strategy, ModuleParams calldata params) external onlyOwner {
    if (_strategyModuleIds[strategy].moduleIds.add(params.moduleId) == false) revert AlreadyAttached(params.moduleId);
    strategyModuleCd[strategy][params.moduleId] = params.cd;
  }

  /**
   * @notice Detaches a module from a strategy
   * @param strategy strategy address to detach module from
   * @param moduleId 4-byte module id
   */
  function detachFrom(address strategy, bytes4 moduleId) external onlyOwner {
    if (_strategyModuleIds[strategy].moduleIds.remove(moduleId) == false) revert NotAttached(moduleId);
    delete strategyModuleCd[strategy][moduleId];
  }

  /**
   * @notice Update an attached strategy's parameters
   * @param strategy strategy address
   * @param params updated module parameters
   */
  function updateParams(address strategy, ModuleParams calldata params) external onlyOwner {
    if (_strategyModuleIds[strategy].moduleIds.contains(params.moduleId) == false) revert NotAttached(params.moduleId);
    strategyModuleCd[strategy][params.moduleId] = params.cd;
  }

  /**
   * @notice Get module Ids attached to a particular strategy
   * @param strategy strategy address
   * @return moduleIds array of 4-byte module ids
   */
  function getStrategyModules(address strategy) external view returns (bytes4[] memory moduleIds) {
    uint _len = _strategyModuleIds[strategy].moduleIds.length();
    moduleIds = new bytes4[](_len);
    for (uint i; i < _len; ++i) {
      moduleIds[i] = bytes4(_strategyModuleIds[strategy].moduleIds.at(i));
    }
  }

  /**
   * @notice Get calldata of module attached to strategy
   * @param strategy strategy address
   * @param moduleId 4-byte module Id
   * @return _calldata array of 4-byte module ids
   */
  function getStrategyModuleCalldata(address strategy, bytes4 moduleId) external view returns (bytes memory) {
    if (_strategyModuleIds[strategy].moduleIds.contains(moduleId) == false) revert NotAttached(moduleId);

    return strategyModuleCd[strategy][moduleId];
  }

  /**
   * @notice Get Nav of a strategy
   *
   * @dev loop `moduleIds.length` times, if module is dynamic,
   * loop dynamicModuleParams to retrieve first instance of moduleId + cd.
   * dynamicModuleParams must not have duplicates.
   *
   * @param strategy strategy address
   * @param dynamicModuleParams array of dynamic module params
   * @return _navInUnderlying sum of all attached modules
   */
  function getStrategyNav(
    address strategy,
    ModuleParams[] calldata dynamicModuleParams
  ) external view returns (uint _navInUnderlying) {
    uint256 moduleIdsLength = _strategyModuleIds[strategy].moduleIds.length();
    for (uint i; i < moduleIdsLength; ++i) {
      bytes4 moduleId = bytes4(_strategyModuleIds[strategy].moduleIds.at(i));
      if (bytes32(strategyModuleCd[strategy][moduleId]) != DYNAMIC) {
        (bool success, bytes memory info) = address(modules[moduleId].addr).staticcall(
          strategyModuleCd[strategy][moduleId]
        );

        if (!success) revert GetNavFailed(moduleId);

        unchecked {
          _navInUnderlying += uint(bytes32(info));
        }
      } else {
        // get first instance of dynamic cd
        bool executed = false;

        for (uint j; j < dynamicModuleParams.length; ++j) {
          if (dynamicModuleParams[j].moduleId == moduleId) {
            (bool success, bytes memory info) = address(modules[moduleId].addr).staticcall(dynamicModuleParams[j].cd);
            if (!success) revert GetNavFailed(moduleId);

            unchecked {
              _navInUnderlying += uint(bytes32(info));
            }

            executed = true;
            break;
          }
        }

        if (!executed) revert MissingDynamicModule(moduleId);
      }
    }
  }
}

Read Contract

DYNAMIC 0x45b78f17 → bytes32
getModuleAddress 0x6069f1f9 → address
getModuleDetails 0x1ae5afef → address, string
getModuleIds 0x42584195 → bytes4[]
getStrategyModuleCalldata 0xdba24786 → bytes
getStrategyModules 0xcfe7dc61 → bytes4[]
getStrategyNav 0xd45d6139 → uint256
isModuleRegistered 0xa9cf7c2c → bool
modules 0x32c2a8b3 → address, bool, string
owner 0x8da5cb5b → address
pendingOwner 0xe30c3978 → address
previousModuleAddresses 0x796607be → address
strategyModuleCd 0x11e4bd1f → bytes

Write Contract 9 functions

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

acceptOwnership 0x79ba5097
No parameters
attachTo 0xbfc2de20
address strategy
tuple params
detachFrom 0x04ff6bec
address strategy
bytes4 moduleId
registerModule 0x69e182f5
bytes4 id
address addr
string name
renounceOwnership 0x715018a6
No parameters
revertModule 0xd561882e
bytes4 id
transferOwnership 0xf2fde38b
address newOwner
updateModule 0xb66d5625
bytes4 id
address newAddr
string name
updateParams 0x31a47515
address strategy
tuple params

Recent Transactions

No transactions found for this address