Forkchoice Ethereum Mainnet

Address Contract Partially Verified

Address 0x7C2230a01DF134A632aFDdcEc962Bf1E9eb659fF
Balance 0 ETH
Nonce 1
Code Size 3394 bytes
Indexed Transactions 0 (1 on-chain, 0.8% indexed)
External Etherscan · Sourcify

Contract Bytecode

3394 bytes
0x608060405234801561000f575f80fd5b50600436106100f0575f3560e01c8063b31c710a11610093578063d7dfc7c211610063578063d7dfc7c2146101d2578063ddac6654146101e5578063e33f2499146101fc578063f2fde38b1461020f575f80fd5b8063b31c710a14610186578063c42bd05a14610199578063ca212509146101ac578063cbdf382c146101bf575f80fd5b806380ea5961116100ce57806380ea59611461012457806381620863146101375780638da5cb5b1461014a5780639dd1ed1b14610173575f80fd5b806327669255146100f45780635bcb318a14610109578063715018a61461011c575b5f80fd5b610107610102366004610b69565b610222565b005b610107610117366004610bbd565b610318565b610107610325565b610107610132366004610bd4565b610338565b610107610145366004610bbd565b610416565b5f546001600160a01b03165b6040516001600160a01b0390911681526020015b60405180910390f35b610107610181366004610bbd565b610438565b600154610156906001600160a01b031681565b600254610156906001600160a01b031681565b6101076101ba366004610bd4565b6104b6565b600354610156906001600160a01b031681565b6101076101e0366004610b69565b610667565b6101ee60045481565b60405190815260200161016a565b61010761020a366004610bbd565b610834565b61010761021d366004610c17565b610853565b600454421061024c5760405162461bcd60e51b815260040161024390610c30565b60405180910390fd5b60015460405163d505accf60e01b81526001600160a01b039091169063d505accf9061028890899030908a908a908a908a908a90600401610c5f565b5f604051808303815f87803b15801561029f575f80fd5b505af19250505080156102b0575060015b506001546102c9906001600160a01b031687308861088d565b6002546102e0906001600160a01b031687876108fa565b856001600160a01b03165f80516020610ced8339815191528660405161030891815260200190565b60405180910390a2505050505050565b610320610930565b600455565b61032d610930565b6103365f61095c565b565b60045442106103595760405162461bcd60e51b815260040161024390610c30565b60015460405163d505accf60e01b81526001600160a01b039091169063d505accf9061039590339030908a908a908a908a908a90600401610c5f565b5f604051808303815f87803b1580156103ac575f80fd5b505af19250505080156103bd575060015b506001546103d6906001600160a01b031633308861088d565b6002546103ed906001600160a01b031633876108fa565b60405185815233905f80516020610ced8339815191529060200160405180910390a25050505050565b61041e610930565b600154610435906001600160a01b031633836108fa565b50565b610440610930565b60035460405163a9059cbb60e01b8152336004820152602481018390526001600160a01b039091169063a9059cbb906044016020604051808303815f875af115801561048e573d5f803e3d5ffd5b505050506040513d601f19601f820116820180604052508101906104b29190610ca0565b5050565b60045442106104d75760405162461bcd60e51b815260040161024390610c30565b60035460405163d505accf60e01b81526001600160a01b039091169063d505accf9061051390339030908a908a908a908a908a90600401610c5f565b5f604051808303815f87803b15801561052a575f80fd5b505af192505050801561053b575060015b506003546040516323b872dd60e01b8152336004820152306024820152604481018790526001600160a01b03909116906323b872dd906064016020604051808303815f875af1158015610590573d5f803e3d5ffd5b505050506040513d601f19601f820116820180604052508101906105b49190610ca0565b50600354604051635d043b2960e11b815260048101879052306024820181905260448201525f916001600160a01b03169063ba087652906064016020604051808303815f875af115801561060a573d5f803e3d5ffd5b505050506040513d601f19601f8201168201806040525081019061062e9190610cbf565b600254909150610648906001600160a01b031633836108fa565b60405181815233905f80516020610ced83398151915290602001610308565b60045442106106885760405162461bcd60e51b815260040161024390610c30565b60035460405163d505accf60e01b81526001600160a01b039091169063d505accf906106c490899030908a908a908a908a908a90600401610c5f565b5f604051808303815f87803b1580156106db575f80fd5b505af19250505080156106ec575060015b506003546040516323b872dd60e01b81526001600160a01b03888116600483015230602483015260448201889052909116906323b872dd906064016020604051808303815f875af1158015610743573d5f803e3d5ffd5b505050506040513d601f19601f820116820180604052508101906107679190610ca0565b50600354604051635d043b2960e11b815260048101879052306024820181905260448201525f916001600160a01b03169063ba087652906064016020604051808303815f875af11580156107bd573d5f803e3d5ffd5b505050506040513d601f19601f820116820180604052508101906107e19190610cbf565b6002549091506107fb906001600160a01b031688836108fa565b866001600160a01b03165f80516020610ced8339815191528260405161082391815260200190565b60405180910390a250505050505050565b61083c610930565b600254610435906001600160a01b031633836108fa565b61085b610930565b6001600160a01b03811661088457604051631e4fbdf760e01b81525f6004820152602401610243565b6104358161095c565b6040516001600160a01b0384811660248301528381166044830152606482018390526108f49186918216906323b872dd906084015b604051602081830303815290604052915060e01b6020820180516001600160e01b0383818316178352505050506109ab565b50505050565b6040516001600160a01b0383811660248301526044820183905261092b91859182169063a9059cbb906064016108c2565b505050565b5f546001600160a01b031633146103365760405163118cdaa760e01b8152336004820152602401610243565b5f80546001600160a01b038381166001600160a01b0319831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b5f6109bf6001600160a01b03841683610a0c565b905080515f141580156109e35750808060200190518101906109e19190610ca0565b155b1561092b57604051635274afe760e01b81526001600160a01b0384166004820152602401610243565b6060610a1983835f610a20565b9392505050565b606081471015610a455760405163cd78605960e01b8152306004820152602401610243565b5f80856001600160a01b03168486604051610a609190610cd6565b5f6040518083038185875af1925050503d805f8114610a9a576040519150601f19603f3d011682016040523d82523d5f602084013e610a9f565b606091505b5091509150610aaf868383610ab9565b9695505050505050565b606082610ace57610ac982610b15565b610a19565b8151158015610ae557506001600160a01b0384163b155b15610b0e57604051639996b31560e01b81526001600160a01b0385166004820152602401610243565b5080610a19565b805115610b255780518082602001fd5b604051630a12f52160e11b815260040160405180910390fd5b80356001600160a01b0381168114610b54575f80fd5b919050565b803560ff81168114610b54575f80fd5b5f805f805f8060c08789031215610b7e575f80fd5b610b8787610b3e565b95506020870135945060408701359350610ba360608801610b59565b9598949750929560808101359460a0909101359350915050565b5f60208284031215610bcd575f80fd5b5035919050565b5f805f805f60a08688031215610be8575f80fd5b8535945060208601359350610bff60408701610b59565b94979396509394606081013594506080013592915050565b5f60208284031215610c27575f80fd5b610a1982610b3e565b602080825260159082015274135a59dc985d1a5bdb881a5cc8191a5cd8589b1959605a1b604082015260600190565b6001600160a01b0397881681529590961660208601526040850193909352606084019190915260ff16608083015260a082015260c081019190915260e00190565b5f60208284031215610cb0575f80fd5b81518015158114610a19575f80fd5b5f60208284031215610ccf575f80fd5b5051919050565b5f82518060208501845e5f92019182525091905056fe8b80bd19aea7b735bc6d75db8d6adbe18b28c30d62b3555245eb67b2340caedca2646970667358221220eec787246d1f3b74fabe29031c566e72fcd100d1ccb4ead1d311125b2588fe6c64736f6c634300081a0033

