Cryo Explorer Ethereum Mainnet

Address Contract Verified

Address 0xED8a2a23bf9D6818651527daaF3bf4FfEB53945F
Balance 0 ETH
Nonce 1
Code Size 3180 bytes
Indexed Transactions 5 (24,455,47724,455,548)
Value (indexed) ↓ 0.162200 ETH
Gas Used (indexed) 1,498,956
External Etherscan · Sourcify

Contract Bytecode

3180 bytes
0x60806040526004361061004e5760003560e01c80634b2084e3146100a35780638340f549146100d9578063ad5c4648146100ec578063c6c3bbe61461012d578063f3f094a11461014057600080fd5b3661009e57336001600160a01b037f000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2161461009c5760405163a2b2dd6360e01b815260040160405180910390fd5b005b600080fd5b3480156100af57600080fd5b506100c36100be3660046109a7565b610160565b6040516100d09190610a13565b60405180910390f35b6100c36100e7366004610a21565b6102b7565b3480156100f857600080fd5b506101207f000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc281565b6040516100d09190610ab3565b6100c361013b366004610a21565b6103f3565b34801561014c57600080fd5b506100c361015b3660046109a7565b61059d565b604051632d182be560e21b815260009047906001600160a01b0387169063b460af949061019590889030903390600401610aca565b6020604051808303816000875af11580156101b4573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906101d89190610b05565b9150828211156101fb57604051638199f5f360e01b815260040160405180910390fd5b604051632e1a7d4d60e01b81526001600160a01b037f000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc21690632e1a7d4d90610247908890600401610a13565b600060405180830381600087803b15801561026157600080fd5b505af1158015610275573d6000803e3d6000fd5b5050505061028384866106bc565b600061028f8247610b3c565b11156102ae57604051633e6d8b5f60e11b815260040160405180910390fd5b50949350505050565b60007f000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc26001600160a01b031663d0e30db0346040518263ffffffff1660e01b81526004016000604051808303818588803b15801561031457600080fd5b505af1158015610328573d6000803e3d6000fd5b50505050506103587f000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2853461074f565b604051636e553f6560e01b81526001600160a01b03851690636e553f65906103869034908790600401610b4f565b6020604051808303816000875af11580156103a5573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906103c99190610b05565b9050818110156103ec57604051638199f5f360e01b815260040160405180910390fd5b9392505050565b60007f000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc26001600160a01b031663d0e30db0346040518263ffffffff1660e01b81526004016000604051808303818588803b15801561045057600080fd5b505af1158015610464573d6000803e3d6000fd5b50505050506104947f000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2853461074f565b6040516363737ac960e11b81526001600160a01b0385169063c6e6f592906104c0903490600401610a13565b602060405180830381865afa1580156104dd573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906105019190610b05565b90508181101561052457604051638199f5f360e01b815260040160405180910390fd5b6040516394bf804d60e01b81526001600160a01b038516906394bf804d906105529084908790600401610b4f565b6020604051808303816000875af1158015610571573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906105959190610b05565b509392505050565b604051635d043b2960e11b815260009047906001600160a01b0387169063ba087652906105d290889030903390600401610aca565b6020604051808303816000875af11580156105f1573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906106159190610b05565b91508282101561063857604051638199f5f360e01b815260040160405180910390fd5b604051632e1a7d4d60e01b81526001600160a01b037f000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc21690632e1a7d4d90610684908590600401610a13565b600060405180830381600087803b15801561069e57600080fd5b505af11580156106b2573d6000803e3d6000fd5b5050505061028384835b604080516000808252602082019092526001600160a01b0384169083906040516106e69190610bb0565b60006040518083038185875af1925050503d8060008114610723576040519150601f19603f3d011682016040523d82523d6000602084013e610728565b606091505b505090508061074a57604051630db2c7f160e31b815260040160405180910390fd5b505050565b604051636eb1769f60e11b81526000906001600160a01b0385169063dd62ed3e906107809030908790600401610bbc565b602060405180830381865afa15801561079d573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906107c19190610b05565b90506107d784846107d28585610bca565b6107dd565b50505050565b6000836001600160a01b031663095ea7b38484604051602401610801929190610bdd565b604051602081830303815290604052915060e01b6020820180516001600160e01b038381831617835250505050905061083a84826108a1565b6107d75761089784856001600160a01b031663095ea7b3866000604051602401610865929190610c0d565b604051602081830303815290604052915060e01b6020820180516001600160e01b0383818316178352505050506108f2565b6107d784826108f2565b6000806000806020600086516020880160008a5af192503d915060005190508280156108e6575081156108d757806001146108e6565b6000866001600160a01b03163b115b93505050505b92915050565b600080602060008451602086016000885af180610915576040513d6000823e3d81fd5b50506000513d9150811561092d57806001141561093a565b6001600160a01b0384163b155b156107d75783604051635274afe760e01b815260040161095a9190610c28565b60405180910390fd5b60006001600160a01b0382166108ec565b61097d81610963565b811461098857600080fd5b50565b80356108ec81610974565b8061097d565b80356108ec81610996565b600080600080608085870312156109c0576109c0600080fd5b60006109cc878761098b565b94505060206109dd8782880161099c565b93505060406109ee8782880161098b565b92505060606109ff8782880161099c565b91505092959194509250565b805b82525050565b602081016108ec8284610a0b565b600080600060608486031215610a3957610a39600080fd5b6000610a45868661098b565b9350506020610a568682870161098b565b9250506040610a678682870161099c565b9150509250925092565b60006108ec6001600160a01b038316610a88565b90565b6001600160a01b031690565b60006108ec82610a71565b60006108ec82610a94565b610a0d81610a9f565b602081016108ec8284610aaa565b610a0d81610963565b60608101610ad88286610a0b565b610ae56020830185610ac1565b610af26040830184610ac1565b949350505050565b80516108ec81610996565b600060208284031215610b1a57610b1a600080fd5b6000610af28484610afa565b634e487b7160e01b600052601160045260246000fd5b818103818111156108ec576108ec610b26565b60408101610b5d8285610a0b565b6103ec6020830184610ac1565b60005b83811015610b85578181015183820152602001610b6d565b50506000910152565b6000610b98825190565b610ba6818560208601610b6a565b9290920192915050565b60006103ec8284610b8e565b60408101610b5d8285610ac1565b808201808211156108ec576108ec610b26565b60408101610beb8285610ac1565b6103ec6020830184610a0b565b60006108ec610a858381565b610a0d81610bf8565b60408101610c1b8285610ac1565b6103ec6020830184610c04565b602081016108ec8284610ac156fea2646970667358221220d9104e3803f6658bd645f389280dc576201be2dce04b0a29abe1dbf8af1cf0e764736f6c634300081c0033

