creation_sourcecode: {{
    "language": "Solidity",
    "sources": {
      "contracts/swapper/LevSwapper/morpho/implementations/ERC4626LevSwapperMorphoGauntletUSDCPrime.sol": {
        "content": "// SPDX-License-Identifier: GPL-3.0\npragma solidity ^0.8.17;\n\nimport \"borrow-staked/swapper/LevSwapper/ERC4626LevSwapper.sol\";\n\n/// @author Angle Labs, Inc.\n/// @notice Gauntlet USDC Prime Leverage swapper\ncontract ERC4626LevSwapperMorphoGauntletUSDCPrime is ERC4626LevSwapper {\n    constructor(\n        ICoreBorrow _core,\n        IUniswapV3Router _uniV3Router,\n        address _aggregator,\n        IAngleRouterSidechain _angleRouter,\n        IMorphoBase _morpho\n    ) ERC4626LevSwapper(_core, _uniV3Router, _aggregator, _angleRouter, _morpho) {}\n\n    /// @inheritdoc BaseLevSwapper\n    function angleStaker() public pure override returns (IBorrowStaker) {\n        return IBorrowStaker(address(0));\n    }\n\n    /// @inheritdoc ERC4626LevSwapper\n    function asset() public pure override returns (IERC20) {\n        return IERC20(address(0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48));\n    }\n\n    /// @inheritdoc ERC4626LevSwapper\n    function token() public pure override returns (IERC4626) {\n        return IERC4626(address(0xdd0f28e19C1780eb6396170735D45153D261490d));\n    }\n}\n"
      },
      "contracts/swapper/LevSwapper/ERC4626LevSwapper.sol": {
        "content": "// SPDX-License-Identifier: GPL-3.0\npragma solidity ^0.8.17;\n\nimport \"borrow-staked/swapper/LevSwapper/BaseLevSwapperMorpho.sol\";\nimport \"@openzeppelin/contracts/interfaces/IERC4626.sol\";\n\n/// @title ERC4626LevSwapper\n/// @author Angle Labs, Inc.\n/// @dev Leverage Swapper on SanTokens\nabstract contract ERC4626LevSwapper is BaseLevSwapperMorpho {\n    using SafeERC20 for IERC20;\n\n    constructor(\n        ICoreBorrow _core,\n        IUniswapV3Router _uniV3Router,\n        address _aggregator,\n        IAngleRouterSidechain _angleRouter,\n        IMorphoBase _morpho\n    ) BaseLevSwapperMorpho(_core, _uniV3Router, _aggregator, _angleRouter, _morpho) {\n        if (address(asset()) != address(0)) {\n            asset().safeIncreaseAllowance(address(token()), type(uint256).max);\n        }\n    }\n\n    // =============================== MAIN FUNCTIONS ==============================\n\n    /// @inheritdoc BaseLevSwapper\n    function _add(bytes memory) internal override returns (uint256 amountOut) {\n        uint256 amount = asset().balanceOf(address(this));\n        // It needs to be deposited directly onto `YT`contracts to mint both PT and YT tokens\n        amountOut = token().deposit(amount, address(this));\n    }\n\n    /// @inheritdoc BaseLevSwapper\n    function _remove(uint256 amount, bytes memory data) internal override {\n        uint256 minAmountOut = abi.decode(data, (uint256));\n        uint256 amountOut = token().redeem(amount, address(this), address(this));\n        // We let this check because the caller may swap part of the tokens received and therefore\n        // the check in the base swapper will only be for the out token\n        if (amountOut < minAmountOut) revert TooSmallAmountOut();\n    }\n\n    // ============================= VIRTUAL FUNCTIONS =============================\n\n    /// @notice Reference to the underlying asset\n    function asset() public pure virtual returns (IERC20);\n\n    /// @notice Reference to the erc4626 wrapper\n    function token() public pure virtual returns (IERC4626);\n}\n"
      },
      "contracts/swapper/LevSwapper/BaseLevSwapperMorpho.sol": {
        "content": "// SPDX-License-Identifier: GPL-3.0\npragma solidity ^0.8.17;\n\nimport { IMorphoLiquidateCallback } from \"morpho-blue/interfaces/IMorphoCallbacks.sol\";\nimport { MarketParams } from \"morpho-blue/libraries/MarketParamsLib.sol\";\nimport { IMorphoBase } from \"morpho-blue/interfaces/IMorpho.sol\";\n\nimport \"borrow-staked/swapper/LevSwapper/BaseLevSwapper.sol\";\n\n/// @title BaseLevSwapper\n/// @author Angle Labs, Inc.\n/// @notice Swapper contract facilitating interactions with Angle VaultManager contracts, notably\n/// liquidation and leverage transactions\n/// @dev This base implementation is for tokens like LP tokens which are not natively supported by `aggregator`\n/// and need some wrapping/unwrapping\nabstract contract BaseLevSwapperMorpho is BaseLevSwapper, IMorphoLiquidateCallback {\n    using SafeERC20 for IERC20;\n\n    IMorphoBase public morpho;\n\n    error NotTrusted();\n\n    constructor(\n        ICoreBorrow _core,\n        IUniswapV3Router _uniV3Router,\n        address _aggregator,\n        IAngleRouterSidechain _angleRouter,\n        IMorphoBase _morpho\n    ) BaseLevSwapper(_core, _uniV3Router, _aggregator, _angleRouter) {\n        morpho = _morpho;\n    }\n\n    /*//////////////////////////////////////////////////////////////////////////////////////////////////////////////////\n                                                    MORPHO RELATED                                                  \n    //////////////////////////////////////////////////////////////////////////////////////////////////////////////////*/\n\n    /// @dev This function liquidate a position on Morpho Blue via a flashloan\n    /// It leverages the previous infrastructure on Angle Borrowing module to liquidate atomically\n    function liquidate(\n        MarketParams memory marketParams,\n        address borrower,\n        uint256 seizedAssets,\n        bytes calldata data\n    ) external {\n        morpho.liquidate(marketParams, borrower, seizedAssets, 0, data);\n    }\n\n    function onMorphoLiquidate(uint256 repaidOutToken, bytes memory data) external {\n        if (msg.sender != address(morpho)) revert NotTrusted();\n        IERC20 inToken;\n        IERC20 outToken;\n        uint256 inTokenObtained;\n        (inToken, outToken, inTokenObtained, data) = abi.decode(data, (IERC20, IERC20, uint256, bytes));\n\n        // Address to receive the surplus amount of token at the end of the call\n        address to;\n        // For slippage protection, it is checked at the end of the call\n        uint256 minAmountOut;\n        // Type of the swap to execute: if `swapType == 4`, then it is optional to swap\n        uint256 swapType;\n        // We're reusing the `data` variable (it can be `path` on UniswapV3, a payload for `aggregator` or like encoded actions\n        // for a router call)\n        (to, minAmountOut, swapType, data) = abi.decode(data, (address, uint256, uint256, bytes));\n\n        _swap(inToken, inTokenObtained, SwapType(swapType), data);\n\n        // A final slippage check is performed after the swaps\n        uint256 outTokenBalance = outToken.balanceOf(address(this));\n        if (outTokenBalance < minAmountOut) revert TooSmallAmountOut();\n\n        if (outTokenBalance > repaidOutToken) {\n            // The `to` should keep the additional collateral\n            outToken.safeTransfer(to, outTokenBalance - repaidOutToken);\n        }\n        // Reusing the `inTokenObtained` variable for the `inToken` balance\n        // Sending back the remaining amount of inTokens to the `to` address: it is possible that not the full `inTokenObtained`\n        // is swapped to `outToken` if we're using the `aggregator` payload\n        inTokenObtained = inToken.balanceOf(address(this));\n        if (inTokenObtained != 0) inToken.safeTransfer(to, inTokenObtained);\n\n        // We need to pay back Morpho flashloan\n        outToken.safeIncreaseAllowance(address(morpho), repaidOutToken);\n    }\n\n    /*//////////////////////////////////////////////////////////////////////////////////////////////////////////////////\n                                                 GOVERNANCE FUNCTIONS                                               \n    //////////////////////////////////////////////////////////////////////////////////////////////////////////////////*/\n\n    /// @notice Changes morpho endpoint\n    function updateMorpho(IMorphoBase _morpho) external {\n        if (!core.isGovernorOrGuardian(msg.sender)) revert NotGovernorOrGuardian();\n        if (address(_morpho) == address(0) || morpho == _morpho) revert ZeroAddress();\n        morpho = _morpho;\n    }\n}\n"
      },
      "node_modules/@openzeppelin/contracts/interfaces/IERC4626.sol": {
        "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.7.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 caller, address indexed owner, uint256 assets, uint256 shares);\n\n    event Withdraw(\n        address indexed caller,\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(\n        uint256 assets,\n        address receiver,\n        address owner\n    ) 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(\n        uint256 shares,\n        address receiver,\n        address owner\n    ) external returns (uint256 assets);\n}\n"
      },
      "lib/morpho-blue/src/interfaces/IMorphoCallbacks.sol": {
        "content": "// SPDX-License-Identifier: GPL-2.0-or-later\npragma solidity >=0.5.0;\n\n/// @title IMorphoLiquidateCallback\n/// @notice Interface that liquidators willing to use `liquidate`'s callback must implement.\ninterface IMorphoLiquidateCallback {\n    /// @notice Callback called when a liquidation occurs.\n    /// @dev The callback is called only if data is not empty.\n    /// @param repaidAssets The amount of repaid assets.\n    /// @param data Arbitrary data passed to the `liquidate` function.\n    function onMorphoLiquidate(uint256 repaidAssets, bytes calldata data) external;\n}\n\n/// @title IMorphoRepayCallback\n/// @notice Interface that users willing to use `repay`'s callback must implement.\ninterface IMorphoRepayCallback {\n    /// @notice Callback called when a repayment occurs.\n    /// @dev The callback is called only if data is not empty.\n    /// @param assets The amount of repaid assets.\n    /// @param data Arbitrary data passed to the `repay` function.\n    function onMorphoRepay(uint256 assets, bytes calldata data) external;\n}\n\n/// @title IMorphoSupplyCallback\n/// @notice Interface that users willing to use `supply`'s callback must implement.\ninterface IMorphoSupplyCallback {\n    /// @notice Callback called when a supply occurs.\n    /// @dev The callback is called only if data is not empty.\n    /// @param assets The amount of supplied assets.\n    /// @param data Arbitrary data passed to the `supply` function.\n    function onMorphoSupply(uint256 assets, bytes calldata data) external;\n}\n\n/// @title IMorphoSupplyCollateralCallback\n/// @notice Interface that users willing to use `supplyCollateral`'s callback must implement.\ninterface IMorphoSupplyCollateralCallback {\n    /// @notice Callback called when a supply of collateral occurs.\n    /// @dev The callback is called only if data is not empty.\n    /// @param assets The amount of supplied collateral.\n    /// @param data Arbitrary data passed to the `supplyCollateral` function.\n    function onMorphoSupplyCollateral(uint256 assets, bytes calldata data) external;\n}\n\n/// @title IMorphoFlashLoanCallback\n/// @notice Interface that users willing to use `flashLoan`'s callback must implement.\ninterface IMorphoFlashLoanCallback {\n    /// @notice Callback called when a flash loan occurs.\n    /// @dev The callback is called only if data is not empty.\n    /// @param assets The amount of assets that was flash loaned.\n    /// @param data Arbitrary data passed to the `flashLoan` function.\n    function onMorphoFlashLoan(uint256 assets, bytes calldata data) external;\n}\n"
      },
      "lib/morpho-blue/src/libraries/MarketParamsLib.sol": {
        "content": "// SPDX-License-Identifier: GPL-2.0-or-later\npragma solidity ^0.8.0;\n\nimport {Id, MarketParams} from \"../interfaces/IMorpho.sol\";\n\n/// @title MarketParamsLib\n/// @author Morpho Labs\n/// @custom:contact security@morpho.org\n/// @notice Library to convert a market to its id.\nlibrary MarketParamsLib {\n    /// @notice The length of the data used to compute the id of a market.\n    /// @dev The length is 5 * 32 because `MarketParams` has 5 variables of 32 bytes each.\n    uint256 internal constant MARKET_PARAMS_BYTES_LENGTH = 5 * 32;\n\n    /// @notice Returns the id of the market `marketParams`.\n    function id(MarketParams memory marketParams) internal pure returns (Id marketParamsId) {\n        assembly (\"memory-safe\") {\n            marketParamsId := keccak256(marketParams, MARKET_PARAMS_BYTES_LENGTH)\n        }\n    }\n}\n"
      },
      "lib/morpho-blue/src/interfaces/IMorpho.sol": {
        "content": "// SPDX-License-Identifier: GPL-2.0-or-later\npragma solidity >=0.5.0;\n\ntype Id is bytes32;\n\nstruct MarketParams {\n    address loanToken;\n    address collateralToken;\n    address oracle;\n    address irm;\n    uint256 lltv;\n}\n\n/// @dev Warning: For `feeRecipient`, `supplyShares` does not contain the accrued shares since the last interest\n/// accrual.\nstruct Position {\n    uint256 supplyShares;\n    uint128 borrowShares;\n    uint128 collateral;\n}\n\n/// @dev Warning: `totalSupplyAssets` does not contain the accrued interest since the last interest accrual.\n/// @dev Warning: `totalBorrowAssets` does not contain the accrued interest since the last interest accrual.\n/// @dev Warning: `totalSupplyShares` does not contain the additional shares accrued by `feeRecipient` since the last\n/// interest accrual.\nstruct Market {\n    uint128 totalSupplyAssets;\n    uint128 totalSupplyShares;\n    uint128 totalBorrowAssets;\n    uint128 totalBorrowShares;\n    uint128 lastUpdate;\n    uint128 fee;\n}\n\nstruct Authorization {\n    address authorizer;\n    address authorized;\n    bool isAuthorized;\n    uint256 nonce;\n    uint256 deadline;\n}\n\nstruct Signature {\n    uint8 v;\n    bytes32 r;\n    bytes32 s;\n}\n\n/// @dev This interface is used for factorizing IMorphoStaticTyping and IMorpho.\n/// @dev Consider using the IMorpho interface instead of this one.\ninterface IMorphoBase {\n    /// @notice The EIP-712 domain separator.\n    /// @dev Warning: Every EIP-712 signed message based on this domain separator can be reused on another chain sharing\n    /// the same chain id because the domain separator would be the same.\n    function DOMAIN_SEPARATOR() external view returns (bytes32);\n\n    /// @notice The owner of the contract.\n    /// @dev It has the power to change the owner.\n    /// @dev It has the power to set fees on markets and set the fee recipient.\n    /// @dev It has the power to enable but not disable IRMs and LLTVs.\n    function owner() external view returns (address);\n\n    /// @notice The fee recipient of all markets.\n    /// @dev The recipient receives the fees of a given market through a supply position on that market.\n    function feeRecipient() external view returns (address);\n\n    /// @notice Whether the `irm` is enabled.\n    function isIrmEnabled(address irm) external view returns (bool);\n\n    /// @notice Whether the `lltv` is enabled.\n    function isLltvEnabled(uint256 lltv) external view returns (bool);\n\n    /// @notice Whether `authorized` is authorized to modify `authorizer`'s position on all markets.\n    /// @dev Anyone is authorized to modify their own positions, regardless of this variable.\n    function isAuthorized(address authorizer, address authorized) external view returns (bool);\n\n    /// @notice The `authorizer`'s current nonce. Used to prevent replay attacks with EIP-712 signatures.\n    function nonce(address authorizer) external view returns (uint256);\n\n    /// @notice Sets `newOwner` as `owner` of the contract.\n    /// @dev Warning: No two-step transfer ownership.\n    /// @dev Warning: The owner can be set to the zero address.\n    function setOwner(address newOwner) external;\n\n    /// @notice Enables `irm` as a possible IRM for market creation.\n    /// @dev Warning: It is not possible to disable an IRM.\n    function enableIrm(address irm) external;\n\n    /// @notice Enables `lltv` as a possible LLTV for market creation.\n    /// @dev Warning: It is not possible to disable a LLTV.\n    function enableLltv(uint256 lltv) external;\n\n    /// @notice Sets the `newFee` for the given market `marketParams`.\n    /// @param newFee The new fee, scaled by WAD.\n    /// @dev Warning: The recipient can be the zero address.\n    function setFee(MarketParams memory marketParams, uint256 newFee) external;\n\n    /// @notice Sets `newFeeRecipient` as `feeRecipient` of the fee.\n    /// @dev Warning: If the fee recipient is set to the zero address, fees will accrue there and will be lost.\n    /// @dev Modifying the fee recipient will allow the new recipient to claim any pending fees not yet accrued. To\n    /// ensure that the current recipient receives all due fees, accrue interest manually prior to making any changes.\n    function setFeeRecipient(address newFeeRecipient) external;\n\n    /// @notice Creates the market `marketParams`.\n    /// @dev Here is the list of assumptions on the market's dependencies (tokens, IRM and oracle) that guarantees\n    /// Morpho behaves as expected:\n    /// - The token should be ERC-20 compliant, except that it can omit return values on `transfer` and `transferFrom`.\n    /// - The token balance of Morpho should only decrease on `transfer` and `transferFrom`. In particular, tokens with\n    /// burn functions are not supported.\n    /// - The token should not re-enter Morpho on `transfer` nor `transferFrom`.\n    /// - The token balance of the sender (resp. receiver) should decrease (resp. increase) by exactly the given amount\n    /// on `transfer` and `transferFrom`. In particular, tokens with fees on transfer are not supported.\n    /// - The IRM should not re-enter Morpho.\n    /// - The oracle should return a price with the correct scaling.\n    /// @dev Here is a list of properties on the market's dependencies that could break Morpho's liveness properties\n    /// (funds could get stuck):\n    /// - The token can revert on `transfer` and `transferFrom` for a reason other than an approval or balance issue.\n    /// - A very high amount of assets (~1e35) supplied or borrowed can make the computation of `toSharesUp` and\n    /// `toSharesDown` overflow.\n    /// - The IRM can revert on `borrowRate`.\n    /// - A very high borrow rate returned by the IRM can make the computation of `interest` in `_accrueInterest`\n    /// overflow.\n    /// - The oracle can revert on `price`. Note that this can be used to prevent `borrow`, `withdrawCollateral` and\n    /// `liquidate` from being used under certain market conditions.\n    /// - A very high price returned by the oracle can make the computation of `maxBorrow` in `_isHealthy` overflow, or\n    /// the computation of `assetsRepaid` in `liquidate` overflow.\n    /// @dev The borrow share price of a market with less than 1e4 assets borrowed can be decreased by manipulations, to\n    /// the point where `totalBorrowShares` is very large and borrowing overflows.\n    function createMarket(MarketParams memory marketParams) external;\n\n    /// @notice Supplies `assets` or `shares` on behalf of `onBehalf`, optionally calling back the caller's\n    /// `onMorphoSupply` function with the given `data`.\n    /// @dev Either `assets` or `shares` should be zero. Most use cases should rely on `assets` as an input so the\n    /// caller is guaranteed to have `assets` tokens pulled from their balance, but the possibility to mint a specific\n    /// amount of shares is given for full compatibility and precision.\n    /// @dev Supplying a large amount can revert for overflow.\n    /// @dev Supplying an amount of shares may lead to supply more or fewer assets than expected due to slippage.\n    /// Consider using the `assets` parameter to avoid this.\n    /// @param marketParams The market to supply assets to.\n    /// @param assets The amount of assets to supply.\n    /// @param shares The amount of shares to mint.\n    /// @param onBehalf The address that will own the increased supply position.\n    /// @param data Arbitrary data to pass to the `onMorphoSupply` callback. Pass empty data if not needed.\n    /// @return assetsSupplied The amount of assets supplied.\n    /// @return sharesSupplied The amount of shares minted.\n    function supply(\n        MarketParams memory marketParams,\n        uint256 assets,\n        uint256 shares,\n        address onBehalf,\n        bytes memory data\n    ) external returns (uint256 assetsSupplied, uint256 sharesSupplied);\n\n    /// @notice Withdraws `assets` or `shares` on behalf of `onBehalf` and sends the assets to `receiver`.\n    /// @dev Either `assets` or `shares` should be zero. To withdraw max, pass the `shares`'s balance of `onBehalf`.\n    /// @dev `msg.sender` must be authorized to manage `onBehalf`'s positions.\n    /// @dev Withdrawing an amount corresponding to more shares than supplied will revert for underflow.\n    /// @dev It is advised to use the `shares` input when withdrawing the full position to avoid reverts due to\n    /// conversion roundings between shares and assets.\n    /// @param marketParams The market to withdraw assets from.\n    /// @param assets The amount of assets to withdraw.\n    /// @param shares The amount of shares to burn.\n    /// @param onBehalf The address of the owner of the supply position.\n    /// @param receiver The address that will receive the withdrawn assets.\n    /// @return assetsWithdrawn The amount of assets withdrawn.\n    /// @return sharesWithdrawn The amount of shares burned.\n    function withdraw(\n        MarketParams memory marketParams,\n        uint256 assets,\n        uint256 shares,\n        address onBehalf,\n        address receiver\n    ) external returns (uint256 assetsWithdrawn, uint256 sharesWithdrawn);\n\n    /// @notice Borrows `assets` or `shares` on behalf of `onBehalf` and sends the assets to `receiver`.\n    /// @dev Either `assets` or `shares` should be zero. Most use cases should rely on `assets` as an input so the\n    /// caller is guaranteed to borrow `assets` of tokens, but the possibility to mint a specific amount of shares is\n    /// given for full compatibility and precision.\n    /// @dev `msg.sender` must be authorized to manage `onBehalf`'s positions.\n    /// @dev Borrowing a large amount can revert for overflow.\n    /// @dev Borrowing an amount of shares may lead to borrow fewer assets than expected due to slippage.\n    /// Consider using the `assets` parameter to avoid this.\n    /// @param marketParams The market to borrow assets from.\n    /// @param assets The amount of assets to borrow.\n    /// @param shares The amount of shares to mint.\n    /// @param onBehalf The address that will own the increased borrow position.\n    /// @param receiver The address that will receive the borrowed assets.\n    /// @return assetsBorrowed The amount of assets borrowed.\n    /// @return sharesBorrowed The amount of shares minted.\n    function borrow(\n        MarketParams memory marketParams,\n        uint256 assets,\n        uint256 shares,\n        address onBehalf,\n        address receiver\n    ) external returns (uint256 assetsBorrowed, uint256 sharesBorrowed);\n\n    /// @notice Repays `assets` or `shares` on behalf of `onBehalf`, optionally calling back the caller's\n    /// `onMorphoReplay` function with the given `data`.\n    /// @dev Either `assets` or `shares` should be zero. To repay max, pass the `shares`'s balance of `onBehalf`.\n    /// @dev Repaying an amount corresponding to more shares than borrowed will revert for underflow.\n    /// @dev It is advised to use the `shares` input when repaying the full position to avoid reverts due to conversion\n    /// roundings between shares and assets.\n    /// @dev An attacker can front-run a repay with a small repay making the transaction revert for underflow.\n    /// @param marketParams The market to repay assets to.\n    /// @param assets The amount of assets to repay.\n    /// @param shares The amount of shares to burn.\n    /// @param onBehalf The address of the owner of the debt position.\n    /// @param data Arbitrary data to pass to the `onMorphoRepay` callback. Pass empty data if not needed.\n    /// @return assetsRepaid The amount of assets repaid.\n    /// @return sharesRepaid The amount of shares burned.\n    function repay(\n        MarketParams memory marketParams,\n        uint256 assets,\n        uint256 shares,\n        address onBehalf,\n        bytes memory data\n    ) external returns (uint256 assetsRepaid, uint256 sharesRepaid);\n\n    /// @notice Supplies `assets` of collateral on behalf of `onBehalf`, optionally calling back the caller's\n    /// `onMorphoSupplyCollateral` function with the given `data`.\n    /// @dev Interest are not accrued since it's not required and it saves gas.\n    /// @dev Supplying a large amount can revert for overflow.\n    /// @param marketParams The market to supply collateral to.\n    /// @param assets The amount of collateral to supply.\n    /// @param onBehalf The address that will own the increased collateral position.\n    /// @param data Arbitrary data to pass to the `onMorphoSupplyCollateral` callback. Pass empty data if not needed.\n    function supplyCollateral(MarketParams memory marketParams, uint256 assets, address onBehalf, bytes memory data)\n        external;\n\n    /// @notice Withdraws `assets` of collateral on behalf of `onBehalf` and sends the assets to `receiver`.\n    /// @dev `msg.sender` must be authorized to manage `onBehalf`'s positions.\n    /// @dev Withdrawing an amount corresponding to more collateral than supplied will revert for underflow.\n    /// @param marketParams The market to withdraw collateral from.\n    /// @param assets The amount of collateral to withdraw.\n    /// @param onBehalf The address of the owner of the collateral position.\n    /// @param receiver The address that will receive the collateral assets.\n    function withdrawCollateral(MarketParams memory marketParams, uint256 assets, address onBehalf, address receiver)\n        external;\n\n    /// @notice Liquidates the given `repaidShares` of debt asset or seize the given `seizedAssets` of collateral on the\n    /// given market `marketParams` of the given `borrower`'s position, optionally calling back the caller's\n    /// `onMorphoLiquidate` function with the given `data`.\n    /// @dev Either `seizedAssets` or `repaidShares` should be zero.\n    /// @dev Seizing more than the collateral balance will underflow and revert without any error message.\n    /// @dev Repaying more than the borrow balance will underflow and revert without any error message.\n    /// @dev An attacker can front-run a liquidation with a small repay making the transaction revert for underflow.\n    /// @param marketParams The market of the position.\n    /// @param borrower The owner of the position.\n    /// @param seizedAssets The amount of collateral to seize.\n    /// @param repaidShares The amount of shares to repay.\n    /// @param data Arbitrary data to pass to the `onMorphoLiquidate` callback. Pass empty data if not needed.\n    /// @return The amount of assets seized.\n    /// @return The amount of assets repaid.\n    function liquidate(\n        MarketParams memory marketParams,\n        address borrower,\n        uint256 seizedAssets,\n        uint256 repaidShares,\n        bytes memory data\n    ) external returns (uint256, uint256);\n\n    /// @notice Executes a flash loan.\n    /// @dev Flash loans have access to the whole balance of the contract (the liquidity and deposited collateral of all\n    /// markets combined, plus donations).\n    /// @dev Warning: Not ERC-3156 compliant but compatibility is easily reached:\n    /// - `flashFee` is zero.\n    /// - `maxFlashLoan` is the token's balance of this contract.\n    /// - The receiver of `assets` is the caller.\n    /// @param token The token to flash loan.\n    /// @param assets The amount of assets to flash loan.\n    /// @param data Arbitrary data to pass to the `onMorphoFlashLoan` callback.\n    function flashLoan(address token, uint256 assets, bytes calldata data) external;\n\n    /// @notice Sets the authorization for `authorized` to manage `msg.sender`'s positions.\n    /// @param authorized The authorized address.\n    /// @param newIsAuthorized The new authorization status.\n    function setAuthorization(address authorized, bool newIsAuthorized) external;\n\n    /// @notice Sets the authorization for `authorization.authorized` to manage `authorization.authorizer`'s positions.\n    /// @dev Warning: Reverts if the signature has already been submitted.\n    /// @dev The signature is malleable, but it has no impact on the security here.\n    /// @dev The nonce is passed as argument to be able to revert with a different error message.\n    /// @param authorization The `Authorization` struct.\n    /// @param signature The signature.\n    function setAuthorizationWithSig(Authorization calldata authorization, Signature calldata signature) external;\n\n    /// @notice Accrues interest for the given market `marketParams`.\n    function accrueInterest(MarketParams memory marketParams) external;\n\n    /// @notice Returns the data stored on the different `slots`.\n    function extSloads(bytes32[] memory slots) external view returns (bytes32[] memory);\n}\n\n/// @dev This interface is inherited by Morpho so that function signatures are checked by the compiler.\n/// @dev Consider using the IMorpho interface instead of this one.\ninterface IMorphoStaticTyping is IMorphoBase {\n    /// @notice The state of the position of `user` on the market corresponding to `id`.\n    /// @dev Warning: For `feeRecipient`, `supplyShares` does not contain the accrued shares since the last interest\n    /// accrual.\n    function position(Id id, address user)\n        external\n        view\n        returns (uint256 supplyShares, uint128 borrowShares, uint128 collateral);\n\n    /// @notice The state of the market corresponding to `id`.\n    /// @dev Warning: `totalSupplyAssets` does not contain the accrued interest since the last interest accrual.\n    /// @dev Warning: `totalBorrowAssets` does not contain the accrued interest since the last interest accrual.\n    /// @dev Warning: `totalSupplyShares` does not contain the accrued shares by `feeRecipient` since the last interest\n    /// accrual.\n    function market(Id id)\n        external\n        view\n        returns (\n            uint128 totalSupplyAssets,\n            uint128 totalSupplyShares,\n            uint128 totalBorrowAssets,\n            uint128 totalBorrowShares,\n            uint128 lastUpdate,\n            uint128 fee\n        );\n\n    /// @notice The market params corresponding to `id`.\n    /// @dev This mapping is not used in Morpho. It is there to enable reducing the cost associated to calldata on layer\n    /// 2s by creating a wrapper contract with functions that take `id` as input instead of `marketParams`.\n    function idToMarketParams(Id id)\n        external\n        view\n        returns (address loanToken, address collateralToken, address oracle, address irm, uint256 lltv);\n}\n\n/// @title IMorpho\n/// @author Morpho Labs\n/// @custom:contact security@morpho.org\n/// @dev Use this interface for Morpho to have access to all the functions with the appropriate function signatures.\ninterface IMorpho is IMorphoBase {\n    /// @notice The state of the position of `user` on the market corresponding to `id`.\n    /// @dev Warning: For `feeRecipient`, `p.supplyShares` does not contain the accrued shares since the last interest\n    /// accrual.\n    function position(Id id, address user) external view returns (Position memory p);\n\n    /// @notice The state of the market corresponding to `id`.\n    /// @dev Warning: `m.totalSupplyAssets` does not contain the accrued interest since the last interest accrual.\n    /// @dev Warning: `m.totalBorrowAssets` does not contain the accrued interest since the last interest accrual.\n    /// @dev Warning: `m.totalSupplyShares` does not contain the accrued shares by `feeRecipient` since the last\n    /// interest accrual.\n    function market(Id id) external view returns (Market memory m);\n\n    /// @notice The market params corresponding to `id`.\n    /// @dev This mapping is not used in Morpho. It is there to enable reducing the cost associated to calldata on layer\n    /// 2s by creating a wrapper contract with functions that take `id` as input instead of `marketParams`.\n    function idToMarketParams(Id id) external view returns (MarketParams memory);\n}\n"
      },
      "contracts/swapper/LevSwapper/BaseLevSwapper.sol": {
        "content": "// SPDX-License-Identifier: GPL-3.0\npragma solidity ^0.8.17;\n\nimport \"@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol\";\nimport \"@openzeppelin/contracts/token/ERC20/IERC20.sol\";\n\nimport \"borrow/interfaces/IAngleRouterSidechain.sol\";\nimport \"borrow/interfaces/ICoreBorrow.sol\";\nimport \"borrow/interfaces/external/uniswap/IUniswapRouter.sol\";\nimport \"borrow-staked/interfaces/IBorrowStaker.sol\";\nimport \"borrow/swapper/Swapper.sol\";\n\n/// @title BaseLevSwapper\n/// @author Angle Labs, Inc.\n/// @notice Swapper contract facilitating interactions with Angle VaultManager contracts, notably\n/// liquidation and leverage transactions\n/// @dev This base implementation is for tokens like LP tokens which are not natively supported by `aggregator`\n/// and need some wrapping/unwrapping\nabstract contract BaseLevSwapper is Swapper {\n    using SafeERC20 for IERC20;\n\n    constructor(\n        ICoreBorrow _core,\n        IUniswapV3Router _uniV3Router,\n        address _aggregator,\n        IAngleRouterSidechain _angleRouter\n    ) Swapper(_core, _uniV3Router, _aggregator, _angleRouter) {\n        if (address(angleStaker()) != address(0))\n            angleStaker().asset().safeIncreaseAllowance(address(angleStaker()), type(uint256).max);\n    }\n\n    // ============================= INTERNAL FUNCTIONS ============================\n\n    /// @inheritdoc Swapper\n    /// @param data Encoded data giving specific instruction to the bundle tx\n    /// @dev The amountOut is unused so left as 0 in the case of a deleverage transaction\n    /// @dev All token transfers must have been done beforehand\n    /// @dev This function can support multiple swaps to get a desired token\n    function _swapLeverage(bytes memory data) internal override returns (uint256 amountOut) {\n        bool leverage;\n        address to;\n        bytes[] memory aggregatorPayloads;\n        (leverage, to, data) = abi.decode(data, (bool, address, bytes));\n        if (leverage) {\n            (aggregatorPayloads, data) = abi.decode(data, (bytes[], bytes));\n            // After sending all your tokens you have the possibility to swap them through `aggregator`\n            // For instance when borrowing on Angle you receive agEUR, but may want to be LP on\n            // the 3Pool, you can then swap 1/3 of the agEUR to USDC, 1/3 to USDT and 1/3 to DAI\n            // before providing liquidity\n            // These swaps are easy to anticipate as you know how many tokens have been sent when querying the `aggregator` API\n            _multiSwapAggregator(aggregatorPayloads);\n            // Hook to add liquidity to the underlying protocol\n            amountOut = _add(data);\n            // Deposit into the AngleStaker\n            if (address(angleStaker()) != address(0)) angleStaker().deposit(amountOut, to);\n        } else {\n            uint256 toUnstake;\n            uint256 toRemove;\n            IERC20[] memory sweepTokens;\n            (toUnstake, toRemove, sweepTokens, aggregatorPayloads, data) = abi.decode(\n                data,\n                (uint256, uint256, IERC20[], bytes[], bytes)\n            );\n            // Should transfer the token to the contract this will claim the rewards for the current owner of the wrapper\n            if (address(angleStaker()) != address(0)) angleStaker().withdraw(toUnstake, address(this), address(this));\n            _remove(toRemove, data);\n            // Taking the same example as in the `leverage` side, you can withdraw USDC, DAI and USDT while wanting to\n            // to repay a debt in agEUR so you need to do a multiswap.\n            // These swaps are not easy to anticipate the amounts received depend on the deleverage action which can be chaotic\n            // Very often, it's better to swap a lower bound and then sweep the tokens, even though it's not the most efficient\n            // thing to do\n            _multiSwapAggregator(aggregatorPayloads);\n            // After the swaps and/or the deleverage we can end up with useless tokens for repaying a debt and therefore let the\n            // possibility to send it wherever\n            _sweep(sweepTokens, to);\n        }\n    }\n\n    /// @notice Allows to do an arbitrary number of swaps using `aggregator` API\n    /// @param data Encoded info to execute the swaps from `_swapOnAggregator`\n    function _multiSwapAggregator(bytes[] memory data) internal {\n        uint256 dataLength = data.length;\n        for (uint256 i; i < dataLength; ++i) {\n            (address inToken, uint256 minAmount, bytes memory payload) = abi.decode(data[i], (address, uint256, bytes));\n            uint256 amountOut = _swapOnAggregator(IERC20(inToken), payload);\n            // We check the slippage in this case as `swap()` will only check it for the `outToken`\n            if (amountOut < minAmount) revert TooSmallAmountOut();\n        }\n    }\n\n    /// @notice Sweeps tokens from the contract\n    /// @param tokensOut Token to sweep\n    /// @param to Address to which tokens should be sent\n    function _sweep(IERC20[] memory tokensOut, address to) internal {\n        uint256 tokensOutLength = tokensOut.length;\n        for (uint256 i; i < tokensOutLength; ++i) {\n            uint256 balanceToken = tokensOut[i].balanceOf(address(this));\n            if (balanceToken != 0) {\n                tokensOut[i].safeTransfer(to, balanceToken);\n            }\n        }\n    }\n\n    // ========================= EXTERNAL VIRTUAL FUNCTIONS ========================\n\n    /// @notice Token used as collateral on the borrow module, which wraps the `true` collateral\n    function angleStaker() public view virtual returns (IBorrowStaker);\n\n    // ========================= INTERNAL VIRTUAL FUNCTIONS ========================\n\n    /// @notice Implements the bundle transaction to increase exposure to a token\n    /// @param data Encoded data giving specific instruction to the bundle tx\n    function _add(bytes memory data) internal virtual returns (uint256 amountOut);\n\n    /// @notice Implements the bundle transaction to decrease exposure to a token\n    /// @param toRemove Amount of tokens to remove\n    /// @param data Encoded data giving specific instruction to the bundle tx\n    function _remove(uint256 toRemove, bytes memory data) internal virtual;\n}\n"
      },
      "node_modules/@openzeppelin/contracts/token/ERC20/IERC20.sol": {
        "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.6.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(\n        address from,\n        address to,\n        uint256 amount\n    ) external returns (bool);\n}\n"
      },
      "node_modules/@openzeppelin/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"
      },
      "node_modules/@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol": {
        "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.7.0) (token/ERC20/utils/SafeERC20.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../IERC20.sol\";\nimport \"../extensions/draft-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    function safeTransfer(\n        IERC20 token,\n        address to,\n        uint256 value\n    ) internal {\n        _callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value));\n    }\n\n    function safeTransferFrom(\n        IERC20 token,\n        address from,\n        address to,\n        uint256 value\n    ) 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(\n        IERC20 token,\n        address spender,\n        uint256 value\n    ) 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    function safeIncreaseAllowance(\n        IERC20 token,\n        address spender,\n        uint256 value\n    ) internal {\n        uint256 newAllowance = token.allowance(address(this), spender) + value;\n        _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance));\n    }\n\n    function safeDecreaseAllowance(\n        IERC20 token,\n        address spender,\n        uint256 value\n    ) internal {\n        unchecked {\n            uint256 oldAllowance = token.allowance(address(this), spender);\n            require(oldAllowance >= value, \"SafeERC20: decreased allowance below zero\");\n            uint256 newAllowance = oldAllowance - value;\n            _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance));\n        }\n    }\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        if (returndata.length > 0) {\n            // Return data is optional\n            require(abi.decode(returndata, (bool)), \"SafeERC20: ERC20 operation did not succeed\");\n        }\n    }\n}\n"
      },
      "lib/borrow-contracts/contracts/interfaces/IAngleRouterSidechain.sol": {
        "content": "// SPDX-License-Identifier: GPL-3.0\n\npragma solidity ^0.8.12;\n\n/// @notice Action types\nenum ActionType {\n    transfer,\n    wrap,\n    wrapNative,\n    sweep,\n    sweepNative,\n    unwrap,\n    unwrapNative,\n    swapIn,\n    swapOut,\n    uniswapV3,\n    oneInch,\n    claimRewards,\n    gaugeDeposit,\n    borrower\n}\n\n/// @notice Data needed to get permits\nstruct PermitType {\n    address token;\n    address owner;\n    uint256 value;\n    uint256 deadline;\n    uint8 v;\n    bytes32 r;\n    bytes32 s;\n}\n\n/// @title IAngleRouterSidechain\n/// @author Angle Labs, Inc.\n/// @notice Interface for the `AngleRouter` contract on other chains\ninterface IAngleRouterSidechain {\n    function mixer(PermitType[] memory paramsPermit, ActionType[] memory actions, bytes[] calldata data) external;\n}\n"
      },
      "lib/borrow-contracts/contracts/interfaces/ICoreBorrow.sol": {
        "content": "// SPDX-License-Identifier: GPL-3.0\n\npragma solidity ^0.8.12;\n\n/// @title ICoreBorrow\n/// @author Angle Labs, Inc.\n/// @notice Interface for the `CoreBorrow` contract\n/// @dev This interface only contains functions of the `CoreBorrow` contract which are called by other contracts\n/// of this module\ninterface ICoreBorrow {\n    /// @notice Checks if an address corresponds to a treasury of a stablecoin with a flash loan\n    /// module initialized on it\n    /// @param treasury Address to check\n    /// @return Whether the address has the `FLASHLOANER_TREASURY_ROLE` or not\n    function isFlashLoanerTreasury(address treasury) external view returns (bool);\n\n    /// @notice Checks whether an address is governor of the Angle Protocol or not\n    /// @param admin Address to check\n    /// @return Whether the address has the `GOVERNOR_ROLE` or not\n    function isGovernor(address admin) external view returns (bool);\n\n    /// @notice Checks whether an address is governor or a guardian of the Angle Protocol or not\n    /// @param admin Address to check\n    /// @return Whether the address has the `GUARDIAN_ROLE` or not\n    /// @dev Governance should make sure when adding a governor to also give this governor the guardian\n    /// role by calling the `addGovernor` function\n    function isGovernorOrGuardian(address admin) external view returns (bool);\n}\n"
      },
      "lib/borrow-contracts/contracts/interfaces/external/uniswap/IUniswapRouter.sol": {
        "content": "// SPDX-License-Identifier: GPL-3.0\n\npragma solidity ^0.8.12;\n\nstruct ExactInputParams {\n    bytes path;\n    address recipient;\n    uint256 deadline;\n    uint256 amountIn;\n    uint256 amountOutMinimum;\n}\n\n/// @title Router token swapping functionality\n/// @notice Functions for swapping tokens via Uniswap V3\ninterface IUniswapV3Router {\n    /// @notice Swaps `amountIn` of one token for as much as possible of another along the specified path\n    /// @param params The parameters necessary for the multi-hop swap, encoded as `ExactInputParams` in calldata\n    /// @return amountOut The amount of the received token\n    function exactInput(ExactInputParams calldata params) external payable returns (uint256 amountOut);\n}\n\n/// @title Router for price estimation functionality\n/// @notice Functions for getting the price of one token with respect to another using Uniswap V2\n/// @dev This interface is only used for non critical elements of the protocol\ninterface IUniswapV2Router {\n    /// @notice Given an input asset amount, returns the maximum output amount of the\n    /// other asset (accounting for fees) given reserves.\n    /// @param path Addresses of the pools used to get prices\n    function getAmountsOut(uint256 amountIn, address[] calldata path) external view returns (uint256[] memory amounts);\n\n    function swapExactTokensForTokens(\n        uint256 swapAmount,\n        uint256 minExpected,\n        address[] calldata path,\n        address receiver,\n        uint256 swapDeadline\n    ) external;\n}\n"
      },
      "contracts/interfaces/IBorrowStaker.sol": {
        "content": "// SPDX-License-Identifier: GPL-3.0\npragma solidity ^0.8.7;\n\nimport \"@openzeppelin/contracts/token/ERC20/IERC20.sol\";\n\ninterface IBorrowStakerCheckpoint {\n    function checkpointFromVaultManager(\n        address from,\n        uint256 amount,\n        bool add\n    ) external;\n}\n\ninterface IBorrowStaker is IBorrowStakerCheckpoint, IERC20 {\n    function asset() external returns (IERC20 stakingToken);\n\n    function deposit(uint256 amount, address to) external;\n\n    function withdraw(\n        uint256 amount,\n        address from,\n        address to\n    ) external;\n\n    //solhint-disable-next-line\n    function claim_rewards(address user) external returns (uint256[] memory);\n}\n"
      },
      "lib/borrow-contracts/contracts/swapper/Swapper.sol": {
        "content": "// SPDX-License-Identifier: GPL-3.0\n\n/*\n                  *                                                  █                              \n                *****                                               ▓▓▓                             \n                  *                                               ▓▓▓▓▓▓▓                         \n                                   *            ///.           ▓▓▓▓▓▓▓▓▓▓▓▓▓                       \n                                 *****        ////////            ▓▓▓▓▓▓▓                          \n                                   *       /////////////            ▓▓▓                             \n                     ▓▓                  //////////////////          █         ▓▓                   \n                   ▓▓  ▓▓             ///////////////////////                ▓▓   ▓▓                \n                ▓▓       ▓▓        ////////////////////////////           ▓▓        ▓▓              \n              ▓▓            ▓▓    /////////▓▓▓///////▓▓▓/////////       ▓▓             ▓▓            \n           ▓▓                 ,////////////////////////////////////// ▓▓                 ▓▓         \n        ▓▓                  //////////////////////////////////////////                     ▓▓      \n      ▓▓                  //////////////////////▓▓▓▓/////////////////////                          \n                       ,////////////////////////////////////////////////////                        \n                    .//////////////////////////////////////////////////////////                     \n                     .//////////////////////////██.,//////////////////////////█                     \n                       .//////////////////////████..,./////////////////////██                       \n                        ...////////////////███████.....,.////////////////███                        \n                          ,.,////////////████████ ........,///////////████                          \n                            .,.,//////█████████      ,.......///////████                            \n                               ,..//████████           ........./████                               \n                                 ..,██████                .....,███                                 \n                                    .██                     ,.,█                                    \n                                                                                                    \n                                                                                                    \n                                                                                                    \n               ▓▓            ▓▓▓▓▓▓▓▓▓▓       ▓▓▓▓▓▓▓▓▓▓        ▓▓               ▓▓▓▓▓▓▓▓▓▓          \n             ▓▓▓▓▓▓          ▓▓▓    ▓▓▓       ▓▓▓               ▓▓               ▓▓   ▓▓▓▓         \n           ▓▓▓    ▓▓▓        ▓▓▓    ▓▓▓       ▓▓▓    ▓▓▓        ▓▓               ▓▓▓▓▓             \n          ▓▓▓        ▓▓      ▓▓▓    ▓▓▓       ▓▓▓▓▓▓▓▓▓▓        ▓▓▓▓▓▓▓▓▓▓       ▓▓▓▓▓▓▓▓▓▓          \n*/\n\npragma solidity ^0.8.12;\n\nimport \"@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol\";\nimport \"@openzeppelin/contracts/token/ERC20/IERC20.sol\";\n\nimport \"../interfaces/IAngleRouterSidechain.sol\";\nimport \"../interfaces/ICoreBorrow.sol\";\nimport \"../interfaces/ISwapper.sol\";\nimport \"../interfaces/external/lido/IWStETH.sol\";\nimport \"../interfaces/external/uniswap/IUniswapRouter.sol\";\n\n// ==================================== ENUM ===================================\n\n/// @notice All possible swaps\nenum SwapType {\n    UniswapV3,\n    Aggregator,\n    AngleRouter,\n    Leverage,\n    None\n}\n\n/// @title Swapper\n/// @author Angle Labs, Inc.\n/// @notice Swapper contract facilitating interactions with Angle VaultManager contracts, notably\n/// liquidation and leverage transactions\ncontract Swapper is ISwapper {\n    using SafeERC20 for IERC20;\n\n    // ===================== CONSTANTS AND IMMUTABLE VARIABLES =====================\n\n    /// @notice Reference to the `CoreBorrow` contract of the module which handles all AccessControl logic\n    ICoreBorrow public immutable core;\n    /// @notice Uniswap Router contract\n    IUniswapV3Router public immutable uniV3Router;\n    /// @notice Aggregator Router\n    address public aggregator;\n    /// @notice AngleRouter\n    IAngleRouterSidechain public immutable angleRouter;\n\n    // =================================== ERRORS ==================================\n\n    error EmptyReturnMessage();\n    error IncompatibleLengths();\n    error NotGovernorOrGuardian();\n    error TooSmallAmountOut();\n    error ZeroAddress();\n\n    /// @notice Constructor of the contract\n    /// @param _core Core address\n    /// @param _uniV3Router UniswapV3 Router address\n    /// @param _aggregator Aggregator Router address\n    /// @param _angleRouter AngleRouter contract address\n    constructor(\n        ICoreBorrow _core,\n        IUniswapV3Router _uniV3Router,\n        address _aggregator,\n        IAngleRouterSidechain _angleRouter\n    ) {\n        if (address(_core) == address(0) || _aggregator == address(0) || address(_angleRouter) == address(0))\n            revert ZeroAddress();\n        core = _core;\n        uniV3Router = _uniV3Router;\n        aggregator = _aggregator;\n        angleRouter = _angleRouter;\n    }\n\n    // ========================= EXTERNAL ACCESS FUNCTIONS =========================\n\n    /// @inheritdoc ISwapper\n    /// @dev This function swaps the `inToken` to the `outToken` by doing a UniV3 swap, a `aggregator` swap or by interacting\n    /// with the `AngleRouter` contract\n    /// @dev One slippage check is performed at the end of the call\n    /// @dev In this implementation, the function tries to make sure that the `outTokenRecipient` address has at the end\n    /// of the call `outTokenOwed`, leftover tokens are sent to a `to` address which by default is the `outTokenRecipient`\n    function swap(\n        IERC20 inToken,\n        IERC20 outToken,\n        address outTokenRecipient,\n        uint256 outTokenOwed,\n        uint256 inTokenObtained,\n        bytes memory data\n    ) external {\n        // Address to receive the surplus amount of token at the end of the call\n        address to;\n        // For slippage protection, it is checked at the end of the call\n        uint256 minAmountOut;\n        // Type of the swap to execute: if `swapType == 4`, then it is optional to swap\n        uint256 swapType;\n        // We're reusing the `data` variable (it can be `path` on UniswapV3, a payload for `aggregator` or like encoded actions\n        // for a router call)\n        (to, minAmountOut, swapType, data) = abi.decode(data, (address, uint256, uint256, bytes));\n\n        to = (to == address(0)) ? outTokenRecipient : to;\n\n        _swap(inToken, inTokenObtained, SwapType(swapType), data);\n\n        // A final slippage check is performed after the swaps\n        uint256 outTokenBalance = outToken.balanceOf(address(this));\n        if (outTokenBalance < minAmountOut) revert TooSmallAmountOut();\n\n        // The `outTokenRecipient` may already have enough in balance, in which case there's no need to transfer\n        // to this address the token and everything can be given to the `to` address\n        uint256 outTokenBalanceRecipient = outToken.balanceOf(outTokenRecipient);\n        if (outTokenBalanceRecipient >= outTokenOwed || to == outTokenRecipient)\n            outToken.safeTransfer(to, outTokenBalance);\n        else {\n            // The `outTokenRecipient` should receive the delta to make sure its end balance is equal to `outTokenOwed`\n            // Any leftover in this case is sent to the `to` address\n            // The function reverts if it did not obtain more than `outTokenOwed - outTokenBalanceRecipient` from the swap\n            outToken.safeTransfer(outTokenRecipient, outTokenOwed - outTokenBalanceRecipient);\n            outToken.safeTransfer(to, outTokenBalanceRecipient + outTokenBalance - outTokenOwed);\n        }\n        // Reusing the `inTokenObtained` variable for the `inToken` balance\n        // Sending back the remaining amount of inTokens to the `to` address: it is possible that not the full `inTokenObtained`\n        // is swapped to `outToken` if we're using the `aggregator` payload\n        inTokenObtained = inToken.balanceOf(address(this));\n        if (inTokenObtained != 0) inToken.safeTransfer(to, inTokenObtained);\n    }\n\n    // ============================ GOVERNANCE FUNCTION ============================\n\n    /// @notice Changes allowances of this contract for different tokens\n    /// @param tokens Addresses of the tokens to allow\n    /// @param spenders Addresses to allow transfer\n    /// @param amounts Amounts to allow\n    function changeAllowance(\n        IERC20[] calldata tokens,\n        address[] calldata spenders,\n        uint256[] calldata amounts\n    ) external {\n        if (!core.isGovernorOrGuardian(msg.sender)) revert NotGovernorOrGuardian();\n        uint256 tokensLength = tokens.length;\n        if (tokensLength != spenders.length || tokensLength != amounts.length) revert IncompatibleLengths();\n        for (uint256 i; i < tokensLength; ++i) {\n            _changeAllowance(tokens[i], spenders[i], amounts[i]);\n        }\n    }\n\n    /// @notice Changes `aggregator` endpoint to swap tokens\n    function setAggregator(address _aggregator) external {\n        if (!core.isGovernorOrGuardian(msg.sender)) revert NotGovernorOrGuardian();\n        if (_aggregator == address(0) || _aggregator == aggregator) revert ZeroAddress();\n        aggregator = _aggregator;\n    }\n\n    // ========================= INTERNAL UTILITY FUNCTIONS ========================\n\n    /// @notice Internal version of the `_changeAllowance` function\n    function _changeAllowance(IERC20 token, address spender, uint256 amount) internal {\n        uint256 currentAllowance = token.allowance(address(this), spender);\n        // In case `currentAllowance < type(uint256).max / 2` and we want to increase it:\n        // Do nothing (to handle tokens that need reapprovals to 0 and save gas)\n        if (currentAllowance < amount && currentAllowance < type(uint256).max / 2) {\n            token.safeIncreaseAllowance(spender, amount - currentAllowance);\n        } else if (currentAllowance > amount) {\n            token.safeDecreaseAllowance(spender, currentAllowance - amount);\n        }\n    }\n\n    /// @notice Checks the allowance for a contract and updates it to the max if it is not big enough\n    /// @param token Token for which allowance should be checked\n    /// @param spender Address to grant allowance to\n    /// @param amount Minimum amount of tokens needed for the allowance\n    function _checkAllowance(IERC20 token, address spender, uint256 amount) internal {\n        uint256 currentAllowance = token.allowance(address(this), spender);\n        if (currentAllowance < amount) token.safeIncreaseAllowance(spender, type(uint256).max - currentAllowance);\n    }\n\n    /// @notice Performs a swap using either Uniswap, `aggregator`. This function can also stake stETH to wstETH\n    /// @param inToken Token to swap\n    /// @param amount Amount of tokens to swap\n    /// @param swapType Type of the swap to perform\n    /// @param args Extra args for the swap: in the case of Uniswap it should be a path, for `aggregator` it should be\n    /// a payload\n    /// @dev This function does nothing if `swapType` is None and it simply passes on the `amount` it received\n    /// @dev No slippage is specified in the actions given here as a final slippage check is performed\n    /// after the call to this function\n    function _swap(IERC20 inToken, uint256 amount, SwapType swapType, bytes memory args) internal {\n        if (swapType == SwapType.UniswapV3) _swapOnUniswapV3(inToken, amount, args);\n        else if (swapType == SwapType.Aggregator) _swapOnAggregator(inToken, args);\n        else if (swapType == SwapType.AngleRouter) _angleRouterActions(inToken, args);\n        else if (swapType == SwapType.Leverage) _swapLeverage(args);\n    }\n\n    /// @notice Performs a UniswapV3 swap\n    /// @param inToken Token to swap\n    /// @param amount Amount of tokens to swap\n    /// @param path Path for the UniswapV3 swap: this encodes the out token that is going to be obtained\n    /// @dev This function does not check the out token obtained here: if it is wrongly specified, either\n    /// the `swap` function could fail or these tokens could stay on the contract\n    function _swapOnUniswapV3(IERC20 inToken, uint256 amount, bytes memory path) internal returns (uint256 amountOut) {\n        // We need more than `amount` of allowance to the contract\n        _checkAllowance(inToken, address(uniV3Router), amount);\n        amountOut = uniV3Router.exactInput(ExactInputParams(path, address(this), block.timestamp, amount, 0));\n    }\n\n    /// @notice Allows to swap any token to an accepted collateral via `aggregator` API\n    /// @param inToken Token received for the `aggregator` swap\n    /// @param payload Bytes needed for `aggregator` API\n    function _swapOnAggregator(IERC20 inToken, bytes memory payload) internal returns (uint256 amountOut) {\n        _changeAllowance(inToken, aggregator, type(uint256).max);\n        //solhint-disable-next-line\n        (bool success, bytes memory result) = aggregator.call(payload);\n        if (!success) _revertBytes(result);\n        amountOut = abi.decode(result, (uint256));\n    }\n\n    /// @notice Performs actions with the router contract of the protocol on the corresponding chain\n    /// @param inToken Token concerned by the action and for which\n    function _angleRouterActions(IERC20 inToken, bytes memory args) internal {\n        (ActionType[] memory actions, bytes[] memory actionData) = abi.decode(args, (ActionType[], bytes[]));\n        _changeAllowance(inToken, address(angleRouter), type(uint256).max);\n        PermitType[] memory permits;\n        angleRouter.mixer(permits, actions, actionData);\n    }\n\n    /// @notice Allows to take leverage or deleverage via a specific contract\n    /// @param payload Bytes needed for `aggregator` API\n    /// @dev This function is to be implemented if the swapper concerns a token that requires some actions\n    /// not supported by `aggregator` or UniV3\n    function _swapLeverage(bytes memory payload) internal virtual returns (uint256 amountOut) {}\n\n    /// @notice Internal function used for error handling\n    /// @param errMsg Error message received\n    function _revertBytes(bytes memory errMsg) internal pure {\n        if (errMsg.length != 0) {\n            //solhint-disable-next-line\n            assembly {\n                revert(add(32, errMsg), mload(errMsg))\n            }\n        }\n        revert EmptyReturnMessage();\n    }\n}\n"
      },
      "node_modules/@openzeppelin/contracts/token/ERC20/extensions/draft-IERC20Permit.sol": {
        "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (token/ERC20/extensions/draft-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 */\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    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"
      },
      "node_modules/@openzeppelin/contracts/utils/Address.sol": {
        "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.7.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     *\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://diligence.consensys.net/posts/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.5.11/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 functionCall(target, data, \"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(\n        address target,\n        bytes memory data,\n        uint256 value\n    ) 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        require(isContract(target), \"Address: call to non-contract\");\n\n        (bool success, bytes memory returndata) = target.call{value: value}(data);\n        return verifyCallResult(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        require(isContract(target), \"Address: static call to non-contract\");\n\n        (bool success, bytes memory returndata) = target.staticcall(data);\n        return verifyCallResult(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        require(isContract(target), \"Address: delegate call to non-contract\");\n\n        (bool success, bytes memory returndata) = target.delegatecall(data);\n        return verifyCallResult(success, returndata, errorMessage);\n    }\n\n    /**\n     * @dev Tool to verifies that a low level call was successful, and revert if it wasn't, either by bubbling the\n     * revert reason 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            // 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}\n"
      },
      "lib/borrow-contracts/contracts/interfaces/ISwapper.sol": {
        "content": "// SPDX-License-Identifier: GPL-3.0\n\npragma solidity ^0.8.12;\n\nimport \"@openzeppelin/contracts/token/ERC20/IERC20.sol\";\n\n/// @title ISwapper\n/// @author Angle Labs, Inc.\n/// @notice Interface for Swapper contracts\n/// @dev This interface defines the key functions `Swapper` contracts should have when interacting with\n/// Angle\ninterface ISwapper {\n    /// @notice Notifies a contract that an address should be given `outToken` from `inToken`\n    /// @param inToken Address of the token received\n    /// @param outToken Address of the token to obtain\n    /// @param outTokenRecipient Address to which the outToken should be sent\n    /// @param outTokenOwed Minimum amount of outToken the `outTokenRecipient` address should have at the end of the call\n    /// @param inTokenObtained Amount of collateral obtained by a related address prior\n    /// to the call to this function\n    /// @param data Extra data needed (to encode Uniswap swaps for instance)\n    function swap(\n        IERC20 inToken,\n        IERC20 outToken,\n        address outTokenRecipient,\n        uint256 outTokenOwed,\n        uint256 inTokenObtained,\n        bytes calldata data\n    ) external;\n}\n"
      },
      "lib/borrow-contracts/contracts/interfaces/external/lido/IWStETH.sol": {
        "content": "// SPDX-License-Identifier: GPL-3.0\n\npragma solidity ^0.8.12;\n\n/// @title IWStETH\n/// @author Angle Labs, Inc.\n/// @notice Interface for the `WStETH` contract\n/// @dev This interface only contains functions of the `WStETH` which are called by other contracts\n/// of this module\ninterface IWStETH {\n    function wrap(uint256 _stETHAmount) external returns (uint256);\n\n    function stETH() external view returns (address);\n}\n"
      }
    },
    "settings": {
      "remappings": [
        "ds-test/=lib/forge-std/lib/ds-test/src/",
        "forge-std/=lib/forge-std/src/",
        "borrow/=lib/borrow-contracts/contracts/",
        "utils/=lib/utils/",
        "morpho-blue/=lib/morpho-blue/src/",
        "borrow-staked/=contracts/",
        "@chainlink/=node_modules/@chainlink/",
        "@ensdomains/=node_modules/@ensdomains/",
        "@openzeppelin/=node_modules/@openzeppelin/",
        "@uniswap/=node_modules/@uniswap/",
        "@prb/test/=lib/borrow-contracts/lib/prb-math/node_modules/@prb/test/",
        "abdk/math/=lib/borrow-contracts/lib/abdk-libraries-solidity/",
        "borrow-contracts/=lib/borrow-contracts/",
        "eth-gas-reporter/=node_modules/eth-gas-reporter/",
        "hardhat-deploy/=node_modules/hardhat-deploy/",
        "hardhat/=node_modules/hardhat/",
        "lz/=lib/utils/lib/solidity-examples/contracts/",
        "openzeppelin-contracts/=lib/utils/lib/openzeppelin-contracts/",
        "oz/=lib/utils/lib/openzeppelin-contracts/contracts/",
        "pendle-core-v2-public/=lib/borrow-contracts/lib/pendle-core-v2-public/contracts/",
        "pendle/=lib/borrow-contracts/lib/pendle-core-v2-public/contracts/",
        "prb-math/=lib/borrow-contracts/lib/prb-math/src/",
        "prb/math/=lib/borrow-contracts/lib/prb-math/src/",
        "solidity-examples/=lib/utils/lib/solidity-examples/contracts/",
        "solidity-stringutils/=lib/utils/lib/solidity-stringutils/",
        "stringutils/=lib/borrow-contracts/lib/solidity-stringutils/"
      ],
      "optimizer": {
        "enabled": true,
        "runs": 1000
      },
      "metadata": {
        "useLiteralContent": false,
        "bytecodeHash": "ipfs",
        "appendCBOR": true
      },
      "outputSelection": {
        "*": {
          "*": [
            "evm.bytecode",
            "evm.deployedBytecode",
            "devdoc",
            "userdoc",
            "metadata",
            "abi"
          ]
        }
      },
      "evmVersion": "shanghai",
      "libraries": {}
    }
  }}