Verified Source Code Partial Match

Compiler: v0.8.26+commit.8a97fa7a EVM: cancun Optimization: Yes (200 runs)
XdefiToCtrlMigration.sol 1019 lines
// File: @openzeppelin/contracts/token/ERC20/IERC20.sol


// OpenZeppelin Contracts (last updated v5.0.0) (token/ERC20/IERC20.sol)

pragma solidity ^0.8.20;

/**
 * @dev Interface of the ERC20 standard as defined in the EIP.
 */
interface IERC20 {
    /**
     * @dev Emitted when `value` tokens are moved from one account (`from`) to
     * another (`to`).
     *
     * Note that `value` may be zero.
     */
    event Transfer(address indexed from, address indexed to, uint256 value);

    /**
     * @dev Emitted when the allowance of a `spender` for an `owner` is set by
     * a call to {approve}. `value` is the new allowance.
     */
    event Approval(address indexed owner, address indexed spender, uint256 value);

    /**
     * @dev Returns the value of tokens in existence.
     */
    function totalSupply() external view returns (uint256);

    /**
     * @dev Returns the value of tokens owned by `account`.
     */
    function balanceOf(address account) external view returns (uint256);

    /**
     * @dev Moves a `value` amount of tokens from the caller's account to `to`.
     *
     * Returns a boolean value indicating whether the operation succeeded.
     *
     * Emits a {Transfer} event.
     */
    function transfer(address to, uint256 value) external returns (bool);

    /**
     * @dev Returns the remaining number of tokens that `spender` will be
     * allowed to spend on behalf of `owner` through {transferFrom}. This is
     * zero by default.
     *
     * This value changes when {approve} or {transferFrom} are called.
     */
    function allowance(address owner, address spender) external view returns (uint256);

