More Info
Private Name Tags
ContractCreator
TokenTracker
Latest 25 from a total of 270 transactions
Transaction Hash |
Method
|
Block
|
From
|
To
|
|||||
---|---|---|---|---|---|---|---|---|---|
Multicall | 21881711 | 56 mins ago | IN | 0 ETH | 0.00075386 | ||||
Multicall | 21881635 | 1 hr ago | IN | 0 ETH | 0.0007889 | ||||
Multicall | 21880883 | 3 hrs ago | IN | 0 ETH | 0.00088478 | ||||
Multicall | 21880690 | 4 hrs ago | IN | 0 ETH | 0.00070282 | ||||
Multicall | 21880562 | 4 hrs ago | IN | 0 ETH | 0.00065019 | ||||
Multicall | 21880494 | 5 hrs ago | IN | 0 ETH | 0.00096911 | ||||
Multicall | 21880124 | 6 hrs ago | IN | 0 ETH | 0.00064948 | ||||
Multicall | 21879947 | 6 hrs ago | IN | 0 ETH | 0.00091645 | ||||
Multicall | 21879876 | 7 hrs ago | IN | 0 ETH | 0.00065731 | ||||
Multicall | 21878423 | 11 hrs ago | IN | 0 ETH | 0.00044371 | ||||
Multicall | 21878381 | 12 hrs ago | IN | 0 ETH | 0.00032425 | ||||
Multicall | 21878249 | 12 hrs ago | IN | 0 ETH | 0.00046744 | ||||
Multicall | 21878210 | 12 hrs ago | IN | 0 ETH | 0.00037503 | ||||
Multicall | 21878084 | 13 hrs ago | IN | 0 ETH | 0.0003974 | ||||
Multicall | 21878001 | 13 hrs ago | IN | 0 ETH | 0.00019582 | ||||
Multicall | 21876817 | 17 hrs ago | IN | 0 ETH | 0.00044756 | ||||
Multicall | 21876142 | 19 hrs ago | IN | 0 ETH | 0.00160396 | ||||
Multicall | 21875512 | 21 hrs ago | IN | 0 ETH | 0.00049151 | ||||
Multicall | 21873526 | 28 hrs ago | IN | 0 ETH | 0.00127931 | ||||
Multicall | 21869398 | 42 hrs ago | IN | 0 ETH | 0.00052234 | ||||
Multicall | 21840034 | 5 days ago | IN | 0 ETH | 0.00048914 | ||||
Multicall | 21835274 | 6 days ago | IN | 0 ETH | 0.00049453 | ||||
Multicall | 21831630 | 7 days ago | IN | 0 ETH | 0.00052448 | ||||
Multicall | 21826543 | 7 days ago | IN | 0 ETH | 0.00045258 | ||||
Multicall | 21826511 | 7 days ago | IN | 0 ETH | 0.00074807 |
Latest 1 internal transaction
Advanced mode:
Parent Transaction Hash | Block |
From
|
To
|
|||
---|---|---|---|---|---|---|
19771128 | 294 days ago | Contract Creation | 0 ETH |
Loading...
Loading
This contract may be a proxy contract. Click on More Options and select Is this a proxy? to confirm and enable the "Read as Proxy" & "Write as Proxy" tabs.
Contract Source Code Verified (Exact Match)
Contract Name:
Yearn4626RouterExt
Compiler Version
v0.8.18+commit.87f61d96
Optimization Enabled:
Yes with 200 runs
Other Settings:
paris EvmVersion
Contract Source Code (Solidity Standard Json-Input format)
// SPDX-License-Identifier: BUSL-1.1 pragma solidity 0.8.18; import { Yearn4626Router } from "Yearn-ERC4626-Router/Yearn4626Router.sol"; import { IYearnVaultV2 } from "./interfaces/deps/yearn/veYFI/IYearnVaultV2.sol"; import { IPermit2 } from "permit2/interfaces/IPermit2.sol"; import { ISignatureTransfer } from "permit2/interfaces/ISignatureTransfer.sol"; import { IWETH9 } from "Yearn-ERC4626-Router/external/PeripheryPayments.sol"; import { IYearn4626RouterExt } from "./interfaces/IYearn4626RouterExt.sol"; import { YearnVaultV2Helper } from "./libraries/YearnVaultV2Helper.sol"; import { SafeERC20, IERC20 } from "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol"; import { IERC4626 } from "@openzeppelin/contracts/interfaces/IERC4626.sol"; import { Math } from "@openzeppelin/contracts/utils/math/Math.sol"; import { Address } from "@openzeppelin/contracts/utils/Address.sol"; import { IStakeDaoGauge } from "./interfaces/deps/stakeDAO/IStakeDaoGauge.sol"; import { IStakeDaoVault } from "./interfaces/deps/stakeDAO/IStakeDaoVault.sol"; /** * @title Yearn4626Router Extension * @notice Extends the Yearn4626Router with additional functionality for depositing to Yearn Vault V2 and pulling tokens * with Permit2. * @dev This contract introduces two key functions: depositing to Yearn Vault V2 and pulling tokens with a signature via * Permit2. * The contract holds an immutable reference to a Permit2 contract to facilitate token transfers with permits. */ contract Yearn4626RouterExt is IYearn4626RouterExt, Yearn4626Router { using SafeERC20 for IERC20; using YearnVaultV2Helper for IYearnVaultV2; // slither-disable-next-line naming-convention IPermit2 private immutable _PERMIT2; /// @notice Error for when the number of shares received is less than the minimum expected. error InsufficientShares(); /// @notice Error for when the amount of assets received is less than the minimum expected. error InsufficientAssets(); /// @notice Error for when the amount of shares burned is more than the maximum expected. error RequiresMoreThanMaxShares(); /// @notice Error for when the `to` address in the Permit2 transfer is not the router contract. error InvalidPermit2TransferTo(); /// @notice Error for when the amount in the Permit2 transfer is not the same as the requested amount. error InvalidPermit2TransferAmount(); /// @notice Error for when the serialized deposit path is too short. error InvalidPathLength(); /// @notice Error for when the path is too short to preview the deposits/mints/withdraws/redeems. error PreviewPathIsTooShort(); /// @notice Error for when the address in the path is not a vault. error PreviewNonVaultAddressInPath(address invalidVault); /// @notice Error for when an address in the path does not match previous or next vault's asset. error PreviewVaultMismatch(); /** * @notice Constructs the Yearn4626RouterExt contract. * @dev Sets up the router with the name for the vault, WETH address, and Permit2 contract address. * @param name_ The name of the vault. * @param weth_ The address of the WETH contract. * @param permit2_ The address of the Permit2 contract. */ // slither-disable-next-line locked-ether constructor(string memory name_, address weth_, address permit2_) payable Yearn4626Router(name_, IWETH9(weth_)) { _PERMIT2 = IPermit2(permit2_); } /** * @notice Deposits the specified `amount` of assets into series of ERC4626 vaults or Yearn Vault V2. * @param path The array of addresses that represents the vaults to deposit into. * @param assetsIn The amount of assets to deposit into the first vault. * @param to The address to which the shares will be transferred. * @param minSharesOut The minimum amount of shares expected to be received. * @return sharesOut The actual amount of shares received by the `to` address. */ function serializedDeposits( address[] calldata path, uint256 assetsIn, address to, uint256 minSharesOut ) external payable returns (uint256 sharesOut) { unchecked { if (path.length == 0) revert InvalidPathLength(); uint256 last = path.length - 1; for (uint256 i; i < path.length;) { address receiver = address(this); if (i == last) { receiver = to; } // slither-disable-next-line calls-loop assetsIn = sharesOut = IERC4626(path[i]).deposit(assetsIn, receiver); ++i; } if (sharesOut < minSharesOut) revert InsufficientShares(); } } /** * @notice Redeems the specified `shares` from a series of ERC4626 vaults or Yearn Vault V2. * @param path The array of addresses that represents the vaults to redeem from. * @param isYearnVaultV2 The array of boolean values that represent whether the vault is a Yearn Vault V2. * @param sharesIn The amount of shares to redeem from the first vault. * @param to The address to which the assets will be transferred. * @param minAssetsOut The minimum amount of assets expected to be received. * @return assetsOut The actual amount of assets received by the `to` address. */ function serializedRedeems( address[] calldata path, bool[] calldata isYearnVaultV2, uint256 sharesIn, address to, uint256 minAssetsOut ) external payable returns (uint256 assetsOut) { unchecked { uint256 length = path.length; if (length == 0) revert InvalidPathLength(); if (length != isYearnVaultV2.length) revert InvalidPathLength(); uint256 last = length - 1; for (uint256 i; i < length;) { address receiver = address(this); if (i == last) { receiver = to; } if (isYearnVaultV2[i]) { // slither-disable-next-line calls-loop sharesIn = assetsOut = IYearnVaultV2(path[i]).withdraw(sharesIn, receiver); } else { // slither-disable-next-line calls-loop sharesIn = assetsOut = IERC4626(path[i]).redeem(sharesIn, receiver, address(this)); } ++i; } if (assetsOut < minAssetsOut) revert InsufficientAssets(); } } // ------------- YEARN VAULT V2 FUNCTIONS ------------- // /** * @notice Redeems the specified `shares` from the Yearn Vault V2. * @dev The shares must exist in this router before calling this function. * @param vault The Yearn Vault V2 contract instance. * @param shares The amount of shares to redeem. * @param to The address to which the assets will be transferred. * @param minAssetsOut The minimum amount of assets expected to be received. * @return amountOut The actual amount of assets received by the `to` address. */ function redeemVaultV2( IYearnVaultV2 vault, uint256 shares, address to, uint256 minAssetsOut ) public payable returns (uint256 amountOut) { if ((amountOut = vault.withdraw(shares, to)) < minAssetsOut) revert InsufficientAssets(); } // ------------- ERC4626 VAULT FUNCTIONS ------------- // /** * @notice Redeems the specified IERC4626 vault `shares` that this router is holding. * @param vault The IERC4626 vault contract instance. * @param shares The amount of shares to redeem. * @param to The address to which the assets will be transferred. * @param minAmountOut The minimum amount of assets expected to be received. * @return amountOut The actual amount of assets received by the `to` address. */ function redeemFromRouter( IERC4626 vault, uint256 shares, address to, uint256 minAmountOut ) public payable virtual returns (uint256 amountOut) { if ((amountOut = vault.redeem(shares, to, address(this))) < minAmountOut) revert InsufficientAssets(); } /** * @notice Withdraws the specified `assets` from the IERC4626 vault. * @param vault The IERC4626 vault contract instance. * @param assets The amount of assets to withdraw. * @param to The address to which the assets will be transferred. * @param maxSharesIn The maximum amount of vault shares expected to be burned. * @return sharesOut The actual amount of shares burned from the `vault`. */ function withdrawFromRouter( IERC4626 vault, uint256 assets, address to, uint256 maxSharesIn ) public payable virtual returns (uint256 sharesOut) { if ((sharesOut = vault.withdraw(assets, to, address(this))) > maxSharesIn) revert RequiresMoreThanMaxShares(); } // ------------- STAKEDAO FUNCTIONS ------------- // /** * @notice Redeems the specified `shares` of the StakeDAO Gauge. * @dev Assumes the assets withdrawn will be the the yearn vault tokens and will always be the same amount as the * `shares` of the burned StakeDAO gauge tokens. * @param gauge The StakeDAO Gauge contract instance. * @param shares The amount of StakeDAO gauge tokens to burn. */ function redeemStakeDaoGauge(IStakeDaoGauge gauge, uint256 shares, address to) public payable returns (uint256) { IStakeDaoVault vault = IStakeDaoVault(gauge.staking_token()); vault.withdraw(shares); if (to != address(this)) { IERC20(vault.token()).safeTransfer(to, shares); } return shares; } // ------------- PERMIT2 FUNCTIONS ------------- // /** * @notice Pulls tokens to the contract using a signature via Permit2. * @dev Verifies that the `to` address in `transferDetails` is the contract itself and then calls * `permitTransferFrom` on the Permit2 contract. * Reverts with `InvalidTo` if the `to` address is not the contract itself. * @param permit The PermitTransferFrom struct containing the permit details. * @param transferDetails The details of the transfer, including the `to` address. * @param signature The signature to authorize the token transfer. */ function pullTokenWithPermit2( ISignatureTransfer.PermitTransferFrom calldata permit, ISignatureTransfer.SignatureTransferDetails calldata transferDetails, bytes calldata signature ) public payable { if (transferDetails.to != address(this)) revert InvalidPermit2TransferTo(); if (permit.permitted.amount != transferDetails.requestedAmount) revert InvalidPermit2TransferAmount(); _PERMIT2.permitTransferFrom(permit, transferDetails, msg.sender, signature); } // ------------- PREVIEW FUNCTIONS ------------- // /** * @notice Calculate the amount of shares to be received from a series of deposits to ERC4626 vaults or Yearn Vault * V2. * @param path The array of addresses that represents the path from input token to output token * @param assetsIn The amount of assets to deposit into the first vault. * @return sharesOut The amount of shares to be received from each deposit. The length of the array is `path.length * - 1`. */ // slither-disable-start calls-loop,low-level-calls function previewDeposits( address[] calldata path, uint256 assetsIn ) external view returns (uint256[] memory sharesOut) { if (path.length < 2) revert PreviewPathIsTooShort(); uint256 sharesOutLength = path.length - 1; sharesOut = new uint256[](sharesOutLength); for (uint256 i; i < sharesOutLength;) { address vault = path[i + 1]; if (!Address.isContract(vault)) { revert PreviewNonVaultAddressInPath(vault); } address vaultAsset = address(0); (bool success, bytes memory data) = vault.staticcall(abi.encodeCall(IERC4626.asset, ())); if (success) { vaultAsset = abi.decode(data, (address)); assetsIn = sharesOut[i] = IERC4626(vault).previewDeposit(assetsIn); } else { (success, data) = vault.staticcall(abi.encodeCall(IYearnVaultV2.token, ())); if (success) { vaultAsset = abi.decode(data, (address)); assetsIn = sharesOut[i] = IYearnVaultV2(vault).previewDeposit(assetsIn); } else { revert PreviewNonVaultAddressInPath(vault); } } if (vaultAsset != path[i]) { revert PreviewVaultMismatch(); } /// @dev Increment the loop index `i` without checking for overflow. /// This is safe because the loop's termination condition ensures that `i` will not exceed /// the bounds of the `sharesOut` array, which would be the only case where an overflow could occur. unchecked { ++i; } } } /** * @notice Calculate the amount of assets required to mint a given amount of shares from a series of deposits to * ERC4626 vaults or Yearn Vault V2. * @param path The array of addresses that represents the path from input to output. * @param sharesOut The amount of shares to mint from the last vault. * @return assetsIn The amount of assets required at each step. The length of the array is `path.length - 1`. * @dev sharesOut is the expected result at the last vault, and the path = [tokenIn, vault0, vault1, ..., vaultN]. * First calculate the amount of assets in to get the desired sharesOut from the last vault, then using that amount * as the next sharesOut to get the amount of assets in for the penultimate vault. */ function previewMints( address[] calldata path, uint256 sharesOut ) external view returns (uint256[] memory assetsIn) { if (path.length < 2) revert PreviewPathIsTooShort(); uint256 assetsInLength = path.length - 1; assetsIn = new uint256[](assetsInLength); for (uint256 i = assetsInLength; i > 0;) { address vault = path[i]; if (!Address.isContract(vault)) { revert PreviewNonVaultAddressInPath(vault); } address vaultAsset = address(0); (bool success, bytes memory data) = vault.staticcall(abi.encodeCall(IERC4626.asset, ())); if (success) { vaultAsset = abi.decode(data, (address)); sharesOut = assetsIn[i - 1] = IERC4626(vault).previewMint(sharesOut); } else { (success, data) = vault.staticcall(abi.encodeCall(IYearnVaultV2.token, ())); if (success) { vaultAsset = abi.decode(data, (address)); sharesOut = assetsIn[i - 1] = IYearnVaultV2(vault).previewMint(sharesOut); } else { revert PreviewNonVaultAddressInPath(vault); } } if (vaultAsset != path[i - 1]) { revert PreviewVaultMismatch(); } /// @dev Decrement the loop counter within an unchecked block to avoid redundant gas cost associated with /// underflow checking. This is safe because the loop's initialization and exit condition ensure that `i` /// will not underflow. unchecked { --i; } } } /** * @notice Calculate the amount of shares required to withdraw a given amount of assets from a series of withdraws * from ERC4626 vaults or Yearn Vault V2. * @param path The array of addresses that represents the path from input to output. * @param assetsOut The amount of assets to withdraw from the last vault. * @dev assetsOut is the desired result of the output token, and the path = [vault0, vault1, ..., vaultN, tokenOut]. * First calculate the amount of shares in to get the desired assetsOut from the last vault, then using that amount * as the next assetsOut to get the amount of shares in for the penultimate vault. * @return sharesIn The amount of shares required at each step. The length of the array is `path.length - 1`. */ function previewWithdraws( address[] calldata path, uint256 assetsOut ) external view returns (uint256[] memory sharesIn) { if (path.length < 2) revert PreviewPathIsTooShort(); uint256 sharesInLength = path.length - 1; sharesIn = new uint256[](sharesInLength); for (uint256 i = path.length - 2;;) { address vault = path[i]; if (!Address.isContract(vault)) { revert PreviewNonVaultAddressInPath(vault); } address vaultAsset = address(0); (bool success, bytes memory data) = vault.staticcall(abi.encodeCall(IERC4626.asset, ())); if (success) { vaultAsset = abi.decode(data, (address)); assetsOut = sharesIn[i] = IERC4626(vault).previewWithdraw(assetsOut); } else { (success, data) = vault.staticcall(abi.encodeCall(IYearnVaultV2.token, ())); if (success) { vaultAsset = abi.decode(data, (address)); assetsOut = sharesIn[i] = IYearnVaultV2(vault).previewWithdraw(assetsOut); } else { // StakeDAO gauge token // StakeDaoGauge.staking_token().token() is the yearn vault v2 token (success, data) = vault.staticcall(abi.encodeCall(IStakeDaoGauge.staking_token, ())); if (success) { vaultAsset = IStakeDaoVault(abi.decode(data, (address))).token(); sharesIn[i] = assetsOut; } else { revert PreviewNonVaultAddressInPath(vault); } } } if (vaultAsset != path[i + 1]) { revert PreviewVaultMismatch(); } if (i == 0) return sharesIn; /// @dev Decrement the loop counter without checking for overflow. This is safe because the for loop /// naturally ensures that `i` will not underflow as it is bounded by i == 0 check. unchecked { --i; } } } /** * @notice Calculate the amount of assets to be received from a series of withdraws from ERC4626 vaults or Yearn * Vault V2. * @param path The array of addresses that represents the path from input to output. * @param sharesIn The amount of shares to withdraw from the first vault. * @return assetsOut The amount of assets to be received at each step. The length of the array is `path.length - 1`. */ function previewRedeems( address[] calldata path, uint256 sharesIn ) external view returns (uint256[] memory assetsOut) { if (path.length < 2) revert PreviewPathIsTooShort(); uint256 assetsOutLength = path.length - 1; assetsOut = new uint256[](assetsOutLength); for (uint256 i; i < assetsOutLength;) { address vault = path[i]; if (!Address.isContract(vault)) { revert PreviewNonVaultAddressInPath(vault); } address vaultAsset = address(0); (bool success, bytes memory data) = vault.staticcall(abi.encodeCall(IERC4626.asset, ())); if (success) { vaultAsset = abi.decode(data, (address)); sharesIn = assetsOut[i] = IERC4626(vault).previewRedeem(sharesIn); } else { (success, data) = vault.staticcall(abi.encodeCall(IYearnVaultV2.token, ())); if (success) { vaultAsset = abi.decode(data, (address)); sharesIn = assetsOut[i] = IYearnVaultV2(vault).previewRedeem(sharesIn); } else { // StakeDAO gauge token // StakeDaoGauge.staking_token().token() is the yearn vault v2 token (success, data) = vault.staticcall(abi.encodeCall(IStakeDaoGauge.staking_token, ())); if (success) { vaultAsset = IStakeDaoVault(abi.decode(data, (address))).token(); assetsOut[i] = sharesIn; } else { revert PreviewNonVaultAddressInPath(vault); } } } if (vaultAsset != path[i + 1]) { revert PreviewVaultMismatch(); } /// @dev The unchecked block is used here to prevent overflow checking for the loop increment, which is not /// necessary since the loop's exit condition ensures `i` will not exceed `assetsOutLength`. unchecked { ++i; } } } // slither-disable-end calls-loop,low-level-calls }
// SPDX-License-Identifier: GPL-2.0-or-later pragma solidity 0.8.18; import "./Yearn4626RouterBase.sol"; import {IYearn4626Router, IYearnV2} from "./interfaces/IYearn4626Router.sol"; /** * @title Yearn4626Router contract * @notice * Router that is meant to be used with Yearn V3 vaults and strategies * for deposits, withdraws and migrations. * * The router was developed from the original router by FEI protocol * https://github.com/fei-protocol/ERC4626 * * The router is designed to be used with permit and multicall for the * optimal experience. * * NOTE: It is important to never leave tokens in the router at the * end of a call, otherwise they can be swept by anyone. */ contract Yearn4626Router is IYearn4626Router, Yearn4626RouterBase { using SafeTransferLib for ERC20; // Store name as bytes so it can be immutable bytes32 private immutable _name; constructor(string memory _name_, IWETH9 weth) PeripheryPayments(weth) { _name = bytes32(abi.encodePacked(_name_)); } // Getter function to unpack stored name. function name() external view returns(string memory) { return string(abi.encodePacked(_name)); } /*////////////////////////////////////////////////////////////// DEPOSIT //////////////////////////////////////////////////////////////*/ // For the below, no approval needed, assumes vault is already max approved /// @inheritdoc IYearn4626Router function depositToVault( IYearn4626 vault, uint256 amount, address to, uint256 minSharesOut ) public payable override returns (uint256) { pullToken(ERC20(vault.asset()), amount, address(this)); return deposit(vault, amount, to, minSharesOut); } //-------- DEPOSIT FUNCTIONS WITH DEFAULT VALUES --------\\ /** @notice See {depositToVault} in IYearn4626Router. @dev Uses msg.sender as the default for `to`. */ function depositToVault( IYearn4626 vault, uint256 amount, uint256 minSharesOut ) external payable returns (uint256) { return depositToVault(vault, amount, msg.sender, minSharesOut); } /** @notice See {depositToVault} in IYearn4626Router. @dev Uses msg.sender as the default for `to` and their full balance of msg.sender as `amount`. */ function depositToVault( IYearn4626 vault, uint256 minSharesOut ) external payable returns (uint256) { uint256 amount = ERC20(vault.asset()).balanceOf(msg.sender); return depositToVault(vault, amount, msg.sender, minSharesOut); } /** @notice See {depositToVault} in IYearn4626Router. @dev Uses msg.sender as the default for `to`, their full balance of msg.sender as `amount` and 1 Basis point for `maxLoss`. NOTE: The slippage tollerance is only useful if {previewDeposit} cannot be manipulated for the `vault`. */ function depositToVault( IYearn4626 vault ) external payable returns (uint256) { uint256 assets = ERC20(vault.asset()).balanceOf(msg.sender); // This give a default 1Basis point acceptance for loss. This is only // considered safe if the vaults PPS can not be manipulated. uint256 minSharesOut = vault.previewDeposit(assets) * 9_999 / 10_000; return depositToVault(vault, assets, msg.sender, minSharesOut); } /*////////////////////////////////////////////////////////////// REDEEM //////////////////////////////////////////////////////////////*/ //-------- REDEEM FUNCTIONS WITH DEFAULT VALUES --------\\ /** @notice See {redeem} in IYearn4626RouterBase. @dev Uses msg.sender as `receiver`. */ function redeem( IYearn4626 vault, uint256 shares, uint256 maxLoss ) external payable returns (uint256) { return redeem(vault, shares, msg.sender, maxLoss); } /** @notice See {redeem} in IYearn4626RouterBase. @dev Uses msg.sender as `receiver` and their full balance as `shares`. */ function redeem( IYearn4626 vault, uint256 maxLoss ) external payable returns (uint256) { uint256 shares = vault.balanceOf(msg.sender); return redeem(vault, shares, msg.sender, maxLoss); } /** @notice See {redeem} in IYearn4626RouterBase. @dev Uses msg.sender as `receiver`, their full balance as `shares` and 1 Basis Point for `maxLoss`. */ function redeem( IYearn4626 vault ) external payable returns (uint256) { uint256 shares = vault.balanceOf(msg.sender); return redeem(vault, shares, msg.sender, 1); } /*////////////////////////////////////////////////////////////// MIGRATE //////////////////////////////////////////////////////////////*/ /// @inheritdoc IYearn4626Router function migrate( IYearn4626 fromVault, IYearn4626 toVault, uint256 shares, address to, uint256 minSharesOut ) public payable override returns (uint256) { // amount out passes through so only one slippage check is needed uint256 amount = redeem(fromVault, shares, address(this), 10_000); return deposit(toVault, amount, to, minSharesOut); } //-------- MIGRATE FUNCTIONS WITH DEFAULT VALUES --------\\ /** @notice See {migrate} in IYearn4626Router. @dev Uses msg.sender as `to`. */ function migrate( IYearn4626 fromVault, IYearn4626 toVault, uint256 shares, uint256 minSharesOut ) external payable returns (uint256) { return migrate(fromVault, toVault, shares, msg.sender, minSharesOut); } /** @notice See {migrate} in IYearn4626Router. @dev Uses msg.sender as `to` and their full balance for `shares`. */ function migrate( IYearn4626 fromVault, IYearn4626 toVault, uint256 minSharesOut ) external payable returns (uint256) { uint256 shares = fromVault.balanceOf(msg.sender); return migrate(fromVault, toVault, shares, msg.sender, minSharesOut); } /** @notice See {migrate} in IYearn4626Router. @dev Uses msg.sender as `to`, their full balance for `shares` and no `minamountOut`. NOTE: Using this will enforce no slippage checks and should be used with care. */ function migrate( IYearn4626 fromVault, IYearn4626 toVault ) external payable returns (uint256) { uint256 shares = fromVault.balanceOf(msg.sender); return migrate(fromVault, toVault, shares, msg.sender, 0); } /*////////////////////////////////////////////////////////////// V2 MIGRATION //////////////////////////////////////////////////////////////*/ /// @inheritdoc IYearn4626Router function migrateFromV2( IYearnV2 fromVault, IYearn4626 toVault, uint256 shares, address to, uint256 minSharesOut ) public payable override returns (uint256) { // V2 can't specify owner so we need to first pull the shares fromVault.transferFrom(msg.sender, address(this), shares); // amount out passes through so only one slippage check is needed uint256 redeemed = fromVault.withdraw(shares, address(this)); return deposit(toVault, redeemed, to, minSharesOut); } //-------- migrateFromV2 FUNCTIONS WITH DEFAULT VALUES --------\\ /** @notice See {migrateFromV2} in IYearn4626Router. @dev Uses msg.sender as `to`. */ function migrateFromV2( IYearnV2 fromVault, IYearn4626 toVault, uint256 shares, uint256 minSharesOut ) external payable returns (uint256) { return migrateFromV2(fromVault, toVault, shares, msg.sender, minSharesOut); } /** @notice See {migrateFromV2} in IYearn4626Router. @dev Uses msg.sender as `to` and their full balance as `shares`. */ function migrateFromV2( IYearnV2 fromVault, IYearn4626 toVault, uint256 minSharesOut ) external payable returns (uint256) { uint256 shares = fromVault.balanceOf(msg.sender); return migrateFromV2(fromVault, toVault, shares, msg.sender, minSharesOut); } /** @notice See {migrate} in IYearn4626Router. @dev Uses msg.sender as `to`, their full balance for `shares` and no `minamountOut`. NOTE: Using this will enforce no slippage checks and should be used with care. */ function migrateFromV2( IYearnV2 fromVault, IYearn4626 toVault ) external payable returns (uint256 sharesOut) { uint256 shares = fromVault.balanceOf(msg.sender); return migrateFromV2(fromVault, toVault, shares, msg.sender, 0); } }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.18; // @dev YearnVaultV2 does not follow ERC4626 interface for `asset()` instead it uses `token()` interface IYearnVaultV2 { function token() external view returns (address); function deposit(uint256 amount, address recipient) external returns (uint256 shares); function deposit(uint256 amount) external returns (uint256 shares); function withdraw(uint256 shares, address recipient) external returns (uint256 amount); function pricePerShare() external view returns (uint256); function totalSupply() external view returns (uint256); function totalAssets() external view returns (uint256); function lastReport() external view returns (uint256); function lockedProfitDegradation() external view returns (uint256); function lockedProfit() external view returns (uint256); }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import {ISignatureTransfer} from "./ISignatureTransfer.sol"; import {IAllowanceTransfer} from "./IAllowanceTransfer.sol"; /// @notice Permit2 handles signature-based transfers in SignatureTransfer and allowance-based transfers in AllowanceTransfer. /// @dev Users must approve Permit2 before calling any of the transfer functions. interface IPermit2 is ISignatureTransfer, IAllowanceTransfer { // IPermit2 unifies the two interfaces so users have maximal flexibility with their approval. }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import {IEIP712} from "./IEIP712.sol"; /// @title SignatureTransfer /// @notice Handles ERC20 token transfers through signature based actions /// @dev Requires user's token approval on the Permit2 contract interface ISignatureTransfer is IEIP712 { /// @notice Thrown when the requested amount for a transfer is larger than the permissioned amount /// @param maxAmount The maximum amount a spender can request to transfer error InvalidAmount(uint256 maxAmount); /// @notice Thrown when the number of tokens permissioned to a spender does not match the number of tokens being transferred /// @dev If the spender does not need to transfer the number of tokens permitted, the spender can request amount 0 to be transferred error LengthMismatch(); /// @notice Emits an event when the owner successfully invalidates an unordered nonce. event UnorderedNonceInvalidation(address indexed owner, uint256 word, uint256 mask); /// @notice The token and amount details for a transfer signed in the permit transfer signature struct TokenPermissions { // ERC20 token address address token; // the maximum amount that can be spent uint256 amount; } /// @notice The signed permit message for a single token transfer struct PermitTransferFrom { TokenPermissions permitted; // a unique value for every token owner's signature to prevent signature replays uint256 nonce; // deadline on the permit signature uint256 deadline; } /// @notice Specifies the recipient address and amount for batched transfers. /// @dev Recipients and amounts correspond to the index of the signed token permissions array. /// @dev Reverts if the requested amount is greater than the permitted signed amount. struct SignatureTransferDetails { // recipient address address to; // spender requested amount uint256 requestedAmount; } /// @notice Used to reconstruct the signed permit message for multiple token transfers /// @dev Do not need to pass in spender address as it is required that it is msg.sender /// @dev Note that a user still signs over a spender address struct PermitBatchTransferFrom { // the tokens and corresponding amounts permitted for a transfer TokenPermissions[] permitted; // a unique value for every token owner's signature to prevent signature replays uint256 nonce; // deadline on the permit signature uint256 deadline; } /// @notice A map from token owner address and a caller specified word index to a bitmap. Used to set bits in the bitmap to prevent against signature replay protection /// @dev Uses unordered nonces so that permit messages do not need to be spent in a certain order /// @dev The mapping is indexed first by the token owner, then by an index specified in the nonce /// @dev It returns a uint256 bitmap /// @dev The index, or wordPosition is capped at type(uint248).max function nonceBitmap(address, uint256) external view returns (uint256); /// @notice Transfers a token using a signed permit message /// @dev Reverts if the requested amount is greater than the permitted signed amount /// @param permit The permit data signed over by the owner /// @param owner The owner of the tokens to transfer /// @param transferDetails The spender's requested transfer details for the permitted token /// @param signature The signature to verify function permitTransferFrom( PermitTransferFrom memory permit, SignatureTransferDetails calldata transferDetails, address owner, bytes calldata signature ) external; /// @notice Transfers a token using a signed permit message /// @notice Includes extra data provided by the caller to verify signature over /// @dev The witness type string must follow EIP712 ordering of nested structs and must include the TokenPermissions type definition /// @dev Reverts if the requested amount is greater than the permitted signed amount /// @param permit The permit data signed over by the owner /// @param owner The owner of the tokens to transfer /// @param transferDetails The spender's requested transfer details for the permitted token /// @param witness Extra data to include when checking the user signature /// @param witnessTypeString The EIP-712 type definition for remaining string stub of the typehash /// @param signature The signature to verify function permitWitnessTransferFrom( PermitTransferFrom memory permit, SignatureTransferDetails calldata transferDetails, address owner, bytes32 witness, string calldata witnessTypeString, bytes calldata signature ) external; /// @notice Transfers multiple tokens using a signed permit message /// @param permit The permit data signed over by the owner /// @param owner The owner of the tokens to transfer /// @param transferDetails Specifies the recipient and requested amount for the token transfer /// @param signature The signature to verify function permitTransferFrom( PermitBatchTransferFrom memory permit, SignatureTransferDetails[] calldata transferDetails, address owner, bytes calldata signature ) external; /// @notice Transfers multiple tokens using a signed permit message /// @dev The witness type string must follow EIP712 ordering of nested structs and must include the TokenPermissions type definition /// @notice Includes extra data provided by the caller to verify signature over /// @param permit The permit data signed over by the owner /// @param owner The owner of the tokens to transfer /// @param transferDetails Specifies the recipient and requested amount for the token transfer /// @param witness Extra data to include when checking the user signature /// @param witnessTypeString The EIP-712 type definition for remaining string stub of the typehash /// @param signature The signature to verify function permitWitnessTransferFrom( PermitBatchTransferFrom memory permit, SignatureTransferDetails[] calldata transferDetails, address owner, bytes32 witness, string calldata witnessTypeString, bytes calldata signature ) external; /// @notice Invalidates the bits specified in mask for the bitmap at the word position /// @dev The wordPos is maxed at type(uint248).max /// @param wordPos A number to index the nonceBitmap at /// @param mask A bitmap masked against msg.sender's current bitmap at the word position function invalidateUnorderedNonces(uint256 wordPos, uint256 mask) external; }
// SPDX-License-Identifier: GPL-2.0-or-later pragma solidity >=0.7.5; import "solmate/utils/SafeTransferLib.sol"; /** @title Periphery Payments @notice Immutable state used by periphery contracts Largely Forked from https://github.com/Uniswap/v3-periphery/blob/main/contracts/base/PeripheryPayments.sol Changes: * no interface * no inheritdoc * add immutable WETH9 in constructor instead of PeripheryImmutableState * receive from any address * Solmate interfaces and transfer lib * casting * add approve, wrapWETH9 and pullToken */ abstract contract PeripheryPayments { using SafeTransferLib for *; IWETH9 public immutable WETH9; constructor(IWETH9 _WETH9) { WETH9 = _WETH9; } receive() external payable {} function approve( ERC20 token, address to, uint256 amount ) public payable { token.safeApprove(to, amount); } function unwrapWETH9(uint256 amountMinimum, address recipient) public payable { uint256 balanceWETH9 = WETH9.balanceOf(address(this)); require(balanceWETH9 >= amountMinimum, "Insufficient WETH9"); if (balanceWETH9 > 0) { WETH9.withdraw(balanceWETH9); recipient.safeTransferETH(balanceWETH9); } } function wrapWETH9() public payable { if (address(this).balance > 0) WETH9.deposit{value: address(this).balance}(); // wrap everything } function pullToken( ERC20 token, uint256 amount, address recipient ) public payable { token.safeTransferFrom(msg.sender, recipient, amount); } function sweepToken( ERC20 token, uint256 amountMinimum, address recipient ) public payable { uint256 balanceToken = token.balanceOf(address(this)); require(balanceToken >= amountMinimum, "Insufficient token"); if (balanceToken > 0) { token.safeTransfer(recipient, balanceToken); } } function refundETH() external payable { if (address(this).balance > 0) SafeTransferLib.safeTransferETH(msg.sender, address(this).balance); } } abstract contract IWETH9 is ERC20 { /// @notice Deposit ether to get wrapped ether function deposit() external payable virtual; /// @notice Withdraw wrapped ether to get ether function withdraw(uint256) external virtual; }
// SPDX-License-Identifier: BUSL-1.1 pragma solidity ^0.8.18; import { IYearn4626Router } from "Yearn-ERC4626-Router/interfaces/IYearn4626Router.sol"; import { IYearnVaultV2 } from "./deps/yearn/veYFI/IYearnVaultV2.sol"; import { ISignatureTransfer } from "permit2/interfaces/ISignatureTransfer.sol"; import { IERC4626 } from "@openzeppelin/contracts/interfaces/IERC4626.sol"; import { IStakeDaoGauge } from "./deps/stakeDAO/IStakeDaoGauge.sol"; interface IYearn4626RouterExt is IYearn4626Router { function redeemVaultV2( IYearnVaultV2 vault, uint256 shares, address to, uint256 minAmountOut ) external payable returns (uint256 amountOut); function redeemFromRouter( IERC4626 vault, uint256 shares, address to, uint256 minAmountOut ) external payable returns (uint256 amountOut); function withdrawFromRouter( IERC4626 vault, uint256 assets, address to, uint256 maxSharesIn ) external payable returns (uint256 sharesIn); function redeemStakeDaoGauge( IStakeDaoGauge gauge, uint256 shares, address to ) external payable returns (uint256 amountOut); function previewDeposits( address[] calldata path, uint256 assetsIn ) external view returns (uint256[] memory sharesOut); function previewMints( address[] calldata path, uint256 sharesOut ) external view returns (uint256[] memory assetsIn); function previewWithdraws( address[] calldata path, uint256 assetsOut ) external view returns (uint256[] memory sharesIn); function previewRedeems( address[] calldata path, uint256 sharesIn ) external view returns (uint256[] memory assetsOut); function pullTokenWithPermit2( ISignatureTransfer.PermitTransferFrom memory permit, ISignatureTransfer.SignatureTransferDetails calldata transferDetails, bytes calldata signature ) external payable; }
// SPDX-License-Identifier: BUSL-1.1 pragma solidity 0.8.18; import { IYearnVaultV2 } from "src/interfaces/deps/yearn/veYFI/IYearnVaultV2.sol"; import { Math } from "@openzeppelin/contracts/utils/math/Math.sol"; /** * @title YearnVaultV2Helper * @notice Helper functions for Yearn Vault V2 contracts. Since Yearn Vault V2 contracts are not ERC-4626 compliant, * they do not provide `previewDeposit`, `previewMint`, `previewRedeem`, and `previewWithdraw` functions. This library * provides these functions for previewing share based deposit/mint/redeem/withdraw estimations. * @dev These functions are only to be used off-chain for previewing. Due to how Yearn Vault V2 contracts work, * share based withdraw/redeem estimations may not be accurate if the vault incurs a loss, thus share price changes. * Coverage is currently disabled for this library due to forge limitations. TODO: Once the fix PR is merged, * https://github.com/foundry-rs/foundry/pull/7510 coverage should be re-enabled. */ library YearnVaultV2Helper { /** * @notice Calculates the currently free funds in a Yearn Vault V2 contract. * @param vault The Yearn Vault V2 contract. * @return The free funds in the vault. * @dev This is based on Yearn Vault V2 contract's free funds calculation logic. * https://github.com/yearn/yearn-vaults/blob/97ca1b2e4fcf20f4be0ff456dabd020bfeb6697b/contracts/Vault.vy#L844-L847 */ function freeFunds(IYearnVaultV2 vault) internal view returns (uint256) { uint256 lockedProfit = vault.lockedProfit(); uint256 lockedFundsRatio = (block.timestamp - vault.lastReport()) * vault.lockedProfitDegradation(); // slither-disable-next-line timestamp if (lockedFundsRatio < 1e18) { lockedProfit -= (lockedProfit * lockedFundsRatio) / 1e18; } else { lockedProfit = 0; } return vault.totalAssets() - lockedProfit; } /** * @notice Preview the amount of shares to be issued for a given deposit amount. * @param vault The Yearn Vault V2 contract. * @param assetsIn The amount of assets to be deposited. * @return The number of shares that would be issued for the deposited assets. */ function previewDeposit(IYearnVaultV2 vault, uint256 assetsIn) internal view returns (uint256) { uint256 totalSupply = vault.totalSupply(); if (totalSupply > 0) { return Math.mulDiv(assetsIn, totalSupply, freeFunds(vault), Math.Rounding.Down); } return assetsIn; } /** * @notice Preview the amount of assets required to mint a given amount of shares. * @param vault The Yearn Vault V2 contract. * @param sharesOut The number of shares to be minted. * @return The amount of assets required to mint the specified number of shares. */ function previewMint(IYearnVaultV2 vault, uint256 sharesOut) internal view returns (uint256) { uint256 totalSupply = vault.totalSupply(); if (totalSupply > 0) { return Math.mulDiv(sharesOut, freeFunds(vault), totalSupply, Math.Rounding.Up); } return sharesOut; } /** * @notice Preview the amount of assets to be received for redeeming a given amount of shares. * @param vault The Yearn Vault V2 contract. * @param sharesIn The number of shares to be redeemed. * @return The amount of assets that would be received for the redeemed shares. */ function previewRedeem(IYearnVaultV2 vault, uint256 sharesIn) internal view returns (uint256) { uint256 totalSupply = vault.totalSupply(); if (sharesIn > totalSupply) { return freeFunds(vault); } if (totalSupply > 0) { return Math.mulDiv(sharesIn, freeFunds(vault), totalSupply, Math.Rounding.Down); } return 0; } /** * @notice Preview the number of shares to be redeemed for a given withdrawal amount of assets. * @param vault The Yearn Vault V2 contract. * @param assetsOut The amount of assets to be withdrawn. * @return The number of shares that would be redeemed for the withdrawn assets. */ function previewWithdraw(IYearnVaultV2 vault, uint256 assetsOut) internal view returns (uint256) { uint256 freeFunds_ = freeFunds(vault); // slither-disable-next-line timestamp if (assetsOut > freeFunds_) { return vault.totalSupply(); } // slither-disable-next-line timestamp if (freeFunds_ > 0) { return Math.mulDiv(assetsOut, vault.totalSupply(), freeFunds(vault), Math.Rounding.Up); } return 0; } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.9.3) (token/ERC20/utils/SafeERC20.sol) pragma solidity ^0.8.0; import "../IERC20.sol"; import "../extensions/IERC20Permit.sol"; import "../../../utils/Address.sol"; /** * @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 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.encodeWithSelector(token.transfer.selector, 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.encodeWithSelector(token.transferFrom.selector, from, to, value)); } /** * @dev Deprecated. This function has issues similar to the ones found in * {IERC20-approve}, and its usage is discouraged. * * Whenever possible, use {safeIncreaseAllowance} and * {safeDecreaseAllowance} instead. */ function safeApprove(IERC20 token, address spender, uint256 value) internal { // safeApprove should only be called when setting an initial allowance, // or when resetting it to zero. To increase and decrease it, use // 'safeIncreaseAllowance' and 'safeDecreaseAllowance' require( (value == 0) || (token.allowance(address(this), spender) == 0), "SafeERC20: approve from non-zero to non-zero allowance" ); _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, 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); _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, oldAllowance + value)); } /** * @dev Decrease the calling contract's allowance toward `spender` by `value`. If `token` returns no value, * non-reverting calls are assumed to be successful. */ function safeDecreaseAllowance(IERC20 token, address spender, uint256 value) internal { unchecked { uint256 oldAllowance = token.allowance(address(this), spender); require(oldAllowance >= value, "SafeERC20: decreased allowance below zero"); _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, oldAllowance - value)); } } /** * @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.encodeWithSelector(token.approve.selector, spender, value); if (!_callOptionalReturnBool(token, approvalCall)) { _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, 0)); _callOptionalReturn(token, approvalCall); } } /** * @dev Use a ERC-2612 signature to set the `owner` approval toward `spender` on `token`. * Revert on invalid signature. */ function safePermit( IERC20Permit token, address owner, address spender, uint256 value, uint256 deadline, uint8 v, bytes32 r, bytes32 s ) internal { uint256 nonceBefore = token.nonces(owner); token.permit(owner, spender, value, deadline, v, r, s); uint256 nonceAfter = token.nonces(owner); require(nonceAfter == nonceBefore + 1, "SafeERC20: permit did not succeed"); } /** * @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, "SafeERC20: low-level call failed"); require(returndata.length == 0 || abi.decode(returndata, (bool)), "SafeERC20: ERC20 operation did not succeed"); } /** * @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.isContract(address(token)); } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.9.0) (interfaces/IERC4626.sol) pragma solidity ^0.8.0; import "../token/ERC20/IERC20.sol"; import "../token/ERC20/extensions/IERC20Metadata.sol"; /** * @dev Interface of the ERC4626 "Tokenized Vault Standard", as defined in * https://eips.ethereum.org/EIPS/eip-4626[ERC-4626]. * * _Available since v4.7._ */ 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); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.9.0) (utils/math/Math.sol) pragma solidity ^0.8.0; /** * @dev Standard math utilities missing in the Solidity language. */ library Math { enum Rounding { Down, // Toward negative infinity Up, // Toward infinity Zero // Toward zero } /** * @dev Returns the largest of two numbers. */ function max(uint256 a, uint256 b) internal pure returns (uint256) { return a > b ? a : b; } /** * @dev Returns the smallest of two numbers. */ function min(uint256 a, uint256 b) internal pure returns (uint256) { return a < b ? a : b; } /** * @dev Returns the average of two numbers. The result is rounded towards * zero. */ function average(uint256 a, uint256 b) internal pure returns (uint256) { // (a + b) / 2 can overflow. return (a & b) + (a ^ b) / 2; } /** * @dev Returns the ceiling of the division of two numbers. * * This differs from standard division with `/` in that it rounds up instead * of rounding down. */ function ceilDiv(uint256 a, uint256 b) internal pure returns (uint256) { // (a + b - 1) / b can overflow on addition, so we distribute. return a == 0 ? 0 : (a - 1) / b + 1; } /** * @notice Calculates floor(x * y / denominator) with full precision. Throws if result overflows a uint256 or denominator == 0 * @dev Original credit to Remco Bloemen under MIT license (https://xn--2-umb.com/21/muldiv) * with further edits by Uniswap Labs also under MIT license. */ function mulDiv(uint256 x, uint256 y, uint256 denominator) internal pure returns (uint256 result) { unchecked { // 512-bit multiply [prod1 prod0] = x * y. Compute the product mod 2^256 and mod 2^256 - 1, then use // use the Chinese Remainder Theorem to reconstruct the 512 bit result. The result is stored in two 256 // variables such that product = prod1 * 2^256 + prod0. uint256 prod0; // Least significant 256 bits of the product uint256 prod1; // Most significant 256 bits of the product assembly { let mm := mulmod(x, y, not(0)) prod0 := mul(x, y) prod1 := sub(sub(mm, prod0), lt(mm, prod0)) } // Handle non-overflow cases, 256 by 256 division. if (prod1 == 0) { // Solidity will revert if denominator == 0, unlike the div opcode on its own. // The surrounding unchecked block does not change this fact. // See https://docs.soliditylang.org/en/latest/control-structures.html#checked-or-unchecked-arithmetic. return prod0 / denominator; } // Make sure the result is less than 2^256. Also prevents denominator == 0. require(denominator > prod1, "Math: mulDiv overflow"); /////////////////////////////////////////////// // 512 by 256 division. /////////////////////////////////////////////// // Make division exact by subtracting the remainder from [prod1 prod0]. uint256 remainder; assembly { // Compute remainder using mulmod. remainder := mulmod(x, y, denominator) // Subtract 256 bit number from 512 bit number. prod1 := sub(prod1, gt(remainder, prod0)) prod0 := sub(prod0, remainder) } // Factor powers of two out of denominator and compute largest power of two divisor of denominator. Always >= 1. // See https://cs.stackexchange.com/q/138556/92363. // Does not overflow because the denominator cannot be zero at this stage in the function. uint256 twos = denominator & (~denominator + 1); assembly { // Divide denominator by twos. denominator := div(denominator, twos) // Divide [prod1 prod0] by twos. prod0 := div(prod0, twos) // Flip twos such that it is 2^256 / twos. If twos is zero, then it becomes one. twos := add(div(sub(0, twos), twos), 1) } // Shift in bits from prod1 into prod0. prod0 |= prod1 * twos; // Invert denominator mod 2^256. Now that denominator is an odd number, it has an inverse modulo 2^256 such // that denominator * inv = 1 mod 2^256. Compute the inverse by starting with a seed that is correct for // four bits. That is, denominator * inv = 1 mod 2^4. uint256 inverse = (3 * denominator) ^ 2; // Use the Newton-Raphson iteration to improve the precision. Thanks to Hensel's lifting lemma, this also works // in modular arithmetic, doubling the correct bits in each step. inverse *= 2 - denominator * inverse; // inverse mod 2^8 inverse *= 2 - denominator * inverse; // inverse mod 2^16 inverse *= 2 - denominator * inverse; // inverse mod 2^32 inverse *= 2 - denominator * inverse; // inverse mod 2^64 inverse *= 2 - denominator * inverse; // inverse mod 2^128 inverse *= 2 - denominator * inverse; // inverse mod 2^256 // Because the division is now exact we can divide by multiplying with the modular inverse of denominator. // This will give us the correct result modulo 2^256. Since the preconditions guarantee that the outcome is // less than 2^256, this is the final result. We don't need to compute the high bits of the result and prod1 // is no longer required. result = prod0 * inverse; return result; } } /** * @notice Calculates x * y / denominator with full precision, following the selected rounding direction. */ function mulDiv(uint256 x, uint256 y, uint256 denominator, Rounding rounding) internal pure returns (uint256) { uint256 result = mulDiv(x, y, denominator); if (rounding == Rounding.Up && mulmod(x, y, denominator) > 0) { result += 1; } return result; } /** * @dev Returns the square root of a number. If the number is not a perfect square, the value is rounded down. * * Inspired by Henry S. Warren, Jr.'s "Hacker's Delight" (Chapter 11). */ function sqrt(uint256 a) internal pure returns (uint256) { if (a == 0) { return 0; } // For our first guess, we get the biggest power of 2 which is smaller than the square root of the target. // // We know that the "msb" (most significant bit) of our target number `a` is a power of 2 such that we have // `msb(a) <= a < 2*msb(a)`. This value can be written `msb(a)=2**k` with `k=log2(a)`. // // This can be rewritten `2**log2(a) <= a < 2**(log2(a) + 1)` // → `sqrt(2**k) <= sqrt(a) < sqrt(2**(k+1))` // → `2**(k/2) <= sqrt(a) < 2**((k+1)/2) <= 2**(k/2 + 1)` // // Consequently, `2**(log2(a) / 2)` is a good first approximation of `sqrt(a)` with at least 1 correct bit. uint256 result = 1 << (log2(a) >> 1); // At this point `result` is an estimation with one bit of precision. We know the true value is a uint128, // since it is the square root of a uint256. Newton's method converges quadratically (precision doubles at // every iteration). We thus need at most 7 iteration to turn our partial result with one bit of precision // into the expected uint128 result. unchecked { result = (result + a / result) >> 1; result = (result + a / result) >> 1; result = (result + a / result) >> 1; result = (result + a / result) >> 1; result = (result + a / result) >> 1; result = (result + a / result) >> 1; result = (result + a / result) >> 1; return min(result, a / result); } } /** * @notice Calculates sqrt(a), following the selected rounding direction. */ function sqrt(uint256 a, Rounding rounding) internal pure returns (uint256) { unchecked { uint256 result = sqrt(a); return result + (rounding == Rounding.Up && result * result < a ? 1 : 0); } } /** * @dev Return the log in base 2, rounded down, of a positive value. * Returns 0 if given 0. */ function log2(uint256 value) internal pure returns (uint256) { uint256 result = 0; unchecked { if (value >> 128 > 0) { value >>= 128; result += 128; } if (value >> 64 > 0) { value >>= 64; result += 64; } if (value >> 32 > 0) { value >>= 32; result += 32; } if (value >> 16 > 0) { value >>= 16; result += 16; } if (value >> 8 > 0) { value >>= 8; result += 8; } if (value >> 4 > 0) { value >>= 4; result += 4; } if (value >> 2 > 0) { value >>= 2; result += 2; } if (value >> 1 > 0) { result += 1; } } return result; } /** * @dev Return the log in base 2, following the selected rounding direction, of a positive value. * Returns 0 if given 0. */ function log2(uint256 value, Rounding rounding) internal pure returns (uint256) { unchecked { uint256 result = log2(value); return result + (rounding == Rounding.Up && 1 << result < value ? 1 : 0); } } /** * @dev Return the log in base 10, rounded down, of a positive value. * Returns 0 if given 0. */ function log10(uint256 value) internal pure returns (uint256) { uint256 result = 0; unchecked { if (value >= 10 ** 64) { value /= 10 ** 64; result += 64; } if (value >= 10 ** 32) { value /= 10 ** 32; result += 32; } if (value >= 10 ** 16) { value /= 10 ** 16; result += 16; } if (value >= 10 ** 8) { value /= 10 ** 8; result += 8; } if (value >= 10 ** 4) { value /= 10 ** 4; result += 4; } if (value >= 10 ** 2) { value /= 10 ** 2; result += 2; } if (value >= 10 ** 1) { result += 1; } } return result; } /** * @dev Return the log in base 10, following the selected rounding direction, of a positive value. * Returns 0 if given 0. */ function log10(uint256 value, Rounding rounding) internal pure returns (uint256) { unchecked { uint256 result = log10(value); return result + (rounding == Rounding.Up && 10 ** result < value ? 1 : 0); } } /** * @dev Return the log in base 256, rounded down, of a positive value. * Returns 0 if given 0. * * Adding one to the result gives the number of pairs of hex symbols needed to represent `value` as a hex string. */ function log256(uint256 value) internal pure returns (uint256) { uint256 result = 0; unchecked { if (value >> 128 > 0) { value >>= 128; result += 16; } if (value >> 64 > 0) { value >>= 64; result += 8; } if (value >> 32 > 0) { value >>= 32; result += 4; } if (value >> 16 > 0) { value >>= 16; result += 2; } if (value >> 8 > 0) { result += 1; } } return result; } /** * @dev Return the log in base 256, following the selected rounding direction, of a positive value. * Returns 0 if given 0. */ function log256(uint256 value, Rounding rounding) internal pure returns (uint256) { unchecked { uint256 result = log256(value); return result + (rounding == Rounding.Up && 1 << (result << 3) < value ? 1 : 0); } } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.9.0) (utils/Address.sol) pragma solidity ^0.8.1; /** * @dev Collection of functions related to the address type */ library Address { /** * @dev Returns true if `account` is a contract. * * [IMPORTANT] * ==== * It is unsafe to assume that an address for which this function returns * false is an externally-owned account (EOA) and not a contract. * * Among others, `isContract` will return false for the following * types of addresses: * * - an externally-owned account * - a contract in construction * - an address where a contract will be created * - an address where a contract lived, but was destroyed * * Furthermore, `isContract` will also return true if the target contract within * the same transaction is already scheduled for destruction by `SELFDESTRUCT`, * which only has an effect at the end of a transaction. * ==== * * [IMPORTANT] * ==== * You shouldn't rely on `isContract` to protect against flash loan attacks! * * Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets * like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract * constructor. * ==== */ function isContract(address account) internal view returns (bool) { // This method relies on extcodesize/address.code.length, which returns 0 // for contracts in construction, since the code is only stored at the end // of the constructor execution. return account.code.length > 0; } /** * @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.0/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern]. */ function sendValue(address payable recipient, uint256 amount) internal { require(address(this).balance >= amount, "Address: insufficient balance"); (bool success, ) = recipient.call{value: amount}(""); require(success, "Address: unable to send value, recipient may have reverted"); } /** * @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, it is bubbled up by this * function (like regular Solidity function calls). * * 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. * * _Available since v3.1._ */ function functionCall(address target, bytes memory data) internal returns (bytes memory) { return functionCallWithValue(target, data, 0, "Address: low-level call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with * `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCall( address target, bytes memory data, string memory errorMessage ) internal returns (bytes memory) { return functionCallWithValue(target, data, 0, errorMessage); } /** * @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`. * * _Available since v3.1._ */ function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) { return functionCallWithValue(target, data, value, "Address: low-level call with value failed"); } /** * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but * with `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCallWithValue( address target, bytes memory data, uint256 value, string memory errorMessage ) internal returns (bytes memory) { require(address(this).balance >= value, "Address: insufficient balance for call"); (bool success, bytes memory returndata) = target.call{value: value}(data); return verifyCallResultFromTarget(target, success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) { return functionStaticCall(target, data, "Address: low-level static call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall( address target, bytes memory data, string memory errorMessage ) internal view returns (bytes memory) { (bool success, bytes memory returndata) = target.staticcall(data); return verifyCallResultFromTarget(target, success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) { return functionDelegateCall(target, data, "Address: low-level delegate call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall( address target, bytes memory data, string memory errorMessage ) internal returns (bytes memory) { (bool success, bytes memory returndata) = target.delegatecall(data); return verifyCallResultFromTarget(target, success, returndata, errorMessage); } /** * @dev Tool to verify that a low level call to smart-contract was successful, and revert (either by bubbling * the revert reason or using the provided one) in case of unsuccessful call or if target was not a contract. * * _Available since v4.8._ */ function verifyCallResultFromTarget( address target, bool success, bytes memory returndata, string memory errorMessage ) internal view returns (bytes memory) { if (success) { if (returndata.length == 0) { // only check isContract if the call was successful and the return data is empty // otherwise we already know that it was a contract require(isContract(target), "Address: call to non-contract"); } return returndata; } else { _revert(returndata, errorMessage); } } /** * @dev Tool to verify that a low level call was successful, and revert if it wasn't, either by bubbling the * revert reason or using the provided one. * * _Available since v4.3._ */ function verifyCallResult( bool success, bytes memory returndata, string memory errorMessage ) internal pure returns (bytes memory) { if (success) { return returndata; } else { _revert(returndata, errorMessage); } } function _revert(bytes memory returndata, string memory errorMessage) 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(errorMessage); } } }
//SPDX-License-Identifier: MIT pragma solidity ^0.8.18; interface IStakeDaoGauge { function staking_token() external view returns (address); }
//SPDX-License-Identifier: MIT pragma solidity ^0.8.18; interface IStakeDaoVault { function withdraw(uint256 shares) external; function token() external view returns (address); }
// SPDX-License-Identifier: GPL-2.0-or-later pragma solidity 0.8.18; import {IYearn4626RouterBase, IYearn4626} from "./interfaces/IYearn4626RouterBase.sol"; import {ERC20} from "solmate/tokens/ERC20.sol"; import {SafeTransferLib} from "solmate/utils/SafeTransferLib.sol"; import {SelfPermit} from "./external/SelfPermit.sol"; import {Multicall} from "./external/Multicall.sol"; import {PeripheryPayments, IWETH9} from "./external/PeripheryPayments.sol"; /// @title ERC4626 Router Base Contract abstract contract Yearn4626RouterBase is IYearn4626RouterBase, SelfPermit, Multicall, PeripheryPayments { using SafeTransferLib for ERC20; /// @inheritdoc IYearn4626RouterBase function mint( IYearn4626 vault, uint256 shares, address to, uint256 maxAmountIn ) public payable virtual override returns (uint256 amountIn) { require ((amountIn = vault.mint(shares, to)) <= maxAmountIn, "!MaxAmount"); } /// @inheritdoc IYearn4626RouterBase function deposit( IYearn4626 vault, uint256 amount, address to, uint256 minSharesOut ) public payable virtual override returns (uint256 sharesOut) { require ((sharesOut = vault.deposit(amount, to)) >= minSharesOut, "!MinShares"); } /// @inheritdoc IYearn4626RouterBase function withdraw( IYearn4626 vault, uint256 amount, address to, uint256 maxLoss ) public payable virtual override returns (uint256) { return vault.withdraw(amount, to, msg.sender, maxLoss); } /// @inheritdoc IYearn4626RouterBase function withdrawDefault( IYearn4626 vault, uint256 amount, address to, uint256 maxSharesOut ) public payable virtual override returns (uint256 sharesOut) { require ((sharesOut = vault.withdraw(amount, to, msg.sender)) <= maxSharesOut, "!MaxShares"); } /// @inheritdoc IYearn4626RouterBase function redeem( IYearn4626 vault, uint256 shares, address to, uint256 maxLoss ) public payable virtual override returns (uint256) { return vault.redeem(shares, to, msg.sender, maxLoss); } /// @inheritdoc IYearn4626RouterBase function redeemDefault( IYearn4626 vault, uint256 shares, address to, uint256 minAmountOut ) public payable virtual override returns (uint256 amountOut) { require ((amountOut = vault.redeem(shares, to, msg.sender)) >= minAmountOut, "!MinAmount"); } }
// SPDX-License-Identifier: GPL-2.0-or-later pragma solidity 0.8.18; import "./IYearn4626.sol"; import "./IYearnV2.sol"; /** @title ERC4626Router Interface @notice Extends the ERC4626RouterBase with specific flows to save gas */ interface IYearn4626Router { /*////////////////////////////////////////////////////////////// DEPOSIT //////////////////////////////////////////////////////////////*/ /** @notice deposit `amount` to an ERC4626 vault. @param vault The ERC4626 vault to deposit assets to. @param to The destination of ownership shares. @param amount The amount of assets to deposit to `vault`. @param minSharesOut The min amount of `vault` shares received by `to`. @return . the amount of shares received by `to`. @dev throws "!minShares" Error. */ function depositToVault( IYearn4626 vault, uint256 amount, address to, uint256 minSharesOut ) external payable returns (uint256); /*////////////////////////////////////////////////////////////// MIGRATION //////////////////////////////////////////////////////////////*/ /** @notice will redeem `shares` from one vault and deposit amountOut to a different ERC4626 vault. @param fromVault The ERC4626 vault to redeem shares from. @param toVault The ERC4626 vault to deposit assets to. @param shares The amount of shares to redeem from fromVault. @param to The destination of ownership shares. @param minSharesOut The min amount of toVault shares received by `to`. @return . the amount of shares received by `to`. @dev throws "!minAmount", "!minShares" Errors. */ function migrate( IYearn4626 fromVault, IYearn4626 toVault, uint256 shares, address to, uint256 minSharesOut ) external payable returns (uint256); /*////////////////////////////////////////////////////////////// V2 MIGRATION //////////////////////////////////////////////////////////////*/ /** @notice migrate from Yearn V2 vault to a V3 vault'. @param fromVault The Yearn V2 vault to withdraw from. @param toVault The Yearn V3 vault to deposit assets to. @param shares The amount of V2 shares to redeem form 'fromVault'. @param to The destination of ownership shares @param minSharesOut The min amount of 'toVault' shares to be received by 'to'. @return . The actual amount of 'toVault' shares received by 'to'. @dev throws "!minAmount", "!minShares" Errors. */ function migrateFromV2( IYearnV2 fromVault, IYearn4626 toVault, uint256 shares, address to, uint256 minSharesOut ) external payable returns (uint256); }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import {IEIP712} from "./IEIP712.sol"; /// @title AllowanceTransfer /// @notice Handles ERC20 token permissions through signature based allowance setting and ERC20 token transfers by checking allowed amounts /// @dev Requires user's token approval on the Permit2 contract interface IAllowanceTransfer is IEIP712 { /// @notice Thrown when an allowance on a token has expired. /// @param deadline The timestamp at which the allowed amount is no longer valid error AllowanceExpired(uint256 deadline); /// @notice Thrown when an allowance on a token has been depleted. /// @param amount The maximum amount allowed error InsufficientAllowance(uint256 amount); /// @notice Thrown when too many nonces are invalidated. error ExcessiveInvalidation(); /// @notice Emits an event when the owner successfully invalidates an ordered nonce. event NonceInvalidation( address indexed owner, address indexed token, address indexed spender, uint48 newNonce, uint48 oldNonce ); /// @notice Emits an event when the owner successfully sets permissions on a token for the spender. event Approval( address indexed owner, address indexed token, address indexed spender, uint160 amount, uint48 expiration ); /// @notice Emits an event when the owner successfully sets permissions using a permit signature on a token for the spender. event Permit( address indexed owner, address indexed token, address indexed spender, uint160 amount, uint48 expiration, uint48 nonce ); /// @notice Emits an event when the owner sets the allowance back to 0 with the lockdown function. event Lockdown(address indexed owner, address token, address spender); /// @notice The permit data for a token struct PermitDetails { // ERC20 token address address token; // the maximum amount allowed to spend uint160 amount; // timestamp at which a spender's token allowances become invalid uint48 expiration; // an incrementing value indexed per owner,token,and spender for each signature uint48 nonce; } /// @notice The permit message signed for a single token allowance struct PermitSingle { // the permit data for a single token alownce PermitDetails details; // address permissioned on the allowed tokens address spender; // deadline on the permit signature uint256 sigDeadline; } /// @notice The permit message signed for multiple token allowances struct PermitBatch { // the permit data for multiple token allowances PermitDetails[] details; // address permissioned on the allowed tokens address spender; // deadline on the permit signature uint256 sigDeadline; } /// @notice The saved permissions /// @dev This info is saved per owner, per token, per spender and all signed over in the permit message /// @dev Setting amount to type(uint160).max sets an unlimited approval struct PackedAllowance { // amount allowed uint160 amount; // permission expiry uint48 expiration; // an incrementing value indexed per owner,token,and spender for each signature uint48 nonce; } /// @notice A token spender pair. struct TokenSpenderPair { // the token the spender is approved address token; // the spender address address spender; } /// @notice Details for a token transfer. struct AllowanceTransferDetails { // the owner of the token address from; // the recipient of the token address to; // the amount of the token uint160 amount; // the token to be transferred address token; } /// @notice A mapping from owner address to token address to spender address to PackedAllowance struct, which contains details and conditions of the approval. /// @notice The mapping is indexed in the above order see: allowance[ownerAddress][tokenAddress][spenderAddress] /// @dev The packed slot holds the allowed amount, expiration at which the allowed amount is no longer valid, and current nonce thats updated on any signature based approvals. function allowance(address user, address token, address spender) external view returns (uint160 amount, uint48 expiration, uint48 nonce); /// @notice Approves the spender to use up to amount of the specified token up until the expiration /// @param token The token to approve /// @param spender The spender address to approve /// @param amount The approved amount of the token /// @param expiration The timestamp at which the approval is no longer valid /// @dev The packed allowance also holds a nonce, which will stay unchanged in approve /// @dev Setting amount to type(uint160).max sets an unlimited approval function approve(address token, address spender, uint160 amount, uint48 expiration) external; /// @notice Permit a spender to a given amount of the owners token via the owner's EIP-712 signature /// @dev May fail if the owner's nonce was invalidated in-flight by invalidateNonce /// @param owner The owner of the tokens being approved /// @param permitSingle Data signed over by the owner specifying the terms of approval /// @param signature The owner's signature over the permit data function permit(address owner, PermitSingle memory permitSingle, bytes calldata signature) external; /// @notice Permit a spender to the signed amounts of the owners tokens via the owner's EIP-712 signature /// @dev May fail if the owner's nonce was invalidated in-flight by invalidateNonce /// @param owner The owner of the tokens being approved /// @param permitBatch Data signed over by the owner specifying the terms of approval /// @param signature The owner's signature over the permit data function permit(address owner, PermitBatch memory permitBatch, bytes calldata signature) external; /// @notice Transfer approved tokens from one address to another /// @param from The address to transfer from /// @param to The address of the recipient /// @param amount The amount of the token to transfer /// @param token The token address to transfer /// @dev Requires the from address to have approved at least the desired amount /// of tokens to msg.sender. function transferFrom(address from, address to, uint160 amount, address token) external; /// @notice Transfer approved tokens in a batch /// @param transferDetails Array of owners, recipients, amounts, and tokens for the transfers /// @dev Requires the from addresses to have approved at least the desired amount /// of tokens to msg.sender. function transferFrom(AllowanceTransferDetails[] calldata transferDetails) external; /// @notice Enables performing a "lockdown" of the sender's Permit2 identity /// by batch revoking approvals /// @param approvals Array of approvals to revoke. function lockdown(TokenSpenderPair[] calldata approvals) external; /// @notice Invalidate nonces for a given (token, spender) pair /// @param token The token to invalidate nonces for /// @param spender The spender to invalidate nonces for /// @param newNonce The new nonce to set. Invalidates all nonces less than it. /// @dev Can't invalidate more than 2**16 nonces per transaction. function invalidateNonces(address token, address spender, uint48 newNonce) external; }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; interface IEIP712 { function DOMAIN_SEPARATOR() external view returns (bytes32); }
// SPDX-License-Identifier: AGPL-3.0-only pragma solidity >=0.8.0; import {ERC20} from "../tokens/ERC20.sol"; /// @notice Safe ETH and ERC20 transfer library that gracefully handles missing return values. /// @author Solmate (https://github.com/transmissions11/solmate/blob/main/src/utils/SafeTransferLib.sol) /// @dev Use with caution! Some functions in this library knowingly create dirty bits at the destination of the free memory pointer. /// @dev Note that none of the functions in this library check that a token has code at all! That responsibility is delegated to the caller. library SafeTransferLib { /*////////////////////////////////////////////////////////////// ETH OPERATIONS //////////////////////////////////////////////////////////////*/ function safeTransferETH(address to, uint256 amount) internal { bool success; /// @solidity memory-safe-assembly assembly { // Transfer the ETH and store if it succeeded or not. success := call(gas(), to, amount, 0, 0, 0, 0) } require(success, "ETH_TRANSFER_FAILED"); } /*////////////////////////////////////////////////////////////// ERC20 OPERATIONS //////////////////////////////////////////////////////////////*/ function safeTransferFrom( ERC20 token, address from, address to, uint256 amount ) internal { bool success; /// @solidity memory-safe-assembly assembly { // Get a pointer to some free memory. let freeMemoryPointer := mload(0x40) // Write the abi-encoded calldata into memory, beginning with the function selector. mstore(freeMemoryPointer, 0x23b872dd00000000000000000000000000000000000000000000000000000000) mstore(add(freeMemoryPointer, 4), from) // Append the "from" argument. mstore(add(freeMemoryPointer, 36), to) // Append the "to" argument. mstore(add(freeMemoryPointer, 68), amount) // Append the "amount" argument. success := and( // Set success to whether the call reverted, if not we check it either // returned exactly 1 (can't just be non-zero data), or had no return data. or(and(eq(mload(0), 1), gt(returndatasize(), 31)), iszero(returndatasize())), // We use 100 because the length of our calldata totals up like so: 4 + 32 * 3. // We use 0 and 32 to copy up to 32 bytes of return data into the scratch space. // Counterintuitively, this call must be positioned second to the or() call in the // surrounding and() call or else returndatasize() will be zero during the computation. call(gas(), token, 0, freeMemoryPointer, 100, 0, 32) ) } require(success, "TRANSFER_FROM_FAILED"); } function safeTransfer( ERC20 token, address to, uint256 amount ) internal { bool success; /// @solidity memory-safe-assembly assembly { // Get a pointer to some free memory. let freeMemoryPointer := mload(0x40) // Write the abi-encoded calldata into memory, beginning with the function selector. mstore(freeMemoryPointer, 0xa9059cbb00000000000000000000000000000000000000000000000000000000) mstore(add(freeMemoryPointer, 4), to) // Append the "to" argument. mstore(add(freeMemoryPointer, 36), amount) // Append the "amount" argument. success := and( // Set success to whether the call reverted, if not we check it either // returned exactly 1 (can't just be non-zero data), or had no return data. or(and(eq(mload(0), 1), gt(returndatasize(), 31)), iszero(returndatasize())), // We use 68 because the length of our calldata totals up like so: 4 + 32 * 2. // We use 0 and 32 to copy up to 32 bytes of return data into the scratch space. // Counterintuitively, this call must be positioned second to the or() call in the // surrounding and() call or else returndatasize() will be zero during the computation. call(gas(), token, 0, freeMemoryPointer, 68, 0, 32) ) } require(success, "TRANSFER_FAILED"); } function safeApprove( ERC20 token, address to, uint256 amount ) internal { bool success; /// @solidity memory-safe-assembly assembly { // Get a pointer to some free memory. let freeMemoryPointer := mload(0x40) // Write the abi-encoded calldata into memory, beginning with the function selector. mstore(freeMemoryPointer, 0x095ea7b300000000000000000000000000000000000000000000000000000000) mstore(add(freeMemoryPointer, 4), to) // Append the "to" argument. mstore(add(freeMemoryPointer, 36), amount) // Append the "amount" argument. success := and( // Set success to whether the call reverted, if not we check it either // returned exactly 1 (can't just be non-zero data), or had no return data. or(and(eq(mload(0), 1), gt(returndatasize(), 31)), iszero(returndatasize())), // We use 68 because the length of our calldata totals up like so: 4 + 32 * 2. // We use 0 and 32 to copy up to 32 bytes of return data into the scratch space. // Counterintuitively, this call must be positioned second to the or() call in the // surrounding and() call or else returndatasize() will be zero during the computation. call(gas(), token, 0, freeMemoryPointer, 68, 0, 32) ) } require(success, "APPROVE_FAILED"); } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.9.0) (token/ERC20/IERC20.sol) pragma solidity ^0.8.0; /** * @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 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 `to`. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transfer(address to, 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 `from` to `to` 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 from, address to, uint256 amount) external returns (bool); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.9.4) (token/ERC20/extensions/IERC20Permit.sol) pragma solidity ^0.8.0; /** * @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); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (token/ERC20/extensions/IERC20Metadata.sol) 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); }
// SPDX-License-Identifier: GPL-2.0-or-later pragma solidity 0.8.18; import "./IYearn4626.sol"; /** @title ERC4626Router Base Interface @notice A canonical router between ERC4626 Vaults https://eips.ethereum.org/EIPS/eip-4626 The base router is a multicall style router inspired by Uniswap v3 with built-in features for permit, WETH9 wrap/unwrap, and ERC20 token pulling/sweeping/approving. It includes methods for the four mutable ERC4626 functions deposit/mint/withdraw/redeem as well. These can all be arbitrarily composed using the multicall functionality of the router. NOTE the router is capable of pulling any approved token from your wallet. This is only possible when your address is msg.sender, but regardless be careful when interacting with the router or ERC4626 Vaults. The router makes no special considerations for unique ERC20 implementations such as fee on transfer. There are no built in protections for unexpected behavior beyond enforcing the minSharesOut is received. */ interface IYearn4626RouterBase { /*////////////////////////////////////////////////////////////// MINT //////////////////////////////////////////////////////////////*/ /** @notice mint `shares` from an ERC4626 vault. @param vault The ERC4626 vault to mint shares from. @param shares The amount of shares to mint from `vault`. @param to The destination of ownership shares. @param maxAmountIn The max amount of assets used to mint. @return amountIn the amount of assets used to mint by `to`. @dev throws "!maxAmount" Error */ function mint( IYearn4626 vault, uint256 shares, address to, uint256 maxAmountIn ) external payable returns (uint256 amountIn); /*////////////////////////////////////////////////////////////// DEPOSIT //////////////////////////////////////////////////////////////*/ /** @notice deposit `amount` to an ERC4626 vault. @param vault The ERC4626 vault to deposit assets to. @param amount The amount of assets to deposit to `vault`. @param to The destination of ownership shares. @param minSharesOut The min amount of `vault` shares received by `to`. @return sharesOut the amount of shares received by `to`. @dev throws "!minShares" Error */ function deposit( IYearn4626 vault, uint256 amount, address to, uint256 minSharesOut ) external payable returns (uint256 sharesOut); /*////////////////////////////////////////////////////////////// WITHDRAW //////////////////////////////////////////////////////////////*/ /** @notice withdraw `amount` from an ERC4626 vault. @dev Uses the Yearn specific 'maxLoss' accounting. @param vault The ERC4626 vault to redeem shares from. @param vault The ERC4626 vault to withdraw assets from. @param amount The amount of assets to withdraw from vault. @param to The destination of assets. @param maxLoss The acceptable loss in Basis Points. @return sharesOut the amount of shares received by `to`. @dev throws "to much loss" Error */ function withdraw( IYearn4626 vault, uint256 amount, address to, uint256 maxLoss ) external payable returns (uint256); /** @notice withdraw `amount` from an ERC4626 vault. @dev Uses the default 4626 syntax, throws !maxShares" Error. @param vault The ERC4626 vault to withdraw assets from. @param amount The amount of assets to withdraw from vault. @param to The destination of assets. @param minSharesOut The min amount of shares received by `to`. @return sharesOut the amount of shares received by `to`. */ function withdrawDefault( IYearn4626 vault, uint256 amount, address to, uint256 minSharesOut ) external payable returns (uint256 sharesOut); /*////////////////////////////////////////////////////////////// REDEEM //////////////////////////////////////////////////////////////*/ /** @notice redeem `shares` shares from an ERC4626 vault. @dev Uses the Yearn specific 'maxLoss' accounting. @param vault The ERC4626 vault to redeem shares from. @param shares The amount of shares to redeem from vault. @param to The destination of assets. @param maxLoss The acceptable loss in Basis Points. @return amountOut the amount of assets received by `to`. @dev throws "to much loss" Error */ function redeem( IYearn4626 vault, uint256 shares, address to, uint256 maxLoss ) external payable returns (uint256); /** @notice redeem `shares` shares from an ERC4626 vault. @dev Uses the default 4626 syntax, throws "!minAmount" Error. @param vault The ERC4626 vault to redeem shares from. @param shares The amount of shares to redeem from vault. @param to The destination of assets. @param minAmountOut The min amount of assets received by `to`. @return amountOut the amount of assets received by `to`. */ function redeemDefault( IYearn4626 vault, uint256 shares, address to, uint256 minAmountOut ) external payable returns (uint256 amountOut); }
// SPDX-License-Identifier: AGPL-3.0-only pragma solidity >=0.8.0; /// @notice Modern and gas efficient ERC20 + EIP-2612 implementation. /// @author Solmate (https://github.com/transmissions11/solmate/blob/main/src/tokens/ERC20.sol) /// @author Modified from Uniswap (https://github.com/Uniswap/uniswap-v2-core/blob/master/contracts/UniswapV2ERC20.sol) /// @dev Do not manually set balances without updating totalSupply, as the sum of all user balances must not exceed it. abstract contract ERC20 { /*////////////////////////////////////////////////////////////// EVENTS //////////////////////////////////////////////////////////////*/ event Transfer(address indexed from, address indexed to, uint256 amount); event Approval(address indexed owner, address indexed spender, uint256 amount); /*////////////////////////////////////////////////////////////// METADATA STORAGE //////////////////////////////////////////////////////////////*/ string public name; string public symbol; uint8 public immutable decimals; /*////////////////////////////////////////////////////////////// ERC20 STORAGE //////////////////////////////////////////////////////////////*/ uint256 public totalSupply; mapping(address => uint256) public balanceOf; mapping(address => mapping(address => uint256)) public allowance; /*////////////////////////////////////////////////////////////// EIP-2612 STORAGE //////////////////////////////////////////////////////////////*/ uint256 internal immutable INITIAL_CHAIN_ID; bytes32 internal immutable INITIAL_DOMAIN_SEPARATOR; mapping(address => uint256) public nonces; /*////////////////////////////////////////////////////////////// CONSTRUCTOR //////////////////////////////////////////////////////////////*/ constructor( string memory _name, string memory _symbol, uint8 _decimals ) { name = _name; symbol = _symbol; decimals = _decimals; INITIAL_CHAIN_ID = block.chainid; INITIAL_DOMAIN_SEPARATOR = computeDomainSeparator(); } /*////////////////////////////////////////////////////////////// ERC20 LOGIC //////////////////////////////////////////////////////////////*/ function approve(address spender, uint256 amount) public virtual returns (bool) { allowance[msg.sender][spender] = amount; emit Approval(msg.sender, spender, amount); return true; } function transfer(address to, uint256 amount) public virtual returns (bool) { balanceOf[msg.sender] -= amount; // Cannot overflow because the sum of all user // balances can't exceed the max uint256 value. unchecked { balanceOf[to] += amount; } emit Transfer(msg.sender, to, amount); return true; } function transferFrom( address from, address to, uint256 amount ) public virtual returns (bool) { uint256 allowed = allowance[from][msg.sender]; // Saves gas for limited approvals. if (allowed != type(uint256).max) allowance[from][msg.sender] = allowed - amount; balanceOf[from] -= amount; // Cannot overflow because the sum of all user // balances can't exceed the max uint256 value. unchecked { balanceOf[to] += amount; } emit Transfer(from, to, amount); return true; } /*////////////////////////////////////////////////////////////// EIP-2612 LOGIC //////////////////////////////////////////////////////////////*/ function permit( address owner, address spender, uint256 value, uint256 deadline, uint8 v, bytes32 r, bytes32 s ) public virtual { require(deadline >= block.timestamp, "PERMIT_DEADLINE_EXPIRED"); // Unchecked because the only math done is incrementing // the owner's nonce which cannot realistically overflow. unchecked { address recoveredAddress = ecrecover( keccak256( abi.encodePacked( "\x19\x01", DOMAIN_SEPARATOR(), keccak256( abi.encode( keccak256( "Permit(address owner,address spender,uint256 value,uint256 nonce,uint256 deadline)" ), owner, spender, value, nonces[owner]++, deadline ) ) ) ), v, r, s ); require(recoveredAddress != address(0) && recoveredAddress == owner, "INVALID_SIGNER"); allowance[recoveredAddress][spender] = value; } emit Approval(owner, spender, value); } function DOMAIN_SEPARATOR() public view virtual returns (bytes32) { return block.chainid == INITIAL_CHAIN_ID ? INITIAL_DOMAIN_SEPARATOR : computeDomainSeparator(); } function computeDomainSeparator() internal view virtual returns (bytes32) { return keccak256( abi.encode( keccak256("EIP712Domain(string name,string version,uint256 chainId,address verifyingContract)"), keccak256(bytes(name)), keccak256("1"), block.chainid, address(this) ) ); } /*////////////////////////////////////////////////////////////// INTERNAL MINT/BURN LOGIC //////////////////////////////////////////////////////////////*/ function _mint(address to, uint256 amount) internal virtual { totalSupply += amount; // Cannot overflow because the sum of all user // balances can't exceed the max uint256 value. unchecked { balanceOf[to] += amount; } emit Transfer(address(0), to, amount); } function _burn(address from, uint256 amount) internal virtual { balanceOf[from] -= amount; // Cannot underflow because a user's balance // will never be larger than the total supply. unchecked { totalSupply -= amount; } emit Transfer(from, address(0), amount); } }
// SPDX-License-Identifier: GPL-2.0-or-later pragma solidity >=0.5.0; import {ERC20} from "solmate/tokens/ERC20.sol"; import "./interfaces/ISelfPermit.sol"; import "./interfaces/IERC20PermitAllowed.sol"; /// @title Self Permit /// @notice Functionality to call permit on any EIP-2612-compliant token for use in the route /// @dev These functions are expected to be embedded in multicalls to allow EOAs to approve a contract and call a function /// that requires an approval in a single transaction. abstract contract SelfPermit is ISelfPermit { /// @inheritdoc ISelfPermit function selfPermit( address token, uint256 value, uint256 deadline, uint8 v, bytes32 r, bytes32 s ) public payable override { ERC20(token).permit(msg.sender, address(this), value, deadline, v, r, s); } /// @inheritdoc ISelfPermit function selfPermitIfNecessary( address token, uint256 value, uint256 deadline, uint8 v, bytes32 r, bytes32 s ) external payable override { if (ERC20(token).allowance(msg.sender, address(this)) < value) selfPermit(token, value, deadline, v, r, s); } /// @inheritdoc ISelfPermit function selfPermitAllowed( address token, uint256 nonce, uint256 expiry, uint8 v, bytes32 r, bytes32 s ) public payable override { IERC20PermitAllowed(token).permit(msg.sender, address(this), nonce, expiry, true, v, r, s); } /// @inheritdoc ISelfPermit function selfPermitAllowedIfNecessary( address token, uint256 nonce, uint256 expiry, uint8 v, bytes32 r, bytes32 s ) external payable override { if (ERC20(token).allowance(msg.sender, address(this)) < type(uint256).max) selfPermitAllowed(token, nonce, expiry, v, r, s); } }
// forked from https://github.com/Uniswap/v3-periphery/blob/main/contracts/base/Multicall.sol // SPDX-License-Identifier: GPL-2.0-or-later pragma solidity >=0.7.6; import "./interfaces/IMulticall.sol"; /// @title Multicall /// @notice Enables calling multiple methods in a single call to the contract abstract contract Multicall is IMulticall { /// @inheritdoc IMulticall function multicall(bytes[] calldata data) public payable override returns (bytes[] memory results) { results = new bytes[](data.length); for (uint256 i = 0; i < data.length; i++) { (bool success, bytes memory result) = address(this).delegatecall(data[i]); if (!success) { // Next 5 lines from https://ethereum.stackexchange.com/a/83577 if (result.length < 68) revert(); assembly { result := add(result, 0x04) } revert(abi.decode(result, (string))); } results[i] = result; } } }
// SPDX-License-Identifier: GPL-2.0-or-later pragma solidity 0.8.18; import {IERC4626} from "./IERC4626.sol"; /// @title Yearn V3 ERC4626 interface /// @notice Extends the normal 4626 standard with some added Yearn specific functionality abstract contract IYearn4626 is IERC4626 { /*//////////////////////////////////////////////////////// Yearn Specific Functions ////////////////////////////////////////////////////////*/ function withdraw( uint256 assets, address receiver, address owner, uint256 maxLoss ) external virtual returns (uint256 shares); /// @notice Yearn Specific "withdraw" with withdrawal stack included function withdraw( uint256 assets, address receiver, address owner, uint256 maxLoss, address[] memory strategies ) external virtual returns (uint256 shares); function redeem( uint256 shares, address receiver, address owner, uint256 maxLoss ) external virtual returns (uint256 assets); /// @notice Yearn Specific "redeem" with withdrawal stack included function redeem( uint256 shares, address receiver, address owner, uint256 maxLoss, address[] memory strategies ) external virtual returns (uint256 assets); }
// SPDX-License-Identifier: GPL-2.0-or-later pragma solidity 0.8.18; import {ERC20} from "solmate/tokens/ERC20.sol"; abstract contract IYearnV2 is ERC20 { // NOTE: Vyper produces multiple signatures for a given function with "default" args function withdraw() external virtual returns (uint256); function withdraw(uint256 maxShares) external virtual returns (uint256); function withdraw(uint256 maxShares, address recipient) external virtual returns (uint256); function withdraw( uint256 maxShares, address recipient, uint256 maxLoss ) external virtual returns (uint256); }
// forked from https://github.com/Uniswap/v3-periphery/blob/main/contracts/interfaces/ISelfPermit.sol // SPDX-License-Identifier: GPL-2.0-or-later pragma solidity >=0.7.5; /// @title Self Permit /// @notice Functionality to call permit on any EIP-2612-compliant token for use in the route interface ISelfPermit { /// @notice Permits this contract to spend a given token from `msg.sender` /// @dev The `owner` is always msg.sender and the `spender` is always address(this). /// @param token The address of the token spent /// @param value The amount that can be spent of token /// @param deadline A timestamp, the current blocktime must be less than or equal to this timestamp /// @param v Must produce valid secp256k1 signature from the holder along with `r` and `s` /// @param r Must produce valid secp256k1 signature from the holder along with `v` and `s` /// @param s Must produce valid secp256k1 signature from the holder along with `r` and `v` function selfPermit( address token, uint256 value, uint256 deadline, uint8 v, bytes32 r, bytes32 s ) external payable; /// @notice Permits this contract to spend a given token from `msg.sender` /// @dev The `owner` is always msg.sender and the `spender` is always address(this). /// Can be used instead of #selfPermit to prevent calls from failing due to a frontrun of a call to #selfPermit /// @param token The address of the token spent /// @param value The amount that can be spent of token /// @param deadline A timestamp, the current blocktime must be less than or equal to this timestamp /// @param v Must produce valid secp256k1 signature from the holder along with `r` and `s` /// @param r Must produce valid secp256k1 signature from the holder along with `v` and `s` /// @param s Must produce valid secp256k1 signature from the holder along with `r` and `v` function selfPermitIfNecessary( address token, uint256 value, uint256 deadline, uint8 v, bytes32 r, bytes32 s ) external payable; /// @notice Permits this contract to spend the sender's tokens for permit signatures that have the `allowed` parameter /// @dev The `owner` is always msg.sender and the `spender` is always address(this) /// @param token The address of the token spent /// @param nonce The current nonce of the owner /// @param expiry The timestamp at which the permit is no longer valid /// @param v Must produce valid secp256k1 signature from the holder along with `r` and `s` /// @param r Must produce valid secp256k1 signature from the holder along with `v` and `s` /// @param s Must produce valid secp256k1 signature from the holder along with `r` and `v` function selfPermitAllowed( address token, uint256 nonce, uint256 expiry, uint8 v, bytes32 r, bytes32 s ) external payable; /// @notice Permits this contract to spend the sender's tokens for permit signatures that have the `allowed` parameter /// @dev The `owner` is always msg.sender and the `spender` is always address(this) /// Can be used instead of #selfPermitAllowed to prevent calls from failing due to a frontrun of a call to #selfPermitAllowed. /// @param token The address of the token spent /// @param nonce The current nonce of the owner /// @param expiry The timestamp at which the permit is no longer valid /// @param v Must produce valid secp256k1 signature from the holder along with `r` and `s` /// @param r Must produce valid secp256k1 signature from the holder along with `v` and `s` /// @param s Must produce valid secp256k1 signature from the holder along with `r` and `v` function selfPermitAllowedIfNecessary( address token, uint256 nonce, uint256 expiry, uint8 v, bytes32 r, bytes32 s ) external payable; }
// forked from https://github.com/Uniswap/v3-periphery/blob/main/contracts/interfaces/external/IERC20PermitAllowed.sol // SPDX-License-Identifier: GPL-2.0-or-later pragma solidity >=0.5.0; /// @title Interface for permit /// @notice Interface used by DAI/CHAI for permit interface IERC20PermitAllowed { /// @notice Approve the spender to spend some tokens via the holder signature /// @dev This is the permit interface used by DAI and CHAI /// @param holder The address of the token holder, the token owner /// @param spender The address of the token spender /// @param nonce The holder's nonce, increases at each call to permit /// @param expiry The timestamp at which the permit is no longer valid /// @param allowed Boolean that sets approval amount, true for type(uint256).max and false for 0 /// @param v Must produce valid secp256k1 signature from the holder along with `r` and `s` /// @param r Must produce valid secp256k1 signature from the holder along with `v` and `s` /// @param s Must produce valid secp256k1 signature from the holder along with `r` and `v` function permit( address holder, address spender, uint256 nonce, uint256 expiry, bool allowed, uint8 v, bytes32 r, bytes32 s ) external; }
// forked from https://github.com/Uniswap/v3-periphery/blob/main/contracts/interfaces/IMulticall.sol // SPDX-License-Identifier: GPL-2.0-or-later pragma solidity >=0.7.5; /// @title Multicall interface /// @notice Enables calling multiple methods in a single call to the contract interface IMulticall { /// @notice Call multiple functions in the current contract and return the data from all of them if they all succeed /// @dev The `msg.value` should not be trusted for any method callable from multicall. /// @param data The encoded function data for each of the calls to make to this contract /// @return results The results from each of the calls passed in via data function multicall(bytes[] calldata data) external payable returns (bytes[] memory results); }
// SPDX-License-Identifier: GPL-2.0-or-later pragma solidity 0.8.18; import {ERC20} from "solmate/tokens/ERC20.sol"; /// @title ERC4626 interface /// See: https://eips.ethereum.org/EIPS/eip-4626 abstract contract IERC4626 is ERC20 { /*//////////////////////////////////////////////////////// Events ////////////////////////////////////////////////////////*/ /// @notice `sender` has exchanged `assets` for `shares`, /// and transferred those `shares` to `receiver`. event Deposit(address indexed sender, address indexed receiver, uint256 assets, uint256 shares); /// @notice `sender` has exchanged `shares` for `assets`, /// and transferred those `assets` to `receiver`. event Withdraw(address indexed sender, address indexed receiver, uint256 assets, uint256 shares); /*//////////////////////////////////////////////////////// Vault properties ////////////////////////////////////////////////////////*/ /// @notice The address of the underlying ERC20 token used for /// the Vault for accounting, depositing, and withdrawing. function asset() external view virtual returns (address asset); /// @notice Total amount of the underlying asset that /// is "managed" by Vault. function totalAssets() external view virtual returns (uint256 totalAssets); /*//////////////////////////////////////////////////////// Deposit/Withdrawal Logic ////////////////////////////////////////////////////////*/ /// @notice Mints `shares` Vault shares to `receiver` by /// depositing exactly `assets` of underlying tokens. function deposit(uint256 assets, address receiver) external virtual returns (uint256 shares); /// @notice Mints exactly `shares` Vault shares to `receiver` /// by depositing `assets` of underlying tokens. function mint(uint256 shares, address receiver) external virtual returns (uint256 assets); /// @notice Redeems `shares` from `owner` and sends `assets` /// of underlying tokens to `receiver`. function withdraw( uint256 assets, address receiver, address owner ) external virtual returns (uint256 shares); /// @notice Redeems `shares` from `owner` and sends `assets` /// of underlying tokens to `receiver`. function redeem( uint256 shares, address receiver, address owner ) external virtual returns (uint256 assets); /*//////////////////////////////////////////////////////// Vault Accounting Logic ////////////////////////////////////////////////////////*/ /// @notice 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. function convertToShares(uint256 assets) external view virtual returns (uint256 shares); /// @notice 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 virtual returns (uint256 assets); /// @notice Total number of underlying assets that can /// be deposited by `owner` into the Vault, where `owner` /// corresponds to the input parameter `receiver` of a /// `deposit` call. function maxDeposit(address owner) external view virtual returns (uint256 maxAssets); /// @notice Allows an on-chain or off-chain user to simulate /// the effects of their deposit at the current block, given /// current on-chain conditions. function previewDeposit(uint256 assets) external view virtual returns (uint256 shares); /// @notice Total number of underlying shares that can be minted /// for `owner`, where `owner` corresponds to the input /// parameter `receiver` of a `mint` call. function maxMint(address owner) external view virtual returns (uint256 maxShares); /// @notice Allows an on-chain or off-chain user to simulate /// the effects of their mint at the current block, given /// current on-chain conditions. function previewMint(uint256 shares) external view virtual returns (uint256 assets); /// @notice Total number of underlying assets that can be /// withdrawn from the Vault by `owner`, where `owner` /// corresponds to the input parameter of a `withdraw` call. function maxWithdraw(address owner) external view virtual returns (uint256 maxAssets); /// @notice Allows an on-chain or off-chain user to simulate /// the effects of their withdrawal at the current block, /// given current on-chain conditions. function previewWithdraw(uint256 assets) external view virtual returns (uint256 shares); /// @notice Total number of underlying shares that can be /// redeemed from the Vault by `owner`, where `owner` corresponds /// to the input parameter of a `redeem` call. function maxRedeem(address owner) external view virtual returns (uint256 maxShares); /// @notice Allows an on-chain or off-chain user to simulate /// the effects of their redeemption at the current block, /// given current on-chain conditions. function previewRedeem(uint256 shares) external view virtual returns (uint256 assets); }
{ "remappings": [ "@openzeppelin/=lib/openzeppelin-contracts/", "@openzeppelin-upgradeable/=lib/openzeppelin-contracts-upgradeable/", "tokenized-strategy/=lib/tokenized-strategy/src/", "yearn-vaults-v3/=lib/yearn-vaults-v3/contracts/", "Yearn-ERC4626-Router/=lib/Yearn-ERC4626-Router/src/", "solmate/=lib/permit2/lib/solmate/src/", "permit2/=lib/permit2/src/", "forge-std/=lib/forge-std/src/", "ds-test/=lib/forge-std/lib/ds-test/src/", "@crytic/properties/=lib/properties/", "forge-deploy/=lib/forge-deploy/contracts/", "script/=script/", "src/=src/", "test/=test/" ], "optimizer": { "enabled": true, "runs": 200 }, "metadata": { "useLiteralContent": false, "bytecodeHash": "ipfs", "appendCBOR": true }, "outputSelection": { "*": { "*": [ "evm.bytecode", "evm.deployedBytecode", "devdoc", "userdoc", "metadata", "abi" ] } }, "evmVersion": "paris", "viaIR": false, "libraries": {} }
Contract Security Audit
- No Contract Security Audit Submitted- Submit Audit Here
[{"inputs":[{"internalType":"string","name":"name_","type":"string"},{"internalType":"address","name":"weth_","type":"address"},{"internalType":"address","name":"permit2_","type":"address"}],"stateMutability":"payable","type":"constructor"},{"inputs":[],"name":"InsufficientAssets","type":"error"},{"inputs":[],"name":"InsufficientShares","type":"error"},{"inputs":[],"name":"InvalidPathLength","type":"error"},{"inputs":[],"name":"InvalidPermit2TransferAmount","type":"error"},{"inputs":[],"name":"InvalidPermit2TransferTo","type":"error"},{"inputs":[{"internalType":"address","name":"invalidVault","type":"address"}],"name":"PreviewNonVaultAddressInPath","type":"error"},{"inputs":[],"name":"PreviewPathIsTooShort","type":"error"},{"inputs":[],"name":"PreviewVaultMismatch","type":"error"},{"inputs":[],"name":"RequiresMoreThanMaxShares","type":"error"},{"inputs":[],"name":"WETH9","outputs":[{"internalType":"contract IWETH9","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"contract ERC20","name":"token","type":"address"},{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"approve","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"contract IYearn4626","name":"vault","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"},{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"minSharesOut","type":"uint256"}],"name":"deposit","outputs":[{"internalType":"uint256","name":"sharesOut","type":"uint256"}],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"contract IYearn4626","name":"vault","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"},{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"minSharesOut","type":"uint256"}],"name":"depositToVault","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"contract IYearn4626","name":"vault","type":"address"},{"internalType":"uint256","name":"minSharesOut","type":"uint256"}],"name":"depositToVault","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"contract IYearn4626","name":"vault","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"},{"internalType":"uint256","name":"minSharesOut","type":"uint256"}],"name":"depositToVault","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"contract IYearn4626","name":"vault","type":"address"}],"name":"depositToVault","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"contract IYearn4626","name":"fromVault","type":"address"},{"internalType":"contract IYearn4626","name":"toVault","type":"address"}],"name":"migrate","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"contract IYearn4626","name":"fromVault","type":"address"},{"internalType":"contract IYearn4626","name":"toVault","type":"address"},{"internalType":"uint256","name":"shares","type":"uint256"},{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"minSharesOut","type":"uint256"}],"name":"migrate","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"contract IYearn4626","name":"fromVault","type":"address"},{"internalType":"contract IYearn4626","name":"toVault","type":"address"},{"internalType":"uint256","name":"shares","type":"uint256"},{"internalType":"uint256","name":"minSharesOut","type":"uint256"}],"name":"migrate","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"contract IYearn4626","name":"fromVault","type":"address"},{"internalType":"contract IYearn4626","name":"toVault","type":"address"},{"internalType":"uint256","name":"minSharesOut","type":"uint256"}],"name":"migrate","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"contract IYearnV2","name":"fromVault","type":"address"},{"internalType":"contract IYearn4626","name":"toVault","type":"address"},{"internalType":"uint256","name":"shares","type":"uint256"},{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"minSharesOut","type":"uint256"}],"name":"migrateFromV2","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"contract IYearnV2","name":"fromVault","type":"address"},{"internalType":"contract IYearn4626","name":"toVault","type":"address"},{"internalType":"uint256","name":"shares","type":"uint256"},{"internalType":"uint256","name":"minSharesOut","type":"uint256"}],"name":"migrateFromV2","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"contract IYearnV2","name":"fromVault","type":"address"},{"internalType":"contract IYearn4626","name":"toVault","type":"address"},{"internalType":"uint256","name":"minSharesOut","type":"uint256"}],"name":"migrateFromV2","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"contract IYearnV2","name":"fromVault","type":"address"},{"internalType":"contract IYearn4626","name":"toVault","type":"address"}],"name":"migrateFromV2","outputs":[{"internalType":"uint256","name":"sharesOut","type":"uint256"}],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"contract IYearn4626","name":"vault","type":"address"},{"internalType":"uint256","name":"shares","type":"uint256"},{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"maxAmountIn","type":"uint256"}],"name":"mint","outputs":[{"internalType":"uint256","name":"amountIn","type":"uint256"}],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"bytes[]","name":"data","type":"bytes[]"}],"name":"multicall","outputs":[{"internalType":"bytes[]","name":"results","type":"bytes[]"}],"stateMutability":"payable","type":"function"},{"inputs":[],"name":"name","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address[]","name":"path","type":"address[]"},{"internalType":"uint256","name":"assetsIn","type":"uint256"}],"name":"previewDeposits","outputs":[{"internalType":"uint256[]","name":"sharesOut","type":"uint256[]"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address[]","name":"path","type":"address[]"},{"internalType":"uint256","name":"sharesOut","type":"uint256"}],"name":"previewMints","outputs":[{"internalType":"uint256[]","name":"assetsIn","type":"uint256[]"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address[]","name":"path","type":"address[]"},{"internalType":"uint256","name":"sharesIn","type":"uint256"}],"name":"previewRedeems","outputs":[{"internalType":"uint256[]","name":"assetsOut","type":"uint256[]"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address[]","name":"path","type":"address[]"},{"internalType":"uint256","name":"assetsOut","type":"uint256"}],"name":"previewWithdraws","outputs":[{"internalType":"uint256[]","name":"sharesIn","type":"uint256[]"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"contract ERC20","name":"token","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"},{"internalType":"address","name":"recipient","type":"address"}],"name":"pullToken","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"components":[{"components":[{"internalType":"address","name":"token","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"internalType":"struct ISignatureTransfer.TokenPermissions","name":"permitted","type":"tuple"},{"internalType":"uint256","name":"nonce","type":"uint256"},{"internalType":"uint256","name":"deadline","type":"uint256"}],"internalType":"struct ISignatureTransfer.PermitTransferFrom","name":"permit","type":"tuple"},{"components":[{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"requestedAmount","type":"uint256"}],"internalType":"struct ISignatureTransfer.SignatureTransferDetails","name":"transferDetails","type":"tuple"},{"internalType":"bytes","name":"signature","type":"bytes"}],"name":"pullTokenWithPermit2","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"contract IYearn4626","name":"vault","type":"address"},{"internalType":"uint256","name":"maxLoss","type":"uint256"}],"name":"redeem","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"contract IYearn4626","name":"vault","type":"address"},{"internalType":"uint256","name":"shares","type":"uint256"},{"internalType":"uint256","name":"maxLoss","type":"uint256"}],"name":"redeem","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"contract IYearn4626","name":"vault","type":"address"}],"name":"redeem","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"contract IYearn4626","name":"vault","type":"address"},{"internalType":"uint256","name":"shares","type":"uint256"},{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"maxLoss","type":"uint256"}],"name":"redeem","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"contract IYearn4626","name":"vault","type":"address"},{"internalType":"uint256","name":"shares","type":"uint256"},{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"minAmountOut","type":"uint256"}],"name":"redeemDefault","outputs":[{"internalType":"uint256","name":"amountOut","type":"uint256"}],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"contract IERC4626","name":"vault","type":"address"},{"internalType":"uint256","name":"shares","type":"uint256"},{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"minAmountOut","type":"uint256"}],"name":"redeemFromRouter","outputs":[{"internalType":"uint256","name":"amountOut","type":"uint256"}],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"contract IStakeDaoGauge","name":"gauge","type":"address"},{"internalType":"uint256","name":"shares","type":"uint256"},{"internalType":"address","name":"to","type":"address"}],"name":"redeemStakeDaoGauge","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"contract IYearnVaultV2","name":"vault","type":"address"},{"internalType":"uint256","name":"shares","type":"uint256"},{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"minAssetsOut","type":"uint256"}],"name":"redeemVaultV2","outputs":[{"internalType":"uint256","name":"amountOut","type":"uint256"}],"stateMutability":"payable","type":"function"},{"inputs":[],"name":"refundETH","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"address","name":"token","type":"address"},{"internalType":"uint256","name":"value","type":"uint256"},{"internalType":"uint256","name":"deadline","type":"uint256"},{"internalType":"uint8","name":"v","type":"uint8"},{"internalType":"bytes32","name":"r","type":"bytes32"},{"internalType":"bytes32","name":"s","type":"bytes32"}],"name":"selfPermit","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"address","name":"token","type":"address"},{"internalType":"uint256","name":"nonce","type":"uint256"},{"internalType":"uint256","name":"expiry","type":"uint256"},{"internalType":"uint8","name":"v","type":"uint8"},{"internalType":"bytes32","name":"r","type":"bytes32"},{"internalType":"bytes32","name":"s","type":"bytes32"}],"name":"selfPermitAllowed","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"address","name":"token","type":"address"},{"internalType":"uint256","name":"nonce","type":"uint256"},{"internalType":"uint256","name":"expiry","type":"uint256"},{"internalType":"uint8","name":"v","type":"uint8"},{"internalType":"bytes32","name":"r","type":"bytes32"},{"internalType":"bytes32","name":"s","type":"bytes32"}],"name":"selfPermitAllowedIfNecessary","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"address","name":"token","type":"address"},{"internalType":"uint256","name":"value","type":"uint256"},{"internalType":"uint256","name":"deadline","type":"uint256"},{"internalType":"uint8","name":"v","type":"uint8"},{"internalType":"bytes32","name":"r","type":"bytes32"},{"internalType":"bytes32","name":"s","type":"bytes32"}],"name":"selfPermitIfNecessary","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"address[]","name":"path","type":"address[]"},{"internalType":"uint256","name":"assetsIn","type":"uint256"},{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"minSharesOut","type":"uint256"}],"name":"serializedDeposits","outputs":[{"internalType":"uint256","name":"sharesOut","type":"uint256"}],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"address[]","name":"path","type":"address[]"},{"internalType":"bool[]","name":"isYearnVaultV2","type":"bool[]"},{"internalType":"uint256","name":"sharesIn","type":"uint256"},{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"minAssetsOut","type":"uint256"}],"name":"serializedRedeems","outputs":[{"internalType":"uint256","name":"assetsOut","type":"uint256"}],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"contract ERC20","name":"token","type":"address"},{"internalType":"uint256","name":"amountMinimum","type":"uint256"},{"internalType":"address","name":"recipient","type":"address"}],"name":"sweepToken","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"uint256","name":"amountMinimum","type":"uint256"},{"internalType":"address","name":"recipient","type":"address"}],"name":"unwrapWETH9","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"contract IYearn4626","name":"vault","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"},{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"maxLoss","type":"uint256"}],"name":"withdraw","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"contract IYearn4626","name":"vault","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"},{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"maxSharesOut","type":"uint256"}],"name":"withdrawDefault","outputs":[{"internalType":"uint256","name":"sharesOut","type":"uint256"}],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"contract IERC4626","name":"vault","type":"address"},{"internalType":"uint256","name":"assets","type":"uint256"},{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"maxSharesIn","type":"uint256"}],"name":"withdrawFromRouter","outputs":[{"internalType":"uint256","name":"sharesOut","type":"uint256"}],"stateMutability":"payable","type":"function"},{"inputs":[],"name":"wrapWETH9","outputs":[],"stateMutability":"payable","type":"function"},{"stateMutability":"payable","type":"receive"}]
Contract Creation Code
60e0604052604051620043a3380380620043a38339810160408190526200002691620000d7565b6001600160a01b038216608052604051839083906200004a908390602001620001b6565b6040516020818303038152906040526200006490620001d4565b60a05250506001600160a01b031660c05250620001fc9050565b634e487b7160e01b600052604160045260246000fd5b60005b83811015620000b157818101518382015260200162000097565b50506000910152565b80516001600160a01b0381168114620000d257600080fd5b919050565b600080600060608486031215620000ed57600080fd5b83516001600160401b03808211156200010557600080fd5b818601915086601f8301126200011a57600080fd5b8151818111156200012f576200012f6200007e565b604051601f8201601f19908116603f011681019083821181831017156200015a576200015a6200007e565b816040528281528960208487010111156200017457600080fd5b6200018783602083016020880162000094565b80975050505050506200019d60208501620000ba565b9150620001ad60408501620000ba565b90509250925092565b60008251620001ca81846020870162000094565b9190910192915050565b80516020808301519190811015620001f6576000198160200360031b1b821691505b50919050565b60805160a05160c051614162620002416000396000612af30152600061029801526000818161044001528181611032015281816113b8015261148e01526141626000f3fe6080604052600436106102765760003560e01c80636f63427e1161014f578063ac9650d8116100c1578063e1f21c671161007a578063e1f21c671461063d578063ed328ab814610650578063efc7a86114610663578063f16565ee14610676578063f3995c6714610689578063f3f094a11461069c57600080fd5b8063ac9650d8146105b1578063c28916f6146105d1578063c2e3140a146105e4578063c61fb8e9146105f7578063dbae029214610617578063df2ab5bb1461062a57600080fd5b8063979c8b8d11610113578063979c8b8d146105325780639b4f09af14610552578063a3d1115814610565578063a3ebe71714610578578063a4a78f0c1461058b578063a79721fe1461059e57600080fd5b80636f63427e146104c657806373d15414146104d957806390d25074146104ec57806391d58968146104ff57806395a2251f1461051f57600080fd5b80633f50fd1f116101e85780634a250330116101ac5780634a2503301461041b5780634aa4a4fc1461042e5780634b2084e31461047a5780635b9a66ee1461048d5780635e8919f7146104a05780635ff8e874146104b357600080fd5b80633f50fd1f146103c75780634292551b146103cf578063431679b7146103e25780634659a494146103f557806349404b7c1461040857600080fd5b80632b83cccd1161023a5780632b83cccd146103555780632eef500d1461036857806330b3484f1461037b57806335052d6e1461038e5780633c173a4f146103a15780633dff6639146103b457600080fd5b806306fdde03146102825780631068361f146102ea57806312210e8a1461030b5780631e9a69501461031557806323f9f02f1461032857600080fd5b3661027d57005b600080fd5b34801561028e57600080fd5b506102d4604080517f0000000000000000000000000000000000000000000000000000000000000000602082015260609101604051602081830303815290604052905090565b6040516102e19190613814565b60405180910390f35b6102fd6102f836600461383f565b6106af565b6040519081526020016102e1565b610313610736565b005b6102fd610323366004613878565b610748565b34801561033457600080fd5b506103486103433660046138ef565b6107c3565b6040516102e1919061393a565b6102fd61036336600461397e565b610b2e565b6102fd6103763660046139b3565b610b46565b6102fd6103893660046139b3565b610be6565b6102fd61039c3660046139fb565b610c69565b6102fd6103af3660046139b3565b610e6e565b6102fd6103c2366004613a91565b610f24565b61031361102a565b6102fd6103dd366004613aec565b6110a6565b6102fd6103f0366004613b52565b6111b9565b610313610403366004613b94565b61130b565b610313610416366004613bf6565b6113a0565b6102fd610429366004613a91565b61150b565b34801561043a57600080fd5b506104627f000000000000000000000000000000000000000000000000000000000000000081565b6040516001600160a01b0390911681526020016102e1565b6102fd6104883660046139b3565b61151c565b6102fd61049b3660046139b3565b6115a1565b6102fd6104ae3660046139b3565b611655565b6102fd6104c13660046139b3565b6116ed565b6102fd6104d43660046139b3565b611725565b6103136104e7366004613b52565b6117d9565b6102fd6104fa3660046139b3565b6117ee565b34801561050b57600080fd5b5061034861051a3660046138ef565b6118a4565b6102fd61052d366004613c1b565b611d17565b34801561053e57600080fd5b5061034861054d3660046138ef565b611d93565b6102fd610560366004613c38565b6121ed565b6102fd610573366004613878565b6121fc565b6102fd610586366004613c7e565b6122d9565b610313610599366004613b94565b612355565b6102fd6105ac366004613c38565b6123e3565b6105c46105bf366004613cbf565b6123f2565b6040516102e19190613d00565b6102fd6105df36600461397e565b612549565b6103136105f2366004613b94565b612557565b34801561060357600080fd5b506103486106123660046138ef565b6125db565b6102fd61062536600461383f565b61291c565b610313610638366004613b52565b612999565b61031361064b366004613c7e565b612a6b565b61031361065e366004613d62565b612a7f565b6102fd610671366004613c1b565b612b68565b6102fd610684366004613c7e565b612cd1565b610313610697366004613b94565b612d4d565b6102fd6106aa3660046139b3565b612da4565b6040516370a0823160e01b815233600482015260009081906001600160a01b038516906370a0823190602401602060405180830381865afa1580156106f8573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061071c9190613e01565b905061072c84848333600061150b565b9150505b92915050565b4715610746576107463347612dea565b565b6040516370a0823160e01b815233600482015260009081906001600160a01b038516906370a0823190602401602060405180830381865afa158015610791573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906107b59190613e01565b905061072c84823386612da4565b606060028310156107e75760405163cbeb538160e01b815260040160405180910390fd5b60006107f4600185613e30565b9050806001600160401b0381111561080e5761080e613e43565b604051908082528060200260200182016040528015610837578160200160208202803683370190505b50915060005b81811015610b255760008686610854846001613e59565b81811061086357610863613e6c565b90506020020160208101906108789190613c1b565b90506001600160a01b0381163b6108b257604051633da8b79760e11b81526001600160a01b03821660048201526024015b60405180910390fd5b60408051600481526024810182526020810180516001600160e01b03166338d52e0f60e01b1790529051600091829182916001600160a01b038616916108f89190613e82565b600060405180830381855afa9150503d8060008114610933576040519150601f19603f3d011682016040523d82523d6000602084013e610938565b606091505b509150915081156109e757808060200190518101906109579190613e9e565b60405163ef8b30f760e01b8152600481018a90529093506001600160a01b0385169063ef8b30f790602401602060405180830381865afa15801561099f573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906109c39190613e01565b8786815181106109d5576109d5613e6c565b60200260200101818152509750610abe565b60408051600481526024810182526020810180516001600160e01b0316637e062a3560e11b17905290516001600160a01b03861691610a2591613e82565b600060405180830381855afa9150503d8060008114610a60576040519150601f19603f3d011682016040523d82523d6000602084013e610a65565b606091505b5090925090508115610a9a5780806020019051810190610a859190613e9e565b92506109c36001600160a01b03851689612e3b565b604051633da8b79760e11b81526001600160a01b03851660048201526024016108a9565b898986818110610ad057610ad0613e6c565b9050602002016020810190610ae59190613c1b565b6001600160a01b0316836001600160a01b031614610b16576040516364d4d57b60e11b815260040160405180910390fd5b8460010194505050505061083d565b50509392505050565b6000610b3c84843385612da4565b90505b9392505050565b600081856001600160a01b031663ba0876528686306040518463ffffffff1660e01b8152600401610b7993929190613ebb565b6020604051808303816000875af1158015610b98573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610bbc9190613e01565b9150811015610bde576040516396d8043360e01b815260040160405180910390fd5b949350505050565b6000610c54856001600160a01b03166338d52e0f6040518163ffffffff1660e01b8152600401602060405180830381865afa158015610c29573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610c4d9190613e9e565b85306117d9565b610c60858585856117ee565b95945050505050565b600086808203610c8c576040516366b045ff60e11b815260040160405180910390fd5b808614610cac576040516366b045ff60e11b815260040160405180910390fd5b600019810160005b82811015610e3f5730828203610cc75750855b898983818110610cd957610cd9613e6c565b9050602002016020810190610cee9190613ee8565b15610d97578b8b83818110610d0557610d05613e6c565b9050602002016020810190610d1a9190613c1b565b604051627b8a6760e11b8152600481018a90526001600160a01b038381166024830152919091169062f714ce906044016020604051808303816000875af1158015610d69573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610d8d9190613e01565b9450849750610e36565b8b8b83818110610da957610da9613e6c565b9050602002016020810190610dbe9190613c1b565b6001600160a01b031663ba0876528983306040518463ffffffff1660e01b8152600401610ded93929190613ebb565b6020604051808303816000875af1158015610e0c573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610e309190613e01565b94508497505b50600101610cb4565b5083831015610e61576040516396d8043360e01b815260040160405180910390fd5b5050979650505050505050565b6040516394bf804d60e01b8152600481018490526001600160a01b03838116602483015260009183918716906394bf804d906044016020604051808303816000875af1158015610ec2573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610ee69190613e01565b9150811115610bde5760405162461bcd60e51b815260206004820152600a6024820152690853585e105b5bdd5b9d60b21b60448201526064016108a9565b6040516323b872dd60e01b8152336004820152306024820152604481018490526000906001600160a01b038716906323b872dd906064016020604051808303816000875af1158015610f7a573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610f9e9190613f05565b50604051627b8a6760e11b8152600481018590523060248201526000906001600160a01b0388169062f714ce906044016020604051808303816000875af1158015610fed573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906110119190613e01565b905061101f868286866117ee565b979650505050505050565b4715610746577f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031663d0e30db0476040518263ffffffff1660e01b81526004016000604051808303818588803b15801561108b57600080fd5b505af115801561109f573d6000803e3d6000fd5b5050505050565b60008481036110c8576040516366b045ff60e11b815260040160405180910390fd5b600019850160005b8681101561118d57308282036110e35750845b8888838181106110f5576110f5613e6c565b905060200201602081019061110a9190613c1b565b604051636e553f6560e01b8152600481018990526001600160a01b0383811660248301529190911690636e553f65906044016020604051808303816000875af115801561115b573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061117f9190613e01565b9650869350506001016110d0565b50828210156111af57604051633999656760e01b815260040160405180910390fd5b5095945050505050565b600080846001600160a01b0316632dc7d74c6040518163ffffffff1660e01b8152600401602060405180830381865afa1580156111fa573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061121e9190613e9e565b604051632e1a7d4d60e01b8152600481018690529091506001600160a01b03821690632e1a7d4d90602401600060405180830381600087803b15801561126357600080fd5b505af1158015611277573d6000803e3d6000fd5b505050506001600160a01b0383163014611302576113028385836001600160a01b031663fc0c546a6040518163ffffffff1660e01b8152600401602060405180830381865afa1580156112ce573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906112f29190613e9e565b6001600160a01b03169190612ecd565b50919392505050565b6040516323f2ebc360e21b815233600482015230602482015260448101869052606481018590526001608482015260ff841660a482015260c4810183905260e481018290526001600160a01b03871690638fcbaf0c90610104015b600060405180830381600087803b15801561138057600080fd5b505af1158015611394573d6000803e3d6000fd5b50505050505050505050565b6040516370a0823160e01b81523060048201526000907f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316906370a0823190602401602060405180830381865afa158015611407573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061142b9190613e01565b9050828110156114725760405162461bcd60e51b8152602060048201526012602482015271496e73756666696369656e7420574554483960701b60448201526064016108a9565b801561150657604051632e1a7d4d60e01b8152600481018290527f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031690632e1a7d4d90602401600060405180830381600087803b1580156114da57600080fd5b505af11580156114ee573d6000803e3d6000fd5b50611506925050506001600160a01b03831682612dea565b505050565b600080611011878630612710612da4565b6040516328c6306960e21b8152600481018490526001600160a01b038381166024830152336044830152606482018390526000919086169063a318c1a4906084015b6020604051808303816000875af115801561157d573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610c609190613e01565b600081856001600160a01b031663ba0876528686336040518463ffffffff1660e01b81526004016115d493929190613ebb565b6020604051808303816000875af11580156115f3573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906116179190613e01565b9150811015610bde5760405162461bcd60e51b815260206004820152600a60248201526908535a5b905b5bdd5b9d60b21b60448201526064016108a9565b600081856001600160a01b031663b460af948686306040518463ffffffff1660e01b815260040161168893929190613ebb565b6020604051808303816000875af11580156116a7573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906116cb9190613e01565b9150811115610bde5760405163bfdb5fcb60e01b815260040160405180910390fd5b604051627b8a6760e11b8152600481018490526001600160a01b038381166024830152600091839187169062f714ce90604401610b79565b600081856001600160a01b031663b460af948686336040518463ffffffff1660e01b815260040161175893929190613ebb565b6020604051808303816000875af1158015611777573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061179b9190613e01565b9150811115610bde5760405162461bcd60e51b815260206004820152600a602482015269214d617853686172657360b01b60448201526064016108a9565b6115066001600160a01b038416338385612f1f565b604051636e553f6560e01b8152600481018490526001600160a01b0383811660248301526000918391871690636e553f65906044016020604051808303816000875af1158015611842573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906118669190613e01565b9150811015610bde5760405162461bcd60e51b815260206004820152600a602482015269214d696e53686172657360b01b60448201526064016108a9565b606060028310156118c85760405163cbeb538160e01b815260040160405180910390fd5b60006118d5600185613e30565b9050806001600160401b038111156118ef576118ef613e43565b604051908082528060200260200182016040528015611918578160200160208202803683370190505b5091506000611928600286613e30565b90505b600086868381811061193f5761193f613e6c565b90506020020160208101906119549190613c1b565b90506001600160a01b0381163b61198957604051633da8b79760e11b81526001600160a01b03821660048201526024016108a9565b60408051600481526024810182526020810180516001600160e01b03166338d52e0f60e01b1790529051600091829182916001600160a01b038616916119cf9190613e82565b600060405180830381855afa9150503d8060008114611a0a576040519150601f19603f3d011682016040523d82523d6000602084013e611a0f565b606091505b50915091508115611abe5780806020019051810190611a2e9190613e9e565b604051630a28a47760e01b8152600481018a90529093506001600160a01b03851690630a28a47790602401602060405180830381865afa158015611a76573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611a9a9190613e01565b878681518110611aac57611aac613e6c565b60200260200101818152509750611c92565b60408051600481526024810182526020810180516001600160e01b0316637e062a3560e11b17905290516001600160a01b03861691611afc91613e82565b600060405180830381855afa9150503d8060008114611b37576040519150601f19603f3d011682016040523d82523d6000602084013e611b3c565b606091505b5090925090508115611b715780806020019051810190611b5c9190613e9e565b9250611a9a6001600160a01b03851689612fa2565b60408051600481526024810182526020810180516001600160e01b0316630b71f5d360e21b17905290516001600160a01b03861691611baf91613e82565b600060405180830381855afa9150503d8060008114611bea576040519150601f19603f3d011682016040523d82523d6000602084013e611bef565b606091505b5090925090508115610a9a5780806020019051810190611c0f9190613e9e565b6001600160a01b031663fc0c546a6040518163ffffffff1660e01b8152600401602060405180830381865afa158015611c4c573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611c709190613e9e565b925087878681518110611c8557611c85613e6c565b6020026020010181815250505b8989611c9f876001613e59565b818110611cae57611cae613e6c565b9050602002016020810190611cc39190613c1b565b6001600160a01b0316836001600160a01b031614611cf4576040516364d4d57b60e11b815260040160405180910390fd5b84600003611d0757505050505050610b3f565b846001900394505050505061192b565b6040516370a0823160e01b815233600482015260009081906001600160a01b038416906370a0823190602401602060405180830381865afa158015611d60573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611d849190613e01565b9050610b3f8382336001612da4565b60606002831015611db75760405163cbeb538160e01b815260040160405180910390fd5b6000611dc4600185613e30565b9050806001600160401b03811115611dde57611dde613e43565b604051908082528060200260200182016040528015611e07578160200160208202803683370190505b50915060005b81811015610b25576000868683818110611e2957611e29613e6c565b9050602002016020810190611e3e9190613c1b565b90506001600160a01b0381163b611e7357604051633da8b79760e11b81526001600160a01b03821660048201526024016108a9565b60408051600481526024810182526020810180516001600160e01b03166338d52e0f60e01b1790529051600091829182916001600160a01b03861691611eb99190613e82565b600060405180830381855afa9150503d8060008114611ef4576040519150601f19603f3d011682016040523d82523d6000602084013e611ef9565b606091505b50915091508115611fa85780806020019051810190611f189190613e9e565b60405163266d6a8360e11b8152600481018a90529093506001600160a01b03851690634cdad50690602401602060405180830381865afa158015611f60573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611f849190613e01565b878681518110611f9657611f96613e6c565b6020026020010181815250975061217c565b60408051600481526024810182526020810180516001600160e01b0316637e062a3560e11b17905290516001600160a01b03861691611fe691613e82565b600060405180830381855afa9150503d8060008114612021576040519150601f19603f3d011682016040523d82523d6000602084013e612026565b606091505b509092509050811561205b57808060200190518101906120469190613e9e565b9250611f846001600160a01b038516896130a0565b60408051600481526024810182526020810180516001600160e01b0316630b71f5d360e21b17905290516001600160a01b0386169161209991613e82565b600060405180830381855afa9150503d80600081146120d4576040519150601f19603f3d011682016040523d82523d6000602084013e6120d9565b606091505b5090925090508115610a9a57808060200190518101906120f99190613e9e565b6001600160a01b031663fc0c546a6040518163ffffffff1660e01b8152600401602060405180830381865afa158015612136573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061215a9190613e9e565b92508787868151811061216f5761216f613e6c565b6020026020010181815250505b8989612189876001613e59565b81811061219857612198613e6c565b90506020020160208101906121ad9190613c1b565b6001600160a01b0316836001600160a01b0316146121de576040516364d4d57b60e11b815260040160405180910390fd5b84600101945050505050611e0d565b6000610c608585853386610f24565b600080836001600160a01b03166338d52e0f6040518163ffffffff1660e01b8152600401602060405180830381865afa15801561223d573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906122619190613e9e565b6040516370a0823160e01b81523360048201526001600160a01b0391909116906370a0823190602401602060405180830381865afa1580156122a7573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906122cb9190613e01565b905061072c84823386610be6565b6040516370a0823160e01b815233600482015260009081906001600160a01b038616906370a0823190602401602060405180830381865afa158015612322573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906123469190613e01565b9050610c608585833387610f24565b604051636eb1769f60e11b8152336004820152306024820152600019906001600160a01b0388169063dd62ed3e90604401602060405180830381865afa1580156123a3573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906123c79190613e01565b10156123db576123db86868686868661130b565b505050505050565b6000610c60858585338661150b565b6060816001600160401b0381111561240c5761240c613e43565b60405190808252806020026020018201604052801561243f57816020015b606081526020019060019003908161242a5790505b50905060005b82811015612542576000803086868581811061246357612463613e6c565b90506020028101906124759190613f22565b604051612483929190613f68565b600060405180830381855af49150503d80600081146124be576040519150601f19603f3d011682016040523d82523d6000602084013e6124c3565b606091505b50915091508161250f576044815110156124dc57600080fd5b600481019050808060200190518101906124f69190613f78565b60405162461bcd60e51b81526004016108a99190613814565b8084848151811061252257612522613e6c565b60200260200101819052505050808061253a90614019565b915050612445565b5092915050565b6000610b3c84843385610be6565b604051636eb1769f60e11b815233600482015230602482015285906001600160a01b0388169063dd62ed3e90604401602060405180830381865afa1580156125a3573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906125c79190613e01565b10156123db576123db868686868686612d4d565b606060028310156125ff5760405163cbeb538160e01b815260040160405180910390fd5b600061260c600185613e30565b9050806001600160401b0381111561262657612626613e43565b60405190808252806020026020018201604052801561264f578160200160208202803683370190505b509150805b8015610b2557600086868381811061266e5761266e613e6c565b90506020020160208101906126839190613c1b565b90506001600160a01b0381163b6126b857604051633da8b79760e11b81526001600160a01b03821660048201526024016108a9565b60408051600481526024810182526020810180516001600160e01b03166338d52e0f60e01b1790529051600091829182916001600160a01b038616916126fe9190613e82565b600060405180830381855afa9150503d8060008114612739576040519150601f19603f3d011682016040523d82523d6000602084013e61273e565b606091505b509150915081156127f7578080602001905181019061275d9190613e9e565b60405163b3d7f6b960e01b8152600481018a90529093506001600160a01b0385169063b3d7f6b990602401602060405180830381865afa1580156127a5573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906127c99190613e01565b876127d5600188613e30565b815181106127e5576127e5613e6c565b602002602001018181525097506128aa565b60408051600481526024810182526020810180516001600160e01b0316637e062a3560e11b17905290516001600160a01b0386169161283591613e82565b600060405180830381855afa9150503d8060008114612870576040519150601f19603f3d011682016040523d82523d6000602084013e612875565b606091505b5090925090508115610a9a57808060200190518101906128959190613e9e565b92506127c96001600160a01b03851689613133565b89896128b7600188613e30565b8181106128c6576128c6613e6c565b90506020020160208101906128db9190613c1b565b6001600160a01b0316836001600160a01b03161461290c576040516364d4d57b60e11b815260040160405180910390fd5b8460019003945050505050612654565b6040516370a0823160e01b815233600482015260009081906001600160a01b038516906370a0823190602401602060405180830381865afa158015612965573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906129899190613e01565b905061072c848483336000610f24565b6040516370a0823160e01b81523060048201526000906001600160a01b038516906370a0823190602401602060405180830381865afa1580156129e0573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612a049190613e01565b905082811015612a4b5760405162461bcd60e51b815260206004820152601260248201527124b739bab33334b1b4b2b73a103a37b5b2b760711b60448201526064016108a9565b8015612a6557612a656001600160a01b03851683836131b5565b50505050565b6115066001600160a01b038416838361322d565b30612a8d6020850185613c1b565b6001600160a01b031614612ab4576040516368b02d7960e01b815260040160405180910390fd5b6020848101359084013514612adc57604051630726615360e41b815260040160405180910390fd5b60405163187945bd60e11b81526001600160a01b037f000000000000000000000000000000000000000000000000000000000000000016906330f28b7a90612b309087908790339088908890600401614053565b600060405180830381600087803b158015612b4a57600080fd5b505af1158015612b5e573d6000803e3d6000fd5b5050505050505050565b600080826001600160a01b03166338d52e0f6040518163ffffffff1660e01b8152600401602060405180830381865afa158015612ba9573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612bcd9190613e9e565b6040516370a0823160e01b81523360048201526001600160a01b0391909116906370a0823190602401602060405180830381865afa158015612c13573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612c379190613e01565b90506000612710846001600160a01b031663ef8b30f7846040518263ffffffff1660e01b8152600401612c6c91815260200190565b602060405180830381865afa158015612c89573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612cad9190613e01565b612cb99061270f6140c7565b612cc391906140f4565b9050610bde84833384610be6565b6040516370a0823160e01b815233600482015260009081906001600160a01b038616906370a0823190602401602060405180830381865afa158015612d1a573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612d3e9190613e01565b9050610c60858583338761150b565b60405163d505accf60e01b8152336004820152306024820152604481018690526064810185905260ff8416608482015260a4810183905260c481018290526001600160a01b0387169063d505accf9060e401611366565b604051639f40a7b360e01b8152600481018490526001600160a01b0383811660248301523360448301526064820183905260009190861690639f40a7b39060840161155e565b600080600080600085875af19050806115065760405162461bcd60e51b815260206004820152601360248201527211551217d514905394d1915497d19052531151606a1b60448201526064016108a9565b600080836001600160a01b03166318160ddd6040518163ffffffff1660e01b8152600401602060405180830381865afa158015612e7c573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612ea09190613e01565b90508015612ec557612ebd8382612eb6876132a4565b6000613497565b915050610730565b509092915050565b604080516001600160a01b038416602482015260448082018490528251808303909101815260649091019091526020810180516001600160e01b031663a9059cbb60e01b1790526115069084906134f2565b60006040516323b872dd60e01b81528460048201528360248201528260448201526020600060648360008a5af13d15601f3d116001600051141617169150508061109f5760405162461bcd60e51b81526020600482015260146024820152731514905394d1915497d19493d357d1905253115160621b60448201526064016108a9565b600080612fae846132a4565b90508083111561301a57836001600160a01b03166318160ddd6040518163ffffffff1660e01b8152600401602060405180830381865afa158015612ff6573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612ebd9190613e01565b801561309657612ebd83856001600160a01b03166318160ddd6040518163ffffffff1660e01b8152600401602060405180830381865afa158015613062573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906130869190613e01565b61308f876132a4565b6001613497565b5060009392505050565b600080836001600160a01b03166318160ddd6040518163ffffffff1660e01b8152600401602060405180830381865afa1580156130e1573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906131059190613e01565b90508083111561311857612ebd846132a4565b801561309657612ebd8361312b866132a4565b836000613497565b600080836001600160a01b03166318160ddd6040518163ffffffff1660e01b8152600401602060405180830381865afa158015613174573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906131989190613e01565b90508015612ec557612ebd836131ad866132a4565b836001613497565b600060405163a9059cbb60e01b8152836004820152826024820152602060006044836000895af13d15601f3d1160016000511416171691505080612a655760405162461bcd60e51b815260206004820152600f60248201526e1514905394d1915497d19052531151608a1b60448201526064016108a9565b600060405163095ea7b360e01b8152836004820152826024820152602060006044836000895af13d15601f3d1160016000511416171691505080612a655760405162461bcd60e51b815260206004820152600e60248201526d1054141493d59157d1905253115160921b60448201526064016108a9565b600080826001600160a01b03166344b813966040518163ffffffff1660e01b8152600401602060405180830381865afa1580156132e5573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906133099190613e01565b90506000836001600160a01b031663422327166040518163ffffffff1660e01b8152600401602060405180830381865afa15801561334b573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061336f9190613e01565b846001600160a01b031663c3535b526040518163ffffffff1660e01b8152600401602060405180830381865afa1580156133ad573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906133d19190613e01565b6133db9042613e30565b6133e591906140c7565b9050670de0b6b3a764000081101561342557670de0b6b3a764000061340a82846140c7565b61341491906140f4565b61341e9083613e30565b915061342a565b600091505b81846001600160a01b03166301e1d1146040518163ffffffff1660e01b8152600401602060405180830381865afa158015613469573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061348d9190613e01565b610bde9190613e30565b6000806134a58686866135c7565b905060018360028111156134bb576134bb614116565b1480156134d85750600084806134d3576134d36140de565b868809115b15610c60576134e8600182613e59565b9695505050505050565b6000613547826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b03166136b19092919063ffffffff16565b90508051600014806135685750808060200190518101906135689190613f05565b6115065760405162461bcd60e51b815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e6044820152691bdd081cdd58d8d9595960b21b60648201526084016108a9565b6000808060001985870985870292508281108382030391505080600003613601578382816135f7576135f76140de565b0492505050610b3f565b8084116136485760405162461bcd60e51b81526020600482015260156024820152744d6174683a206d756c446976206f766572666c6f7760581b60448201526064016108a9565b60008486880960026001871981018816978890046003810283188082028403028082028403028082028403028082028403028082028403029081029092039091026000889003889004909101858311909403939093029303949094049190911702949350505050565b6060610b3c848460008585600080866001600160a01b031685876040516136d89190613e82565b60006040518083038185875af1925050503d8060008114613715576040519150601f19603f3d011682016040523d82523d6000602084013e61371a565b606091505b509150915061101f878383876060831561379557825160000361378e576001600160a01b0385163b61378e5760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e747261637400000060448201526064016108a9565b5081610bde565b610bde83838151156137aa5781518083602001fd5b8060405162461bcd60e51b81526004016108a99190613814565b60005b838110156137df5781810151838201526020016137c7565b50506000910152565b600081518084526138008160208601602086016137c4565b601f01601f19169290920160200192915050565b602081526000610b3f60208301846137e8565b6001600160a01b038116811461383c57600080fd5b50565b6000806040838503121561385257600080fd5b823561385d81613827565b9150602083013561386d81613827565b809150509250929050565b6000806040838503121561388b57600080fd5b823561389681613827565b946020939093013593505050565b60008083601f8401126138b657600080fd5b5081356001600160401b038111156138cd57600080fd5b6020830191508360208260051b85010111156138e857600080fd5b9250929050565b60008060006040848603121561390457600080fd5b83356001600160401b0381111561391a57600080fd5b613926868287016138a4565b909790965060209590950135949350505050565b6020808252825182820181905260009190848201906040850190845b8181101561397257835183529284019291840191600101613956565b50909695505050505050565b60008060006060848603121561399357600080fd5b833561399e81613827565b95602085013595506040909401359392505050565b600080600080608085870312156139c957600080fd5b84356139d481613827565b93506020850135925060408501356139eb81613827565b9396929550929360600135925050565b600080600080600080600060a0888a031215613a1657600080fd5b87356001600160401b0380821115613a2d57600080fd5b613a398b838c016138a4565b909950975060208a0135915080821115613a5257600080fd5b50613a5f8a828b016138a4565b909650945050604088013592506060880135613a7a81613827565b809250506080880135905092959891949750929550565b600080600080600060a08688031215613aa957600080fd5b8535613ab481613827565b94506020860135613ac481613827565b9350604086013592506060860135613adb81613827565b949793965091946080013592915050565b600080600080600060808688031215613b0457600080fd5b85356001600160401b03811115613b1a57600080fd5b613b26888289016138a4565b909650945050602086013592506040860135613b4181613827565b949793965091946060013592915050565b600080600060608486031215613b6757600080fd5b8335613b7281613827565b9250602084013591506040840135613b8981613827565b809150509250925092565b60008060008060008060c08789031215613bad57600080fd5b8635613bb881613827565b95506020870135945060408701359350606087013560ff81168114613bdc57600080fd5b9598949750929560808101359460a0909101359350915050565b60008060408385031215613c0957600080fd5b82359150602083013561386d81613827565b600060208284031215613c2d57600080fd5b8135610b3f81613827565b60008060008060808587031215613c4e57600080fd5b8435613c5981613827565b93506020850135613c6981613827565b93969395505050506040820135916060013590565b600080600060608486031215613c9357600080fd5b8335613c9e81613827565b92506020840135613cae81613827565b929592945050506040919091013590565b60008060208385031215613cd257600080fd5b82356001600160401b03811115613ce857600080fd5b613cf4858286016138a4565b90969095509350505050565b6000602080830181845280855180835260408601915060408160051b870101925083870160005b82811015613d5557603f19888603018452613d438583516137e8565b94509285019290850190600101613d27565b5092979650505050505050565b60008060008084860360e0811215613d7957600080fd5b6080811215613d8757600080fd5b8594506040607f1982011215613d9c57600080fd5b5060808501925060c08501356001600160401b0380821115613dbd57600080fd5b818701915087601f830112613dd157600080fd5b813581811115613de057600080fd5b886020828501011115613df257600080fd5b95989497505060200194505050565b600060208284031215613e1357600080fd5b5051919050565b634e487b7160e01b600052601160045260246000fd5b8181038181111561073057610730613e1a565b634e487b7160e01b600052604160045260246000fd5b8082018082111561073057610730613e1a565b634e487b7160e01b600052603260045260246000fd5b60008251613e948184602087016137c4565b9190910192915050565b600060208284031215613eb057600080fd5b8151610b3f81613827565b9283526001600160a01b03918216602084015216604082015260600190565b801515811461383c57600080fd5b600060208284031215613efa57600080fd5b8135610b3f81613eda565b600060208284031215613f1757600080fd5b8151610b3f81613eda565b6000808335601e19843603018112613f3957600080fd5b8301803591506001600160401b03821115613f5357600080fd5b6020019150368190038213156138e857600080fd5b8183823760009101908152919050565b600060208284031215613f8a57600080fd5b81516001600160401b0380821115613fa157600080fd5b818401915084601f830112613fb557600080fd5b815181811115613fc757613fc7613e43565b604051601f8201601f19908116603f01168101908382118183101715613fef57613fef613e43565b8160405282815287602084870101111561400857600080fd5b61101f8360208301602088016137c4565b60006001820161402b5761402b613e1a565b5060010190565b803561403d81613827565b6001600160a01b03168252602090810135910152565b60006101006140628389614032565b60408801356040840152606088013560608401526140836080840188614032565b6001600160a01b03861660c084015260e0830181905282018390526101208385828501376000838501820152601f909301601f191690910190910195945050505050565b808202811582820484141761073057610730613e1a565b634e487b7160e01b600052601260045260246000fd5b60008261411157634e487b7160e01b600052601260045260246000fd5b500490565b634e487b7160e01b600052602160045260246000fdfea26469706673582212205471a74404f2c722bb640ed728cade6c2ec1306a58ef18c606984e3fd80c79e164736f6c634300081200330000000000000000000000000000000000000000000000000000000000000060000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2000000000000000000000000000000000022d473030f116ddee9f6b43ac78ba30000000000000000000000000000000000000000000000000000000000000012596561726e34363236526f757465724578740000000000000000000000000000
Deployed Bytecode
0x6080604052600436106102765760003560e01c80636f63427e1161014f578063ac9650d8116100c1578063e1f21c671161007a578063e1f21c671461063d578063ed328ab814610650578063efc7a86114610663578063f16565ee14610676578063f3995c6714610689578063f3f094a11461069c57600080fd5b8063ac9650d8146105b1578063c28916f6146105d1578063c2e3140a146105e4578063c61fb8e9146105f7578063dbae029214610617578063df2ab5bb1461062a57600080fd5b8063979c8b8d11610113578063979c8b8d146105325780639b4f09af14610552578063a3d1115814610565578063a3ebe71714610578578063a4a78f0c1461058b578063a79721fe1461059e57600080fd5b80636f63427e146104c657806373d15414146104d957806390d25074146104ec57806391d58968146104ff57806395a2251f1461051f57600080fd5b80633f50fd1f116101e85780634a250330116101ac5780634a2503301461041b5780634aa4a4fc1461042e5780634b2084e31461047a5780635b9a66ee1461048d5780635e8919f7146104a05780635ff8e874146104b357600080fd5b80633f50fd1f146103c75780634292551b146103cf578063431679b7146103e25780634659a494146103f557806349404b7c1461040857600080fd5b80632b83cccd1161023a5780632b83cccd146103555780632eef500d1461036857806330b3484f1461037b57806335052d6e1461038e5780633c173a4f146103a15780633dff6639146103b457600080fd5b806306fdde03146102825780631068361f146102ea57806312210e8a1461030b5780631e9a69501461031557806323f9f02f1461032857600080fd5b3661027d57005b600080fd5b34801561028e57600080fd5b506102d4604080517f596561726e34363236526f757465724578740000000000000000000000000000602082015260609101604051602081830303815290604052905090565b6040516102e19190613814565b60405180910390f35b6102fd6102f836600461383f565b6106af565b6040519081526020016102e1565b610313610736565b005b6102fd610323366004613878565b610748565b34801561033457600080fd5b506103486103433660046138ef565b6107c3565b6040516102e1919061393a565b6102fd61036336600461397e565b610b2e565b6102fd6103763660046139b3565b610b46565b6102fd6103893660046139b3565b610be6565b6102fd61039c3660046139fb565b610c69565b6102fd6103af3660046139b3565b610e6e565b6102fd6103c2366004613a91565b610f24565b61031361102a565b6102fd6103dd366004613aec565b6110a6565b6102fd6103f0366004613b52565b6111b9565b610313610403366004613b94565b61130b565b610313610416366004613bf6565b6113a0565b6102fd610429366004613a91565b61150b565b34801561043a57600080fd5b506104627f000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc281565b6040516001600160a01b0390911681526020016102e1565b6102fd6104883660046139b3565b61151c565b6102fd61049b3660046139b3565b6115a1565b6102fd6104ae3660046139b3565b611655565b6102fd6104c13660046139b3565b6116ed565b6102fd6104d43660046139b3565b611725565b6103136104e7366004613b52565b6117d9565b6102fd6104fa3660046139b3565b6117ee565b34801561050b57600080fd5b5061034861051a3660046138ef565b6118a4565b6102fd61052d366004613c1b565b611d17565b34801561053e57600080fd5b5061034861054d3660046138ef565b611d93565b6102fd610560366004613c38565b6121ed565b6102fd610573366004613878565b6121fc565b6102fd610586366004613c7e565b6122d9565b610313610599366004613b94565b612355565b6102fd6105ac366004613c38565b6123e3565b6105c46105bf366004613cbf565b6123f2565b6040516102e19190613d00565b6102fd6105df36600461397e565b612549565b6103136105f2366004613b94565b612557565b34801561060357600080fd5b506103486106123660046138ef565b6125db565b6102fd61062536600461383f565b61291c565b610313610638366004613b52565b612999565b61031361064b366004613c7e565b612a6b565b61031361065e366004613d62565b612a7f565b6102fd610671366004613c1b565b612b68565b6102fd610684366004613c7e565b612cd1565b610313610697366004613b94565b612d4d565b6102fd6106aa3660046139b3565b612da4565b6040516370a0823160e01b815233600482015260009081906001600160a01b038516906370a0823190602401602060405180830381865afa1580156106f8573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061071c9190613e01565b905061072c84848333600061150b565b9150505b92915050565b4715610746576107463347612dea565b565b6040516370a0823160e01b815233600482015260009081906001600160a01b038516906370a0823190602401602060405180830381865afa158015610791573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906107b59190613e01565b905061072c84823386612da4565b606060028310156107e75760405163cbeb538160e01b815260040160405180910390fd5b60006107f4600185613e30565b9050806001600160401b0381111561080e5761080e613e43565b604051908082528060200260200182016040528015610837578160200160208202803683370190505b50915060005b81811015610b255760008686610854846001613e59565b81811061086357610863613e6c565b90506020020160208101906108789190613c1b565b90506001600160a01b0381163b6108b257604051633da8b79760e11b81526001600160a01b03821660048201526024015b60405180910390fd5b60408051600481526024810182526020810180516001600160e01b03166338d52e0f60e01b1790529051600091829182916001600160a01b038616916108f89190613e82565b600060405180830381855afa9150503d8060008114610933576040519150601f19603f3d011682016040523d82523d6000602084013e610938565b606091505b509150915081156109e757808060200190518101906109579190613e9e565b60405163ef8b30f760e01b8152600481018a90529093506001600160a01b0385169063ef8b30f790602401602060405180830381865afa15801561099f573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906109c39190613e01565b8786815181106109d5576109d5613e6c565b60200260200101818152509750610abe565b60408051600481526024810182526020810180516001600160e01b0316637e062a3560e11b17905290516001600160a01b03861691610a2591613e82565b600060405180830381855afa9150503d8060008114610a60576040519150601f19603f3d011682016040523d82523d6000602084013e610a65565b606091505b5090925090508115610a9a5780806020019051810190610a859190613e9e565b92506109c36001600160a01b03851689612e3b565b604051633da8b79760e11b81526001600160a01b03851660048201526024016108a9565b898986818110610ad057610ad0613e6c565b9050602002016020810190610ae59190613c1b565b6001600160a01b0316836001600160a01b031614610b16576040516364d4d57b60e11b815260040160405180910390fd5b8460010194505050505061083d565b50509392505050565b6000610b3c84843385612da4565b90505b9392505050565b600081856001600160a01b031663ba0876528686306040518463ffffffff1660e01b8152600401610b7993929190613ebb565b6020604051808303816000875af1158015610b98573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610bbc9190613e01565b9150811015610bde576040516396d8043360e01b815260040160405180910390fd5b949350505050565b6000610c54856001600160a01b03166338d52e0f6040518163ffffffff1660e01b8152600401602060405180830381865afa158015610c29573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610c4d9190613e9e565b85306117d9565b610c60858585856117ee565b95945050505050565b600086808203610c8c576040516366b045ff60e11b815260040160405180910390fd5b808614610cac576040516366b045ff60e11b815260040160405180910390fd5b600019810160005b82811015610e3f5730828203610cc75750855b898983818110610cd957610cd9613e6c565b9050602002016020810190610cee9190613ee8565b15610d97578b8b83818110610d0557610d05613e6c565b9050602002016020810190610d1a9190613c1b565b604051627b8a6760e11b8152600481018a90526001600160a01b038381166024830152919091169062f714ce906044016020604051808303816000875af1158015610d69573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610d8d9190613e01565b9450849750610e36565b8b8b83818110610da957610da9613e6c565b9050602002016020810190610dbe9190613c1b565b6001600160a01b031663ba0876528983306040518463ffffffff1660e01b8152600401610ded93929190613ebb565b6020604051808303816000875af1158015610e0c573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610e309190613e01565b94508497505b50600101610cb4565b5083831015610e61576040516396d8043360e01b815260040160405180910390fd5b5050979650505050505050565b6040516394bf804d60e01b8152600481018490526001600160a01b03838116602483015260009183918716906394bf804d906044016020604051808303816000875af1158015610ec2573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610ee69190613e01565b9150811115610bde5760405162461bcd60e51b815260206004820152600a6024820152690853585e105b5bdd5b9d60b21b60448201526064016108a9565b6040516323b872dd60e01b8152336004820152306024820152604481018490526000906001600160a01b038716906323b872dd906064016020604051808303816000875af1158015610f7a573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610f9e9190613f05565b50604051627b8a6760e11b8152600481018590523060248201526000906001600160a01b0388169062f714ce906044016020604051808303816000875af1158015610fed573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906110119190613e01565b905061101f868286866117ee565b979650505050505050565b4715610746577f000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc26001600160a01b031663d0e30db0476040518263ffffffff1660e01b81526004016000604051808303818588803b15801561108b57600080fd5b505af115801561109f573d6000803e3d6000fd5b5050505050565b60008481036110c8576040516366b045ff60e11b815260040160405180910390fd5b600019850160005b8681101561118d57308282036110e35750845b8888838181106110f5576110f5613e6c565b905060200201602081019061110a9190613c1b565b604051636e553f6560e01b8152600481018990526001600160a01b0383811660248301529190911690636e553f65906044016020604051808303816000875af115801561115b573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061117f9190613e01565b9650869350506001016110d0565b50828210156111af57604051633999656760e01b815260040160405180910390fd5b5095945050505050565b600080846001600160a01b0316632dc7d74c6040518163ffffffff1660e01b8152600401602060405180830381865afa1580156111fa573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061121e9190613e9e565b604051632e1a7d4d60e01b8152600481018690529091506001600160a01b03821690632e1a7d4d90602401600060405180830381600087803b15801561126357600080fd5b505af1158015611277573d6000803e3d6000fd5b505050506001600160a01b0383163014611302576113028385836001600160a01b031663fc0c546a6040518163ffffffff1660e01b8152600401602060405180830381865afa1580156112ce573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906112f29190613e9e565b6001600160a01b03169190612ecd565b50919392505050565b6040516323f2ebc360e21b815233600482015230602482015260448101869052606481018590526001608482015260ff841660a482015260c4810183905260e481018290526001600160a01b03871690638fcbaf0c90610104015b600060405180830381600087803b15801561138057600080fd5b505af1158015611394573d6000803e3d6000fd5b50505050505050505050565b6040516370a0823160e01b81523060048201526000907f000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc26001600160a01b0316906370a0823190602401602060405180830381865afa158015611407573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061142b9190613e01565b9050828110156114725760405162461bcd60e51b8152602060048201526012602482015271496e73756666696369656e7420574554483960701b60448201526064016108a9565b801561150657604051632e1a7d4d60e01b8152600481018290527f000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc26001600160a01b031690632e1a7d4d90602401600060405180830381600087803b1580156114da57600080fd5b505af11580156114ee573d6000803e3d6000fd5b50611506925050506001600160a01b03831682612dea565b505050565b600080611011878630612710612da4565b6040516328c6306960e21b8152600481018490526001600160a01b038381166024830152336044830152606482018390526000919086169063a318c1a4906084015b6020604051808303816000875af115801561157d573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610c609190613e01565b600081856001600160a01b031663ba0876528686336040518463ffffffff1660e01b81526004016115d493929190613ebb565b6020604051808303816000875af11580156115f3573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906116179190613e01565b9150811015610bde5760405162461bcd60e51b815260206004820152600a60248201526908535a5b905b5bdd5b9d60b21b60448201526064016108a9565b600081856001600160a01b031663b460af948686306040518463ffffffff1660e01b815260040161168893929190613ebb565b6020604051808303816000875af11580156116a7573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906116cb9190613e01565b9150811115610bde5760405163bfdb5fcb60e01b815260040160405180910390fd5b604051627b8a6760e11b8152600481018490526001600160a01b038381166024830152600091839187169062f714ce90604401610b79565b600081856001600160a01b031663b460af948686336040518463ffffffff1660e01b815260040161175893929190613ebb565b6020604051808303816000875af1158015611777573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061179b9190613e01565b9150811115610bde5760405162461bcd60e51b815260206004820152600a602482015269214d617853686172657360b01b60448201526064016108a9565b6115066001600160a01b038416338385612f1f565b604051636e553f6560e01b8152600481018490526001600160a01b0383811660248301526000918391871690636e553f65906044016020604051808303816000875af1158015611842573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906118669190613e01565b9150811015610bde5760405162461bcd60e51b815260206004820152600a602482015269214d696e53686172657360b01b60448201526064016108a9565b606060028310156118c85760405163cbeb538160e01b815260040160405180910390fd5b60006118d5600185613e30565b9050806001600160401b038111156118ef576118ef613e43565b604051908082528060200260200182016040528015611918578160200160208202803683370190505b5091506000611928600286613e30565b90505b600086868381811061193f5761193f613e6c565b90506020020160208101906119549190613c1b565b90506001600160a01b0381163b61198957604051633da8b79760e11b81526001600160a01b03821660048201526024016108a9565b60408051600481526024810182526020810180516001600160e01b03166338d52e0f60e01b1790529051600091829182916001600160a01b038616916119cf9190613e82565b600060405180830381855afa9150503d8060008114611a0a576040519150601f19603f3d011682016040523d82523d6000602084013e611a0f565b606091505b50915091508115611abe5780806020019051810190611a2e9190613e9e565b604051630a28a47760e01b8152600481018a90529093506001600160a01b03851690630a28a47790602401602060405180830381865afa158015611a76573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611a9a9190613e01565b878681518110611aac57611aac613e6c565b60200260200101818152509750611c92565b60408051600481526024810182526020810180516001600160e01b0316637e062a3560e11b17905290516001600160a01b03861691611afc91613e82565b600060405180830381855afa9150503d8060008114611b37576040519150601f19603f3d011682016040523d82523d6000602084013e611b3c565b606091505b5090925090508115611b715780806020019051810190611b5c9190613e9e565b9250611a9a6001600160a01b03851689612fa2565b60408051600481526024810182526020810180516001600160e01b0316630b71f5d360e21b17905290516001600160a01b03861691611baf91613e82565b600060405180830381855afa9150503d8060008114611bea576040519150601f19603f3d011682016040523d82523d6000602084013e611bef565b606091505b5090925090508115610a9a5780806020019051810190611c0f9190613e9e565b6001600160a01b031663fc0c546a6040518163ffffffff1660e01b8152600401602060405180830381865afa158015611c4c573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611c709190613e9e565b925087878681518110611c8557611c85613e6c565b6020026020010181815250505b8989611c9f876001613e59565b818110611cae57611cae613e6c565b9050602002016020810190611cc39190613c1b565b6001600160a01b0316836001600160a01b031614611cf4576040516364d4d57b60e11b815260040160405180910390fd5b84600003611d0757505050505050610b3f565b846001900394505050505061192b565b6040516370a0823160e01b815233600482015260009081906001600160a01b038416906370a0823190602401602060405180830381865afa158015611d60573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611d849190613e01565b9050610b3f8382336001612da4565b60606002831015611db75760405163cbeb538160e01b815260040160405180910390fd5b6000611dc4600185613e30565b9050806001600160401b03811115611dde57611dde613e43565b604051908082528060200260200182016040528015611e07578160200160208202803683370190505b50915060005b81811015610b25576000868683818110611e2957611e29613e6c565b9050602002016020810190611e3e9190613c1b565b90506001600160a01b0381163b611e7357604051633da8b79760e11b81526001600160a01b03821660048201526024016108a9565b60408051600481526024810182526020810180516001600160e01b03166338d52e0f60e01b1790529051600091829182916001600160a01b03861691611eb99190613e82565b600060405180830381855afa9150503d8060008114611ef4576040519150601f19603f3d011682016040523d82523d6000602084013e611ef9565b606091505b50915091508115611fa85780806020019051810190611f189190613e9e565b60405163266d6a8360e11b8152600481018a90529093506001600160a01b03851690634cdad50690602401602060405180830381865afa158015611f60573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611f849190613e01565b878681518110611f9657611f96613e6c565b6020026020010181815250975061217c565b60408051600481526024810182526020810180516001600160e01b0316637e062a3560e11b17905290516001600160a01b03861691611fe691613e82565b600060405180830381855afa9150503d8060008114612021576040519150601f19603f3d011682016040523d82523d6000602084013e612026565b606091505b509092509050811561205b57808060200190518101906120469190613e9e565b9250611f846001600160a01b038516896130a0565b60408051600481526024810182526020810180516001600160e01b0316630b71f5d360e21b17905290516001600160a01b0386169161209991613e82565b600060405180830381855afa9150503d80600081146120d4576040519150601f19603f3d011682016040523d82523d6000602084013e6120d9565b606091505b5090925090508115610a9a57808060200190518101906120f99190613e9e565b6001600160a01b031663fc0c546a6040518163ffffffff1660e01b8152600401602060405180830381865afa158015612136573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061215a9190613e9e565b92508787868151811061216f5761216f613e6c565b6020026020010181815250505b8989612189876001613e59565b81811061219857612198613e6c565b90506020020160208101906121ad9190613c1b565b6001600160a01b0316836001600160a01b0316146121de576040516364d4d57b60e11b815260040160405180910390fd5b84600101945050505050611e0d565b6000610c608585853386610f24565b600080836001600160a01b03166338d52e0f6040518163ffffffff1660e01b8152600401602060405180830381865afa15801561223d573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906122619190613e9e565b6040516370a0823160e01b81523360048201526001600160a01b0391909116906370a0823190602401602060405180830381865afa1580156122a7573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906122cb9190613e01565b905061072c84823386610be6565b6040516370a0823160e01b815233600482015260009081906001600160a01b038616906370a0823190602401602060405180830381865afa158015612322573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906123469190613e01565b9050610c608585833387610f24565b604051636eb1769f60e11b8152336004820152306024820152600019906001600160a01b0388169063dd62ed3e90604401602060405180830381865afa1580156123a3573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906123c79190613e01565b10156123db576123db86868686868661130b565b505050505050565b6000610c60858585338661150b565b6060816001600160401b0381111561240c5761240c613e43565b60405190808252806020026020018201604052801561243f57816020015b606081526020019060019003908161242a5790505b50905060005b82811015612542576000803086868581811061246357612463613e6c565b90506020028101906124759190613f22565b604051612483929190613f68565b600060405180830381855af49150503d80600081146124be576040519150601f19603f3d011682016040523d82523d6000602084013e6124c3565b606091505b50915091508161250f576044815110156124dc57600080fd5b600481019050808060200190518101906124f69190613f78565b60405162461bcd60e51b81526004016108a99190613814565b8084848151811061252257612522613e6c565b60200260200101819052505050808061253a90614019565b915050612445565b5092915050565b6000610b3c84843385610be6565b604051636eb1769f60e11b815233600482015230602482015285906001600160a01b0388169063dd62ed3e90604401602060405180830381865afa1580156125a3573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906125c79190613e01565b10156123db576123db868686868686612d4d565b606060028310156125ff5760405163cbeb538160e01b815260040160405180910390fd5b600061260c600185613e30565b9050806001600160401b0381111561262657612626613e43565b60405190808252806020026020018201604052801561264f578160200160208202803683370190505b509150805b8015610b2557600086868381811061266e5761266e613e6c565b90506020020160208101906126839190613c1b565b90506001600160a01b0381163b6126b857604051633da8b79760e11b81526001600160a01b03821660048201526024016108a9565b60408051600481526024810182526020810180516001600160e01b03166338d52e0f60e01b1790529051600091829182916001600160a01b038616916126fe9190613e82565b600060405180830381855afa9150503d8060008114612739576040519150601f19603f3d011682016040523d82523d6000602084013e61273e565b606091505b509150915081156127f7578080602001905181019061275d9190613e9e565b60405163b3d7f6b960e01b8152600481018a90529093506001600160a01b0385169063b3d7f6b990602401602060405180830381865afa1580156127a5573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906127c99190613e01565b876127d5600188613e30565b815181106127e5576127e5613e6c565b602002602001018181525097506128aa565b60408051600481526024810182526020810180516001600160e01b0316637e062a3560e11b17905290516001600160a01b0386169161283591613e82565b600060405180830381855afa9150503d8060008114612870576040519150601f19603f3d011682016040523d82523d6000602084013e612875565b606091505b5090925090508115610a9a57808060200190518101906128959190613e9e565b92506127c96001600160a01b03851689613133565b89896128b7600188613e30565b8181106128c6576128c6613e6c565b90506020020160208101906128db9190613c1b565b6001600160a01b0316836001600160a01b03161461290c576040516364d4d57b60e11b815260040160405180910390fd5b8460019003945050505050612654565b6040516370a0823160e01b815233600482015260009081906001600160a01b038516906370a0823190602401602060405180830381865afa158015612965573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906129899190613e01565b905061072c848483336000610f24565b6040516370a0823160e01b81523060048201526000906001600160a01b038516906370a0823190602401602060405180830381865afa1580156129e0573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612a049190613e01565b905082811015612a4b5760405162461bcd60e51b815260206004820152601260248201527124b739bab33334b1b4b2b73a103a37b5b2b760711b60448201526064016108a9565b8015612a6557612a656001600160a01b03851683836131b5565b50505050565b6115066001600160a01b038416838361322d565b30612a8d6020850185613c1b565b6001600160a01b031614612ab4576040516368b02d7960e01b815260040160405180910390fd5b6020848101359084013514612adc57604051630726615360e41b815260040160405180910390fd5b60405163187945bd60e11b81526001600160a01b037f000000000000000000000000000000000022d473030f116ddee9f6b43ac78ba316906330f28b7a90612b309087908790339088908890600401614053565b600060405180830381600087803b158015612b4a57600080fd5b505af1158015612b5e573d6000803e3d6000fd5b5050505050505050565b600080826001600160a01b03166338d52e0f6040518163ffffffff1660e01b8152600401602060405180830381865afa158015612ba9573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612bcd9190613e9e565b6040516370a0823160e01b81523360048201526001600160a01b0391909116906370a0823190602401602060405180830381865afa158015612c13573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612c379190613e01565b90506000612710846001600160a01b031663ef8b30f7846040518263ffffffff1660e01b8152600401612c6c91815260200190565b602060405180830381865afa158015612c89573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612cad9190613e01565b612cb99061270f6140c7565b612cc391906140f4565b9050610bde84833384610be6565b6040516370a0823160e01b815233600482015260009081906001600160a01b038616906370a0823190602401602060405180830381865afa158015612d1a573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612d3e9190613e01565b9050610c60858583338761150b565b60405163d505accf60e01b8152336004820152306024820152604481018690526064810185905260ff8416608482015260a4810183905260c481018290526001600160a01b0387169063d505accf9060e401611366565b604051639f40a7b360e01b8152600481018490526001600160a01b0383811660248301523360448301526064820183905260009190861690639f40a7b39060840161155e565b600080600080600085875af19050806115065760405162461bcd60e51b815260206004820152601360248201527211551217d514905394d1915497d19052531151606a1b60448201526064016108a9565b600080836001600160a01b03166318160ddd6040518163ffffffff1660e01b8152600401602060405180830381865afa158015612e7c573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612ea09190613e01565b90508015612ec557612ebd8382612eb6876132a4565b6000613497565b915050610730565b509092915050565b604080516001600160a01b038416602482015260448082018490528251808303909101815260649091019091526020810180516001600160e01b031663a9059cbb60e01b1790526115069084906134f2565b60006040516323b872dd60e01b81528460048201528360248201528260448201526020600060648360008a5af13d15601f3d116001600051141617169150508061109f5760405162461bcd60e51b81526020600482015260146024820152731514905394d1915497d19493d357d1905253115160621b60448201526064016108a9565b600080612fae846132a4565b90508083111561301a57836001600160a01b03166318160ddd6040518163ffffffff1660e01b8152600401602060405180830381865afa158015612ff6573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612ebd9190613e01565b801561309657612ebd83856001600160a01b03166318160ddd6040518163ffffffff1660e01b8152600401602060405180830381865afa158015613062573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906130869190613e01565b61308f876132a4565b6001613497565b5060009392505050565b600080836001600160a01b03166318160ddd6040518163ffffffff1660e01b8152600401602060405180830381865afa1580156130e1573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906131059190613e01565b90508083111561311857612ebd846132a4565b801561309657612ebd8361312b866132a4565b836000613497565b600080836001600160a01b03166318160ddd6040518163ffffffff1660e01b8152600401602060405180830381865afa158015613174573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906131989190613e01565b90508015612ec557612ebd836131ad866132a4565b836001613497565b600060405163a9059cbb60e01b8152836004820152826024820152602060006044836000895af13d15601f3d1160016000511416171691505080612a655760405162461bcd60e51b815260206004820152600f60248201526e1514905394d1915497d19052531151608a1b60448201526064016108a9565b600060405163095ea7b360e01b8152836004820152826024820152602060006044836000895af13d15601f3d1160016000511416171691505080612a655760405162461bcd60e51b815260206004820152600e60248201526d1054141493d59157d1905253115160921b60448201526064016108a9565b600080826001600160a01b03166344b813966040518163ffffffff1660e01b8152600401602060405180830381865afa1580156132e5573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906133099190613e01565b90506000836001600160a01b031663422327166040518163ffffffff1660e01b8152600401602060405180830381865afa15801561334b573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061336f9190613e01565b846001600160a01b031663c3535b526040518163ffffffff1660e01b8152600401602060405180830381865afa1580156133ad573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906133d19190613e01565b6133db9042613e30565b6133e591906140c7565b9050670de0b6b3a764000081101561342557670de0b6b3a764000061340a82846140c7565b61341491906140f4565b61341e9083613e30565b915061342a565b600091505b81846001600160a01b03166301e1d1146040518163ffffffff1660e01b8152600401602060405180830381865afa158015613469573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061348d9190613e01565b610bde9190613e30565b6000806134a58686866135c7565b905060018360028111156134bb576134bb614116565b1480156134d85750600084806134d3576134d36140de565b868809115b15610c60576134e8600182613e59565b9695505050505050565b6000613547826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b03166136b19092919063ffffffff16565b90508051600014806135685750808060200190518101906135689190613f05565b6115065760405162461bcd60e51b815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e6044820152691bdd081cdd58d8d9595960b21b60648201526084016108a9565b6000808060001985870985870292508281108382030391505080600003613601578382816135f7576135f76140de565b0492505050610b3f565b8084116136485760405162461bcd60e51b81526020600482015260156024820152744d6174683a206d756c446976206f766572666c6f7760581b60448201526064016108a9565b60008486880960026001871981018816978890046003810283188082028403028082028403028082028403028082028403028082028403029081029092039091026000889003889004909101858311909403939093029303949094049190911702949350505050565b6060610b3c848460008585600080866001600160a01b031685876040516136d89190613e82565b60006040518083038185875af1925050503d8060008114613715576040519150601f19603f3d011682016040523d82523d6000602084013e61371a565b606091505b509150915061101f878383876060831561379557825160000361378e576001600160a01b0385163b61378e5760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e747261637400000060448201526064016108a9565b5081610bde565b610bde83838151156137aa5781518083602001fd5b8060405162461bcd60e51b81526004016108a99190613814565b60005b838110156137df5781810151838201526020016137c7565b50506000910152565b600081518084526138008160208601602086016137c4565b601f01601f19169290920160200192915050565b602081526000610b3f60208301846137e8565b6001600160a01b038116811461383c57600080fd5b50565b6000806040838503121561385257600080fd5b823561385d81613827565b9150602083013561386d81613827565b809150509250929050565b6000806040838503121561388b57600080fd5b823561389681613827565b946020939093013593505050565b60008083601f8401126138b657600080fd5b5081356001600160401b038111156138cd57600080fd5b6020830191508360208260051b85010111156138e857600080fd5b9250929050565b60008060006040848603121561390457600080fd5b83356001600160401b0381111561391a57600080fd5b613926868287016138a4565b909790965060209590950135949350505050565b6020808252825182820181905260009190848201906040850190845b8181101561397257835183529284019291840191600101613956565b50909695505050505050565b60008060006060848603121561399357600080fd5b833561399e81613827565b95602085013595506040909401359392505050565b600080600080608085870312156139c957600080fd5b84356139d481613827565b93506020850135925060408501356139eb81613827565b9396929550929360600135925050565b600080600080600080600060a0888a031215613a1657600080fd5b87356001600160401b0380821115613a2d57600080fd5b613a398b838c016138a4565b909950975060208a0135915080821115613a5257600080fd5b50613a5f8a828b016138a4565b909650945050604088013592506060880135613a7a81613827565b809250506080880135905092959891949750929550565b600080600080600060a08688031215613aa957600080fd5b8535613ab481613827565b94506020860135613ac481613827565b9350604086013592506060860135613adb81613827565b949793965091946080013592915050565b600080600080600060808688031215613b0457600080fd5b85356001600160401b03811115613b1a57600080fd5b613b26888289016138a4565b909650945050602086013592506040860135613b4181613827565b949793965091946060013592915050565b600080600060608486031215613b6757600080fd5b8335613b7281613827565b9250602084013591506040840135613b8981613827565b809150509250925092565b60008060008060008060c08789031215613bad57600080fd5b8635613bb881613827565b95506020870135945060408701359350606087013560ff81168114613bdc57600080fd5b9598949750929560808101359460a0909101359350915050565b60008060408385031215613c0957600080fd5b82359150602083013561386d81613827565b600060208284031215613c2d57600080fd5b8135610b3f81613827565b60008060008060808587031215613c4e57600080fd5b8435613c5981613827565b93506020850135613c6981613827565b93969395505050506040820135916060013590565b600080600060608486031215613c9357600080fd5b8335613c9e81613827565b92506020840135613cae81613827565b929592945050506040919091013590565b60008060208385031215613cd257600080fd5b82356001600160401b03811115613ce857600080fd5b613cf4858286016138a4565b90969095509350505050565b6000602080830181845280855180835260408601915060408160051b870101925083870160005b82811015613d5557603f19888603018452613d438583516137e8565b94509285019290850190600101613d27565b5092979650505050505050565b60008060008084860360e0811215613d7957600080fd5b6080811215613d8757600080fd5b8594506040607f1982011215613d9c57600080fd5b5060808501925060c08501356001600160401b0380821115613dbd57600080fd5b818701915087601f830112613dd157600080fd5b813581811115613de057600080fd5b886020828501011115613df257600080fd5b95989497505060200194505050565b600060208284031215613e1357600080fd5b5051919050565b634e487b7160e01b600052601160045260246000fd5b8181038181111561073057610730613e1a565b634e487b7160e01b600052604160045260246000fd5b8082018082111561073057610730613e1a565b634e487b7160e01b600052603260045260246000fd5b60008251613e948184602087016137c4565b9190910192915050565b600060208284031215613eb057600080fd5b8151610b3f81613827565b9283526001600160a01b03918216602084015216604082015260600190565b801515811461383c57600080fd5b600060208284031215613efa57600080fd5b8135610b3f81613eda565b600060208284031215613f1757600080fd5b8151610b3f81613eda565b6000808335601e19843603018112613f3957600080fd5b8301803591506001600160401b03821115613f5357600080fd5b6020019150368190038213156138e857600080fd5b8183823760009101908152919050565b600060208284031215613f8a57600080fd5b81516001600160401b0380821115613fa157600080fd5b818401915084601f830112613fb557600080fd5b815181811115613fc757613fc7613e43565b604051601f8201601f19908116603f01168101908382118183101715613fef57613fef613e43565b8160405282815287602084870101111561400857600080fd5b61101f8360208301602088016137c4565b60006001820161402b5761402b613e1a565b5060010190565b803561403d81613827565b6001600160a01b03168252602090810135910152565b60006101006140628389614032565b60408801356040840152606088013560608401526140836080840188614032565b6001600160a01b03861660c084015260e0830181905282018390526101208385828501376000838501820152601f909301601f191690910190910195945050505050565b808202811582820484141761073057610730613e1a565b634e487b7160e01b600052601260045260246000fd5b60008261411157634e487b7160e01b600052601260045260246000fd5b500490565b634e487b7160e01b600052602160045260246000fdfea26469706673582212205471a74404f2c722bb640ed728cade6c2ec1306a58ef18c606984e3fd80c79e164736f6c63430008120033
Constructor Arguments (ABI-Encoded and is the last bytes of the Contract Creation Code above)
0000000000000000000000000000000000000000000000000000000000000060000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2000000000000000000000000000000000022d473030f116ddee9f6b43ac78ba30000000000000000000000000000000000000000000000000000000000000012596561726e34363236526f757465724578740000000000000000000000000000
-----Decoded View---------------
Arg [0] : name_ (string): Yearn4626RouterExt
Arg [1] : weth_ (address): 0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2
Arg [2] : permit2_ (address): 0x000000000022D473030F116dDEE9F6B43aC78BA3
-----Encoded View---------------
5 Constructor Arguments found :
Arg [0] : 0000000000000000000000000000000000000000000000000000000000000060
Arg [1] : 000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2
Arg [2] : 000000000000000000000000000000000022d473030f116ddee9f6b43ac78ba3
Arg [3] : 0000000000000000000000000000000000000000000000000000000000000012
Arg [4] : 596561726e34363236526f757465724578740000000000000000000000000000
Loading...
Loading
Loading...
Loading
Multichain Portfolio | 31 Chains
Chain | Token | Portfolio % | Price | Amount | Value |
---|
Loading...
Loading
[ Download: CSV Export ]
[ Download: CSV Export ]
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.