Cryo Explorer Ethereum Mainnet

Address Contract Partially Verified

Address 0xb7cFfebB06621287C7850ffefB22c30252E78e6B
Balance 0.000728130 ETH
Nonce 1
Code Size 3782 bytes
Indexed Transactions 0
External Etherscan · Sourcify

Contract Bytecode

3782 bytes
0x608060405260043610610058575f3560e01c806306d2e426146100715780633659cfe61461008d578063559e0e03146100b55780635c60da1b146100d15780638f283970146100fb578063f851a4401461012357610067565b366100675761006561014d565b005b61006f61014d565b005b61008b60048036038101906100869190610b94565b610167565b005b348015610098575f80fd5b506100b360048036038101906100ae9190610c00565b6101bf565b005b6100cf60048036038101906100ca9190610b94565b610213565b005b3480156100dc575f80fd5b506100e561026b565b6040516100f29190610c3a565b60405180910390f35b348015610106575f80fd5b50610121600480360381019061011c9190610c00565b6102b4565b005b34801561012e575f80fd5b50610137610308565b6040516101449190610c3a565b60405180910390f35b610155610351565b610165610160610353565b610361565b565b61016f610380565b73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16036101b1576101ac8383836103d3565b6101ba565b6101b961014d565b5b505050565b6101c7610380565b73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff160361020757610202816103fe565b610210565b61020f61014d565b5b50565b61021b610380565b73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff160361025d5761025883838361044d565b610266565b61026561014d565b5b505050565b5f610274610380565b73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16036102b1576102ae610353565b90505b90565b6102bc610380565b73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16036102fc576102f781610613565b610305565b61030461014d565b5b50565b5f610311610380565b73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff160361034e5761034b610380565b90505b90565b565b5f61035c61065f565b905090565b365f80375f80365f845af43d5f803e805f811461037c573d5ff35b3d5ffd5b5f6103ac7f444d5549c1b0fc679fe1d30daefb9b9e9d70ad980174932fc88b58cd57e102115f1b6106b2565b5f015f9054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905090565b6103dc836103fe565b5f825111806103e85750805b156103f9576103f783836106bb565b505b505050565b6104078161073b565b8073ffffffffffffffffffffffffffffffffffffffff167fbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b60405160405180910390a250565b5f61045661065f565b90506104618461073b565b5f8351118061046d5750815b1561047e5761047c84846106bb565b505b5f6104aa7f9843adc2ce1ee58312ba81786d469e32c03edf6b0879757a3b7f4a49a98bfbc75f1b610802565b9050805f015f9054906101000a900460ff1661060c576001815f015f6101000a81548160ff02191690831515021790555061057285836040516024016104f09190610c3a565b6040516020818303038152906040527f3659cfe6000000000000000000000000000000000000000000000000000000007bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19166020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff83818316178352505050506106bb565b505f815f015f6101000a81548160ff02191690831515021790555061059561065f565b73ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff1614610602576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016105f990610cd3565b60405180910390fd5b61060b856103fe565b5b5050505050565b7f7e644d79422f17c01e4894b5f4f588d331ebfa28653d42ae832dc59e38c9798f61063c610380565b8260405161064b929190610cf1565b60405180910390a161065c8161080b565b50565b5f61068b7f20882e7e0b3c1661dc1474ff6a22afb8e557e42e9ade77c07c8ee84ac37bea1b5f1b6106b2565b5f015f9054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905090565b5f819050919050565b60605f808473ffffffffffffffffffffffffffffffffffffffff16846040516106e49190610d84565b5f60405180830381855af49150503d805f811461071c576040519150601f19603f3d011682016040523d82523d5f602084013e610721565b606091505b50915091506107318583836108e7565b9250505092915050565b5f8173ffffffffffffffffffffffffffffffffffffffff163b03610794576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161078b90610de4565b60405180910390fd5b806107c07f20882e7e0b3c1661dc1474ff6a22afb8e557e42e9ade77c07c8ee84ac37bea1b5f1b6106b2565b5f015f6101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050565b5f819050919050565b5f73ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff1603610879576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161087090610e72565b60405180910390fd5b806108a57f444d5549c1b0fc679fe1d30daefb9b9e9d70ad980174932fc88b58cd57e102115f1b6106b2565b5f015f6101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050565b6060826108fc576108f782610974565b61096c565b5f825114801561092257505f8473ffffffffffffffffffffffffffffffffffffffff163b145b1561096457836040517f9996b31500000000000000000000000000000000000000000000000000000000815260040161095b9190610c3a565b60405180910390fd5b81905061096d565b5b9392505050565b5f815111156109865780518082602001fd5b6040517f1425ea4200000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b5f604051905090565b5f80fd5b5f80fd5b5f73ffffffffffffffffffffffffffffffffffffffff82169050919050565b5f6109f2826109c9565b9050919050565b610a02816109e8565b8114610a0c575f80fd5b50565b5f81359050610a1d816109f9565b92915050565b5f80fd5b5f80fd5b5f601f19601f8301169050919050565b7f4e487b71000000000000000000000000000000000000000000000000000000005f52604160045260245ffd5b610a7182610a2b565b810181811067ffffffffffffffff82111715610a9057610a8f610a3b565b5b80604052505050565b5f610aa26109b8565b9050610aae8282610a68565b919050565b5f67ffffffffffffffff821115610acd57610acc610a3b565b5b610ad682610a2b565b9050602081019050919050565b828183375f83830152505050565b5f610b03610afe84610ab3565b610a99565b905082815260208101848484011115610b1f57610b1e610a27565b5b610b2a848285610ae3565b509392505050565b5f82601f830112610b4657610b45610a23565b5b8135610b56848260208601610af1565b91505092915050565b5f8115159050919050565b610b7381610b5f565b8114610b7d575f80fd5b50565b5f81359050610b8e81610b6a565b92915050565b5f805f60608486031215610bab57610baa6109c1565b5b5f610bb886828701610a0f565b935050602084013567ffffffffffffffff811115610bd957610bd86109c5565b5b610be586828701610b32565b9250506040610bf686828701610b80565b9150509250925092565b5f60208284031215610c1557610c146109c1565b5b5f610c2284828501610a0f565b91505092915050565b610c34816109e8565b82525050565b5f602082019050610c4d5f830184610c2b565b92915050565b5f82825260208201905092915050565b7f45524331393637557067726164653a207570677261646520627265616b7320665f8201527f7572746865722075706772616465730000000000000000000000000000000000602082015250565b5f610cbd602f83610c53565b9150610cc882610c63565b604082019050919050565b5f6020820190508181035f830152610cea81610cb1565b9050919050565b5f604082019050610d045f830185610c2b565b610d116020830184610c2b565b9392505050565b5f81519050919050565b5f81905092915050565b5f5b83811015610d49578082015181840152602081019050610d2e565b5f8484015250505050565b5f610d5e82610d18565b610d688185610d22565b9350610d78818560208601610d2c565b80840191505092915050565b5f610d8f8284610d54565b915081905092915050565b7f6e6f7420636f6e747261637400000000000000000000000000000000000000005f82015250565b5f610dce600c83610c53565b9150610dd982610d9a565b602082019050919050565b5f6020820190508181035f830152610dfb81610dc2565b9050919050565b7f455243313936373a206e65772061646d696e20697320746865207a65726f20615f8201527f6464726573730000000000000000000000000000000000000000000000000000602082015250565b5f610e5c602683610c53565b9150610e6782610e02565b604082019050919050565b5f6020820190508181035f830152610e8981610e50565b905091905056fea2646970667358221220bab8df286ae2f47729fa3b4dcd54d83c3cb075f82e803b02fef510ae7e74192c64736f6c63430008140033