Verified Source Code Full Match

Compiler: v0.8.28+commit.7893614a EVM: paris
IERC1363.sol 86 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.1.0) (interfaces/IERC1363.sol)

pragma solidity ^0.8.20;

import {IERC20} from "./IERC20.sol";
import {IERC165} from "./IERC165.sol";

/**
 * @title IERC1363
 * @dev Interface of the ERC-1363 standard as defined in the https://eips.ethereum.org/EIPS/eip-1363[ERC-1363].
 *
 * Defines an extension interface for ERC-20 tokens that supports executing code on a recipient contract
 * after `transfer` or `transferFrom`, or code on a spender contract after `approve`, in a single transaction.
 */
interface IERC1363 is IERC20, IERC165 {
    /*
     * Note: the ERC-165 identifier for this interface is 0xb0202a11.
     * 0xb0202a11 ===
     *   bytes4(keccak256('transferAndCall(address,uint256)')) ^
     *   bytes4(keccak256('transferAndCall(address,uint256,bytes)')) ^
     *   bytes4(keccak256('transferFromAndCall(address,address,uint256)')) ^
     *   bytes4(keccak256('transferFromAndCall(address,address,uint256,bytes)')) ^
     *   bytes4(keccak256('approveAndCall(address,uint256)')) ^
     *   bytes4(keccak256('approveAndCall(address,uint256,bytes)'))
     */

    /**
     * @dev Moves a `value` amount of tokens from the caller's account to `to`
     * and then calls {IERC1363Receiver-onTransferReceived} on `to`.
     * @param to The address which you want to transfer to.
     * @param value The amount of tokens to be transferred.
     * @return A boolean value indicating whether the operation succeeded unless throwing.
     */
    function transferAndCall(address to, uint256 value) external returns (bool);