    /**
     * @dev Sets a `value` amount of tokens as the allowance of `spender` over the
     * caller's tokens.
     *
     * Returns a boolean value indicating whether the operation succeeded.
     *
     * IMPORTANT: Beware that changing an allowance with this method brings the risk
     * that someone may use both the old and the new allowance by unfortunate
     * transaction ordering. One possible solution to mitigate this race
     * condition is to first reduce the spender's allowance to 0 and set the
     * desired value afterwards:
     * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
     *
     * Emits an {Approval} event.
     */
    function approve(address spender, uint256 value) external returns (bool);

    /**
     * @dev Moves a `value` amount of tokens from `from` to `to` using the
     * allowance mechanism. `value` is then deducted from the caller's
     * allowance.
     *
     * Returns a boolean value indicating whether the operation succeeded.
     *
     * Emits a {Transfer} event.
     */
    function transferFrom(address from, address to, uint256 value) external returns (bool);
}

// File: @openzeppelin/contracts/token/ERC20/extensions/IERC20Permit.sol


// OpenZeppelin Contracts (last updated v5.0.0) (token/ERC20/extensions/IERC20Permit.sol)

pragma solidity ^0.8.20;

/**
 * @dev Interface of the ERC20 Permit extension allowing approvals to be made via signatures, as defined in
 * https://eips.ethereum.org/EIPS/eip-2612[EIP-2612].
 *
 * Adds the {permit} method, which can be used to change an account's ERC20 allowance (see {IERC20-allowance}) by
 * presenting a message signed by the account. By not relying on {IERC20-approve}, the token holder account doesn't
 * need to send a transaction, and thus is not required to hold Ether at all.
 *
 * ==== Security Considerations
 *
 * There are two important considerations concerning the use of `permit`. The first is that a valid permit signature
 * expresses an allowance, and it should not be assumed to convey additional meaning. In particular, it should not be
 * considered as an intention to spend the allowance in any specific way. The second is that because permits have
 * built-in replay protection and can be submitted by anyone, they can be frontrun. A protocol that uses permits should
 * take this into consideration and allow a `permit` call to fail. Combining these two aspects, a pattern that may be
 * generally recommended is:
 *
 * ```solidity
 * function doThingWithPermit(..., uint256 value, uint256 deadline, uint8 v, bytes32 r, bytes32 s) public {
 *     try token.permit(msg.sender, address(this), value, deadline, v, r, s) {} catch {}
 *     doThing(..., value);
 * }
 *
 * function doThing(..., uint256 value) public {
 *     token.safeTransferFrom(msg.sender, address(this), value);
 *     ...
 * }
 * ```
 *
 * Observe that: 1) `msg.sender` is used as the owner, leaving no ambiguity as to the signer intent, and 2) the use of
 * `try/catch` allows the permit to fail and makes the code tolerant to frontrunning. (See also
 * {SafeERC20-safeTransferFrom}).
 *
 * Additionally, note that smart contract wallets (such as Argent or Safe) are not able to produce permit signatures, so
 * contracts should have entry points that don't rely on permit.
 */
interface IERC20Permit {
    /**
     * @dev Sets `value` as the allowance of `spender` over ``owner``'s tokens,
     * given ``owner``'s signed approval.
     *
     * IMPORTANT: The same issues {IERC20-approve} has related to transaction
     * ordering also apply here.
     *
     * Emits an {Approval} event.
     *
     * Requirements:
     *
     * - `spender` cannot be the zero address.
     * - `deadline` must be a timestamp in the future.
     * - `v`, `r` and `s` must be a valid `secp256k1` signature from `owner`
     * over the EIP712-formatted function arguments.
     * - the signature must use ``owner``'s current nonce (see {nonces}).
     *
     * For more information on the signature format, see the
     * https://eips.ethereum.org/EIPS/eip-2612#specification[relevant EIP
     * section].
     *
     * CAUTION: See Security Considerations above.
     */
    function permit(
        address owner,
        address spender,
        uint256 value,
        uint256 deadline,
        uint8 v,
        bytes32 r,
        bytes32 s
    ) external;

    /**
     * @dev Returns the current nonce for `owner`. This value must be
     * included whenever a signature is generated for {permit}.
     *
     * Every successful call to {permit} increases ``owner``'s nonce by one. This
     * prevents a signature from being used multiple times.
     */
    function nonces(address owner) external view returns (uint256);

    /**
     * @dev Returns the domain separator used in the encoding of the signature for {permit}, as defined by {EIP712}.
     */
    // solhint-disable-next-line func-name-mixedcase
    function DOMAIN_SEPARATOR() external view returns (bytes32);
}

// 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: @openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol


// OpenZeppelin Contracts (last updated v5.0.0) (token/ERC20/utils/SafeERC20.sol)