Verified Source Code Partial Match

Compiler: v0.8.20+commit.a1b79de6 EVM: shanghai Optimization: No
DriftProxy.sol 635 lines
// File: @openzeppelin/contracts/utils/StorageSlot.sol


// OpenZeppelin Contracts (last updated v5.0.0) (utils/StorageSlot.sol)
// This file was procedurally generated from scripts/generate/templates/StorageSlot.js.

pragma solidity ^0.8.20;

/**
 * @dev Library for reading and writing primitive types to specific storage slots.
 *
 * Storage slots are often used to avoid storage conflict when dealing with upgradeable contracts.
 * This library helps with reading and writing to such slots without the need for inline assembly.
 *
 * The functions in this library return Slot structs that contain a `value` member that can be used to read or write.
 *
 * Example usage to set ERC1967 implementation slot:
 * ```solidity
 * contract ERC1967 {
 *     bytes32 internal constant _IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc;
 *
 *     function _getImplementation() internal view returns (address) {
 *         return StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value;
 *     }
 *
 *     function _setImplementation(address newImplementation) internal {
 *         require(newImplementation.code.length > 0);
 *         StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value = newImplementation;
 *     }
 * }
 * ```
 */
library StorageSlot {
    struct AddressSlot {
        address value;
    }

    struct BooleanSlot {
        bool value;
    }

    struct Bytes32Slot {
        bytes32 value;
    }

    struct Uint256Slot {
        uint256 value;
    }

    struct StringSlot {
        string value;
    }

    struct BytesSlot {
        bytes value;
    }

    /**
     * @dev Returns an `AddressSlot` with member `value` located at `slot`.
     */
    function getAddressSlot(bytes32 slot) internal pure returns (AddressSlot storage r) {
        /// @solidity memory-safe-assembly
        assembly {
            r.slot := slot
        }
    }

    /**
     * @dev Returns an `BooleanSlot` with member `value` located at `slot`.
     */
    function getBooleanSlot(bytes32 slot) internal pure returns (BooleanSlot storage r) {
        /// @solidity memory-safe-assembly
        assembly {
            r.slot := slot
        }
    }

    /**
     * @dev Returns an `Bytes32Slot` with member `value` located at `slot`.
     */
    function getBytes32Slot(bytes32 slot) internal pure returns (Bytes32Slot storage r) {
        /// @solidity memory-safe-assembly
        assembly {
            r.slot := slot
        }
    }

    /**
     * @dev Returns an `Uint256Slot` with member `value` located at `slot`.
     */
    function getUint256Slot(bytes32 slot) internal pure returns (Uint256Slot storage r) {
        /// @solidity memory-safe-assembly
        assembly {
            r.slot := slot
        }
    }

    /**
     * @dev Returns an `StringSlot` with member `value` located at `slot`.
     */
    function getStringSlot(bytes32 slot) internal pure returns (StringSlot storage r) {
        /// @solidity memory-safe-assembly
        assembly {
            r.slot := slot
        }
    }

    /**
     * @dev Returns an `StringSlot` representation of the string storage pointer `store`.
     */
    function getStringSlot(string storage store) internal pure returns (StringSlot storage r) {
        /// @solidity memory-safe-assembly
        assembly {
            r.slot := store.slot
        }
    }

    /**
     * @dev Returns an `BytesSlot` with member `value` located at `slot`.
     */
    function getBytesSlot(bytes32 slot) internal pure returns (BytesSlot storage r) {
        /// @solidity memory-safe-assembly
        assembly {
            r.slot := slot
        }
    }

    /**
     * @dev Returns an `BytesSlot` representation of the bytes storage pointer `store`.
     */
    function getBytesSlot(bytes storage store) internal pure returns (BytesSlot storage r) {
        /// @solidity memory-safe-assembly
        assembly {
            r.slot := store.slot
        }
    }
}