    /**
     * @dev Moves a `value` amount of tokens from the caller's account to `to`
     * and then calls {IERC1363Receiver-onTransferReceived} on `to`.
     * @param to The address which you want to transfer to.
     * @param value The amount of tokens to be transferred.
     * @param data Additional data with no specified format, sent in call to `to`.
     * @return A boolean value indicating whether the operation succeeded unless throwing.
     */
    function transferAndCall(address to, uint256 value, bytes calldata data) external returns (bool);

    /**
     * @dev Moves a `value` amount of tokens from `from` to `to` using the allowance mechanism
     * and then calls {IERC1363Receiver-onTransferReceived} on `to`.
     * @param from The address which you want to send tokens from.
     * @param to The address which you want to transfer to.
     * @param value The amount of tokens to be transferred.
     * @return A boolean value indicating whether the operation succeeded unless throwing.
     */
    function transferFromAndCall(address from, address to, uint256 value) external returns (bool);

    /**
     * @dev Moves a `value` amount of tokens from `from` to `to` using the allowance mechanism
     * and then calls {IERC1363Receiver-onTransferReceived} on `to`.
     * @param from The address which you want to send tokens from.
     * @param to The address which you want to transfer to.
     * @param value The amount of tokens to be transferred.
     * @param data Additional data with no specified format, sent in call to `to`.
     * @return A boolean value indicating whether the operation succeeded unless throwing.
     */
    function transferFromAndCall(address from, address to, uint256 value, bytes calldata data) external returns (bool);

    /**
     * @dev Sets a `value` amount of tokens as the allowance of `spender` over the
     * caller's tokens and then calls {IERC1363Spender-onApprovalReceived} on `spender`.
     * @param spender The address which will spend the funds.
     * @param value The amount of tokens to be spent.
     * @return A boolean value indicating whether the operation succeeded unless throwing.
     */
    function approveAndCall(address spender, uint256 value) external returns (bool);

    /**
     * @dev Sets a `value` amount of tokens as the allowance of `spender` over the
     * caller's tokens and then calls {IERC1363Spender-onApprovalReceived} on `spender`.
     * @param spender The address which will spend the funds.
     * @param value The amount of tokens to be spent.
     * @param data Additional data with no specified format, sent in call to `spender`.
     * @return A boolean value indicating whether the operation succeeded unless throwing.
     */
    function approveAndCall(address spender, uint256 value, bytes calldata data) external returns (bool);
}
IERC165.sol 6 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (interfaces/IERC165.sol)

pragma solidity ^0.8.20;

import {IERC165} from "../utils/introspection/IERC165.sol";
IERC20.sol 6 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (interfaces/IERC20.sol)

pragma solidity ^0.8.20;

import {IERC20} from "../token/ERC20/IERC20.sol";
IERC4626.sol 230 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.3.0) (interfaces/IERC4626.sol)

pragma solidity ^0.8.20;

import {IERC20} from "../token/ERC20/IERC20.sol";
import {IERC20Metadata} from "../token/ERC20/extensions/IERC20Metadata.sol";

/**
 * @dev Interface of the ERC-4626 "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 redemption 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);
}
IERC20Metadata.sol 26 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.1.0) (token/ERC20/extensions/IERC20Metadata.sol)

pragma solidity ^0.8.20;

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

/**
 * @dev Interface for the optional metadata functions from the ERC-20 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);
}
IERC20.sol 79 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.1.0) (token/ERC20/IERC20.sol)

pragma solidity ^0.8.20;

/**
 * @dev Interface of the ERC-20 standard as defined in the ERC.
 */
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);
}
SafeERC20.sol 212 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.3.0) (token/ERC20/utils/SafeERC20.sol)

pragma solidity ^0.8.20;

import {IERC20} from "../IERC20.sol";
import {IERC1363} from "../../../interfaces/IERC1363.sol";