pragma solidity ^0.8.20;




/**
 * @title SafeERC20
 * @dev Wrappers around ERC20 operations that throw on failure (when the token
 * contract returns false). Tokens that return no value (and instead revert or
 * throw on failure) are also supported, non-reverting calls are assumed to be
 * successful.
 * To use this library you can add a `using SafeERC20 for IERC20;` statement to your contract,
 * which allows you to call the safe operations as `token.safeTransfer(...)`, etc.
 */
library SafeERC20 {
    using Address for address;

    /**
     * @dev An operation with an ERC20 token failed.
     */
    error SafeERC20FailedOperation(address token);

    /**
     * @dev Indicates a failed `decreaseAllowance` request.
     */
    error SafeERC20FailedDecreaseAllowance(address spender, uint256 currentAllowance, uint256 requestedDecrease);

    /**
     * @dev Transfer `value` amount of `token` from the calling contract to `to`. If `token` returns no value,
     * non-reverting calls are assumed to be successful.
     */
    function safeTransfer(IERC20 token, address to, uint256 value) internal {
        _callOptionalReturn(token, abi.encodeCall(token.transfer, (to, value)));
    }

    /**
     * @dev Transfer `value` amount of `token` from `from` to `to`, spending the approval given by `from` to the
     * calling contract. If `token` returns no value, non-reverting calls are assumed to be successful.
     */
    function safeTransferFrom(IERC20 token, address from, address to, uint256 value) internal {
        _callOptionalReturn(token, abi.encodeCall(token.transferFrom, (from, to, value)));
    }

    /**
     * @dev Increase the calling contract's allowance toward `spender` by `value`. If `token` returns no value,
     * non-reverting calls are assumed to be successful.
     */
    function safeIncreaseAllowance(IERC20 token, address spender, uint256 value) internal {
        uint256 oldAllowance = token.allowance(address(this), spender);
        forceApprove(token, spender, oldAllowance + value);
    }

    /**
     * @dev Decrease the calling contract's allowance toward `spender` by `requestedDecrease`. If `token` returns no
     * value, non-reverting calls are assumed to be successful.
     */
    function safeDecreaseAllowance(IERC20 token, address spender, uint256 requestedDecrease) internal {
        unchecked {
            uint256 currentAllowance = token.allowance(address(this), spender);
            if (currentAllowance < requestedDecrease) {
                revert SafeERC20FailedDecreaseAllowance(spender, currentAllowance, requestedDecrease);
            }
            forceApprove(token, spender, currentAllowance - requestedDecrease);
        }
    }

    /**
     * @dev Set the calling contract's allowance toward `spender` to `value`. If `token` returns no value,
     * non-reverting calls are assumed to be successful. Meant to be used with tokens that require the approval
     * to be set to zero before setting it to a non-zero value, such as USDT.
     */
    function forceApprove(IERC20 token, address spender, uint256 value) internal {
        bytes memory approvalCall = abi.encodeCall(token.approve, (spender, value));

        if (!_callOptionalReturnBool(token, approvalCall)) {
            _callOptionalReturn(token, abi.encodeCall(token.approve, (spender, 0)));
            _callOptionalReturn(token, approvalCall);
        }
    }

    /**
     * @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement
     * on the return value: the return value is optional (but if data is returned, it must not be false).
     * @param token The token targeted by the call.
     * @param data The call data (encoded using abi.encode or one of its variants).
     */
    function _callOptionalReturn(IERC20 token, bytes memory data) private {
        // We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since
        // we're implementing it ourselves. We use {Address-functionCall} to perform this call, which verifies that
        // the target address contains contract code and also asserts for success in the low-level call.

        bytes memory returndata = address(token).functionCall(data);
        if (returndata.length != 0 && !abi.decode(returndata, (bool))) {
            revert SafeERC20FailedOperation(address(token));
        }
    }

    /**
     * @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement
     * on the return value: the return value is optional (but if data is returned, it must not be false).
     * @param token The token targeted by the call.
     * @param data The call data (encoded using abi.encode or one of its variants).
     *
     * This is a variant of {_callOptionalReturn} that silents catches all reverts and returns a bool instead.
     */
    function _callOptionalReturnBool(IERC20 token, bytes memory data) private returns (bool) {
        // We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since
        // we're implementing it ourselves. We cannot use {Address-functionCall} here since this should return false
        // and not revert is the subcall reverts.

        (bool success, bytes memory returndata) = address(token).call(data);
        return success && (returndata.length == 0 || abi.decode(returndata, (bool))) && address(token).code.length > 0;
    }
}

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


// 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;
    }
}

// File: @openzeppelin/contracts/access/Ownable.sol


// OpenZeppelin Contracts (last updated v5.0.0) (access/Ownable.sol)

pragma solidity ^0.8.20;