// File: @openzeppelin/contracts/utils/Address.sol


// OpenZeppelin Contracts (last updated v5.0.0) (utils/Address.sol)

pragma solidity ^0.8.20;

/**
 * @dev Collection of functions related to the address type
 */
library Address {
    /**
     * @dev The ETH balance of the account is not enough to perform the operation.
     */
    error AddressInsufficientBalance(address account);

    /**
     * @dev There's no code at `target` (it is not a contract).
     */
    error AddressEmptyCode(address target);

    /**
     * @dev A call to an address target failed. The target may have reverted.
     */
    error FailedInnerCall();

    /**
     * @dev Replacement for Solidity's `transfer`: sends `amount` wei to
     * `recipient`, forwarding all available gas and reverting on errors.
     *
     * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost
     * of certain opcodes, possibly making contracts go over the 2300 gas limit
     * imposed by `transfer`, making them unable to receive funds via
     * `transfer`. {sendValue} removes this limitation.
     *
     * https://consensys.net/diligence/blog/2019/09/stop-using-soliditys-transfer-now/[Learn more].
     *
     * IMPORTANT: because control is transferred to `recipient`, care must be
     * taken to not create reentrancy vulnerabilities. Consider using
     * {ReentrancyGuard} or the
     * https://solidity.readthedocs.io/en/v0.8.20/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].
     */
    function sendValue(address payable recipient, uint256 amount) internal {
        if (address(this).balance < amount) {
            revert AddressInsufficientBalance(address(this));
        }

        (bool success, ) = recipient.call{value: amount}("");
        if (!success) {
            revert FailedInnerCall();
        }
    }

    /**
     * @dev Performs a Solidity function call using a low level `call`. A
     * plain `call` is an unsafe replacement for a function call: use this
     * function instead.
     *
     * If `target` reverts with a revert reason or custom error, it is bubbled
     * up by this function (like regular Solidity function calls). However, if
     * the call reverted with no returned reason, this function reverts with a
     * {FailedInnerCall} error.
     *
     * Returns the raw returned data. To convert to the expected return value,
     * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].
     *
     * Requirements:
     *
     * - `target` must be a contract.
     * - calling `target` with `data` must not revert.
     */
    function functionCall(address target, bytes memory data) internal returns (bytes memory) {
        return functionCallWithValue(target, data, 0);
    }

    /**
     * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
     * but also transferring `value` wei to `target`.
     *
     * Requirements:
     *
     * - the calling contract must have an ETH balance of at least `value`.
     * - the called Solidity function must be `payable`.
     */
    function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) {
        if (address(this).balance < value) {
            revert AddressInsufficientBalance(address(this));
        }
        (bool success, bytes memory returndata) = target.call{value: value}(data);
        return verifyCallResultFromTarget(target, success, returndata);
    }

    /**
     * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
     * but performing a static call.
     */
    function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {
        (bool success, bytes memory returndata) = target.staticcall(data);
        return verifyCallResultFromTarget(target, success, returndata);
    }

    /**
     * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
     * but performing a delegate call.
     */
    function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {
        (bool success, bytes memory returndata) = target.delegatecall(data);
        return verifyCallResultFromTarget(target, success, returndata);
    }

    /**
     * @dev Tool to verify that a low level call to smart-contract was successful, and reverts if the target
     * was not a contract or bubbling up the revert reason (falling back to {FailedInnerCall}) in case of an
     * unsuccessful call.
     */
    function verifyCallResultFromTarget(
        address target,
        bool success,
        bytes memory returndata
    ) internal view returns (bytes memory) {
        if (!success) {
            _revert(returndata);
        } else {
            // only check if target is a contract if the call was successful and the return data is empty
            // otherwise we already know that it was a contract
            if (returndata.length == 0 && target.code.length == 0) {
                revert AddressEmptyCode(target);
            }
            return returndata;
        }
    }

    /**
     * @dev Tool to verify that a low level call was successful, and reverts if it wasn't, either by bubbling the
     * revert reason or with a default {FailedInnerCall} error.
     */
    function verifyCallResult(bool success, bytes memory returndata) internal pure returns (bytes memory) {
        if (!success) {
            _revert(returndata);
        } else {
            return returndata;
        }
    }

    /**
     * @dev Reverts with returndata if present. Otherwise reverts with {FailedInnerCall}.
     */
    function _revert(bytes memory returndata) private pure {
        // Look for revert reason and bubble it up if present
        if (returndata.length > 0) {
            // The easiest way to bubble the revert reason is using memory via assembly
            /// @solidity memory-safe-assembly
            assembly {
                let returndata_size := mload(returndata)
                revert(add(32, returndata), returndata_size)
            }
        } else {
            revert FailedInnerCall();
        }
    }
}

