Discover more of Etherscan's tools and services in one place.
Sponsored
Contract Source Code:
File 1 of 2 : Deposit.sol
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "IERC20Lite.sol"; /** * @title Deposit contract * @notice Creates a contract with a known address and withdraws tokens from it. * After deployment, the Vault will call fetch() to withdraw tokens. * @dev Any change in this contract, including comments, will affect the final * bytecode and therefore will affect the create2 derived addresses. * Do NOT modify unless the consequences of doing so are fully understood. */ contract Deposit { address payable private immutable vault; /** * @notice Upon deployment it fetches the tokens (native or ERC20) to the Vault. * @param token The address of the token to fetch */ constructor(address token) { vault = payable(msg.sender); // Slightly cheaper to use msg.sender instead of Vault. if (token == 0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE) { // solhint-disable-next-line avoid-low-level-calls (bool success, ) = msg.sender.call{value: address(this).balance}(""); require(success); } else { // IERC20Lite.transfer doesn't have a return bool to avoid reverts on non-standard ERC20s IERC20Lite(token).transfer(msg.sender, IERC20Lite(token).balanceOf(address(this))); } } /** * @notice Allows the Vault to fetch ERC20 tokens from this contract. * @param token The address of the token to fetch */ function fetch(address token) external { require(msg.sender == vault); // IERC20Lite.transfer doesn't have a return bool to avoid reverts on non-standard ERC20s IERC20Lite(token).transfer(msg.sender, IERC20Lite(token).balanceOf(address(this))); } /// @notice Receives native tokens, emits an event and sends them to the Vault. Note that this // requires the sender to forward some more gas than for a simple transfer. receive() external payable { // solhint-disable-next-line avoid-low-level-calls (bool success, ) = vault.call{value: address(this).balance}(""); require(success); } }
File 2 of 2 : IERC20Lite.sol
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; /** * @title ERC20 Lite Interface * @notice The interface for functions ERC20Lite implements. This is intended to * be used only in the Deposit contract. * @dev Any change in this contract, including comments, will affect the final * bytecode and therefore will affect the create2 derived addresses. * Do NOT modify unless the consequences of doing so are fully understood. */ interface IERC20Lite { /// @dev Removed the return bool to avoid reverts on non-standard ERC20s. function transfer(address, uint256) external; function balanceOf(address) external view returns (uint256); }
Please enter a contract address above to load the contract details and source code.
Please DO NOT store any passwords or private keys here. A private note (up to 100 characters) can be saved and is useful for transaction tracking.
This website uses cookies to improve your experience. By continuing to use this website, you agree to its Terms and Privacy Policy.