/**
 * @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);
    }
}

// File: @openzeppelin/contracts/token/ERC20/extensions/IERC20Metadata.sol


// OpenZeppelin Contracts (last updated v5.0.0) (token/ERC20/extensions/IERC20Metadata.sol)

pragma solidity ^0.8.20;


/**
 * @dev Interface for the optional metadata functions from the ERC20 standard.
 */
interface IERC20Metadata is IERC20 {
    /**
     * @dev Returns the name of the token.
     */
    function name() external view returns (string memory);

    /**
     * @dev Returns the symbol of the token.
     */
    function symbol() external view returns (string memory);

    /**
     * @dev Returns the decimals places of the token.
     */
    function decimals() external view returns (uint8);
}

// File: @openzeppelin/contracts/interfaces/IERC4626.sol


// OpenZeppelin Contracts (last updated v5.0.0) (interfaces/IERC4626.sol)

pragma solidity ^0.8.20;



/**
 * @dev Interface of the ERC4626 "Tokenized Vault Standard", as defined in
 * https://eips.ethereum.org/EIPS/eip-4626[ERC-4626].
 */
interface IERC4626 is IERC20, IERC20Metadata {
    event Deposit(address indexed sender, address indexed owner, uint256 assets, uint256 shares);

    event Withdraw(
        address indexed sender,
        address indexed receiver,
        address indexed owner,
        uint256 assets,
        uint256 shares
    );

    /**
     * @dev Returns the address of the underlying token used for the Vault for accounting, depositing, and withdrawing.
     *
     * - MUST be an ERC-20 token contract.
     * - MUST NOT revert.
     */
    function asset() external view returns (address assetTokenAddress);

    /**
     * @dev Returns the total amount of the underlying asset that is “managed” by Vault.
     *
     * - SHOULD include any compounding that occurs from yield.
     * - MUST be inclusive of any fees that are charged against assets in the Vault.
     * - MUST NOT revert.
     */
    function totalAssets() external view returns (uint256 totalManagedAssets);

    /**
     * @dev Returns the amount of shares that the Vault would exchange for the amount of assets provided, in an ideal
     * scenario where all the conditions are met.
     *
     * - MUST NOT be inclusive of any fees that are charged against assets in the Vault.
     * - MUST NOT show any variations depending on the caller.
     * - MUST NOT reflect slippage or other on-chain conditions, when performing the actual exchange.
     * - MUST NOT revert.
     *
     * NOTE: This calculation MAY NOT reflect the “per-user” price-per-share, and instead should reflect the
     * “average-user’s” price-per-share, meaning what the average user should expect to see when exchanging to and
     * from.
     */
    function convertToShares(uint256 assets) external view returns (uint256 shares);

    /**
     * @dev Returns the amount of assets that the Vault would exchange for the amount of shares provided, in an ideal
     * scenario where all the conditions are met.
     *
     * - MUST NOT be inclusive of any fees that are charged against assets in the Vault.
     * - MUST NOT show any variations depending on the caller.
     * - MUST NOT reflect slippage or other on-chain conditions, when performing the actual exchange.
     * - MUST NOT revert.
     *
     * NOTE: This calculation MAY NOT reflect the “per-user” price-per-share, and instead should reflect the
     * “average-user’s” price-per-share, meaning what the average user should expect to see when exchanging to and
     * from.
     */
    function convertToAssets(uint256 shares) external view returns (uint256 assets);

    /**
     * @dev Returns the maximum amount of the underlying asset that can be deposited into the Vault for the receiver,
     * through a deposit call.
     *
     * - MUST return a limited value if receiver is subject to some deposit limit.
     * - MUST return 2 ** 256 - 1 if there is no limit on the maximum amount of assets that may be deposited.
     * - MUST NOT revert.
     */
    function maxDeposit(address receiver) external view returns (uint256 maxAssets);

    /**
     * @dev Allows an on-chain or off-chain user to simulate the effects of their deposit at the current block, given
     * current on-chain conditions.
     *
     * - MUST return as close to and no more than the exact amount of Vault shares that would be minted in a deposit
     *   call in the same transaction. I.e. deposit should return the same or more shares as previewDeposit if called
     *   in the same transaction.
     * - MUST NOT account for deposit limits like those returned from maxDeposit and should always act as though the
     *   deposit would be accepted, regardless if the user has enough tokens approved, etc.
     * - MUST be inclusive of deposit fees. Integrators should be aware of the existence of deposit fees.
     * - MUST NOT revert.
     *
     * NOTE: any unfavorable discrepancy between convertToShares and previewDeposit SHOULD be considered slippage in
     * share price or some other type of condition, meaning the depositor will lose assets by depositing.
     */
    function previewDeposit(uint256 assets) external view returns (uint256 shares);