/**
 * @title SafeERC20
 * @dev Wrappers around ERC-20 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 {
    /**
     * @dev An operation with an ERC-20 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 Variant of {safeTransfer} that returns a bool instead of reverting if the operation is not successful.
     */
    function trySafeTransfer(IERC20 token, address to, uint256 value) internal returns (bool) {
        return _callOptionalReturnBool(token, abi.encodeCall(token.transfer, (to, value)));
    }

    /**
     * @dev Variant of {safeTransferFrom} that returns a bool instead of reverting if the operation is not successful.
     */
    function trySafeTransferFrom(IERC20 token, address from, address to, uint256 value) internal returns (bool) {
        return _callOptionalReturnBool(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.
     *
     * IMPORTANT: If the token implements ERC-7674 (ERC-20 with temporary allowance), and if the "client"
     * smart contract uses ERC-7674 to set temporary allowances, then the "client" smart contract should avoid using
     * this function. Performing a {safeIncreaseAllowance} or {safeDecreaseAllowance} operation on a token contract
     * that has a non-zero temporary allowance (for that particular owner-spender) will result in unexpected behavior.
     */
    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.
     *
     * IMPORTANT: If the token implements ERC-7674 (ERC-20 with temporary allowance), and if the "client"
     * smart contract uses ERC-7674 to set temporary allowances, then the "client" smart contract should avoid using
     * this function. Performing a {safeIncreaseAllowance} or {safeDecreaseAllowance} operation on a token contract
     * that has a non-zero temporary allowance (for that particular owner-spender) will result in unexpected behavior.
     */
    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.
     *
     * NOTE: If the token implements ERC-7674, this function will not modify any temporary allowance. This function
     * only sets the "standard" allowance. Any temporary allowance will remain active, in addition to the value being
     * set here.
     */
    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 Performs an {ERC1363} transferAndCall, with a fallback to the simple {ERC20} transfer if the target has no
     * code. This can be used to implement an {ERC721}-like safe transfer that rely on {ERC1363} checks when
     * targeting contracts.
     *
     * Reverts if the returned value is other than `true`.
     */
    function transferAndCallRelaxed(IERC1363 token, address to, uint256 value, bytes memory data) internal {
        if (to.code.length == 0) {
            safeTransfer(token, to, value);
        } else if (!token.transferAndCall(to, value, data)) {
            revert SafeERC20FailedOperation(address(token));
        }
    }

    /**
     * @dev Performs an {ERC1363} transferFromAndCall, with a fallback to the simple {ERC20} transferFrom if the target
     * has no code. This can be used to implement an {ERC721}-like safe transfer that rely on {ERC1363} checks when
     * targeting contracts.
     *
     * Reverts if the returned value is other than `true`.
     */
    function transferFromAndCallRelaxed(
        IERC1363 token,
        address from,
        address to,
        uint256 value,
        bytes memory data
    ) internal {
        if (to.code.length == 0) {
            safeTransferFrom(token, from, to, value);
        } else if (!token.transferFromAndCall(from, to, value, data)) {
            revert SafeERC20FailedOperation(address(token));
        }
    }

    /**
     * @dev Performs an {ERC1363} approveAndCall, with a fallback to the simple {ERC20} approve if the target has no
     * code. This can be used to implement an {ERC721}-like safe transfer that rely on {ERC1363} checks when
     * targeting contracts.
     *
     * NOTE: When the recipient address (`to`) has no code (i.e. is an EOA), this function behaves as {forceApprove}.
     * Opposedly, when the recipient address (`to`) has code, this function only attempts to call {ERC1363-approveAndCall}
     * once without retrying, and relies on the returned value to be true.
     *
     * Reverts if the returned value is other than `true`.
     */
    function approveAndCallRelaxed(IERC1363 token, address to, uint256 value, bytes memory data) internal {
        if (to.code.length == 0) {
            forceApprove(token, to, value);
        } else if (!token.approveAndCall(to, value, data)) {
            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 {_callOptionalReturnBool} that reverts if call fails to meet the requirements.
     */
    function _callOptionalReturn(IERC20 token, bytes memory data) private {
        uint256 returnSize;
        uint256 returnValue;
        assembly ("memory-safe") {
            let success := call(gas(), token, 0, add(data, 0x20), mload(data), 0, 0x20)
            // bubble errors
            if iszero(success) {
                let ptr := mload(0x40)
                returndatacopy(ptr, 0, returndatasize())
                revert(ptr, returndatasize())
            }
            returnSize := returndatasize()
            returnValue := mload(0)
        }

        if (returnSize == 0 ? address(token).code.length == 0 : returnValue != 1) {
            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 silently catches all reverts and returns a bool instead.
     */
    function _callOptionalReturnBool(IERC20 token, bytes memory data) private returns (bool) {
        bool success;
        uint256 returnSize;
        uint256 returnValue;
        assembly ("memory-safe") {
            success := call(gas(), token, 0, add(data, 0x20), mload(data), 0, 0x20)
            returnSize := returndatasize()
            returnValue := mload(0)
        }
        return success && (returnSize == 0 ? address(token).code.length > 0 : returnValue == 1);
    }
}
IERC165.sol 25 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.1.0) (utils/introspection/IERC165.sol)

pragma solidity ^0.8.20;

/**
 * @dev Interface of the ERC-165 standard, as defined in the
 * https://eips.ethereum.org/EIPS/eip-165[ERC].
 *
 * Implementers can declare support of contract interfaces, which can then be
 * queried by others ({ERC165Checker}).
 *
 * For an implementation, see {ERC165}.
 */
interface IERC165 {
    /**
     * @dev Returns true if this contract implements the interface defined by
     * `interfaceId`. See the corresponding
     * https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[ERC section]
     * to learn more about how these ids are created.
     *
     * This function call must use less than 30 000 gas.
     */
    function supportsInterface(bytes4 interfaceId) external view returns (bool);
}
IWETH.sol 20 lines
// SPDX-License-Identifier: MIT
pragma solidity >=0.7.0 <0.9.0;

interface IWETH {
  function deposit() external payable;

  function transfer(address to, uint256 value) external returns (bool);

  function transferFrom(
    address src,
    address dst,
    uint256 wad
  ) external returns (bool);

  function withdraw(uint256) external;

  function balanceOf(address) external view returns (uint);

  function approve(address spender, uint256 amount) external returns (bool);
}
RelayPoolNativeGateway.sol 169 lines
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.28;

import {SafeERC20} from "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";
import {IERC20} from "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import {IERC4626} from "@openzeppelin/contracts/interfaces/IERC4626.sol";
import {IWETH} from "./interfaces/IWETH.sol";

/// @title RelayPoolNativeGateway
/// @author Relay Protocol
/// @notice Gateway contract for depositing and withdrawing native ETH to/from WETH-based RelayPools
/// @dev Handles wrapping/unwrapping of ETH and provides slippage protection for all operations
contract RelayPoolNativeGateway {
  /// @notice Error when ETH transfer fails
  error EthTransferFailed();

  /// @notice Error when contract receives ETH from non-WETH address
  error OnlyWethCanSendEth();

  /// @notice Error when ETH remains in contract after operation
  error RemainingEth();

  /// @notice Error when slippage protection is triggered
  error SlippageExceeded();

  /// @notice The Wrapped ETH (WETH) contract
  /// @dev Used to wrap/unwrap native ETH for pool operations
  IWETH public immutable WETH;

  /// @notice Initializes the gateway with the WETH contract address
  /// @param wethAddress Address of the Wrapped Native token contract
  constructor(address wethAddress) {
    WETH = IWETH(wethAddress);
  }

  /// @notice Deposits native ETH into a WETH-based pool
  /// @dev Wraps ETH to WETH, then deposits to the pool with slippage protection
  /// @param pool The address of the ERC4626 pool to deposit into
  /// @param receiver The address that will receive the pool shares
  /// @param minSharesOut Minimum amount of shares to receive (slippage protection)
  /// @return shares The amount of pool shares minted to the receiver
  function deposit(
    address pool,
    address receiver,
    uint256 minSharesOut
  ) external payable returns (uint256 shares) {
    // wrap tokens
    WETH.deposit{value: msg.value}();
    SafeERC20.safeIncreaseAllowance(IERC20(address(WETH)), pool, msg.value);

    // do the deposit
    shares = IERC4626(pool).deposit(msg.value, receiver);

    // Enforce slippage protection
    if (shares < minSharesOut) {
      revert SlippageExceeded();
    }
  }

  /// @notice Mints pool shares by depositing native ETH
  /// @dev Wraps ETH, calculates shares, then mints with slippage protection
  /// @param pool The address of the ERC4626 pool to mint shares from
  /// @param receiver The address that will receive the pool shares
  /// @param minSharesOut Minimum amount of shares to receive (slippage protection)
  /// @return shares The amount of pool shares minted to the receiver
  function mint(
    address pool,
    address receiver,
    uint256 minSharesOut
  ) external payable returns (uint256 shares) {
    // wrap tokens
    WETH.deposit{value: msg.value}();
    SafeERC20.safeIncreaseAllowance(IERC20(address(WETH)), pool, msg.value);

    // do the deposit
    shares = IERC4626(pool).convertToShares(msg.value);

    // Enforce slippage protection
    if (shares < minSharesOut) {
      revert SlippageExceeded();
    }

    IERC4626(pool).mint(shares, receiver);
  }

  /// @notice Withdraws a specific amount of native ETH from a WETH-based pool
  /// @dev Withdraws WETH from pool, unwraps to ETH, with slippage protection
  /// @param pool The address of the ERC4626 pool to withdraw from
  /// @param assets Amount of native ETH to withdraw
  /// @param receiver The address that will receive the native ETH
  /// @param maxSharesIn Maximum amount of shares to burn (slippage protection)
  /// @return shares The amount of pool shares burned
  function withdraw(
    address pool,
    uint256 assets,
    address receiver,
    uint256 maxSharesIn
  ) external virtual returns (uint256 shares) {
    uint256 balanceBefore = address(this).balance;

    // withdraw from pool
    shares = IERC4626(pool).withdraw(assets, address(this), msg.sender);

    // Enforce slippage protection
    if (shares > maxSharesIn) {
      revert SlippageExceeded();
    }

    // withdraw native tokens and send them back
    WETH.withdraw(assets);
    safeTransferETH(receiver, assets);

    // make sure no ETH is left in the contract
    if (address(this).balance - balanceBefore > 0) {
      revert RemainingEth();
    }
  }

  /// @notice Redeems pool shares for native ETH
  /// @dev Redeems shares for WETH, unwraps to ETH, with slippage protection
  /// @param pool The address of the ERC4626 pool to redeem from
  /// @param shares Amount of pool shares to redeem
  /// @param receiver The address that will receive the native ETH
  /// @param minAssetsOut Minimum amount of ETH to receive (slippage protection)
  /// @return assets The amount of native ETH sent to receiver
  function redeem(
    address pool,
    uint256 shares,
    address receiver,
    uint256 minAssetsOut
  ) external virtual returns (uint256 assets) {
    uint256 balanceBefore = address(this).balance;
    // withdraw from pool
    assets = IERC4626(pool).redeem(shares, address(this), msg.sender);

    // Enforce slippage protection
    if (assets < minAssetsOut) {
      revert SlippageExceeded();
    }

    // withdraw native tokens and send them back
    WETH.withdraw(assets);
    safeTransferETH(receiver, assets);

    // make sure no ETH is left in the contract
    if (address(this).balance - balanceBefore > 0) {
      revert RemainingEth();
    }
  }

  /// @notice Safely transfers ETH to an address
  /// @dev Reverts if the ETH transfer fails
  /// @param to Recipient of the ETH transfer
  /// @param value Amount of ETH to transfer
  function safeTransferETH(address to, uint256 value) internal {
    (bool success, ) = to.call{value: value}(new bytes(0));
    if (!success) {
      revert EthTransferFailed();
    }
  }

  /// @notice Receives ETH only from WETH contract
  /// @dev Required for WETH unwrapping operations
  receive() external payable {
    if (msg.sender != address(WETH)) {
      revert OnlyWethCanSendEth();
    }
  }
}

Read Contract

WETH 0xad5c4648 → address

Write Contract 4 functions

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

deposit 0x8340f549
address pool
address receiver
uint256 minSharesOut
returns: uint256
mint 0xc6c3bbe6
address pool
address receiver
uint256 minSharesOut
returns: uint256
redeem 0xf3f094a1
address pool
uint256 shares
address receiver
uint256 minAssetsOut
returns: uint256
withdraw 0x4b2084e3
address pool
uint256 assets
address receiver
uint256 maxSharesIn
returns: uint256

Top Interactions

AddressTxnsSentReceived
0x5BeC9Dd4...8fE6 2 2
0xb21E93a0...8616 2 2
0x21264c1F...Fb1E 1 1

Recent Transactions

CSV
|
Hash Method Block Age From/To Value Txn Fee Type
0x9c0a8b0f...ddb354 0x8340f549 24,455,548 IN 0x21264c1F...Fb1E 0.054000 ETH EIP-1559
0xcfbe554b...79ec91 0x4b2084e3 24,455,524 IN 0x5BeC9Dd4...8fE6 0 ETH EIP-1559
0x98634267...b02584 0x8340f549 24,455,512 IN 0x5BeC9Dd4...8fE6 0.054000 ETH EIP-1559
0x63d9d436...d69a30 0x4b2084e3 24,455,487 IN 0xb21E93a0...8616 0 ETH EIP-1559
0x89c09487...24be77 0x8340f549 24,455,477 IN 0xb21E93a0...8616 0.054200 ETH EIP-1559