creation_sourcecode: {{
    "language": "Solidity",
    "sources": {
      "src/Yearn4626RouterExt.sol": {
        "content": "// SPDX-License-Identifier: BUSL-1.1\npragma solidity 0.8.18;\n\nimport { Yearn4626Router } from \"Yearn-ERC4626-Router/Yearn4626Router.sol\";\nimport { IYearnVaultV2 } from \"./interfaces/deps/yearn/veYFI/IYearnVaultV2.sol\";\nimport { IPermit2 } from \"permit2/interfaces/IPermit2.sol\";\nimport { ISignatureTransfer } from \"permit2/interfaces/ISignatureTransfer.sol\";\nimport { IWETH9 } from \"Yearn-ERC4626-Router/external/PeripheryPayments.sol\";\nimport { IYearn4626RouterExt } from \"./interfaces/IYearn4626RouterExt.sol\";\nimport { YearnVaultV2Helper } from \"./libraries/YearnVaultV2Helper.sol\";\nimport { SafeERC20, IERC20 } from \"@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol\";\nimport { IERC4626 } from \"@openzeppelin/contracts/interfaces/IERC4626.sol\";\nimport { Math } from \"@openzeppelin/contracts/utils/math/Math.sol\";\nimport { Address } from \"@openzeppelin/contracts/utils/Address.sol\";\nimport { IStakeDaoGauge } from \"./interfaces/deps/stakeDAO/IStakeDaoGauge.sol\";\nimport { IStakeDaoVault } from \"./interfaces/deps/stakeDAO/IStakeDaoVault.sol\";\n\n/**\n * @title Yearn4626Router Extension\n * @notice Extends the Yearn4626Router with additional functionality for depositing to Yearn Vault V2 and pulling tokens\n * with Permit2.\n * @dev This contract introduces two key functions: depositing to Yearn Vault V2 and pulling tokens with a signature via\n * Permit2.\n * The contract holds an immutable reference to a Permit2 contract to facilitate token transfers with permits.\n */\ncontract Yearn4626RouterExt is IYearn4626RouterExt, Yearn4626Router {\n    using SafeERC20 for IERC20;\n    using YearnVaultV2Helper for IYearnVaultV2;\n\n    // slither-disable-next-line naming-convention\n    IPermit2 private immutable _PERMIT2;\n\n    /// @notice Error for when the number of shares received is less than the minimum expected.\n    error InsufficientShares();\n    /// @notice Error for when the amount of assets received is less than the minimum expected.\n    error InsufficientAssets();\n    /// @notice Error for when the amount of shares burned is more than the maximum expected.\n    error RequiresMoreThanMaxShares();\n    /// @notice Error for when the `to` address in the Permit2 transfer is not the router contract.\n    error InvalidPermit2TransferTo();\n    /// @notice Error for when the amount in the Permit2 transfer is not the same as the requested amount.\n    error InvalidPermit2TransferAmount();\n    /// @notice Error for when the serialized deposit path is too short.\n    error InvalidPathLength();\n    /// @notice Error for when the path is too short to preview the deposits/mints/withdraws/redeems.\n    error PreviewPathIsTooShort();\n    /// @notice Error for when the address in the path is not a vault.\n    error PreviewNonVaultAddressInPath(address invalidVault);\n    /// @notice Error for when an address in the path does not match previous or next vault's asset.\n    error PreviewVaultMismatch();\n\n    /**\n     * @notice Constructs the Yearn4626RouterExt contract.\n     * @dev Sets up the router with the name for the vault, WETH address, and Permit2 contract address.\n     * @param name_ The name of the vault.\n     * @param weth_ The address of the WETH contract.\n     * @param permit2_ The address of the Permit2 contract.\n     */\n    // slither-disable-next-line locked-ether\n    constructor(string memory name_, address weth_, address permit2_) payable Yearn4626Router(name_, IWETH9(weth_)) {\n        _PERMIT2 = IPermit2(permit2_);\n    }\n\n    /**\n     * @notice Deposits the specified `amount` of assets into series of ERC4626 vaults or Yearn Vault V2.\n     * @param path The array of addresses that represents the vaults to deposit into.\n     * @param assetsIn The amount of assets to deposit into the first vault.\n     * @param to The address to which the shares will be transferred.\n     * @param minSharesOut The minimum amount of shares expected to be received.\n     * @return sharesOut The actual amount of shares received by the `to` address.\n     */\n    function serializedDeposits(\n        address[] calldata path,\n        uint256 assetsIn,\n        address to,\n        uint256 minSharesOut\n    )\n        external\n        payable\n        returns (uint256 sharesOut)\n    {\n        unchecked {\n            if (path.length == 0) revert InvalidPathLength();\n            uint256 last = path.length - 1;\n            for (uint256 i; i < path.length;) {\n                address receiver = address(this);\n                if (i == last) {\n                    receiver = to;\n                }\n                // slither-disable-next-line calls-loop\n                assetsIn = sharesOut = IERC4626(path[i]).deposit(assetsIn, receiver);\n                ++i;\n            }\n            if (sharesOut < minSharesOut) revert InsufficientShares();\n        }\n    }\n\n    /**\n     * @notice Redeems the specified `shares` from a series of ERC4626 vaults or Yearn Vault V2.\n     * @param path The array of addresses that represents the vaults to redeem from.\n     * @param isYearnVaultV2 The array of boolean values that represent whether the vault is a Yearn Vault V2.\n     * @param sharesIn The amount of shares to redeem from the first vault.\n     * @param to The address to which the assets will be transferred.\n     * @param minAssetsOut The minimum amount of assets expected to be received.\n     * @return assetsOut The actual amount of assets received by the `to` address.\n     */\n    function serializedRedeems(\n        address[] calldata path,\n        bool[] calldata isYearnVaultV2,\n        uint256 sharesIn,\n        address to,\n        uint256 minAssetsOut\n    )\n        external\n        payable\n        returns (uint256 assetsOut)\n    {\n        unchecked {\n            uint256 length = path.length;\n            if (length == 0) revert InvalidPathLength();\n            if (length != isYearnVaultV2.length) revert InvalidPathLength();\n            uint256 last = length - 1;\n            for (uint256 i; i < length;) {\n                address receiver = address(this);\n                if (i == last) {\n                    receiver = to;\n                }\n                if (isYearnVaultV2[i]) {\n                    // slither-disable-next-line calls-loop\n                    sharesIn = assetsOut = IYearnVaultV2(path[i]).withdraw(sharesIn, receiver);\n                } else {\n                    // slither-disable-next-line calls-loop\n                    sharesIn = assetsOut = IERC4626(path[i]).redeem(sharesIn, receiver, address(this));\n                }\n                ++i;\n            }\n            if (assetsOut < minAssetsOut) revert InsufficientAssets();\n        }\n    }\n\n    // ------------- YEARN VAULT V2 FUNCTIONS ------------- //\n\n    /**\n     * @notice Redeems the specified `shares` from the Yearn Vault V2.\n     * @dev The shares must exist in this router before calling this function.\n     * @param vault The Yearn Vault V2 contract instance.\n     * @param shares The amount of shares to redeem.\n     * @param to The address to which the assets will be transferred.\n     * @param minAssetsOut The minimum amount of assets expected to be received.\n     * @return amountOut The actual amount of assets received by the `to` address.\n     */\n    function redeemVaultV2(\n        IYearnVaultV2 vault,\n        uint256 shares,\n        address to,\n        uint256 minAssetsOut\n    )\n        public\n        payable\n        returns (uint256 amountOut)\n    {\n        if ((amountOut = vault.withdraw(shares, to)) < minAssetsOut) revert InsufficientAssets();\n    }\n\n    // ------------- ERC4626 VAULT FUNCTIONS  ------------- //\n\n    /**\n     * @notice Redeems the specified IERC4626 vault `shares` that this router is holding.\n     * @param vault The IERC4626 vault contract instance.\n     * @param shares The amount of shares to redeem.\n     * @param to The address to which the assets will be transferred.\n     * @param minAmountOut The minimum amount of assets expected to be received.\n     * @return amountOut The actual amount of assets received by the `to` address.\n     */\n    function redeemFromRouter(\n        IERC4626 vault,\n        uint256 shares,\n        address to,\n        uint256 minAmountOut\n    )\n        public\n        payable\n        virtual\n        returns (uint256 amountOut)\n    {\n        if ((amountOut = vault.redeem(shares, to, address(this))) < minAmountOut) revert InsufficientAssets();\n    }\n\n    /**\n     * @notice Withdraws the specified `assets` from the IERC4626 vault.\n     * @param vault The IERC4626 vault contract instance.\n     * @param assets The amount of assets to withdraw.\n     * @param to The address to which the assets will be transferred.\n     * @param maxSharesIn The maximum amount of vault shares expected to be burned.\n     * @return sharesOut The actual amount of shares burned from the `vault`.\n     */\n    function withdrawFromRouter(\n        IERC4626 vault,\n        uint256 assets,\n        address to,\n        uint256 maxSharesIn\n    )\n        public\n        payable\n        virtual\n        returns (uint256 sharesOut)\n    {\n        if ((sharesOut = vault.withdraw(assets, to, address(this))) > maxSharesIn) revert RequiresMoreThanMaxShares();\n    }\n\n    // ------------- STAKEDAO FUNCTIONS  ------------- //\n\n    /**\n     * @notice Redeems the specified `shares` of the StakeDAO Gauge.\n     * @dev Assumes the assets withdrawn will be the the yearn vault tokens and will always be the same amount as the\n     * `shares` of the burned StakeDAO gauge tokens.\n     * @param gauge The StakeDAO Gauge contract instance.\n     * @param shares The amount of StakeDAO gauge tokens to burn.\n     */\n    function redeemStakeDaoGauge(IStakeDaoGauge gauge, uint256 shares, address to) public payable returns (uint256) {\n        IStakeDaoVault vault = IStakeDaoVault(gauge.staking_token());\n        vault.withdraw(shares);\n        if (to != address(this)) {\n            IERC20(vault.token()).safeTransfer(to, shares);\n        }\n        return shares;\n    }\n\n    // ------------- PERMIT2 FUNCTIONS  ------------- //\n\n    /**\n     * @notice Pulls tokens to the contract using a signature via Permit2.\n     * @dev Verifies that the `to` address in `transferDetails` is the contract itself and then calls\n     * `permitTransferFrom` on the Permit2 contract.\n     * Reverts with `InvalidTo` if the `to` address is not the contract itself.\n     * @param permit The PermitTransferFrom struct containing the permit details.\n     * @param transferDetails The details of the transfer, including the `to` address.\n     * @param signature The signature to authorize the token transfer.\n     */\n    function pullTokenWithPermit2(\n        ISignatureTransfer.PermitTransferFrom calldata permit,\n        ISignatureTransfer.SignatureTransferDetails calldata transferDetails,\n        bytes calldata signature\n    )\n        public\n        payable\n    {\n        if (transferDetails.to != address(this)) revert InvalidPermit2TransferTo();\n        if (permit.permitted.amount != transferDetails.requestedAmount) revert InvalidPermit2TransferAmount();\n        _PERMIT2.permitTransferFrom(permit, transferDetails, msg.sender, signature);\n    }\n\n    // ------------- PREVIEW FUNCTIONS  ------------- //\n\n    /**\n     * @notice Calculate the amount of shares to be received from a series of deposits to ERC4626 vaults or Yearn Vault\n     * V2.\n     * @param path The array of addresses that represents the path from input token to output token\n     * @param assetsIn The amount of assets to deposit into the first vault.\n     * @return sharesOut The amount of shares to be received from each deposit. The length of the array is `path.length\n     * - 1`.\n     */\n    // slither-disable-start calls-loop,low-level-calls\n    function previewDeposits(\n        address[] calldata path,\n        uint256 assetsIn\n    )\n        external\n        view\n        returns (uint256[] memory sharesOut)\n    {\n        if (path.length < 2) revert PreviewPathIsTooShort();\n        uint256 sharesOutLength = path.length - 1;\n        sharesOut = new uint256[](sharesOutLength);\n        for (uint256 i; i < sharesOutLength;) {\n            address vault = path[i + 1];\n            if (!Address.isContract(vault)) {\n                revert PreviewNonVaultAddressInPath(vault);\n            }\n            address vaultAsset = address(0);\n            (bool success, bytes memory data) = vault.staticcall(abi.encodeCall(IERC4626.asset, ()));\n            if (success) {\n                vaultAsset = abi.decode(data, (address));\n                assetsIn = sharesOut[i] = IERC4626(vault).previewDeposit(assetsIn);\n            } else {\n                (success, data) = vault.staticcall(abi.encodeCall(IYearnVaultV2.token, ()));\n                if (success) {\n                    vaultAsset = abi.decode(data, (address));\n                    assetsIn = sharesOut[i] = IYearnVaultV2(vault).previewDeposit(assetsIn);\n                } else {\n                    revert PreviewNonVaultAddressInPath(vault);\n                }\n            }\n            if (vaultAsset != path[i]) {\n                revert PreviewVaultMismatch();\n            }\n\n            /// @dev Increment the loop index `i` without checking for overflow.\n            /// This is safe because the loop's termination condition ensures that `i` will not exceed\n            /// the bounds of the `sharesOut` array, which would be the only case where an overflow could occur.\n            unchecked {\n                ++i;\n            }\n        }\n    }\n\n    /**\n     * @notice Calculate the amount of assets required to mint a given amount of shares from a series of deposits to\n     * ERC4626 vaults or Yearn Vault V2.\n     * @param path The array of addresses that represents the path from input to output.\n     * @param sharesOut The amount of shares to mint from the last vault.\n     * @return assetsIn The amount of assets required at each step. The length of the array is `path.length - 1`.\n     * @dev sharesOut is the expected result at the last vault, and the path = [tokenIn, vault0, vault1, ..., vaultN].\n     * First calculate the amount of assets in to get the desired sharesOut from the last vault, then using that amount\n     * as the next sharesOut to get the amount of assets in for the penultimate vault.\n     */\n    function previewMints(\n        address[] calldata path,\n        uint256 sharesOut\n    )\n        external\n        view\n        returns (uint256[] memory assetsIn)\n    {\n        if (path.length < 2) revert PreviewPathIsTooShort();\n        uint256 assetsInLength = path.length - 1;\n        assetsIn = new uint256[](assetsInLength);\n        for (uint256 i = assetsInLength; i > 0;) {\n            address vault = path[i];\n            if (!Address.isContract(vault)) {\n                revert PreviewNonVaultAddressInPath(vault);\n            }\n            address vaultAsset = address(0);\n            (bool success, bytes memory data) = vault.staticcall(abi.encodeCall(IERC4626.asset, ()));\n            if (success) {\n                vaultAsset = abi.decode(data, (address));\n                sharesOut = assetsIn[i - 1] = IERC4626(vault).previewMint(sharesOut);\n            } else {\n                (success, data) = vault.staticcall(abi.encodeCall(IYearnVaultV2.token, ()));\n                if (success) {\n                    vaultAsset = abi.decode(data, (address));\n                    sharesOut = assetsIn[i - 1] = IYearnVaultV2(vault).previewMint(sharesOut);\n                } else {\n                    revert PreviewNonVaultAddressInPath(vault);\n                }\n            }\n\n            if (vaultAsset != path[i - 1]) {\n                revert PreviewVaultMismatch();\n            }\n\n            /// @dev Decrement the loop counter within an unchecked block to avoid redundant gas cost associated with\n            /// underflow checking. This is safe because the loop's initialization and exit condition ensure that `i`\n            /// will not underflow.\n            unchecked {\n                --i;\n            }\n        }\n    }\n\n    /**\n     * @notice Calculate the amount of shares required to withdraw a given amount of assets from a series of withdraws\n     * from ERC4626 vaults or Yearn Vault V2.\n     * @param path The array of addresses that represents the path from input to output.\n     * @param assetsOut The amount of assets to withdraw from the last vault.\n     * @dev assetsOut is the desired result of the output token, and the path = [vault0, vault1, ..., vaultN, tokenOut].\n     * First calculate the amount of shares in to get the desired assetsOut from the last vault, then using that amount\n     * as the next assetsOut to get the amount of shares in for the penultimate vault.\n     * @return sharesIn The amount of shares required at each step. The length of the array is `path.length - 1`.\n     */\n    function previewWithdraws(\n        address[] calldata path,\n        uint256 assetsOut\n    )\n        external\n        view\n        returns (uint256[] memory sharesIn)\n    {\n        if (path.length < 2) revert PreviewPathIsTooShort();\n        uint256 sharesInLength = path.length - 1;\n        sharesIn = new uint256[](sharesInLength);\n        for (uint256 i = path.length - 2;;) {\n            address vault = path[i];\n            if (!Address.isContract(vault)) {\n                revert PreviewNonVaultAddressInPath(vault);\n            }\n            address vaultAsset = address(0);\n            (bool success, bytes memory data) = vault.staticcall(abi.encodeCall(IERC4626.asset, ()));\n            if (success) {\n                vaultAsset = abi.decode(data, (address));\n                assetsOut = sharesIn[i] = IERC4626(vault).previewWithdraw(assetsOut);\n            } else {\n                (success, data) = vault.staticcall(abi.encodeCall(IYearnVaultV2.token, ()));\n                if (success) {\n                    vaultAsset = abi.decode(data, (address));\n                    assetsOut = sharesIn[i] = IYearnVaultV2(vault).previewWithdraw(assetsOut);\n                } else {\n                    // StakeDAO gauge token\n                    // StakeDaoGauge.staking_token().token() is the yearn vault v2 token\n                    (success, data) = vault.staticcall(abi.encodeCall(IStakeDaoGauge.staking_token, ()));\n                    if (success) {\n                        vaultAsset = IStakeDaoVault(abi.decode(data, (address))).token();\n                        sharesIn[i] = assetsOut;\n                    } else {\n                        revert PreviewNonVaultAddressInPath(vault);\n                    }\n                }\n            }\n            if (vaultAsset != path[i + 1]) {\n                revert PreviewVaultMismatch();\n            }\n            if (i == 0) return sharesIn;\n\n            /// @dev Decrement the loop counter without checking for overflow.  This is safe because the for loop\n            /// naturally ensures that `i` will not underflow as it is bounded by i == 0 check.\n            unchecked {\n                --i;\n            }\n        }\n    }\n\n    /**\n     * @notice Calculate the amount of assets to be received from a series of withdraws from ERC4626 vaults or Yearn\n     * Vault V2.\n     * @param path The array of addresses that represents the path from input to output.\n     * @param sharesIn The amount of shares to withdraw from the first vault.\n     * @return assetsOut The amount of assets to be received at each step. The length of the array is `path.length - 1`.\n     */\n    function previewRedeems(\n        address[] calldata path,\n        uint256 sharesIn\n    )\n        external\n        view\n        returns (uint256[] memory assetsOut)\n    {\n        if (path.length < 2) revert PreviewPathIsTooShort();\n        uint256 assetsOutLength = path.length - 1;\n        assetsOut = new uint256[](assetsOutLength);\n        for (uint256 i; i < assetsOutLength;) {\n            address vault = path[i];\n            if (!Address.isContract(vault)) {\n                revert PreviewNonVaultAddressInPath(vault);\n            }\n            address vaultAsset = address(0);\n            (bool success, bytes memory data) = vault.staticcall(abi.encodeCall(IERC4626.asset, ()));\n            if (success) {\n                vaultAsset = abi.decode(data, (address));\n                sharesIn = assetsOut[i] = IERC4626(vault).previewRedeem(sharesIn);\n            } else {\n                (success, data) = vault.staticcall(abi.encodeCall(IYearnVaultV2.token, ()));\n                if (success) {\n                    vaultAsset = abi.decode(data, (address));\n                    sharesIn = assetsOut[i] = IYearnVaultV2(vault).previewRedeem(sharesIn);\n                } else {\n                    // StakeDAO gauge token\n                    // StakeDaoGauge.staking_token().token() is the yearn vault v2 token\n                    (success, data) = vault.staticcall(abi.encodeCall(IStakeDaoGauge.staking_token, ()));\n                    if (success) {\n                        vaultAsset = IStakeDaoVault(abi.decode(data, (address))).token();\n                        assetsOut[i] = sharesIn;\n                    } else {\n                        revert PreviewNonVaultAddressInPath(vault);\n                    }\n                }\n            }\n            if (vaultAsset != path[i + 1]) {\n                revert PreviewVaultMismatch();\n            }\n\n            /// @dev The unchecked block is used here to prevent overflow checking for the loop increment, which is not\n            /// necessary since the loop's exit condition ensures `i` will not exceed `assetsOutLength`.\n            unchecked {\n                ++i;\n            }\n        }\n    }\n    // slither-disable-end calls-loop,low-level-calls\n}\n"
      },
      "lib/Yearn-ERC4626-Router/src/Yearn4626Router.sol": {
        "content": "\n// SPDX-License-Identifier: GPL-2.0-or-later\npragma solidity 0.8.18;\n\nimport \"./Yearn4626RouterBase.sol\";\nimport {IYearn4626Router, IYearnV2} from \"./interfaces/IYearn4626Router.sol\";\n\n/**\n * @title Yearn4626Router contract\n * @notice\n *  Router that is meant to be used with Yearn V3 vaults and strategies\n *  for deposits, withdraws and migrations.\n *  \n *  The router was developed from the original router by FEI protocol\n *  https://github.com/fei-protocol/ERC4626\n *\n *  The router is designed to be used with permit and multicall for the \n *  optimal experience.\n *\n *  NOTE: It is important to never leave tokens in the router at the \n *  end of a call, otherwise they can be swept by anyone.\n */\ncontract Yearn4626Router is IYearn4626Router, Yearn4626RouterBase {\n    using SafeTransferLib for ERC20;\n\n    // Store name as bytes so it can be immutable\n    bytes32 private immutable _name;\n\n    constructor(string memory _name_, IWETH9 weth) PeripheryPayments(weth) {\n        _name = bytes32(abi.encodePacked(_name_));\n    }\n\n    // Getter function to unpack stored name.\n    function name() external view returns(string memory) {\n        return string(abi.encodePacked(_name));\n    }\n\n    /*//////////////////////////////////////////////////////////////\n                            DEPOSIT\n    //////////////////////////////////////////////////////////////*/\n\n    // For the below, no approval needed, assumes vault is already max approved\n\n    /// @inheritdoc IYearn4626Router\n    function depositToVault(\n        IYearn4626 vault,\n        uint256 amount,\n        address to,\n        uint256 minSharesOut\n    ) public payable override returns (uint256) {\n        pullToken(ERC20(vault.asset()), amount, address(this));\n        return deposit(vault, amount, to, minSharesOut);\n    }\n\n    //-------- DEPOSIT FUNCTIONS WITH DEFAULT VALUES --------\\\\ \n\n    /**\n     @notice See {depositToVault} in IYearn4626Router.\n     @dev Uses msg.sender as the default for `to`.\n    */\n    function depositToVault(\n        IYearn4626 vault,\n        uint256 amount,\n        uint256 minSharesOut\n    ) external payable returns (uint256) {\n        return depositToVault(vault, amount, msg.sender, minSharesOut);\n    }\n\n    /**\n     @notice See {depositToVault} in IYearn4626Router.\n     @dev Uses msg.sender as the default for `to` and their full \n     balance of msg.sender as `amount`.\n    */\n    function depositToVault(\n        IYearn4626 vault, \n        uint256 minSharesOut\n    ) external payable returns (uint256) {\n        uint256 amount = ERC20(vault.asset()).balanceOf(msg.sender);\n        return depositToVault(vault, amount, msg.sender, minSharesOut);\n    }\n\n    /**\n     @notice See {depositToVault} in IYearn4626Router.\n     @dev Uses msg.sender as the default for `to`, their full balance \n     of msg.sender as `amount` and 1 Basis point for `maxLoss`.\n     \n     NOTE: The slippage tollerance is only useful if {previewDeposit}\n     cannot be manipulated for the `vault`.\n    */\n    function depositToVault(\n        IYearn4626 vault\n    ) external payable returns (uint256) {\n        uint256 assets =  ERC20(vault.asset()).balanceOf(msg.sender);\n        // This give a default 1Basis point acceptance for loss. This is only \n        // considered safe if the vaults PPS can not be manipulated.\n        uint256 minSharesOut = vault.previewDeposit(assets) * 9_999 / 10_000;\n        return depositToVault(vault, assets, msg.sender, minSharesOut);\n    }\n\n    /*//////////////////////////////////////////////////////////////\n                            REDEEM\n    //////////////////////////////////////////////////////////////*/\n\n    //-------- REDEEM FUNCTIONS WITH DEFAULT VALUES --------\\\\\n\n    /**\n     @notice See {redeem} in IYearn4626RouterBase.\n     @dev Uses msg.sender as `receiver`.\n    */\n    function redeem(\n        IYearn4626 vault,\n        uint256 shares,\n        uint256 maxLoss\n    ) external payable returns (uint256) {\n        return redeem(vault, shares, msg.sender, maxLoss);\n    }\n\n    /**\n     @notice See {redeem} in IYearn4626RouterBase.\n     @dev Uses msg.sender as `receiver` and their full balance as `shares`.\n    */\n    function redeem(\n        IYearn4626 vault,\n        uint256 maxLoss\n    ) external payable returns (uint256) {\n        uint256 shares = vault.balanceOf(msg.sender);\n        return redeem(vault, shares, msg.sender, maxLoss);\n    }\n\n    /**\n     @notice See {redeem} in IYearn4626RouterBase.\n     @dev Uses msg.sender as `receiver`, their full balance as `shares`\n     and 1 Basis Point for `maxLoss`.\n    */\n    function redeem(\n        IYearn4626 vault\n    ) external payable returns (uint256) {\n        uint256 shares = vault.balanceOf(msg.sender);\n        return redeem(vault, shares, msg.sender, 1);\n    }\n\n    /*//////////////////////////////////////////////////////////////\n                            MIGRATE\n    //////////////////////////////////////////////////////////////*/\n\n    /// @inheritdoc IYearn4626Router\n    function migrate(\n        IYearn4626 fromVault,\n        IYearn4626 toVault,\n        uint256 shares,\n        address to,\n        uint256 minSharesOut\n    ) public payable override returns (uint256) {\n        // amount out passes through so only one slippage check is needed\n        uint256 amount = redeem(fromVault, shares, address(this), 10_000);\n        return deposit(toVault, amount, to, minSharesOut);\n    }\n\n    //-------- MIGRATE FUNCTIONS WITH DEFAULT VALUES --------\\\\\n\n    /**\n     @notice See {migrate} in IYearn4626Router.\n     @dev Uses msg.sender as `to`.\n    */\n    function migrate(\n        IYearn4626 fromVault,\n        IYearn4626 toVault,\n        uint256 shares,\n        uint256 minSharesOut\n    ) external payable returns (uint256) {\n        return migrate(fromVault, toVault, shares, msg.sender, minSharesOut);\n    }\n\n    /**\n     @notice See {migrate} in IYearn4626Router.\n     @dev Uses msg.sender as `to` and their full balance for `shares`.\n    */\n    function migrate(\n        IYearn4626 fromVault,\n        IYearn4626 toVault,\n        uint256 minSharesOut\n    ) external payable returns (uint256) {\n        uint256 shares = fromVault.balanceOf(msg.sender);\n        return migrate(fromVault, toVault, shares, msg.sender, minSharesOut);\n    }\n\n    /**\n     @notice See {migrate} in IYearn4626Router.\n     @dev Uses msg.sender as `to`, their full balance for `shares` and no `minamountOut`.\n\n     NOTE: Using this will enforce no slippage checks and should be used with care.\n    */\n    function migrate(\n        IYearn4626 fromVault, \n        IYearn4626 toVault\n    ) external payable returns (uint256) {\n        uint256 shares = fromVault.balanceOf(msg.sender);\n        return migrate(fromVault, toVault, shares, msg.sender, 0);\n    }\n\n    /*//////////////////////////////////////////////////////////////\n                        V2 MIGRATION\n    //////////////////////////////////////////////////////////////*/\n\n    /// @inheritdoc IYearn4626Router\n    function migrateFromV2(\n        IYearnV2 fromVault,\n        IYearn4626 toVault,\n        uint256 shares,\n        address to,\n        uint256 minSharesOut\n    ) public payable override returns (uint256) {\n        // V2 can't specify owner so we need to first pull the shares\n        fromVault.transferFrom(msg.sender, address(this), shares);\n        // amount out passes through so only one slippage check is needed\n        uint256 redeemed = fromVault.withdraw(shares, address(this));\n        return deposit(toVault, redeemed, to, minSharesOut);\n    }\n\n    //-------- migrateFromV2 FUNCTIONS WITH DEFAULT VALUES --------\\\\\n\n    /**\n     @notice See {migrateFromV2} in IYearn4626Router.\n     @dev Uses msg.sender as `to`.\n    */\n    function migrateFromV2(\n        IYearnV2 fromVault,\n        IYearn4626 toVault,\n        uint256 shares,\n        uint256 minSharesOut\n    ) external payable returns (uint256) {\n        return migrateFromV2(fromVault, toVault, shares, msg.sender, minSharesOut);\n    }\n\n    /**\n     @notice See {migrateFromV2} in IYearn4626Router.\n     @dev Uses msg.sender as `to` and their full balance as `shares`.\n    */\n    function migrateFromV2(\n        IYearnV2 fromVault,\n        IYearn4626 toVault,\n        uint256 minSharesOut\n    ) external payable returns (uint256) {\n        uint256 shares = fromVault.balanceOf(msg.sender);\n        return migrateFromV2(fromVault, toVault, shares, msg.sender, minSharesOut);\n    }\n\n    /**\n     @notice See {migrate} in IYearn4626Router.\n     @dev Uses msg.sender as `to`, their full balance for `shares` and no `minamountOut`.\n\n     NOTE: Using this will enforce no slippage checks and should be used with care.\n    */\n    function migrateFromV2(\n        IYearnV2 fromVault,\n        IYearn4626 toVault\n    ) external payable returns (uint256 sharesOut) {\n        uint256 shares = fromVault.balanceOf(msg.sender);\n        return migrateFromV2(fromVault, toVault, shares, msg.sender, 0);\n    }\n}"
      },
      "src/interfaces/deps/yearn/veYFI/IYearnVaultV2.sol": {
        "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.18;\n\n// @dev YearnVaultV2 does not follow ERC4626 interface for `asset()` instead it uses `token()`\ninterface IYearnVaultV2 {\n    function token() external view returns (address);\n    function deposit(uint256 amount, address recipient) external returns (uint256 shares);\n    function deposit(uint256 amount) external returns (uint256 shares);\n    function withdraw(uint256 shares, address recipient) external returns (uint256 amount);\n    function pricePerShare() external view returns (uint256);\n    function totalSupply() external view returns (uint256);\n    function totalAssets() external view returns (uint256);\n    function lastReport() external view returns (uint256);\n    function lockedProfitDegradation() external view returns (uint256);\n    function lockedProfit() external view returns (uint256);\n}\n"
      },
      "lib/permit2/src/interfaces/IPermit2.sol": {
        "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.0;\n\nimport {ISignatureTransfer} from \"./ISignatureTransfer.sol\";\nimport {IAllowanceTransfer} from \"./IAllowanceTransfer.sol\";\n\n/// @notice Permit2 handles signature-based transfers in SignatureTransfer and allowance-based transfers in AllowanceTransfer.\n/// @dev Users must approve Permit2 before calling any of the transfer functions.\ninterface IPermit2 is ISignatureTransfer, IAllowanceTransfer {\n// IPermit2 unifies the two interfaces so users have maximal flexibility with their approval.\n}\n"
      },
      "lib/permit2/src/interfaces/ISignatureTransfer.sol": {
        "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.0;\n\nimport {IEIP712} from \"./IEIP712.sol\";\n\n/// @title SignatureTransfer\n/// @notice Handles ERC20 token transfers through signature based actions\n/// @dev Requires user's token approval on the Permit2 contract\ninterface ISignatureTransfer is IEIP712 {\n    /// @notice Thrown when the requested amount for a transfer is larger than the permissioned amount\n    /// @param maxAmount The maximum amount a spender can request to transfer\n    error InvalidAmount(uint256 maxAmount);\n\n    /// @notice Thrown when the number of tokens permissioned to a spender does not match the number of tokens being transferred\n    /// @dev If the spender does not need to transfer the number of tokens permitted, the spender can request amount 0 to be transferred\n    error LengthMismatch();\n\n    /// @notice Emits an event when the owner successfully invalidates an unordered nonce.\n    event UnorderedNonceInvalidation(address indexed owner, uint256 word, uint256 mask);\n\n    /// @notice The token and amount details for a transfer signed in the permit transfer signature\n    struct TokenPermissions {\n        // ERC20 token address\n        address token;\n        // the maximum amount that can be spent\n        uint256 amount;\n    }\n\n    /// @notice The signed permit message for a single token transfer\n    struct PermitTransferFrom {\n        TokenPermissions permitted;\n        // a unique value for every token owner's signature to prevent signature replays\n        uint256 nonce;\n        // deadline on the permit signature\n        uint256 deadline;\n    }\n\n    /// @notice Specifies the recipient address and amount for batched transfers.\n    /// @dev Recipients and amounts correspond to the index of the signed token permissions array.\n    /// @dev Reverts if the requested amount is greater than the permitted signed amount.\n    struct SignatureTransferDetails {\n        // recipient address\n        address to;\n        // spender requested amount\n        uint256 requestedAmount;\n    }\n\n    /// @notice Used to reconstruct the signed permit message for multiple token transfers\n    /// @dev Do not need to pass in spender address as it is required that it is msg.sender\n    /// @dev Note that a user still signs over a spender address\n    struct PermitBatchTransferFrom {\n        // the tokens and corresponding amounts permitted for a transfer\n        TokenPermissions[] permitted;\n        // a unique value for every token owner's signature to prevent signature replays\n        uint256 nonce;\n        // deadline on the permit signature\n        uint256 deadline;\n    }\n\n    /// @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\n    /// @dev Uses unordered nonces so that permit messages do not need to be spent in a certain order\n    /// @dev The mapping is indexed first by the token owner, then by an index specified in the nonce\n    /// @dev It returns a uint256 bitmap\n    /// @dev The index, or wordPosition is capped at type(uint248).max\n    function nonceBitmap(address, uint256) external view returns (uint256);\n\n    /// @notice Transfers a token using a signed permit message\n    /// @dev Reverts if the requested amount is greater than the permitted signed amount\n    /// @param permit The permit data signed over by the owner\n    /// @param owner The owner of the tokens to transfer\n    /// @param transferDetails The spender's requested transfer details for the permitted token\n    /// @param signature The signature to verify\n    function permitTransferFrom(\n        PermitTransferFrom memory permit,\n        SignatureTransferDetails calldata transferDetails,\n        address owner,\n        bytes calldata signature\n    ) external;\n\n    /// @notice Transfers a token using a signed permit message\n    /// @notice Includes extra data provided by the caller to verify signature over\n    /// @dev The witness type string must follow EIP712 ordering of nested structs and must include the TokenPermissions type definition\n    /// @dev Reverts if the requested amount is greater than the permitted signed amount\n    /// @param permit The permit data signed over by the owner\n    /// @param owner The owner of the tokens to transfer\n    /// @param transferDetails The spender's requested transfer details for the permitted token\n    /// @param witness Extra data to include when checking the user signature\n    /// @param witnessTypeString The EIP-712 type definition for remaining string stub of the typehash\n    /// @param signature The signature to verify\n    function permitWitnessTransferFrom(\n        PermitTransferFrom memory permit,\n        SignatureTransferDetails calldata transferDetails,\n        address owner,\n        bytes32 witness,\n        string calldata witnessTypeString,\n        bytes calldata signature\n    ) external;\n\n    /// @notice Transfers multiple tokens using a signed permit message\n    /// @param permit The permit data signed over by the owner\n    /// @param owner The owner of the tokens to transfer\n    /// @param transferDetails Specifies the recipient and requested amount for the token transfer\n    /// @param signature The signature to verify\n    function permitTransferFrom(\n        PermitBatchTransferFrom memory permit,\n        SignatureTransferDetails[] calldata transferDetails,\n        address owner,\n        bytes calldata signature\n    ) external;\n\n    /// @notice Transfers multiple tokens using a signed permit message\n    /// @dev The witness type string must follow EIP712 ordering of nested structs and must include the TokenPermissions type definition\n    /// @notice Includes extra data provided by the caller to verify signature over\n    /// @param permit The permit data signed over by the owner\n    /// @param owner The owner of the tokens to transfer\n    /// @param transferDetails Specifies the recipient and requested amount for the token transfer\n    /// @param witness Extra data to include when checking the user signature\n    /// @param witnessTypeString The EIP-712 type definition for remaining string stub of the typehash\n    /// @param signature The signature to verify\n    function permitWitnessTransferFrom(\n        PermitBatchTransferFrom memory permit,\n        SignatureTransferDetails[] calldata transferDetails,\n        address owner,\n        bytes32 witness,\n        string calldata witnessTypeString,\n        bytes calldata signature\n    ) external;\n\n    /// @notice Invalidates the bits specified in mask for the bitmap at the word position\n    /// @dev The wordPos is maxed at type(uint248).max\n    /// @param wordPos A number to index the nonceBitmap at\n    /// @param mask A bitmap masked against msg.sender's current bitmap at the word position\n    function invalidateUnorderedNonces(uint256 wordPos, uint256 mask) external;\n}\n"
      },
      "lib/Yearn-ERC4626-Router/src/external/PeripheryPayments.sol": {
        "content": "// SPDX-License-Identifier: GPL-2.0-or-later\npragma solidity >=0.7.5;\n\nimport \"solmate/utils/SafeTransferLib.sol\";\n\n/**\n @title Periphery Payments\n @notice Immutable state used by periphery contracts\n Largely Forked from https://github.com/Uniswap/v3-periphery/blob/main/contracts/base/PeripheryPayments.sol \n Changes:\n * no interface\n * no inheritdoc\n * add immutable WETH9 in constructor instead of PeripheryImmutableState\n * receive from any address\n * Solmate interfaces and transfer lib\n * casting\n * add approve, wrapWETH9 and pullToken\n*/\nabstract contract PeripheryPayments {\n    using SafeTransferLib for *;\n\n    IWETH9 public immutable WETH9;\n\n    constructor(IWETH9 _WETH9) {\n        WETH9 = _WETH9;\n    }\n\n    receive() external payable {}\n\n    function approve(\n        ERC20 token,\n        address to,\n        uint256 amount\n    ) public payable {\n        token.safeApprove(to, amount);\n    }\n\n    function unwrapWETH9(uint256 amountMinimum, address recipient) public payable {\n        uint256 balanceWETH9 = WETH9.balanceOf(address(this));\n        require(balanceWETH9 >= amountMinimum, \"Insufficient WETH9\");\n\n        if (balanceWETH9 > 0) {\n            WETH9.withdraw(balanceWETH9);\n            recipient.safeTransferETH(balanceWETH9);\n        }\n    }\n\n    function wrapWETH9() public payable {\n        if (address(this).balance > 0) WETH9.deposit{value: address(this).balance}(); // wrap everything\n    }\n\n    function pullToken(\n        ERC20 token,\n        uint256 amount,\n        address recipient\n    ) public payable {\n        token.safeTransferFrom(msg.sender, recipient, amount);\n    }\n\n    function sweepToken(\n        ERC20 token,\n        uint256 amountMinimum,\n        address recipient\n    ) public payable {\n        uint256 balanceToken = token.balanceOf(address(this));\n        require(balanceToken >= amountMinimum, \"Insufficient token\");\n\n        if (balanceToken > 0) {\n            token.safeTransfer(recipient, balanceToken);\n        }\n    }\n\n    function refundETH() external payable {\n        if (address(this).balance > 0) SafeTransferLib.safeTransferETH(msg.sender, address(this).balance);\n    }\n}\n\nabstract contract IWETH9 is ERC20 {\n    /// @notice Deposit ether to get wrapped ether\n    function deposit() external payable virtual;\n\n    /// @notice Withdraw wrapped ether to get ether\n    function withdraw(uint256) external virtual;\n}\n"
      },
      "src/interfaces/IYearn4626RouterExt.sol": {
        "content": "// SPDX-License-Identifier: BUSL-1.1\npragma solidity ^0.8.18;\n\nimport { IYearn4626Router } from \"Yearn-ERC4626-Router/interfaces/IYearn4626Router.sol\";\nimport { IYearnVaultV2 } from \"./deps/yearn/veYFI/IYearnVaultV2.sol\";\nimport { ISignatureTransfer } from \"permit2/interfaces/ISignatureTransfer.sol\";\nimport { IERC4626 } from \"@openzeppelin/contracts/interfaces/IERC4626.sol\";\nimport { IStakeDaoGauge } from \"./deps/stakeDAO/IStakeDaoGauge.sol\";\n\ninterface IYearn4626RouterExt is IYearn4626Router {\n    function redeemVaultV2(\n        IYearnVaultV2 vault,\n        uint256 shares,\n        address to,\n        uint256 minAmountOut\n    )\n        external\n        payable\n        returns (uint256 amountOut);\n\n    function redeemFromRouter(\n        IERC4626 vault,\n        uint256 shares,\n        address to,\n        uint256 minAmountOut\n    )\n        external\n        payable\n        returns (uint256 amountOut);\n\n    function withdrawFromRouter(\n        IERC4626 vault,\n        uint256 assets,\n        address to,\n        uint256 maxSharesIn\n    )\n        external\n        payable\n        returns (uint256 sharesIn);\n\n    function redeemStakeDaoGauge(\n        IStakeDaoGauge gauge,\n        uint256 shares,\n        address to\n    )\n        external\n        payable\n        returns (uint256 amountOut);\n\n    function previewDeposits(\n        address[] calldata path,\n        uint256 assetsIn\n    )\n        external\n        view\n        returns (uint256[] memory sharesOut);\n    function previewMints(\n        address[] calldata path,\n        uint256 sharesOut\n    )\n        external\n        view\n        returns (uint256[] memory assetsIn);\n    function previewWithdraws(\n        address[] calldata path,\n        uint256 assetsOut\n    )\n        external\n        view\n        returns (uint256[] memory sharesIn);\n    function previewRedeems(\n        address[] calldata path,\n        uint256 sharesIn\n    )\n        external\n        view\n        returns (uint256[] memory assetsOut);\n\n    function pullTokenWithPermit2(\n        ISignatureTransfer.PermitTransferFrom memory permit,\n        ISignatureTransfer.SignatureTransferDetails calldata transferDetails,\n        bytes calldata signature\n    )\n        external\n        payable;\n}\n"
      },
      "src/libraries/YearnVaultV2Helper.sol": {
        "content": "// SPDX-License-Identifier: BUSL-1.1\npragma solidity 0.8.18;\n\nimport { IYearnVaultV2 } from \"src/interfaces/deps/yearn/veYFI/IYearnVaultV2.sol\";\nimport { Math } from \"@openzeppelin/contracts/utils/math/Math.sol\";\n\n/**\n * @title YearnVaultV2Helper\n * @notice Helper functions for Yearn Vault V2 contracts. Since Yearn Vault V2 contracts are not ERC-4626 compliant,\n * they do not provide `previewDeposit`, `previewMint`, `previewRedeem`, and `previewWithdraw` functions. This library\n * provides these functions for previewing share based deposit/mint/redeem/withdraw estimations.\n * @dev These functions are only to be used off-chain for previewing. Due to how Yearn Vault V2 contracts work,\n * share based withdraw/redeem estimations may not be accurate if the vault incurs a loss, thus share price changes.\n * Coverage is currently disabled for this library due to forge limitations. TODO: Once the fix PR is merged,\n * https://github.com/foundry-rs/foundry/pull/7510 coverage should be re-enabled.\n */\nlibrary YearnVaultV2Helper {\n    /**\n     * @notice Calculates the currently free funds in a Yearn Vault V2 contract.\n     * @param vault The Yearn Vault V2 contract.\n     * @return The free funds in the vault.\n     * @dev This is based on Yearn Vault V2 contract's free funds calculation logic.\n     * https://github.com/yearn/yearn-vaults/blob/97ca1b2e4fcf20f4be0ff456dabd020bfeb6697b/contracts/Vault.vy#L844-L847\n     */\n    function freeFunds(IYearnVaultV2 vault) internal view returns (uint256) {\n        uint256 lockedProfit = vault.lockedProfit();\n        uint256 lockedFundsRatio = (block.timestamp - vault.lastReport()) * vault.lockedProfitDegradation();\n        // slither-disable-next-line timestamp\n        if (lockedFundsRatio < 1e18) {\n            lockedProfit -= (lockedProfit * lockedFundsRatio) / 1e18;\n        } else {\n            lockedProfit = 0;\n        }\n        return vault.totalAssets() - lockedProfit;\n    }\n\n    /**\n     * @notice Preview the amount of shares to be issued for a given deposit amount.\n     * @param vault The Yearn Vault V2 contract.\n     * @param assetsIn The amount of assets to be deposited.\n     * @return The number of shares that would be issued for the deposited assets.\n     */\n    function previewDeposit(IYearnVaultV2 vault, uint256 assetsIn) internal view returns (uint256) {\n        uint256 totalSupply = vault.totalSupply();\n        if (totalSupply > 0) {\n            return Math.mulDiv(assetsIn, totalSupply, freeFunds(vault), Math.Rounding.Down);\n        }\n        return assetsIn;\n    }\n\n    /**\n     * @notice Preview the amount of assets required to mint a given amount of shares.\n     * @param vault The Yearn Vault V2 contract.\n     * @param sharesOut The number of shares to be minted.\n     * @return The amount of assets required to mint the specified number of shares.\n     */\n    function previewMint(IYearnVaultV2 vault, uint256 sharesOut) internal view returns (uint256) {\n        uint256 totalSupply = vault.totalSupply();\n        if (totalSupply > 0) {\n            return Math.mulDiv(sharesOut, freeFunds(vault), totalSupply, Math.Rounding.Up);\n        }\n        return sharesOut;\n    }\n\n    /**\n     * @notice Preview the amount of assets to be received for redeeming a given amount of shares.\n     * @param vault The Yearn Vault V2 contract.\n     * @param sharesIn The number of shares to be redeemed.\n     * @return The amount of assets that would be received for the redeemed shares.\n     */\n    function previewRedeem(IYearnVaultV2 vault, uint256 sharesIn) internal view returns (uint256) {\n        uint256 totalSupply = vault.totalSupply();\n        if (sharesIn > totalSupply) {\n            return freeFunds(vault);\n        }\n        if (totalSupply > 0) {\n            return Math.mulDiv(sharesIn, freeFunds(vault), totalSupply, Math.Rounding.Down);\n        }\n        return 0;\n    }\n\n    /**\n     * @notice Preview the number of shares to be redeemed for a given withdrawal amount of assets.\n     * @param vault The Yearn Vault V2 contract.\n     * @param assetsOut The amount of assets to be withdrawn.\n     * @return The number of shares that would be redeemed for the withdrawn assets.\n     */\n    function previewWithdraw(IYearnVaultV2 vault, uint256 assetsOut) internal view returns (uint256) {\n        uint256 freeFunds_ = freeFunds(vault);\n        // slither-disable-next-line timestamp\n        if (assetsOut > freeFunds_) {\n            return vault.totalSupply();\n        }\n        // slither-disable-next-line timestamp\n        if (freeFunds_ > 0) {\n            return Math.mulDiv(assetsOut, vault.totalSupply(), freeFunds(vault), Math.Rounding.Up);\n        }\n        return 0;\n    }\n}\n"
      },
      "lib/openzeppelin-contracts/contracts/token/ERC20/utils/SafeERC20.sol": {
        "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.9.3) (token/ERC20/utils/SafeERC20.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../IERC20.sol\";\nimport \"../extensions/IERC20Permit.sol\";\nimport \"../../../utils/Address.sol\";\n\n/**\n * @title SafeERC20\n * @dev Wrappers around ERC20 operations that throw on failure (when the token\n * contract returns false). Tokens that return no value (and instead revert or\n * throw on failure) are also supported, non-reverting calls are assumed to be\n * successful.\n * To use this library you can add a `using SafeERC20 for IERC20;` statement to your contract,\n * which allows you to call the safe operations as `token.safeTransfer(...)`, etc.\n */\nlibrary SafeERC20 {\n    using Address for address;\n\n    /**\n     * @dev Transfer `value` amount of `token` from the calling contract to `to`. If `token` returns no value,\n     * non-reverting calls are assumed to be successful.\n     */\n    function safeTransfer(IERC20 token, address to, uint256 value) internal {\n        _callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value));\n    }\n\n    /**\n     * @dev Transfer `value` amount of `token` from `from` to `to`, spending the approval given by `from` to the\n     * calling contract. If `token` returns no value, non-reverting calls are assumed to be successful.\n     */\n    function safeTransferFrom(IERC20 token, address from, address to, uint256 value) internal {\n        _callOptionalReturn(token, abi.encodeWithSelector(token.transferFrom.selector, from, to, value));\n    }\n\n    /**\n     * @dev Deprecated. This function has issues similar to the ones found in\n     * {IERC20-approve}, and its usage is discouraged.\n     *\n     * Whenever possible, use {safeIncreaseAllowance} and\n     * {safeDecreaseAllowance} instead.\n     */\n    function safeApprove(IERC20 token, address spender, uint256 value) internal {\n        // safeApprove should only be called when setting an initial allowance,\n        // or when resetting it to zero. To increase and decrease it, use\n        // 'safeIncreaseAllowance' and 'safeDecreaseAllowance'\n        require(\n            (value == 0) || (token.allowance(address(this), spender) == 0),\n            \"SafeERC20: approve from non-zero to non-zero allowance\"\n        );\n        _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, value));\n    }\n\n    /**\n     * @dev Increase the calling contract's allowance toward `spender` by `value`. If `token` returns no value,\n     * non-reverting calls are assumed to be successful.\n     */\n    function safeIncreaseAllowance(IERC20 token, address spender, uint256 value) internal {\n        uint256 oldAllowance = token.allowance(address(this), spender);\n        _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, oldAllowance + value));\n    }\n\n    /**\n     * @dev Decrease the calling contract's allowance toward `spender` by `value`. If `token` returns no value,\n     * non-reverting calls are assumed to be successful.\n     */\n    function safeDecreaseAllowance(IERC20 token, address spender, uint256 value) internal {\n        unchecked {\n            uint256 oldAllowance = token.allowance(address(this), spender);\n            require(oldAllowance >= value, \"SafeERC20: decreased allowance below zero\");\n            _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, oldAllowance - value));\n        }\n    }\n\n    /**\n     * @dev Set the calling contract's allowance toward `spender` to `value`. If `token` returns no value,\n     * non-reverting calls are assumed to be successful. Meant to be used with tokens that require the approval\n     * to be set to zero before setting it to a non-zero value, such as USDT.\n     */\n    function forceApprove(IERC20 token, address spender, uint256 value) internal {\n        bytes memory approvalCall = abi.encodeWithSelector(token.approve.selector, spender, value);\n\n        if (!_callOptionalReturnBool(token, approvalCall)) {\n            _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, 0));\n            _callOptionalReturn(token, approvalCall);\n        }\n    }\n\n    /**\n     * @dev Use a ERC-2612 signature to set the `owner` approval toward `spender` on `token`.\n     * Revert on invalid signature.\n     */\n    function safePermit(\n        IERC20Permit token,\n        address owner,\n        address spender,\n        uint256 value,\n        uint256 deadline,\n        uint8 v,\n        bytes32 r,\n        bytes32 s\n    ) internal {\n        uint256 nonceBefore = token.nonces(owner);\n        token.permit(owner, spender, value, deadline, v, r, s);\n        uint256 nonceAfter = token.nonces(owner);\n        require(nonceAfter == nonceBefore + 1, \"SafeERC20: permit did not succeed\");\n    }\n\n    /**\n     * @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement\n     * on the return value: the return value is optional (but if data is returned, it must not be false).\n     * @param token The token targeted by the call.\n     * @param data The call data (encoded using abi.encode or one of its variants).\n     */\n    function _callOptionalReturn(IERC20 token, bytes memory data) private {\n        // We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since\n        // we're implementing it ourselves. We use {Address-functionCall} to perform this call, which verifies that\n        // the target address contains contract code and also asserts for success in the low-level call.\n\n        bytes memory returndata = address(token).functionCall(data, \"SafeERC20: low-level call failed\");\n        require(returndata.length == 0 || abi.decode(returndata, (bool)), \"SafeERC20: ERC20 operation did not succeed\");\n    }\n\n    /**\n     * @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement\n     * on the return value: the return value is optional (but if data is returned, it must not be false).\n     * @param token The token targeted by the call.\n     * @param data The call data (encoded using abi.encode or one of its variants).\n     *\n     * This is a variant of {_callOptionalReturn} that silents catches all reverts and returns a bool instead.\n     */\n    function _callOptionalReturnBool(IERC20 token, bytes memory data) private returns (bool) {\n        // We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since\n        // we're implementing it ourselves. We cannot use {Address-functionCall} here since this should return false\n        // and not revert is the subcall reverts.\n\n        (bool success, bytes memory returndata) = address(token).call(data);\n        return\n            success && (returndata.length == 0 || abi.decode(returndata, (bool))) && Address.isContract(address(token));\n    }\n}\n"
      },
      "lib/openzeppelin-contracts/contracts/interfaces/IERC4626.sol": {
        "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.9.0) (interfaces/IERC4626.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../token/ERC20/IERC20.sol\";\nimport \"../token/ERC20/extensions/IERC20Metadata.sol\";\n\n/**\n * @dev Interface of the ERC4626 \"Tokenized Vault Standard\", as defined in\n * https://eips.ethereum.org/EIPS/eip-4626[ERC-4626].\n *\n * _Available since v4.7._\n */\ninterface IERC4626 is IERC20, IERC20Metadata {\n    event Deposit(address indexed sender, address indexed owner, uint256 assets, uint256 shares);\n\n    event Withdraw(\n        address indexed sender,\n        address indexed receiver,\n        address indexed owner,\n        uint256 assets,\n        uint256 shares\n    );\n\n    /**\n     * @dev Returns the address of the underlying token used for the Vault for accounting, depositing, and withdrawing.\n     *\n     * - MUST be an ERC-20 token contract.\n     * - MUST NOT revert.\n     */\n    function asset() external view returns (address assetTokenAddress);\n\n    /**\n     * @dev Returns the total amount of the underlying asset that is “managed” by Vault.\n     *\n     * - SHOULD include any compounding that occurs from yield.\n     * - MUST be inclusive of any fees that are charged against assets in the Vault.\n     * - MUST NOT revert.\n     */\n    function totalAssets() external view returns (uint256 totalManagedAssets);\n\n    /**\n     * @dev Returns the amount of shares that the Vault would exchange for the amount of assets provided, in an ideal\n     * scenario where all the conditions are met.\n     *\n     * - MUST NOT be inclusive of any fees that are charged against assets in the Vault.\n     * - MUST NOT show any variations depending on the caller.\n     * - MUST NOT reflect slippage or other on-chain conditions, when performing the actual exchange.\n     * - MUST NOT revert.\n     *\n     * NOTE: This calculation MAY NOT reflect the “per-user” price-per-share, and instead should reflect the\n     * “average-user’s” price-per-share, meaning what the average user should expect to see when exchanging to and\n     * from.\n     */\n    function convertToShares(uint256 assets) external view returns (uint256 shares);\n\n    /**\n     * @dev Returns the amount of assets that the Vault would exchange for the amount of shares provided, in an ideal\n     * scenario where all the conditions are met.\n     *\n     * - MUST NOT be inclusive of any fees that are charged against assets in the Vault.\n     * - MUST NOT show any variations depending on the caller.\n     * - MUST NOT reflect slippage or other on-chain conditions, when performing the actual exchange.\n     * - MUST NOT revert.\n     *\n     * NOTE: This calculation MAY NOT reflect the “per-user” price-per-share, and instead should reflect the\n     * “average-user’s” price-per-share, meaning what the average user should expect to see when exchanging to and\n     * from.\n     */\n    function convertToAssets(uint256 shares) external view returns (uint256 assets);\n\n    /**\n     * @dev Returns the maximum amount of the underlying asset that can be deposited into the Vault for the receiver,\n     * through a deposit call.\n     *\n     * - MUST return a limited value if receiver is subject to some deposit limit.\n     * - MUST return 2 ** 256 - 1 if there is no limit on the maximum amount of assets that may be deposited.\n     * - MUST NOT revert.\n     */\n    function maxDeposit(address receiver) external view returns (uint256 maxAssets);\n\n    /**\n     * @dev Allows an on-chain or off-chain user to simulate the effects of their deposit at the current block, given\n     * current on-chain conditions.\n     *\n     * - MUST return as close to and no more than the exact amount of Vault shares that would be minted in a deposit\n     *   call in the same transaction. I.e. deposit should return the same or more shares as previewDeposit if called\n     *   in the same transaction.\n     * - MUST NOT account for deposit limits like those returned from maxDeposit and should always act as though the\n     *   deposit would be accepted, regardless if the user has enough tokens approved, etc.\n     * - MUST be inclusive of deposit fees. Integrators should be aware of the existence of deposit fees.\n     * - MUST NOT revert.\n     *\n     * NOTE: any unfavorable discrepancy between convertToShares and previewDeposit SHOULD be considered slippage in\n     * share price or some other type of condition, meaning the depositor will lose assets by depositing.\n     */\n    function previewDeposit(uint256 assets) external view returns (uint256 shares);\n\n    /**\n     * @dev Mints shares Vault shares to receiver by depositing exactly amount of underlying tokens.\n     *\n     * - MUST emit the Deposit event.\n     * - MAY support an additional flow in which the underlying tokens are owned by the Vault contract before the\n     *   deposit execution, and are accounted for during deposit.\n     * - MUST revert if all of assets cannot be deposited (due to deposit limit being reached, slippage, the user not\n     *   approving enough underlying tokens to the Vault contract, etc).\n     *\n     * NOTE: most implementations will require pre-approval of the Vault with the Vault’s underlying asset token.\n     */\n    function deposit(uint256 assets, address receiver) external returns (uint256 shares);\n\n    /**\n     * @dev Returns the maximum amount of the Vault shares that can be minted for the receiver, through a mint call.\n     * - MUST return a limited value if receiver is subject to some mint limit.\n     * - MUST return 2 ** 256 - 1 if there is no limit on the maximum amount of shares that may be minted.\n     * - MUST NOT revert.\n     */\n    function maxMint(address receiver) external view returns (uint256 maxShares);\n\n    /**\n     * @dev Allows an on-chain or off-chain user to simulate the effects of their mint at the current block, given\n     * current on-chain conditions.\n     *\n     * - MUST return as close to and no fewer than the exact amount of assets that would be deposited in a mint call\n     *   in the same transaction. I.e. mint should return the same or fewer assets as previewMint if called in the\n     *   same transaction.\n     * - MUST NOT account for mint limits like those returned from maxMint and should always act as though the mint\n     *   would be accepted, regardless if the user has enough tokens approved, etc.\n     * - MUST be inclusive of deposit fees. Integrators should be aware of the existence of deposit fees.\n     * - MUST NOT revert.\n     *\n     * NOTE: any unfavorable discrepancy between convertToAssets and previewMint SHOULD be considered slippage in\n     * share price or some other type of condition, meaning the depositor will lose assets by minting.\n     */\n    function previewMint(uint256 shares) external view returns (uint256 assets);\n\n    /**\n     * @dev Mints exactly shares Vault shares to receiver by depositing amount of underlying tokens.\n     *\n     * - MUST emit the Deposit event.\n     * - MAY support an additional flow in which the underlying tokens are owned by the Vault contract before the mint\n     *   execution, and are accounted for during mint.\n     * - MUST revert if all of shares cannot be minted (due to deposit limit being reached, slippage, the user not\n     *   approving enough underlying tokens to the Vault contract, etc).\n     *\n     * NOTE: most implementations will require pre-approval of the Vault with the Vault’s underlying asset token.\n     */\n    function mint(uint256 shares, address receiver) external returns (uint256 assets);\n\n    /**\n     * @dev Returns the maximum amount of the underlying asset that can be withdrawn from the owner balance in the\n     * Vault, through a withdraw call.\n     *\n     * - MUST return a limited value if owner is subject to some withdrawal limit or timelock.\n     * - MUST NOT revert.\n     */\n    function maxWithdraw(address owner) external view returns (uint256 maxAssets);\n\n    /**\n     * @dev Allows an on-chain or off-chain user to simulate the effects of their withdrawal at the current block,\n     * given current on-chain conditions.\n     *\n     * - MUST return as close to and no fewer than the exact amount of Vault shares that would be burned in a withdraw\n     *   call in the same transaction. I.e. withdraw should return the same or fewer shares as previewWithdraw if\n     *   called\n     *   in the same transaction.\n     * - MUST NOT account for withdrawal limits like those returned from maxWithdraw and should always act as though\n     *   the withdrawal would be accepted, regardless if the user has enough shares, etc.\n     * - MUST be inclusive of withdrawal fees. Integrators should be aware of the existence of withdrawal fees.\n     * - MUST NOT revert.\n     *\n     * NOTE: any unfavorable discrepancy between convertToShares and previewWithdraw SHOULD be considered slippage in\n     * share price or some other type of condition, meaning the depositor will lose assets by depositing.\n     */\n    function previewWithdraw(uint256 assets) external view returns (uint256 shares);\n\n    /**\n     * @dev Burns shares from owner and sends exactly assets of underlying tokens to receiver.\n     *\n     * - MUST emit the Withdraw event.\n     * - MAY support an additional flow in which the underlying tokens are owned by the Vault contract before the\n     *   withdraw execution, and are accounted for during withdraw.\n     * - MUST revert if all of assets cannot be withdrawn (due to withdrawal limit being reached, slippage, the owner\n     *   not having enough shares, etc).\n     *\n     * Note that some implementations will require pre-requesting to the Vault before a withdrawal may be performed.\n     * Those methods should be performed separately.\n     */\n    function withdraw(uint256 assets, address receiver, address owner) external returns (uint256 shares);\n\n    /**\n     * @dev Returns the maximum amount of Vault shares that can be redeemed from the owner balance in the Vault,\n     * through a redeem call.\n     *\n     * - MUST return a limited value if owner is subject to some withdrawal limit or timelock.\n     * - MUST return balanceOf(owner) if owner is not subject to any withdrawal limit or timelock.\n     * - MUST NOT revert.\n     */\n    function maxRedeem(address owner) external view returns (uint256 maxShares);\n\n    /**\n     * @dev Allows an on-chain or off-chain user to simulate the effects of their redeemption at the current block,\n     * given current on-chain conditions.\n     *\n     * - MUST return as close to and no more than the exact amount of assets that would be withdrawn in a redeem call\n     *   in the same transaction. I.e. redeem should return the same or more assets as previewRedeem if called in the\n     *   same transaction.\n     * - MUST NOT account for redemption limits like those returned from maxRedeem and should always act as though the\n     *   redemption would be accepted, regardless if the user has enough shares, etc.\n     * - MUST be inclusive of withdrawal fees. Integrators should be aware of the existence of withdrawal fees.\n     * - MUST NOT revert.\n     *\n     * NOTE: any unfavorable discrepancy between convertToAssets and previewRedeem SHOULD be considered slippage in\n     * share price or some other type of condition, meaning the depositor will lose assets by redeeming.\n     */\n    function previewRedeem(uint256 shares) external view returns (uint256 assets);\n\n    /**\n     * @dev Burns exactly shares from owner and sends assets of underlying tokens to receiver.\n     *\n     * - MUST emit the Withdraw event.\n     * - MAY support an additional flow in which the underlying tokens are owned by the Vault contract before the\n     *   redeem execution, and are accounted for during redeem.\n     * - MUST revert if all of shares cannot be redeemed (due to withdrawal limit being reached, slippage, the owner\n     *   not having enough shares, etc).\n     *\n     * NOTE: some implementations will require pre-requesting to the Vault before a withdrawal may be performed.\n     * Those methods should be performed separately.\n     */\n    function redeem(uint256 shares, address receiver, address owner) external returns (uint256 assets);\n}\n"
      },
      "lib/openzeppelin-contracts/contracts/utils/math/Math.sol": {
        "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.9.0) (utils/math/Math.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev Standard math utilities missing in the Solidity language.\n */\nlibrary Math {\n    enum Rounding {\n        Down, // Toward negative infinity\n        Up, // Toward infinity\n        Zero // Toward zero\n    }\n\n    /**\n     * @dev Returns the largest of two numbers.\n     */\n    function max(uint256 a, uint256 b) internal pure returns (uint256) {\n        return a > b ? a : b;\n    }\n\n    /**\n     * @dev Returns the smallest of two numbers.\n     */\n    function min(uint256 a, uint256 b) internal pure returns (uint256) {\n        return a < b ? a : b;\n    }\n\n    /**\n     * @dev Returns the average of two numbers. The result is rounded towards\n     * zero.\n     */\n    function average(uint256 a, uint256 b) internal pure returns (uint256) {\n        // (a + b) / 2 can overflow.\n        return (a & b) + (a ^ b) / 2;\n    }\n\n    /**\n     * @dev Returns the ceiling of the division of two numbers.\n     *\n     * This differs from standard division with `/` in that it rounds up instead\n     * of rounding down.\n     */\n    function ceilDiv(uint256 a, uint256 b) internal pure returns (uint256) {\n        // (a + b - 1) / b can overflow on addition, so we distribute.\n        return a == 0 ? 0 : (a - 1) / b + 1;\n    }\n\n    /**\n     * @notice Calculates floor(x * y / denominator) with full precision. Throws if result overflows a uint256 or denominator == 0\n     * @dev Original credit to Remco Bloemen under MIT license (https://xn--2-umb.com/21/muldiv)\n     * with further edits by Uniswap Labs also under MIT license.\n     */\n    function mulDiv(uint256 x, uint256 y, uint256 denominator) internal pure returns (uint256 result) {\n        unchecked {\n            // 512-bit multiply [prod1 prod0] = x * y. Compute the product mod 2^256 and mod 2^256 - 1, then use\n            // use the Chinese Remainder Theorem to reconstruct the 512 bit result. The result is stored in two 256\n            // variables such that product = prod1 * 2^256 + prod0.\n            uint256 prod0; // Least significant 256 bits of the product\n            uint256 prod1; // Most significant 256 bits of the product\n            assembly {\n                let mm := mulmod(x, y, not(0))\n                prod0 := mul(x, y)\n                prod1 := sub(sub(mm, prod0), lt(mm, prod0))\n            }\n\n            // Handle non-overflow cases, 256 by 256 division.\n            if (prod1 == 0) {\n                // Solidity will revert if denominator == 0, unlike the div opcode on its own.\n                // The surrounding unchecked block does not change this fact.\n                // See https://docs.soliditylang.org/en/latest/control-structures.html#checked-or-unchecked-arithmetic.\n                return prod0 / denominator;\n            }\n\n            // Make sure the result is less than 2^256. Also prevents denominator == 0.\n            require(denominator > prod1, \"Math: mulDiv overflow\");\n\n            ///////////////////////////////////////////////\n            // 512 by 256 division.\n            ///////////////////////////////////////////////\n\n            // Make division exact by subtracting the remainder from [prod1 prod0].\n            uint256 remainder;\n            assembly {\n                // Compute remainder using mulmod.\n                remainder := mulmod(x, y, denominator)\n\n                // Subtract 256 bit number from 512 bit number.\n                prod1 := sub(prod1, gt(remainder, prod0))\n                prod0 := sub(prod0, remainder)\n            }\n\n            // Factor powers of two out of denominator and compute largest power of two divisor of denominator. Always >= 1.\n            // See https://cs.stackexchange.com/q/138556/92363.\n\n            // Does not overflow because the denominator cannot be zero at this stage in the function.\n            uint256 twos = denominator & (~denominator + 1);\n            assembly {\n                // Divide denominator by twos.\n                denominator := div(denominator, twos)\n\n                // Divide [prod1 prod0] by twos.\n                prod0 := div(prod0, twos)\n\n                // Flip twos such that it is 2^256 / twos. If twos is zero, then it becomes one.\n                twos := add(div(sub(0, twos), twos), 1)\n            }\n\n            // Shift in bits from prod1 into prod0.\n            prod0 |= prod1 * twos;\n\n            // Invert denominator mod 2^256. Now that denominator is an odd number, it has an inverse modulo 2^256 such\n            // that denominator * inv = 1 mod 2^256. Compute the inverse by starting with a seed that is correct for\n            // four bits. That is, denominator * inv = 1 mod 2^4.\n            uint256 inverse = (3 * denominator) ^ 2;\n\n            // Use the Newton-Raphson iteration to improve the precision. Thanks to Hensel's lifting lemma, this also works\n            // in modular arithmetic, doubling the correct bits in each step.\n            inverse *= 2 - denominator * inverse; // inverse mod 2^8\n            inverse *= 2 - denominator * inverse; // inverse mod 2^16\n            inverse *= 2 - denominator * inverse; // inverse mod 2^32\n            inverse *= 2 - denominator * inverse; // inverse mod 2^64\n            inverse *= 2 - denominator * inverse; // inverse mod 2^128\n            inverse *= 2 - denominator * inverse; // inverse mod 2^256\n\n            // Because the division is now exact we can divide by multiplying with the modular inverse of denominator.\n            // This will give us the correct result modulo 2^256. Since the preconditions guarantee that the outcome is\n            // less than 2^256, this is the final result. We don't need to compute the high bits of the result and prod1\n            // is no longer required.\n            result = prod0 * inverse;\n            return result;\n        }\n    }\n\n    /**\n     * @notice Calculates x * y / denominator with full precision, following the selected rounding direction.\n     */\n    function mulDiv(uint256 x, uint256 y, uint256 denominator, Rounding rounding) internal pure returns (uint256) {\n        uint256 result = mulDiv(x, y, denominator);\n        if (rounding == Rounding.Up && mulmod(x, y, denominator) > 0) {\n            result += 1;\n        }\n        return result;\n    }\n\n    /**\n     * @dev Returns the square root of a number. If the number is not a perfect square, the value is rounded down.\n     *\n     * Inspired by Henry S. Warren, Jr.'s \"Hacker's Delight\" (Chapter 11).\n     */\n    function sqrt(uint256 a) internal pure returns (uint256) {\n        if (a == 0) {\n            return 0;\n        }\n\n        // For our first guess, we get the biggest power of 2 which is smaller than the square root of the target.\n        //\n        // We know that the \"msb\" (most significant bit) of our target number `a` is a power of 2 such that we have\n        // `msb(a) <= a < 2*msb(a)`. This value can be written `msb(a)=2**k` with `k=log2(a)`.\n        //\n        // This can be rewritten `2**log2(a) <= a < 2**(log2(a) + 1)`\n        // → `sqrt(2**k) <= sqrt(a) < sqrt(2**(k+1))`\n        // → `2**(k/2) <= sqrt(a) < 2**((k+1)/2) <= 2**(k/2 + 1)`\n        //\n        // Consequently, `2**(log2(a) / 2)` is a good first approximation of `sqrt(a)` with at least 1 correct bit.\n        uint256 result = 1 << (log2(a) >> 1);\n\n        // At this point `result` is an estimation with one bit of precision. We know the true value is a uint128,\n        // since it is the square root of a uint256. Newton's method converges quadratically (precision doubles at\n        // every iteration). We thus need at most 7 iteration to turn our partial result with one bit of precision\n        // into the expected uint128 result.\n        unchecked {\n            result = (result + a / result) >> 1;\n            result = (result + a / result) >> 1;\n            result = (result + a / result) >> 1;\n            result = (result + a / result) >> 1;\n            result = (result + a / result) >> 1;\n            result = (result + a / result) >> 1;\n            result = (result + a / result) >> 1;\n            return min(result, a / result);\n        }\n    }\n\n    /**\n     * @notice Calculates sqrt(a), following the selected rounding direction.\n     */\n    function sqrt(uint256 a, Rounding rounding) internal pure returns (uint256) {\n        unchecked {\n            uint256 result = sqrt(a);\n            return result + (rounding == Rounding.Up && result * result < a ? 1 : 0);\n        }\n    }\n\n    /**\n     * @dev Return the log in base 2, rounded down, of a positive value.\n     * Returns 0 if given 0.\n     */\n    function log2(uint256 value) internal pure returns (uint256) {\n        uint256 result = 0;\n        unchecked {\n            if (value >> 128 > 0) {\n                value >>= 128;\n                result += 128;\n            }\n            if (value >> 64 > 0) {\n                value >>= 64;\n                result += 64;\n            }\n            if (value >> 32 > 0) {\n                value >>= 32;\n                result += 32;\n            }\n            if (value >> 16 > 0) {\n                value >>= 16;\n                result += 16;\n            }\n            if (value >> 8 > 0) {\n                value >>= 8;\n                result += 8;\n            }\n            if (value >> 4 > 0) {\n                value >>= 4;\n                result += 4;\n            }\n            if (value >> 2 > 0) {\n                value >>= 2;\n                result += 2;\n            }\n            if (value >> 1 > 0) {\n                result += 1;\n            }\n        }\n        return result;\n    }\n\n    /**\n     * @dev Return the log in base 2, following the selected rounding direction, of a positive value.\n     * Returns 0 if given 0.\n     */\n    function log2(uint256 value, Rounding rounding) internal pure returns (uint256) {\n        unchecked {\n            uint256 result = log2(value);\n            return result + (rounding == Rounding.Up && 1 << result < value ? 1 : 0);\n        }\n    }\n\n    /**\n     * @dev Return the log in base 10, rounded down, of a positive value.\n     * Returns 0 if given 0.\n     */\n    function log10(uint256 value) internal pure returns (uint256) {\n        uint256 result = 0;\n        unchecked {\n            if (value >= 10 ** 64) {\n                value /= 10 ** 64;\n                result += 64;\n            }\n            if (value >= 10 ** 32) {\n                value /= 10 ** 32;\n                result += 32;\n            }\n            if (value >= 10 ** 16) {\n                value /= 10 ** 16;\n                result += 16;\n            }\n            if (value >= 10 ** 8) {\n                value /= 10 ** 8;\n                result += 8;\n            }\n            if (value >= 10 ** 4) {\n                value /= 10 ** 4;\n                result += 4;\n            }\n            if (value >= 10 ** 2) {\n                value /= 10 ** 2;\n                result += 2;\n            }\n            if (value >= 10 ** 1) {\n                result += 1;\n            }\n        }\n        return result;\n    }\n\n    /**\n     * @dev Return the log in base 10, following the selected rounding direction, of a positive value.\n     * Returns 0 if given 0.\n     */\n    function log10(uint256 value, Rounding rounding) internal pure returns (uint256) {\n        unchecked {\n            uint256 result = log10(value);\n            return result + (rounding == Rounding.Up && 10 ** result < value ? 1 : 0);\n        }\n    }\n\n    /**\n     * @dev Return the log in base 256, rounded down, of a positive value.\n     * Returns 0 if given 0.\n     *\n     * Adding one to the result gives the number of pairs of hex symbols needed to represent `value` as a hex string.\n     */\n    function log256(uint256 value) internal pure returns (uint256) {\n        uint256 result = 0;\n        unchecked {\n            if (value >> 128 > 0) {\n                value >>= 128;\n                result += 16;\n            }\n            if (value >> 64 > 0) {\n                value >>= 64;\n                result += 8;\n            }\n            if (value >> 32 > 0) {\n                value >>= 32;\n                result += 4;\n            }\n            if (value >> 16 > 0) {\n                value >>= 16;\n                result += 2;\n            }\n            if (value >> 8 > 0) {\n                result += 1;\n            }\n        }\n        return result;\n    }\n\n    /**\n     * @dev Return the log in base 256, following the selected rounding direction, of a positive value.\n     * Returns 0 if given 0.\n     */\n    function log256(uint256 value, Rounding rounding) internal pure returns (uint256) {\n        unchecked {\n            uint256 result = log256(value);\n            return result + (rounding == Rounding.Up && 1 << (result << 3) < value ? 1 : 0);\n        }\n    }\n}\n"
      },
      "lib/openzeppelin-contracts/contracts/utils/Address.sol": {
        "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.9.0) (utils/Address.sol)\n\npragma solidity ^0.8.1;\n\n/**\n * @dev Collection of functions related to the address type\n */\nlibrary Address {\n    /**\n     * @dev Returns true if `account` is a contract.\n     *\n     * [IMPORTANT]\n     * ====\n     * It is unsafe to assume that an address for which this function returns\n     * false is an externally-owned account (EOA) and not a contract.\n     *\n     * Among others, `isContract` will return false for the following\n     * types of addresses:\n     *\n     *  - an externally-owned account\n     *  - a contract in construction\n     *  - an address where a contract will be created\n     *  - an address where a contract lived, but was destroyed\n     *\n     * Furthermore, `isContract` will also return true if the target contract within\n     * the same transaction is already scheduled for destruction by `SELFDESTRUCT`,\n     * which only has an effect at the end of a transaction.\n     * ====\n     *\n     * [IMPORTANT]\n     * ====\n     * You shouldn't rely on `isContract` to protect against flash loan attacks!\n     *\n     * Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets\n     * like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract\n     * constructor.\n     * ====\n     */\n    function isContract(address account) internal view returns (bool) {\n        // This method relies on extcodesize/address.code.length, which returns 0\n        // for contracts in construction, since the code is only stored at the end\n        // of the constructor execution.\n\n        return account.code.length > 0;\n    }\n\n    /**\n     * @dev Replacement for Solidity's `transfer`: sends `amount` wei to\n     * `recipient`, forwarding all available gas and reverting on errors.\n     *\n     * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost\n     * of certain opcodes, possibly making contracts go over the 2300 gas limit\n     * imposed by `transfer`, making them unable to receive funds via\n     * `transfer`. {sendValue} removes this limitation.\n     *\n     * https://consensys.net/diligence/blog/2019/09/stop-using-soliditys-transfer-now/[Learn more].\n     *\n     * IMPORTANT: because control is transferred to `recipient`, care must be\n     * taken to not create reentrancy vulnerabilities. Consider using\n     * {ReentrancyGuard} or the\n     * https://solidity.readthedocs.io/en/v0.8.0/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].\n     */\n    function sendValue(address payable recipient, uint256 amount) internal {\n        require(address(this).balance >= amount, \"Address: insufficient balance\");\n\n        (bool success, ) = recipient.call{value: amount}(\"\");\n        require(success, \"Address: unable to send value, recipient may have reverted\");\n    }\n\n    /**\n     * @dev Performs a Solidity function call using a low level `call`. A\n     * plain `call` is an unsafe replacement for a function call: use this\n     * function instead.\n     *\n     * If `target` reverts with a revert reason, it is bubbled up by this\n     * function (like regular Solidity function calls).\n     *\n     * Returns the raw returned data. To convert to the expected return value,\n     * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].\n     *\n     * Requirements:\n     *\n     * - `target` must be a contract.\n     * - calling `target` with `data` must not revert.\n     *\n     * _Available since v3.1._\n     */\n    function functionCall(address target, bytes memory data) internal returns (bytes memory) {\n        return functionCallWithValue(target, data, 0, \"Address: low-level call failed\");\n    }\n\n    /**\n     * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with\n     * `errorMessage` as a fallback revert reason when `target` reverts.\n     *\n     * _Available since v3.1._\n     */\n    function functionCall(\n        address target,\n        bytes memory data,\n        string memory errorMessage\n    ) internal returns (bytes memory) {\n        return functionCallWithValue(target, data, 0, errorMessage);\n    }\n\n    /**\n     * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n     * but also transferring `value` wei to `target`.\n     *\n     * Requirements:\n     *\n     * - the calling contract must have an ETH balance of at least `value`.\n     * - the called Solidity function must be `payable`.\n     *\n     * _Available since v3.1._\n     */\n    function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) {\n        return functionCallWithValue(target, data, value, \"Address: low-level call with value failed\");\n    }\n\n    /**\n     * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but\n     * with `errorMessage` as a fallback revert reason when `target` reverts.\n     *\n     * _Available since v3.1._\n     */\n    function functionCallWithValue(\n        address target,\n        bytes memory data,\n        uint256 value,\n        string memory errorMessage\n    ) internal returns (bytes memory) {\n        require(address(this).balance >= value, \"Address: insufficient balance for call\");\n        (bool success, bytes memory returndata) = target.call{value: value}(data);\n        return verifyCallResultFromTarget(target, success, returndata, errorMessage);\n    }\n\n    /**\n     * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n     * but performing a static call.\n     *\n     * _Available since v3.3._\n     */\n    function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {\n        return functionStaticCall(target, data, \"Address: low-level static call failed\");\n    }\n\n    /**\n     * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\n     * but performing a static call.\n     *\n     * _Available since v3.3._\n     */\n    function functionStaticCall(\n        address target,\n        bytes memory data,\n        string memory errorMessage\n    ) internal view returns (bytes memory) {\n        (bool success, bytes memory returndata) = target.staticcall(data);\n        return verifyCallResultFromTarget(target, success, returndata, errorMessage);\n    }\n\n    /**\n     * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n     * but performing a delegate call.\n     *\n     * _Available since v3.4._\n     */\n    function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {\n        return functionDelegateCall(target, data, \"Address: low-level delegate call failed\");\n    }\n\n    /**\n     * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\n     * but performing a delegate call.\n     *\n     * _Available since v3.4._\n     */\n    function functionDelegateCall(\n        address target,\n        bytes memory data,\n        string memory errorMessage\n    ) internal returns (bytes memory) {\n        (bool success, bytes memory returndata) = target.delegatecall(data);\n        return verifyCallResultFromTarget(target, success, returndata, errorMessage);\n    }\n\n    /**\n     * @dev Tool to verify that a low level call to smart-contract was successful, and revert (either by bubbling\n     * the revert reason or using the provided one) in case of unsuccessful call or if target was not a contract.\n     *\n     * _Available since v4.8._\n     */\n    function verifyCallResultFromTarget(\n        address target,\n        bool success,\n        bytes memory returndata,\n        string memory errorMessage\n    ) internal view returns (bytes memory) {\n        if (success) {\n            if (returndata.length == 0) {\n                // only check isContract if the call was successful and the return data is empty\n                // otherwise we already know that it was a contract\n                require(isContract(target), \"Address: call to non-contract\");\n            }\n            return returndata;\n        } else {\n            _revert(returndata, errorMessage);\n        }\n    }\n\n    /**\n     * @dev Tool to verify that a low level call was successful, and revert if it wasn't, either by bubbling the\n     * revert reason or using the provided one.\n     *\n     * _Available since v4.3._\n     */\n    function verifyCallResult(\n        bool success,\n        bytes memory returndata,\n        string memory errorMessage\n    ) internal pure returns (bytes memory) {\n        if (success) {\n            return returndata;\n        } else {\n            _revert(returndata, errorMessage);\n        }\n    }\n\n    function _revert(bytes memory returndata, string memory errorMessage) private pure {\n        // Look for revert reason and bubble it up if present\n        if (returndata.length > 0) {\n            // The easiest way to bubble the revert reason is using memory via assembly\n            /// @solidity memory-safe-assembly\n            assembly {\n                let returndata_size := mload(returndata)\n                revert(add(32, returndata), returndata_size)\n            }\n        } else {\n            revert(errorMessage);\n        }\n    }\n}\n"
      },
      "src/interfaces/deps/stakeDAO/IStakeDaoGauge.sol": {
        "content": "//SPDX-License-Identifier: MIT\npragma solidity ^0.8.18;\n\ninterface IStakeDaoGauge {\n    function staking_token() external view returns (address);\n}\n"
      },
      "src/interfaces/deps/stakeDAO/IStakeDaoVault.sol": {
        "content": "//SPDX-License-Identifier: MIT\npragma solidity ^0.8.18;\n\ninterface IStakeDaoVault {\n    function withdraw(uint256 shares) external;\n    function token() external view returns (address);\n}\n"
      },
      "lib/Yearn-ERC4626-Router/src/Yearn4626RouterBase.sol": {
        "content": "// SPDX-License-Identifier: GPL-2.0-or-later\npragma solidity 0.8.18;\n\nimport {IYearn4626RouterBase, IYearn4626} from \"./interfaces/IYearn4626RouterBase.sol\";\nimport {ERC20} from \"solmate/tokens/ERC20.sol\";\nimport {SafeTransferLib} from \"solmate/utils/SafeTransferLib.sol\";\n\nimport {SelfPermit} from \"./external/SelfPermit.sol\";\nimport {Multicall} from \"./external/Multicall.sol\";\nimport {PeripheryPayments, IWETH9} from \"./external/PeripheryPayments.sol\";\n\n/// @title ERC4626 Router Base Contract\nabstract contract Yearn4626RouterBase is\n    IYearn4626RouterBase,\n    SelfPermit,\n    Multicall,\n    PeripheryPayments\n{\n    using SafeTransferLib for ERC20;\n\n    /// @inheritdoc IYearn4626RouterBase\n    function mint(\n        IYearn4626 vault,\n        uint256 shares,\n        address to,\n        uint256 maxAmountIn\n    ) public payable virtual override returns (uint256 amountIn) {\n        require ((amountIn = vault.mint(shares, to)) <= maxAmountIn, \"!MaxAmount\");\n    }\n\n    /// @inheritdoc IYearn4626RouterBase\n    function deposit(\n        IYearn4626 vault,\n        uint256 amount,\n        address to,\n        uint256 minSharesOut\n    ) public payable virtual override returns (uint256 sharesOut) {\n        require ((sharesOut = vault.deposit(amount, to)) >= minSharesOut, \"!MinShares\");\n    }\n\n    /// @inheritdoc IYearn4626RouterBase\n    function withdraw(\n        IYearn4626 vault,\n        uint256 amount,\n        address to,\n        uint256 maxLoss\n    ) public payable virtual override returns (uint256) {\n        return vault.withdraw(amount, to, msg.sender, maxLoss);\n    }\n\n    /// @inheritdoc IYearn4626RouterBase\n    function withdrawDefault(\n        IYearn4626 vault,\n        uint256 amount,\n        address to,\n        uint256 maxSharesOut\n    ) public payable virtual override returns (uint256 sharesOut) {\n        require ((sharesOut = vault.withdraw(amount, to, msg.sender)) <= maxSharesOut, \"!MaxShares\");\n    }\n\n    /// @inheritdoc IYearn4626RouterBase\n    function redeem(\n        IYearn4626 vault,\n        uint256 shares,\n        address to,\n        uint256 maxLoss\n    ) public payable virtual override returns (uint256) {\n        return vault.redeem(shares, to, msg.sender, maxLoss);\n    }\n\n    /// @inheritdoc IYearn4626RouterBase\n    function redeemDefault(\n        IYearn4626 vault,\n        uint256 shares,\n        address to,\n        uint256 minAmountOut\n    ) public payable virtual override returns (uint256 amountOut) {\n        require ((amountOut = vault.redeem(shares, to, msg.sender)) >= minAmountOut, \"!MinAmount\");\n    }\n}\n"
      },
      "lib/Yearn-ERC4626-Router/src/interfaces/IYearn4626Router.sol": {
        "content": "// SPDX-License-Identifier: GPL-2.0-or-later\npragma solidity 0.8.18;\n\nimport \"./IYearn4626.sol\";\nimport \"./IYearnV2.sol\";\n\n/** \n @title ERC4626Router Interface\n @notice Extends the ERC4626RouterBase with specific flows to save gas\n */\ninterface IYearn4626Router {\n    /*//////////////////////////////////////////////////////////////\n                            DEPOSIT\n    //////////////////////////////////////////////////////////////*/\n\n    /** \n     @notice deposit `amount` to an ERC4626 vault.\n     @param vault The ERC4626 vault to deposit assets to.\n     @param to The destination of ownership shares.\n     @param amount The amount of assets to deposit to `vault`.\n     @param minSharesOut The min amount of `vault` shares received by `to`.\n     @return . the amount of shares received by `to`.\n     @dev throws \"!minShares\" Error.\n    */\n    function depositToVault(\n        IYearn4626 vault,\n        uint256 amount,\n        address to,\n        uint256 minSharesOut\n    ) external payable returns (uint256);\n\n    /*//////////////////////////////////////////////////////////////\n                            MIGRATION\n    //////////////////////////////////////////////////////////////*/\n\n    /** \n     @notice will redeem `shares` from one vault and deposit amountOut to a different ERC4626 vault.\n     @param fromVault The ERC4626 vault to redeem shares from.\n     @param toVault The ERC4626 vault to deposit assets to.\n     @param shares The amount of shares to redeem from fromVault.\n     @param to The destination of ownership shares.\n     @param minSharesOut The min amount of toVault shares received by `to`.\n     @return . the amount of shares received by `to`.\n     @dev throws \"!minAmount\", \"!minShares\" Errors.\n    */\n    function migrate(\n        IYearn4626 fromVault,\n        IYearn4626 toVault,\n        uint256 shares,\n        address to,\n        uint256 minSharesOut\n    ) external payable returns (uint256);\n\n    /*//////////////////////////////////////////////////////////////\n                            V2 MIGRATION\n    //////////////////////////////////////////////////////////////*/\n\n    /**\n     @notice migrate from Yearn V2 vault to a V3 vault'.\n     @param fromVault The Yearn V2 vault to withdraw from.\n     @param toVault The Yearn V3 vault to deposit assets to.\n     @param shares The amount of V2 shares to redeem form 'fromVault'.\n     @param to The destination of ownership shares\n     @param minSharesOut The min amount of 'toVault' shares to be received by 'to'.\n     @return . The actual amount of 'toVault' shares received by 'to'.\n     @dev throws \"!minAmount\", \"!minShares\" Errors.\n    */\n    function migrateFromV2(\n        IYearnV2 fromVault,\n        IYearn4626 toVault,\n        uint256 shares,\n        address to,\n        uint256 minSharesOut\n    ) external payable returns (uint256);\n}\n"
      },
      "lib/permit2/src/interfaces/IAllowanceTransfer.sol": {
        "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.0;\n\nimport {IEIP712} from \"./IEIP712.sol\";\n\n/// @title AllowanceTransfer\n/// @notice Handles ERC20 token permissions through signature based allowance setting and ERC20 token transfers by checking allowed amounts\n/// @dev Requires user's token approval on the Permit2 contract\ninterface IAllowanceTransfer is IEIP712 {\n    /// @notice Thrown when an allowance on a token has expired.\n    /// @param deadline The timestamp at which the allowed amount is no longer valid\n    error AllowanceExpired(uint256 deadline);\n\n    /// @notice Thrown when an allowance on a token has been depleted.\n    /// @param amount The maximum amount allowed\n    error InsufficientAllowance(uint256 amount);\n\n    /// @notice Thrown when too many nonces are invalidated.\n    error ExcessiveInvalidation();\n\n    /// @notice Emits an event when the owner successfully invalidates an ordered nonce.\n    event NonceInvalidation(\n        address indexed owner, address indexed token, address indexed spender, uint48 newNonce, uint48 oldNonce\n    );\n\n    /// @notice Emits an event when the owner successfully sets permissions on a token for the spender.\n    event Approval(\n        address indexed owner, address indexed token, address indexed spender, uint160 amount, uint48 expiration\n    );\n\n    /// @notice Emits an event when the owner successfully sets permissions using a permit signature on a token for the spender.\n    event Permit(\n        address indexed owner,\n        address indexed token,\n        address indexed spender,\n        uint160 amount,\n        uint48 expiration,\n        uint48 nonce\n    );\n\n    /// @notice Emits an event when the owner sets the allowance back to 0 with the lockdown function.\n    event Lockdown(address indexed owner, address token, address spender);\n\n    /// @notice The permit data for a token\n    struct PermitDetails {\n        // ERC20 token address\n        address token;\n        // the maximum amount allowed to spend\n        uint160 amount;\n        // timestamp at which a spender's token allowances become invalid\n        uint48 expiration;\n        // an incrementing value indexed per owner,token,and spender for each signature\n        uint48 nonce;\n    }\n\n    /// @notice The permit message signed for a single token allowance\n    struct PermitSingle {\n        // the permit data for a single token alownce\n        PermitDetails details;\n        // address permissioned on the allowed tokens\n        address spender;\n        // deadline on the permit signature\n        uint256 sigDeadline;\n    }\n\n    /// @notice The permit message signed for multiple token allowances\n    struct PermitBatch {\n        // the permit data for multiple token allowances\n        PermitDetails[] details;\n        // address permissioned on the allowed tokens\n        address spender;\n        // deadline on the permit signature\n        uint256 sigDeadline;\n    }\n\n    /// @notice The saved permissions\n    /// @dev This info is saved per owner, per token, per spender and all signed over in the permit message\n    /// @dev Setting amount to type(uint160).max sets an unlimited approval\n    struct PackedAllowance {\n        // amount allowed\n        uint160 amount;\n        // permission expiry\n        uint48 expiration;\n        // an incrementing value indexed per owner,token,and spender for each signature\n        uint48 nonce;\n    }\n\n    /// @notice A token spender pair.\n    struct TokenSpenderPair {\n        // the token the spender is approved\n        address token;\n        // the spender address\n        address spender;\n    }\n\n    /// @notice Details for a token transfer.\n    struct AllowanceTransferDetails {\n        // the owner of the token\n        address from;\n        // the recipient of the token\n        address to;\n        // the amount of the token\n        uint160 amount;\n        // the token to be transferred\n        address token;\n    }\n\n    /// @notice A mapping from owner address to token address to spender address to PackedAllowance struct, which contains details and conditions of the approval.\n    /// @notice The mapping is indexed in the above order see: allowance[ownerAddress][tokenAddress][spenderAddress]\n    /// @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.\n    function allowance(address user, address token, address spender)\n        external\n        view\n        returns (uint160 amount, uint48 expiration, uint48 nonce);\n\n    /// @notice Approves the spender to use up to amount of the specified token up until the expiration\n    /// @param token The token to approve\n    /// @param spender The spender address to approve\n    /// @param amount The approved amount of the token\n    /// @param expiration The timestamp at which the approval is no longer valid\n    /// @dev The packed allowance also holds a nonce, which will stay unchanged in approve\n    /// @dev Setting amount to type(uint160).max sets an unlimited approval\n    function approve(address token, address spender, uint160 amount, uint48 expiration) external;\n\n    /// @notice Permit a spender to a given amount of the owners token via the owner's EIP-712 signature\n    /// @dev May fail if the owner's nonce was invalidated in-flight by invalidateNonce\n    /// @param owner The owner of the tokens being approved\n    /// @param permitSingle Data signed over by the owner specifying the terms of approval\n    /// @param signature The owner's signature over the permit data\n    function permit(address owner, PermitSingle memory permitSingle, bytes calldata signature) external;\n\n    /// @notice Permit a spender to the signed amounts of the owners tokens via the owner's EIP-712 signature\n    /// @dev May fail if the owner's nonce was invalidated in-flight by invalidateNonce\n    /// @param owner The owner of the tokens being approved\n    /// @param permitBatch Data signed over by the owner specifying the terms of approval\n    /// @param signature The owner's signature over the permit data\n    function permit(address owner, PermitBatch memory permitBatch, bytes calldata signature) external;\n\n    /// @notice Transfer approved tokens from one address to another\n    /// @param from The address to transfer from\n    /// @param to The address of the recipient\n    /// @param amount The amount of the token to transfer\n    /// @param token The token address to transfer\n    /// @dev Requires the from address to have approved at least the desired amount\n    /// of tokens to msg.sender.\n    function transferFrom(address from, address to, uint160 amount, address token) external;\n\n    /// @notice Transfer approved tokens in a batch\n    /// @param transferDetails Array of owners, recipients, amounts, and tokens for the transfers\n    /// @dev Requires the from addresses to have approved at least the desired amount\n    /// of tokens to msg.sender.\n    function transferFrom(AllowanceTransferDetails[] calldata transferDetails) external;\n\n    /// @notice Enables performing a \"lockdown\" of the sender's Permit2 identity\n    /// by batch revoking approvals\n    /// @param approvals Array of approvals to revoke.\n    function lockdown(TokenSpenderPair[] calldata approvals) external;\n\n    /// @notice Invalidate nonces for a given (token, spender) pair\n    /// @param token The token to invalidate nonces for\n    /// @param spender The spender to invalidate nonces for\n    /// @param newNonce The new nonce to set. Invalidates all nonces less than it.\n    /// @dev Can't invalidate more than 2**16 nonces per transaction.\n    function invalidateNonces(address token, address spender, uint48 newNonce) external;\n}\n"
      },
      "lib/permit2/src/interfaces/IEIP712.sol": {
        "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.0;\n\ninterface IEIP712 {\n    function DOMAIN_SEPARATOR() external view returns (bytes32);\n}\n"
      },
      "lib/permit2/lib/solmate/src/utils/SafeTransferLib.sol": {
        "content": "// SPDX-License-Identifier: AGPL-3.0-only\npragma solidity >=0.8.0;\n\nimport {ERC20} from \"../tokens/ERC20.sol\";\n\n/// @notice Safe ETH and ERC20 transfer library that gracefully handles missing return values.\n/// @author Solmate (https://github.com/transmissions11/solmate/blob/main/src/utils/SafeTransferLib.sol)\n/// @dev Use with caution! Some functions in this library knowingly create dirty bits at the destination of the free memory pointer.\n/// @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.\nlibrary SafeTransferLib {\n    /*//////////////////////////////////////////////////////////////\n                             ETH OPERATIONS\n    //////////////////////////////////////////////////////////////*/\n\n    function safeTransferETH(address to, uint256 amount) internal {\n        bool success;\n\n        /// @solidity memory-safe-assembly\n        assembly {\n            // Transfer the ETH and store if it succeeded or not.\n            success := call(gas(), to, amount, 0, 0, 0, 0)\n        }\n\n        require(success, \"ETH_TRANSFER_FAILED\");\n    }\n\n    /*//////////////////////////////////////////////////////////////\n                            ERC20 OPERATIONS\n    //////////////////////////////////////////////////////////////*/\n\n    function safeTransferFrom(\n        ERC20 token,\n        address from,\n        address to,\n        uint256 amount\n    ) internal {\n        bool success;\n\n        /// @solidity memory-safe-assembly\n        assembly {\n            // Get a pointer to some free memory.\n            let freeMemoryPointer := mload(0x40)\n\n            // Write the abi-encoded calldata into memory, beginning with the function selector.\n            mstore(freeMemoryPointer, 0x23b872dd00000000000000000000000000000000000000000000000000000000)\n            mstore(add(freeMemoryPointer, 4), from) // Append the \"from\" argument.\n            mstore(add(freeMemoryPointer, 36), to) // Append the \"to\" argument.\n            mstore(add(freeMemoryPointer, 68), amount) // Append the \"amount\" argument.\n\n            success := and(\n                // Set success to whether the call reverted, if not we check it either\n                // returned exactly 1 (can't just be non-zero data), or had no return data.\n                or(and(eq(mload(0), 1), gt(returndatasize(), 31)), iszero(returndatasize())),\n                // We use 100 because the length of our calldata totals up like so: 4 + 32 * 3.\n                // We use 0 and 32 to copy up to 32 bytes of return data into the scratch space.\n                // Counterintuitively, this call must be positioned second to the or() call in the\n                // surrounding and() call or else returndatasize() will be zero during the computation.\n                call(gas(), token, 0, freeMemoryPointer, 100, 0, 32)\n            )\n        }\n\n        require(success, \"TRANSFER_FROM_FAILED\");\n    }\n\n    function safeTransfer(\n        ERC20 token,\n        address to,\n        uint256 amount\n    ) internal {\n        bool success;\n\n        /// @solidity memory-safe-assembly\n        assembly {\n            // Get a pointer to some free memory.\n            let freeMemoryPointer := mload(0x40)\n\n            // Write the abi-encoded calldata into memory, beginning with the function selector.\n            mstore(freeMemoryPointer, 0xa9059cbb00000000000000000000000000000000000000000000000000000000)\n            mstore(add(freeMemoryPointer, 4), to) // Append the \"to\" argument.\n            mstore(add(freeMemoryPointer, 36), amount) // Append the \"amount\" argument.\n\n            success := and(\n                // Set success to whether the call reverted, if not we check it either\n                // returned exactly 1 (can't just be non-zero data), or had no return data.\n                or(and(eq(mload(0), 1), gt(returndatasize(), 31)), iszero(returndatasize())),\n                // We use 68 because the length of our calldata totals up like so: 4 + 32 * 2.\n                // We use 0 and 32 to copy up to 32 bytes of return data into the scratch space.\n                // Counterintuitively, this call must be positioned second to the or() call in the\n                // surrounding and() call or else returndatasize() will be zero during the computation.\n                call(gas(), token, 0, freeMemoryPointer, 68, 0, 32)\n            )\n        }\n\n        require(success, \"TRANSFER_FAILED\");\n    }\n\n    function safeApprove(\n        ERC20 token,\n        address to,\n        uint256 amount\n    ) internal {\n        bool success;\n\n        /// @solidity memory-safe-assembly\n        assembly {\n            // Get a pointer to some free memory.\n            let freeMemoryPointer := mload(0x40)\n\n            // Write the abi-encoded calldata into memory, beginning with the function selector.\n            mstore(freeMemoryPointer, 0x095ea7b300000000000000000000000000000000000000000000000000000000)\n            mstore(add(freeMemoryPointer, 4), to) // Append the \"to\" argument.\n            mstore(add(freeMemoryPointer, 36), amount) // Append the \"amount\" argument.\n\n            success := and(\n                // Set success to whether the call reverted, if not we check it either\n                // returned exactly 1 (can't just be non-zero data), or had no return data.\n                or(and(eq(mload(0), 1), gt(returndatasize(), 31)), iszero(returndatasize())),\n                // We use 68 because the length of our calldata totals up like so: 4 + 32 * 2.\n                // We use 0 and 32 to copy up to 32 bytes of return data into the scratch space.\n                // Counterintuitively, this call must be positioned second to the or() call in the\n                // surrounding and() call or else returndatasize() will be zero during the computation.\n                call(gas(), token, 0, freeMemoryPointer, 68, 0, 32)\n            )\n        }\n\n        require(success, \"APPROVE_FAILED\");\n    }\n}\n"
      },
      "lib/openzeppelin-contracts/contracts/token/ERC20/IERC20.sol": {
        "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.9.0) (token/ERC20/IERC20.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev Interface of the ERC20 standard as defined in the EIP.\n */\ninterface IERC20 {\n    /**\n     * @dev Emitted when `value` tokens are moved from one account (`from`) to\n     * another (`to`).\n     *\n     * Note that `value` may be zero.\n     */\n    event Transfer(address indexed from, address indexed to, uint256 value);\n\n    /**\n     * @dev Emitted when the allowance of a `spender` for an `owner` is set by\n     * a call to {approve}. `value` is the new allowance.\n     */\n    event Approval(address indexed owner, address indexed spender, uint256 value);\n\n    /**\n     * @dev Returns the amount of tokens in existence.\n     */\n    function totalSupply() external view returns (uint256);\n\n    /**\n     * @dev Returns the amount of tokens owned by `account`.\n     */\n    function balanceOf(address account) external view returns (uint256);\n\n    /**\n     * @dev Moves `amount` tokens from the caller's account to `to`.\n     *\n     * Returns a boolean value indicating whether the operation succeeded.\n     *\n     * Emits a {Transfer} event.\n     */\n    function transfer(address to, uint256 amount) external returns (bool);\n\n    /**\n     * @dev Returns the remaining number of tokens that `spender` will be\n     * allowed to spend on behalf of `owner` through {transferFrom}. This is\n     * zero by default.\n     *\n     * This value changes when {approve} or {transferFrom} are called.\n     */\n    function allowance(address owner, address spender) external view returns (uint256);\n\n    /**\n     * @dev Sets `amount` as the allowance of `spender` over the caller's tokens.\n     *\n     * Returns a boolean value indicating whether the operation succeeded.\n     *\n     * IMPORTANT: Beware that changing an allowance with this method brings the risk\n     * that someone may use both the old and the new allowance by unfortunate\n     * transaction ordering. One possible solution to mitigate this race\n     * condition is to first reduce the spender's allowance to 0 and set the\n     * desired value afterwards:\n     * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729\n     *\n     * Emits an {Approval} event.\n     */\n    function approve(address spender, uint256 amount) external returns (bool);\n\n    /**\n     * @dev Moves `amount` tokens from `from` to `to` using the\n     * allowance mechanism. `amount` is then deducted from the caller's\n     * allowance.\n     *\n     * Returns a boolean value indicating whether the operation succeeded.\n     *\n     * Emits a {Transfer} event.\n     */\n    function transferFrom(address from, address to, uint256 amount) external returns (bool);\n}\n"
      },
      "lib/openzeppelin-contracts/contracts/token/ERC20/extensions/IERC20Permit.sol": {
        "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.9.4) (token/ERC20/extensions/IERC20Permit.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev Interface of the ERC20 Permit extension allowing approvals to be made via signatures, as defined in\n * https://eips.ethereum.org/EIPS/eip-2612[EIP-2612].\n *\n * Adds the {permit} method, which can be used to change an account's ERC20 allowance (see {IERC20-allowance}) by\n * presenting a message signed by the account. By not relying on {IERC20-approve}, the token holder account doesn't\n * need to send a transaction, and thus is not required to hold Ether at all.\n *\n * ==== Security Considerations\n *\n * There are two important considerations concerning the use of `permit`. The first is that a valid permit signature\n * expresses an allowance, and it should not be assumed to convey additional meaning. In particular, it should not be\n * considered as an intention to spend the allowance in any specific way. The second is that because permits have\n * built-in replay protection and can be submitted by anyone, they can be frontrun. A protocol that uses permits should\n * take this into consideration and allow a `permit` call to fail. Combining these two aspects, a pattern that may be\n * generally recommended is:\n *\n * ```solidity\n * function doThingWithPermit(..., uint256 value, uint256 deadline, uint8 v, bytes32 r, bytes32 s) public {\n *     try token.permit(msg.sender, address(this), value, deadline, v, r, s) {} catch {}\n *     doThing(..., value);\n * }\n *\n * function doThing(..., uint256 value) public {\n *     token.safeTransferFrom(msg.sender, address(this), value);\n *     ...\n * }\n * ```\n *\n * Observe that: 1) `msg.sender` is used as the owner, leaving no ambiguity as to the signer intent, and 2) the use of\n * `try/catch` allows the permit to fail and makes the code tolerant to frontrunning. (See also\n * {SafeERC20-safeTransferFrom}).\n *\n * Additionally, note that smart contract wallets (such as Argent or Safe) are not able to produce permit signatures, so\n * contracts should have entry points that don't rely on permit.\n */\ninterface IERC20Permit {\n    /**\n     * @dev Sets `value` as the allowance of `spender` over ``owner``'s tokens,\n     * given ``owner``'s signed approval.\n     *\n     * IMPORTANT: The same issues {IERC20-approve} has related to transaction\n     * ordering also apply here.\n     *\n     * Emits an {Approval} event.\n     *\n     * Requirements:\n     *\n     * - `spender` cannot be the zero address.\n     * - `deadline` must be a timestamp in the future.\n     * - `v`, `r` and `s` must be a valid `secp256k1` signature from `owner`\n     * over the EIP712-formatted function arguments.\n     * - the signature must use ``owner``'s current nonce (see {nonces}).\n     *\n     * For more information on the signature format, see the\n     * https://eips.ethereum.org/EIPS/eip-2612#specification[relevant EIP\n     * section].\n     *\n     * CAUTION: See Security Considerations above.\n     */\n    function permit(\n        address owner,\n        address spender,\n        uint256 value,\n        uint256 deadline,\n        uint8 v,\n        bytes32 r,\n        bytes32 s\n    ) external;\n\n    /**\n     * @dev Returns the current nonce for `owner`. This value must be\n     * included whenever a signature is generated for {permit}.\n     *\n     * Every successful call to {permit} increases ``owner``'s nonce by one. This\n     * prevents a signature from being used multiple times.\n     */\n    function nonces(address owner) external view returns (uint256);\n\n    /**\n     * @dev Returns the domain separator used in the encoding of the signature for {permit}, as defined by {EIP712}.\n     */\n    // solhint-disable-next-line func-name-mixedcase\n    function DOMAIN_SEPARATOR() external view returns (bytes32);\n}\n"
      },
      "lib/openzeppelin-contracts/contracts/token/ERC20/extensions/IERC20Metadata.sol": {
        "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (token/ERC20/extensions/IERC20Metadata.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../IERC20.sol\";\n\n/**\n * @dev Interface for the optional metadata functions from the ERC20 standard.\n *\n * _Available since v4.1._\n */\ninterface IERC20Metadata is IERC20 {\n    /**\n     * @dev Returns the name of the token.\n     */\n    function name() external view returns (string memory);\n\n    /**\n     * @dev Returns the symbol of the token.\n     */\n    function symbol() external view returns (string memory);\n\n    /**\n     * @dev Returns the decimals places of the token.\n     */\n    function decimals() external view returns (uint8);\n}\n"
      },
      "lib/Yearn-ERC4626-Router/src/interfaces/IYearn4626RouterBase.sol": {
        "content": "// SPDX-License-Identifier: GPL-2.0-or-later\npragma solidity 0.8.18;\n\nimport \"./IYearn4626.sol\";\n\n/** \n @title ERC4626Router Base Interface\n @notice A canonical router between ERC4626 Vaults https://eips.ethereum.org/EIPS/eip-4626\n\n 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.\n It includes methods for the four mutable ERC4626 functions deposit/mint/withdraw/redeem as well.\n\n These can all be arbitrarily composed using the multicall functionality of the router.\n\n 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.\n The router makes no special considerations for unique ERC20 implementations such as fee on transfer. \n There are no built in protections for unexpected behavior beyond enforcing the minSharesOut is received.\n */\ninterface IYearn4626RouterBase {\n    /*//////////////////////////////////////////////////////////////\n                                MINT\n    //////////////////////////////////////////////////////////////*/\n\n    /** \n     @notice mint `shares` from an ERC4626 vault.\n     @param vault The ERC4626 vault to mint shares from.\n     @param shares The amount of shares to mint from `vault`.\n     @param to The destination of ownership shares.\n     @param maxAmountIn The max amount of assets used to mint.\n     @return amountIn the amount of assets used to mint by `to`.\n     @dev throws \"!maxAmount\" Error   \n    */\n    function mint(\n        IYearn4626 vault,\n        uint256 shares,\n        address to,\n        uint256 maxAmountIn\n    ) external payable returns (uint256 amountIn);\n\n    /*//////////////////////////////////////////////////////////////\n                                DEPOSIT\n    //////////////////////////////////////////////////////////////*/\n\n    /** \n     @notice deposit `amount` to an ERC4626 vault.\n     @param vault The ERC4626 vault to deposit assets to.\n     @param amount The amount of assets to deposit to `vault`.\n     @param to The destination of ownership shares.\n     @param minSharesOut The min amount of `vault` shares received by `to`.\n     @return sharesOut the amount of shares received by `to`.\n     @dev throws \"!minShares\" Error   \n    */\n    function deposit(\n        IYearn4626 vault,\n        uint256 amount,\n        address to,\n        uint256 minSharesOut\n    ) external payable returns (uint256 sharesOut);\n\n    /*//////////////////////////////////////////////////////////////\n                                WITHDRAW\n    //////////////////////////////////////////////////////////////*/\n\n    /** \n     @notice withdraw `amount` from an ERC4626 vault.\n     @dev Uses the Yearn specific 'maxLoss' accounting.\n     @param vault The ERC4626 vault to redeem shares from.\n     @param vault The ERC4626 vault to withdraw assets from.\n     @param amount The amount of assets to withdraw from vault.\n     @param to The destination of assets.\n     @param maxLoss The acceptable loss in Basis Points.\n     @return sharesOut the amount of shares received by `to`.\n     @dev throws \"to much loss\" Error   \n    */\n    function withdraw(\n        IYearn4626 vault,\n        uint256 amount,\n        address to,\n        uint256 maxLoss\n    ) external payable returns (uint256);\n\n    /** \n     @notice withdraw `amount` from an ERC4626 vault.\n     @dev Uses the default 4626 syntax, throws !maxShares\" Error.\n     @param vault The ERC4626 vault to withdraw assets from.\n     @param amount The amount of assets to withdraw from vault.\n     @param to The destination of assets.\n     @param minSharesOut The min amount of shares received by `to`.\n     @return sharesOut the amount of shares received by `to`. \n    */\n    function withdrawDefault(\n        IYearn4626 vault,\n        uint256 amount,\n        address to,\n        uint256 minSharesOut\n    ) external payable returns (uint256 sharesOut);\n\n    /*//////////////////////////////////////////////////////////////\n                                REDEEM\n    //////////////////////////////////////////////////////////////*/\n\n    /** \n     @notice redeem `shares` shares from an ERC4626 vault.\n     @dev Uses the Yearn specific 'maxLoss' accounting.\n     @param vault The ERC4626 vault to redeem shares from.\n     @param shares The amount of shares to redeem from vault.\n     @param to The destination of assets.\n     @param maxLoss The acceptable loss in Basis Points.\n     @return amountOut the amount of assets received by `to`.\n     @dev throws \"to much loss\" Error   \n    */\n    function redeem(\n        IYearn4626 vault,\n        uint256 shares,\n        address to,\n        uint256 maxLoss\n    ) external payable returns (uint256);\n\n    /** \n     @notice redeem `shares` shares from an ERC4626 vault.\n     @dev Uses the default 4626 syntax, throws \"!minAmount\" Error.\n     @param vault The ERC4626 vault to redeem shares from.\n     @param shares The amount of shares to redeem from vault.\n     @param to The destination of assets.\n     @param minAmountOut The min amount of assets received by `to`.\n     @return amountOut the amount of assets received by `to`.\n    */\n    function redeemDefault(\n        IYearn4626 vault,\n        uint256 shares,\n        address to,\n        uint256 minAmountOut\n    ) external payable returns (uint256 amountOut);\n}\n"
      },
      "lib/permit2/lib/solmate/src/tokens/ERC20.sol": {
        "content": "// SPDX-License-Identifier: AGPL-3.0-only\npragma solidity >=0.8.0;\n\n/// @notice Modern and gas efficient ERC20 + EIP-2612 implementation.\n/// @author Solmate (https://github.com/transmissions11/solmate/blob/main/src/tokens/ERC20.sol)\n/// @author Modified from Uniswap (https://github.com/Uniswap/uniswap-v2-core/blob/master/contracts/UniswapV2ERC20.sol)\n/// @dev Do not manually set balances without updating totalSupply, as the sum of all user balances must not exceed it.\nabstract contract ERC20 {\n    /*//////////////////////////////////////////////////////////////\n                                 EVENTS\n    //////////////////////////////////////////////////////////////*/\n\n    event Transfer(address indexed from, address indexed to, uint256 amount);\n\n    event Approval(address indexed owner, address indexed spender, uint256 amount);\n\n    /*//////////////////////////////////////////////////////////////\n                            METADATA STORAGE\n    //////////////////////////////////////////////////////////////*/\n\n    string public name;\n\n    string public symbol;\n\n    uint8 public immutable decimals;\n\n    /*//////////////////////////////////////////////////////////////\n                              ERC20 STORAGE\n    //////////////////////////////////////////////////////////////*/\n\n    uint256 public totalSupply;\n\n    mapping(address => uint256) public balanceOf;\n\n    mapping(address => mapping(address => uint256)) public allowance;\n\n    /*//////////////////////////////////////////////////////////////\n                            EIP-2612 STORAGE\n    //////////////////////////////////////////////////////////////*/\n\n    uint256 internal immutable INITIAL_CHAIN_ID;\n\n    bytes32 internal immutable INITIAL_DOMAIN_SEPARATOR;\n\n    mapping(address => uint256) public nonces;\n\n    /*//////////////////////////////////////////////////////////////\n                               CONSTRUCTOR\n    //////////////////////////////////////////////////////////////*/\n\n    constructor(\n        string memory _name,\n        string memory _symbol,\n        uint8 _decimals\n    ) {\n        name = _name;\n        symbol = _symbol;\n        decimals = _decimals;\n\n        INITIAL_CHAIN_ID = block.chainid;\n        INITIAL_DOMAIN_SEPARATOR = computeDomainSeparator();\n    }\n\n    /*//////////////////////////////////////////////////////////////\n                               ERC20 LOGIC\n    //////////////////////////////////////////////////////////////*/\n\n    function approve(address spender, uint256 amount) public virtual returns (bool) {\n        allowance[msg.sender][spender] = amount;\n\n        emit Approval(msg.sender, spender, amount);\n\n        return true;\n    }\n\n    function transfer(address to, uint256 amount) public virtual returns (bool) {\n        balanceOf[msg.sender] -= amount;\n\n        // Cannot overflow because the sum of all user\n        // balances can't exceed the max uint256 value.\n        unchecked {\n            balanceOf[to] += amount;\n        }\n\n        emit Transfer(msg.sender, to, amount);\n\n        return true;\n    }\n\n    function transferFrom(\n        address from,\n        address to,\n        uint256 amount\n    ) public virtual returns (bool) {\n        uint256 allowed = allowance[from][msg.sender]; // Saves gas for limited approvals.\n\n        if (allowed != type(uint256).max) allowance[from][msg.sender] = allowed - amount;\n\n        balanceOf[from] -= amount;\n\n        // Cannot overflow because the sum of all user\n        // balances can't exceed the max uint256 value.\n        unchecked {\n            balanceOf[to] += amount;\n        }\n\n        emit Transfer(from, to, amount);\n\n        return true;\n    }\n\n    /*//////////////////////////////////////////////////////////////\n                             EIP-2612 LOGIC\n    //////////////////////////////////////////////////////////////*/\n\n    function permit(\n        address owner,\n        address spender,\n        uint256 value,\n        uint256 deadline,\n        uint8 v,\n        bytes32 r,\n        bytes32 s\n    ) public virtual {\n        require(deadline >= block.timestamp, \"PERMIT_DEADLINE_EXPIRED\");\n\n        // Unchecked because the only math done is incrementing\n        // the owner's nonce which cannot realistically overflow.\n        unchecked {\n            address recoveredAddress = ecrecover(\n                keccak256(\n                    abi.encodePacked(\n                        \"\\x19\\x01\",\n                        DOMAIN_SEPARATOR(),\n                        keccak256(\n                            abi.encode(\n                                keccak256(\n                                    \"Permit(address owner,address spender,uint256 value,uint256 nonce,uint256 deadline)\"\n                                ),\n                                owner,\n                                spender,\n                                value,\n                                nonces[owner]++,\n                                deadline\n                            )\n                        )\n                    )\n                ),\n                v,\n                r,\n                s\n            );\n\n            require(recoveredAddress != address(0) && recoveredAddress == owner, \"INVALID_SIGNER\");\n\n            allowance[recoveredAddress][spender] = value;\n        }\n\n        emit Approval(owner, spender, value);\n    }\n\n    function DOMAIN_SEPARATOR() public view virtual returns (bytes32) {\n        return block.chainid == INITIAL_CHAIN_ID ? INITIAL_DOMAIN_SEPARATOR : computeDomainSeparator();\n    }\n\n    function computeDomainSeparator() internal view virtual returns (bytes32) {\n        return\n            keccak256(\n                abi.encode(\n                    keccak256(\"EIP712Domain(string name,string version,uint256 chainId,address verifyingContract)\"),\n                    keccak256(bytes(name)),\n                    keccak256(\"1\"),\n                    block.chainid,\n                    address(this)\n                )\n            );\n    }\n\n    /*//////////////////////////////////////////////////////////////\n                        INTERNAL MINT/BURN LOGIC\n    //////////////////////////////////////////////////////////////*/\n\n    function _mint(address to, uint256 amount) internal virtual {\n        totalSupply += amount;\n\n        // Cannot overflow because the sum of all user\n        // balances can't exceed the max uint256 value.\n        unchecked {\n            balanceOf[to] += amount;\n        }\n\n        emit Transfer(address(0), to, amount);\n    }\n\n    function _burn(address from, uint256 amount) internal virtual {\n        balanceOf[from] -= amount;\n\n        // Cannot underflow because a user's balance\n        // will never be larger than the total supply.\n        unchecked {\n            totalSupply -= amount;\n        }\n\n        emit Transfer(from, address(0), amount);\n    }\n}\n"
      },
      "lib/Yearn-ERC4626-Router/src/external/SelfPermit.sol": {
        "content": "// SPDX-License-Identifier: GPL-2.0-or-later\npragma solidity >=0.5.0;\n\nimport {ERC20} from \"solmate/tokens/ERC20.sol\";\n\nimport \"./interfaces/ISelfPermit.sol\";\nimport \"./interfaces/IERC20PermitAllowed.sol\";\n\n/// @title Self Permit\n/// @notice Functionality to call permit on any EIP-2612-compliant token for use in the route\n/// @dev These functions are expected to be embedded in multicalls to allow EOAs to approve a contract and call a function\n/// that requires an approval in a single transaction.\nabstract contract SelfPermit is ISelfPermit {\n    /// @inheritdoc ISelfPermit\n    function selfPermit(\n        address token,\n        uint256 value,\n        uint256 deadline,\n        uint8 v,\n        bytes32 r,\n        bytes32 s\n    ) public payable override {\n        ERC20(token).permit(msg.sender, address(this), value, deadline, v, r, s);\n    }\n\n    /// @inheritdoc ISelfPermit\n    function selfPermitIfNecessary(\n        address token,\n        uint256 value,\n        uint256 deadline,\n        uint8 v,\n        bytes32 r,\n        bytes32 s\n    ) external payable override {\n        if (ERC20(token).allowance(msg.sender, address(this)) < value) selfPermit(token, value, deadline, v, r, s);\n    }\n\n    /// @inheritdoc ISelfPermit\n    function selfPermitAllowed(\n        address token,\n        uint256 nonce,\n        uint256 expiry,\n        uint8 v,\n        bytes32 r,\n        bytes32 s\n    ) public payable override {\n        IERC20PermitAllowed(token).permit(msg.sender, address(this), nonce, expiry, true, v, r, s);\n    }\n\n    /// @inheritdoc ISelfPermit\n    function selfPermitAllowedIfNecessary(\n        address token,\n        uint256 nonce,\n        uint256 expiry,\n        uint8 v,\n        bytes32 r,\n        bytes32 s\n    ) external payable override {\n        if (ERC20(token).allowance(msg.sender, address(this)) < type(uint256).max)\n            selfPermitAllowed(token, nonce, expiry, v, r, s);\n    }\n}\n"
      },
      "lib/Yearn-ERC4626-Router/src/external/Multicall.sol": {
        "content": "// forked from https://github.com/Uniswap/v3-periphery/blob/main/contracts/base/Multicall.sol\n\n// SPDX-License-Identifier: GPL-2.0-or-later\npragma solidity >=0.7.6;\n\nimport \"./interfaces/IMulticall.sol\";\n\n/// @title Multicall\n/// @notice Enables calling multiple methods in a single call to the contract\nabstract contract Multicall is IMulticall {\n    /// @inheritdoc IMulticall\n    function multicall(bytes[] calldata data) public payable override returns (bytes[] memory results) {\n        results = new bytes[](data.length);\n        for (uint256 i = 0; i < data.length; i++) {\n            (bool success, bytes memory result) = address(this).delegatecall(data[i]);\n\n            if (!success) {\n                // Next 5 lines from https://ethereum.stackexchange.com/a/83577\n                if (result.length < 68) revert();\n                assembly {\n                    result := add(result, 0x04)\n                }\n                revert(abi.decode(result, (string)));\n            }\n\n            results[i] = result;\n        }\n    }\n}\n"
      },
      "lib/Yearn-ERC4626-Router/src/interfaces/IYearn4626.sol": {
        "content": "// SPDX-License-Identifier: GPL-2.0-or-later\npragma solidity 0.8.18;\n\nimport {IERC4626} from \"./IERC4626.sol\";\n\n/// @title Yearn V3 ERC4626 interface\n/// @notice Extends the normal 4626 standard with some added Yearn specific functionality\nabstract contract IYearn4626 is IERC4626 {\n    /*////////////////////////////////////////////////////////\n                    Yearn Specific Functions\n    ////////////////////////////////////////////////////////*/\n\n    function withdraw(\n        uint256 assets,\n        address receiver,\n        address owner,\n        uint256 maxLoss\n    ) external virtual returns (uint256 shares);\n\n    /// @notice Yearn Specific \"withdraw\" with withdrawal stack included\n    function withdraw(\n        uint256 assets,\n        address receiver,\n        address owner,\n        uint256 maxLoss,\n        address[] memory strategies\n    ) external virtual returns (uint256 shares);\n\n    function redeem(\n        uint256 shares,\n        address receiver,\n        address owner,\n        uint256 maxLoss\n    ) external virtual returns (uint256 assets);\n\n    /// @notice Yearn Specific \"redeem\" with withdrawal stack included\n    function redeem(\n        uint256 shares,\n        address receiver,\n        address owner,\n        uint256 maxLoss,\n        address[] memory strategies\n    ) external virtual returns (uint256 assets);\n}\n"
      },
      "lib/Yearn-ERC4626-Router/src/interfaces/IYearnV2.sol": {
        "content": "// SPDX-License-Identifier: GPL-2.0-or-later\npragma solidity 0.8.18;\n\nimport {ERC20} from \"solmate/tokens/ERC20.sol\";\n\nabstract contract IYearnV2 is ERC20 {\n    // NOTE: Vyper produces multiple signatures for a given function with \"default\" args\n    function withdraw() external virtual returns (uint256);\n\n    function withdraw(uint256 maxShares) external virtual returns (uint256);\n\n    function withdraw(uint256 maxShares, address recipient) external virtual returns (uint256);\n\n    function withdraw(\n        uint256 maxShares,\n        address recipient,\n        uint256 maxLoss\n    ) external virtual returns (uint256);\n}\n"
      },
      "lib/Yearn-ERC4626-Router/src/external/interfaces/ISelfPermit.sol": {
        "content": "// forked from https://github.com/Uniswap/v3-periphery/blob/main/contracts/interfaces/ISelfPermit.sol\n\n// SPDX-License-Identifier: GPL-2.0-or-later\npragma solidity >=0.7.5;\n\n/// @title Self Permit\n/// @notice Functionality to call permit on any EIP-2612-compliant token for use in the route\ninterface ISelfPermit {\n    /// @notice Permits this contract to spend a given token from `msg.sender`\n    /// @dev The `owner` is always msg.sender and the `spender` is always address(this).\n    /// @param token The address of the token spent\n    /// @param value The amount that can be spent of token\n    /// @param deadline A timestamp, the current blocktime must be less than or equal to this timestamp\n    /// @param v Must produce valid secp256k1 signature from the holder along with `r` and `s`\n    /// @param r Must produce valid secp256k1 signature from the holder along with `v` and `s`\n    /// @param s Must produce valid secp256k1 signature from the holder along with `r` and `v`\n    function selfPermit(\n        address token,\n        uint256 value,\n        uint256 deadline,\n        uint8 v,\n        bytes32 r,\n        bytes32 s\n    ) external payable;\n\n    /// @notice Permits this contract to spend a given token from `msg.sender`\n    /// @dev The `owner` is always msg.sender and the `spender` is always address(this).\n    /// Can be used instead of #selfPermit to prevent calls from failing due to a frontrun of a call to #selfPermit\n    /// @param token The address of the token spent\n    /// @param value The amount that can be spent of token\n    /// @param deadline A timestamp, the current blocktime must be less than or equal to this timestamp\n    /// @param v Must produce valid secp256k1 signature from the holder along with `r` and `s`\n    /// @param r Must produce valid secp256k1 signature from the holder along with `v` and `s`\n    /// @param s Must produce valid secp256k1 signature from the holder along with `r` and `v`\n    function selfPermitIfNecessary(\n        address token,\n        uint256 value,\n        uint256 deadline,\n        uint8 v,\n        bytes32 r,\n        bytes32 s\n    ) external payable;\n\n    /// @notice Permits this contract to spend the sender's tokens for permit signatures that have the `allowed` parameter\n    /// @dev The `owner` is always msg.sender and the `spender` is always address(this)\n    /// @param token The address of the token spent\n    /// @param nonce The current nonce of the owner\n    /// @param expiry The timestamp at which the permit is no longer valid\n    /// @param v Must produce valid secp256k1 signature from the holder along with `r` and `s`\n    /// @param r Must produce valid secp256k1 signature from the holder along with `v` and `s`\n    /// @param s Must produce valid secp256k1 signature from the holder along with `r` and `v`\n    function selfPermitAllowed(\n        address token,\n        uint256 nonce,\n        uint256 expiry,\n        uint8 v,\n        bytes32 r,\n        bytes32 s\n    ) external payable;\n\n    /// @notice Permits this contract to spend the sender's tokens for permit signatures that have the `allowed` parameter\n    /// @dev The `owner` is always msg.sender and the `spender` is always address(this)\n    /// Can be used instead of #selfPermitAllowed to prevent calls from failing due to a frontrun of a call to #selfPermitAllowed.\n    /// @param token The address of the token spent\n    /// @param nonce The current nonce of the owner\n    /// @param expiry The timestamp at which the permit is no longer valid\n    /// @param v Must produce valid secp256k1 signature from the holder along with `r` and `s`\n    /// @param r Must produce valid secp256k1 signature from the holder along with `v` and `s`\n    /// @param s Must produce valid secp256k1 signature from the holder along with `r` and `v`\n    function selfPermitAllowedIfNecessary(\n        address token,\n        uint256 nonce,\n        uint256 expiry,\n        uint8 v,\n        bytes32 r,\n        bytes32 s\n    ) external payable;\n}\n"
      },
      "lib/Yearn-ERC4626-Router/src/external/interfaces/IERC20PermitAllowed.sol": {
        "content": "// forked from https://github.com/Uniswap/v3-periphery/blob/main/contracts/interfaces/external/IERC20PermitAllowed.sol\n\n// SPDX-License-Identifier: GPL-2.0-or-later\npragma solidity >=0.5.0;\n\n/// @title Interface for permit\n/// @notice Interface used by DAI/CHAI for permit\ninterface IERC20PermitAllowed {\n    /// @notice Approve the spender to spend some tokens via the holder signature\n    /// @dev This is the permit interface used by DAI and CHAI\n    /// @param holder The address of the token holder, the token owner\n    /// @param spender The address of the token spender\n    /// @param nonce The holder's nonce, increases at each call to permit\n    /// @param expiry The timestamp at which the permit is no longer valid\n    /// @param allowed Boolean that sets approval amount, true for type(uint256).max and false for 0\n    /// @param v Must produce valid secp256k1 signature from the holder along with `r` and `s`\n    /// @param r Must produce valid secp256k1 signature from the holder along with `v` and `s`\n    /// @param s Must produce valid secp256k1 signature from the holder along with `r` and `v`\n    function permit(\n        address holder,\n        address spender,\n        uint256 nonce,\n        uint256 expiry,\n        bool allowed,\n        uint8 v,\n        bytes32 r,\n        bytes32 s\n    ) external;\n}\n"
      },
      "lib/Yearn-ERC4626-Router/src/external/interfaces/IMulticall.sol": {
        "content": "// forked from https://github.com/Uniswap/v3-periphery/blob/main/contracts/interfaces/IMulticall.sol\n\n// SPDX-License-Identifier: GPL-2.0-or-later\npragma solidity >=0.7.5;\n\n/// @title Multicall interface\n/// @notice Enables calling multiple methods in a single call to the contract\ninterface IMulticall {\n    /// @notice Call multiple functions in the current contract and return the data from all of them if they all succeed\n    /// @dev The `msg.value` should not be trusted for any method callable from multicall.\n    /// @param data The encoded function data for each of the calls to make to this contract\n    /// @return results The results from each of the calls passed in via data\n    function multicall(bytes[] calldata data) external payable returns (bytes[] memory results);\n}\n"
      },
      "lib/Yearn-ERC4626-Router/src/interfaces/IERC4626.sol": {
        "content": "// SPDX-License-Identifier: GPL-2.0-or-later\npragma solidity 0.8.18;\n\nimport {ERC20} from \"solmate/tokens/ERC20.sol\";\n\n/// @title ERC4626 interface\n/// See: https://eips.ethereum.org/EIPS/eip-4626\nabstract contract IERC4626 is ERC20 {\n    /*////////////////////////////////////////////////////////\n                      Events\n    ////////////////////////////////////////////////////////*/\n\n    /// @notice `sender` has exchanged `assets` for `shares`,\n    /// and transferred those `shares` to `receiver`.\n    event Deposit(address indexed sender, address indexed receiver, uint256 assets, uint256 shares);\n\n    /// @notice `sender` has exchanged `shares` for `assets`,\n    /// and transferred those `assets` to `receiver`.\n    event Withdraw(address indexed sender, address indexed receiver, uint256 assets, uint256 shares);\n\n    /*////////////////////////////////////////////////////////\n                      Vault properties\n    ////////////////////////////////////////////////////////*/\n\n    /// @notice The address of the underlying ERC20 token used for\n    /// the Vault for accounting, depositing, and withdrawing.\n    function asset() external view virtual returns (address asset);\n\n    /// @notice Total amount of the underlying asset that\n    /// is \"managed\" by Vault.\n    function totalAssets() external view virtual returns (uint256 totalAssets);\n\n    /*////////////////////////////////////////////////////////\n                      Deposit/Withdrawal Logic\n    ////////////////////////////////////////////////////////*/\n\n    /// @notice Mints `shares` Vault shares to `receiver` by\n    /// depositing exactly `assets` of underlying tokens.\n    function deposit(uint256 assets, address receiver) external virtual returns (uint256 shares);\n\n    /// @notice Mints exactly `shares` Vault shares to `receiver`\n    /// by depositing `assets` of underlying tokens.\n    function mint(uint256 shares, address receiver) external virtual returns (uint256 assets);\n\n    /// @notice Redeems `shares` from `owner` and sends `assets`\n    /// of underlying tokens to `receiver`.\n    function withdraw(\n        uint256 assets,\n        address receiver,\n        address owner\n    ) external virtual returns (uint256 shares);\n\n    /// @notice Redeems `shares` from `owner` and sends `assets`\n    /// of underlying tokens to `receiver`.\n    function redeem(\n        uint256 shares,\n        address receiver,\n        address owner\n    ) external virtual returns (uint256 assets);\n\n    /*////////////////////////////////////////////////////////\n                      Vault Accounting Logic\n    ////////////////////////////////////////////////////////*/\n\n    /// @notice The amount of shares that the vault would\n    /// exchange for the amount of assets provided, in an\n    /// ideal scenario where all the conditions are met.\n    function convertToShares(uint256 assets) external view virtual returns (uint256 shares);\n\n    /// @notice The amount of assets that the vault would\n    /// exchange for the amount of shares provided, in an\n    /// ideal scenario where all the conditions are met.\n    function convertToAssets(uint256 shares) external view virtual returns (uint256 assets);\n\n    /// @notice Total number of underlying assets that can\n    /// be deposited by `owner` into the Vault, where `owner`\n    /// corresponds to the input parameter `receiver` of a\n    /// `deposit` call.\n    function maxDeposit(address owner) external view virtual returns (uint256 maxAssets);\n\n    /// @notice Allows an on-chain or off-chain user to simulate\n    /// the effects of their deposit at the current block, given\n    /// current on-chain conditions.\n    function previewDeposit(uint256 assets) external view virtual returns (uint256 shares);\n\n    /// @notice Total number of underlying shares that can be minted\n    /// for `owner`, where `owner` corresponds to the input\n    /// parameter `receiver` of a `mint` call.\n    function maxMint(address owner) external view virtual returns (uint256 maxShares);\n\n    /// @notice Allows an on-chain or off-chain user to simulate\n    /// the effects of their mint at the current block, given\n    /// current on-chain conditions.\n    function previewMint(uint256 shares) external view virtual returns (uint256 assets);\n\n    /// @notice Total number of underlying assets that can be\n    /// withdrawn from the Vault by `owner`, where `owner`\n    /// corresponds to the input parameter of a `withdraw` call.\n    function maxWithdraw(address owner) external view virtual returns (uint256 maxAssets);\n\n    /// @notice Allows an on-chain or off-chain user to simulate\n    /// the effects of their withdrawal at the current block,\n    /// given current on-chain conditions.\n    function previewWithdraw(uint256 assets) external view virtual returns (uint256 shares);\n\n    /// @notice Total number of underlying shares that can be\n    /// redeemed from the Vault by `owner`, where `owner` corresponds\n    /// to the input parameter of a `redeem` call.\n    function maxRedeem(address owner) external view virtual returns (uint256 maxShares);\n\n    /// @notice Allows an on-chain or off-chain user to simulate\n    /// the effects of their redeemption at the current block,\n    /// given current on-chain conditions.\n    function previewRedeem(uint256 shares) external view virtual returns (uint256 assets);\n}\n"
      }
    },
    "settings": {
      "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": {}
    }
  }}