// File: DriftProxy.sol


pragma solidity ^0.8.20;



/**
 * @dev This abstract contract provides a fallback function that delegates all calls to another contract using the EVM
 * instruction `delegatecall`. We refer to the second contract as the _implementation_ behind the proxy, and it has to
 * be specified by overriding the virtual {_implementation} function.
 *
 * Additionally, delegation to the implementation can be triggered manually through the {_fallback} function, or to a
 * different contract through the {_delegate} function.
 *
 * The success and return data of the delegated call will be returned back to the caller of the proxy.
 */
abstract contract Proxy {
    /**
     * @dev Delegates the current call to `implementation`.
     *
     * This function does not return to its internal call site, it will return directly to the external caller.
     */
    function _delegate(address implementation) internal {
        assembly {
            // Copy msg.data. We take full control of memory in this inline assembly
            // block because it will not return to Solidity code. We overwrite the
            // Solidity scratch pad at memory position 0.
            calldatacopy(0, 0, calldatasize())

            // Call the implementation.
            // out and outsize are 0 because we don't know the size yet.
            let result := delegatecall(gas(), implementation, 0, calldatasize(), 0, 0)

            // Copy the returned data.
            returndatacopy(0, 0, returndatasize())

            switch result
            // delegatecall returns 0 on error.
            case 0 {
                revert(0, returndatasize())
            }
            default {
                return(0, returndatasize())
            }
        }
    }

    /**
     * @dev This is a virtual function that should be overridden so it returns the address to which the fallback function
     * and {_fallback} should delegate.
     */
    function _implementation() internal view virtual returns (address);

    /**
     * @dev Delegates the current call to the address returned by `_implementation()`.
     *
     * This function does not return to its internal call site, it will return directly to the external caller.
     */
    function _fallback() internal {
        _beforeFallback();
        _delegate(_implementation());
    }

    /**
     * @dev Fallback function that delegates calls to the address returned by `_implementation()`. Will run if no other
     * function in the contract matches the call data.
     */
    fallback() external payable {
        _fallback();
    }

    /**
     * @dev Fallback function that delegates calls to the address returned by `_implementation()`. Will run if call data
     * is empty.
     */
    receive() external payable {
        _fallback();
    }

    /**
     * @dev Hook that is called before falling back to the implementation. Can happen as part of a manual `_fallback`
     * call, or as part of the Solidity `fallback` or `receive` functions.
     *
     * If overridden should call `super._beforeFallback()`.
     */
    function _beforeFallback() internal {}
}

