Contract 0xEDEe9503756AaFdb50F6A7f6bfA3324CDa453D47 1

 
 
Txn Hash
Method
Block
From
To
Value
0x7c48344d7659d57a34bc97ab7bf0f4eb2e62c153057551f8c01ed6aa89d0bbdd0x60c06040155993082022-09-23 23:23:2374 days 21 hrs ago0xbbc2cd847bdf10468861dab854cd2b2e315e28c8 IN  Create: ERC4626Silo0 Ether0.0398819185
[ Download CSV Export 
View more zero value Internal Transactions in Advanced View mode
Loading

Contract Source Code Verified (Exact Match)

Contract Name:
ERC4626Silo

Compiler Version
v0.8.10+commit.fc410830

Optimization Enabled:
Yes with 800 runs

Other Settings:
default evmVersion
File 1 of 4 : ERC4626Silo.sol
// SPDX-License-Identifier: Unlicense
pragma solidity ^0.8.10;

import "@openzeppelin/contracts/token/ERC20/extensions/IERC20Metadata.sol";

import "contracts/interfaces/ISilo.sol";

interface IERC4626 {
    /// @notice Mints `shares` amount of vault tokens to `to` by depositing exactly `value` underlying tokens.

    function deposit(uint256 assets, address receiver) external returns (uint256 shares);

    /// @notice Burns `shares` vault tokens from `from`, withdrawing exactly `value` underlying tokens to `to`.
    function withdraw(
        uint256 assets,
        address receiver,
        address owner
    ) external returns (uint256 shares);

    /// @notice Returns the address of the token the vault uses for accounting, depositing, and withdrawing.
    function asset() external view returns (address);

    /// 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.
    function convertToAssets(uint256 shares) external view returns (uint256 assets);
}

contract ERC4626Silo is ISilo {
    /// @inheritdoc ISilo
    string public name;

    IERC4626 public immutable vault;

    address public immutable underlying;

    constructor(IERC4626 _vault) {
        vault = _vault;
        underlying = _vault.asset();

        // ex: ERC4626 (fDAI) DAI Silo
        name = string(
            abi.encodePacked(
                "ERC4626 (",
                IERC20Metadata(address(vault)).symbol(),
                ") ",
                IERC20Metadata(underlying).symbol(),
                " Silo"
            )
        );
    }

    /// @inheritdoc ISilo
    function poke() external override {}

    /// @inheritdoc ISilo
    function deposit(uint256 amount) external override {
        if (amount == 0) return;
        _approve(underlying, address(vault), amount);
        vault.deposit(amount, address(this));
    }

    /// @inheritdoc ISilo
    function withdraw(uint256 amount) external override {
        if (amount == 0) return;
        vault.withdraw(amount, address(this), address(this));
    }

    /// @inheritdoc ISilo
    function balanceOf(address account) external view override returns (uint256 balance) {
        balance = vault.convertToAssets(IERC20(address(vault)).balanceOf(account));
    }

    /// @inheritdoc ISilo
    function shouldAllowRemovalOf(address token) external view override returns (bool shouldAllow) {
        shouldAllow = token != address(vault);
    }

    function _approve(
        address token,
        address spender,
        uint256 amount
    ) private {
        // 200 gas to read uint256
        if (IERC20(token).allowance(address(this), spender) < amount) {
            // 20000 gas to write uint256 if changing from zero to non-zero
            // 5000  gas to write uint256 if changing from non-zero to non-zero
            IERC20(token).approve(spender, type(uint256).max);
        }
    }
}

File 2 of 4 : IERC20Metadata.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.0;

import "../IERC20.sol";

/**
 * @dev Interface for the optional metadata functions from the ERC20 standard.
 *
 * _Available since v4.1._
 */
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 3 of 4 : ISilo.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.10;

interface ISilo {
    /// @notice A descriptive name for the silo (ex: Compound USDC Silo)
    function name() external view returns (string memory);

    /// @notice A place to update the silo's internal state
    /// @dev After this has been called, balances reported by `balanceOf` MUST be correct
    function poke() external;

    /// @notice Deposits `amount` of the underlying token
    function deposit(uint256 amount) external;

    /// @notice Withdraws EXACTLY `amount` of the underlying token
    function withdraw(uint256 amount) external;

    /// @notice Reports how much of the underlying token `account` has stored
    /// @dev Must never overestimate `balance`. Should give the exact, correct value after `poke` is called
    function balanceOf(address account) external view returns (uint256 balance);

    /**
     * @notice Whether the given token is irrelevant to the silo's strategy (`shouldAllow = true`) or
     * is required for proper management (`shouldAllow = false`). ex: Compound silos shouldn't allow
     * removal of cTokens, but the may allow removal of COMP rewards.
     * @dev Removed tokens are used to help incentivize rebalances for the Blend vault that uses the silo. So
     * if you want something like COMP rewards to go to Blend *users* instead, you'd have to implement a
     * trading function as part of `poke()` to convert COMP to the underlying token.
     */
    function shouldAllowRemovalOf(address token) external view returns (bool shouldAllow);
}

File 4 of 4 : IERC20.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.0;

/**
 * @dev Interface of the ERC20 standard as defined in the EIP.
 */
interface IERC20 {
    /**
     * @dev Returns the amount of tokens in existence.
     */
    function totalSupply() external view returns (uint256);

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

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

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

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

Settings
{
  "optimizer": {
    "enabled": true,
    "runs": 800
  },
  "metadata": {
    "bytecodeHash": "none"
  },
  "outputSelection": {
    "*": {
      "*": [
        "evm.bytecode",
        "evm.deployedBytecode",
        "devdoc",
        "userdoc",
        "metadata",
        "abi"
      ]
    }
  },
  "libraries": {}
}

Contract Security Audit

Contract ABI

[{"inputs":[{"internalType":"contract IERC4626","name":"_vault","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"inputs":[{"internalType":"address","name":"account","type":"address"}],"name":"balanceOf","outputs":[{"internalType":"uint256","name":"balance","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"deposit","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"name","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"poke","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"token","type":"address"}],"name":"shouldAllowRemovalOf","outputs":[{"internalType":"bool","name":"shouldAllow","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"underlying","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"vault","outputs":[{"internalType":"contract IERC4626","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"withdraw","outputs":[],"stateMutability":"nonpayable","type":"function"}]

60c06040523480156200001157600080fd5b5060405162000b4538038062000b45833981016040819052620000349162000294565b6001600160a01b0381166080819052604080516338d52e0f60e01b815290516338d52e0f916004808201926020929091908290030181865afa1580156200007f573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190620000a5919062000294565b6001600160a01b031660a0816001600160a01b0316815250506080516001600160a01b03166395d89b416040518163ffffffff1660e01b8152600401600060405180830381865afa158015620000ff573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f1916820160405262000129919081019062000304565b60a0516001600160a01b03166395d89b416040518163ffffffff1660e01b8152600401600060405180830381865afa1580156200016a573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f1916820160405262000194919081019062000304565b604051602001620001a7929190620003bc565b60405160208183030381529060405260009080519060200190620001cd929190620001d5565b505062000461565b828054620001e39062000424565b90600052602060002090601f01602090048101928262000207576000855562000252565b82601f106200022257805160ff191683800117855562000252565b8280016001018555821562000252579182015b828111156200025257825182559160200191906001019062000235565b506200026092915062000264565b5090565b5b8082111562000260576000815560010162000265565b6001600160a01b03811681146200029157600080fd5b50565b600060208284031215620002a757600080fd5b8151620002b4816200027b565b9392505050565b634e487b7160e01b600052604160045260246000fd5b60005b83811015620002ee578181015183820152602001620002d4565b83811115620002fe576000848401525b50505050565b6000602082840312156200031757600080fd5b81516001600160401b03808211156200032f57600080fd5b818401915084601f8301126200034457600080fd5b815181811115620003595762000359620002bb565b604051601f8201601f19908116603f01168101908382118183101715620003845762000384620002bb565b816040528281528760208487010111156200039e57600080fd5b620003b1836020830160208801620002d1565b979650505050505050565b6808aa486686c646c40560bb1b815260008351620003e2816009850160208801620002d1565b61014960f51b60099184019182015283516200040681600b840160208801620002d1565b642053696c6f60d81b600b9290910191820152601001949350505050565b600181811c908216806200043957607f821691505b602082108114156200045b57634e487b7160e01b600052602260045260246000fd5b50919050565b60805160a051610695620004b06000396000818161011601526103e701526000818160bb01528181610189015281816102640152818161030001528181610408015261044901526106956000f3fe608060405234801561001057600080fd5b50600436106100885760003560e01c80636f307dc31161005b5780636f307dc31461011157806370a0823114610150578063b6b55f2514610171578063fbfa77cf1461018457600080fd5b806306fdde031461008d5780631363efd8146100ab57806318178358146100fc5780632e1a7d4d146100fe575b600080fd5b6100956101ab565b6040516100a29190610574565b60405180910390f35b6100ec6100b93660046105c9565b7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b039081169116141590565b60405190151581526020016100a2565b005b6100fc61010c3660046105f9565b610239565b6101387f000000000000000000000000000000000000000000000000000000000000000081565b6040516001600160a01b0390911681526020016100a2565b61016361015e3660046105c9565b6102de565b6040519081526020016100a2565b6100fc61017f3660046105f9565b6103da565b6101387f000000000000000000000000000000000000000000000000000000000000000081565b600080546101b890610612565b80601f01602080910402602001604051908101604052809291908181526020018280546101e490610612565b80156102315780601f1061020657610100808354040283529160200191610231565b820191906000526020600020905b81548152906001019060200180831161021457829003601f168201915b505050505081565b806102415750565b604051632d182be560e21b815260048101829052306024820181905260448201527f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03169063b460af94906064015b6020604051808303816000875af11580156102b6573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906102da919061064d565b5050565b6040516370a0823160e01b81526001600160a01b0382811660048301526000917f0000000000000000000000000000000000000000000000000000000000000000909116906307a2d13a9082906370a0823190602401602060405180830381865afa158015610351573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610375919061064d565b6040518263ffffffff1660e01b815260040161039391815260200190565b602060405180830381865afa1580156103b0573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906103d4919061064d565b92915050565b806103e25750565b61042d7f00000000000000000000000000000000000000000000000000000000000000007f000000000000000000000000000000000000000000000000000000000000000083610480565b604051636e553f6560e01b8152600481018290523060248201527f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031690636e553f6590604401610297565b604051636eb1769f60e11b81523060048201526001600160a01b03838116602483015282919085169063dd62ed3e90604401602060405180830381865afa1580156104cf573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906104f3919061064d565b101561056f5760405163095ea7b360e01b81526001600160a01b038381166004830152600019602483015284169063095ea7b3906044016020604051808303816000875af1158015610549573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061056d9190610666565b505b505050565b600060208083528351808285015260005b818110156105a157858101830151858201604001528201610585565b818111156105b3576000604083870101525b50601f01601f1916929092016040019392505050565b6000602082840312156105db57600080fd5b81356001600160a01b03811681146105f257600080fd5b9392505050565b60006020828403121561060b57600080fd5b5035919050565b600181811c9082168061062657607f821691505b6020821081141561064757634e487b7160e01b600052602260045260246000fd5b50919050565b60006020828403121561065f57600080fd5b5051919050565b60006020828403121561067857600080fd5b815180151581146105f257600080fdfea164736f6c634300080a000a00000000000000000000000020706baa0f89e2dccf48ea549ea5a13b9b30462f

Constructor Arguments (ABI-Encoded and is the last bytes of the Contract Creation Code above)

00000000000000000000000020706baa0f89e2dccf48ea549ea5a13b9b30462f

-----Decoded View---------------
Arg [0] : _vault (address): 0x20706baA0F89e2dccF48eA549ea5A13B9b30462f

-----Encoded View---------------
1 Constructor Arguments found :
Arg [0] : 00000000000000000000000020706baa0f89e2dccf48ea549ea5a13b9b30462f


Block Transaction Difficulty Gas Used Reward
Block Uncle Number Difficulty Gas Used Reward
Loading
Loading
Make sure to use the "Vote Down" button for any spammy posts, and the "Vote Up" for interesting conversations.

A contract address hosts a smart contract, which is a set of code stored on the blockchain that runs when predetermined conditions are met. Learn more about addresses in our Knowledge Base.