creation_sourcecode: {{
    "language": "Solidity",
    "sources": {
      "@aave/core-v3/contracts/flashloan/base/FlashLoanSimpleReceiverBase.sol": {
        "content": "// SPDX-License-Identifier: AGPL-3.0\npragma solidity ^0.8.0;\n\nimport {IFlashLoanSimpleReceiver} from '../interfaces/IFlashLoanSimpleReceiver.sol';\nimport {IPoolAddressesProvider} from '../../interfaces/IPoolAddressesProvider.sol';\nimport {IPool} from '../../interfaces/IPool.sol';\n\n/**\n * @title FlashLoanSimpleReceiverBase\n * @author Aave\n * @notice Base contract to develop a flashloan-receiver contract.\n */\nabstract contract FlashLoanSimpleReceiverBase is IFlashLoanSimpleReceiver {\n  IPoolAddressesProvider public immutable override ADDRESSES_PROVIDER;\n  IPool public immutable override POOL;\n\n  constructor(IPoolAddressesProvider provider) {\n    ADDRESSES_PROVIDER = provider;\n    POOL = IPool(provider.getPool());\n  }\n}\n"
      },
      "@aave/core-v3/contracts/flashloan/interfaces/IFlashLoanSimpleReceiver.sol": {
        "content": "// SPDX-License-Identifier: AGPL-3.0\npragma solidity ^0.8.0;\n\nimport {IPoolAddressesProvider} from '../../interfaces/IPoolAddressesProvider.sol';\nimport {IPool} from '../../interfaces/IPool.sol';\n\n/**\n * @title IFlashLoanSimpleReceiver\n * @author Aave\n * @notice Defines the basic interface of a flashloan-receiver contract.\n * @dev Implement this interface to develop a flashloan-compatible flashLoanReceiver contract\n */\ninterface IFlashLoanSimpleReceiver {\n  /**\n   * @notice Executes an operation after receiving the flash-borrowed asset\n   * @dev Ensure that the contract can return the debt + premium, e.g., has\n   *      enough funds to repay and has approved the Pool to pull the total amount\n   * @param asset The address of the flash-borrowed asset\n   * @param amount The amount of the flash-borrowed asset\n   * @param premium The fee of the flash-borrowed asset\n   * @param initiator The address of the flashloan initiator\n   * @param params The byte-encoded params passed when initiating the flashloan\n   * @return True if the execution of the operation succeeds, false otherwise\n   */\n  function executeOperation(\n    address asset,\n    uint256 amount,\n    uint256 premium,\n    address initiator,\n    bytes calldata params\n  ) external returns (bool);\n\n  function ADDRESSES_PROVIDER() external view returns (IPoolAddressesProvider);\n\n  function POOL() external view returns (IPool);\n}\n"
      },
      "@aave/core-v3/contracts/interfaces/IPool.sol": {
        "content": "// SPDX-License-Identifier: AGPL-3.0\npragma solidity ^0.8.0;\n\nimport {IPoolAddressesProvider} from './IPoolAddressesProvider.sol';\nimport {DataTypes} from '../protocol/libraries/types/DataTypes.sol';\n\n/**\n * @title IPool\n * @author Aave\n * @notice Defines the basic interface for an Aave Pool.\n */\ninterface IPool {\n  /**\n   * @dev Emitted on mintUnbacked()\n   * @param reserve The address of the underlying asset of the reserve\n   * @param user The address initiating the supply\n   * @param onBehalfOf The beneficiary of the supplied assets, receiving the aTokens\n   * @param amount The amount of supplied assets\n   * @param referralCode The referral code used\n   */\n  event MintUnbacked(\n    address indexed reserve,\n    address user,\n    address indexed onBehalfOf,\n    uint256 amount,\n    uint16 indexed referralCode\n  );\n\n  /**\n   * @dev Emitted on backUnbacked()\n   * @param reserve The address of the underlying asset of the reserve\n   * @param backer The address paying for the backing\n   * @param amount The amount added as backing\n   * @param fee The amount paid in fees\n   */\n  event BackUnbacked(address indexed reserve, address indexed backer, uint256 amount, uint256 fee);\n\n  /**\n   * @dev Emitted on supply()\n   * @param reserve The address of the underlying asset of the reserve\n   * @param user The address initiating the supply\n   * @param onBehalfOf The beneficiary of the supply, receiving the aTokens\n   * @param amount The amount supplied\n   * @param referralCode The referral code used\n   */\n  event Supply(\n    address indexed reserve,\n    address user,\n    address indexed onBehalfOf,\n    uint256 amount,\n    uint16 indexed referralCode\n  );\n\n  /**\n   * @dev Emitted on withdraw()\n   * @param reserve The address of the underlying asset being withdrawn\n   * @param user The address initiating the withdrawal, owner of aTokens\n   * @param to The address that will receive the underlying\n   * @param amount The amount to be withdrawn\n   */\n  event Withdraw(address indexed reserve, address indexed user, address indexed to, uint256 amount);\n\n  /**\n   * @dev Emitted on borrow() and flashLoan() when debt needs to be opened\n   * @param reserve The address of the underlying asset being borrowed\n   * @param user The address of the user initiating the borrow(), receiving the funds on borrow() or just\n   * initiator of the transaction on flashLoan()\n   * @param onBehalfOf The address that will be getting the debt\n   * @param amount The amount borrowed out\n   * @param interestRateMode The rate mode: 1 for Stable, 2 for Variable\n   * @param borrowRate The numeric rate at which the user has borrowed, expressed in ray\n   * @param referralCode The referral code used\n   */\n  event Borrow(\n    address indexed reserve,\n    address user,\n    address indexed onBehalfOf,\n    uint256 amount,\n    DataTypes.InterestRateMode interestRateMode,\n    uint256 borrowRate,\n    uint16 indexed referralCode\n  );\n\n  /**\n   * @dev Emitted on repay()\n   * @param reserve The address of the underlying asset of the reserve\n   * @param user The beneficiary of the repayment, getting his debt reduced\n   * @param repayer The address of the user initiating the repay(), providing the funds\n   * @param amount The amount repaid\n   * @param useATokens True if the repayment is done using aTokens, `false` if done with underlying asset directly\n   */\n  event Repay(\n    address indexed reserve,\n    address indexed user,\n    address indexed repayer,\n    uint256 amount,\n    bool useATokens\n  );\n\n  /**\n   * @dev Emitted on swapBorrowRateMode()\n   * @param reserve The address of the underlying asset of the reserve\n   * @param user The address of the user swapping his rate mode\n   * @param interestRateMode The current interest rate mode of the position being swapped: 1 for Stable, 2 for Variable\n   */\n  event SwapBorrowRateMode(\n    address indexed reserve,\n    address indexed user,\n    DataTypes.InterestRateMode interestRateMode\n  );\n\n  /**\n   * @dev Emitted on borrow(), repay() and liquidationCall() when using isolated assets\n   * @param asset The address of the underlying asset of the reserve\n   * @param totalDebt The total isolation mode debt for the reserve\n   */\n  event IsolationModeTotalDebtUpdated(address indexed asset, uint256 totalDebt);\n\n  /**\n   * @dev Emitted when the user selects a certain asset category for eMode\n   * @param user The address of the user\n   * @param categoryId The category id\n   */\n  event UserEModeSet(address indexed user, uint8 categoryId);\n\n  /**\n   * @dev Emitted on setUserUseReserveAsCollateral()\n   * @param reserve The address of the underlying asset of the reserve\n   * @param user The address of the user enabling the usage as collateral\n   */\n  event ReserveUsedAsCollateralEnabled(address indexed reserve, address indexed user);\n\n  /**\n   * @dev Emitted on setUserUseReserveAsCollateral()\n   * @param reserve The address of the underlying asset of the reserve\n   * @param user The address of the user enabling the usage as collateral\n   */\n  event ReserveUsedAsCollateralDisabled(address indexed reserve, address indexed user);\n\n  /**\n   * @dev Emitted on rebalanceStableBorrowRate()\n   * @param reserve The address of the underlying asset of the reserve\n   * @param user The address of the user for which the rebalance has been executed\n   */\n  event RebalanceStableBorrowRate(address indexed reserve, address indexed user);\n\n  /**\n   * @dev Emitted on flashLoan()\n   * @param target The address of the flash loan receiver contract\n   * @param initiator The address initiating the flash loan\n   * @param asset The address of the asset being flash borrowed\n   * @param amount The amount flash borrowed\n   * @param interestRateMode The flashloan mode: 0 for regular flashloan, 1 for Stable debt, 2 for Variable debt\n   * @param premium The fee flash borrowed\n   * @param referralCode The referral code used\n   */\n  event FlashLoan(\n    address indexed target,\n    address initiator,\n    address indexed asset,\n    uint256 amount,\n    DataTypes.InterestRateMode interestRateMode,\n    uint256 premium,\n    uint16 indexed referralCode\n  );\n\n  /**\n   * @dev Emitted when a borrower is liquidated.\n   * @param collateralAsset The address of the underlying asset used as collateral, to receive as result of the liquidation\n   * @param debtAsset The address of the underlying borrowed asset to be repaid with the liquidation\n   * @param user The address of the borrower getting liquidated\n   * @param debtToCover The debt amount of borrowed `asset` the liquidator wants to cover\n   * @param liquidatedCollateralAmount The amount of collateral received by the liquidator\n   * @param liquidator The address of the liquidator\n   * @param receiveAToken True if the liquidators wants to receive the collateral aTokens, `false` if he wants\n   * to receive the underlying collateral asset directly\n   */\n  event LiquidationCall(\n    address indexed collateralAsset,\n    address indexed debtAsset,\n    address indexed user,\n    uint256 debtToCover,\n    uint256 liquidatedCollateralAmount,\n    address liquidator,\n    bool receiveAToken\n  );\n\n  /**\n   * @dev Emitted when the state of a reserve is updated.\n   * @param reserve The address of the underlying asset of the reserve\n   * @param liquidityRate The next liquidity rate\n   * @param stableBorrowRate The next stable borrow rate\n   * @param variableBorrowRate The next variable borrow rate\n   * @param liquidityIndex The next liquidity index\n   * @param variableBorrowIndex The next variable borrow index\n   */\n  event ReserveDataUpdated(\n    address indexed reserve,\n    uint256 liquidityRate,\n    uint256 stableBorrowRate,\n    uint256 variableBorrowRate,\n    uint256 liquidityIndex,\n    uint256 variableBorrowIndex\n  );\n\n  /**\n   * @dev Emitted when the protocol treasury receives minted aTokens from the accrued interest.\n   * @param reserve The address of the reserve\n   * @param amountMinted The amount minted to the treasury\n   */\n  event MintedToTreasury(address indexed reserve, uint256 amountMinted);\n\n  /**\n   * @notice Mints an `amount` of aTokens to the `onBehalfOf`\n   * @param asset The address of the underlying asset to mint\n   * @param amount The amount to mint\n   * @param onBehalfOf The address that will receive the aTokens\n   * @param referralCode Code used to register the integrator originating the operation, for potential rewards.\n   *   0 if the action is executed directly by the user, without any middle-man\n   */\n  function mintUnbacked(\n    address asset,\n    uint256 amount,\n    address onBehalfOf,\n    uint16 referralCode\n  ) external;\n\n  /**\n   * @notice Back the current unbacked underlying with `amount` and pay `fee`.\n   * @param asset The address of the underlying asset to back\n   * @param amount The amount to back\n   * @param fee The amount paid in fees\n   * @return The backed amount\n   */\n  function backUnbacked(address asset, uint256 amount, uint256 fee) external returns (uint256);\n\n  /**\n   * @notice Supplies an `amount` of underlying asset into the reserve, receiving in return overlying aTokens.\n   * - E.g. User supplies 100 USDC and gets in return 100 aUSDC\n   * @param asset The address of the underlying asset to supply\n   * @param amount The amount to be supplied\n   * @param onBehalfOf The address that will receive the aTokens, same as msg.sender if the user\n   *   wants to receive them on his own wallet, or a different address if the beneficiary of aTokens\n   *   is a different wallet\n   * @param referralCode Code used to register the integrator originating the operation, for potential rewards.\n   *   0 if the action is executed directly by the user, without any middle-man\n   */\n  function supply(address asset, uint256 amount, address onBehalfOf, uint16 referralCode) external;\n\n  /**\n   * @notice Supply with transfer approval of asset to be supplied done via permit function\n   * see: https://eips.ethereum.org/EIPS/eip-2612 and https://eips.ethereum.org/EIPS/eip-713\n   * @param asset The address of the underlying asset to supply\n   * @param amount The amount to be supplied\n   * @param onBehalfOf The address that will receive the aTokens, same as msg.sender if the user\n   *   wants to receive them on his own wallet, or a different address if the beneficiary of aTokens\n   *   is a different wallet\n   * @param deadline The deadline timestamp that the permit is valid\n   * @param referralCode Code used to register the integrator originating the operation, for potential rewards.\n   *   0 if the action is executed directly by the user, without any middle-man\n   * @param permitV The V parameter of ERC712 permit sig\n   * @param permitR The R parameter of ERC712 permit sig\n   * @param permitS The S parameter of ERC712 permit sig\n   */\n  function supplyWithPermit(\n    address asset,\n    uint256 amount,\n    address onBehalfOf,\n    uint16 referralCode,\n    uint256 deadline,\n    uint8 permitV,\n    bytes32 permitR,\n    bytes32 permitS\n  ) external;\n\n  /**\n   * @notice Withdraws an `amount` of underlying asset from the reserve, burning the equivalent aTokens owned\n   * E.g. User has 100 aUSDC, calls withdraw() and receives 100 USDC, burning the 100 aUSDC\n   * @param asset The address of the underlying asset to withdraw\n   * @param amount The underlying amount to be withdrawn\n   *   - Send the value type(uint256).max in order to withdraw the whole aToken balance\n   * @param to The address that will receive the underlying, same as msg.sender if the user\n   *   wants to receive it on his own wallet, or a different address if the beneficiary is a\n   *   different wallet\n   * @return The final amount withdrawn\n   */\n  function withdraw(address asset, uint256 amount, address to) external returns (uint256);\n\n  /**\n   * @notice Allows users to borrow a specific `amount` of the reserve underlying asset, provided that the borrower\n   * already supplied enough collateral, or he was given enough allowance by a credit delegator on the\n   * corresponding debt token (StableDebtToken or VariableDebtToken)\n   * - E.g. User borrows 100 USDC passing as `onBehalfOf` his own address, receiving the 100 USDC in his wallet\n   *   and 100 stable/variable debt tokens, depending on the `interestRateMode`\n   * @param asset The address of the underlying asset to borrow\n   * @param amount The amount to be borrowed\n   * @param interestRateMode The interest rate mode at which the user wants to borrow: 1 for Stable, 2 for Variable\n   * @param referralCode The code used to register the integrator originating the operation, for potential rewards.\n   *   0 if the action is executed directly by the user, without any middle-man\n   * @param onBehalfOf The address of the user who will receive the debt. Should be the address of the borrower itself\n   * calling the function if he wants to borrow against his own collateral, or the address of the credit delegator\n   * if he has been given credit delegation allowance\n   */\n  function borrow(\n    address asset,\n    uint256 amount,\n    uint256 interestRateMode,\n    uint16 referralCode,\n    address onBehalfOf\n  ) external;\n\n  /**\n   * @notice Repays a borrowed `amount` on a specific reserve, burning the equivalent debt tokens owned\n   * - E.g. User repays 100 USDC, burning 100 variable/stable debt tokens of the `onBehalfOf` address\n   * @param asset The address of the borrowed underlying asset previously borrowed\n   * @param amount The amount to repay\n   * - Send the value type(uint256).max in order to repay the whole debt for `asset` on the specific `debtMode`\n   * @param interestRateMode The interest rate mode at of the debt the user wants to repay: 1 for Stable, 2 for Variable\n   * @param onBehalfOf The address of the user who will get his debt reduced/removed. Should be the address of the\n   * user calling the function if he wants to reduce/remove his own debt, or the address of any other\n   * other borrower whose debt should be removed\n   * @return The final amount repaid\n   */\n  function repay(\n    address asset,\n    uint256 amount,\n    uint256 interestRateMode,\n    address onBehalfOf\n  ) external returns (uint256);\n\n  /**\n   * @notice Repay with transfer approval of asset to be repaid done via permit function\n   * see: https://eips.ethereum.org/EIPS/eip-2612 and https://eips.ethereum.org/EIPS/eip-713\n   * @param asset The address of the borrowed underlying asset previously borrowed\n   * @param amount The amount to repay\n   * - Send the value type(uint256).max in order to repay the whole debt for `asset` on the specific `debtMode`\n   * @param interestRateMode The interest rate mode at of the debt the user wants to repay: 1 for Stable, 2 for Variable\n   * @param onBehalfOf Address of the user who will get his debt reduced/removed. Should be the address of the\n   * user calling the function if he wants to reduce/remove his own debt, or the address of any other\n   * other borrower whose debt should be removed\n   * @param deadline The deadline timestamp that the permit is valid\n   * @param permitV The V parameter of ERC712 permit sig\n   * @param permitR The R parameter of ERC712 permit sig\n   * @param permitS The S parameter of ERC712 permit sig\n   * @return The final amount repaid\n   */\n  function repayWithPermit(\n    address asset,\n    uint256 amount,\n    uint256 interestRateMode,\n    address onBehalfOf,\n    uint256 deadline,\n    uint8 permitV,\n    bytes32 permitR,\n    bytes32 permitS\n  ) external returns (uint256);\n\n  /**\n   * @notice Repays a borrowed `amount` on a specific reserve using the reserve aTokens, burning the\n   * equivalent debt tokens\n   * - E.g. User repays 100 USDC using 100 aUSDC, burning 100 variable/stable debt tokens\n   * @dev  Passing uint256.max as amount will clean up any residual aToken dust balance, if the user aToken\n   * balance is not enough to cover the whole debt\n   * @param asset The address of the borrowed underlying asset previously borrowed\n   * @param amount The amount to repay\n   * - Send the value type(uint256).max in order to repay the whole debt for `asset` on the specific `debtMode`\n   * @param interestRateMode The interest rate mode at of the debt the user wants to repay: 1 for Stable, 2 for Variable\n   * @return The final amount repaid\n   */\n  function repayWithATokens(\n    address asset,\n    uint256 amount,\n    uint256 interestRateMode\n  ) external returns (uint256);\n\n  /**\n   * @notice Allows a borrower to swap his debt between stable and variable mode, or vice versa\n   * @param asset The address of the underlying asset borrowed\n   * @param interestRateMode The current interest rate mode of the position being swapped: 1 for Stable, 2 for Variable\n   */\n  function swapBorrowRateMode(address asset, uint256 interestRateMode) external;\n\n  /**\n   * @notice Rebalances the stable interest rate of a user to the current stable rate defined on the reserve.\n   * - Users can be rebalanced if the following conditions are satisfied:\n   *     1. Usage ratio is above 95%\n   *     2. the current supply APY is below REBALANCE_UP_THRESHOLD * maxVariableBorrowRate, which means that too\n   *        much has been borrowed at a stable rate and suppliers are not earning enough\n   * @param asset The address of the underlying asset borrowed\n   * @param user The address of the user to be rebalanced\n   */\n  function rebalanceStableBorrowRate(address asset, address user) external;\n\n  /**\n   * @notice Allows suppliers to enable/disable a specific supplied asset as collateral\n   * @param asset The address of the underlying asset supplied\n   * @param useAsCollateral True if the user wants to use the supply as collateral, false otherwise\n   */\n  function setUserUseReserveAsCollateral(address asset, bool useAsCollateral) external;\n\n  /**\n   * @notice Function to liquidate a non-healthy position collateral-wise, with Health Factor below 1\n   * - The caller (liquidator) covers `debtToCover` amount of debt of the user getting liquidated, and receives\n   *   a proportionally amount of the `collateralAsset` plus a bonus to cover market risk\n   * @param collateralAsset The address of the underlying asset used as collateral, to receive as result of the liquidation\n   * @param debtAsset The address of the underlying borrowed asset to be repaid with the liquidation\n   * @param user The address of the borrower getting liquidated\n   * @param debtToCover The debt amount of borrowed `asset` the liquidator wants to cover\n   * @param receiveAToken True if the liquidators wants to receive the collateral aTokens, `false` if he wants\n   * to receive the underlying collateral asset directly\n   */\n  function liquidationCall(\n    address collateralAsset,\n    address debtAsset,\n    address user,\n    uint256 debtToCover,\n    bool receiveAToken\n  ) external;\n\n  /**\n   * @notice Allows smartcontracts to access the liquidity of the pool within one transaction,\n   * as long as the amount taken plus a fee is returned.\n   * @dev IMPORTANT There are security concerns for developers of flashloan receiver contracts that must be kept\n   * into consideration. For further details please visit https://docs.aave.com/developers/\n   * @param receiverAddress The address of the contract receiving the funds, implementing IFlashLoanReceiver interface\n   * @param assets The addresses of the assets being flash-borrowed\n   * @param amounts The amounts of the assets being flash-borrowed\n   * @param interestRateModes Types of the debt to open if the flash loan is not returned:\n   *   0 -> Don't open any debt, just revert if funds can't be transferred from the receiver\n   *   1 -> Open debt at stable rate for the value of the amount flash-borrowed to the `onBehalfOf` address\n   *   2 -> Open debt at variable rate for the value of the amount flash-borrowed to the `onBehalfOf` address\n   * @param onBehalfOf The address  that will receive the debt in the case of using on `modes` 1 or 2\n   * @param params Variadic packed params to pass to the receiver as extra information\n   * @param referralCode The code used to register the integrator originating the operation, for potential rewards.\n   *   0 if the action is executed directly by the user, without any middle-man\n   */\n  function flashLoan(\n    address receiverAddress,\n    address[] calldata assets,\n    uint256[] calldata amounts,\n    uint256[] calldata interestRateModes,\n    address onBehalfOf,\n    bytes calldata params,\n    uint16 referralCode\n  ) external;\n\n  /**\n   * @notice Allows smartcontracts to access the liquidity of the pool within one transaction,\n   * as long as the amount taken plus a fee is returned.\n   * @dev IMPORTANT There are security concerns for developers of flashloan receiver contracts that must be kept\n   * into consideration. For further details please visit https://docs.aave.com/developers/\n   * @param receiverAddress The address of the contract receiving the funds, implementing IFlashLoanSimpleReceiver interface\n   * @param asset The address of the asset being flash-borrowed\n   * @param amount The amount of the asset being flash-borrowed\n   * @param params Variadic packed params to pass to the receiver as extra information\n   * @param referralCode The code used to register the integrator originating the operation, for potential rewards.\n   *   0 if the action is executed directly by the user, without any middle-man\n   */\n  function flashLoanSimple(\n    address receiverAddress,\n    address asset,\n    uint256 amount,\n    bytes calldata params,\n    uint16 referralCode\n  ) external;\n\n  /**\n   * @notice Returns the user account data across all the reserves\n   * @param user The address of the user\n   * @return totalCollateralBase The total collateral of the user in the base currency used by the price feed\n   * @return totalDebtBase The total debt of the user in the base currency used by the price feed\n   * @return availableBorrowsBase The borrowing power left of the user in the base currency used by the price feed\n   * @return currentLiquidationThreshold The liquidation threshold of the user\n   * @return ltv The loan to value of The user\n   * @return healthFactor The current health factor of the user\n   */\n  function getUserAccountData(\n    address user\n  )\n    external\n    view\n    returns (\n      uint256 totalCollateralBase,\n      uint256 totalDebtBase,\n      uint256 availableBorrowsBase,\n      uint256 currentLiquidationThreshold,\n      uint256 ltv,\n      uint256 healthFactor\n    );\n\n  /**\n   * @notice Initializes a reserve, activating it, assigning an aToken and debt tokens and an\n   * interest rate strategy\n   * @dev Only callable by the PoolConfigurator contract\n   * @param asset The address of the underlying asset of the reserve\n   * @param aTokenAddress The address of the aToken that will be assigned to the reserve\n   * @param stableDebtAddress The address of the StableDebtToken that will be assigned to the reserve\n   * @param variableDebtAddress The address of the VariableDebtToken that will be assigned to the reserve\n   * @param interestRateStrategyAddress The address of the interest rate strategy contract\n   */\n  function initReserve(\n    address asset,\n    address aTokenAddress,\n    address stableDebtAddress,\n    address variableDebtAddress,\n    address interestRateStrategyAddress\n  ) external;\n\n  /**\n   * @notice Drop a reserve\n   * @dev Only callable by the PoolConfigurator contract\n   * @param asset The address of the underlying asset of the reserve\n   */\n  function dropReserve(address asset) external;\n\n  /**\n   * @notice Updates the address of the interest rate strategy contract\n   * @dev Only callable by the PoolConfigurator contract\n   * @param asset The address of the underlying asset of the reserve\n   * @param rateStrategyAddress The address of the interest rate strategy contract\n   */\n  function setReserveInterestRateStrategyAddress(\n    address asset,\n    address rateStrategyAddress\n  ) external;\n\n  /**\n   * @notice Sets the configuration bitmap of the reserve as a whole\n   * @dev Only callable by the PoolConfigurator contract\n   * @param asset The address of the underlying asset of the reserve\n   * @param configuration The new configuration bitmap\n   */\n  function setConfiguration(\n    address asset,\n    DataTypes.ReserveConfigurationMap calldata configuration\n  ) external;\n\n  /**\n   * @notice Returns the configuration of the reserve\n   * @param asset The address of the underlying asset of the reserve\n   * @return The configuration of the reserve\n   */\n  function getConfiguration(\n    address asset\n  ) external view returns (DataTypes.ReserveConfigurationMap memory);\n\n  /**\n   * @notice Returns the configuration of the user across all the reserves\n   * @param user The user address\n   * @return The configuration of the user\n   */\n  function getUserConfiguration(\n    address user\n  ) external view returns (DataTypes.UserConfigurationMap memory);\n\n  /**\n   * @notice Returns the normalized income of the reserve\n   * @param asset The address of the underlying asset of the reserve\n   * @return The reserve's normalized income\n   */\n  function getReserveNormalizedIncome(address asset) external view returns (uint256);\n\n  /**\n   * @notice Returns the normalized variable debt per unit of asset\n   * @dev WARNING: This function is intended to be used primarily by the protocol itself to get a\n   * \"dynamic\" variable index based on time, current stored index and virtual rate at the current\n   * moment (approx. a borrower would get if opening a position). This means that is always used in\n   * combination with variable debt supply/balances.\n   * If using this function externally, consider that is possible to have an increasing normalized\n   * variable debt that is not equivalent to how the variable debt index would be updated in storage\n   * (e.g. only updates with non-zero variable debt supply)\n   * @param asset The address of the underlying asset of the reserve\n   * @return The reserve normalized variable debt\n   */\n  function getReserveNormalizedVariableDebt(address asset) external view returns (uint256);\n\n  /**\n   * @notice Returns the state and configuration of the reserve\n   * @param asset The address of the underlying asset of the reserve\n   * @return The state and configuration data of the reserve\n   */\n  function getReserveData(address asset) external view returns (DataTypes.ReserveData memory);\n\n  /**\n   * @notice Validates and finalizes an aToken transfer\n   * @dev Only callable by the overlying aToken of the `asset`\n   * @param asset The address of the underlying asset of the aToken\n   * @param from The user from which the aTokens are transferred\n   * @param to The user receiving the aTokens\n   * @param amount The amount being transferred/withdrawn\n   * @param balanceFromBefore The aToken balance of the `from` user before the transfer\n   * @param balanceToBefore The aToken balance of the `to` user before the transfer\n   */\n  function finalizeTransfer(\n    address asset,\n    address from,\n    address to,\n    uint256 amount,\n    uint256 balanceFromBefore,\n    uint256 balanceToBefore\n  ) external;\n\n  /**\n   * @notice Returns the list of the underlying assets of all the initialized reserves\n   * @dev It does not include dropped reserves\n   * @return The addresses of the underlying assets of the initialized reserves\n   */\n  function getReservesList() external view returns (address[] memory);\n\n  /**\n   * @notice Returns the address of the underlying asset of a reserve by the reserve id as stored in the DataTypes.ReserveData struct\n   * @param id The id of the reserve as stored in the DataTypes.ReserveData struct\n   * @return The address of the reserve associated with id\n   */\n  function getReserveAddressById(uint16 id) external view returns (address);\n\n  /**\n   * @notice Returns the PoolAddressesProvider connected to this contract\n   * @return The address of the PoolAddressesProvider\n   */\n  function ADDRESSES_PROVIDER() external view returns (IPoolAddressesProvider);\n\n  /**\n   * @notice Updates the protocol fee on the bridging\n   * @param bridgeProtocolFee The part of the premium sent to the protocol treasury\n   */\n  function updateBridgeProtocolFee(uint256 bridgeProtocolFee) external;\n\n  /**\n   * @notice Updates flash loan premiums. Flash loan premium consists of two parts:\n   * - A part is sent to aToken holders as extra, one time accumulated interest\n   * - A part is collected by the protocol treasury\n   * @dev The total premium is calculated on the total borrowed amount\n   * @dev The premium to protocol is calculated on the total premium, being a percentage of `flashLoanPremiumTotal`\n   * @dev Only callable by the PoolConfigurator contract\n   * @param flashLoanPremiumTotal The total premium, expressed in bps\n   * @param flashLoanPremiumToProtocol The part of the premium sent to the protocol treasury, expressed in bps\n   */\n  function updateFlashloanPremiums(\n    uint128 flashLoanPremiumTotal,\n    uint128 flashLoanPremiumToProtocol\n  ) external;\n\n  /**\n   * @notice Configures a new category for the eMode.\n   * @dev In eMode, the protocol allows very high borrowing power to borrow assets of the same category.\n   * The category 0 is reserved as it's the default for volatile assets\n   * @param id The id of the category\n   * @param config The configuration of the category\n   */\n  function configureEModeCategory(uint8 id, DataTypes.EModeCategory memory config) external;\n\n  /**\n   * @notice Returns the data of an eMode category\n   * @param id The id of the category\n   * @return The configuration data of the category\n   */\n  function getEModeCategoryData(uint8 id) external view returns (DataTypes.EModeCategory memory);\n\n  /**\n   * @notice Allows a user to use the protocol in eMode\n   * @param categoryId The id of the category\n   */\n  function setUserEMode(uint8 categoryId) external;\n\n  /**\n   * @notice Returns the eMode the user is using\n   * @param user The address of the user\n   * @return The eMode id\n   */\n  function getUserEMode(address user) external view returns (uint256);\n\n  /**\n   * @notice Resets the isolation mode total debt of the given asset to zero\n   * @dev It requires the given asset has zero debt ceiling\n   * @param asset The address of the underlying asset to reset the isolationModeTotalDebt\n   */\n  function resetIsolationModeTotalDebt(address asset) external;\n\n  /**\n   * @notice Returns the percentage of available liquidity that can be borrowed at once at stable rate\n   * @return The percentage of available liquidity to borrow, expressed in bps\n   */\n  function MAX_STABLE_RATE_BORROW_SIZE_PERCENT() external view returns (uint256);\n\n  /**\n   * @notice Returns the total fee on flash loans\n   * @return The total fee on flashloans\n   */\n  function FLASHLOAN_PREMIUM_TOTAL() external view returns (uint128);\n\n  /**\n   * @notice Returns the part of the bridge fees sent to protocol\n   * @return The bridge fee sent to the protocol treasury\n   */\n  function BRIDGE_PROTOCOL_FEE() external view returns (uint256);\n\n  /**\n   * @notice Returns the part of the flashloan fees sent to protocol\n   * @return The flashloan fee sent to the protocol treasury\n   */\n  function FLASHLOAN_PREMIUM_TO_PROTOCOL() external view returns (uint128);\n\n  /**\n   * @notice Returns the maximum number of reserves supported to be listed in this Pool\n   * @return The maximum number of reserves supported\n   */\n  function MAX_NUMBER_RESERVES() external view returns (uint16);\n\n  /**\n   * @notice Mints the assets accrued through the reserve factor to the treasury in the form of aTokens\n   * @param assets The list of reserves for which the minting needs to be executed\n   */\n  function mintToTreasury(address[] calldata assets) external;\n\n  /**\n   * @notice Rescue and transfer tokens locked in this contract\n   * @param token The address of the token\n   * @param to The address of the recipient\n   * @param amount The amount of token to transfer\n   */\n  function rescueTokens(address token, address to, uint256 amount) external;\n\n  /**\n   * @notice Supplies an `amount` of underlying asset into the reserve, receiving in return overlying aTokens.\n   * - E.g. User supplies 100 USDC and gets in return 100 aUSDC\n   * @dev Deprecated: Use the `supply` function instead\n   * @param asset The address of the underlying asset to supply\n   * @param amount The amount to be supplied\n   * @param onBehalfOf The address that will receive the aTokens, same as msg.sender if the user\n   *   wants to receive them on his own wallet, or a different address if the beneficiary of aTokens\n   *   is a different wallet\n   * @param referralCode Code used to register the integrator originating the operation, for potential rewards.\n   *   0 if the action is executed directly by the user, without any middle-man\n   */\n  function deposit(address asset, uint256 amount, address onBehalfOf, uint16 referralCode) external;\n}\n"
      },
      "@aave/core-v3/contracts/interfaces/IPoolAddressesProvider.sol": {
        "content": "// SPDX-License-Identifier: AGPL-3.0\npragma solidity ^0.8.0;\n\n/**\n * @title IPoolAddressesProvider\n * @author Aave\n * @notice Defines the basic interface for a Pool Addresses Provider.\n */\ninterface IPoolAddressesProvider {\n  /**\n   * @dev Emitted when the market identifier is updated.\n   * @param oldMarketId The old id of the market\n   * @param newMarketId The new id of the market\n   */\n  event MarketIdSet(string indexed oldMarketId, string indexed newMarketId);\n\n  /**\n   * @dev Emitted when the pool is updated.\n   * @param oldAddress The old address of the Pool\n   * @param newAddress The new address of the Pool\n   */\n  event PoolUpdated(address indexed oldAddress, address indexed newAddress);\n\n  /**\n   * @dev Emitted when the pool configurator is updated.\n   * @param oldAddress The old address of the PoolConfigurator\n   * @param newAddress The new address of the PoolConfigurator\n   */\n  event PoolConfiguratorUpdated(address indexed oldAddress, address indexed newAddress);\n\n  /**\n   * @dev Emitted when the price oracle is updated.\n   * @param oldAddress The old address of the PriceOracle\n   * @param newAddress The new address of the PriceOracle\n   */\n  event PriceOracleUpdated(address indexed oldAddress, address indexed newAddress);\n\n  /**\n   * @dev Emitted when the ACL manager is updated.\n   * @param oldAddress The old address of the ACLManager\n   * @param newAddress The new address of the ACLManager\n   */\n  event ACLManagerUpdated(address indexed oldAddress, address indexed newAddress);\n\n  /**\n   * @dev Emitted when the ACL admin is updated.\n   * @param oldAddress The old address of the ACLAdmin\n   * @param newAddress The new address of the ACLAdmin\n   */\n  event ACLAdminUpdated(address indexed oldAddress, address indexed newAddress);\n\n  /**\n   * @dev Emitted when the price oracle sentinel is updated.\n   * @param oldAddress The old address of the PriceOracleSentinel\n   * @param newAddress The new address of the PriceOracleSentinel\n   */\n  event PriceOracleSentinelUpdated(address indexed oldAddress, address indexed newAddress);\n\n  /**\n   * @dev Emitted when the pool data provider is updated.\n   * @param oldAddress The old address of the PoolDataProvider\n   * @param newAddress The new address of the PoolDataProvider\n   */\n  event PoolDataProviderUpdated(address indexed oldAddress, address indexed newAddress);\n\n  /**\n   * @dev Emitted when a new proxy is created.\n   * @param id The identifier of the proxy\n   * @param proxyAddress The address of the created proxy contract\n   * @param implementationAddress The address of the implementation contract\n   */\n  event ProxyCreated(\n    bytes32 indexed id,\n    address indexed proxyAddress,\n    address indexed implementationAddress\n  );\n\n  /**\n   * @dev Emitted when a new non-proxied contract address is registered.\n   * @param id The identifier of the contract\n   * @param oldAddress The address of the old contract\n   * @param newAddress The address of the new contract\n   */\n  event AddressSet(bytes32 indexed id, address indexed oldAddress, address indexed newAddress);\n\n  /**\n   * @dev Emitted when the implementation of the proxy registered with id is updated\n   * @param id The identifier of the contract\n   * @param proxyAddress The address of the proxy contract\n   * @param oldImplementationAddress The address of the old implementation contract\n   * @param newImplementationAddress The address of the new implementation contract\n   */\n  event AddressSetAsProxy(\n    bytes32 indexed id,\n    address indexed proxyAddress,\n    address oldImplementationAddress,\n    address indexed newImplementationAddress\n  );\n\n  /**\n   * @notice Returns the id of the Aave market to which this contract points to.\n   * @return The market id\n   */\n  function getMarketId() external view returns (string memory);\n\n  /**\n   * @notice Associates an id with a specific PoolAddressesProvider.\n   * @dev This can be used to create an onchain registry of PoolAddressesProviders to\n   * identify and validate multiple Aave markets.\n   * @param newMarketId The market id\n   */\n  function setMarketId(string calldata newMarketId) external;\n\n  /**\n   * @notice Returns an address by its identifier.\n   * @dev The returned address might be an EOA or a contract, potentially proxied\n   * @dev It returns ZERO if there is no registered address with the given id\n   * @param id The id\n   * @return The address of the registered for the specified id\n   */\n  function getAddress(bytes32 id) external view returns (address);\n\n  /**\n   * @notice General function to update the implementation of a proxy registered with\n   * certain `id`. If there is no proxy registered, it will instantiate one and\n   * set as implementation the `newImplementationAddress`.\n   * @dev IMPORTANT Use this function carefully, only for ids that don't have an explicit\n   * setter function, in order to avoid unexpected consequences\n   * @param id The id\n   * @param newImplementationAddress The address of the new implementation\n   */\n  function setAddressAsProxy(bytes32 id, address newImplementationAddress) external;\n\n  /**\n   * @notice Sets an address for an id replacing the address saved in the addresses map.\n   * @dev IMPORTANT Use this function carefully, as it will do a hard replacement\n   * @param id The id\n   * @param newAddress The address to set\n   */\n  function setAddress(bytes32 id, address newAddress) external;\n\n  /**\n   * @notice Returns the address of the Pool proxy.\n   * @return The Pool proxy address\n   */\n  function getPool() external view returns (address);\n\n  /**\n   * @notice Updates the implementation of the Pool, or creates a proxy\n   * setting the new `pool` implementation when the function is called for the first time.\n   * @param newPoolImpl The new Pool implementation\n   */\n  function setPoolImpl(address newPoolImpl) external;\n\n  /**\n   * @notice Returns the address of the PoolConfigurator proxy.\n   * @return The PoolConfigurator proxy address\n   */\n  function getPoolConfigurator() external view returns (address);\n\n  /**\n   * @notice Updates the implementation of the PoolConfigurator, or creates a proxy\n   * setting the new `PoolConfigurator` implementation when the function is called for the first time.\n   * @param newPoolConfiguratorImpl The new PoolConfigurator implementation\n   */\n  function setPoolConfiguratorImpl(address newPoolConfiguratorImpl) external;\n\n  /**\n   * @notice Returns the address of the price oracle.\n   * @return The address of the PriceOracle\n   */\n  function getPriceOracle() external view returns (address);\n\n  /**\n   * @notice Updates the address of the price oracle.\n   * @param newPriceOracle The address of the new PriceOracle\n   */\n  function setPriceOracle(address newPriceOracle) external;\n\n  /**\n   * @notice Returns the address of the ACL manager.\n   * @return The address of the ACLManager\n   */\n  function getACLManager() external view returns (address);\n\n  /**\n   * @notice Updates the address of the ACL manager.\n   * @param newAclManager The address of the new ACLManager\n   */\n  function setACLManager(address newAclManager) external;\n\n  /**\n   * @notice Returns the address of the ACL admin.\n   * @return The address of the ACL admin\n   */\n  function getACLAdmin() external view returns (address);\n\n  /**\n   * @notice Updates the address of the ACL admin.\n   * @param newAclAdmin The address of the new ACL admin\n   */\n  function setACLAdmin(address newAclAdmin) external;\n\n  /**\n   * @notice Returns the address of the price oracle sentinel.\n   * @return The address of the PriceOracleSentinel\n   */\n  function getPriceOracleSentinel() external view returns (address);\n\n  /**\n   * @notice Updates the address of the price oracle sentinel.\n   * @param newPriceOracleSentinel The address of the new PriceOracleSentinel\n   */\n  function setPriceOracleSentinel(address newPriceOracleSentinel) external;\n\n  /**\n   * @notice Returns the address of the data provider.\n   * @return The address of the DataProvider\n   */\n  function getPoolDataProvider() external view returns (address);\n\n  /**\n   * @notice Updates the address of the data provider.\n   * @param newDataProvider The address of the new DataProvider\n   */\n  function setPoolDataProvider(address newDataProvider) external;\n}\n"
      },
      "@aave/core-v3/contracts/interfaces/IPoolDataProvider.sol": {
        "content": "// SPDX-License-Identifier: AGPL-3.0\npragma solidity ^0.8.0;\n\nimport {IPoolAddressesProvider} from './IPoolAddressesProvider.sol';\n\n/**\n * @title IPoolDataProvider\n * @author Aave\n * @notice Defines the basic interface of a PoolDataProvider\n */\ninterface IPoolDataProvider {\n  struct TokenData {\n    string symbol;\n    address tokenAddress;\n  }\n\n  /**\n   * @notice Returns the address for the PoolAddressesProvider contract.\n   * @return The address for the PoolAddressesProvider contract\n   */\n  function ADDRESSES_PROVIDER() external view returns (IPoolAddressesProvider);\n\n  /**\n   * @notice Returns the list of the existing reserves in the pool.\n   * @dev Handling MKR and ETH in a different way since they do not have standard `symbol` functions.\n   * @return The list of reserves, pairs of symbols and addresses\n   */\n  function getAllReservesTokens() external view returns (TokenData[] memory);\n\n  /**\n   * @notice Returns the list of the existing ATokens in the pool.\n   * @return The list of ATokens, pairs of symbols and addresses\n   */\n  function getAllATokens() external view returns (TokenData[] memory);\n\n  /**\n   * @notice Returns the configuration data of the reserve\n   * @dev Not returning borrow and supply caps for compatibility, nor pause flag\n   * @param asset The address of the underlying asset of the reserve\n   * @return decimals The number of decimals of the reserve\n   * @return ltv The ltv of the reserve\n   * @return liquidationThreshold The liquidationThreshold of the reserve\n   * @return liquidationBonus The liquidationBonus of the reserve\n   * @return reserveFactor The reserveFactor of the reserve\n   * @return usageAsCollateralEnabled True if the usage as collateral is enabled, false otherwise\n   * @return borrowingEnabled True if borrowing is enabled, false otherwise\n   * @return stableBorrowRateEnabled True if stable rate borrowing is enabled, false otherwise\n   * @return isActive True if it is active, false otherwise\n   * @return isFrozen True if it is frozen, false otherwise\n   */\n  function getReserveConfigurationData(\n    address asset\n  )\n    external\n    view\n    returns (\n      uint256 decimals,\n      uint256 ltv,\n      uint256 liquidationThreshold,\n      uint256 liquidationBonus,\n      uint256 reserveFactor,\n      bool usageAsCollateralEnabled,\n      bool borrowingEnabled,\n      bool stableBorrowRateEnabled,\n      bool isActive,\n      bool isFrozen\n    );\n\n  /**\n   * @notice Returns the efficiency mode category of the reserve\n   * @param asset The address of the underlying asset of the reserve\n   * @return The eMode id of the reserve\n   */\n  function getReserveEModeCategory(address asset) external view returns (uint256);\n\n  /**\n   * @notice Returns the caps parameters of the reserve\n   * @param asset The address of the underlying asset of the reserve\n   * @return borrowCap The borrow cap of the reserve\n   * @return supplyCap The supply cap of the reserve\n   */\n  function getReserveCaps(\n    address asset\n  ) external view returns (uint256 borrowCap, uint256 supplyCap);\n\n  /**\n   * @notice Returns if the pool is paused\n   * @param asset The address of the underlying asset of the reserve\n   * @return isPaused True if the pool is paused, false otherwise\n   */\n  function getPaused(address asset) external view returns (bool isPaused);\n\n  /**\n   * @notice Returns the siloed borrowing flag\n   * @param asset The address of the underlying asset of the reserve\n   * @return True if the asset is siloed for borrowing\n   */\n  function getSiloedBorrowing(address asset) external view returns (bool);\n\n  /**\n   * @notice Returns the protocol fee on the liquidation bonus\n   * @param asset The address of the underlying asset of the reserve\n   * @return The protocol fee on liquidation\n   */\n  function getLiquidationProtocolFee(address asset) external view returns (uint256);\n\n  /**\n   * @notice Returns the unbacked mint cap of the reserve\n   * @param asset The address of the underlying asset of the reserve\n   * @return The unbacked mint cap of the reserve\n   */\n  function getUnbackedMintCap(address asset) external view returns (uint256);\n\n  /**\n   * @notice Returns the debt ceiling of the reserve\n   * @param asset The address of the underlying asset of the reserve\n   * @return The debt ceiling of the reserve\n   */\n  function getDebtCeiling(address asset) external view returns (uint256);\n\n  /**\n   * @notice Returns the debt ceiling decimals\n   * @return The debt ceiling decimals\n   */\n  function getDebtCeilingDecimals() external pure returns (uint256);\n\n  /**\n   * @notice Returns the reserve data\n   * @param asset The address of the underlying asset of the reserve\n   * @return unbacked The amount of unbacked tokens\n   * @return accruedToTreasuryScaled The scaled amount of tokens accrued to treasury that is to be minted\n   * @return totalAToken The total supply of the aToken\n   * @return totalStableDebt The total stable debt of the reserve\n   * @return totalVariableDebt The total variable debt of the reserve\n   * @return liquidityRate The liquidity rate of the reserve\n   * @return variableBorrowRate The variable borrow rate of the reserve\n   * @return stableBorrowRate The stable borrow rate of the reserve\n   * @return averageStableBorrowRate The average stable borrow rate of the reserve\n   * @return liquidityIndex The liquidity index of the reserve\n   * @return variableBorrowIndex The variable borrow index of the reserve\n   * @return lastUpdateTimestamp The timestamp of the last update of the reserve\n   */\n  function getReserveData(\n    address asset\n  )\n    external\n    view\n    returns (\n      uint256 unbacked,\n      uint256 accruedToTreasuryScaled,\n      uint256 totalAToken,\n      uint256 totalStableDebt,\n      uint256 totalVariableDebt,\n      uint256 liquidityRate,\n      uint256 variableBorrowRate,\n      uint256 stableBorrowRate,\n      uint256 averageStableBorrowRate,\n      uint256 liquidityIndex,\n      uint256 variableBorrowIndex,\n      uint40 lastUpdateTimestamp\n    );\n\n  /**\n   * @notice Returns the total supply of aTokens for a given asset\n   * @param asset The address of the underlying asset of the reserve\n   * @return The total supply of the aToken\n   */\n  function getATokenTotalSupply(address asset) external view returns (uint256);\n\n  /**\n   * @notice Returns the total debt for a given asset\n   * @param asset The address of the underlying asset of the reserve\n   * @return The total debt for asset\n   */\n  function getTotalDebt(address asset) external view returns (uint256);\n\n  /**\n   * @notice Returns the user data in a reserve\n   * @param asset The address of the underlying asset of the reserve\n   * @param user The address of the user\n   * @return currentATokenBalance The current AToken balance of the user\n   * @return currentStableDebt The current stable debt of the user\n   * @return currentVariableDebt The current variable debt of the user\n   * @return principalStableDebt The principal stable debt of the user\n   * @return scaledVariableDebt The scaled variable debt of the user\n   * @return stableBorrowRate The stable borrow rate of the user\n   * @return liquidityRate The liquidity rate of the reserve\n   * @return stableRateLastUpdated The timestamp of the last update of the user stable rate\n   * @return usageAsCollateralEnabled True if the user is using the asset as collateral, false\n   *         otherwise\n   */\n  function getUserReserveData(\n    address asset,\n    address user\n  )\n    external\n    view\n    returns (\n      uint256 currentATokenBalance,\n      uint256 currentStableDebt,\n      uint256 currentVariableDebt,\n      uint256 principalStableDebt,\n      uint256 scaledVariableDebt,\n      uint256 stableBorrowRate,\n      uint256 liquidityRate,\n      uint40 stableRateLastUpdated,\n      bool usageAsCollateralEnabled\n    );\n\n  /**\n   * @notice Returns the token addresses of the reserve\n   * @param asset The address of the underlying asset of the reserve\n   * @return aTokenAddress The AToken address of the reserve\n   * @return stableDebtTokenAddress The StableDebtToken address of the reserve\n   * @return variableDebtTokenAddress The VariableDebtToken address of the reserve\n   */\n  function getReserveTokensAddresses(\n    address asset\n  )\n    external\n    view\n    returns (\n      address aTokenAddress,\n      address stableDebtTokenAddress,\n      address variableDebtTokenAddress\n    );\n\n  /**\n   * @notice Returns the address of the Interest Rate strategy\n   * @param asset The address of the underlying asset of the reserve\n   * @return irStrategyAddress The address of the Interest Rate strategy\n   */\n  function getInterestRateStrategyAddress(\n    address asset\n  ) external view returns (address irStrategyAddress);\n\n  /**\n   * @notice Returns whether the reserve has FlashLoans enabled or disabled\n   * @param asset The address of the underlying asset of the reserve\n   * @return True if FlashLoans are enabled, false otherwise\n   */\n  function getFlashLoanEnabled(address asset) external view returns (bool);\n}\n"
      },
      "@aave/core-v3/contracts/protocol/libraries/types/DataTypes.sol": {
        "content": "// SPDX-License-Identifier: BUSL-1.1\npragma solidity ^0.8.0;\n\nlibrary DataTypes {\n  struct ReserveData {\n    //stores the reserve configuration\n    ReserveConfigurationMap configuration;\n    //the liquidity index. Expressed in ray\n    uint128 liquidityIndex;\n    //the current supply rate. Expressed in ray\n    uint128 currentLiquidityRate;\n    //variable borrow index. Expressed in ray\n    uint128 variableBorrowIndex;\n    //the current variable borrow rate. Expressed in ray\n    uint128 currentVariableBorrowRate;\n    //the current stable borrow rate. Expressed in ray\n    uint128 currentStableBorrowRate;\n    //timestamp of last update\n    uint40 lastUpdateTimestamp;\n    //the id of the reserve. Represents the position in the list of the active reserves\n    uint16 id;\n    //aToken address\n    address aTokenAddress;\n    //stableDebtToken address\n    address stableDebtTokenAddress;\n    //variableDebtToken address\n    address variableDebtTokenAddress;\n    //address of the interest rate strategy\n    address interestRateStrategyAddress;\n    //the current treasury balance, scaled\n    uint128 accruedToTreasury;\n    //the outstanding unbacked aTokens minted through the bridging feature\n    uint128 unbacked;\n    //the outstanding debt borrowed against this asset in isolation mode\n    uint128 isolationModeTotalDebt;\n  }\n\n  struct ReserveConfigurationMap {\n    //bit 0-15: LTV\n    //bit 16-31: Liq. threshold\n    //bit 32-47: Liq. bonus\n    //bit 48-55: Decimals\n    //bit 56: reserve is active\n    //bit 57: reserve is frozen\n    //bit 58: borrowing is enabled\n    //bit 59: stable rate borrowing enabled\n    //bit 60: asset is paused\n    //bit 61: borrowing in isolation mode is enabled\n    //bit 62: siloed borrowing enabled\n    //bit 63: flashloaning enabled\n    //bit 64-79: reserve factor\n    //bit 80-115 borrow cap in whole tokens, borrowCap == 0 => no cap\n    //bit 116-151 supply cap in whole tokens, supplyCap == 0 => no cap\n    //bit 152-167 liquidation protocol fee\n    //bit 168-175 eMode category\n    //bit 176-211 unbacked mint cap in whole tokens, unbackedMintCap == 0 => minting disabled\n    //bit 212-251 debt ceiling for isolation mode with (ReserveConfiguration::DEBT_CEILING_DECIMALS) decimals\n    //bit 252-255 unused\n\n    uint256 data;\n  }\n\n  struct UserConfigurationMap {\n    /**\n     * @dev Bitmap of the users collaterals and borrows. It is divided in pairs of bits, one pair per asset.\n     * The first bit indicates if an asset is used as collateral by the user, the second whether an\n     * asset is borrowed by the user.\n     */\n    uint256 data;\n  }\n\n  struct EModeCategory {\n    // each eMode category has a custom ltv and liquidation threshold\n    uint16 ltv;\n    uint16 liquidationThreshold;\n    uint16 liquidationBonus;\n    // each eMode category may or may not have a custom oracle to override the individual assets price oracles\n    address priceSource;\n    string label;\n  }\n\n  enum InterestRateMode {NONE, STABLE, VARIABLE}\n\n  struct ReserveCache {\n    uint256 currScaledVariableDebt;\n    uint256 nextScaledVariableDebt;\n    uint256 currPrincipalStableDebt;\n    uint256 currAvgStableBorrowRate;\n    uint256 currTotalStableDebt;\n    uint256 nextAvgStableBorrowRate;\n    uint256 nextTotalStableDebt;\n    uint256 currLiquidityIndex;\n    uint256 nextLiquidityIndex;\n    uint256 currVariableBorrowIndex;\n    uint256 nextVariableBorrowIndex;\n    uint256 currLiquidityRate;\n    uint256 currVariableBorrowRate;\n    uint256 reserveFactor;\n    ReserveConfigurationMap reserveConfiguration;\n    address aTokenAddress;\n    address stableDebtTokenAddress;\n    address variableDebtTokenAddress;\n    uint40 reserveLastUpdateTimestamp;\n    uint40 stableDebtLastUpdateTimestamp;\n  }\n\n  struct ExecuteLiquidationCallParams {\n    uint256 reservesCount;\n    uint256 debtToCover;\n    address collateralAsset;\n    address debtAsset;\n    address user;\n    bool receiveAToken;\n    address priceOracle;\n    uint8 userEModeCategory;\n    address priceOracleSentinel;\n  }\n\n  struct ExecuteSupplyParams {\n    address asset;\n    uint256 amount;\n    address onBehalfOf;\n    uint16 referralCode;\n  }\n\n  struct ExecuteBorrowParams {\n    address asset;\n    address user;\n    address onBehalfOf;\n    uint256 amount;\n    InterestRateMode interestRateMode;\n    uint16 referralCode;\n    bool releaseUnderlying;\n    uint256 maxStableRateBorrowSizePercent;\n    uint256 reservesCount;\n    address oracle;\n    uint8 userEModeCategory;\n    address priceOracleSentinel;\n  }\n\n  struct ExecuteRepayParams {\n    address asset;\n    uint256 amount;\n    InterestRateMode interestRateMode;\n    address onBehalfOf;\n    bool useATokens;\n  }\n\n  struct ExecuteWithdrawParams {\n    address asset;\n    uint256 amount;\n    address to;\n    uint256 reservesCount;\n    address oracle;\n    uint8 userEModeCategory;\n  }\n\n  struct ExecuteSetUserEModeParams {\n    uint256 reservesCount;\n    address oracle;\n    uint8 categoryId;\n  }\n\n  struct FinalizeTransferParams {\n    address asset;\n    address from;\n    address to;\n    uint256 amount;\n    uint256 balanceFromBefore;\n    uint256 balanceToBefore;\n    uint256 reservesCount;\n    address oracle;\n    uint8 fromEModeCategory;\n  }\n\n  struct FlashloanParams {\n    address receiverAddress;\n    address[] assets;\n    uint256[] amounts;\n    uint256[] interestRateModes;\n    address onBehalfOf;\n    bytes params;\n    uint16 referralCode;\n    uint256 flashLoanPremiumToProtocol;\n    uint256 flashLoanPremiumTotal;\n    uint256 maxStableRateBorrowSizePercent;\n    uint256 reservesCount;\n    address addressesProvider;\n    uint8 userEModeCategory;\n    bool isAuthorizedFlashBorrower;\n  }\n\n  struct FlashloanSimpleParams {\n    address receiverAddress;\n    address asset;\n    uint256 amount;\n    bytes params;\n    uint16 referralCode;\n    uint256 flashLoanPremiumToProtocol;\n    uint256 flashLoanPremiumTotal;\n  }\n\n  struct FlashLoanRepaymentParams {\n    uint256 amount;\n    uint256 totalPremium;\n    uint256 flashLoanPremiumToProtocol;\n    address asset;\n    address receiverAddress;\n    uint16 referralCode;\n  }\n\n  struct CalculateUserAccountDataParams {\n    UserConfigurationMap userConfig;\n    uint256 reservesCount;\n    address user;\n    address oracle;\n    uint8 userEModeCategory;\n  }\n\n  struct ValidateBorrowParams {\n    ReserveCache reserveCache;\n    UserConfigurationMap userConfig;\n    address asset;\n    address userAddress;\n    uint256 amount;\n    InterestRateMode interestRateMode;\n    uint256 maxStableLoanPercent;\n    uint256 reservesCount;\n    address oracle;\n    uint8 userEModeCategory;\n    address priceOracleSentinel;\n    bool isolationModeActive;\n    address isolationModeCollateralAddress;\n    uint256 isolationModeDebtCeiling;\n  }\n\n  struct ValidateLiquidationCallParams {\n    ReserveCache debtReserveCache;\n    uint256 totalDebt;\n    uint256 healthFactor;\n    address priceOracleSentinel;\n  }\n\n  struct CalculateInterestRatesParams {\n    uint256 unbacked;\n    uint256 liquidityAdded;\n    uint256 liquidityTaken;\n    uint256 totalStableDebt;\n    uint256 totalVariableDebt;\n    uint256 averageStableBorrowRate;\n    uint256 reserveFactor;\n    address reserve;\n    address aToken;\n  }\n\n  struct InitReserveParams {\n    address asset;\n    address aTokenAddress;\n    address stableDebtAddress;\n    address variableDebtAddress;\n    address interestRateStrategyAddress;\n    uint16 reservesCount;\n    uint16 maxNumberReserves;\n  }\n}\n"
      },
      "@openzeppelin/contracts/token/ERC20/extensions/IERC20Permit.sol": {
        "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v5.0.0) (token/ERC20/extensions/IERC20Permit.sol)\n\npragma solidity ^0.8.20;\n\n/**\n * @dev Interface of the ERC20 Permit extension allowing approvals to be made via signatures, as defined in\n * https://eips.ethereum.org/EIPS/eip-2612[EIP-2612].\n *\n * Adds the {permit} method, which can be used to change an account's ERC20 allowance (see {IERC20-allowance}) by\n * presenting a message signed by the account. By not relying on {IERC20-approve}, the token holder account doesn't\n * need to send a transaction, and thus is not required to hold Ether at all.\n *\n * ==== Security Considerations\n *\n * There are two important considerations concerning the use of `permit`. The first is that a valid permit signature\n * expresses an allowance, and it should not be assumed to convey additional meaning. In particular, it should not be\n * considered as an intention to spend the allowance in any specific way. The second is that because permits have\n * built-in replay protection and can be submitted by anyone, they can be frontrun. A protocol that uses permits should\n * take this into consideration and allow a `permit` call to fail. Combining these two aspects, a pattern that may be\n * generally recommended is:\n *\n * ```solidity\n * function doThingWithPermit(..., uint256 value, uint256 deadline, uint8 v, bytes32 r, bytes32 s) public {\n *     try token.permit(msg.sender, address(this), value, deadline, v, r, s) {} catch {}\n *     doThing(..., value);\n * }\n *\n * function doThing(..., uint256 value) public {\n *     token.safeTransferFrom(msg.sender, address(this), value);\n *     ...\n * }\n * ```\n *\n * Observe that: 1) `msg.sender` is used as the owner, leaving no ambiguity as to the signer intent, and 2) the use of\n * `try/catch` allows the permit to fail and makes the code tolerant to frontrunning. (See also\n * {SafeERC20-safeTransferFrom}).\n *\n * Additionally, note that smart contract wallets (such as Argent or Safe) are not able to produce permit signatures, so\n * contracts should have entry points that don't rely on permit.\n */\ninterface IERC20Permit {\n    /**\n     * @dev Sets `value` as the allowance of `spender` over ``owner``'s tokens,\n     * given ``owner``'s signed approval.\n     *\n     * IMPORTANT: The same issues {IERC20-approve} has related to transaction\n     * ordering also apply here.\n     *\n     * Emits an {Approval} event.\n     *\n     * Requirements:\n     *\n     * - `spender` cannot be the zero address.\n     * - `deadline` must be a timestamp in the future.\n     * - `v`, `r` and `s` must be a valid `secp256k1` signature from `owner`\n     * over the EIP712-formatted function arguments.\n     * - the signature must use ``owner``'s current nonce (see {nonces}).\n     *\n     * For more information on the signature format, see the\n     * https://eips.ethereum.org/EIPS/eip-2612#specification[relevant EIP\n     * section].\n     *\n     * CAUTION: See Security Considerations above.\n     */\n    function permit(\n        address owner,\n        address spender,\n        uint256 value,\n        uint256 deadline,\n        uint8 v,\n        bytes32 r,\n        bytes32 s\n    ) external;\n\n    /**\n     * @dev Returns the current nonce for `owner`. This value must be\n     * included whenever a signature is generated for {permit}.\n     *\n     * Every successful call to {permit} increases ``owner``'s nonce by one. This\n     * prevents a signature from being used multiple times.\n     */\n    function nonces(address owner) external view returns (uint256);\n\n    /**\n     * @dev Returns the domain separator used in the encoding of the signature for {permit}, as defined by {EIP712}.\n     */\n    // solhint-disable-next-line func-name-mixedcase\n    function DOMAIN_SEPARATOR() external view returns (bytes32);\n}\n"
      },
      "@openzeppelin/contracts/token/ERC20/IERC20.sol": {
        "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v5.0.0) (token/ERC20/IERC20.sol)\n\npragma solidity ^0.8.20;\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 value of tokens in existence.\n     */\n    function totalSupply() external view returns (uint256);\n\n    /**\n     * @dev Returns the value of tokens owned by `account`.\n     */\n    function balanceOf(address account) external view returns (uint256);\n\n    /**\n     * @dev Moves a `value` amount of 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 value) 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 a `value` amount of tokens as the allowance of `spender` over the\n     * 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 value) external returns (bool);\n\n    /**\n     * @dev Moves a `value` amount of tokens from `from` to `to` using the\n     * allowance mechanism. `value` is then deducted from the caller's\n     * allowance.\n     *\n     * Returns a boolean value indicating whether the operation succeeded.\n     *\n     * Emits a {Transfer} event.\n     */\n    function transferFrom(address from, address to, uint256 value) external returns (bool);\n}\n"
      },
      "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol": {
        "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v5.0.0) (token/ERC20/utils/SafeERC20.sol)\n\npragma solidity ^0.8.20;\n\nimport {IERC20} from \"../IERC20.sol\";\nimport {IERC20Permit} from \"../extensions/IERC20Permit.sol\";\nimport {Address} from \"../../../utils/Address.sol\";\n\n/**\n * @title SafeERC20\n * @dev Wrappers around ERC20 operations that throw on failure (when the token\n * contract returns false). Tokens that return no value (and instead revert or\n * throw on failure) are also supported, non-reverting calls are assumed to be\n * successful.\n * To use this library you can add a `using SafeERC20 for IERC20;` statement to your contract,\n * which allows you to call the safe operations as `token.safeTransfer(...)`, etc.\n */\nlibrary SafeERC20 {\n    using Address for address;\n\n    /**\n     * @dev An operation with an ERC20 token failed.\n     */\n    error SafeERC20FailedOperation(address token);\n\n    /**\n     * @dev Indicates a failed `decreaseAllowance` request.\n     */\n    error SafeERC20FailedDecreaseAllowance(address spender, uint256 currentAllowance, uint256 requestedDecrease);\n\n    /**\n     * @dev Transfer `value` amount of `token` from the calling contract to `to`. If `token` returns no value,\n     * non-reverting calls are assumed to be successful.\n     */\n    function safeTransfer(IERC20 token, address to, uint256 value) internal {\n        _callOptionalReturn(token, abi.encodeCall(token.transfer, (to, value)));\n    }\n\n    /**\n     * @dev Transfer `value` amount of `token` from `from` to `to`, spending the approval given by `from` to the\n     * calling contract. If `token` returns no value, non-reverting calls are assumed to be successful.\n     */\n    function safeTransferFrom(IERC20 token, address from, address to, uint256 value) internal {\n        _callOptionalReturn(token, abi.encodeCall(token.transferFrom, (from, to, value)));\n    }\n\n    /**\n     * @dev Increase the calling contract's allowance toward `spender` by `value`. If `token` returns no value,\n     * non-reverting calls are assumed to be successful.\n     */\n    function safeIncreaseAllowance(IERC20 token, address spender, uint256 value) internal {\n        uint256 oldAllowance = token.allowance(address(this), spender);\n        forceApprove(token, spender, oldAllowance + value);\n    }\n\n    /**\n     * @dev Decrease the calling contract's allowance toward `spender` by `requestedDecrease`. If `token` returns no\n     * value, non-reverting calls are assumed to be successful.\n     */\n    function safeDecreaseAllowance(IERC20 token, address spender, uint256 requestedDecrease) internal {\n        unchecked {\n            uint256 currentAllowance = token.allowance(address(this), spender);\n            if (currentAllowance < requestedDecrease) {\n                revert SafeERC20FailedDecreaseAllowance(spender, currentAllowance, requestedDecrease);\n            }\n            forceApprove(token, spender, currentAllowance - requestedDecrease);\n        }\n    }\n\n    /**\n     * @dev Set the calling contract's allowance toward `spender` to `value`. If `token` returns no value,\n     * non-reverting calls are assumed to be successful. Meant to be used with tokens that require the approval\n     * to be set to zero before setting it to a non-zero value, such as USDT.\n     */\n    function forceApprove(IERC20 token, address spender, uint256 value) internal {\n        bytes memory approvalCall = abi.encodeCall(token.approve, (spender, value));\n\n        if (!_callOptionalReturnBool(token, approvalCall)) {\n            _callOptionalReturn(token, abi.encodeCall(token.approve, (spender, 0)));\n            _callOptionalReturn(token, approvalCall);\n        }\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);\n        if (returndata.length != 0 && !abi.decode(returndata, (bool))) {\n            revert SafeERC20FailedOperation(address(token));\n        }\n    }\n\n    /**\n     * @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement\n     * on the return value: the return value is optional (but if data is returned, it must not be false).\n     * @param token The token targeted by the call.\n     * @param data The call data (encoded using abi.encode or one of its variants).\n     *\n     * This is a variant of {_callOptionalReturn} that silents catches all reverts and returns a bool instead.\n     */\n    function _callOptionalReturnBool(IERC20 token, bytes memory data) private returns (bool) {\n        // We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since\n        // we're implementing it ourselves. We cannot use {Address-functionCall} here since this should return false\n        // and not revert is the subcall reverts.\n\n        (bool success, bytes memory returndata) = address(token).call(data);\n        return success && (returndata.length == 0 || abi.decode(returndata, (bool))) && address(token).code.length > 0;\n    }\n}\n"
      },
      "@openzeppelin/contracts/utils/Address.sol": {
        "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v5.0.0) (utils/Address.sol)\n\npragma solidity ^0.8.20;\n\n/**\n * @dev Collection of functions related to the address type\n */\nlibrary Address {\n    /**\n     * @dev The ETH balance of the account is not enough to perform the operation.\n     */\n    error AddressInsufficientBalance(address account);\n\n    /**\n     * @dev There's no code at `target` (it is not a contract).\n     */\n    error AddressEmptyCode(address target);\n\n    /**\n     * @dev A call to an address target failed. The target may have reverted.\n     */\n    error FailedInnerCall();\n\n    /**\n     * @dev Replacement for Solidity's `transfer`: sends `amount` wei to\n     * `recipient`, forwarding all available gas and reverting on errors.\n     *\n     * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost\n     * of certain opcodes, possibly making contracts go over the 2300 gas limit\n     * imposed by `transfer`, making them unable to receive funds via\n     * `transfer`. {sendValue} removes this limitation.\n     *\n     * https://consensys.net/diligence/blog/2019/09/stop-using-soliditys-transfer-now/[Learn more].\n     *\n     * IMPORTANT: because control is transferred to `recipient`, care must be\n     * taken to not create reentrancy vulnerabilities. Consider using\n     * {ReentrancyGuard} or the\n     * https://solidity.readthedocs.io/en/v0.8.20/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].\n     */\n    function sendValue(address payable recipient, uint256 amount) internal {\n        if (address(this).balance < amount) {\n            revert AddressInsufficientBalance(address(this));\n        }\n\n        (bool success, ) = recipient.call{value: amount}(\"\");\n        if (!success) {\n            revert FailedInnerCall();\n        }\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 or custom error, it is bubbled\n     * up by this function (like regular Solidity function calls). However, if\n     * the call reverted with no returned reason, this function reverts with a\n     * {FailedInnerCall} error.\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    function functionCall(address target, bytes memory data) internal returns (bytes memory) {\n        return functionCallWithValue(target, data, 0);\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    function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) {\n        if (address(this).balance < value) {\n            revert AddressInsufficientBalance(address(this));\n        }\n        (bool success, bytes memory returndata) = target.call{value: value}(data);\n        return verifyCallResultFromTarget(target, success, returndata);\n    }\n\n    /**\n     * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n     * but performing a static call.\n     */\n    function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {\n        (bool success, bytes memory returndata) = target.staticcall(data);\n        return verifyCallResultFromTarget(target, success, returndata);\n    }\n\n    /**\n     * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n     * but performing a delegate call.\n     */\n    function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {\n        (bool success, bytes memory returndata) = target.delegatecall(data);\n        return verifyCallResultFromTarget(target, success, returndata);\n    }\n\n    /**\n     * @dev Tool to verify that a low level call to smart-contract was successful, and reverts if the target\n     * was not a contract or bubbling up the revert reason (falling back to {FailedInnerCall}) in case of an\n     * unsuccessful call.\n     */\n    function verifyCallResultFromTarget(\n        address target,\n        bool success,\n        bytes memory returndata\n    ) internal view returns (bytes memory) {\n        if (!success) {\n            _revert(returndata);\n        } else {\n            // only check if target is a contract if the call was successful and the return data is empty\n            // otherwise we already know that it was a contract\n            if (returndata.length == 0 && target.code.length == 0) {\n                revert AddressEmptyCode(target);\n            }\n            return returndata;\n        }\n    }\n\n    /**\n     * @dev Tool to verify that a low level call was successful, and reverts if it wasn't, either by bubbling the\n     * revert reason or with a default {FailedInnerCall} error.\n     */\n    function verifyCallResult(bool success, bytes memory returndata) internal pure returns (bytes memory) {\n        if (!success) {\n            _revert(returndata);\n        } else {\n            return returndata;\n        }\n    }\n\n    /**\n     * @dev Reverts with returndata if present. Otherwise reverts with {FailedInnerCall}.\n     */\n    function _revert(bytes memory returndata) private pure {\n        // Look for revert reason and bubble it up if present\n        if (returndata.length > 0) {\n            // The easiest way to bubble the revert reason is using memory via assembly\n            /// @solidity memory-safe-assembly\n            assembly {\n                let returndata_size := mload(returndata)\n                revert(add(32, returndata), returndata_size)\n            }\n        } else {\n            revert FailedInnerCall();\n        }\n    }\n}\n"
      },
      "@uniswap/v3-core/contracts/interfaces/callback/IUniswapV3SwapCallback.sol": {
        "content": "// SPDX-License-Identifier: GPL-2.0-or-later\npragma solidity >=0.5.0;\n\n/// @title Callback for IUniswapV3PoolActions#swap\n/// @notice Any contract that calls IUniswapV3PoolActions#swap must implement this interface\ninterface IUniswapV3SwapCallback {\n    /// @notice Called to `msg.sender` after executing a swap via IUniswapV3Pool#swap.\n    /// @dev In the implementation you must pay the pool tokens owed for the swap.\n    /// The caller of this method must be checked to be a UniswapV3Pool deployed by the canonical UniswapV3Factory.\n    /// amount0Delta and amount1Delta can both be 0 if no tokens were swapped.\n    /// @param amount0Delta The amount of token0 that was sent (negative) or must be received (positive) by the pool by\n    /// the end of the swap. If positive, the callback must send that amount of token0 to the pool.\n    /// @param amount1Delta The amount of token1 that was sent (negative) or must be received (positive) by the pool by\n    /// the end of the swap. If positive, the callback must send that amount of token1 to the pool.\n    /// @param data Any data passed through by the caller via the IUniswapV3PoolActions#swap call\n    function uniswapV3SwapCallback(\n        int256 amount0Delta,\n        int256 amount1Delta,\n        bytes calldata data\n    ) external;\n}\n"
      },
      "@uniswap/v3-periphery/contracts/interfaces/IQuoter.sol": {
        "content": "// SPDX-License-Identifier: GPL-2.0-or-later\npragma solidity >=0.7.5;\npragma abicoder v2;\n\n/// @title Quoter Interface\n/// @notice Supports quoting the calculated amounts from exact input or exact output swaps\n/// @dev These functions are not marked view because they rely on calling non-view functions and reverting\n/// to compute the result. They are also not gas efficient and should not be called on-chain.\ninterface IQuoter {\n    /// @notice Returns the amount out received for a given exact input swap without executing the swap\n    /// @param path The path of the swap, i.e. each token pair and the pool fee\n    /// @param amountIn The amount of the first token to swap\n    /// @return amountOut The amount of the last token that would be received\n    function quoteExactInput(bytes memory path, uint256 amountIn) external returns (uint256 amountOut);\n\n    /// @notice Returns the amount out received for a given exact input but for a swap of a single pool\n    /// @param tokenIn The token being swapped in\n    /// @param tokenOut The token being swapped out\n    /// @param fee The fee of the token pool to consider for the pair\n    /// @param amountIn The desired input amount\n    /// @param sqrtPriceLimitX96 The price limit of the pool that cannot be exceeded by the swap\n    /// @return amountOut The amount of `tokenOut` that would be received\n    function quoteExactInputSingle(\n        address tokenIn,\n        address tokenOut,\n        uint24 fee,\n        uint256 amountIn,\n        uint160 sqrtPriceLimitX96\n    ) external returns (uint256 amountOut);\n\n    /// @notice Returns the amount in required for a given exact output swap without executing the swap\n    /// @param path The path of the swap, i.e. each token pair and the pool fee. Path must be provided in reverse order\n    /// @param amountOut The amount of the last token to receive\n    /// @return amountIn The amount of first token required to be paid\n    function quoteExactOutput(bytes memory path, uint256 amountOut) external returns (uint256 amountIn);\n\n    /// @notice Returns the amount in required to receive the given exact output amount but for a swap of a single pool\n    /// @param tokenIn The token being swapped in\n    /// @param tokenOut The token being swapped out\n    /// @param fee The fee of the token pool to consider for the pair\n    /// @param amountOut The desired output amount\n    /// @param sqrtPriceLimitX96 The price limit of the pool that cannot be exceeded by the swap\n    /// @return amountIn The amount required as the input for the swap in order to receive `amountOut`\n    function quoteExactOutputSingle(\n        address tokenIn,\n        address tokenOut,\n        uint24 fee,\n        uint256 amountOut,\n        uint160 sqrtPriceLimitX96\n    ) external returns (uint256 amountIn);\n}\n"
      },
      "@uniswap/v3-periphery/contracts/interfaces/ISwapRouter.sol": {
        "content": "// SPDX-License-Identifier: GPL-2.0-or-later\npragma solidity >=0.7.5;\npragma abicoder v2;\n\nimport '@uniswap/v3-core/contracts/interfaces/callback/IUniswapV3SwapCallback.sol';\n\n/// @title Router token swapping functionality\n/// @notice Functions for swapping tokens via Uniswap V3\ninterface ISwapRouter is IUniswapV3SwapCallback {\n    struct ExactInputSingleParams {\n        address tokenIn;\n        address tokenOut;\n        uint24 fee;\n        address recipient;\n        uint256 deadline;\n        uint256 amountIn;\n        uint256 amountOutMinimum;\n        uint160 sqrtPriceLimitX96;\n    }\n\n    /// @notice Swaps `amountIn` of one token for as much as possible of another token\n    /// @param params The parameters necessary for the swap, encoded as `ExactInputSingleParams` in calldata\n    /// @return amountOut The amount of the received token\n    function exactInputSingle(ExactInputSingleParams calldata params) external payable returns (uint256 amountOut);\n\n    struct ExactInputParams {\n        bytes path;\n        address recipient;\n        uint256 deadline;\n        uint256 amountIn;\n        uint256 amountOutMinimum;\n    }\n\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    struct ExactOutputSingleParams {\n        address tokenIn;\n        address tokenOut;\n        uint24 fee;\n        address recipient;\n        uint256 deadline;\n        uint256 amountOut;\n        uint256 amountInMaximum;\n        uint160 sqrtPriceLimitX96;\n    }\n\n    /// @notice Swaps as little as possible of one token for `amountOut` of another token\n    /// @param params The parameters necessary for the swap, encoded as `ExactOutputSingleParams` in calldata\n    /// @return amountIn The amount of the input token\n    function exactOutputSingle(ExactOutputSingleParams calldata params) external payable returns (uint256 amountIn);\n\n    struct ExactOutputParams {\n        bytes path;\n        address recipient;\n        uint256 deadline;\n        uint256 amountOut;\n        uint256 amountInMaximum;\n    }\n\n    /// @notice Swaps as little as possible of one token for `amountOut` of another along the specified path (reversed)\n    /// @param params The parameters necessary for the multi-hop swap, encoded as `ExactOutputParams` in calldata\n    /// @return amountIn The amount of the input token\n    function exactOutput(ExactOutputParams calldata params) external payable returns (uint256 amountIn);\n}\n"
      },
      "contracts/connectors/ConnectorFlashloan.sol": {
        "content": "// SPDX-License-Identifier: BUSL-1.1\npragma solidity =0.8.24;\n\nimport { DoughCore } from \"../libraries/DoughCore.sol\";\nimport { IPool } from \"@aave/core-v3/contracts/interfaces/IPool.sol\";\nimport { SafeERC20, IERC20} from \"@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol\";\nimport { FlashLoanSimpleReceiverBase, IPoolAddressesProvider } from \"@aave/core-v3/contracts/flashloan/base/FlashLoanSimpleReceiverBase.sol\";\nimport { IDoughIndex, IDoughDsa, IConnectorFlashloan, IDoughRealHF, ILiquidationManager, CustomError } from \"../Interfaces.sol\";\n\n/**\n* $$$$$$$\\                                $$\\             $$$$$$$$\\ $$\\                                                   \n* $$  __$$\\                               $$ |            $$  _____|\\__|                                                  \n* $$ |  $$ | $$$$$$\\  $$\\   $$\\  $$$$$$\\  $$$$$$$\\        $$ |      $$\\ $$$$$$$\\   $$$$$$\\  $$$$$$$\\   $$$$$$$\\  $$$$$$\\  \n* $$ |  $$ |$$  __$$\\ $$ |  $$ |$$  __$$\\ $$  __$$\\       $$$$$\\    $$ |$$  __$$\\  \\____$$\\ $$  __$$\\ $$  _____|$$  __$$\\ \n* $$ |  $$ |$$ /  $$ |$$ |  $$ |$$ /  $$ |$$ |  $$ |      $$  __|   $$ |$$ |  $$ | $$$$$$$ |$$ |  $$ |$$ /      $$$$$$$$ |\n* $$ |  $$ |$$ |  $$ |$$ |  $$ |$$ |  $$ |$$ |  $$ |      $$ |      $$ |$$ |  $$ |$$  __$$ |$$ |  $$ |$$ |      $$   ____|\n* $$$$$$$  |\\$$$$$$  |\\$$$$$$  |\\$$$$$$$ |$$ |  $$ |      $$ |      $$ |$$ |  $$ |\\$$$$$$$ |$$ |  $$ |\\$$$$$$$\\ \\$$$$$$$\\ \n* \\_______/  \\______/  \\______/  \\____$$ |\\__|  \\__|      \\__|      \\__|\\__|  \\__| \\_______|\\__|  \\__| \\_______| \\_______|\n*                               $$\\   $$ |                                                                                \n*                               \\$$$$$$  |                                                                                \n*                                \\______/                                                                                 \n* \n* @title ConnectorFlashloan\n* @notice This connector is used to perform flashloan operations using Aave V3 and Paraswap\n* @custom:version 1.4 - Added Actions Events - Connector ID 2\n* @author Liberalite https://github.com/liberalite\n* @custom:coauthor 0xboga https://github.com/0xboga\n*/\ncontract ConnectorFlashloan is FlashLoanSimpleReceiverBase {\n    using SafeERC20 for IERC20;\n\n    /* ========== LAYOUT ========== */\n    address public dsaOwner;\n    address public doughIndex;\n\n    /* ========== IMMUTABLE ========== */\n    address public immutable doughRealHF;\n    address public immutable liqManager;\n\n    /* ========== STRUCT ========== */\n    struct FlashloanVars {\n        address dsaOwnerAddress;\n        address dsaAddress;\n        address srcToken;\n        address destToken;\n        address paraSwapContract;\n        address tokenTransferProxy;\n        uint256 actionId;\n        uint256 srcAmount;\n        uint256 destAmount;\n        uint256 beforeAmount;\n        uint256 afterAmount;\n        uint256 currentATokenBalanceOfUsdc;\n        bool sent;\n        bytes swapData;\n        bytes paraswapCallData;\n    }\n\n    /* ========== MAPPING ========== */\n    mapping(address => bytes32) private dataHashes;\n    mapping(address => bool) private flashStatus;\n\n    /* ========== MODIFIER ========== */\n    modifier verifyDataHash(bytes memory _data) {\n        (, address _dsaAddress,,) = abi.decode(_data, (address, address, uint256, bytes));\n        bytes32 dataHash_ = keccak256(_data);\n        if (dataHash_ != dataHashes[_dsaAddress] || dataHash_ == bytes32(0)) revert CustomError(\"invalid-data-hash\");\n        if (flashStatus[_dsaAddress] != true) revert CustomError(\"already-entered3\");\n        _;\n        dataHashes[_dsaAddress] = bytes32(0);\n        flashStatus[_dsaAddress] = false;\n    }\n\n    /** @notice Flashloan request reentrancy guard */\n    modifier reentrancy(address _dsaAddress) {\n        // if 0 then can enter flashloan, if 1 then callback\n        if (flashStatus[_dsaAddress] != false) revert CustomError(\"already-entered1\");\n        flashStatus[_dsaAddress] = true;\n        _;\n        if (flashStatus[_dsaAddress] != false) revert CustomError(\"already-entered2\");\n    }\n\n    // ============ EVENTS ============ */\n    event DoughAction(uint256 actionId, address indexed dsaAddress, address indexed token, uint256 flashloanAmount);\n\n    /**\n    * @notice Constructor to set the DoughIndex address\n    * @param _doughIndex The address of the DoughIndex contract\n    * @param _liqManager The address of the Liquidation Manager contract\n    * @dev The address of the DoughIndex contract should not be the zero address\n    * @dev The address of the Liquidation Manager contract should not be the zero address\n    */\n    constructor(address _doughIndex, address _doughRealHF, address _liqManager) FlashLoanSimpleReceiverBase(IPoolAddressesProvider(DoughCore.AAVE_V3_POOL_ADDRESS_PROVIDER)) {\n        if (_doughIndex == address(0)) revert CustomError(\"invalid _doughIndex\");\n        if (_doughRealHF == address(0)) revert CustomError(\"invalid _doughRealHF\");\n        if (_liqManager == address(0)) revert CustomError(\"invalid _liquidationManager\");\n        doughIndex = _doughIndex;\n        doughRealHF = _doughRealHF;\n        liqManager = _liqManager;\n    }\n\n    /**\n    * @notice Function to delegate DSA call to Aave V3 Connector\n    * @param _actionId The action to be performed\n    * @param _token The address of the token\n    * @param _amount The amount of the token\n    * @param _opt The boolean value to check if the user wants to withdraw the maximum amount\n    * @param _swapData The swap data bytes array\n    */\n    function delegateDoughCall(uint256 _actionId, address _token, uint256 _amount, bool _opt, bytes[] calldata _swapData) external {\n        if (_actionId > 2) revert CustomError(\"invalid id\");\n        if (_amount == 0) revert CustomError(\"invalid amount\");\n\n        if (ILiquidationManager(liqManager).dsaLiquidationStatus(address(this))) revert CustomError(\"DSA liquidated\");\n        if (IDoughIndex(doughIndex).getOwnerOfDoughDsa(address(this)) == address(0)) revert CustomError(\"DSA not found\");\n        if (IDoughIndex(doughIndex).getTokenDecimals(_token) == 0) revert CustomError(\"token not whitelisted\");\n\n        // Check if DSA is a flash borrower\n        bool notFlashBorrower = !IDoughIndex(doughIndex).getFlashBorrowers(address(this));\n        if(notFlashBorrower) {\n            DoughCore.collectApyFeesInterest(doughIndex, _token);\n        }\n\n        address flashloanToken = _token;\n        uint256 flashloanAmount = _amount;\n        // _actionId: 0-Loop , 1-DeLoop, 2-Switch\n        if (_actionId == 0) {\n            // Loop\n            if (_token == DoughCore.WETH) {\n                if (_swapData[0].length == 0) revert CustomError(\"paraswap Data is empty\");\n                (address _srcToken, , uint256 _srcAmount, , , , ) = _getParaswapData(_swapData[0]);\n                if (_srcToken != DoughCore.USDC) revert CustomError(\"invalid paraswap token\");\n                flashloanToken = _srcToken;\n                flashloanAmount = _srcAmount;\n            }\n        } else if (_actionId == 1) {\n            // Deloop\n            (uint256 currentATokenBalanceOfUsdc, , uint256 currentVariableDebt, , , , , , ) = DoughCore._I_AAVE_V3_DATA_PROVIDER.getUserReserveData(_token, address(this));\n            if (currentVariableDebt == 0) revert CustomError(\"Deloop: Loop first\");\n\n            if (_token != DoughCore.USDC) revert CustomError(\"Deloop: Invalid token\");\n\n            if (_opt || flashloanAmount >= currentVariableDebt) {\n                flashloanAmount = currentVariableDebt;\n            }\n\n            if (currentATokenBalanceOfUsdc >= flashloanAmount) {\n                // DSA has enough aUSDC to repay entire flashloanAmount\n                DoughCore.repayWithATokens(_token, flashloanAmount);\n                if(notFlashBorrower) {\n                    uint256 newDate = currentVariableDebt == flashloanAmount ? 0 : block.timestamp;\n                    IDoughIndex(doughIndex).updateBorrowDate(DoughCore.CONNECTOR_ID2, newDate, address(this), _token);\n                }\n\n                emit DoughAction(_actionId, address(this), _token, flashloanAmount);\n\n                return;\n            } else if (currentATokenBalanceOfUsdc > 0) {\n                // DSA has enough aUSDC to repay partially flashloanAmount\n                DoughCore.repayWithATokens(_token, currentATokenBalanceOfUsdc);\n                flashloanAmount = flashloanAmount - currentATokenBalanceOfUsdc;\n            }\n\n        } else {\n            // Switch\n            (uint256 currentATokenBalance, , , , , , , , ) = DoughCore._I_AAVE_V3_DATA_PROVIDER.getUserReserveData(_token, address(this));\n            if (currentATokenBalance == 0) revert CustomError(\"Switch: Loop first\");\n        }\n\n        // Get connectorFlashloan address\n        address _connectorFlashloan = IDoughIndex(doughIndex).getDoughConnector(DoughCore.CONNECTOR_ID2);\n        if (_connectorFlashloan == address(0)) revert CustomError(\"Unregistered Flashloan Connector\");\n        IConnectorFlashloan(_connectorFlashloan).flashloanReq(msg.sender, flashloanToken, flashloanAmount, _actionId, _swapData[0]);\n    }\n\n    /**\n    * @notice Function that requests a flashloan\n    * @param _dsaOwnerAddress The address of the DSA owner\n    * @param _flashloanToken The address of the flashloan token\n    * @param _flashloanAmount The amount of the flashloan token\n    * @param _flashActionId The action to be performed\n    * @param _swapData The swap data bytes array\n    * @dev The caller of the function should be the DSA contract\n    */\n    function flashloanReq(address _dsaOwnerAddress, address _flashloanToken, uint256 _flashloanAmount, uint256 _flashActionId, bytes calldata _swapData) external reentrancy(msg.sender) {\n        //  _actionId: 0-Loop, 1-DeLoop, 2-Switch\n        if (_flashActionId > 2) revert CustomError(\"flashloanReq: invalid-id\");\n        bytes memory data = abi.encode(_dsaOwnerAddress, msg.sender, _flashActionId, _swapData);\n        dataHashes[msg.sender] = keccak256(data);\n        IPool(address(POOL)).flashLoanSimple(address(this), _flashloanToken, _flashloanAmount, data, 0);\n    }\n\n    /**\n    * @notice Function to execute the flashloan\n    * @param _asset The address of the flashloan token\n    * @param _amount The amount of the flashloan token\n    * @param _premium The amount of the flashloan fee\n    * @param _initiator The address of the initiator\n    * @param _data The data bytes array to verify the data hash\n    * @return bool true if the operation is successful\n    */\n    function executeOperation(address _asset, uint256 _amount, uint256 _premium, address _initiator, bytes memory _data) public override verifyDataHash(_data) returns (bool) {\n        if (_initiator != address(this)) revert CustomError(\"not-same-sender\");\n        if (msg.sender != address(POOL)) revert CustomError(\"not-aave-sender\");\n\n        FlashloanVars memory flashloanVars;\n        (flashloanVars.dsaOwnerAddress, flashloanVars.dsaAddress, flashloanVars.actionId, flashloanVars.swapData) = abi.decode(_data, (address, address, uint256, bytes));\n\n        uint256 amountPlusPremium = _amount + _premium;\n\n        //  _actionId: 0-Loop , 1-DeLoop, 2-Switch\n        if (flashloanVars.actionId > 2) revert CustomError(\"invalid-id\");\n\n        //------- Custom Logic Start ---------\n        if (flashloanVars.actionId == 0) {\n            // Loop\n            if (_asset != DoughCore.USDC) revert CustomError(\"invalid token loop\");\n\n            if(!IDoughIndex(doughIndex).getFlashBorrowers(flashloanVars.dsaAddress)) {\n                if(IDoughIndex(doughIndex).getDsaBorrowStartDate(flashloanVars.dsaAddress, _asset) == 0) {\n                    IDoughIndex(doughIndex).updateBorrowDate(DoughCore.CONNECTOR_ID2, block.timestamp, flashloanVars.dsaAddress, _asset);\n                }\n            }\n\n            if (flashloanVars.swapData.length > 0) {\n                // Get paraswap data\n                (flashloanVars.srcToken, flashloanVars.destToken, flashloanVars.srcAmount, flashloanVars.destAmount, flashloanVars.paraSwapContract, flashloanVars.tokenTransferProxy, flashloanVars.paraswapCallData) = _getParaswapData(flashloanVars.swapData);\n                if (flashloanVars.srcToken != DoughCore.USDC) revert CustomError(\"invalid srcToken loop token\");\n                if (flashloanVars.destToken != DoughCore.WETH) revert CustomError(\"invalid destToken loop token\");\n                \n                // Check ConnectorFlashloan balance before\n                flashloanVars.beforeAmount = IERC20(flashloanVars.destToken).balanceOf(address(this));\n\n                // Using ParaSwap\n                IERC20(flashloanVars.srcToken).safeIncreaseAllowance(flashloanVars.tokenTransferProxy, flashloanVars.srcAmount);\n                (flashloanVars.sent, ) = flashloanVars.paraSwapContract.call(flashloanVars.paraswapCallData);\n                if (!flashloanVars.sent) revert CustomError(\"ParaSwap loop failed\");\n\n                // Check ConnectorFlashloan balance after\n                flashloanVars.afterAmount = IERC20(flashloanVars.destToken).balanceOf(address(this)) - flashloanVars.beforeAmount;\n\n                // supply WETH to Aave\n                IERC20(flashloanVars.destToken).safeIncreaseAllowance(flashloanVars.dsaAddress, flashloanVars.afterAmount);\n                IDoughDsa(flashloanVars.dsaAddress).executeAction(DoughCore.CONNECTOR_ID2, flashloanVars.destToken, flashloanVars.afterAmount, flashloanVars.srcToken, amountPlusPremium, flashloanVars.actionId);\n            } else {\n                // Supply USDC to Aave\n                IERC20(_asset).safeIncreaseAllowance(flashloanVars.dsaAddress, _amount);\n                IDoughDsa(flashloanVars.dsaAddress).executeAction(DoughCore.CONNECTOR_ID2, _asset, _amount, _asset, amountPlusPremium, flashloanVars.actionId);\n            }\n            // Borrow USDC from Aave\n            IERC20(_asset).safeTransferFrom(flashloanVars.dsaAddress, address(this), amountPlusPremium);\n\n            // Check Health Factor\n            checkHF(flashloanVars.dsaAddress);\n            \n        } else if (flashloanVars.actionId == 1) {\n            // Deloop\n            if (_asset != DoughCore.USDC) revert CustomError(\"invalid token deloop\");\n\n            // Get paraswap data\n            (flashloanVars.srcToken, flashloanVars.destToken, flashloanVars.srcAmount, flashloanVars.destAmount, flashloanVars.paraSwapContract, flashloanVars.tokenTransferProxy, flashloanVars.paraswapCallData) = _getParaswapData(flashloanVars.swapData);\n            if (flashloanVars.srcToken != DoughCore.WETH) revert CustomError(\"invalid srcToken deloop token\");\n            if (flashloanVars.destToken != DoughCore.USDC) revert CustomError(\"invalid destToken deloop token\");\n\n            // Repay USDC & Withdraw WETH\n            IERC20(_asset).safeIncreaseAllowance(flashloanVars.dsaAddress, _amount);\n            IDoughDsa(flashloanVars.dsaAddress).executeAction(DoughCore.CONNECTOR_ID2, _asset, _amount, flashloanVars.srcToken, flashloanVars.srcAmount, flashloanVars.actionId);\n            IERC20(flashloanVars.srcToken).safeTransferFrom(flashloanVars.dsaAddress, address(this), flashloanVars.srcAmount);\n\n            // Check ConnectorFlashloan balance before\n            flashloanVars.beforeAmount = IERC20(flashloanVars.destToken).balanceOf(address(this));\n\n            // using ParaSwap\n            IERC20(flashloanVars.srcToken).safeIncreaseAllowance(flashloanVars.tokenTransferProxy, flashloanVars.srcAmount);\n            (flashloanVars.sent, ) = flashloanVars.paraSwapContract.call(flashloanVars.paraswapCallData);\n            if (!flashloanVars.sent) revert CustomError(\"ParaSwap deloop failed\");\n\n            // Check ConnectorFlashloan balance after\n            flashloanVars.afterAmount = IERC20(flashloanVars.destToken).balanceOf(address(this)) - flashloanVars.beforeAmount;\n\n            // Check excess and refund the owner externally owned address            \n            transferExcess(_asset, flashloanVars.dsaOwnerAddress, flashloanVars.afterAmount, amountPlusPremium);\n\n            // Reset borrow date\n            resetBorrowDate(flashloanVars.dsaAddress, _asset);\n\n        } else {\n            // Switch\n            if (_asset != DoughCore.WETH && _asset != DoughCore.USDC) revert CustomError(\"invalid token\");\n\n            // Get paraswap data\n            (flashloanVars.srcToken, flashloanVars.destToken, flashloanVars.srcAmount, flashloanVars.destAmount, flashloanVars.paraSwapContract, flashloanVars.tokenTransferProxy, flashloanVars.paraswapCallData) = _getParaswapData(flashloanVars.swapData);\n            if (_asset != flashloanVars.srcToken || _amount != flashloanVars.srcAmount) revert CustomError(\"invalid paraswap data\");\n\n            // Verify flashloan _asset is srcToken and is whitelisted\n            verifyAssetsAreWhitelisted(flashloanVars.srcToken, flashloanVars.destToken);\n\n            // Check ConnectorFlashloan balance before\n            flashloanVars.beforeAmount = IERC20(flashloanVars.destToken).balanceOf(address(this));\n\n            // ParaSwap\n            IERC20(_asset).safeIncreaseAllowance(flashloanVars.tokenTransferProxy, flashloanVars.srcAmount);\n            (flashloanVars.sent, ) = flashloanVars.paraSwapContract.call(flashloanVars.paraswapCallData);\n            if (!flashloanVars.sent) revert CustomError(\"ParaSwap swap failed\");\n\n            // Check ConnectorFlashloan balance after\n            flashloanVars.afterAmount = IERC20(flashloanVars.destToken).balanceOf(address(this)) - flashloanVars.beforeAmount;\n\n            // Supply _destToken and Withdraw _srcToken\n            IERC20(flashloanVars.destToken).safeIncreaseAllowance(flashloanVars.dsaAddress, flashloanVars.afterAmount);\n            IDoughDsa(flashloanVars.dsaAddress).executeAction(DoughCore.CONNECTOR_ID2, flashloanVars.destToken, flashloanVars.afterAmount, _asset, amountPlusPremium, flashloanVars.actionId);\n            IERC20(_asset).safeTransferFrom(flashloanVars.dsaAddress, address(this), amountPlusPremium);\n\n            // Check Health Factor\n            checkHF(flashloanVars.dsaAddress);\n        }\n\n        emit DoughAction(flashloanVars.actionId, flashloanVars.dsaAddress, _asset, _amount);\n\n        // Pay back the flashloan amount + premium\n        IERC20(_asset).safeIncreaseAllowance(address(POOL), amountPlusPremium);\n        return true;\n    }\n\n    /**\n    * @notice Function to decode the paraswap data\n    * @param _swapData The swap data bytes array\n    * @return srcToken, destToken, srcAmount, destAmount, paraSwapContract, tokenTransferProxy, paraswapCallData\n    */\n    function _getParaswapData(bytes memory _swapData) private pure returns (address, address, uint256, uint256, address, address, bytes memory) {\n        return abi.decode(_swapData, (address, address, uint256, uint256, address, address, bytes));\n    }\n\n    /**\n     * @notice Function to reset the borrow date\n     * @param _dsaAddress The address of the DSA\n     * @param _asset The asset address of the token\n     */\n    function resetBorrowDate(address _dsaAddress, address _asset) private {\n        if(!IDoughIndex(doughIndex).getFlashBorrowers(_dsaAddress)) {\n            (, , uint256 currentVariableDebt, , , , , , ) = DoughCore._I_AAVE_V3_DATA_PROVIDER.getUserReserveData(_asset, _dsaAddress);\n            if(currentVariableDebt == 0) {\n                IDoughIndex(doughIndex).updateBorrowDate(DoughCore.CONNECTOR_ID2, 0, _dsaAddress, _asset);\n            }\n        }\n    }\n\n    /**\n    * @notice Function to verify the assets are whitelisted\n    * @param _srcToken The address of the source token\n    * @param _destToken The address of the destination token\n    */\n    function verifyAssetsAreWhitelisted(address _srcToken, address _destToken) private view {\n        // Verify srcToken is whitelisted\n        uint8 srcTokenDecimals = IDoughIndex(doughIndex).getTokenDecimals(_srcToken);\n        if(srcTokenDecimals == 0) revert CustomError(\"srcToken not whitelisted\");\n\n        // Verify destToken is whitelisted\n        uint8 destTokenDecimals = IDoughIndex(doughIndex).getTokenDecimals(_destToken);\n        if(destTokenDecimals == 0) revert CustomError(\"destToken not whitelisted\");\n    }\n\n    /**\n     * @notice Function to transfer the excess amount to the owner\n     * @param _asset The address of the asset\n     * @param _ownerAddress The address of the DSA owner\n     * @param actualAmount The actual amount\n     * @param amountPlusPremium The amount plus premium\n     */\n    function transferExcess(address _asset, address _ownerAddress, uint256 actualAmount , uint256 amountPlusPremium) private {\n        if(actualAmount > amountPlusPremium) {\n            uint256 diff = actualAmount - amountPlusPremium;\n            IERC20(_asset).safeTransfer(_ownerAddress, diff);\n        }\n    }\n\n    /**\n    * @notice Function to check the health factor of the DSA\n    * @param _sender The address of the DSA\n    * @dev The health factor should be greater than the minimum health factor or it will revert\n    */\n    function checkHF(address _sender) private view {\n        uint256 _healthFactor = IDoughRealHF(doughRealHF).getDoughHFData(_sender);\n        if (_healthFactor < IDoughIndex(doughIndex).minHealthFactor()) revert CustomError(\"ConnectorFlashloan < minHF\");\n    }\n\n    /**\n     * @notice Function to set new dough index address after upgrade\n     * @param _newDoughIndex The address of the new DoughIndex contract\n     * @dev The new DoughIndex address should not be the zero address\n     * @dev Only the multisig of DoughIndex can call this function\n     */\n    function setNewDoughIndex(address _newDoughIndex) external {\n        if (msg.sender != IDoughIndex(doughIndex).multisig()) revert CustomError(\"not multisig of doughIndex\");\n        if (_newDoughIndex == address(0)) revert CustomError(\"invalid _newDoughIndex\");\n        doughIndex = _newDoughIndex;\n    }\n\n    /** @notice Function to get the Dough Multisig address */\n    function getDoughMultisig() external view returns (address) {\n        return IDoughIndex(doughIndex).multisig();\n    }\n\n    /** @notice Function to get the Dough Index address */\n    function getDoughIndex() external view returns (address) {\n        return doughIndex;\n    }\n\n    /**\n    * @notice Function to withdraw accidentaly sent ETH/ERC20 tokens to the connector\n    * @param _asset The address of the ETH/ERC20 token\n    * @param _treasury The address of the treasury\n    * @param _amount The amount of ETH/ERC20 token to withdraw\n    */\n    function withdrawToken(address _asset, address _treasury, uint256 _amount) external {\n        if (msg.sender != IDoughIndex(doughIndex).multisig()) revert CustomError(\"not multisig of doughIndex\");\n        if (_treasury == address(0)) revert CustomError(\"invalid _treasury\");\n        if (_amount == 0) revert CustomError(\"must be greater than zero\");\n        if (_asset == DoughCore.ETH) {\n            payable(_treasury).transfer(_amount);\n        } else {\n            uint256 balanceOfToken = IERC20(_asset).balanceOf(address(this));\n            uint256 transferAmount = _amount;\n            if (_amount > balanceOfToken) {\n                transferAmount = balanceOfToken;\n            }\n            IERC20(_asset).safeTransfer(_treasury, transferAmount);\n        }\n    }\n}"
      },
      "contracts/Interfaces.sol": {
        "content": "// SPDX-License-Identifier: BUSL-1.1\npragma solidity ^0.8.10;\nimport \"@openzeppelin/contracts/token/ERC20/IERC20.sol\";\n\nerror CustomError(string errorMsg);\n\ninterface IWETH is IERC20 {\n    function deposit() external payable;\n    function withdraw(uint amount) external;\n}\n\ninterface AaveActionsConnector {\n    function executeAaveAction(address _dsaAddress, uint256 _connectorId, address _tokenIn, uint256 _inAmount, address _tokenOut, uint256 _outAmount, uint256 _actionId) external payable;\n}\n\ninterface IDoughDsa {\n    function doughCall(uint256 _connectorId, uint256 _actionId, address _token, uint256 _amount, bool _opt, bytes[] calldata _swapData) external payable;\n    function executeAction(uint256 _connectorId, address tokenIn, uint256 inAmount, address tokenOut, uint256 outAmount, uint256 actionId) external payable;\n    function dsaOwner() external view returns (address);\n    function doughIndex() external view returns (address);\n}\n\ninterface IDoughIndex {\n    function aaveActionsAddress() external view returns (address);\n    function setDsaMasterClone(address _dsaMasterCopy) external;\n    function setNewBorrowFormula(address _newBorrowFormula) external;\n    function setNewAaveActions(address _newAaveActions) external;\n    function apyFee() external view returns (uint256);\n    function getFlashBorrowers(address _flashBorrower) external view returns (bool);\n    function deleverageAutomation() external view returns (address);\n    function shieldAutomation() external view returns (address);\n    function vaultAutomation() external view returns (address);\n    function getWhitelistedTokenList() external view returns (address[] memory);\n    function multisig() external view returns (address);\n    function treasury() external view returns (address);\n    function deleverageAsset() external view returns (address);\n    function getDoughConnector (uint256 _connectorId) external view returns (address);\n    function getOwnerOfDoughDsa(address dsaAddress) external view returns (address);\n    function getDoughDsa(address dsaAddress) external view returns (address);\n    function getTokenDecimals(address _token) external view returns (uint8);\n    function getTokenMinInterest(address _token) external view returns (uint256);\n    function getTokenIndex(address _token) external view returns (uint256);\n    function borrowFormula (address _token, address _dsaAddress) external returns (uint256, uint256, uint256, uint256);\n    function borrowFormulaInterest (address _token, address _dsaAddress) external returns (uint256);\n    function getDsaBorrowStartDate (address _dsaAddress, address _token) external view returns (uint256);\n    function updateBorrowDate(uint256 _connectorID, uint256 _time, address _dsaAddress, address _token) external;\n    function minDeleveragingRatio() external view returns (uint256);\n    function minHealthFactor() external view returns (uint256);\n}\n\ninterface IDoughRealHF {\n    function getDoughHFData(address _dsaAddress) external view returns (uint256 healthFactor);\n    function getUserData(address _dsaAddress) external view returns (uint256 totalCollateralBase, uint256 totalDebtBase, uint256 availableBorrowBase, uint256 currentLiquidationThreshold, uint256 ltv, uint256 healthFactor,uint256 scaledInterest);\n    function calculateMaxBorrow(address _token, address _dsaAddress) external view returns (uint256 maxBorrowInTokens);\n}\n\ninterface ILiquidationManager {\n    function startDsaLiquidationInOneTx(address _dsaAddress, uint256 _blockNumber) external;\n    function startDsaLiquidationInMultipleTX(address _dsaAddress, uint256 _blockNumber) external;\n    function startDsaLiquidationStatusMulti(address[] calldata _dsaAddresses, uint256[] calldata _blockNumber) external;\n    function resetDsaLiquidationStatus(address _dsaAddress) external;\n    function dsaLiquidationBlockNumbers(address _dsaAddress) external view returns (uint256[] memory);\n    function dsaLiquidationStatus(address _dsaAddress) external view returns (bool);\n}\n\ninterface IDeleverageAutomation {\n    function whitelistedAddresses(address) external view returns (bool);\n    function whitelistedAddressesList() external view returns (address[] memory);\n}\n\ninterface IBorrowManagementConnector {\n    function borrowFormula(address _token, address _dsaAddress) external view returns (uint256, uint256, uint256, uint256);\n    function borrowFormulaInterest(address _token, address _dsaAddress) external view returns (uint256);\n}\n\n// interface IConnectorMultiStepParaswapFlashloan {\n//     function flashloanReq(bool opt, address[] calldata flashloanTokens, uint256[] calldata flashloanAmounts, uint256[] calldata flashLoanInterestRateModes, bytes[] calldata swapData) external;\n// }\n\ninterface IConnectorParaswapFlashloan {\n    function flashloanReq(bool opt, address[] memory flashloanTokens, uint256[] memory flashloanAmounts, uint256[] memory flashLoanInterestRateModes, address[] memory totalTokensCollateral, uint256[] memory totalAmountsCollateral, bytes[] memory swapData) external;\n}\n\ninterface IConnectorMultiFlashloanOnchain {\n    function flashloanReq(address[] memory flashloanTokens, uint256[] memory flashloanAmount, uint256[] memory flashLoanInterestRateModes, address[] memory flashLoanTokensCollateral, uint256[] memory flashLoanAmountsCollateral) external;\n}\n\ninterface IConnectorFlashloan {\n    function flashloanReq(address dsaOwnerAddress, address flashloanToken, uint256 flashloanAmount, uint256 flashActionId, bytes calldata _swapData) external;\n}\n\ninterface IDoughFinance {\n    function numCheckpoints(address account) external returns (uint256);\n    function getPastTotalSupply(uint256 timepoint) external view returns (uint256);\n    function getPastVotes(address account, uint256 timepoint) external view returns (uint256);\n    function getAccountsStatus(address account) external view returns (bool status);\n    function setAccountStatus(address account, bool _status) external;\n    function setPublicStatus(bool status) external;\n    function approve(address spender, uint256 amount) external returns (bool status);\n    function transferFrom(address from, address to, uint256 amount) external returns (bool);\n}"
      },
      "contracts/libraries/DoughCore.sol": {
        "content": "// SPDX-License-Identifier: BUSL-1.1\npragma solidity =0.8.24;\n\nimport \"@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol\";\nimport \"@aave/core-v3/contracts/interfaces/IPoolDataProvider.sol\";\nimport \"@aave/core-v3/contracts/interfaces/IPool.sol\";\nimport \"@uniswap/v3-periphery/contracts/interfaces/IQuoter.sol\";\nimport \"@uniswap/v3-periphery/contracts/interfaces/ISwapRouter.sol\";\nimport { IWETH, IDoughIndex, CustomError } from \"../Interfaces.sol\";\n\n/**\n* $$$$$$$\\                                $$\\             $$$$$$$$\\ $$\\                                                   \n* $$  __$$\\                               $$ |            $$  _____|\\__|                                                  \n* $$ |  $$ | $$$$$$\\  $$\\   $$\\  $$$$$$\\  $$$$$$$\\        $$ |      $$\\ $$$$$$$\\   $$$$$$\\  $$$$$$$\\   $$$$$$$\\  $$$$$$\\  \n* $$ |  $$ |$$  __$$\\ $$ |  $$ |$$  __$$\\ $$  __$$\\       $$$$$\\    $$ |$$  __$$\\  \\____$$\\ $$  __$$\\ $$  _____|$$  __$$\\ \n* $$ |  $$ |$$ /  $$ |$$ |  $$ |$$ /  $$ |$$ |  $$ |      $$  __|   $$ |$$ |  $$ | $$$$$$$ |$$ |  $$ |$$ /      $$$$$$$$ |\n* $$ |  $$ |$$ |  $$ |$$ |  $$ |$$ |  $$ |$$ |  $$ |      $$ |      $$ |$$ |  $$ |$$  __$$ |$$ |  $$ |$$ |      $$   ____|\n* $$$$$$$  |\\$$$$$$  |\\$$$$$$  |\\$$$$$$$ |$$ |  $$ |      $$ |      $$ |$$ |  $$ |\\$$$$$$$ |$$ |  $$ |\\$$$$$$$\\ \\$$$$$$$\\ \n* \\_______/  \\______/  \\______/  \\____$$ |\\__|  \\__|      \\__|      \\__|\\__|  \\__| \\_______|\\__|  \\__| \\_______| \\_______|\n*                               $$\\   $$ |                                                                                \n*                               \\$$$$$$  |                                                                                \n*                                \\______/                                                                                 \n* \n* @title DoughCoreEthereum\n* @notice The core contract for Dough Finance\n* @custom:version 1.0 - Initial release\n* @author Liberalite https://github.com/liberalite\n* @custom:coauthor 0xboga https://github.com/0xboga\n*/\nlibrary DoughCore {\n    using SafeERC20 for IERC20;\n\n    // MAINNET\n    uint256 public constant CHAIN_ID = 1;\n\n    // TOKENS\n    address public constant ADDRESS_ZERO = 0x0000000000000000000000000000000000000000;\n    address public constant ETH = 0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE;\n    address public constant WBTC = 0x2260FAC5E5542a773Aa44fBCfeDf7C193bc2C599;\n    address public constant WETH = 0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2;\n    address public constant LINK = 0x514910771AF9Ca656af840dff83E8264EcF986CA;\n    address public constant USDC = 0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48;\n    address public constant USDT = 0xdAC17F958D2ee523a2206206994597C13D831ec7;\n    address public constant DAI = 0x6B175474E89094C44Da98b954EedeAC495271d0F;\n\n    // AAVE V3 CONFIG\n    uint256 public constant FLASHLOAN_RATE_MODE = 0; // no borrow debt\n    uint256 public constant VARIABLE_RATE_MODE = 2; // variable borrow rate \n\n    // AAVE V3 ADDRESSES\n    address public constant AAVE_V3_POOL_ADDRESS = 0x87870Bca3F3fD6335C3F4ce8392D69350B4fA4E2;\n    address public constant AAVE_V3_DATA_PROVIDER_ADDRESS = 0x7B4EB56E7CD4b454BA8ff71E4518426369a138a3;\n    address public constant AAVE_V3_POOL_ADDRESS_PROVIDER = 0x2f39d218133AFaB8F2B819B1066c7E434Ad94E9e;\n    address public constant AAVE_V3_PRICE_ORACLE = 0x54586bE62E3c3580375aE3723C145253060Ca0C2;\n\n    // UNISWAP V2\n    address public constant UNISWAP_V2_ROUTER_ADDRESS = 0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D;\n\n    // UNISWAP V3\n    address public constant UNISWAP_V3_ROUTER_ADDRESS = 0xE592427A0AEce92De3Edee1F18E0157C05861564;\n    address public constant UNISWAP_V3_QUOTER_ADDRESS = 0xb27308f9F90D607463bb33eA1BeBb41C27CE5AB6;\n\n    // UNISWAP V3 INTERFACES\n    ISwapRouter public constant _I_UNISWAP_V3_ROUTER = ISwapRouter(UNISWAP_V3_ROUTER_ADDRESS);\n    IQuoter public constant _I_UNISWAP_V3_QUOTER = IQuoter(UNISWAP_V3_QUOTER_ADDRESS);\n\n    // AAVE V3 INTERFACES\n    IPool public constant _I_AAVE_V3_POOL = IPool(AAVE_V3_POOL_ADDRESS);\n    IPoolDataProvider public constant _I_AAVE_V3_DATA_PROVIDER = IPoolDataProvider(AAVE_V3_DATA_PROVIDER_ADDRESS);\n\n    // DOUGH CONNECTORS ID\n    uint256 public constant CONNECTOR_ID0 = 0;\n    uint256 public constant CONNECTOR_ID1 = 1;\n    uint256 public constant CONNECTOR_ID2 = 2;\n    uint256 public constant CONNECTOR_ID3 = 3;\n    uint256 public constant CONNECTOR_ID4 = 4;\n    uint256 public constant CONNECTOR_ID5 = 5;\n    uint256 public constant CONNECTOR_ID6 = 6;\n    uint256 public constant CONNECTOR_ID7 = 7;\n    uint256 public constant CONNECTOR_ID8 = 8;\n    uint256 public constant CONNECTOR_ID9 = 9;\n    uint256 public constant CONNECTOR_ID10 = 10;\n    uint256 public constant CONNECTOR_ID11 = 11;\n    uint256 public constant CONNECTOR_ID12 = 12;\n    uint256 public constant CONNECTOR_ID13 = 13;\n    uint256 public constant CONNECTOR_ID14 = 14;\n    uint256 public constant CONNECTOR_ID15 = 15;\n    uint256 public constant CONNECTOR_ID16 = 16;\n    uint256 public constant CONNECTOR_ID17 = 17;\n    uint256 public constant CONNECTOR_ID18 = 18;\n    uint256 public constant CONNECTOR_ID19 = 19;\n    uint256 public constant CONNECTOR_ID20 = 20;\n    uint256 public constant CONNECTOR_ID21 = 21;\n    uint256 public constant CONNECTOR_ID22 = 22;\n    uint256 public constant CONNECTOR_ID23 = 23;\n    uint256 public constant CONNECTOR_ID24 = 24;\n    uint256 public constant CONNECTOR_ID25 = 25;\n    uint256 public constant CONNECTOR_ID26 = 26;\n    uint256 public constant CONNECTOR_ID27 = 27;\n    uint256 public constant CONNECTOR_ID28 = 28;\n    uint256 public constant CONNECTOR_ID29 = 29;\n    uint256 public constant CONNECTOR_ID30 = 30;\n    uint256 public constant CONNECTOR_ID31 = 31;\n    uint256 public constant CONNECTOR_ID32 = 32;\n    uint256 public constant CONNECTOR_ID33 = 33;\n\n    /**\n     * @notice Function to repay AAVE V3 debt with Aave Tokens\n     * @param _tokenIn The token address to repay the debt\n     * @param _inAmount The amount of the token to repay the debt\n     * @dev The token should be whitelisted in the DoughIndex contract\n     */\n    function repayWithATokens(address _tokenIn, uint256 _inAmount) external {\n        _I_AAVE_V3_POOL.repayWithATokens(_tokenIn, _inAmount, VARIABLE_RATE_MODE);\n    }\n\n    /**\n    * @notice Collects the APY fees for all the whitelisted tokens\n    * @param _doughIndex The DoughIndex address\n    * @dev The APY fees are collected for all the whitelisted tokens\n    */\n    function collectApyFees(address _doughIndex) external {\n        // Check if the flash borrower is the caller\n        if(IDoughIndex(_doughIndex).getFlashBorrowers(address(this))) return;\n\n        // Get the whitelisted tokens\n        address[] memory whitelistedTokens = IDoughIndex(_doughIndex).getWhitelistedTokenList();\n\n        // Iterate through the whitelisted tokens\n        for (uint i = 0; i < whitelistedTokens.length;) {\n            // Get the APY fees for the given token\n            (, , uint256 scaledInterest, uint256 minInterest) = IDoughIndex(_doughIndex).borrowFormula(whitelistedTokens[i], address(this));\n\n            // Check if the scaled interest is greater than the minimum interest\n            if (scaledInterest > minInterest) collectTreasuryFees(_doughIndex, address(this), whitelistedTokens[i], scaledInterest);\n\n            // Increment the counter\n            unchecked { i++; }\n        }\n    }\n\n    /**\n    * @notice Collects the APY fees for the given token if minimum interest is met\n    * @param _doughIndex The DoughIndex address\n    * @param _token: The whitelisted token address\n    */\n    function collectAnyApyFees(address _doughIndex, address _token) external {\n        // Check if the flash borrower is the caller\n        if(IDoughIndex(_doughIndex).getFlashBorrowers(address(this))) return;\n        \n        // Get the APY fees for the given token\n        (, , uint256 scaledInterest, uint256 minInterest) = IDoughIndex(_doughIndex).borrowFormula(_token, address(this));\n        \n        // Check if the scaled interest is greater than the minimum interest\n        if (scaledInterest > minInterest) collectTreasuryFees(_doughIndex, address(this), _token, scaledInterest);\n    }\n\n    /**\n    * @notice Collects the APY fees for the given token \n    * @param _doughIndex The DoughIndex address\n    * @param _token: The whitelisted token address\n    */\n    function collectApyFeesInterest(address _doughIndex, address _token) external {\n        // Check if the flash borrower is the caller\n        if(IDoughIndex(_doughIndex).getFlashBorrowers(address(this))) return;\n        \n        // Get the time when the borrowing started\n        (uint256 scaledInterest) = IDoughIndex(_doughIndex).borrowFormulaInterest(_token, address(this));\n\n        // Check if the scaled interest is greater than 0\n        if (scaledInterest > 0) collectTreasuryFees(_doughIndex, address(this), _token, scaledInterest);\n    }\n\n    /**\n    * @notice Collects the APY fees for the given token partially\n    * @param _doughIndex The DoughIndex address\n    * @param _token: The whitelisted token address\n    * @param _partialAmount The partial amount of APY fees\n    */\n    function collectApyFeesPartially(address _doughIndex, address _token, uint256 _partialAmount) private {\n        // Check if the flash borrower is the caller\n        if(IDoughIndex(_doughIndex).getFlashBorrowers(address(this))) return;\n\n        // Get the time when the borrowing started\n        uint256 timeStartedBorrow = IDoughIndex(_doughIndex).getDsaBorrowStartDate(address(this), _token);\n\n        // Get the scaled interest for the given token\n        (uint256 scaledInterest) = IDoughIndex(_doughIndex).borrowFormulaInterest(_token, address(this));\n\n        // Check if the partial amount is greater than the scaled interest\n        if (_partialAmount > scaledInterest) revert CustomError(\"partialAmount >= scaled interest\");\n\n        // Calculate the time difference between the current time and the time when the borrowing started\n        uint256 timeDiff = block.timestamp - timeStartedBorrow;\n\n        // Calculate the APY fees per second\n        uint256 perSecond = scaledInterest / timeDiff;\n\n        // Check if the perSecond is 0\n        if (perSecond == 0) revert CustomError(\"perSecond is 0\");\n\n        // Calculate the back time in seconds\n        uint256 backTimeInSeconds = (_partialAmount * 1e18) / perSecond;\n\n        // Check if the backTimeInSeconds is 0\n        uint256 actualBackTimeInSeconds = backTimeInSeconds / 1e18;\n\n        // Check if the actualBackTimeInSeconds is 0\n        if (actualBackTimeInSeconds == 0) revert CustomError(\"actualBackTimeInSeconds is 0\");\n\n        // Calculate the adjusted start time after partial APY fees collection\n        uint256 adjustedStartTime = timeStartedBorrow + actualBackTimeInSeconds;\n\n        // Collect the APY fees partially\n        collectTreasuryFeesPartially(_doughIndex, _token, address(this), scaledInterest, _partialAmount, adjustedStartTime);\n    }\n\n    /**\n    * @notice Collects the APY fees for the given token\n    * @param _doughIndex The DoughIndex address\n    * @param _dsaAddress The DSA address\n    * @param _token: The whitelisted token address\n    * @param _scaledInterest The scaled interest of APY fees\n    */\n    function collectTreasuryFees(address _doughIndex, address _dsaAddress, address _token, uint256 _scaledInterest) private {\n        // Borrow the APY fees from the Aave V3 pool\n        _I_AAVE_V3_POOL.borrow(_token, _scaledInterest, VARIABLE_RATE_MODE, 0, address(this));\n\n        // Transfer the fee to the treasury\n        IERC20(_token).safeTransfer(IDoughIndex(_doughIndex).treasury(), _scaledInterest);\n        \n        // Update the borrow start date to now, as a new fee period starts\n        IDoughIndex(_doughIndex).updateBorrowDate(CONNECTOR_ID0, block.timestamp, _dsaAddress, _token);\n    }\n\n    /**\n    * @notice Collects the APY fees for the given token partially\n    * @param _token: The token address to collect the APY fees\n    * @param _dsaAddress: The DSA address to collect the APY fees\n    * @param _scaledInterest: The scaled interest to collect the APY fees\n    * @param _partialAmount: The partial amount to collect the APY fees\n    * @param _adjustedStartTime: The adjusted start time after partial APY fees collection\n    */\n    function collectTreasuryFeesPartially(address _doughIndex, address _token, address _dsaAddress, uint256 _scaledInterest, uint256 _partialAmount, uint256 _adjustedStartTime) private {\n        // Check if the scaled interest is greater than the partial amount\n        if (_scaledInterest >= _partialAmount) {\n            // Borrow the APY fees from the Aave V3 pool\n            _I_AAVE_V3_POOL.borrow(_token, _partialAmount, VARIABLE_RATE_MODE, 0, address(this));\n            \n            // Transfer the fee to the treasury\n            IERC20(_token).safeTransfer(IDoughIndex(_doughIndex).treasury(), _partialAmount);\n            \n            // Update the borrow start date to now, as a new fee period starts\n            IDoughIndex(_doughIndex).updateBorrowDate(CONNECTOR_ID0, _adjustedStartTime, _dsaAddress, _token);\n        }\n    }\n}"
      }
    },
    "settings": {
      "optimizer": {
        "enabled": true,
        "runs": 200
      },
      "evmVersion": "paris",
      "outputSelection": {
        "*": {
          "*": [
            "evm.bytecode",
            "evm.deployedBytecode",
            "devdoc",
            "userdoc",
            "metadata",
            "abi"
          ]
        }
      },
      "libraries": {
        "contracts/libraries/DoughCore.sol": {
          "DoughCore": "0x18911cadade9101955c003551251c4ff8f6bfc84"
        }
      }
    }
  }}