/**
 * @dev This abstract contract provides getters and event emitting update functions for
 * https://eips.ethereum.org/EIPS/eip-1967[EIP1967] slots.
 */
abstract contract ERC1967Upgrade {
    // This is the keccak-256 hash of "drift.token.proxy.rollback" subtracted by 1
    bytes32 private constant _ROLLBACK_SLOT =
        0x9843adc2ce1ee58312ba81786d469e32c03edf6b0879757a3b7f4a49a98bfbc7;

    /**
     * @dev Storage slot with the address of the current implementation.
     * This is the keccak-256 hash of "drift.token.proxy.implementation" subtracted by 1, and is
     * validated in the constructor.
     */
    bytes32 internal constant _IMPLEMENTATION_SLOT =
        0x20882e7e0b3c1661dc1474ff6a22afb8e557e42e9ade77c07c8ee84ac37bea1b;

    /**
     * @dev Emitted when the implementation is upgraded.
     */
    event Upgraded(address indexed implementation);

    /**
     * @dev Returns the current implementation address.
     */
    function _getImplementation() internal view returns (address) {
        return StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value;
    }

    /**
     * @dev Stores a new address in the EIP1967 implementation slot.
     */
    function _setImplementation(address newImplementation) private {
        if (newImplementation.code.length == 0) {
            revert("not contract");
        }
        StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value = newImplementation;
    }

    /**
     * @dev Perform implementation upgrade
     *
     * Emits an {Upgraded} event.
     */
    function _upgradeTo(address newImplementation) internal {
        _setImplementation(newImplementation);
        emit Upgraded(newImplementation);
    }

    /**
     * @dev Perform implementation upgrade with additional setup call.
     *
     * Emits an {Upgraded} event.
     */
    function _upgradeToAndCall(
        address newImplementation,
        bytes memory data,
        bool forceCall
    ) internal {
        _upgradeTo(newImplementation);
        if (data.length > 0 || forceCall) {
            Address.functionDelegateCall(newImplementation, data);
        }
    }

    /**
     * @dev Perform implementation upgrade with security checks for UUPS proxies, and additional setup call.
     *
     * Emits an {Upgraded} event.
     */
    function _upgradeToAndCallSecure(
        address newImplementation,
        bytes memory data,
        bool forceCall
    ) internal {
        address oldImplementation = _getImplementation();

        // Initial upgrade and setup call
        _setImplementation(newImplementation);
        if (data.length > 0 || forceCall) {
            Address.functionDelegateCall(newImplementation, data);
        }

        // Perform rollback test if not already in progress
        StorageSlot.BooleanSlot storage rollbackTesting = StorageSlot.getBooleanSlot(
            _ROLLBACK_SLOT
        );
        if (!rollbackTesting.value) {
            // Trigger rollback using upgradeTo from the new implementation
            rollbackTesting.value = true;
            Address.functionDelegateCall(
                newImplementation,
                abi.encodeWithSignature("upgradeTo(address)", oldImplementation)
            );
            rollbackTesting.value = false;
            // Check rollback was effective
            require(
                oldImplementation == _getImplementation(),
                "ERC1967Upgrade: upgrade breaks further upgrades"
            );
            // Finally reset to the new implementation and log the upgrade
            _upgradeTo(newImplementation);
        }
    }

    /**
     * @dev Storage slot with the admin of the contract.
     * This is the keccak-256 hash of "drift.token.proxy.admin" subtracted by 1, and is
     * validated in the constructor.
     */
    bytes32 internal constant _ADMIN_SLOT =
        0x444d5549c1b0fc679fe1d30daefb9b9e9d70ad980174932fc88b58cd57e10211;

    /**
     * @dev Emitted when the admin account has changed.
     */
    event AdminChanged(address previousAdmin, address newAdmin);

    /**
     * @dev Returns the current admin.
     */
    function _getAdmin() internal view returns (address) {
        return StorageSlot.getAddressSlot(_ADMIN_SLOT).value;
    }

    /**
     * @dev Stores a new address in the EIP1967 admin slot.
     */
    function _setAdmin(address newAdmin) private {
        require(newAdmin != address(0), "ERC1967: new admin is the zero address");
        StorageSlot.getAddressSlot(_ADMIN_SLOT).value = newAdmin;
    }

    /**
     * @dev Changes the admin of the proxy.
     *
     * Emits an {AdminChanged} event.
     */
    function _changeAdmin(address newAdmin) internal {
        emit AdminChanged(_getAdmin(), newAdmin);
        _setAdmin(newAdmin);
    }
}