    /**
     * @dev Mints shares Vault shares to receiver by depositing exactly amount of underlying tokens.
     *
     * - MUST emit the Deposit event.
     * - MAY support an additional flow in which the underlying tokens are owned by the Vault contract before the
     *   deposit execution, and are accounted for during deposit.
     * - MUST revert if all of assets cannot be deposited (due to deposit limit being reached, slippage, the user not
     *   approving enough underlying tokens to the Vault contract, etc).
     *
     * NOTE: most implementations will require pre-approval of the Vault with the Vault’s underlying asset token.
     */
    function deposit(uint256 assets, address receiver) external returns (uint256 shares);

    /**
     * @dev Returns the maximum amount of the Vault shares that can be minted for the receiver, through a mint call.
     * - MUST return a limited value if receiver is subject to some mint limit.
     * - MUST return 2 ** 256 - 1 if there is no limit on the maximum amount of shares that may be minted.
     * - MUST NOT revert.
     */
    function maxMint(address receiver) external view returns (uint256 maxShares);

    /**
     * @dev Allows an on-chain or off-chain user to simulate the effects of their mint at the current block, given
     * current on-chain conditions.
     *
     * - MUST return as close to and no fewer than the exact amount of assets that would be deposited in a mint call
     *   in the same transaction. I.e. mint should return the same or fewer assets as previewMint if called in the
     *   same transaction.
     * - MUST NOT account for mint limits like those returned from maxMint and should always act as though the mint
     *   would be accepted, regardless if the user has enough tokens approved, etc.
     * - MUST be inclusive of deposit fees. Integrators should be aware of the existence of deposit fees.
     * - MUST NOT revert.
     *
     * NOTE: any unfavorable discrepancy between convertToAssets and previewMint SHOULD be considered slippage in
     * share price or some other type of condition, meaning the depositor will lose assets by minting.
     */
    function previewMint(uint256 shares) external view returns (uint256 assets);

    /**
     * @dev Mints exactly shares Vault shares to receiver by depositing amount of underlying tokens.
     *
     * - MUST emit the Deposit event.
     * - MAY support an additional flow in which the underlying tokens are owned by the Vault contract before the mint
     *   execution, and are accounted for during mint.
     * - MUST revert if all of shares cannot be minted (due to deposit limit being reached, slippage, the user not
     *   approving enough underlying tokens to the Vault contract, etc).
     *
     * NOTE: most implementations will require pre-approval of the Vault with the Vault’s underlying asset token.
     */
    function mint(uint256 shares, address receiver) external returns (uint256 assets);

    /**
     * @dev Returns the maximum amount of the underlying asset that can be withdrawn from the owner balance in the
     * Vault, through a withdraw call.
     *
     * - MUST return a limited value if owner is subject to some withdrawal limit or timelock.
     * - MUST NOT revert.
     */
    function maxWithdraw(address owner) external view returns (uint256 maxAssets);

    /**
     * @dev Allows an on-chain or off-chain user to simulate the effects of their withdrawal at the current block,
     * given current on-chain conditions.
     *
     * - MUST return as close to and no fewer than the exact amount of Vault shares that would be burned in a withdraw
     *   call in the same transaction. I.e. withdraw should return the same or fewer shares as previewWithdraw if
     *   called
     *   in the same transaction.
     * - MUST NOT account for withdrawal limits like those returned from maxWithdraw and should always act as though
     *   the withdrawal would be accepted, regardless if the user has enough shares, etc.
     * - MUST be inclusive of withdrawal fees. Integrators should be aware of the existence of withdrawal fees.
     * - MUST NOT revert.
     *
     * NOTE: any unfavorable discrepancy between convertToShares and previewWithdraw SHOULD be considered slippage in
     * share price or some other type of condition, meaning the depositor will lose assets by depositing.
     */
    function previewWithdraw(uint256 assets) external view returns (uint256 shares);

    /**
     * @dev Burns shares from owner and sends exactly assets of underlying tokens to receiver.
     *
     * - MUST emit the Withdraw event.
     * - MAY support an additional flow in which the underlying tokens are owned by the Vault contract before the
     *   withdraw execution, and are accounted for during withdraw.
     * - MUST revert if all of assets cannot be withdrawn (due to withdrawal limit being reached, slippage, the owner
     *   not having enough shares, etc).
     *
     * Note that some implementations will require pre-requesting to the Vault before a withdrawal may be performed.
     * Those methods should be performed separately.
     */
    function withdraw(uint256 assets, address receiver, address owner) external returns (uint256 shares);

    /**
     * @dev Returns the maximum amount of Vault shares that can be redeemed from the owner balance in the Vault,
     * through a redeem call.
     *
     * - MUST return a limited value if owner is subject to some withdrawal limit or timelock.
     * - MUST return balanceOf(owner) if owner is not subject to any withdrawal limit or timelock.
     * - MUST NOT revert.
     */
    function maxRedeem(address owner) external view returns (uint256 maxShares);

