creation_sourcecode: {{
    "language": "Solidity",
    "sources": {
      "contracts/misc/BatchGateway.sol": {
        "content": "// SPDX-License-Identifier: agpl-3.0\npragma solidity 0.8.4;\n\nimport {OwnableUpgradeable} from \"@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol\";\n\nimport {ILendPoolAddressesProvider} from \"../interfaces/ILendPoolAddressesProvider.sol\";\nimport {ILendPool} from \"../interfaces/ILendPool.sol\";\nimport {IWETH} from \"../interfaces/IWETH.sol\";\n\nimport {EmergencyTokenRecoveryUpgradeable} from \"../protocol/EmergencyTokenRecoveryUpgradeable.sol\";\n\ncontract BatchGateway is OwnableUpgradeable, EmergencyTokenRecoveryUpgradeable {\n  ILendPoolAddressesProvider public addressProvider;\n  IWETH public WETH;\n  ILendPool public lendPool;\n  bool public paused;\n\n  function initialize(address provider_, address weth_) public initializer {\n    __Ownable_init();\n    __EmergencyTokenRecovery_init();\n\n    addressProvider = ILendPoolAddressesProvider(provider_);\n    WETH = IWETH(weth_);\n\n    lendPool = ILendPool(addressProvider.getLendPool());\n    WETH.approve(address(lendPool), type(uint256).max);\n  }\n\n  function batchLiquidateETH(\n    address[] calldata nftAssets,\n    uint256[] calldata nftTokenIds,\n    uint256[] calldata amounts\n  ) external payable returns (uint256[] memory extraAmounts) {\n    require(!paused, \"Paused\");\n\n    uint256 wethAmountBefore = WETH.balanceOf(address(this));\n\n    if (msg.value > 0) {\n      WETH.deposit{value: msg.value}();\n    }\n\n    extraAmounts = new uint256[](nftAssets.length);\n    for (uint256 i = 0; i < nftAssets.length; i++) {\n      extraAmounts[i] = lendPool.liquidate(nftAssets[i], nftTokenIds[i], amounts[i]);\n    }\n\n    _safeTransferWETH(msg.sender, wethAmountBefore);\n\n    return (extraAmounts);\n  }\n\n  function setPause(bool paused_) public onlyOwner {\n    paused = paused_;\n  }\n\n  function _safeTransferWETH(address to, uint256 wethAmountBefore) internal {\n    uint256 wethAmountAfter = WETH.balanceOf(address(this));\n    if (wethAmountAfter > wethAmountBefore) {\n      WETH.withdraw(wethAmountAfter - wethAmountBefore);\n      _safeTransferETH(to, wethAmountAfter - wethAmountBefore);\n    }\n  }\n\n  function _safeTransferETH(address to, uint256 value) internal {\n    (bool success, ) = to.call{value: value}(new bytes(0));\n    require(success, \"ETH_TRANSFER_FAILED\");\n  }\n\n  receive() external payable {}\n}\n"
      },
      "@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol": {
        "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (access/Ownable.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../utils/ContextUpgradeable.sol\";\nimport \"../proxy/utils/Initializable.sol\";\n\n/**\n * @dev Contract module which provides a basic access control mechanism, where\n * there is an account (an owner) that can be granted exclusive access to\n * specific functions.\n *\n * By default, the owner account will be the one that deploys the contract. This\n * can later be changed with {transferOwnership}.\n *\n * This module is used through inheritance. It will make available the modifier\n * `onlyOwner`, which can be applied to your functions to restrict their use to\n * the owner.\n */\nabstract contract OwnableUpgradeable is Initializable, ContextUpgradeable {\n    address private _owner;\n\n    event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);\n\n    /**\n     * @dev Initializes the contract setting the deployer as the initial owner.\n     */\n    function __Ownable_init() internal onlyInitializing {\n        __Context_init_unchained();\n        __Ownable_init_unchained();\n    }\n\n    function __Ownable_init_unchained() internal onlyInitializing {\n        _transferOwnership(_msgSender());\n    }\n\n    /**\n     * @dev Returns the address of the current owner.\n     */\n    function owner() public view virtual returns (address) {\n        return _owner;\n    }\n\n    /**\n     * @dev Throws if called by any account other than the owner.\n     */\n    modifier onlyOwner() {\n        require(owner() == _msgSender(), \"Ownable: caller is not the owner\");\n        _;\n    }\n\n    /**\n     * @dev Leaves the contract without owner. It will not be possible to call\n     * `onlyOwner` functions anymore. Can only be called by the current owner.\n     *\n     * NOTE: Renouncing ownership will leave the contract without an owner,\n     * thereby removing any functionality that is only available to the owner.\n     */\n    function renounceOwnership() public virtual onlyOwner {\n        _transferOwnership(address(0));\n    }\n\n    /**\n     * @dev Transfers ownership of the contract to a new account (`newOwner`).\n     * Can only be called by the current owner.\n     */\n    function transferOwnership(address newOwner) public virtual onlyOwner {\n        require(newOwner != address(0), \"Ownable: new owner is the zero address\");\n        _transferOwnership(newOwner);\n    }\n\n    /**\n     * @dev Transfers ownership of the contract to a new account (`newOwner`).\n     * Internal function without access restriction.\n     */\n    function _transferOwnership(address newOwner) internal virtual {\n        address oldOwner = _owner;\n        _owner = newOwner;\n        emit OwnershipTransferred(oldOwner, newOwner);\n    }\n    uint256[49] private __gap;\n}\n"
      },
      "contracts/interfaces/ILendPoolAddressesProvider.sol": {
        "content": "// SPDX-License-Identifier: agpl-3.0\npragma solidity 0.8.4;\n\n/**\n * @title LendPoolAddressesProvider contract\n * @dev Main registry of addresses part of or connected to the protocol, including permissioned roles\n * - Acting also as factory of proxies and admin of those, so with right to change its implementations\n * - Owned by the Bend Governance\n * @author Bend\n **/\ninterface ILendPoolAddressesProvider {\n  event MarketIdSet(string newMarketId);\n  event LendPoolUpdated(address indexed newAddress, bytes encodedCallData);\n  event ConfigurationAdminUpdated(address indexed newAddress);\n  event EmergencyAdminUpdated(address indexed newAddress);\n  event LendPoolConfiguratorUpdated(address indexed newAddress, bytes encodedCallData);\n  event ReserveOracleUpdated(address indexed newAddress);\n  event NftOracleUpdated(address indexed newAddress);\n  event LendPoolLoanUpdated(address indexed newAddress, bytes encodedCallData);\n  event ProxyCreated(bytes32 id, address indexed newAddress);\n  event AddressSet(bytes32 id, address indexed newAddress, bool hasProxy, bytes encodedCallData);\n  event BNFTRegistryUpdated(address indexed newAddress);\n  event IncentivesControllerUpdated(address indexed newAddress);\n  event UIDataProviderUpdated(address indexed newAddress);\n  event BendDataProviderUpdated(address indexed newAddress);\n  event WalletBalanceProviderUpdated(address indexed newAddress);\n\n  function getMarketId() external view returns (string memory);\n\n  function setMarketId(string calldata marketId) external;\n\n  function setAddress(bytes32 id, address newAddress) external;\n\n  function setAddressAsProxy(\n    bytes32 id,\n    address impl,\n    bytes memory encodedCallData\n  ) external;\n\n  function getAddress(bytes32 id) external view returns (address);\n\n  function getLendPool() external view returns (address);\n\n  function setLendPoolImpl(address pool, bytes memory encodedCallData) external;\n\n  function getLendPoolConfigurator() external view returns (address);\n\n  function setLendPoolConfiguratorImpl(address configurator, bytes memory encodedCallData) external;\n\n  function getPoolAdmin() external view returns (address);\n\n  function setPoolAdmin(address admin) external;\n\n  function getEmergencyAdmin() external view returns (address);\n\n  function setEmergencyAdmin(address admin) external;\n\n  function getReserveOracle() external view returns (address);\n\n  function setReserveOracle(address reserveOracle) external;\n\n  function getNFTOracle() external view returns (address);\n\n  function setNFTOracle(address nftOracle) external;\n\n  function getLendPoolLoan() external view returns (address);\n\n  function setLendPoolLoanImpl(address loan, bytes memory encodedCallData) external;\n\n  function getBNFTRegistry() external view returns (address);\n\n  function setBNFTRegistry(address factory) external;\n\n  function getIncentivesController() external view returns (address);\n\n  function setIncentivesController(address controller) external;\n\n  function getUIDataProvider() external view returns (address);\n\n  function setUIDataProvider(address provider) external;\n\n  function getBendDataProvider() external view returns (address);\n\n  function setBendDataProvider(address provider) external;\n\n  function getWalletBalanceProvider() external view returns (address);\n\n  function setWalletBalanceProvider(address provider) external;\n}\n"
      },
      "contracts/interfaces/ILendPool.sol": {
        "content": "// SPDX-License-Identifier: agpl-3.0\npragma solidity 0.8.4;\n\nimport {ILendPoolAddressesProvider} from \"./ILendPoolAddressesProvider.sol\";\nimport {DataTypes} from \"../libraries/types/DataTypes.sol\";\n\ninterface ILendPool {\n  /**\n   * @dev Emitted on deposit()\n   * @param user The address initiating the deposit\n   * @param amount The amount deposited\n   * @param reserve The address of the underlying asset of the reserve\n   * @param onBehalfOf The beneficiary of the deposit, receiving the bTokens\n   * @param referral The referral code used\n   **/\n  event Deposit(\n    address user,\n    address indexed reserve,\n    uint256 amount,\n    address indexed onBehalfOf,\n    uint16 indexed referral\n  );\n\n  /**\n   * @dev Emitted on withdraw()\n   * @param user The address initiating the withdrawal, owner of bTokens\n   * @param reserve The address of the underlyng asset being withdrawn\n   * @param amount The amount to be withdrawn\n   * @param to Address that will receive the underlying\n   **/\n  event Withdraw(address indexed user, address indexed reserve, uint256 amount, address indexed to);\n\n  /**\n   * @dev Emitted on borrow() when loan needs to be opened\n   * @param user The address of the user initiating the borrow(), receiving the funds\n   * @param reserve The address of the underlying asset being borrowed\n   * @param amount The amount borrowed out\n   * @param nftAsset The address of the underlying NFT used as collateral\n   * @param nftTokenId The token id of the underlying NFT used as collateral\n   * @param onBehalfOf The address that will be getting the loan\n   * @param referral The referral code used\n   **/\n  event Borrow(\n    address user,\n    address indexed reserve,\n    uint256 amount,\n    address nftAsset,\n    uint256 nftTokenId,\n    address indexed onBehalfOf,\n    uint256 borrowRate,\n    uint256 loanId,\n    uint16 indexed referral\n  );\n\n  /**\n   * @dev Emitted on repay()\n   * @param user The address of the user initiating the repay(), providing the funds\n   * @param reserve The address of the underlying asset of the reserve\n   * @param amount The amount repaid\n   * @param nftAsset The address of the underlying NFT used as collateral\n   * @param nftTokenId The token id of the underlying NFT used as collateral\n   * @param borrower The beneficiary of the repayment, getting his debt reduced\n   * @param loanId The loan ID of the NFT loans\n   **/\n  event Repay(\n    address user,\n    address indexed reserve,\n    uint256 amount,\n    address indexed nftAsset,\n    uint256 nftTokenId,\n    address indexed borrower,\n    uint256 loanId\n  );\n\n  /**\n   * @dev Emitted when a borrower's loan is auctioned.\n   * @param user The address of the user initiating the auction\n   * @param reserve The address of the underlying asset of the reserve\n   * @param bidPrice The price of the underlying reserve given by the bidder\n   * @param nftAsset The address of the underlying NFT used as collateral\n   * @param nftTokenId The token id of the underlying NFT used as collateral\n   * @param onBehalfOf The address that will be getting the NFT\n   * @param loanId The loan ID of the NFT loans\n   **/\n  event Auction(\n    address user,\n    address indexed reserve,\n    uint256 bidPrice,\n    address indexed nftAsset,\n    uint256 nftTokenId,\n    address onBehalfOf,\n    address indexed borrower,\n    uint256 loanId\n  );\n\n  /**\n   * @dev Emitted on redeem()\n   * @param user The address of the user initiating the redeem(), providing the funds\n   * @param reserve The address of the underlying asset of the reserve\n   * @param borrowAmount The borrow amount repaid\n   * @param nftAsset The address of the underlying NFT used as collateral\n   * @param nftTokenId The token id of the underlying NFT used as collateral\n   * @param loanId The loan ID of the NFT loans\n   **/\n  event Redeem(\n    address user,\n    address indexed reserve,\n    uint256 borrowAmount,\n    uint256 fineAmount,\n    address indexed nftAsset,\n    uint256 nftTokenId,\n    address indexed borrower,\n    uint256 loanId\n  );\n\n  /**\n   * @dev Emitted when a borrower's loan is liquidated.\n   * @param user The address of the user initiating the auction\n   * @param reserve The address of the underlying asset of the reserve\n   * @param repayAmount The amount of reserve repaid by the liquidator\n   * @param remainAmount The amount of reserve received by the borrower\n   * @param loanId The loan ID of the NFT loans\n   **/\n  event Liquidate(\n    address user,\n    address indexed reserve,\n    uint256 repayAmount,\n    uint256 remainAmount,\n    address indexed nftAsset,\n    uint256 nftTokenId,\n    address indexed borrower,\n    uint256 loanId\n  );\n\n  /**\n   * @dev Emitted when the pause is triggered.\n   */\n  event Paused();\n\n  /**\n   * @dev Emitted when the pause is lifted.\n   */\n  event Unpaused();\n\n  /**\n   * @dev Emitted when the pause time is updated.\n   */\n  event PausedTimeUpdated(uint256 startTime, uint256 durationTime);\n\n  /**\n   * @dev Emitted when the state of a reserve is updated. NOTE: This event is actually declared\n   * in the ReserveLogic library and emitted in the updateInterestRates() function. Since the function is internal,\n   * the event will actually be fired by the LendPool contract. The event is therefore replicated here so it\n   * gets added to the LendPool ABI\n   * @param reserve The address of the underlying asset of the reserve\n   * @param liquidityRate The new liquidity rate\n   * @param variableBorrowRate The new variable borrow rate\n   * @param liquidityIndex The new liquidity index\n   * @param variableBorrowIndex The new variable borrow index\n   **/\n  event ReserveDataUpdated(\n    address indexed reserve,\n    uint256 liquidityRate,\n    uint256 variableBorrowRate,\n    uint256 liquidityIndex,\n    uint256 variableBorrowIndex\n  );\n\n  /**\n   * @dev Deposits an `amount` of underlying asset into the reserve, receiving in return overlying bTokens.\n   * - E.g. User deposits 100 USDC and gets in return 100 bUSDC\n   * @param reserve The address of the underlying asset to deposit\n   * @param amount The amount to be deposited\n   * @param onBehalfOf The address that will receive the bTokens, same as msg.sender if the user\n   *   wants to receive them on his own wallet, or a different address if the beneficiary of bTokens\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(\n    address reserve,\n    uint256 amount,\n    address onBehalfOf,\n    uint16 referralCode\n  ) external;\n\n  /**\n   * @dev Withdraws an `amount` of underlying asset from the reserve, burning the equivalent bTokens owned\n   * E.g. User has 100 bUSDC, calls withdraw() and receives 100 USDC, burning the 100 bUSDC\n   * @param reserve 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 bToken balance\n   * @param to 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(\n    address reserve,\n    uint256 amount,\n    address to\n  ) external returns (uint256);\n\n  /**\n   * @dev Allows users to borrow a specific `amount` of the reserve underlying asset, provided that the borrower\n   * already deposited enough collateral\n   * - E.g. User borrows 100 USDC, receiving the 100 USDC in his wallet\n   *   and lock collateral asset in contract\n   * @param reserveAsset The address of the underlying asset to borrow\n   * @param amount The amount to be borrowed\n   * @param nftAsset The address of the underlying NFT used as collateral\n   * @param nftTokenId The token ID of the underlying NFT used as collateral\n   * @param onBehalfOf Address of the user who will receive the loan. 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   * @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 borrow(\n    address reserveAsset,\n    uint256 amount,\n    address nftAsset,\n    uint256 nftTokenId,\n    address onBehalfOf,\n    uint16 referralCode\n  ) external;\n\n  function batchBorrow(\n    address[] calldata assets,\n    uint256[] calldata amounts,\n    address[] calldata nftAssets,\n    uint256[] calldata nftTokenIds,\n    address onBehalfOf,\n    uint16 referralCode\n  ) external;\n\n  /**\n   * @notice Repays a borrowed `amount` on a specific reserve, burning the equivalent loan owned\n   * - E.g. User repays 100 USDC, burning loan and receives collateral asset\n   * @param nftAsset The address of the underlying NFT used as collateral\n   * @param nftTokenId The token ID of the underlying NFT used as collateral\n   * @param amount The amount to repay\n   * @return The final amount repaid, loan is burned or not\n   **/\n  function repay(\n    address nftAsset,\n    uint256 nftTokenId,\n    uint256 amount\n  ) external returns (uint256, bool);\n\n  function batchRepay(\n    address[] calldata nftAssets,\n    uint256[] calldata nftTokenIds,\n    uint256[] calldata amounts\n  ) external returns (uint256[] memory, bool[] memory);\n\n  /**\n   * @dev Function to auction a non-healthy position collateral-wise\n   * - The caller (liquidator) want to buy collateral asset of the user getting liquidated\n   * @param nftAsset The address of the underlying NFT used as collateral\n   * @param nftTokenId The token ID of the underlying NFT used as collateral\n   * @param bidPrice The bid price of the liquidator want to buy the underlying NFT\n   * @param onBehalfOf Address of the user who will get the underlying NFT, same as msg.sender if the user\n   *   wants to receive them on his own wallet, or a different address if the beneficiary of NFT\n   *   is a different wallet\n   **/\n  function auction(\n    address nftAsset,\n    uint256 nftTokenId,\n    uint256 bidPrice,\n    address onBehalfOf\n  ) external;\n\n  /**\n   * @notice Redeem a NFT loan which state is in Auction\n   * - E.g. User repays 100 USDC, burning loan and receives collateral asset\n   * @param nftAsset The address of the underlying NFT used as collateral\n   * @param nftTokenId The token ID of the underlying NFT used as collateral\n   * @param amount The amount to repay the debt\n   * @param bidFine The amount of bid fine\n   **/\n  function redeem(\n    address nftAsset,\n    uint256 nftTokenId,\n    uint256 amount,\n    uint256 bidFine\n  ) external returns (uint256);\n\n  /**\n   * @dev Function to liquidate a non-healthy position collateral-wise\n   * - The caller (liquidator) buy collateral asset of the user getting liquidated, and receives\n   *   the collateral asset\n   * @param nftAsset The address of the underlying NFT used as collateral\n   * @param nftTokenId The token ID of the underlying NFT used as collateral\n   **/\n  function liquidate(\n    address nftAsset,\n    uint256 nftTokenId,\n    uint256 amount\n  ) external returns (uint256);\n\n  /**\n   * @dev Validates and finalizes an bToken transfer\n   * - Only callable by the overlying bToken of the `asset`\n   * @param asset The address of the underlying asset of the bToken\n   * @param from The user from which the bTokens are transferred\n   * @param to The user receiving the bTokens\n   * @param amount The amount being transferred/withdrawn\n   * @param balanceFromBefore The bToken balance of the `from` user before the transfer\n   * @param balanceToBefore The bToken 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 view;\n\n  function getReserveConfiguration(address asset) external view returns (DataTypes.ReserveConfigurationMap memory);\n\n  function getNftConfiguration(address asset) external view returns (DataTypes.NftConfigurationMap memory);\n\n  /**\n   * @dev Returns the normalized income 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   * @dev Returns the normalized variable debt per unit of asset\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   * @dev Returns the state and configuration of the reserve\n   * @param asset The address of the underlying asset of the reserve\n   * @return The state of the reserve\n   **/\n  function getReserveData(address asset) external view returns (DataTypes.ReserveData memory);\n\n  function getReservesList() external view returns (address[] memory);\n\n  function getNftData(address asset) external view returns (DataTypes.NftData memory);\n\n  /**\n   * @dev Returns the loan data of the NFT\n   * @param nftAsset The address of the NFT\n   * @param reserveAsset The address of the Reserve\n   * @return totalCollateralInETH the total collateral in ETH of the NFT\n   * @return totalCollateralInReserve the total collateral in Reserve of the NFT\n   * @return availableBorrowsInETH the borrowing power in ETH of the NFT\n   * @return availableBorrowsInReserve the borrowing power in Reserve of the NFT\n   * @return ltv the loan to value of the user\n   * @return liquidationThreshold the liquidation threshold of the NFT\n   * @return liquidationBonus the liquidation bonus of the NFT\n   **/\n  function getNftCollateralData(address nftAsset, address reserveAsset)\n    external\n    view\n    returns (\n      uint256 totalCollateralInETH,\n      uint256 totalCollateralInReserve,\n      uint256 availableBorrowsInETH,\n      uint256 availableBorrowsInReserve,\n      uint256 ltv,\n      uint256 liquidationThreshold,\n      uint256 liquidationBonus\n    );\n\n  /**\n   * @dev Returns the debt data of the NFT\n   * @param nftAsset The address of the NFT\n   * @param nftTokenId The token id of the NFT\n   * @return loanId the loan id of the NFT\n   * @return reserveAsset the address of the Reserve\n   * @return totalCollateral the total power of the NFT\n   * @return totalDebt the total debt of the NFT\n   * @return availableBorrows the borrowing power left of the NFT\n   * @return healthFactor the current health factor of the NFT\n   **/\n  function getNftDebtData(address nftAsset, uint256 nftTokenId)\n    external\n    view\n    returns (\n      uint256 loanId,\n      address reserveAsset,\n      uint256 totalCollateral,\n      uint256 totalDebt,\n      uint256 availableBorrows,\n      uint256 healthFactor\n    );\n\n  /**\n   * @dev Returns the auction data of the NFT\n   * @param nftAsset The address of the NFT\n   * @param nftTokenId The token id of the NFT\n   * @return loanId the loan id of the NFT\n   * @return bidderAddress the highest bidder address of the loan\n   * @return bidPrice the highest bid price in Reserve of the loan\n   * @return bidBorrowAmount the borrow amount in Reserve of the loan\n   * @return bidFine the penalty fine of the loan\n   **/\n  function getNftAuctionData(address nftAsset, uint256 nftTokenId)\n    external\n    view\n    returns (\n      uint256 loanId,\n      address bidderAddress,\n      uint256 bidPrice,\n      uint256 bidBorrowAmount,\n      uint256 bidFine\n    );\n\n  function getNftAuctionEndTime(address nftAsset, uint256 nftTokenId)\n    external\n    view\n    returns (\n      uint256 loanId,\n      uint256 bidStartTimestamp,\n      uint256 bidEndTimestamp,\n      uint256 redeemEndTimestamp\n    );\n\n  function getNftLiquidatePrice(address nftAsset, uint256 nftTokenId)\n    external\n    view\n    returns (uint256 liquidatePrice, uint256 paybackAmount);\n\n  function getNftsList() external view returns (address[] memory);\n\n  /**\n   * @dev Set the _pause state of a reserve\n   * - Only callable by the LendPool contract\n   * @param val `true` to pause the reserve, `false` to un-pause it\n   */\n  function setPause(bool val) external;\n\n  function setPausedTime(uint256 startTime, uint256 durationTime) external;\n\n  /**\n   * @dev Returns if the LendPool is paused\n   */\n  function paused() external view returns (bool);\n\n  function getPausedTime() external view returns (uint256, uint256);\n\n  function getAddressesProvider() external view returns (ILendPoolAddressesProvider);\n\n  function initReserve(\n    address asset,\n    address bTokenAddress,\n    address debtTokenAddress,\n    address interestRateAddress\n  ) external;\n\n  function initNft(address asset, address bNftAddress) external;\n\n  function setReserveInterestRateAddress(address asset, address rateAddress) external;\n\n  function setReserveConfiguration(address asset, uint256 configuration) external;\n\n  function setNftConfiguration(address asset, uint256 configuration) external;\n\n  function setNftMaxSupplyAndTokenId(\n    address asset,\n    uint256 maxSupply,\n    uint256 maxTokenId\n  ) external;\n\n  function setMaxNumberOfReserves(uint256 val) external;\n\n  function setMaxNumberOfNfts(uint256 val) external;\n\n  function getMaxNumberOfReserves() external view returns (uint256);\n\n  function getMaxNumberOfNfts() external view returns (uint256);\n}\n"
      },
      "contracts/interfaces/IWETH.sol": {
        "content": "// SPDX-License-Identifier: agpl-3.0\npragma solidity 0.8.4;\n\ninterface IWETH {\n  function balanceOf(address guy) external returns (uint256);\n\n  function deposit() external payable;\n\n  function withdraw(uint256) external;\n\n  function approve(address guy, uint256 wad) external returns (bool);\n\n  function transferFrom(\n    address src,\n    address dst,\n    uint256 wad\n  ) external returns (bool);\n}\n"
      },
      "contracts/protocol/EmergencyTokenRecoveryUpgradeable.sol": {
        "content": "// SPDX-License-Identifier: agpl-3.0\npragma solidity 0.8.4;\n\nimport {OwnableUpgradeable} from \"@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol\";\nimport {IERC20Upgradeable} from \"@openzeppelin/contracts-upgradeable/token/ERC20/IERC20Upgradeable.sol\";\nimport {IERC721Upgradeable} from \"@openzeppelin/contracts-upgradeable/token/ERC721/IERC721Upgradeable.sol\";\nimport {SafeERC20Upgradeable} from \"@openzeppelin/contracts-upgradeable/token/ERC20/utils/SafeERC20Upgradeable.sol\";\n\nimport {IPunks} from \"../interfaces/IPunks.sol\";\n\n/**\n * @title EmergencyTokenRecovery\n * @notice Add Emergency Recovery Logic to contract implementation\n * @author Bend\n **/\nabstract contract EmergencyTokenRecoveryUpgradeable is OwnableUpgradeable {\n  using SafeERC20Upgradeable for IERC20Upgradeable;\n\n  event EmergencyEtherTransfer(address indexed to, uint256 amount);\n\n  function __EmergencyTokenRecovery_init() internal onlyInitializing {\n    __Ownable_init();\n  }\n\n  /**\n   * @dev transfer ERC20 from the utility contract, for ERC20 recovery in case of stuck tokens due\n   * direct transfers to the contract address.\n   * @param token token to transfer\n   * @param to recipient of the transfer\n   * @param amount amount to send\n   */\n  function emergencyERC20Transfer(\n    address token,\n    address to,\n    uint256 amount\n  ) external onlyOwner {\n    IERC20Upgradeable(token).safeTransfer(to, amount);\n  }\n\n  /**\n   * @dev transfer ERC721 from the utility contract, for ERC721 recovery in case of stuck tokens due\n   * direct transfers to the contract address.\n   * @param token token to transfer\n   * @param to recipient of the transfer\n   * @param id token id to send\n   */\n  function emergencyERC721Transfer(\n    address token,\n    address to,\n    uint256 id\n  ) external onlyOwner {\n    IERC721Upgradeable(token).safeTransferFrom(address(this), to, id);\n  }\n\n  /**\n   * @dev transfer CryptoPunks from the utility contract, for punks recovery in case of stuck punks\n   * due direct transfers to the contract address.\n   * @param to recipient of the transfer\n   * @param index punk index to send\n   */\n  function emergencyPunksTransfer(\n    address punks,\n    address to,\n    uint256 index\n  ) external onlyOwner {\n    IPunks(punks).transferPunk(to, index);\n  }\n\n  /**\n   * @dev transfer native Ether from the utility contract, for native Ether recovery in case of stuck Ether\n   * due selfdestructs or transfer ether to pre-computated contract address before deployment.\n   * @param to recipient of the transfer\n   * @param amount amount to send\n   */\n  function emergencyEtherTransfer(address to, uint256 amount) external onlyOwner {\n    (bool success, ) = to.call{value: amount}(new bytes(0));\n    require(success, \"ETH_TRANSFER_FAILED\");\n    emit EmergencyEtherTransfer(to, amount);\n  }\n\n  uint256[50] private __gap;\n}\n"
      },
      "@openzeppelin/contracts-upgradeable/utils/ContextUpgradeable.sol": {
        "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (utils/Context.sol)\n\npragma solidity ^0.8.0;\nimport \"../proxy/utils/Initializable.sol\";\n\n/**\n * @dev Provides information about the current execution context, including the\n * sender of the transaction and its data. While these are generally available\n * via msg.sender and msg.data, they should not be accessed in such a direct\n * manner, since when dealing with meta-transactions the account sending and\n * paying for execution may not be the actual sender (as far as an application\n * is concerned).\n *\n * This contract is only required for intermediate, library-like contracts.\n */\nabstract contract ContextUpgradeable is Initializable {\n    function __Context_init() internal onlyInitializing {\n        __Context_init_unchained();\n    }\n\n    function __Context_init_unchained() internal onlyInitializing {\n    }\n    function _msgSender() internal view virtual returns (address) {\n        return msg.sender;\n    }\n\n    function _msgData() internal view virtual returns (bytes calldata) {\n        return msg.data;\n    }\n    uint256[50] private __gap;\n}\n"
      },
      "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol": {
        "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (proxy/utils/Initializable.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../../utils/AddressUpgradeable.sol\";\n\n/**\n * @dev This is a base contract to aid in writing upgradeable contracts, or any kind of contract that will be deployed\n * behind a proxy. Since a proxied contract can't have a constructor, it's common to move constructor logic to an\n * external initializer function, usually called `initialize`. It then becomes necessary to protect this initializer\n * function so it can only be called once. The {initializer} modifier provided by this contract will have this effect.\n *\n * TIP: To avoid leaving the proxy in an uninitialized state, the initializer function should be called as early as\n * possible by providing the encoded function call as the `_data` argument to {ERC1967Proxy-constructor}.\n *\n * CAUTION: When used with inheritance, manual care must be taken to not invoke a parent initializer twice, or to ensure\n * that all initializers are idempotent. This is not verified automatically as constructors are by Solidity.\n *\n * [CAUTION]\n * ====\n * Avoid leaving a contract uninitialized.\n *\n * An uninitialized contract can be taken over by an attacker. This applies to both a proxy and its implementation\n * contract, which may impact the proxy. To initialize the implementation contract, you can either invoke the\n * initializer manually, or you can include a constructor to automatically mark it as initialized when it is deployed:\n *\n * [.hljs-theme-light.nopadding]\n * ```\n * /// @custom:oz-upgrades-unsafe-allow constructor\n * constructor() initializer {}\n * ```\n * ====\n */\nabstract contract Initializable {\n    /**\n     * @dev Indicates that the contract has been initialized.\n     */\n    bool private _initialized;\n\n    /**\n     * @dev Indicates that the contract is in the process of being initialized.\n     */\n    bool private _initializing;\n\n    /**\n     * @dev Modifier to protect an initializer function from being invoked twice.\n     */\n    modifier initializer() {\n        // If the contract is initializing we ignore whether _initialized is set in order to support multiple\n        // inheritance patterns, but we only do this in the context of a constructor, because in other contexts the\n        // contract may have been reentered.\n        require(_initializing ? _isConstructor() : !_initialized, \"Initializable: contract is already initialized\");\n\n        bool isTopLevelCall = !_initializing;\n        if (isTopLevelCall) {\n            _initializing = true;\n            _initialized = true;\n        }\n\n        _;\n\n        if (isTopLevelCall) {\n            _initializing = false;\n        }\n    }\n\n    /**\n     * @dev Modifier to protect an initialization function so that it can only be invoked by functions with the\n     * {initializer} modifier, directly or indirectly.\n     */\n    modifier onlyInitializing() {\n        require(_initializing, \"Initializable: contract is not initializing\");\n        _;\n    }\n\n    function _isConstructor() private view returns (bool) {\n        return !AddressUpgradeable.isContract(address(this));\n    }\n}\n"
      },
      "@openzeppelin/contracts-upgradeable/utils/AddressUpgradeable.sol": {
        "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (utils/Address.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev Collection of functions related to the address type\n */\nlibrary AddressUpgradeable {\n    /**\n     * @dev Returns true if `account` is a contract.\n     *\n     * [IMPORTANT]\n     * ====\n     * It is unsafe to assume that an address for which this function returns\n     * false is an externally-owned account (EOA) and not a contract.\n     *\n     * Among others, `isContract` will return false for the following\n     * types of addresses:\n     *\n     *  - an externally-owned account\n     *  - a contract in construction\n     *  - an address where a contract will be created\n     *  - an address where a contract lived, but was destroyed\n     * ====\n     */\n    function isContract(address account) internal view returns (bool) {\n        // This method relies on extcodesize, which returns 0 for contracts in\n        // construction, since the code is only stored at the end of the\n        // constructor execution.\n\n        uint256 size;\n        assembly {\n            size := extcodesize(account)\n        }\n        return size > 0;\n    }\n\n    /**\n     * @dev Replacement for Solidity's `transfer`: sends `amount` wei to\n     * `recipient`, forwarding all available gas and reverting on errors.\n     *\n     * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost\n     * of certain opcodes, possibly making contracts go over the 2300 gas limit\n     * imposed by `transfer`, making them unable to receive funds via\n     * `transfer`. {sendValue} removes this limitation.\n     *\n     * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more].\n     *\n     * IMPORTANT: because control is transferred to `recipient`, care must be\n     * taken to not create reentrancy vulnerabilities. Consider using\n     * {ReentrancyGuard} or the\n     * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].\n     */\n    function sendValue(address payable recipient, uint256 amount) internal {\n        require(address(this).balance >= amount, \"Address: insufficient balance\");\n\n        (bool success, ) = recipient.call{value: amount}(\"\");\n        require(success, \"Address: unable to send value, recipient may have reverted\");\n    }\n\n    /**\n     * @dev Performs a Solidity function call using a low level `call`. A\n     * plain `call` is an unsafe replacement for a function call: use this\n     * function instead.\n     *\n     * If `target` reverts with a revert reason, it is bubbled up by this\n     * function (like regular Solidity function calls).\n     *\n     * Returns the raw returned data. To convert to the expected return value,\n     * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].\n     *\n     * Requirements:\n     *\n     * - `target` must be a contract.\n     * - calling `target` with `data` must not revert.\n     *\n     * _Available since v3.1._\n     */\n    function functionCall(address target, bytes memory data) internal returns (bytes memory) {\n        return functionCall(target, data, \"Address: low-level call failed\");\n    }\n\n    /**\n     * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with\n     * `errorMessage` as a fallback revert reason when `target` reverts.\n     *\n     * _Available since v3.1._\n     */\n    function functionCall(\n        address target,\n        bytes memory data,\n        string memory errorMessage\n    ) internal returns (bytes memory) {\n        return functionCallWithValue(target, data, 0, errorMessage);\n    }\n\n    /**\n     * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n     * but also transferring `value` wei to `target`.\n     *\n     * Requirements:\n     *\n     * - the calling contract must have an ETH balance of at least `value`.\n     * - the called Solidity function must be `payable`.\n     *\n     * _Available since v3.1._\n     */\n    function functionCallWithValue(\n        address target,\n        bytes memory data,\n        uint256 value\n    ) internal returns (bytes memory) {\n        return functionCallWithValue(target, data, value, \"Address: low-level call with value failed\");\n    }\n\n    /**\n     * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but\n     * with `errorMessage` as a fallback revert reason when `target` reverts.\n     *\n     * _Available since v3.1._\n     */\n    function functionCallWithValue(\n        address target,\n        bytes memory data,\n        uint256 value,\n        string memory errorMessage\n    ) internal returns (bytes memory) {\n        require(address(this).balance >= value, \"Address: insufficient balance for call\");\n        require(isContract(target), \"Address: call to non-contract\");\n\n        (bool success, bytes memory returndata) = target.call{value: value}(data);\n        return verifyCallResult(success, returndata, errorMessage);\n    }\n\n    /**\n     * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n     * but performing a static call.\n     *\n     * _Available since v3.3._\n     */\n    function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {\n        return functionStaticCall(target, data, \"Address: low-level static call failed\");\n    }\n\n    /**\n     * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\n     * but performing a static call.\n     *\n     * _Available since v3.3._\n     */\n    function functionStaticCall(\n        address target,\n        bytes memory data,\n        string memory errorMessage\n    ) internal view returns (bytes memory) {\n        require(isContract(target), \"Address: static call to non-contract\");\n\n        (bool success, bytes memory returndata) = target.staticcall(data);\n        return verifyCallResult(success, returndata, errorMessage);\n    }\n\n    /**\n     * @dev Tool to verifies that a low level call was successful, and revert if it wasn't, either by bubbling the\n     * revert reason using the provided one.\n     *\n     * _Available since v4.3._\n     */\n    function verifyCallResult(\n        bool success,\n        bytes memory returndata,\n        string memory errorMessage\n    ) internal pure returns (bytes memory) {\n        if (success) {\n            return returndata;\n        } else {\n            // Look for revert reason and bubble it up if present\n            if (returndata.length > 0) {\n                // The easiest way to bubble the revert reason is using memory via assembly\n\n                assembly {\n                    let returndata_size := mload(returndata)\n                    revert(add(32, returndata), returndata_size)\n                }\n            } else {\n                revert(errorMessage);\n            }\n        }\n    }\n}\n"
      },
      "contracts/libraries/types/DataTypes.sol": {
        "content": "// SPDX-License-Identifier: agpl-3.0\npragma solidity 0.8.4;\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    //variable borrow index. Expressed in ray\n    uint128 variableBorrowIndex;\n    //the current supply rate. Expressed in ray\n    uint128 currentLiquidityRate;\n    //the current variable borrow rate. Expressed in ray\n    uint128 currentVariableBorrowRate;\n    uint40 lastUpdateTimestamp;\n    //tokens addresses\n    address bTokenAddress;\n    address debtTokenAddress;\n    //address of the interest rate strategy\n    address interestRateAddress;\n    //the id of the reserve. Represents the position in the list of the active reserves\n    uint8 id;\n  }\n\n  struct NftData {\n    //stores the nft configuration\n    NftConfigurationMap configuration;\n    //address of the bNFT contract\n    address bNftAddress;\n    //the id of the nft. Represents the position in the list of the active nfts\n    uint8 id;\n    uint256 maxSupply;\n    uint256 maxTokenId;\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-63: reserved\n    //bit 64-79: reserve factor\n    uint256 data;\n  }\n\n  struct NftConfigurationMap {\n    //bit 0-15: LTV\n    //bit 16-31: Liq. threshold\n    //bit 32-47: Liq. bonus\n    //bit 56: NFT is active\n    //bit 57: NFT is frozen\n    uint256 data;\n  }\n\n  /**\n   * @dev Enum describing the current state of a loan\n   * State change flow:\n   *  Created -> Active -> Repaid\n   *                    -> Auction -> Defaulted\n   */\n  enum LoanState {\n    // We need a default that is not 'Created' - this is the zero value\n    None,\n    // The loan data is stored, but not initiated yet.\n    Created,\n    // The loan has been initialized, funds have been delivered to the borrower and the collateral is held.\n    Active,\n    // The loan is in auction, higest price liquidator will got chance to claim it.\n    Auction,\n    // The loan has been repaid, and the collateral has been returned to the borrower. This is a terminal state.\n    Repaid,\n    // The loan was delinquent and collateral claimed by the liquidator. This is a terminal state.\n    Defaulted\n  }\n\n  struct LoanData {\n    //the id of the nft loan\n    uint256 loanId;\n    //the current state of the loan\n    LoanState state;\n    //address of borrower\n    address borrower;\n    //address of nft asset token\n    address nftAsset;\n    //the id of nft token\n    uint256 nftTokenId;\n    //address of reserve asset token\n    address reserveAsset;\n    //scaled borrow amount. Expressed in ray\n    uint256 scaledAmount;\n    //start time of first bid time\n    uint256 bidStartTimestamp;\n    //bidder address of higest bid\n    address bidderAddress;\n    //price of higest bid\n    uint256 bidPrice;\n    //borrow amount of loan\n    uint256 bidBorrowAmount;\n    //bidder address of first bid\n    address firstBidderAddress;\n  }\n\n  struct ExecuteDepositParams {\n    address initiator;\n    address asset;\n    uint256 amount;\n    address onBehalfOf;\n    uint16 referralCode;\n  }\n\n  struct ExecuteWithdrawParams {\n    address initiator;\n    address asset;\n    uint256 amount;\n    address to;\n  }\n\n  struct ExecuteBorrowParams {\n    address initiator;\n    address asset;\n    uint256 amount;\n    address nftAsset;\n    uint256 nftTokenId;\n    address onBehalfOf;\n    uint16 referralCode;\n  }\n\n  struct ExecuteBatchBorrowParams {\n    address initiator;\n    address[] assets;\n    uint256[] amounts;\n    address[] nftAssets;\n    uint256[] nftTokenIds;\n    address onBehalfOf;\n    uint16 referralCode;\n  }\n\n  struct ExecuteRepayParams {\n    address initiator;\n    address nftAsset;\n    uint256 nftTokenId;\n    uint256 amount;\n  }\n\n  struct ExecuteBatchRepayParams {\n    address initiator;\n    address[] nftAssets;\n    uint256[] nftTokenIds;\n    uint256[] amounts;\n  }\n\n  struct ExecuteAuctionParams {\n    address initiator;\n    address nftAsset;\n    uint256 nftTokenId;\n    uint256 bidPrice;\n    address onBehalfOf;\n  }\n\n  struct ExecuteRedeemParams {\n    address initiator;\n    address nftAsset;\n    uint256 nftTokenId;\n    uint256 amount;\n    uint256 bidFine;\n  }\n\n  struct ExecuteLiquidateParams {\n    address initiator;\n    address nftAsset;\n    uint256 nftTokenId;\n    uint256 amount;\n  }\n\n  struct ExecuteLendPoolStates {\n    uint256 pauseStartTime;\n    uint256 pauseDurationTime;\n  }\n}\n"
      },
      "@openzeppelin/contracts-upgradeable/token/ERC20/IERC20Upgradeable.sol": {
        "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (token/ERC20/IERC20.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev Interface of the ERC20 standard as defined in the EIP.\n */\ninterface IERC20Upgradeable {\n    /**\n     * @dev Returns the amount of tokens in existence.\n     */\n    function totalSupply() external view returns (uint256);\n\n    /**\n     * @dev Returns the amount of tokens owned by `account`.\n     */\n    function balanceOf(address account) external view returns (uint256);\n\n    /**\n     * @dev Moves `amount` tokens from the caller's account to `recipient`.\n     *\n     * Returns a boolean value indicating whether the operation succeeded.\n     *\n     * Emits a {Transfer} event.\n     */\n    function transfer(address recipient, uint256 amount) external returns (bool);\n\n    /**\n     * @dev Returns the remaining number of tokens that `spender` will be\n     * allowed to spend on behalf of `owner` through {transferFrom}. This is\n     * zero by default.\n     *\n     * This value changes when {approve} or {transferFrom} are called.\n     */\n    function allowance(address owner, address spender) external view returns (uint256);\n\n    /**\n     * @dev Sets `amount` as the allowance of `spender` over the caller's tokens.\n     *\n     * Returns a boolean value indicating whether the operation succeeded.\n     *\n     * IMPORTANT: Beware that changing an allowance with this method brings the risk\n     * that someone may use both the old and the new allowance by unfortunate\n     * transaction ordering. One possible solution to mitigate this race\n     * condition is to first reduce the spender's allowance to 0 and set the\n     * desired value afterwards:\n     * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729\n     *\n     * Emits an {Approval} event.\n     */\n    function approve(address spender, uint256 amount) external returns (bool);\n\n    /**\n     * @dev Moves `amount` tokens from `sender` to `recipient` using the\n     * allowance mechanism. `amount` is then deducted from the caller's\n     * allowance.\n     *\n     * Returns a boolean value indicating whether the operation succeeded.\n     *\n     * Emits a {Transfer} event.\n     */\n    function transferFrom(\n        address sender,\n        address recipient,\n        uint256 amount\n    ) external returns (bool);\n\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"
      },
      "@openzeppelin/contracts-upgradeable/token/ERC721/IERC721Upgradeable.sol": {
        "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (token/ERC721/IERC721.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../../utils/introspection/IERC165Upgradeable.sol\";\n\n/**\n * @dev Required interface of an ERC721 compliant contract.\n */\ninterface IERC721Upgradeable is IERC165Upgradeable {\n    /**\n     * @dev Emitted when `tokenId` token is transferred from `from` to `to`.\n     */\n    event Transfer(address indexed from, address indexed to, uint256 indexed tokenId);\n\n    /**\n     * @dev Emitted when `owner` enables `approved` to manage the `tokenId` token.\n     */\n    event Approval(address indexed owner, address indexed approved, uint256 indexed tokenId);\n\n    /**\n     * @dev Emitted when `owner` enables or disables (`approved`) `operator` to manage all of its assets.\n     */\n    event ApprovalForAll(address indexed owner, address indexed operator, bool approved);\n\n    /**\n     * @dev Returns the number of tokens in ``owner``'s account.\n     */\n    function balanceOf(address owner) external view returns (uint256 balance);\n\n    /**\n     * @dev Returns the owner of the `tokenId` token.\n     *\n     * Requirements:\n     *\n     * - `tokenId` must exist.\n     */\n    function ownerOf(uint256 tokenId) external view returns (address owner);\n\n    /**\n     * @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients\n     * are aware of the ERC721 protocol to prevent tokens from being forever locked.\n     *\n     * Requirements:\n     *\n     * - `from` cannot be the zero address.\n     * - `to` cannot be the zero address.\n     * - `tokenId` token must exist and be owned by `from`.\n     * - If the caller is not `from`, it must be have been allowed to move this token by either {approve} or {setApprovalForAll}.\n     * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.\n     *\n     * Emits a {Transfer} event.\n     */\n    function safeTransferFrom(\n        address from,\n        address to,\n        uint256 tokenId\n    ) external;\n\n    /**\n     * @dev Transfers `tokenId` token from `from` to `to`.\n     *\n     * WARNING: Usage of this method is discouraged, use {safeTransferFrom} whenever possible.\n     *\n     * Requirements:\n     *\n     * - `from` cannot be the zero address.\n     * - `to` cannot be the zero address.\n     * - `tokenId` token must be owned by `from`.\n     * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}.\n     *\n     * Emits a {Transfer} event.\n     */\n    function transferFrom(\n        address from,\n        address to,\n        uint256 tokenId\n    ) external;\n\n    /**\n     * @dev Gives permission to `to` to transfer `tokenId` token to another account.\n     * The approval is cleared when the token is transferred.\n     *\n     * Only a single account can be approved at a time, so approving the zero address clears previous approvals.\n     *\n     * Requirements:\n     *\n     * - The caller must own the token or be an approved operator.\n     * - `tokenId` must exist.\n     *\n     * Emits an {Approval} event.\n     */\n    function approve(address to, uint256 tokenId) external;\n\n    /**\n     * @dev Returns the account approved for `tokenId` token.\n     *\n     * Requirements:\n     *\n     * - `tokenId` must exist.\n     */\n    function getApproved(uint256 tokenId) external view returns (address operator);\n\n    /**\n     * @dev Approve or remove `operator` as an operator for the caller.\n     * Operators can call {transferFrom} or {safeTransferFrom} for any token owned by the caller.\n     *\n     * Requirements:\n     *\n     * - The `operator` cannot be the caller.\n     *\n     * Emits an {ApprovalForAll} event.\n     */\n    function setApprovalForAll(address operator, bool _approved) external;\n\n    /**\n     * @dev Returns if the `operator` is allowed to manage all of the assets of `owner`.\n     *\n     * See {setApprovalForAll}\n     */\n    function isApprovedForAll(address owner, address operator) external view returns (bool);\n\n    /**\n     * @dev Safely transfers `tokenId` token from `from` to `to`.\n     *\n     * Requirements:\n     *\n     * - `from` cannot be the zero address.\n     * - `to` cannot be the zero address.\n     * - `tokenId` token must exist and be owned by `from`.\n     * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}.\n     * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.\n     *\n     * Emits a {Transfer} event.\n     */\n    function safeTransferFrom(\n        address from,\n        address to,\n        uint256 tokenId,\n        bytes calldata data\n    ) external;\n}\n"
      },
      "@openzeppelin/contracts-upgradeable/token/ERC20/utils/SafeERC20Upgradeable.sol": {
        "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (token/ERC20/utils/SafeERC20.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../IERC20Upgradeable.sol\";\nimport \"../../../utils/AddressUpgradeable.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 SafeERC20Upgradeable {\n    using AddressUpgradeable for address;\n\n    function safeTransfer(\n        IERC20Upgradeable token,\n        address to,\n        uint256 value\n    ) internal {\n        _callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value));\n    }\n\n    function safeTransferFrom(\n        IERC20Upgradeable token,\n        address from,\n        address to,\n        uint256 value\n    ) internal {\n        _callOptionalReturn(token, abi.encodeWithSelector(token.transferFrom.selector, from, to, value));\n    }\n\n    /**\n     * @dev Deprecated. This function has issues similar to the ones found in\n     * {IERC20-approve}, and its usage is discouraged.\n     *\n     * Whenever possible, use {safeIncreaseAllowance} and\n     * {safeDecreaseAllowance} instead.\n     */\n    function safeApprove(\n        IERC20Upgradeable token,\n        address spender,\n        uint256 value\n    ) internal {\n        // safeApprove should only be called when setting an initial allowance,\n        // or when resetting it to zero. To increase and decrease it, use\n        // 'safeIncreaseAllowance' and 'safeDecreaseAllowance'\n        require(\n            (value == 0) || (token.allowance(address(this), spender) == 0),\n            \"SafeERC20: approve from non-zero to non-zero allowance\"\n        );\n        _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, value));\n    }\n\n    function safeIncreaseAllowance(\n        IERC20Upgradeable token,\n        address spender,\n        uint256 value\n    ) internal {\n        uint256 newAllowance = token.allowance(address(this), spender) + value;\n        _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance));\n    }\n\n    function safeDecreaseAllowance(\n        IERC20Upgradeable token,\n        address spender,\n        uint256 value\n    ) internal {\n        unchecked {\n            uint256 oldAllowance = token.allowance(address(this), spender);\n            require(oldAllowance >= value, \"SafeERC20: decreased allowance below zero\");\n            uint256 newAllowance = oldAllowance - value;\n            _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance));\n        }\n    }\n\n    /**\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(IERC20Upgradeable token, bytes memory data) private {\n        // We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since\n        // we're implementing it ourselves. We use {Address.functionCall} to perform this call, which verifies that\n        // the target address contains contract code and also asserts for success in the low-level call.\n\n        bytes memory returndata = address(token).functionCall(data, \"SafeERC20: low-level call failed\");\n        if (returndata.length > 0) {\n            // Return data is optional\n            require(abi.decode(returndata, (bool)), \"SafeERC20: ERC20 operation did not succeed\");\n        }\n    }\n}\n"
      },
      "contracts/interfaces/IPunks.sol": {
        "content": "// SPDX-License-Identifier: agpl-3.0\npragma solidity 0.8.4;\n\n/**\n * @dev Interface for a permittable ERC721 contract\n * See https://eips.ethereum.org/EIPS/eip-2612[EIP-2612].\n *\n * Adds the {permit} method, which can be used to change an account's ERC72 allowance (see {IERC721-allowance}) by\n * presenting a message signed by the account. By not relying on {IERC721-approve}, the token holder account doesn't\n * need to send a transaction, and thus is not required to hold Ether at all.\n */\ninterface IPunks {\n  function balanceOf(address account) external view returns (uint256);\n\n  function punkIndexToAddress(uint256 punkIndex) external view returns (address owner);\n\n  function offerPunkForSaleToAddress(\n    uint256 punkIndex,\n    uint256 minSalePriceInWei,\n    address toAddress\n  ) external;\n\n  function buyPunk(uint256 punkIndex) external;\n\n  function transferPunk(address to, uint256 punkIndex) external;\n}\n"
      },
      "@openzeppelin/contracts-upgradeable/utils/introspection/IERC165Upgradeable.sol": {
        "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (utils/introspection/IERC165.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev Interface of the ERC165 standard, as defined in the\n * https://eips.ethereum.org/EIPS/eip-165[EIP].\n *\n * Implementers can declare support of contract interfaces, which can then be\n * queried by others ({ERC165Checker}).\n *\n * For an implementation, see {ERC165}.\n */\ninterface IERC165Upgradeable {\n    /**\n     * @dev Returns true if this contract implements the interface defined by\n     * `interfaceId`. See the corresponding\n     * https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section]\n     * to learn more about how these ids are created.\n     *\n     * This function call must use less than 30 000 gas.\n     */\n    function supportsInterface(bytes4 interfaceId) external view returns (bool);\n}\n"
      }
    },
    "settings": {
      "optimizer": {
        "enabled": true,
        "runs": 200
      },
      "evmVersion": "istanbul",
      "outputSelection": {
        "*": {
          "*": [
            "evm.bytecode",
            "evm.deployedBytecode",
            "devdoc",
            "userdoc",
            "metadata",
            "abi"
          ]
        }
      },
      "libraries": {}
    }
  }}