contract DriftProxy is Proxy, ERC1967Upgrade {
    constructor(address _logic, bytes memory _data) payable {
        assert(
            _IMPLEMENTATION_SLOT ==
                bytes32(uint256(keccak256("drift.token.proxy.implementation")) - 1) &&
                _ADMIN_SLOT == bytes32(uint256(keccak256("drift.token.proxy.admin")) - 1)
        );
        _upgradeToAndCall(_logic, _data, false);
        _changeAdmin(msg.sender);
    }

    modifier isProxyAdmin() {
        if (msg.sender == _getAdmin()) {
            _;
        }
    }

    modifier isProxyAdminWithFallback() {
        if (msg.sender == _getAdmin()) {
            _;
        } else {
            _fallback();
        }
    }

    /**
     * @dev Returns the current implementation address.
     */
    function _implementation() internal view virtual override returns (address impl) {
        return ERC1967Upgrade._getImplementation();
    }

    /**
     * @return impl The address of the implementation.
     */
    function implementation() external view isProxyAdmin returns (address impl) {
        return _implementation();
    }

    /**
     * @return adm The address of the proxy admin.
     */
    function admin() external view isProxyAdmin returns (address adm) {
        return _getAdmin();
    }

    /**
     * @dev Changes the admin of the proxy.
     * Only the current admin can call this function.
     * @param newAdmin Address to transfer proxy administration to.
     */
    function changeAdmin(address newAdmin) external isProxyAdminWithFallback {
        _changeAdmin(newAdmin);
    }

    /**
     * @dev Upgrade the backing implementation of the proxy.
     * Only the admin can call this function.
     * @param newImplementation Address of the new implementation.
     */
    function upgradeTo(address newImplementation) external isProxyAdminWithFallback {
        _upgradeTo(newImplementation);
    }

    /**
     * @dev Upgrade the backing implementation of the proxy and call a function
     * on the new implementation.
     * This is useful to initialize the proxied contract.
     * @param newImplementation Address of the new implementation.
     * @param data Data to send as msg.data in the low level call.
     * @param forceCall Boolean check to force call.
     * It should include the signature and the parameters of the function to be
     * called, as described in
     * https://solidity.readthedocs.io/en/develop/abi-spec.html#function-selector-and-argument-encoding.
     */
    function upgradeToAndCall(
        address newImplementation,
        bytes memory data,
        bool forceCall
    ) external payable isProxyAdminWithFallback {
        _upgradeToAndCall(newImplementation, data, forceCall);
    }

    /**
     * @dev Upgrade the backing implementation of the proxy and call a function
     * on the new implementation.
     * This is useful to initialize the proxied contract.
     * @param newImplementation Address of the new implementation.
     * @param data Data to send as msg.data in the low level call.
     * @param forceCall Boolean check to force call.
     * It should include the signature and the parameters of the function to be
     * called, as described in
     * https://solidity.readthedocs.io/en/develop/abi-spec.html#function-selector-and-argument-encoding.
     */
    function upgradeToAndCallSecure(
        address newImplementation,
        bytes memory data,
        bool forceCall
    ) external payable isProxyAdminWithFallback {
        _upgradeToAndCallSecure(newImplementation, data, forceCall);
    }
}

Read Contract

admin 0xf851a440 → address
implementation 0x5c60da1b → address

Write Contract 4 functions

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

changeAdmin 0x8f283970
address newAdmin
upgradeTo 0x3659cfe6
address newImplementation
upgradeToAndCall 0x06d2e426
address newImplementation
bytes data
bool forceCall
upgradeToAndCallSecure 0x559e0e03
address newImplementation
bytes data
bool forceCall

Recent Transactions

No transactions found for this address