    /**
     * @dev Allows an on-chain or off-chain user to simulate the effects of their redeemption at the current block,
     * given current on-chain conditions.
     *
     * - MUST return as close to and no more than the exact amount of assets that would be withdrawn in a redeem call
     *   in the same transaction. I.e. redeem should return the same or more assets as previewRedeem if called in the
     *   same transaction.
     * - MUST NOT account for redemption limits like those returned from maxRedeem and should always act as though the
     *   redemption would be accepted, regardless if the user has enough shares, etc.
     * - MUST be inclusive of withdrawal fees. Integrators should be aware of the existence of withdrawal fees.
     * - MUST NOT revert.
     *
     * NOTE: any unfavorable discrepancy between convertToAssets and previewRedeem SHOULD be considered slippage in
     * share price or some other type of condition, meaning the depositor will lose assets by redeeming.
     */
    function previewRedeem(uint256 shares) external view returns (uint256 assets);

    /**
     * @dev Burns exactly shares from owner and sends assets of underlying tokens to receiver.
     *
     * - MUST emit the Withdraw event.
     * - MAY support an additional flow in which the underlying tokens are owned by the Vault contract before the
     *   redeem execution, and are accounted for during redeem.
     * - MUST revert if all of shares cannot be redeemed (due to withdrawal limit being reached, slippage, the owner
     *   not having enough shares, etc).
     *
     * NOTE: some implementations will require pre-requesting to the Vault before a withdrawal may be performed.
     * Those methods should be performed separately.
     */
    function redeem(uint256 shares, address receiver, address owner) external returns (uint256 assets);
}

// File: migration/contracts/XdefiToCtrlMigration.sol


pragma solidity ^0.8.0;





contract XdefiToCtrlMigration is Ownable {
    using SafeERC20 for IERC20;

    IERC20 public oldToken;
    IERC20 public newToken;
    IERC4626 public poolToken;
    uint256 public validUntil;

    event Migrated(address indexed user, uint256 amount);

    /**
        * @dev Throws if the migration is disabled.
        * The migration is disabled after the validUntil timestamp.
    */
    modifier timeLock() {
        require(block.timestamp < validUntil, "Migration is disabled");
        _;
    }

    /**
     * @dev Initializes the contract with the old token, new token, and pool token addresses.
     * @param _oldToken The address of the old token (XDEFI).
     * @param _newToken The address of the new token (CTRL).
     * @param _poolToken The address of the pool token (vXDEFI).
     */
    constructor(IERC20 _oldToken, IERC20 _newToken, IERC4626 _poolToken) Ownable(msg.sender) {
        require(address(_oldToken) != address(0), "Old token address cannot be zero");
        require(address(_newToken) != address(0), "New token address cannot be zero");
        require(address(_poolToken) != address(0), "Pool token address cannot be zero");
        
        oldToken = _oldToken;
        newToken = _newToken;
        poolToken = _poolToken;
    }

    /**
     * @dev Sets the validUntil timestamp for the migration.
     * function can only be called by the owner.
     * @param _validUntil The new validUntil timestamp.
     */
    function setTimeLock(uint256 _validUntil) external onlyOwner {
        validUntil = _validUntil;
    }

    /**
     * @dev Migrates old tokens (XDEFI) to new tokens (CTRL) for the caller.
     * @param amount The amount of old tokens to migrate.
     * @param deadline The permit deadline for the old token.
     * @param v The recovery byte of the old token's signature.
     * @param r The first 32 bytes of the old token's signature.
     * @param s The second 32 bytes of the old token's signature.
     */
    function migrate(uint256 amount, uint256 deadline, uint8 v, bytes32 r, bytes32 s) external timeLock {
        // Approve oldToken with EIP-2612
        try IERC20Permit(address(oldToken)).permit(msg.sender, address(this), amount, deadline, v, r, s) {} catch {}

        // Transfer old tokens from the user to this contract
        oldToken.safeTransferFrom(msg.sender, address(this), amount);

        // Transfer new tokens to the user
        newToken.safeTransfer(msg.sender, amount);

        emit Migrated(msg.sender, amount);
    }

    /**
     * @dev Migrates old tokens (XDEFI) to new tokens (CTRL) on behalf of a user in a gasless manner.
     * @param user The address of the user on whose behalf the migration is performed.
     * @param amount The amount of old tokens to migrate.
     * @param deadline The permit deadline for the old token.
     * @param v The recovery byte of the old token's signature.
     * @param r The first 32 bytes of the old token's signature.
     * @param s The second 32 bytes of the old token's signature.
     */
    function migrateWithGaslessApproval(address user, uint256 amount, uint256 deadline, uint8 v, bytes32 r, bytes32 s) external timeLock {
        // Approve oldToken with EIP-2612 on behalf of the user
        try IERC20Permit(address(oldToken)).permit(user, address(this), amount, deadline, v, r, s) {} catch {}

        // Transfer old tokens from the user to this contract
        oldToken.safeTransferFrom(user, address(this), amount);

        // Transfer new tokens to the user
        newToken.safeTransfer(user, amount);

        emit Migrated(user, amount);
    }

    /**
     * @dev Migrates pool tokens (vXDEFI) to new tokens (CTRL) for the caller.
     * @param shares The amount of pool tokens to migrate.
     * @param deadline The permit deadline for the pool token.
     * @param v The recovery byte of the pool token's signature.
     * @param r The first 32 bytes of the pool token's signature.
     * @param s The second 32 bytes of the pool token's signature.
     */
    function migrateFromVXDEFI(uint256 shares, uint256 deadline, uint8 v, bytes32 r, bytes32 s) external timeLock {
        // Approve vXDEFI with EIP-2612
        try IERC20Permit(address(poolToken)).permit(msg.sender, address(this), shares, deadline, v, r, s) {} catch {}

        // Transfer vXDEFI tokens from the user to this contract
        poolToken.transferFrom(msg.sender, address(this), shares);

        // Redeem vXDEFI for XDEFI
        uint256 xdefiAmount = poolToken.redeem(shares, address(this), address(this));

        // Transfer new tokens to the user
        newToken.safeTransfer(msg.sender, xdefiAmount);

        emit Migrated(msg.sender, xdefiAmount);
    }

    /**
     * @dev Migrates pool tokens (vXDEFI) to new tokens (CTRL) on behalf of a user in a gasless manner.
     * @param user The address of the user on whose behalf the migration is performed.
     * @param shares The amount of pool tokens to migrate.
     * @param deadline The permit deadline for the pool token.
     * @param v The recovery byte of the pool token's signature.
     * @param r The first 32 bytes of the pool token's signature.
     * @param s The second 32 bytes of the pool token's signature.
     */
    function migrateGaslessFromVXDEFI(address user, uint256 shares, uint256 deadline, uint8 v, bytes32 r, bytes32 s) external timeLock {
        // Approve vXDEFI with EIP-2612 on behalf of the user
        try IERC20Permit(address(poolToken)).permit(user, address(this), shares, deadline, v, r, s) {} catch {}

        // Transfer vXDEFI tokens from the user to this contract
        poolToken.transferFrom(user, address(this), shares);

        // Redeem vXDEFI for XDEFI
        uint256 xdefiAmount = poolToken.redeem(shares, address(this), address(this));

        // Transfer new tokens to the user
        newToken.safeTransfer(user, xdefiAmount);

        emit Migrated(user, xdefiAmount);
    }

    /**
     * @dev Withdraws old tokens (XDEFI) from the contract.
     * @param amount The amount of old tokens to withdraw.
     */
    function withdrawOldTokens(uint256 amount) external onlyOwner {
        oldToken.safeTransfer(msg.sender, amount);
    }

    /**
     * @dev Withdraws new tokens (CTRL) from the contract.
     * @param amount The amount of new tokens to withdraw.
     */
    function withdrawNewTokens(uint256 amount) external onlyOwner {
        newToken.safeTransfer(msg.sender, amount);
    }

    /**
     * @dev Withdraws pool tokens (vXDEFI) from the contract.
     * @param amount The amount of pool tokens to withdraw.
     */
    function withdrawPoolTokens(uint256 amount) external onlyOwner {
        poolToken.transfer(msg.sender, amount);
    }
}

Read Contract

newToken 0xc42bd05a → address
oldToken 0xb31c710a → address
owner 0x8da5cb5b → address
poolToken 0xcbdf382c → address
validUntil 0xddac6654 → uint256

Write Contract 10 functions

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

migrate 0x80ea5961
uint256 amount
uint256 deadline
uint8 v
bytes32 r
bytes32 s
migrateFromVXDEFI 0xca212509
uint256 shares
uint256 deadline
uint8 v
bytes32 r
bytes32 s
migrateGaslessFromVXDEFI 0xd7dfc7c2
address user
uint256 shares
uint256 deadline
uint8 v
bytes32 r
bytes32 s
migrateWithGaslessApproval 0x27669255
address user
uint256 amount
uint256 deadline
uint8 v
bytes32 r
bytes32 s
renounceOwnership 0x715018a6
No parameters
setTimeLock 0x5bcb318a
uint256 _validUntil
transferOwnership 0xf2fde38b
address newOwner
withdrawNewTokens 0xe33f2499
uint256 amount
withdrawOldTokens 0x81620863
uint256 amount
withdrawPoolTokens 0x9dd1ed1b
uint256 amount

Recent Transactions

This address has 1 on-chain transactions, but only 0.8% of the chain is indexed. Transactions will appear as indexing progresses. View on Etherscan →