Contract 0x48cDD2531B35cfA35061125CE977d796571E4627 11

 
Txn Hash Method
Block
From
To
Value [Txn Fee]
0x57a0bdbf8d30f86dc7cbfc0f7073b4e4f9213471fc60fa41961521ec5d038e08Flash Close1335048932023-09-22 11:26:4420 hrs 56 mins ago0xcd36b622085c508404ddaaca943eb69ad8113ff7 IN  Fuji DAO: Fliquidator0 ETH0.0001166 0.1
0x6322c277c7b1e9aa442dad557a9cfbbdc4cfe6f68d999bf8ae2f2a73f6bd0246Flash Close1332300362023-09-21 15:43:191 day 16 hrs ago0x71a1df0d820d29c784c04865904492ac38801a04 IN  Fuji DAO: Fliquidator0 ETH0.00012101 0.1
0x40b5abf060ff470876323a6d591524a4848ae8dd238e7d0df45cbd0e86b51f6cFlash Close1329560602023-09-20 20:09:132 days 12 hrs ago0x04777aeecc844b88e4d23e053870052432b183d4 IN  Fuji DAO: Fliquidator0 ETH0.00012509 0.1
0xce4b78ec6fedf4752df6994092ab620a0fe6b91c42780d420d3d8afce65fdf95Flash Close1329558962023-09-20 20:08:292 days 12 hrs ago0x04777aeecc844b88e4d23e053870052432b183d4 IN  Fuji DAO: Fliquidator0 ETH0.00013164 0.1
0x24f99c151ab2e53bbbfb7b0ef95466fb5f3f5f9254f9255ae2e7ab46a9ce2c6aFlash Close1270369932023-09-01 13:29:0621 days 18 hrs ago0x2c6802060c60162c0bf45e3df533415c49c7c0ba IN  Fuji DAO: Fliquidator0 ETH0.00013491 0.1
0x099028c08104b97e5a6e9ca2cd18c3ffd92a7d730f129a23c15d02d052258eb0Flash Close1231840502023-08-20 8:44:3833 days 23 hrs ago0x0fd90b9d61af052c4328bc2fa9a1529627af0a7d IN  Fuji DAO: Fliquidator0 ETH0.00012491 0.1
0x7091b537c9e8918a0e65b9de9d154320636a31a2c37b08c0664167cb342c0aa8Flash Close1210503252023-08-13 17:09:0740 days 15 hrs ago0xb397bd1d5879ad7628975d6dc40ffbd970bb76e9 IN  Fuji DAO: Fliquidator0 ETH0.00013724 0.1
0x4e87c07f1933d334d40e466fd5eadd356f3295d815d6d73aed842932b22a0dedFlash Close1210490292023-08-13 17:03:1940 days 15 hrs ago0xf44c5f75c4eeb6433a285b6b05765343a1dd72e6 IN  Fuji DAO: Fliquidator0 ETH0.00013733 0.1
0x7dabd5be27a5a6e5ffce36c9eea46cc6767d66096cfb041be1cb21ff28c75d14Flash Close1205979962023-08-12 7:22:4142 days 1 hr ago0x0aa5244f1402c0c06aeac321e2ae2c27d7e16446 IN  Fuji DAO: Fliquidator0 ETH0.00012543 0.1
0xe79cecc6a61cf6ce665de4cb1b3c1c27eaa0167a283571db261823aa3b4d624cFlash Close1157377352023-07-28 9:11:3956 days 23 hrs ago0xcbcdfa152b4725a870b8ad853d8a74ebadea19fc IN  Fuji DAO: Fliquidator0 ETH0.00013442 0.1
0x644051b0e5635dff15c825302e96a90b25fc09db1218f73bfa0f558372df5ce1Flash Close1151078522023-07-26 11:26:4358 days 20 hrs ago0xa9e0eab9c54c4fe3f254721b55db63cc35e6d77f IN  Fuji DAO: Fliquidator0 ETH0.00013947 0.1
0x007cec5a598ba0f6e02abbf73519f0b3e42595186b5d53615a56b6d35822259bFlash Close1144437122023-07-24 11:12:1860 days 21 hrs ago0x4e2a5c7d995678677decc01f9fc8f937cf5b3c22 IN  Fuji DAO: Fliquidator0 ETH0.00014793 0.1
0x4db41842eb72c47c0d5894fae2b4f49cb0510f81265c6e350eb4237efabca63aFlash Close1144406772023-07-24 10:59:2760 days 21 hrs ago0x75399b184afdb4ffe526aefaad0f7ecefe8bf7a7 IN  Fuji DAO: Fliquidator0 ETH0.00015763 0.1
0xa1e8023924dda0520d9827087426da25d27fbaa0e4d8bc54985e88faeeff2ecdFlash Close1144374322023-07-24 10:45:4260 days 21 hrs ago0x84ad600eade8a21bb785a7a7a1528b307db84e52 IN  Fuji DAO: Fliquidator0 ETH0.00017044 0.1
0x5b72c455b72ab13500b2e5644aaf49672cad1416474dd4d3031dc95ce4fca137Flash Close1144360852023-07-24 10:40:0160 days 21 hrs ago0x180a9c42a49f65f8c4f611d4396af79a53b33953 IN  Fuji DAO: Fliquidator0 ETH0.00017928 0.1
0xbb682a5e4f741d9f9c66fe3c6c793cb7294ca9780034b0ba9e1a8b79b3a0d86bFlash Close1135314132023-07-21 17:04:4163 days 15 hrs ago0x26c9cd33f56d2c78f7443d15caaae6229f881f7a IN  Fuji DAO: Fliquidator0 ETH0.00017847 0.1
0xc0b97aaa7ac797b16d6e75f99f2a562c960d9d01445da3e13da09b8c7f9feb50Flash Close1135297622023-07-21 16:57:2563 days 15 hrs ago0xc09b39cb5ea407c15526d466f5094df612bd8d61 IN  Fuji DAO: Fliquidator0 ETH0.00017613 0.1
0xc6ca27ed03bdb4bbe7cceeced81f049cf2affc4debc3ca80e6dcb647b622e0b9Flash Close1135283132023-07-21 16:51:0563 days 15 hrs ago0xdf03662372ebccfaf34c57cc848533656417ccc5 IN  Fuji DAO: Fliquidator0 ETH0.0001791 0.1
0xfcca43e31db1405a89b5c82043fece5d5e868d7620aeb33861f92a01acea61e7Flash Close1135248812023-07-21 16:36:0863 days 15 hrs ago0x4c2b5b7ce010cbf90eeb92a00d96469ec9a04aef IN  Fuji DAO: Fliquidator0 ETH0.0001826 0.1
0xd18f7d62259486c02fe2d62f3c2815567445279377b2280302eecb04a407777bFlash Close1135221892023-07-21 16:24:2363 days 15 hrs ago0x51856f187a1b621d94f3486f6503ae9d0ba08311 IN  Fuji DAO: Fliquidator0 ETH0.00018248 0.1
0x1691c2aa6a5626c4159d8c1ef82f4a77799cd38896a0970bb370ca12cea928b8Flash Close1135204552023-07-21 16:17:0263 days 16 hrs ago0x7c2672051a1ad6a0c5942480aa0699eac23be9c5 IN  Fuji DAO: Fliquidator0 ETH0.00017589 0.1
0xe87dc1b7b216712b51b05484f16de5e27601d0b5c6e0a49ab36ff435ce92f2a2Flash Close1135188052023-07-21 16:09:5663 days 16 hrs ago0xcb2f6e30971048dc8448d8d409b9fed006aba53f IN  Fuji DAO: Fliquidator0 ETH0.00017331 0.1
0x257a265ed246b03380b24ddaad320fb1ca8ac4f9259cf6917b4c45e8d50bc827Flash Close1135159802023-07-21 15:57:5563 days 16 hrs ago0x5d5e48fd17201afd7390fa250faddf6edfdc24b1 IN  Fuji DAO: Fliquidator0 ETH0.00017652 0.1
0xae0b8d3100115b9122f4f4493bb9d4bccb059992a886d8f4289dddeb2979ab57Flash Close1135123612023-07-21 15:42:3263 days 16 hrs ago0xa9033d7d80e05480f3b699312f31ffc564cb61e7 IN  Fuji DAO: Fliquidator0 ETH0.00017559 0.1
0x8c107320de2cca356f1aee4d9fc4a352da0d9eb786fc187ecf16252027ff5a8dFlash Close1114940192023-07-15 14:40:5569 days 17 hrs ago0xac7c71a8e3e0e5458e471d503d1e6369a54fa0bc IN  Fuji DAO: Fliquidator0 ETH0.00012978 0.1
[ Download CSV Export 
Latest 25 internal transaction
Parent Txn Hash Block From To Value
0x57a0bdbf8d30f86dc7cbfc0f7073b4e4f9213471fc60fa41961521ec5d038e081335048932023-09-22 11:26:4420 hrs 56 mins ago Fuji DAO: Fliquidator SushiSwap: Router0.032050677438635601 ETH
0x57a0bdbf8d30f86dc7cbfc0f7073b4e4f9213471fc60fa41961521ec5d038e081335048932023-09-22 11:26:4420 hrs 56 mins ago Fuji DAO: Fliquidator0xcd36b622085c508404ddaaca943eb69ad8113ff70.008076033381558564 ETH
0x57a0bdbf8d30f86dc7cbfc0f7073b4e4f9213471fc60fa41961521ec5d038e081335048932023-09-22 11:26:4420 hrs 56 mins ago Fuji DAO: VaultWETHUSDC Fuji DAO: Fliquidator0.040126710820194165 ETH
0x6322c277c7b1e9aa442dad557a9cfbbdc4cfe6f68d999bf8ae2f2a73f6bd02461332300362023-09-21 15:43:191 day 16 hrs ago Fuji DAO: Fliquidator SushiSwap: Router0.003294201748596074 ETH
0x6322c277c7b1e9aa442dad557a9cfbbdc4cfe6f68d999bf8ae2f2a73f6bd02461332300362023-09-21 15:43:191 day 16 hrs ago Fuji DAO: Fliquidator0x71a1df0d820d29c784c04865904492ac38801a040.016950321045081774 ETH
0x6322c277c7b1e9aa442dad557a9cfbbdc4cfe6f68d999bf8ae2f2a73f6bd02461332300362023-09-21 15:43:191 day 16 hrs ago Fuji DAO: VaultWETHUSDC Fuji DAO: Fliquidator0.020244522793677848 ETH
0x40b5abf060ff470876323a6d591524a4848ae8dd238e7d0df45cbd0e86b51f6c1329560602023-09-20 20:09:132 days 12 hrs ago Fuji DAO: Fliquidator SushiSwap: Router0.03096164464100663 ETH
0x40b5abf060ff470876323a6d591524a4848ae8dd238e7d0df45cbd0e86b51f6c1329560602023-09-20 20:09:132 days 12 hrs ago Fuji DAO: Fliquidator0x04777aeecc844b88e4d23e053870052432b183d40.010477418873264308 ETH
0x40b5abf060ff470876323a6d591524a4848ae8dd238e7d0df45cbd0e86b51f6c1329560602023-09-20 20:09:132 days 12 hrs ago Fuji DAO: VaultWETHUSDC Fuji DAO: Fliquidator0.041439063514270938 ETH
0xce4b78ec6fedf4752df6994092ab620a0fe6b91c42780d420d3d8afce65fdf951329558962023-09-20 20:08:292 days 12 hrs ago Fuji DAO: Fliquidator Fuji DAO: Flasher0.004381870849922824 ETH
0xce4b78ec6fedf4752df6994092ab620a0fe6b91c42780d420d3d8afce65fdf951329558962023-09-20 20:08:292 days 12 hrs ago Fuji DAO: Fliquidator 0x89c1e94f47c4e3a374b5a98455468f27ca2b25440.000043818708499228 ETH
0xce4b78ec6fedf4752df6994092ab620a0fe6b91c42780d420d3d8afce65fdf951329558962023-09-20 20:08:292 days 12 hrs ago SushiSwap: Router Fuji DAO: Fliquidator0.004425689558422052 ETH
0xce4b78ec6fedf4752df6994092ab620a0fe6b91c42780d420d3d8afce65fdf951329558962023-09-20 20:08:292 days 12 hrs ago Fuji DAO: Fliquidator Fuji DAO: VaultUSDCWETH0.004381870849922824 ETH
0xce4b78ec6fedf4752df6994092ab620a0fe6b91c42780d420d3d8afce65fdf951329558962023-09-20 20:08:292 days 12 hrs ago Fuji DAO: Flasher Fuji DAO: Fliquidator0.004381870849922824 ETH
0x24f99c151ab2e53bbbfb7b0ef95466fb5f3f5f9254f9255ae2e7ab46a9ce2c6a1270369932023-09-01 13:29:0621 days 18 hrs ago Fuji DAO: Fliquidator SushiSwap: Router0.015708438198157681 ETH
0x24f99c151ab2e53bbbfb7b0ef95466fb5f3f5f9254f9255ae2e7ab46a9ce2c6a1270369932023-09-01 13:29:0621 days 18 hrs ago Fuji DAO: Fliquidator0x2c6802060c60162c0bf45e3df533415c49c7c0ba0.004680521640304936 ETH
0x24f99c151ab2e53bbbfb7b0ef95466fb5f3f5f9254f9255ae2e7ab46a9ce2c6a1270369932023-09-01 13:29:0621 days 18 hrs ago Fuji DAO: VaultWETHUSDC Fuji DAO: Fliquidator0.020388959838462617 ETH
0x099028c08104b97e5a6e9ca2cd18c3ffd92a7d730f129a23c15d02d052258eb01231840502023-08-20 8:44:3833 days 23 hrs ago Fuji DAO: Fliquidator SushiSwap: Router0.217020085243457168 ETH
0x099028c08104b97e5a6e9ca2cd18c3ffd92a7d730f129a23c15d02d052258eb01231840502023-08-20 8:44:3833 days 23 hrs ago Fuji DAO: Fliquidator0x0fd90b9d61af052c4328bc2fa9a1529627af0a7d0.790928704751288315 ETH
0x099028c08104b97e5a6e9ca2cd18c3ffd92a7d730f129a23c15d02d052258eb01231840502023-08-20 8:44:3833 days 23 hrs ago Fuji DAO: VaultWETHUSDC Fuji DAO: Fliquidator1.007948789994745483 ETH
0x7091b537c9e8918a0e65b9de9d154320636a31a2c37b08c0664167cb342c0aa81210503252023-08-13 17:09:0740 days 15 hrs ago Fuji DAO: Fliquidator SushiSwap: Router0.000000041881106422 ETH
0x7091b537c9e8918a0e65b9de9d154320636a31a2c37b08c0664167cb342c0aa81210503252023-08-13 17:09:0740 days 15 hrs ago Fuji DAO: Fliquidator0xb397bd1d5879ad7628975d6dc40ffbd970bb76e90.000000012874214966 ETH
0x7091b537c9e8918a0e65b9de9d154320636a31a2c37b08c0664167cb342c0aa81210503252023-08-13 17:09:0740 days 15 hrs ago Fuji DAO: VaultWETHUSDC Fuji DAO: Fliquidator0.000000054755321388 ETH
0x4e87c07f1933d334d40e466fd5eadd356f3295d815d6d73aed842932b22a0ded1210490292023-08-13 17:03:1940 days 15 hrs ago Fuji DAO: Fliquidator SushiSwap: Router0.000000017946012336 ETH
0x4e87c07f1933d334d40e466fd5eadd356f3295d815d6d73aed842932b22a0ded1210490292023-08-13 17:03:1940 days 15 hrs ago Fuji DAO: Fliquidator0xf44c5f75c4eeb6433a285b6b05765343a1dd72e60.000000005520553952 ETH
[ Download CSV Export 
Loading

Contract Source Code Verified (Exact Match)

Contract Name:
F2Fliquidator

Compiler Version
v0.8.4+commit.c7e474f2

Optimization Enabled:
Yes with 500 runs

Other Settings:
default evmVersion
File 1 of 21 : F2Fliquidator.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.0;

import "@uniswap/v2-periphery/contracts/interfaces/IUniswapV2Router02.sol";
import "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";
import "@openzeppelin/contracts/token/ERC1155/IERC1155.sol";
import "@openzeppelin/contracts/security/ReentrancyGuard.sol";

import "./abstracts/claimable/Claimable.sol";
import "./interfaces/IVault.sol";
import "./interfaces/IVaultControl.sol";
import "./interfaces/IFujiAdmin.sol";
import "./interfaces/IFujiOracle.sol";
import "./interfaces/IFujiERC1155.sol";
import "./interfaces/IERC20Extended.sol";
import "./interfaces/IFlasher.sol";
import "./libraries/LibUniversalERC20.sol";
import "./libraries/FlashLoans.sol";
import "./libraries/Errors.sol";

/**
 * @dev Contract to execute liquidations and flash close.
 */

contract F2Fliquidator is Claimable, ReentrancyGuard {
  using SafeERC20 for IERC20;
  using LibUniversalERC20 for IERC20;

  address public constant NATIVE = 0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE;

  // slippage limit to 2%
  uint256 public constant SLIPPAGE_LIMIT_NUMERATOR = 2;
  uint256 public constant SLIPPAGE_LIMIT_DENOMINATOR = 100;

  struct Factor {
    uint64 a;
    uint64 b;
  }

  // Flash Close Fee Factor
  Factor public flashCloseF;

  IFujiAdmin private _fujiAdmin;
  IFujiOracle private _oracle;
  IUniswapV2Router02 public swapper;

  /**
   * @dev Log when a user is liquidated
   */
  event Liquidate(
    address indexed userAddr,
    address indexed vault,
    uint256 amount,
    address liquidator
  );
  /**
   * @dev Log when a user FlashClose its position
   */
  event FlashClose(address indexed userAddr, address indexed vault, uint256 amount);
  /**
   * @dev Log a change in fuji admin address
   */
  event FujiAdminChanged(address newFujiAdmin);
  /**
   * @dev Log a change in the factor values
   */
  event FactorChanged(bytes32 typehash, uint64 newFactorA, uint64 newFactorB);

  /**
   * @dev Log a change in the oracle address
   */
  event OracleChanged(address newOracle);
  /**
   * @dev Log change of swapper address
   */
  event SwapperChanged(address newSwapper);

  /**
   * @dev Throws if caller is not 'owner'.
   */
  modifier isAuthorized() {
    require(msg.sender == owner(), Errors.VL_NOT_AUTHORIZED);
    _;
  }

  /**
   * @dev Throws if caller is not '_flasher' address in {FujiAdmin}.
   */
  modifier onlyFlash() {
    require(msg.sender == _fujiAdmin.getFlasher(), Errors.VL_NOT_AUTHORIZED);
    _;
  }

  /**
   * @dev Throws if address passed is not a recognized vault.
   */
  modifier isValidVault(address _vaultAddr) {
    require(_fujiAdmin.validVault(_vaultAddr), "Invalid vault!");
    _;
  }

  /**
   * @dev Sets the flash close fee factor.
   */
  constructor() {
    // 0.01
    flashCloseF.a = 1;
    flashCloseF.b = 100;
  }

  receive() external payable {}

  // FLiquidator Core Functions

  /**
   * @dev Liquidates undercollaterized debt positions and get bonus (bonusL in Vault)
   * @param _addrs: Address array of users whose position is liquidatable
   * @param _vault: Address of the vault in where liquidation will occur
   * Emits a {Liquidate} event for each liquidated user.
   */
  function batchLiquidate(address[] calldata _addrs, address _vault)
    external
    payable
    nonReentrant
    isValidVault(_vault)
  {
    IVaultControl.VaultAssets memory vAssets = IVaultControl(_vault).vAssets();
    address f1155 = IVault(_vault).fujiERC1155();

    IVault(_vault).updateF1155Balances();

    (address[] memory addrs, uint256[] memory borrowBals, uint256 debtTotal) = _constructParams(
      _addrs,
      vAssets,
      _vault,
      f1155
    );

    // Check there is at least one user liquidatable
    require(debtTotal > 0, Errors.VL_USER_NOT_LIQUIDATABLE);

    if (vAssets.borrowAsset == NATIVE) {
      require(msg.value >= debtTotal, Errors.VL_AMOUNT_ERROR);
    } else {
      // Check Liquidator Allowance
      require(
        IERC20(vAssets.borrowAsset).allowance(msg.sender, address(this)) >= debtTotal,
        Errors.VL_MISSING_ERC20_ALLOWANCE
      );

      // Transfer borrowAsset funds from the Liquidator to Vault
      IERC20(vAssets.borrowAsset).safeTransferFrom(msg.sender, _vault, debtTotal);
    }

    // Repay BaseProtocol debt
    uint256 _value = vAssets.borrowAsset == NATIVE ? debtTotal : 0;
    IVault(_vault).paybackLiq{ value: _value }(addrs, debtTotal);

    // Compute liquidator's bonus: bonusL
    uint256 bonus = IVault(_vault).getLiquidationBonusFor(debtTotal);
    // Compute how much collateral needs to be swapt
    uint256 collateralInPlay = _getCollateralInPlay(
      vAssets.collateralAsset,
      vAssets.borrowAsset,
      debtTotal + bonus
    );

    // Burn f1155
    _burnMulti(addrs, borrowBals, vAssets, _vault, f1155);

    // Withdraw collateral
    IVault(_vault).withdrawLiq(int256(collateralInPlay));

    // Swap Collateral
    _swap(vAssets.collateralAsset, vAssets.borrowAsset, debtTotal + bonus, collateralInPlay, true);

    // Transfer to Liquidator the debtBalance + bonus
    IERC20(vAssets.borrowAsset).univTransfer(payable(msg.sender), debtTotal + bonus);

    // Emit liquidation event for each liquidated user
    for (uint256 i = 0; i < addrs.length; i += 1) {
      if (addrs[i] != address(0)) {
        emit Liquidate(addrs[i], _vault, borrowBals[i], msg.sender);
      }
    }
  }

  /**
   * @dev Initiates a flashloan to liquidate array of undercollaterized debt positions,
   * gets bonus (bonusFlashL in Vault)
   * @param _addrs: Array of Address whose position is liquidatable
   * @param _vault: The vault address where the debt position exist.
   * @param _flashnum: integer identifier of flashloan provider
   */
  function flashBatchLiquidate(
    address[] calldata _addrs,
    address _vault,
    uint8 _flashnum
  ) external isValidVault(_vault) nonReentrant {
    IVaultControl.VaultAssets memory vAssets = IVaultControl(_vault).vAssets();
    address f1155 = IVault(_vault).fujiERC1155();

    IVault(_vault).updateF1155Balances();

    (address[] memory addrs, uint256[] memory borrowBals, uint256 debtTotal) = _constructParams(
      _addrs,
      vAssets,
      _vault,
      f1155
    );

    // Check there is at least one user liquidatable
    require(debtTotal > 0, Errors.VL_USER_NOT_LIQUIDATABLE);

    FlashLoan.Info memory info = FlashLoan.Info({
      callType: FlashLoan.CallType.BatchLiquidate,
      asset: vAssets.borrowAsset,
      amount: debtTotal,
      vault: _vault,
      newProvider: address(0),
      userAddrs: addrs,
      userBalances: borrowBals,
      userliquidator: msg.sender,
      fliquidator: address(this)
    });

    IFlasher(payable(_fujiAdmin.getFlasher())).initiateFlashloan(info, _flashnum);
  }

  /**
   * @dev Liquidate a debt position by using a flashloan
   * @param _addrs: array **See addrs construction in 'function flashBatchLiquidate'
   * @param _borrowBals: array **See construction in 'function flashBatchLiquidate'
   * @param _liquidator: liquidator address
   * @param _vault: Vault address
   * @param _amount: amount of debt to be repaid
   * @param _flashloanFee: amount extra charged by flashloan provider
   * Emits a {Liquidate} event for each liquidated user.
   */
  function executeFlashBatchLiquidation(
    address[] calldata _addrs,
    uint256[] calldata _borrowBals,
    address _liquidator,
    address _vault,
    uint256 _amount,
    uint256 _flashloanFee
  ) external payable onlyFlash {
    address f1155 = IVault(_vault).fujiERC1155();
    IVaultControl.VaultAssets memory vAssets = IVaultControl(_vault).vAssets();

    // Repay BaseProtocol debt to release collateral
    uint256 _value = vAssets.borrowAsset == NATIVE ? _amount : 0;
    IVault(_vault).paybackLiq{ value: _value }(_addrs, _amount);

    // Compute liquidator's bonus
    uint256 bonus = IVault(_vault).getLiquidationBonusFor(_amount);

    // Compute how much collateral needs to be swapt for all liquidated users
    uint256 collateralInPlay = _getCollateralInPlay(
      vAssets.collateralAsset,
      vAssets.borrowAsset,
      _amount + _flashloanFee + bonus
    );

    // Burn f1155
    _burnMulti(_addrs, _borrowBals, vAssets, _vault, f1155);

    // Withdraw collateral
    IVault(_vault).withdrawLiq(int256(collateralInPlay));

    _swap(
      vAssets.collateralAsset,
      vAssets.borrowAsset,
      _amount + _flashloanFee + bonus,
      collateralInPlay,
      true
    );

    // Send flasher the underlying to repay Flashloan
    IERC20(vAssets.borrowAsset).univTransfer(
      payable(_fujiAdmin.getFlasher()),
      _amount + _flashloanFee
    );

    // Liquidator's bonus gets reduced by 20% as a protocol fee
    uint256 fujiFee = bonus / 5;

    // Transfer liquidator's bonus, minus fujiFee
    IERC20(vAssets.borrowAsset).univTransfer(payable(_liquidator), bonus - fujiFee);

    // Transfer fee to Fuji Treasury
    IERC20(vAssets.borrowAsset).univTransfer(_fujiAdmin.getTreasury(), fujiFee);

    // Emit liquidation event for each liquidated user
    for (uint256 i = 0; i < _addrs.length; i += 1) {
      if (_addrs[i] != address(0)) {
        emit Liquidate(_addrs[i], _vault, _borrowBals[i], _liquidator);
      }
    }
  }

  /**
   * @dev Initiates a flashloan used to repay partially or fully the debt position of msg.sender
   * @param _amount: Pass -1 to fully close debt position, otherwise Amount to be repaid with a flashloan
   * @param _vault: The vault address where the debt position exist.
   * @param _flashnum: integer identifier of flashloan provider
   */
  function flashClose(
    int256 _amount,
    address _vault,
    uint8 _flashnum
  ) external nonReentrant isValidVault(_vault) {
    // Update Balances at FujiERC1155
    IVault(_vault).updateF1155Balances();

    // Create Instance of FujiERC1155
    IFujiERC1155 f1155 = IFujiERC1155(IVault(_vault).fujiERC1155());

    // Struct Instance to get Vault Asset IDs in f1155
    IVaultControl.VaultAssets memory vAssets = IVaultControl(_vault).vAssets();

    // Get user  Balances
    uint256 userCollateral = f1155.balanceOf(msg.sender, vAssets.collateralID);
    uint256 debtTotal = IVault(_vault).userDebtBalance(msg.sender);

    require(debtTotal > 0, Errors.VL_NO_DEBT_TO_PAYBACK);

    uint256 amount = _amount < 0 ? debtTotal : uint256(_amount);

    uint256 neededCollateral = IVault(_vault).getNeededCollateralFor(amount, false);
    require(userCollateral >= neededCollateral, Errors.VL_UNDERCOLLATERIZED_ERROR);

    address[] memory userAddressArray = new address[](1);
    userAddressArray[0] = msg.sender;

    FlashLoan.Info memory info = FlashLoan.Info({
      callType: FlashLoan.CallType.Close,
      asset: vAssets.borrowAsset,
      amount: amount,
      vault: _vault,
      newProvider: address(0),
      userAddrs: userAddressArray,
      userBalances: new uint256[](0),
      userliquidator: address(0),
      fliquidator: address(this)
    });

    IFlasher(payable(_fujiAdmin.getFlasher())).initiateFlashloan(info, _flashnum);
  }

  /**
   * @dev Close user's debt position by using a flashloan
   * @param _userAddr: user addr to be liquidated
   * @param _vault: Vault address
   * @param _amount: amount received by Flashloan
   * @param _flashloanFee: amount extra charged by flashloan provider
   * Emits a {FlashClose} event.
   * Requirements:
   * - Should only be called by '_flasher' contract address stored in {FujiAdmin}
   */
  function executeFlashClose(
    address payable _userAddr,
    address _vault,
    uint256 _amount,
    uint256 _flashloanFee
  ) external payable onlyFlash {
    // Create Instance of FujiERC1155
    IFujiERC1155 f1155 = IFujiERC1155(IVault(_vault).fujiERC1155());

    // Struct Instance to get Vault Asset IDs in f1155
    IVaultControl.VaultAssets memory vAssets = IVaultControl(_vault).vAssets();
    uint256 flashCloseFee = (_amount * flashCloseF.a) / flashCloseF.b;

    uint256 protocolFee = IVault(_vault).userProtocolFee(_userAddr);
    uint256 totalDebt = f1155.balanceOf(_userAddr, vAssets.borrowID) + protocolFee;

    uint256 collateralInPlay = _getCollateralInPlay(
      vAssets.collateralAsset,
      vAssets.borrowAsset,
      _amount + _flashloanFee + flashCloseFee
    );

    // Repay BaseProtocol debt
    uint256 _value = vAssets.borrowAsset == NATIVE ? _amount : 0;
    address[] memory _addrs = new address[](1);
    _addrs[0] = _userAddr;
    IVault(_vault).paybackLiq{ value: _value }(_addrs, _amount);

    // Full close
    if (_amount == totalDebt) {
      uint256 userCollateral = f1155.balanceOf(_userAddr, vAssets.collateralID);

      f1155.burn(_userAddr, vAssets.collateralID, userCollateral);

      // Withdraw full collateral
      IVault(_vault).withdrawLiq(int256(userCollateral));

      // Send remaining collateral to user
      IERC20(vAssets.collateralAsset).univTransfer(_userAddr, userCollateral - collateralInPlay);
    } else {
      f1155.burn(_userAddr, vAssets.collateralID, collateralInPlay);

      // Withdraw collateral in play only
      IVault(_vault).withdrawLiq(int256(collateralInPlay));
    }

    // Swap collateral for underlying to repay flashloan
    _swap(
      vAssets.collateralAsset,
      vAssets.borrowAsset,
      _amount + _flashloanFee + flashCloseFee,
      collateralInPlay,
      false
    );

    // Send flashClose fee to Fuji Treasury
    IERC20(vAssets.borrowAsset).univTransfer(_fujiAdmin.getTreasury(), flashCloseFee);

    // Send flasher the underlying to repay flashloan
    IERC20(vAssets.borrowAsset).univTransfer(
      payable(_fujiAdmin.getFlasher()),
      _amount + _flashloanFee
    );

    // Burn Debt f1155 tokens
    f1155.burn(_userAddr, vAssets.borrowID, _amount - protocolFee);

    emit FlashClose(_userAddr, _vault, _amount);
  }

  /**
   * @dev Swap an amount of underlying
   * @param _collateralAsset: Address of vault collateralAsset
   * @param _borrowAsset: Address of vault borrowAsset
   * @param _amountToReceive: amount of underlying to receive
   * @param _collateralAmount: collateral Amount sent for swap
   */
  function _swap(
    address _collateralAsset,
    address _borrowAsset,
    uint256 _amountToReceive,
    uint256 _collateralAmount,
    bool _checkSlippage
  ) internal returns (uint256) {
    if (_checkSlippage) {
      uint8 _collateralAssetDecimals;
      uint8 _borrowAssetDecimals;
      if (_collateralAsset == NATIVE) {
        _collateralAssetDecimals = 18;
      } else {
        _collateralAssetDecimals = IERC20Extended(_collateralAsset).decimals();
      }
      if (_borrowAsset == NATIVE) {
        _borrowAssetDecimals = 18;
      } else {
        _borrowAssetDecimals = IERC20Extended(_borrowAsset).decimals();
      }

      uint256 priceFromSwapper = (_collateralAmount * (10**uint256(_borrowAssetDecimals))) /
        _amountToReceive;
      uint256 priceFromOracle = _oracle.getPriceOf(
        _collateralAsset,
        _borrowAsset,
        _collateralAssetDecimals
      );
      uint256 priceDelta = priceFromSwapper > priceFromOracle
        ? priceFromSwapper - priceFromOracle
        : priceFromOracle - priceFromSwapper;

      require(
        (priceDelta * SLIPPAGE_LIMIT_DENOMINATOR) / priceFromOracle < SLIPPAGE_LIMIT_NUMERATOR,
        Errors.VL_SWAP_SLIPPAGE_LIMIT_EXCEED
      );
    }

    // Swap Collateral Asset to Borrow Asset
    address weth = swapper.WETH();
    address[] memory path;
    uint256[] memory swapperAmounts;

    if (_collateralAsset == NATIVE) {
      path = new address[](2);
      path[0] = weth;
      path[1] = _borrowAsset;

      swapperAmounts = swapper.swapETHForExactTokens{ value: _collateralAmount }(
        _amountToReceive,
        path,
        address(this),
        // solhint-disable-next-line
        block.timestamp
      );
    } else if (_borrowAsset == NATIVE) {
      path = new address[](2);
      path[0] = _collateralAsset;
      path[1] = weth;

      IERC20(_collateralAsset).univApprove(address(swapper), _collateralAmount);
      swapperAmounts = swapper.swapTokensForExactETH(
        _amountToReceive,
        _collateralAmount,
        path,
        address(this),
        // solhint-disable-next-line
        block.timestamp
      );
    } else {
      if (_collateralAsset == weth || _borrowAsset == weth) {
        path = new address[](2);
        path[0] = _collateralAsset;
        path[1] = _borrowAsset;
      } else {
        path = new address[](3);
        path[0] = _collateralAsset;
        path[1] = weth;
        path[2] = _borrowAsset;
      }

      IERC20(_collateralAsset).univApprove(address(swapper), _collateralAmount);
      swapperAmounts = swapper.swapTokensForExactTokens(
        _amountToReceive,
        _collateralAmount,
        path,
        address(this),
        // solhint-disable-next-line
        block.timestamp
      );
    }

    return _collateralAmount - swapperAmounts[0];
  }

  /**
   * @dev Get exact amount of collateral to be swapt
   * @param _collateralAsset: Address of vault collateralAsset
   * @param _borrowAsset: Address of vault borrowAsset
   * @param _amountToReceive: amount of underlying to receive
   */
  function _getCollateralInPlay(
    address _collateralAsset,
    address _borrowAsset,
    uint256 _amountToReceive
  ) internal view returns (uint256) {
    address weth = swapper.WETH();
    address[] memory path;
    if (_collateralAsset == NATIVE || _collateralAsset == weth) {
      path = new address[](2);
      path[0] = weth;
      path[1] = _borrowAsset;
    } else if (_borrowAsset == NATIVE || _borrowAsset == weth) {
      path = new address[](2);
      path[0] = _collateralAsset;
      path[1] = weth;
    } else {
      path = new address[](3);
      path[0] = _collateralAsset;
      path[1] = weth;
      path[2] = _borrowAsset;
    }

    uint256[] memory amounts = swapper.getAmountsIn(_amountToReceive, path);

    return amounts[0];
  }

  function _constructParams(
    address[] memory _userAddrs,
    IVaultControl.VaultAssets memory _vAssets,
    address _vault,
    address _f1155
  )
    internal
    view
    returns (
      address[] memory addrs,
      uint256[] memory borrowBals,
      uint256 debtTotal
    )
  {
    addrs = new address[](_userAddrs.length);

    uint256[] memory borrowIds = new uint256[](_userAddrs.length);
    uint256[] memory collateralIds = new uint256[](_userAddrs.length);

    // Build the required Arrays to query balanceOfBatch from f1155
    for (uint256 i = 0; i < _userAddrs.length; i += 1) {
      collateralIds[i] = _vAssets.collateralID;
      borrowIds[i] = _vAssets.borrowID;
    }

    // Get user collateral and debt balances
    borrowBals = IERC1155(_f1155).balanceOfBatch(_userAddrs, borrowIds);
    uint256[] memory collateralBals = IERC1155(_f1155).balanceOfBatch(_userAddrs, collateralIds);

    uint256 neededCollateral;

    for (uint256 i = 0; i < _userAddrs.length; i += 1) {
      // Compute amount of min collateral required including factors
      neededCollateral = IVault(_vault).getNeededCollateralFor(borrowBals[i], true);

      // Check if User is liquidatable
      if (collateralBals[i] < neededCollateral) {
        // If true, add User debt balance to the total balance to be liquidated
        addrs[i] = _userAddrs[i];
        debtTotal += borrowBals[i] + IVault(_vault).userProtocolFee(addrs[i]);
      } else {
        // set user that is not liquidatable to Zero Address
        addrs[i] = address(0);
      }
    }
  }

  /**
   * @dev Perform multi-batch burn of collateral
   * checking bonus paid to liquidator by each
   */
  function _burnMulti(
    address[] memory _addrs,
    uint256[] memory _borrowBals,
    IVaultControl.VaultAssets memory _vAssets,
    address _vault,
    address _f1155
  ) internal {
    uint256 bonusPerUser;
    uint256 collateralInPlayPerUser;

    for (uint256 i = 0; i < _addrs.length; i += 1) {
      if (_addrs[i] != address(0)) {
        bonusPerUser = IVault(_vault).getLiquidationBonusFor(_borrowBals[i]);

        collateralInPlayPerUser = _getCollateralInPlay(
          _vAssets.collateralAsset,
          _vAssets.borrowAsset,
          _borrowBals[i] + bonusPerUser
        );

        IFujiERC1155(_f1155).burn(_addrs[i], _vAssets.borrowID, _borrowBals[i]);
        IFujiERC1155(_f1155).burn(_addrs[i], _vAssets.collateralID, collateralInPlayPerUser);
      }
    }
  }

  // Administrative functions

  /**
   * @dev Set Factors "a" and "b" for a Struct Factor flashcloseF
   * @param _newFactorA: Nominator
   * @param _newFactorB: Denominator
   * Emits a {FactorChanged} event.
   */
  function setFlashCloseFee(uint64 _newFactorA, uint64 _newFactorB) external isAuthorized {
    flashCloseF.a = _newFactorA;
    flashCloseF.b = _newFactorB;
    emit FactorChanged(keccak256(abi.encode("flashCloseF")), _newFactorA, _newFactorB);
  }

  /**
   * @dev Sets the fujiAdmin Address
   * @param _newFujiAdmin: FujiAdmin Contract Address
   * Emits a {FujiAdminChanged} event.
   */
  function setFujiAdmin(address _newFujiAdmin) external isAuthorized {
    require(_newFujiAdmin != address(0), Errors.VL_ZERO_ADDR);
    _fujiAdmin = IFujiAdmin(_newFujiAdmin);
    emit FujiAdminChanged(_newFujiAdmin);
  }

  /**
   * @dev Changes the Swapper contract address
   * @param _newSwapper: address of new swapper contract
   * Emits {SwapperChanged} event.
   */
  function setSwapper(address _newSwapper) external isAuthorized {
    require(_newSwapper != address(0), Errors.VL_ZERO_ADDR);
    swapper = IUniswapV2Router02(_newSwapper);
    emit SwapperChanged(_newSwapper);
  }

  /**
   * @dev Changes the Oracle contract address
   * @param _newFujiOracle: address of new oracle contract
   * Emits {OracleChanged} event.
   */
  function setFujiOracle(address _newFujiOracle) external isAuthorized {
    require(_newFujiOracle != address(0), Errors.VL_ZERO_ADDR);
    _oracle = IFujiOracle(_newFujiOracle);
    emit OracleChanged(_newFujiOracle);
  }
}

File 2 of 21 : IUniswapV2Router02.sol
pragma solidity >=0.6.2;

import './IUniswapV2Router01.sol';

interface IUniswapV2Router02 is IUniswapV2Router01 {
    function removeLiquidityETHSupportingFeeOnTransferTokens(
        address token,
        uint liquidity,
        uint amountTokenMin,
        uint amountETHMin,
        address to,
        uint deadline
    ) external returns (uint amountETH);
    function removeLiquidityETHWithPermitSupportingFeeOnTransferTokens(
        address token,
        uint liquidity,
        uint amountTokenMin,
        uint amountETHMin,
        address to,
        uint deadline,
        bool approveMax, uint8 v, bytes32 r, bytes32 s
    ) external returns (uint amountETH);

    function swapExactTokensForTokensSupportingFeeOnTransferTokens(
        uint amountIn,
        uint amountOutMin,
        address[] calldata path,
        address to,
        uint deadline
    ) external;
    function swapExactETHForTokensSupportingFeeOnTransferTokens(
        uint amountOutMin,
        address[] calldata path,
        address to,
        uint deadline
    ) external payable;
    function swapExactTokensForETHSupportingFeeOnTransferTokens(
        uint amountIn,
        uint amountOutMin,
        address[] calldata path,
        address to,
        uint deadline
    ) external;
}

File 3 of 21 : IERC20.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.6.0) (token/ERC20/IERC20.sol)

pragma solidity ^0.8.0;

/**
 * @dev Interface of the ERC20 standard as defined in the EIP.
 */
interface IERC20 {
    /**
     * @dev Emitted when `value` tokens are moved from one account (`from`) to
     * another (`to`).
     *
     * Note that `value` may be zero.
     */
    event Transfer(address indexed from, address indexed to, uint256 value);

    /**
     * @dev Emitted when the allowance of a `spender` for an `owner` is set by
     * a call to {approve}. `value` is the new allowance.
     */
    event Approval(address indexed owner, address indexed spender, uint256 value);

    /**
     * @dev Returns the amount of tokens in existence.
     */
    function totalSupply() external view returns (uint256);

    /**
     * @dev Returns the amount of tokens owned by `account`.
     */
    function balanceOf(address account) external view returns (uint256);

    /**
     * @dev Moves `amount` tokens from the caller's account to `to`.
     *
     * Returns a boolean value indicating whether the operation succeeded.
     *
     * Emits a {Transfer} event.
     */
    function transfer(address to, uint256 amount) external returns (bool);

    /**
     * @dev Returns the remaining number of tokens that `spender` will be
     * allowed to spend on behalf of `owner` through {transferFrom}. This is
     * zero by default.
     *
     * This value changes when {approve} or {transferFrom} are called.
     */
    function allowance(address owner, address spender) external view returns (uint256);

    /**
     * @dev Sets `amount` as the allowance of `spender` over the caller's tokens.
     *
     * Returns a boolean value indicating whether the operation succeeded.
     *
     * IMPORTANT: Beware that changing an allowance with this method brings the risk
     * that someone may use both the old and the new allowance by unfortunate
     * transaction ordering. One possible solution to mitigate this race
     * condition is to first reduce the spender's allowance to 0 and set the
     * desired value afterwards:
     * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
     *
     * Emits an {Approval} event.
     */
    function approve(address spender, uint256 amount) external returns (bool);

    /**
     * @dev Moves `amount` tokens from `from` to `to` using the
     * allowance mechanism. `amount` is then deducted from the caller's
     * allowance.
     *
     * Returns a boolean value indicating whether the operation succeeded.
     *
     * Emits a {Transfer} event.
     */
    function transferFrom(
        address from,
        address to,
        uint256 amount
    ) external returns (bool);
}

File 4 of 21 : SafeERC20.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (token/ERC20/utils/SafeERC20.sol)

pragma solidity ^0.8.0;

import "../IERC20.sol";
import "../../../utils/Address.sol";

/**
 * @title SafeERC20
 * @dev Wrappers around ERC20 operations that throw on failure (when the token
 * contract returns false). Tokens that return no value (and instead revert or
 * throw on failure) are also supported, non-reverting calls are assumed to be
 * successful.
 * To use this library you can add a `using SafeERC20 for IERC20;` statement to your contract,
 * which allows you to call the safe operations as `token.safeTransfer(...)`, etc.
 */
library SafeERC20 {
    using Address for address;

    function safeTransfer(
        IERC20 token,
        address to,
        uint256 value
    ) internal {
        _callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value));
    }

    function safeTransferFrom(
        IERC20 token,
        address from,
        address to,
        uint256 value
    ) internal {
        _callOptionalReturn(token, abi.encodeWithSelector(token.transferFrom.selector, from, to, value));
    }

    /**
     * @dev Deprecated. This function has issues similar to the ones found in
     * {IERC20-approve}, and its usage is discouraged.
     *
     * Whenever possible, use {safeIncreaseAllowance} and
     * {safeDecreaseAllowance} instead.
     */
    function safeApprove(
        IERC20 token,
        address spender,
        uint256 value
    ) internal {
        // safeApprove should only be called when setting an initial allowance,
        // or when resetting it to zero. To increase and decrease it, use
        // 'safeIncreaseAllowance' and 'safeDecreaseAllowance'
        require(
            (value == 0) || (token.allowance(address(this), spender) == 0),
            "SafeERC20: approve from non-zero to non-zero allowance"
        );
        _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, value));
    }

    function safeIncreaseAllowance(
        IERC20 token,
        address spender,
        uint256 value
    ) internal {
        uint256 newAllowance = token.allowance(address(this), spender) + value;
        _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance));
    }

    function safeDecreaseAllowance(
        IERC20 token,
        address spender,
        uint256 value
    ) internal {
        unchecked {
            uint256 oldAllowance = token.allowance(address(this), spender);
            require(oldAllowance >= value, "SafeERC20: decreased allowance below zero");
            uint256 newAllowance = oldAllowance - value;
            _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance));
        }
    }

    /**
     * @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement
     * on the return value: the return value is optional (but if data is returned, it must not be false).
     * @param token The token targeted by the call.
     * @param data The call data (encoded using abi.encode or one of its variants).
     */
    function _callOptionalReturn(IERC20 token, bytes memory data) private {
        // We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since
        // we're implementing it ourselves. We use {Address.functionCall} to perform this call, which verifies that
        // the target address contains contract code and also asserts for success in the low-level call.

        bytes memory returndata = address(token).functionCall(data, "SafeERC20: low-level call failed");
        if (returndata.length > 0) {
            // Return data is optional
            require(abi.decode(returndata, (bool)), "SafeERC20: ERC20 operation did not succeed");
        }
    }
}

File 5 of 21 : IERC1155.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (token/ERC1155/IERC1155.sol)

pragma solidity ^0.8.0;

import "../../utils/introspection/IERC165.sol";

/**
 * @dev Required interface of an ERC1155 compliant contract, as defined in the
 * https://eips.ethereum.org/EIPS/eip-1155[EIP].
 *
 * _Available since v3.1._
 */
interface IERC1155 is IERC165 {
    /**
     * @dev Emitted when `value` tokens of token type `id` are transferred from `from` to `to` by `operator`.
     */
    event TransferSingle(address indexed operator, address indexed from, address indexed to, uint256 id, uint256 value);

    /**
     * @dev Equivalent to multiple {TransferSingle} events, where `operator`, `from` and `to` are the same for all
     * transfers.
     */
    event TransferBatch(
        address indexed operator,
        address indexed from,
        address indexed to,
        uint256[] ids,
        uint256[] values
    );

    /**
     * @dev Emitted when `account` grants or revokes permission to `operator` to transfer their tokens, according to
     * `approved`.
     */
    event ApprovalForAll(address indexed account, address indexed operator, bool approved);

    /**
     * @dev Emitted when the URI for token type `id` changes to `value`, if it is a non-programmatic URI.
     *
     * If an {URI} event was emitted for `id`, the standard
     * https://eips.ethereum.org/EIPS/eip-1155#metadata-extensions[guarantees] that `value` will equal the value
     * returned by {IERC1155MetadataURI-uri}.
     */
    event URI(string value, uint256 indexed id);

    /**
     * @dev Returns the amount of tokens of token type `id` owned by `account`.
     *
     * Requirements:
     *
     * - `account` cannot be the zero address.
     */
    function balanceOf(address account, uint256 id) external view returns (uint256);

    /**
     * @dev xref:ROOT:erc1155.adoc#batch-operations[Batched] version of {balanceOf}.
     *
     * Requirements:
     *
     * - `accounts` and `ids` must have the same length.
     */
    function balanceOfBatch(address[] calldata accounts, uint256[] calldata ids)
        external
        view
        returns (uint256[] memory);

    /**
     * @dev Grants or revokes permission to `operator` to transfer the caller's tokens, according to `approved`,
     *
     * Emits an {ApprovalForAll} event.
     *
     * Requirements:
     *
     * - `operator` cannot be the caller.
     */
    function setApprovalForAll(address operator, bool approved) external;

    /**
     * @dev Returns true if `operator` is approved to transfer ``account``'s tokens.
     *
     * See {setApprovalForAll}.
     */
    function isApprovedForAll(address account, address operator) external view returns (bool);

    /**
     * @dev Transfers `amount` tokens of token type `id` from `from` to `to`.
     *
     * Emits a {TransferSingle} event.
     *
     * Requirements:
     *
     * - `to` cannot be the zero address.
     * - If the caller is not `from`, it must be have been approved to spend ``from``'s tokens via {setApprovalForAll}.
     * - `from` must have a balance of tokens of type `id` of at least `amount`.
     * - If `to` refers to a smart contract, it must implement {IERC1155Receiver-onERC1155Received} and return the
     * acceptance magic value.
     */
    function safeTransferFrom(
        address from,
        address to,
        uint256 id,
        uint256 amount,
        bytes calldata data
    ) external;

    /**
     * @dev xref:ROOT:erc1155.adoc#batch-operations[Batched] version of {safeTransferFrom}.
     *
     * Emits a {TransferBatch} event.
     *
     * Requirements:
     *
     * - `ids` and `amounts` must have the same length.
     * - If `to` refers to a smart contract, it must implement {IERC1155Receiver-onERC1155BatchReceived} and return the
     * acceptance magic value.
     */
    function safeBatchTransferFrom(
        address from,
        address to,
        uint256[] calldata ids,
        uint256[] calldata amounts,
        bytes calldata data
    ) external;
}

File 6 of 21 : ReentrancyGuard.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (security/ReentrancyGuard.sol)

pragma solidity ^0.8.0;

/**
 * @dev Contract module that helps prevent reentrant calls to a function.
 *
 * Inheriting from `ReentrancyGuard` will make the {nonReentrant} modifier
 * available, which can be applied to functions to make sure there are no nested
 * (reentrant) calls to them.
 *
 * Note that because there is a single `nonReentrant` guard, functions marked as
 * `nonReentrant` may not call one another. This can be worked around by making
 * those functions `private`, and then adding `external` `nonReentrant` entry
 * points to them.
 *
 * TIP: If you would like to learn more about reentrancy and alternative ways
 * to protect against it, check out our blog post
 * https://blog.openzeppelin.com/reentrancy-after-istanbul/[Reentrancy After Istanbul].
 */
abstract contract ReentrancyGuard {
    // Booleans are more expensive than uint256 or any type that takes up a full
    // word because each write operation emits an extra SLOAD to first read the
    // slot's contents, replace the bits taken up by the boolean, and then write
    // back. This is the compiler's defense against contract upgrades and
    // pointer aliasing, and it cannot be disabled.

    // The values being non-zero value makes deployment a bit more expensive,
    // but in exchange the refund on every call to nonReentrant will be lower in
    // amount. Since refunds are capped to a percentage of the total
    // transaction's gas, it is best to keep them low in cases like this one, to
    // increase the likelihood of the full refund coming into effect.
    uint256 private constant _NOT_ENTERED = 1;
    uint256 private constant _ENTERED = 2;

    uint256 private _status;

    constructor() {
        _status = _NOT_ENTERED;
    }

    /**
     * @dev Prevents a contract from calling itself, directly or indirectly.
     * Calling a `nonReentrant` function from another `nonReentrant`
     * function is not supported. It is possible to prevent this from happening
     * by making the `nonReentrant` function external, and making it call a
     * `private` function that does the actual work.
     */
    modifier nonReentrant() {
        // On the first call to nonReentrant, _notEntered will be true
        require(_status != _ENTERED, "ReentrancyGuard: reentrant call");

        // Any calls to nonReentrant after this point will fail
        _status = _ENTERED;

        _;

        // By storing the original value once again, a refund is triggered (see
        // https://eips.ethereum.org/EIPS/eip-2200)
        _status = _NOT_ENTERED;
    }
}

File 7 of 21 : Claimable.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.0;

import "@openzeppelin/contracts/utils/Context.sol";

/**
 * @dev Abstract contract that implements a modified version of  Openzeppelin {Ownable.sol} contract.
 * It creates a two step process for the transfer of ownership.
 */

abstract contract Claimable is Context {
  address private _owner;

  address public pendingOwner;

  // Claimable Events

  /**
   * @dev Emits when step two in ownership transfer is completed.
   */
  event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
  /**
   * @dev Emits when step one in ownership transfer is initiated.
   */
  event NewPendingOwner(address indexed owner);

  /**
   * @dev Initializes the contract setting the deployer as the initial owner.
   */
  constructor() {
    address msgSender = _msgSender();
    _owner = msgSender;
    emit OwnershipTransferred(address(0), msgSender);
  }

  /**
   * @dev Returns the address of the current owner.
   */
  function owner() public view virtual returns (address) {
    return _owner;
  }

  /**
   * @dev Throws if called by any account other than the owner.
   */
  modifier onlyOwner() {
    require(_msgSender() == owner(), "Ownable: caller is not the owner");
    _;
  }

  /**
   * @dev Throws if called by any account other than the pendingOwner.
   */
  modifier onlyPendingOwner() {
    require(_msgSender() == pendingOwner);
    _;
  }

  /**
   * @dev Leaves the contract without owner. It will not be possible to call
   * `onlyOwner` functions anymore. Can only be called by the current owner.
   *
   * NOTE: Renouncing ownership will leave the contract without an owner,
   * thereby removing any functionality that is only available to the owner.
   */
  function renounceOwnership() public virtual onlyOwner {
    emit OwnershipTransferred(owner(), address(0));
    _owner = address(0);
  }

  /**
   * @dev Step one of ownership transfer.
   * Initiates transfer of ownership of the contract to a new account (`newOwner`).
   * Can only be called by the current owner.
   *
   * NOTE:`newOwner` requires to claim ownership in order to be able to call
   * {onlyOwner} modified functions.
   */
  function transferOwnership(address newOwner) public virtual onlyOwner {
    require(newOwner != address(0), "Cannot pass zero address!");
    require(pendingOwner == address(0), "There is a pending owner!");
    pendingOwner = newOwner;
    emit NewPendingOwner(newOwner);
  }

  /**
   * @dev Cancels the transfer of ownership of the contract.
   * Can only be called by the current owner.
   */
  function cancelTransferOwnership() public onlyOwner {
    require(pendingOwner != address(0));
    delete pendingOwner;
    emit NewPendingOwner(address(0));
  }

  /**
   * @dev Step two of ownership transfer.
   * 'pendingOwner' claims ownership of the contract.
   * Can only be called by the pending owner.
   */
  function claimOwnership() public onlyPendingOwner {
    emit OwnershipTransferred(owner(), pendingOwner);
    _owner = pendingOwner;
    delete pendingOwner;
  }
}

File 8 of 21 : IVault.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.0;

interface IVault {
  // Vault Events

  /**
   * @dev Log a deposit transaction done by a user
   */
  event Deposit(address indexed userAddrs, address indexed asset, uint256 amount);
  /**
   * @dev Log a withdraw transaction done by a user
   */
  event Withdraw(address indexed userAddrs, address indexed asset, uint256 amount);
  /**
   * @dev Log a borrow transaction done by a user
   */
  event Borrow(address indexed userAddrs, address indexed asset, uint256 amount);
  /**
   * @dev Log a payback transaction done by a user
   */
  event Payback(address indexed userAddrs, address indexed asset, uint256 amount);
  /**
   * @dev Log a switch from provider to new provider in vault
   */
  event Switch(
    address fromProviderAddrs,
    address toProviderAddr,
    uint256 debtamount,
    uint256 collattamount
  );
  /**
   * @dev Log a change in active provider
   */
  event SetActiveProvider(address newActiveProviderAddress);
  /**
   * @dev Log a change in the array of provider addresses
   */
  event ProvidersChanged(address[] newProviderArray);
  /**
   * @dev Log a change in F1155 address
   */
  event F1155Changed(address newF1155Address);
  /**
   * @dev Log a change in fuji admin address
   */
  event FujiAdminChanged(address newFujiAdmin);
  /**
   * @dev Log a change in the factor values
   */
  event FactorChanged(FactorType factorType, uint64 newFactorA, uint64 newFactorB);
  /**
   * @dev Log a change in the oracle address
   */
  event OracleChanged(address newOracle);

  enum FactorType {
    Safety,
    Collateralization,
    ProtocolFee,
    BonusLiquidation
  }

  struct Factor {
    uint64 a;
    uint64 b;
  }

  // Core Vault Functions

  function deposit(uint256 _collateralAmount) external payable;

  function withdraw(int256 _withdrawAmount) external;

  function withdrawLiq(int256 _withdrawAmount) external;

  function borrow(uint256 _borrowAmount) external;

  function payback(int256 _repayAmount) external payable;

  function paybackLiq(address[] memory _users, uint256 _repayAmount) external payable;

  function executeSwitch(
    address _newProvider,
    uint256 _flashLoanDebt,
    uint256 _fee
  ) external payable;

  //Getter Functions

  function activeProvider() external view returns (address);

  function borrowBalance(address _provider) external view returns (uint256);

  function depositBalance(address _provider) external view returns (uint256);

  function userDebtBalance(address _user) external view returns (uint256);

  function userProtocolFee(address _user) external view returns (uint256);

  function userDepositBalance(address _user) external view returns (uint256);

  function getNeededCollateralFor(uint256 _amount, bool _withFactors)
    external
    view
    returns (uint256);

  function getLiquidationBonusFor(uint256 _amount) external view returns (uint256);

  function getProviders() external view returns (address[] memory);

  function fujiERC1155() external view returns (address);

  //Setter Functions

  function setActiveProvider(address _provider) external;

  function updateF1155Balances() external;

  function protocolFee() external view returns (uint64, uint64);
}

File 9 of 21 : IVaultControl.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.0;

interface IVaultControl {
  struct VaultAssets {
    address collateralAsset;
    address borrowAsset;
    uint64 collateralID;
    uint64 borrowID;
  }

  function vAssets() external view returns (VaultAssets memory);
}

File 10 of 21 : IFujiAdmin.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.0;

interface IFujiAdmin {
  // FujiAdmin Events

  /**
   * @dev Log change of flasher address
   */
  event FlasherChanged(address newFlasher);
  /**
   * @dev Log change of fliquidator address
   */
  event FliquidatorChanged(address newFliquidator);
  /**
   * @dev Log change of treasury address
   */
  event TreasuryChanged(address newTreasury);
  /**
   * @dev Log change of controller address
   */
  event ControllerChanged(address newController);
  /**
   * @dev Log change of vault harvester address
   */
  event VaultHarvesterChanged(address newHarvester);
  /**
   * @dev Log change of swapper address
   */
  event SwapperChanged(address newSwapper);
  /**
   * @dev Log change of vault address permission
   */
  event VaultPermitChanged(address vaultAddress, bool newPermit);

  function validVault(address _vaultAddr) external view returns (bool);

  function getFlasher() external view returns (address);

  function getFliquidator() external view returns (address);

  function getController() external view returns (address);

  function getTreasury() external view returns (address payable);

  function getVaultHarvester() external view returns (address);

  function getSwapper() external view returns (address);
}

File 11 of 21 : IFujiOracle.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.0;

interface IFujiOracle {
  // FujiOracle Events

  /**
   * @dev Log a change in price feed address for asset address
   */
  event AssetPriceFeedChanged(address asset, address newPriceFeedAddress);

  function getPriceOf(
    address _collateralAsset,
    address _borrowAsset,
    uint8 _decimals
  ) external view returns (uint256);
}

File 12 of 21 : IFujiERC1155.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.0;

interface IFujiERC1155 {
  //Asset Types
  enum AssetType {
    //uint8 = 0
    collateralToken,
    //uint8 = 1
    debtToken
  }

  //General Getter Functions

  function getAssetID(AssetType _type, address _assetAddr) external view returns (uint256);

  function qtyOfManagedAssets() external view returns (uint64);

  function balanceOf(address _account, uint256 _id) external view returns (uint256);

  // function splitBalanceOf(address account,uint256 _AssetID) external view  returns (uint256,uint256);

  // function balanceOfBatchType(address account, AssetType _Type) external view returns (uint256);

  //Permit Controlled  Functions
  function mint(
    address _account,
    uint256 _id,
    uint256 _amount
  ) external;

  function burn(
    address _account,
    uint256 _id,
    uint256 _amount
  ) external;

  function updateState(uint256 _assetID, uint256 _newBalance) external;

  function addInitializeAsset(AssetType _type, address _addr) external returns (uint64);
}

File 13 of 21 : IERC20Extended.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

interface IERC20Extended {
  function symbol() external view returns (string memory);

  function decimals() external view returns (uint8);
}

File 14 of 21 : IFlasher.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.0;

import "../libraries/FlashLoans.sol";

interface IFlasher {
  /**
   * @dev Logs a change in FujiAdmin address.
   */
  event FujiAdminChanged(address newFujiAdmin);

  function initiateFlashloan(FlashLoan.Info calldata info, uint8 amount) external;
}

File 15 of 21 : LibUniversalERC20.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.0;

import { IERC20 } from "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import { SafeERC20 } from "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";

library LibUniversalERC20 {
  using SafeERC20 for IERC20;

  IERC20 private constant _NATIVE_ADDRESS = IERC20(0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE);
  IERC20 private constant _ZERO_ADDRESS = IERC20(0x0000000000000000000000000000000000000000);

  function isNative(IERC20 token) internal pure returns (bool) {
    return (token == _ZERO_ADDRESS || token == _NATIVE_ADDRESS);
  }

  function univBalanceOf(IERC20 token, address account) internal view returns (uint256) {
    if (isNative(token)) {
      return account.balance;
    } else {
      return token.balanceOf(account);
    }
  }

  function univTransfer(
    IERC20 token,
    address payable to,
    uint256 amount
  ) internal {
    if (amount > 0) {
      if (isNative(token)) {
        (bool sent, ) = to.call{ value: amount }("");
        require(sent, "Failed to send Native");
      } else {
        token.safeTransfer(to, amount);
      }
    }
  }

  function univApprove(
    IERC20 token,
    address to,
    uint256 amount
  ) internal {
    require(!isNative(token), "Approve called on Native");

    if (amount == 0) {
      token.safeApprove(to, 0);
    } else {
      uint256 allowance = token.allowance(address(this), to);
      if (allowance < amount) {
        if (allowance > 0) {
          token.safeApprove(to, 0);
        }
        token.safeApprove(to, amount);
      }
    }
  }
}

File 16 of 21 : FlashLoans.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.0;

library Account {
  enum Status {
    Normal,
    Liquid,
    Vapor
  }
  struct Info {
    address owner; // The address that owns the account
    uint256 number; // A nonce that allows a single address to control many accounts
  }
}

library Actions {
  enum ActionType {
    Deposit, // supply tokens
    Withdraw, // borrow tokens
    Transfer, // transfer balance between accounts
    Buy, // buy an amount of some token (publicly)
    Sell, // sell an amount of some token (publicly)
    Trade, // trade tokens against another account
    Liquidate, // liquidate an undercollateralized or expiring account
    Vaporize, // use excess tokens to zero-out a completely negative account
    Call // send arbitrary data to an address
  }

  struct ActionArgs {
    ActionType actionType;
    uint256 accountId;
    Types.AssetAmount amount;
    uint256 primaryMarketId;
    uint256 secondaryMarketId;
    address otherAddress;
    uint256 otherAccountId;
    bytes data;
  }
}

library Types {
  enum AssetDenomination {
    Wei, // the amount is denominated in wei
    Par // the amount is denominated in par
  }

  enum AssetReference {
    Delta, // the amount is given as a delta from the current value
    Target // the amount is given as an exact number to end up at
  }

  struct AssetAmount {
    bool sign; // true if positive
    AssetDenomination denomination;
    AssetReference ref;
    uint256 value;
  }
}

library FlashLoan {
  /**
   * @dev Used to determine which vault's function to call post-flashloan:
   * - Switch for executeSwitch(...)
   * - Close for executeFlashClose(...)
   * - Liquidate for executeFlashLiquidation(...)
   * - BatchLiquidate for executeFlashBatchLiquidation(...)
   */
  enum CallType {
    Switch,
    Close,
    BatchLiquidate
  }

  /**
   * @dev Struct of params to be passed between functions executing flashloan logic
   * @param asset: Address of asset to be borrowed with flashloan
   * @param amount: Amount of asset to be borrowed with flashloan
   * @param vault: Vault's address on which the flashloan logic to be executed
   * @param newProvider: New provider's address. Used when callType is Switch
   * @param userAddrs: User's address array Used when callType is BatchLiquidate
   * @param userBals:  Array of user's balances, Used when callType is BatchLiquidate
   * @param userliquidator: The user's address who is  performing liquidation. Used when callType is Liquidate
   * @param fliquidator: Fujis Liquidator's address.
   */
  struct Info {
    CallType callType;
    address asset;
    uint256 amount;
    address vault;
    address newProvider;
    address[] userAddrs;
    uint256[] userBalances;
    address userliquidator;
    address fliquidator;
  }
}

File 17 of 21 : Errors.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

/**
 * @title Errors library
 * @author Fuji
 * @notice Defines the error messages emitted by the different contracts
 * @dev Error messages prefix glossary:
 *  - VL = Validation Logic 100 series
 *  - MATH = Math libraries 200 series
 *  - RF = Refinancing 300 series
 *  - VLT = vault 400 series
 *  - SP = Special 900 series
 */
library Errors {
  //Errors
  string public constant VL_INDEX_OVERFLOW = "100"; // index overflows uint128
  string public constant VL_INVALID_MINT_AMOUNT = "101"; //invalid amount to mint
  string public constant VL_INVALID_BURN_AMOUNT = "102"; //invalid amount to burn
  string public constant VL_AMOUNT_ERROR = "103"; //Input value >0, and for ETH msg.value and amount shall match
  string public constant VL_INVALID_WITHDRAW_AMOUNT = "104"; //Withdraw amount exceeds provided collateral, or falls undercollaterized
  string public constant VL_INVALID_BORROW_AMOUNT = "105"; //Borrow amount does not meet collaterization
  string public constant VL_NO_DEBT_TO_PAYBACK = "106"; //Msg sender has no debt amount to be payback
  string public constant VL_MISSING_ERC20_ALLOWANCE = "107"; //Msg sender has not approved ERC20 full amount to transfer
  string public constant VL_USER_NOT_LIQUIDATABLE = "108"; //User debt position is not liquidatable
  string public constant VL_DEBT_LESS_THAN_AMOUNT = "109"; //User debt is less than amount to partial close
  string public constant VL_PROVIDER_ALREADY_ADDED = "110"; // Provider is already added in Provider Array
  string public constant VL_NOT_AUTHORIZED = "111"; //Not authorized
  string public constant VL_INVALID_COLLATERAL = "112"; //There is no Collateral, or Collateral is not in active in vault
  string public constant VL_NO_ERC20_BALANCE = "113"; //User does not have ERC20 balance
  string public constant VL_INPUT_ERROR = "114"; //Check inputs. For ERC1155 batch functions, array sizes should match.
  string public constant VL_ASSET_EXISTS = "115"; //Asset intended to be added already exists in FujiERC1155
  string public constant VL_ZERO_ADDR_1155 = "116"; //ERC1155: balance/transfer for zero address
  string public constant VL_NOT_A_CONTRACT = "117"; //Address is not a contract.
  string public constant VL_INVALID_ASSETID_1155 = "118"; //ERC1155 Asset ID is invalid.
  string public constant VL_NO_ERC1155_BALANCE = "119"; //ERC1155: insufficient balance for transfer.
  string public constant VL_MISSING_ERC1155_APPROVAL = "120"; //ERC1155: transfer caller is not owner nor approved.
  string public constant VL_RECEIVER_REJECT_1155 = "121"; //ERC1155Receiver rejected tokens
  string public constant VL_RECEIVER_CONTRACT_NON_1155 = "122"; //ERC1155: transfer to non ERC1155Receiver implementer
  string public constant VL_OPTIMIZER_FEE_SMALL = "123"; //Fuji OptimizerFee has to be > 1 RAY (1e27)
  string public constant VL_UNDERCOLLATERIZED_ERROR = "124"; // Flashloan-Flashclose cannot be used when User's collateral is worth less than intended debt position to close.
  string public constant VL_MINIMUM_PAYBACK_ERROR = "125"; // Minimum Amount payback should be at least Fuji Optimizerfee accrued interest.
  string public constant VL_HARVESTING_FAILED = "126"; // Harvesting Function failed, check provided _farmProtocolNum or no claimable balance.
  string public constant VL_FLASHLOAN_FAILED = "127"; // Flashloan failed
  string public constant VL_ERC1155_NOT_TRANSFERABLE = "128"; // ERC1155: Not Transferable
  string public constant VL_SWAP_SLIPPAGE_LIMIT_EXCEED = "129"; // ERC1155: Not Transferable
  string public constant VL_ZERO_ADDR = "130"; // Zero Address
  string public constant VL_INVALID_FLASH_NUMBER = "131"; // invalid flashloan number
  string public constant VL_INVALID_HARVEST_PROTOCOL_NUMBER = "132"; // invalid flashloan number
  string public constant VL_INVALID_HARVEST_TYPE = "133"; // invalid flashloan number
  string public constant VL_INVALID_FACTOR = "134"; // invalid factor
  string public constant VL_INVALID_NEW_PROVIDER ="135"; // invalid newProvider in executeSwitch

  string public constant MATH_DIVISION_BY_ZERO = "201";
  string public constant MATH_ADDITION_OVERFLOW = "202";
  string public constant MATH_MULTIPLICATION_OVERFLOW = "203";

  string public constant RF_INVALID_RATIO_VALUES = "301"; // Ratio Value provided is invalid, _ratioA/_ratioB <= 1, and > 0, or activeProvider borrowBalance = 0
  string public constant RF_INVALID_NEW_ACTIVEPROVIDER = "302"; //Input '_newProvider' and vault's 'activeProvider' must be different

  string public constant VLT_CALLER_MUST_BE_VAULT = "401"; // The caller of this function must be a vault

  string public constant ORACLE_INVALID_LENGTH = "501"; // The assets length and price feeds length doesn't match
  string public constant ORACLE_NONE_PRICE_FEED = "502"; // The price feed is not found
}

File 18 of 21 : IUniswapV2Router01.sol
pragma solidity >=0.6.2;

interface IUniswapV2Router01 {
    function factory() external pure returns (address);
    function WETH() external pure returns (address);

    function addLiquidity(
        address tokenA,
        address tokenB,
        uint amountADesired,
        uint amountBDesired,
        uint amountAMin,
        uint amountBMin,
        address to,
        uint deadline
    ) external returns (uint amountA, uint amountB, uint liquidity);
    function addLiquidityETH(
        address token,
        uint amountTokenDesired,
        uint amountTokenMin,
        uint amountETHMin,
        address to,
        uint deadline
    ) external payable returns (uint amountToken, uint amountETH, uint liquidity);
    function removeLiquidity(
        address tokenA,
        address tokenB,
        uint liquidity,
        uint amountAMin,
        uint amountBMin,
        address to,
        uint deadline
    ) external returns (uint amountA, uint amountB);
    function removeLiquidityETH(
        address token,
        uint liquidity,
        uint amountTokenMin,
        uint amountETHMin,
        address to,
        uint deadline
    ) external returns (uint amountToken, uint amountETH);
    function removeLiquidityWithPermit(
        address tokenA,
        address tokenB,
        uint liquidity,
        uint amountAMin,
        uint amountBMin,
        address to,
        uint deadline,
        bool approveMax, uint8 v, bytes32 r, bytes32 s
    ) external returns (uint amountA, uint amountB);
    function removeLiquidityETHWithPermit(
        address token,
        uint liquidity,
        uint amountTokenMin,
        uint amountETHMin,
        address to,
        uint deadline,
        bool approveMax, uint8 v, bytes32 r, bytes32 s
    ) external returns (uint amountToken, uint amountETH);
    function swapExactTokensForTokens(
        uint amountIn,
        uint amountOutMin,
        address[] calldata path,
        address to,
        uint deadline
    ) external returns (uint[] memory amounts);
    function swapTokensForExactTokens(
        uint amountOut,
        uint amountInMax,
        address[] calldata path,
        address to,
        uint deadline
    ) external returns (uint[] memory amounts);
    function swapExactETHForTokens(uint amountOutMin, address[] calldata path, address to, uint deadline)
        external
        payable
        returns (uint[] memory amounts);
    function swapTokensForExactETH(uint amountOut, uint amountInMax, address[] calldata path, address to, uint deadline)
        external
        returns (uint[] memory amounts);
    function swapExactTokensForETH(uint amountIn, uint amountOutMin, address[] calldata path, address to, uint deadline)
        external
        returns (uint[] memory amounts);
    function swapETHForExactTokens(uint amountOut, address[] calldata path, address to, uint deadline)
        external
        payable
        returns (uint[] memory amounts);

    function quote(uint amountA, uint reserveA, uint reserveB) external pure returns (uint amountB);
    function getAmountOut(uint amountIn, uint reserveIn, uint reserveOut) external pure returns (uint amountOut);
    function getAmountIn(uint amountOut, uint reserveIn, uint reserveOut) external pure returns (uint amountIn);
    function getAmountsOut(uint amountIn, address[] calldata path) external view returns (uint[] memory amounts);
    function getAmountsIn(uint amountOut, address[] calldata path) external view returns (uint[] memory amounts);
}

File 19 of 21 : Address.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.5.0) (utils/Address.sol)

pragma solidity ^0.8.1;

/**
 * @dev Collection of functions related to the address type
 */
library Address {
    /**
     * @dev Returns true if `account` is a contract.
     *
     * [IMPORTANT]
     * ====
     * It is unsafe to assume that an address for which this function returns
     * false is an externally-owned account (EOA) and not a contract.
     *
     * Among others, `isContract` will return false for the following
     * types of addresses:
     *
     *  - an externally-owned account
     *  - a contract in construction
     *  - an address where a contract will be created
     *  - an address where a contract lived, but was destroyed
     * ====
     *
     * [IMPORTANT]
     * ====
     * You shouldn't rely on `isContract` to protect against flash loan attacks!
     *
     * Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets
     * like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract
     * constructor.
     * ====
     */
    function isContract(address account) internal view returns (bool) {
        // This method relies on extcodesize/address.code.length, which returns 0
        // for contracts in construction, since the code is only stored at the end
        // of the constructor execution.

        return account.code.length > 0;
    }

    /**
     * @dev Replacement for Solidity's `transfer`: sends `amount` wei to
     * `recipient`, forwarding all available gas and reverting on errors.
     *
     * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost
     * of certain opcodes, possibly making contracts go over the 2300 gas limit
     * imposed by `transfer`, making them unable to receive funds via
     * `transfer`. {sendValue} removes this limitation.
     *
     * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more].
     *
     * IMPORTANT: because control is transferred to `recipient`, care must be
     * taken to not create reentrancy vulnerabilities. Consider using
     * {ReentrancyGuard} or the
     * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].
     */
    function sendValue(address payable recipient, uint256 amount) internal {
        require(address(this).balance >= amount, "Address: insufficient balance");

        (bool success, ) = recipient.call{value: amount}("");
        require(success, "Address: unable to send value, recipient may have reverted");
    }

    /**
     * @dev Performs a Solidity function call using a low level `call`. A
     * plain `call` is an unsafe replacement for a function call: use this
     * function instead.
     *
     * If `target` reverts with a revert reason, it is bubbled up by this
     * function (like regular Solidity function calls).
     *
     * Returns the raw returned data. To convert to the expected return value,
     * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].
     *
     * Requirements:
     *
     * - `target` must be a contract.
     * - calling `target` with `data` must not revert.
     *
     * _Available since v3.1._
     */
    function functionCall(address target, bytes memory data) internal returns (bytes memory) {
        return functionCall(target, data, "Address: low-level call failed");
    }

    /**
     * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with
     * `errorMessage` as a fallback revert reason when `target` reverts.
     *
     * _Available since v3.1._
     */
    function functionCall(
        address target,
        bytes memory data,
        string memory errorMessage
    ) internal returns (bytes memory) {
        return functionCallWithValue(target, data, 0, errorMessage);
    }

    /**
     * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
     * but also transferring `value` wei to `target`.
     *
     * Requirements:
     *
     * - the calling contract must have an ETH balance of at least `value`.
     * - the called Solidity function must be `payable`.
     *
     * _Available since v3.1._
     */
    function functionCallWithValue(
        address target,
        bytes memory data,
        uint256 value
    ) internal returns (bytes memory) {
        return functionCallWithValue(target, data, value, "Address: low-level call with value failed");
    }

    /**
     * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but
     * with `errorMessage` as a fallback revert reason when `target` reverts.
     *
     * _Available since v3.1._
     */
    function functionCallWithValue(
        address target,
        bytes memory data,
        uint256 value,
        string memory errorMessage
    ) internal returns (bytes memory) {
        require(address(this).balance >= value, "Address: insufficient balance for call");
        require(isContract(target), "Address: call to non-contract");

        (bool success, bytes memory returndata) = target.call{value: value}(data);
        return verifyCallResult(success, returndata, errorMessage);
    }

    /**
     * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
     * but performing a static call.
     *
     * _Available since v3.3._
     */
    function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {
        return functionStaticCall(target, data, "Address: low-level static call failed");
    }

    /**
     * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],
     * but performing a static call.
     *
     * _Available since v3.3._
     */
    function functionStaticCall(
        address target,
        bytes memory data,
        string memory errorMessage
    ) internal view returns (bytes memory) {
        require(isContract(target), "Address: static call to non-contract");

        (bool success, bytes memory returndata) = target.staticcall(data);
        return verifyCallResult(success, returndata, errorMessage);
    }

    /**
     * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
     * but performing a delegate call.
     *
     * _Available since v3.4._
     */
    function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {
        return functionDelegateCall(target, data, "Address: low-level delegate call failed");
    }

    /**
     * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],
     * but performing a delegate call.
     *
     * _Available since v3.4._
     */
    function functionDelegateCall(
        address target,
        bytes memory data,
        string memory errorMessage
    ) internal returns (bytes memory) {
        require(isContract(target), "Address: delegate call to non-contract");

        (bool success, bytes memory returndata) = target.delegatecall(data);
        return verifyCallResult(success, returndata, errorMessage);
    }

    /**
     * @dev Tool to verifies that a low level call was successful, and revert if it wasn't, either by bubbling the
     * revert reason using the provided one.
     *
     * _Available since v4.3._
     */
    function verifyCallResult(
        bool success,
        bytes memory returndata,
        string memory errorMessage
    ) internal pure returns (bytes memory) {
        if (success) {
            return returndata;
        } else {
            // Look for revert reason and bubble it up if present
            if (returndata.length > 0) {
                // The easiest way to bubble the revert reason is using memory via assembly

                assembly {
                    let returndata_size := mload(returndata)
                    revert(add(32, returndata), returndata_size)
                }
            } else {
                revert(errorMessage);
            }
        }
    }
}

File 20 of 21 : IERC165.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (utils/introspection/IERC165.sol)

pragma solidity ^0.8.0;

/**
 * @dev Interface of the ERC165 standard, as defined in the
 * https://eips.ethereum.org/EIPS/eip-165[EIP].
 *
 * Implementers can declare support of contract interfaces, which can then be
 * queried by others ({ERC165Checker}).
 *
 * For an implementation, see {ERC165}.
 */
interface IERC165 {
    /**
     * @dev Returns true if this contract implements the interface defined by
     * `interfaceId`. See the corresponding
     * https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section]
     * to learn more about how these ids are created.
     *
     * This function call must use less than 30 000 gas.
     */
    function supportsInterface(bytes4 interfaceId) external view returns (bool);
}

File 21 of 21 : Context.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (utils/Context.sol)

pragma solidity ^0.8.0;

/**
 * @dev Provides information about the current execution context, including the
 * sender of the transaction and its data. While these are generally available
 * via msg.sender and msg.data, they should not be accessed in such a direct
 * manner, since when dealing with meta-transactions the account sending and
 * paying for execution may not be the actual sender (as far as an application
 * is concerned).
 *
 * This contract is only required for intermediate, library-like contracts.
 */
abstract contract Context {
    function _msgSender() internal view virtual returns (address) {
        return msg.sender;
    }

    function _msgData() internal view virtual returns (bytes calldata) {
        return msg.data;
    }
}

Settings
{
  "optimizer": {
    "enabled": true,
    "runs": 500
  },
  "outputSelection": {
    "*": {
      "*": [
        "evm.bytecode",
        "evm.deployedBytecode",
        "devdoc",
        "userdoc",
        "metadata",
        "abi"
      ]
    }
  },
  "libraries": {}
}

Contract ABI

[{"inputs":[],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"bytes32","name":"typehash","type":"bytes32"},{"indexed":false,"internalType":"uint64","name":"newFactorA","type":"uint64"},{"indexed":false,"internalType":"uint64","name":"newFactorB","type":"uint64"}],"name":"FactorChanged","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"userAddr","type":"address"},{"indexed":true,"internalType":"address","name":"vault","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"FlashClose","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"newFujiAdmin","type":"address"}],"name":"FujiAdminChanged","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"userAddr","type":"address"},{"indexed":true,"internalType":"address","name":"vault","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"},{"indexed":false,"internalType":"address","name":"liquidator","type":"address"}],"name":"Liquidate","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"owner","type":"address"}],"name":"NewPendingOwner","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"newOracle","type":"address"}],"name":"OracleChanged","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"previousOwner","type":"address"},{"indexed":true,"internalType":"address","name":"newOwner","type":"address"}],"name":"OwnershipTransferred","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"newSwapper","type":"address"}],"name":"SwapperChanged","type":"event"},{"inputs":[],"name":"NATIVE","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"SLIPPAGE_LIMIT_DENOMINATOR","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"SLIPPAGE_LIMIT_NUMERATOR","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address[]","name":"_addrs","type":"address[]"},{"internalType":"address","name":"_vault","type":"address"}],"name":"batchLiquidate","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[],"name":"cancelTransferOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"claimOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address[]","name":"_addrs","type":"address[]"},{"internalType":"uint256[]","name":"_borrowBals","type":"uint256[]"},{"internalType":"address","name":"_liquidator","type":"address"},{"internalType":"address","name":"_vault","type":"address"},{"internalType":"uint256","name":"_amount","type":"uint256"},{"internalType":"uint256","name":"_flashloanFee","type":"uint256"}],"name":"executeFlashBatchLiquidation","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"address payable","name":"_userAddr","type":"address"},{"internalType":"address","name":"_vault","type":"address"},{"internalType":"uint256","name":"_amount","type":"uint256"},{"internalType":"uint256","name":"_flashloanFee","type":"uint256"}],"name":"executeFlashClose","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"address[]","name":"_addrs","type":"address[]"},{"internalType":"address","name":"_vault","type":"address"},{"internalType":"uint8","name":"_flashnum","type":"uint8"}],"name":"flashBatchLiquidate","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"int256","name":"_amount","type":"int256"},{"internalType":"address","name":"_vault","type":"address"},{"internalType":"uint8","name":"_flashnum","type":"uint8"}],"name":"flashClose","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"flashCloseF","outputs":[{"internalType":"uint64","name":"a","type":"uint64"},{"internalType":"uint64","name":"b","type":"uint64"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"pendingOwner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"renounceOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint64","name":"_newFactorA","type":"uint64"},{"internalType":"uint64","name":"_newFactorB","type":"uint64"}],"name":"setFlashCloseFee","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_newFujiAdmin","type":"address"}],"name":"setFujiAdmin","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_newFujiOracle","type":"address"}],"name":"setFujiOracle","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_newSwapper","type":"address"}],"name":"setSwapper","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"swapper","outputs":[{"internalType":"contract IUniswapV2Router02","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"stateMutability":"payable","type":"receive"}]

608060405234801561001057600080fd5b50600080546001600160a01b031916339081178255604051909182917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0908290a3506001600255600380546001600160801b03191668640000000000000001179055615013806100816000396000f3fe6080604052600436106101235760003560e01c806392fede00116100a0578063a0cf0aea11610064578063a0cf0aea14610326578063a10364d71461034e578063e30c397814610363578063f2fde38b14610383578063fae5a8f0146103a357600080fd5b806392fede00146102ab57806398e1fdb5146102c05780639c6ce5aa146102e05780639c82f2a4146102f35780639df97b041461031357600080fd5b80635003d4b4116100e75780635003d4b41461021857806356bae45314610238578063715018a6146102585780638da5cb5b1461026d57806391c154321461028b57600080fd5b80630fd9be711461012f5780632b3297f91461018657806339221f50146101be57806346be3413146101e15780634e71e0c81461020357600080fd5b3661012a57005b600080fd5b34801561013b57600080fd5b506003546101609067ffffffffffffffff808216916801000000000000000090041682565b6040805167ffffffffffffffff9384168152929091166020830152015b60405180910390f35b34801561019257600080fd5b506006546101a6906001600160a01b031681565b6040516001600160a01b03909116815260200161017d565b3480156101ca57600080fd5b506101d3600281565b60405190815260200161017d565b3480156101ed57600080fd5b506102016101fc3660046146f9565b6103b6565b005b34801561020f57600080fd5b5061020161049d565b34801561022457600080fd5b5061020161023336600461499d565b610537565b34801561024457600080fd5b506102016102533660046147cb565b610bac565b34801561026457600080fd5b50610201610fc1565b34801561027957600080fd5b506000546001600160a01b03166101a6565b34801561029757600080fd5b506102016102a63660046146f9565b611065565b3480156102b757600080fd5b5061020161113c565b3480156102cc57600080fd5b506102016102db366004614a6f565b6111e8565b6102016102ee366004614831565b6112f9565b3480156102ff57600080fd5b5061020161030e3660046146f9565b6119a2565b610201610321366004614731565b611a79565b34801561033257600080fd5b506101a673eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee81565b34801561035a57600080fd5b506101d3606481565b34801561036f57600080fd5b506001546101a6906001600160a01b031681565b34801561038f57600080fd5b5061020161039e3660046146f9565b612366565b6102016103b1366004614776565b6124b9565b60005460408051808201909152600381526231313160e81b6020820152906001600160a01b031633146104055760405162461bcd60e51b81526004016103fc9190614c19565b60405180910390fd5b5060408051808201909152600381526203133360ec1b60208201526001600160a01b0382166104475760405162461bcd60e51b81526004016103fc9190614c19565b50600580546001600160a01b0319166001600160a01b0383169081179091556040519081527f0e05ae75e8b926552cf6fcd744d19f422561e3ced1e426868730852702dbe418906020015b60405180910390a150565b6001546001600160a01b0316336001600160a01b0316146104bd57600080fd5b6001546001600160a01b03166104db6000546001600160a01b031690565b6001600160a01b03167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a360018054600080546001600160a01b03199081166001600160a01b03841617909155169055565b6002805414156105895760405162461bcd60e51b815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c0060448201526064016103fc565b6002805560048054604051630f6ec81f60e01b81526001600160a01b0380861693820193909352849290911690630f6ec81f9060240160206040518083038186803b1580156105d757600080fd5b505afa1580156105eb573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061060f919061497d565b61064c5760405162461bcd60e51b815260206004820152600e60248201526d496e76616c6964207661756c742160901b60448201526064016103fc565b826001600160a01b03166367ac280a6040518163ffffffff1660e01b8152600401600060405180830381600087803b15801561068757600080fd5b505af115801561069b573d6000803e3d6000fd5b505050506000836001600160a01b031663acb2d4106040518163ffffffff1660e01b815260040160206040518083038186803b1580156106da57600080fd5b505afa1580156106ee573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906107129190614715565b90506000846001600160a01b031663d8df4ce76040518163ffffffff1660e01b815260040160806040518083038186803b15801561074f57600080fd5b505afa158015610763573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061078791906149d3565b6040808201519051627eeac760e11b815233600482015267ffffffffffffffff90911660248201529091506000906001600160a01b0384169062fdd58e9060440160206040518083038186803b1580156107e057600080fd5b505afa1580156107f4573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906108189190614a57565b604051631714decd60e01b81523360048201529091506000906001600160a01b03881690631714decd9060240160206040518083038186803b15801561085d57600080fd5b505afa158015610871573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906108959190614a57565b9050600081116040518060400160405280600381526020016218981b60e91b815250906108d55760405162461bcd60e51b81526004016103fc9190614c19565b5060008089126108e557886108e7565b815b60405163486bdfd760e11b8152600481018290526000602482018190529192506001600160a01b038a16906390d7bfae9060440160206040518083038186803b15801561093357600080fd5b505afa158015610947573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061096b9190614a57565b905080841015604051806040016040528060038152602001620c4c8d60ea1b815250906109ab5760405162461bcd60e51b81526004016103fc9190614c19565b506040805160018082528183019092526000916020808301908036833701905050905033816000815181106109f057634e487b7160e01b600052603260045260246000fd5b6001600160a01b0390921660209283029190910190910152604080516101208101909152600090806001815260200188602001516001600160a01b031681526020018581526020018c6001600160a01b0316815260200160006001600160a01b03168152602001838152602001600067ffffffffffffffff811115610a8557634e487b7160e01b600052604160045260246000fd5b604051908082528060200260200182016040528015610aae578160200160208202803683370190505b508152600060208083019190915230604092830152600480548351637fabc90b60e01b815293519495506001600160a01b031693637fabc90b93808301939290829003018186803b158015610b0257600080fd5b505afa158015610b16573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610b3a9190614715565b6001600160a01b0316635ccd808c828c6040518363ffffffff1660e01b8152600401610b67929190614c4c565b600060405180830381600087803b158015610b8157600080fd5b505af1158015610b95573d6000803e3d6000fd5b505060016002555050505050505050505050505050565b60048054604051630f6ec81f60e01b81526001600160a01b0380861693820193909352849290911690630f6ec81f9060240160206040518083038186803b158015610bf657600080fd5b505afa158015610c0a573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610c2e919061497d565b610c6b5760405162461bcd60e51b815260206004820152600e60248201526d496e76616c6964207661756c742160901b60448201526064016103fc565b600280541415610cbd5760405162461bcd60e51b815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c0060448201526064016103fc565b600280819055506000836001600160a01b031663d8df4ce76040518163ffffffff1660e01b815260040160806040518083038186803b158015610cff57600080fd5b505afa158015610d13573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610d3791906149d3565b90506000846001600160a01b031663acb2d4106040518163ffffffff1660e01b815260040160206040518083038186803b158015610d7457600080fd5b505afa158015610d88573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610dac9190614715565b9050846001600160a01b03166367ac280a6040518163ffffffff1660e01b8152600401600060405180830381600087803b158015610de957600080fd5b505af1158015610dfd573d6000803e3d6000fd5b505050506000806000610e478a8a808060200260200160405190810160405280939291908181526020018383602002808284376000920191909152508992508c9150889050612bcf565b925092509250600081116040518060400160405280600381526020016206260760eb1b81525090610e8b5760405162461bcd60e51b81526004016103fc9190614c19565b506040805161012081018252600281526020878101516001600160a01b03908116828401528284018590528b811660608401526000608084015260a0830187905260c083018690523360e084015230610100840152600480548551637fabc90b60e01b815295519495921693637fabc90b9383830193909290829003018186803b158015610f1857600080fd5b505afa158015610f2c573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610f509190614715565b6001600160a01b0316635ccd808c828a6040518363ffffffff1660e01b8152600401610f7d929190614c4c565b600060405180830381600087803b158015610f9757600080fd5b505af1158015610fab573d6000803e3d6000fd5b5050600160025550505050505050505050505050565b6000546001600160a01b0316331461101b5760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657260448201526064016103fc565b600080546040516001600160a01b03909116907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0908390a3600080546001600160a01b0319169055565b60005460408051808201909152600381526231313160e81b6020820152906001600160a01b031633146110ab5760405162461bcd60e51b81526004016103fc9190614c19565b5060408051808201909152600381526203133360ec1b60208201526001600160a01b0382166110ed5760405162461bcd60e51b81526004016103fc9190614c19565b50600480546001600160a01b0319166001600160a01b0383169081179091556040519081527fa05e64ea7e34b372177317c71229808e25bdbfe5dc3e6bc4fc7ca66c97d9327690602001610492565b6000546001600160a01b031633146111965760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657260448201526064016103fc565b6001546001600160a01b03166111ab57600080fd5b600180546001600160a01b03191690556040516000907f69737d41162474a7ca514809b07d7becaecf72eae8c23bceb071f0e09af93ffc908290a2565b60005460408051808201909152600381526231313160e81b6020820152906001600160a01b0316331461122e5760405162461bcd60e51b81526004016103fc9190614c19565b506003805467ffffffffffffffff83811668010000000000000000026fffffffffffffffffffffffffffffffff19909216908516171790556040517f4e0575b6657dd07a883013977eb34af3deab3528c640a26ce02097f5351e8b7f906112b7906020016020808252600b908201526a333630b9b421b637b9b2a360a91b604082015260600190565b60408051601f198184030181528282528051602091820120835267ffffffffffffffff8087169184019190915284169082015260600160405180910390a15050565b6004805460408051637fabc90b60e01b815290516001600160a01b0390921692637fabc90b928282019260209290829003018186803b15801561133b57600080fd5b505afa15801561134f573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906113739190614715565b6001600160a01b0316336001600160a01b0316146040518060400160405280600381526020016231313160e81b815250906113c15760405162461bcd60e51b81526004016103fc9190614c19565b506000836001600160a01b031663acb2d4106040518163ffffffff1660e01b815260040160206040518083038186803b1580156113fd57600080fd5b505afa158015611411573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906114359190614715565b90506000846001600160a01b031663d8df4ce76040518163ffffffff1660e01b815260040160806040518083038186803b15801561147257600080fd5b505afa158015611486573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906114aa91906149d3565b9050600073eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee6001600160a01b031682602001516001600160a01b0316146114e65760006114e8565b845b9050856001600160a01b031663e5aa6d05828d8d896040518563ffffffff1660e01b815260040161151b93929190614b73565b6000604051808303818588803b15801561153457600080fd5b505af1158015611548573d6000803e3d6000fd5b505060405163e897effb60e01b815260048101899052600093506001600160a01b038a16925063e897effb915060240160206040518083038186803b15801561159057600080fd5b505afa1580156115a4573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906115c89190614a57565b905060006115f58460000151856020015184898b6115e69190614def565b6115f09190614def565b613122565b905061167a8d8d80806020026020016040519081016040528093929190818152602001838360200280828437600081840152601f19601f820116905080830192505050505050508c8c808060200260200160405190810160405280939291908181526020018383602002808284376000920191909152508992508d91508a9050613505565b60405162197ac760e01b8152600481018290526001600160a01b0389169062197ac790602401600060405180830381600087803b1580156116ba57600080fd5b505af11580156116ce573d6000803e3d6000fd5b5050855160208701516116fc9350909150846116ea8a8c614def565b6116f49190614def565b8460016137df565b506117a5600460009054906101000a90046001600160a01b03166001600160a01b0316637fabc90b6040518163ffffffff1660e01b815260040160206040518083038186803b15801561174e57600080fd5b505afa158015611762573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906117869190614715565b611790888a614def565b60208701516001600160a01b03169190614045565b60006117b2600584614e07565b90506117d78a6117c28386614f31565b60208801516001600160a01b03169190614045565b611875600460009054906101000a90046001600160a01b03166001600160a01b0316633b19e84a6040518163ffffffff1660e01b815260040160206040518083038186803b15801561182857600080fd5b505afa15801561183c573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906118609190614715565b60208701516001600160a01b03169083614045565b60005b8d8110156119915760008f8f838181106118a257634e487b7160e01b600052603260045260246000fd5b90506020020160208101906118b791906146f9565b6001600160a01b03161461197f57896001600160a01b03168f8f838181106118ef57634e487b7160e01b600052603260045260246000fd5b905060200201602081019061190491906146f9565b6001600160a01b03167f60b8242c7715592d395c118b86e1c56e483030f45fab92e8694eda9f1a837f5e8f8f8581811061194e57634e487b7160e01b600052603260045260246000fd5b905060200201358e6040516119769291909182526001600160a01b0316602082015260400190565b60405180910390a35b61198a600182614def565b9050611878565b505050505050505050505050505050565b60005460408051808201909152600381526231313160e81b6020820152906001600160a01b031633146119e85760405162461bcd60e51b81526004016103fc9190614c19565b5060408051808201909152600381526203133360ec1b60208201526001600160a01b038216611a2a5760405162461bcd60e51b81526004016103fc9190614c19565b50600680546001600160a01b0319166001600160a01b0383169081179091556040519081527f7d7719313229e558c5a3893cad2eb86a86a049156d1d9ebd5c63a8eedefd1c0390602001610492565b6004805460408051637fabc90b60e01b815290516001600160a01b0390921692637fabc90b928282019260209290829003018186803b158015611abb57600080fd5b505afa158015611acf573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611af39190614715565b6001600160a01b0316336001600160a01b0316146040518060400160405280600381526020016231313160e81b81525090611b415760405162461bcd60e51b81526004016103fc9190614c19565b506000836001600160a01b031663acb2d4106040518163ffffffff1660e01b815260040160206040518083038186803b158015611b7d57600080fd5b505afa158015611b91573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611bb59190614715565b90506000846001600160a01b031663d8df4ce76040518163ffffffff1660e01b815260040160806040518083038186803b158015611bf257600080fd5b505afa158015611c06573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611c2a91906149d3565b60035490915060009067ffffffffffffffff680100000000000000008204811691611c56911687614f12565b611c609190614e07565b604051636fb1b05360e11b81526001600160a01b03898116600483015291925060009188169063df6360a69060240160206040518083038186803b158015611ca757600080fd5b505afa158015611cbb573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611cdf9190614a57565b6060840151604051627eeac760e11b81526001600160a01b038b8116600483015267ffffffffffffffff9092166024820152919250600091839187169062fdd58e9060440160206040518083038186803b158015611d3c57600080fd5b505afa158015611d50573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611d749190614a57565b611d7e9190614def565b90506000611d9c85600001518660200151868a8c6115e69190614def565b9050600073eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee6001600160a01b031686602001516001600160a01b031614611dd8576000611dda565b885b60408051600180825281830190925291925060009190602080830190803683370190505090508b81600081518110611e2257634e487b7160e01b600052603260045260246000fd5b6001600160a01b03928316602091820292909201015260405163e5aa6d0560e01b8152908c169063e5aa6d05908490611e619085908f90600401614bf7565b6000604051808303818588803b158015611e7a57600080fd5b505af1158015611e8e573d6000803e3d6000fd5b5050505050838a1415612039576040808801519051627eeac760e11b81526001600160a01b038e8116600483015267ffffffffffffffff90921660248201526000918a169062fdd58e9060440160206040518083038186803b158015611ef357600080fd5b505afa158015611f07573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611f2b9190614a57565b9050886001600160a01b031663f5298aca8e8a60400151846040518463ffffffff1660e01b8152600401611f87939291906001600160a01b0393909316835267ffffffffffffffff919091166020830152604082015260600190565b600060405180830381600087803b158015611fa157600080fd5b505af1158015611fb5573d6000803e3d6000fd5b505060405162197ac760e01b8152600481018490526001600160a01b038f16925062197ac79150602401600060405180830381600087803b158015611ff957600080fd5b505af115801561200d573d6000803e3d6000fd5b505050506120338d85836120219190614f31565b8a516001600160a01b03169190614045565b5061210b565b6040808801519051637a94c56560e11b81526001600160a01b038e8116600483015267ffffffffffffffff9092166024820152604481018590529089169063f5298aca90606401600060405180830381600087803b15801561209a57600080fd5b505af11580156120ae573d6000803e3d6000fd5b505060405162197ac760e01b8152600481018690526001600160a01b038e16925062197ac79150602401600060405180830381600087803b1580156120f257600080fd5b505af1158015612106573d6000803e3d6000fd5b505050505b865160208801516121349190886121228d8f614def565b61212c9190614def565b8660006137df565b506121d3600460009054906101000a90046001600160a01b03166001600160a01b0316633b19e84a6040518163ffffffff1660e01b815260040160206040518083038186803b15801561218657600080fd5b505afa15801561219a573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906121be9190614715565b60208901516001600160a01b03169088614045565b61227b600460009054906101000a90046001600160a01b03166001600160a01b0316637fabc90b6040518163ffffffff1660e01b815260040160206040518083038186803b15801561222457600080fd5b505afa158015612238573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061225c9190614715565b6122668b8d614def565b60208a01516001600160a01b03169190614045565b876001600160a01b031663f5298aca8d8960600151888e61229c9190614f31565b6040516001600160e01b031960e086901b1681526001600160a01b03909316600484015267ffffffffffffffff90911660248301526044820152606401600060405180830381600087803b1580156122f357600080fd5b505af1158015612307573d6000803e3d6000fd5b505050508a6001600160a01b03168c6001600160a01b03167f3eeeaba10d85fe3ba0708f01d644ff55bbdf227dd736ce68eba30cd119514c128c60405161235091815260200190565b60405180910390a3505050505050505050505050565b6000546001600160a01b031633146123c05760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657260448201526064016103fc565b6001600160a01b0381166124165760405162461bcd60e51b815260206004820152601960248201527f43616e6e6f742070617373207a65726f2061646472657373210000000000000060448201526064016103fc565b6001546001600160a01b03161561246f5760405162461bcd60e51b815260206004820152601960248201527f546865726520697320612070656e64696e67206f776e6572210000000000000060448201526064016103fc565b600180546001600160a01b0319166001600160a01b0383169081179091556040517f69737d41162474a7ca514809b07d7becaecf72eae8c23bceb071f0e09af93ffc90600090a250565b60028054141561250b5760405162461bcd60e51b815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c0060448201526064016103fc565b6002805560048054604051630f6ec81f60e01b81526001600160a01b0380851693820193909352839290911690630f6ec81f9060240160206040518083038186803b15801561255957600080fd5b505afa15801561256d573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612591919061497d565b6125ce5760405162461bcd60e51b815260206004820152600e60248201526d496e76616c6964207661756c742160901b60448201526064016103fc565b6000826001600160a01b031663d8df4ce76040518163ffffffff1660e01b815260040160806040518083038186803b15801561260957600080fd5b505afa15801561261d573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061264191906149d3565b90506000836001600160a01b031663acb2d4106040518163ffffffff1660e01b815260040160206040518083038186803b15801561267e57600080fd5b505afa158015612692573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906126b69190614715565b9050836001600160a01b03166367ac280a6040518163ffffffff1660e01b8152600401600060405180830381600087803b1580156126f357600080fd5b505af1158015612707573d6000803e3d6000fd5b5050505060008060006127518989808060200260200160405190810160405280939291908181526020018383602002808284376000920191909152508992508b9150889050612bcf565b925092509250600081116040518060400160405280600381526020016206260760eb1b815250906127955760405162461bcd60e51b81526004016103fc9190614c19565b5060208501516001600160a01b031673eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee141561280357803410156040518060400160405280600381526020016231303360e81b815250906127fd5760405162461bcd60e51b81526004016103fc9190614c19565b506128dd565b6020850151604051636eb1769f60e11b815233600482015230602482015282916001600160a01b03169063dd62ed3e9060440160206040518083038186803b15801561284e57600080fd5b505afa158015612862573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906128869190614a57565b10156040518060400160405280600381526020016231303760e81b815250906128c25760405162461bcd60e51b81526004016103fc9190614c19565b5060208501516128dd906001600160a01b031633898461411b565b60208501516000906001600160a01b031673eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee1461290f576000612911565b815b9050876001600160a01b031663e5aa6d058286856040518463ffffffff1660e01b8152600401612942929190614bf7565b6000604051808303818588803b15801561295b57600080fd5b505af115801561296f573d6000803e3d6000fd5b505060405163e897effb60e01b815260048101869052600093506001600160a01b038c16925063e897effb915060240160206040518083038186803b1580156129b757600080fd5b505afa1580156129cb573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906129ef9190614a57565b90506000612a0c8860000151896020015184876115f09190614def565b9050612a1b86868a8d8b613505565b60405162197ac760e01b8152600481018290526001600160a01b038b169062197ac790602401600060405180830381600087803b158015612a5b57600080fd5b505af1158015612a6f573d6000803e3d6000fd5b5050895160208b0151612a8a93509091506116f48588614def565b50612aae33612a998487614def565b60208b01516001600160a01b03169190614045565b60005b8651811015612bbb5760006001600160a01b0316878281518110612ae557634e487b7160e01b600052603260045260246000fd5b60200260200101516001600160a01b031614612ba9578a6001600160a01b0316878281518110612b2557634e487b7160e01b600052603260045260246000fd5b60200260200101516001600160a01b03167f60b8242c7715592d395c118b86e1c56e483030f45fab92e8694eda9f1a837f5e888481518110612b7757634e487b7160e01b600052603260045260246000fd5b602002602001015133604051612ba09291909182526001600160a01b0316602082015260400190565b60405180910390a35b612bb4600182614def565b9050612ab1565b505060016002555050505050505050505050565b6060806000865167ffffffffffffffff811115612bfc57634e487b7160e01b600052604160045260246000fd5b604051908082528060200260200182016040528015612c25578160200160208202803683370190505b5092506000875167ffffffffffffffff811115612c5257634e487b7160e01b600052604160045260246000fd5b604051908082528060200260200182016040528015612c7b578160200160208202803683370190505b5090506000885167ffffffffffffffff811115612ca857634e487b7160e01b600052604160045260246000fd5b604051908082528060200260200182016040528015612cd1578160200160208202803683370190505b50905060005b8951811015612d6757886040015167ffffffffffffffff16828281518110612d0f57634e487b7160e01b600052603260045260246000fd5b602002602001018181525050886060015167ffffffffffffffff16838281518110612d4a57634e487b7160e01b600052603260045260246000fd5b6020908102919091010152612d60600182614def565b9050612cd7565b506040516313849cfd60e21b81526001600160a01b03871690634e1273f490612d96908c908690600401614bc9565b60006040518083038186803b158015612dae57600080fd5b505afa158015612dc2573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f19168201604052612dea91908101906148d5565b93506000866001600160a01b0316634e1273f48b846040518363ffffffff1660e01b8152600401612e1c929190614bc9565b60006040518083038186803b158015612e3457600080fd5b505afa158015612e48573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f19168201604052612e7091908101906148d5565b90506000805b8b5181101561311357896001600160a01b03166390d7bfae888381518110612eae57634e487b7160e01b600052603260045260246000fd5b602002602001015160016040518363ffffffff1660e01b8152600401612ee09291909182521515602082015260400190565b60206040518083038186803b158015612ef857600080fd5b505afa158015612f0c573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612f309190614a57565b915081838281518110612f5357634e487b7160e01b600052603260045260246000fd5b602002602001015110156130be578b8181518110612f8157634e487b7160e01b600052603260045260246000fd5b6020026020010151888281518110612fa957634e487b7160e01b600052603260045260246000fd5b60200260200101906001600160a01b031690816001600160a01b031681525050896001600160a01b031663df6360a6898381518110612ff857634e487b7160e01b600052603260045260246000fd5b60200260200101516040518263ffffffff1660e01b815260040161302b91906001600160a01b0391909116815260200190565b60206040518083038186803b15801561304357600080fd5b505afa158015613057573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061307b9190614a57565b87828151811061309b57634e487b7160e01b600052603260045260246000fd5b60200260200101516130ad9190614def565b6130b79087614def565b9550613101565b60008882815181106130e057634e487b7160e01b600052603260045260246000fd5b60200260200101906001600160a01b031690816001600160a01b0316815250505b61310c600182614def565b9050612e76565b50505050509450945094915050565b600080600660009054906101000a90046001600160a01b03166001600160a01b031663ad5c46486040518163ffffffff1660e01b815260040160206040518083038186803b15801561317357600080fd5b505afa158015613187573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906131ab9190614715565b905060606001600160a01b03861673eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee14806131eb5750816001600160a01b0316866001600160a01b0316145b15613299576040805160028082526060820183529091602083019080368337019050509050818160008151811061323257634e487b7160e01b600052603260045260246000fd5b60200260200101906001600160a01b031690816001600160a01b031681525050848160018151811061327457634e487b7160e01b600052603260045260246000fd5b60200260200101906001600160a01b031690816001600160a01b031681525050613446565b6001600160a01b03851673eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee14806132d55750816001600160a01b0316856001600160a01b0316145b1561335e576040805160028082526060820183529091602083019080368337019050509050858160008151811061331c57634e487b7160e01b600052603260045260246000fd5b60200260200101906001600160a01b031690816001600160a01b031681525050818160018151811061327457634e487b7160e01b600052603260045260246000fd5b60408051600380825260808201909252906020820160608036833701905050905085816000815181106133a157634e487b7160e01b600052603260045260246000fd5b60200260200101906001600160a01b031690816001600160a01b03168152505081816001815181106133e357634e487b7160e01b600052603260045260246000fd5b60200260200101906001600160a01b031690816001600160a01b031681525050848160028151811061342557634e487b7160e01b600052603260045260246000fd5b60200260200101906001600160a01b031690816001600160a01b0316815250505b6006546040516307c0329d60e21b81526000916001600160a01b031690631f00ca74906134799088908690600401614d34565b60006040518083038186803b15801561349157600080fd5b505afa1580156134a5573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f191682016040526134cd91908101906148d5565b9050806000815181106134f057634e487b7160e01b600052603260045260246000fd5b602002602001015193505050505b9392505050565b60008060005b87518110156137d55760006001600160a01b031688828151811061353f57634e487b7160e01b600052603260045260246000fd5b60200260200101516001600160a01b0316146137c357846001600160a01b031663e897effb88838151811061358457634e487b7160e01b600052603260045260246000fd5b60200260200101516040518263ffffffff1660e01b81526004016135aa91815260200190565b60206040518083038186803b1580156135c257600080fd5b505afa1580156135d6573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906135fa9190614a57565b925061363c86600001518760200151858a858151811061362a57634e487b7160e01b600052603260045260246000fd5b60200260200101516115f09190614def565b9150836001600160a01b031663f5298aca89838151811061366d57634e487b7160e01b600052603260045260246000fd5b602002602001015188606001518a858151811061369a57634e487b7160e01b600052603260045260246000fd5b60209081029190910101516040516001600160e01b031960e086901b1681526001600160a01b03909316600484015267ffffffffffffffff90911660248301526044820152606401600060405180830381600087803b1580156136fc57600080fd5b505af1158015613710573d6000803e3d6000fd5b50505050836001600160a01b031663f5298aca89838151811061374357634e487b7160e01b600052603260045260246000fd5b60209081029190910101516040808a015190516001600160e01b031960e085901b1681526001600160a01b03909216600483015267ffffffffffffffff16602482015260448101859052606401600060405180830381600087803b1580156137aa57600080fd5b505af11580156137be573d6000803e3d6000fd5b505050505b6137ce600182614def565b905061350b565b5050505050505050565b60008115613a66576000806001600160a01b03881673eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee1415613818576012915061388c565b876001600160a01b031663313ce5676040518163ffffffff1660e01b815260040160206040518083038186803b15801561385157600080fd5b505afa158015613865573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906138899190614aa7565b91505b6001600160a01b03871673eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee14156138b95750601261392d565b866001600160a01b031663313ce5676040518163ffffffff1660e01b815260040160206040518083038186803b1580156138f257600080fd5b505afa158015613906573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061392a9190614aa7565b90505b60008661393e60ff8416600a614e6a565b6139489088614f12565b6139529190614e07565b60055460405163721adea760e01b81526001600160a01b038c811660048301528b8116602483015260ff871660448301529293506000929091169063721adea79060640160206040518083038186803b1580156139ae57600080fd5b505afa1580156139c2573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906139e69190614a57565b90506000818311613a00576139fb8383614f31565b613a0a565b613a0a8284614f31565b9050600282613a1a606484614f12565b613a249190614e07565b106040518060400160405280600381526020016231323960e81b81525090613a5f5760405162461bcd60e51b81526004016103fc9190614c19565b5050505050505b600654604080516315ab88c960e31b815290516000926001600160a01b03169163ad5c4648916004808301926020929190829003018186803b158015613aab57600080fd5b505afa158015613abf573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613ae39190614715565b90506060806001600160a01b03891673eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee1415613c335760408051600280825260608201835290916020830190803683370190505091508282600081518110613b4f57634e487b7160e01b600052603260045260246000fd5b60200260200101906001600160a01b031690816001600160a01b0316815250508782600181518110613b9157634e487b7160e01b600052603260045260246000fd5b6001600160a01b03928316602091820292909201015260065460405163fb3bdb4160e01b815291169063fb3bdb41908890613bd6908b90879030904290600401614d4d565b6000604051808303818588803b158015613bef57600080fd5b505af1158015613c03573d6000803e3d6000fd5b50505050506040513d6000823e601f3d908101601f19168201604052613c2c91908101906148d5565b9050614004565b6001600160a01b03881673eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee1415613d925760408051600280825260608201835290916020830190803683370190505091508882600081518110613c9a57634e487b7160e01b600052603260045260246000fd5b60200260200101906001600160a01b031690816001600160a01b0316815250508282600181518110613cdc57634e487b7160e01b600052603260045260246000fd5b6001600160a01b039283166020918202929092010152600654613d04918b811691168861419b565b600654604051632512eca560e11b81526001600160a01b0390911690634a25d94a90613d3c908a908a90879030904290600401614d82565b600060405180830381600087803b158015613d5657600080fd5b505af1158015613d6a573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f19168201604052613c2c91908101906148d5565b826001600160a01b0316896001600160a01b03161480613dc35750826001600160a01b0316886001600160a01b0316145b15613e715760408051600280825260608201835290916020830190803683370190505091508882600081518110613e0a57634e487b7160e01b600052603260045260246000fd5b60200260200101906001600160a01b031690816001600160a01b0316815250508782600181518110613e4c57634e487b7160e01b600052603260045260246000fd5b60200260200101906001600160a01b031690816001600160a01b031681525050613f59565b6040805160038082526080820190925290602082016060803683370190505091508882600081518110613eb457634e487b7160e01b600052603260045260246000fd5b60200260200101906001600160a01b031690816001600160a01b0316815250508282600181518110613ef657634e487b7160e01b600052603260045260246000fd5b60200260200101906001600160a01b031690816001600160a01b0316815250508782600281518110613f3857634e487b7160e01b600052603260045260246000fd5b60200260200101906001600160a01b031690816001600160a01b0316815250505b600654613f73906001600160a01b038b811691168861419b565b600654604051634401edf760e11b81526001600160a01b0390911690638803dbee90613fab908a908a90879030904290600401614d82565b600060405180830381600087803b158015613fc557600080fd5b505af1158015613fd9573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f1916820160405261400191908101906148d5565b90505b8060008151811061402557634e487b7160e01b600052603260045260246000fd5b6020026020010151866140389190614f31565b9998505050505050505050565b801561411657614054836142c7565b15614102576000826001600160a01b03168260405160006040518083038185875af1925050503d80600081146140a6576040519150601f19603f3d011682016040523d82523d6000602084013e6140ab565b606091505b50509050806140fc5760405162461bcd60e51b815260206004820152601560248201527f4661696c656420746f2073656e64204e6174697665000000000000000000000060448201526064016103fc565b50505050565b6141166001600160a01b0384168383614301565b505050565b6040516001600160a01b03808516602483015283166044820152606481018290526140fc9085906323b872dd60e01b906084015b60408051601f198184030181529190526020810180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff166001600160e01b031990931692909217909152614331565b6141a4836142c7565b156141f15760405162461bcd60e51b815260206004820152601860248201527f417070726f76652063616c6c6564206f6e204e6174697665000000000000000060448201526064016103fc565b8061420b576141166001600160a01b038416836000614403565b604051636eb1769f60e11b81523060048201526001600160a01b0383811660248301526000919085169063dd62ed3e9060440160206040518083038186803b15801561425657600080fd5b505afa15801561426a573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061428e9190614a57565b9050818110156140fc5780156142b3576142b36001600160a01b038516846000614403565b6140fc6001600160a01b0385168484614403565b60006001600160a01b03821615806142fb57506001600160a01b03821673eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee145b92915050565b6040516001600160a01b03831660248201526044810182905261411690849063a9059cbb60e01b9060640161414f565b6000614386826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b031661452e9092919063ffffffff16565b80519091501561411657808060200190518101906143a4919061497d565b6141165760405162461bcd60e51b815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e6044820152691bdd081cdd58d8d9595960b21b60648201526084016103fc565b80158061448c5750604051636eb1769f60e11b81523060048201526001600160a01b03838116602483015284169063dd62ed3e9060440160206040518083038186803b15801561445257600080fd5b505afa158015614466573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061448a9190614a57565b155b6144fe5760405162461bcd60e51b815260206004820152603660248201527f5361666545524332303a20617070726f76652066726f6d206e6f6e2d7a65726f60448201527f20746f206e6f6e2d7a65726f20616c6c6f77616e63650000000000000000000060648201526084016103fc565b6040516001600160a01b03831660248201526044810182905261411690849063095ea7b360e01b9060640161414f565b606061453d8484600085614545565b949350505050565b6060824710156145a65760405162461bcd60e51b815260206004820152602660248201527f416464726573733a20696e73756666696369656e742062616c616e636520666f6044820152651c8818d85b1b60d21b60648201526084016103fc565b6001600160a01b0385163b6145fd5760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e747261637400000060448201526064016103fc565b600080866001600160a01b031685876040516146199190614b57565b60006040518083038185875af1925050503d8060008114614656576040519150601f19603f3d011682016040523d82523d6000602084013e61465b565b606091505b509150915061466b828286614676565b979650505050505050565b606083156146855750816134fe565b8251156146955782518084602001fd5b8160405162461bcd60e51b81526004016103fc9190614c19565b60008083601f8401126146c0578182fd5b50813567ffffffffffffffff8111156146d7578182fd5b6020830191508360208260051b85010111156146f257600080fd5b9250929050565b60006020828403121561470a578081fd5b81356134fe81614fa0565b600060208284031215614726578081fd5b81516134fe81614fa0565b60008060008060808587031215614746578283fd5b843561475181614fa0565b9350602085013561476181614fa0565b93969395505050506040820135916060013590565b60008060006040848603121561478a578283fd5b833567ffffffffffffffff8111156147a0578384fd5b6147ac868287016146af565b90945092505060208401356147c081614fa0565b809150509250925092565b600080600080606085870312156147e0578384fd5b843567ffffffffffffffff8111156147f6578485fd5b614802878288016146af565b909550935050602085013561481681614fa0565b9150604085013561482681614fce565b939692955090935050565b60008060008060008060008060c0898b03121561484c578384fd5b883567ffffffffffffffff80821115614863578586fd5b61486f8c838d016146af565b909a50985060208b0135915080821115614887578586fd5b506148948b828c016146af565b90975095505060408901356148a881614fa0565b935060608901356148b881614fa0565b979a969950949793969295929450505060808201359160a0013590565b600060208083850312156148e7578182fd5b825167ffffffffffffffff808211156148fe578384fd5b818501915085601f830112614911578384fd5b81518181111561492357614923614f8a565b8060051b9150614934848301614dbe565b8181528481019084860184860187018a101561494e578788fd5b8795505b83861015614970578051835260019590950194918601918601614952565b5098975050505050505050565b60006020828403121561498e578081fd5b815180151581146134fe578182fd5b6000806000606084860312156149b1578081fd5b8335925060208401356149c381614fa0565b915060408401356147c081614fce565b6000608082840312156149e4578081fd5b6040516080810181811067ffffffffffffffff82111715614a0757614a07614f8a565b6040528251614a1581614fa0565b81526020830151614a2581614fa0565b60208201526040830151614a3881614fb8565b60408201526060830151614a4b81614fb8565b60608201529392505050565b600060208284031215614a68578081fd5b5051919050565b60008060408385031215614a81578182fd5b8235614a8c81614fb8565b91506020830135614a9c81614fb8565b809150509250929050565b600060208284031215614ab8578081fd5b81516134fe81614fce565b6000815180845260208085019450808401835b83811015614afb5781516001600160a01b031687529582019590820190600101614ad6565b509495945050505050565b6000815180845260208085019450808401835b83811015614afb57815187529582019590820190600101614b19565b60038110614b5357634e487b7160e01b600052602160045260246000fd5b9052565b60008251614b69818460208701614f48565b9190910192915050565b6040808252810183905260008460608301825b86811015614bb6578235614b9981614fa0565b6001600160a01b0316825260209283019290910190600101614b86565b5060209390930193909352509392505050565b604081526000614bdc6040830185614ac3565b8281036020840152614bee8185614b06565b95945050505050565b604081526000614c0a6040830185614ac3565b90508260208301529392505050565b6020815260008251806020840152614c38816040850160208701614f48565b601f01601f19169190910160400192915050565b60408152614c5e604082018451614b35565b60006020840151614c7a60608401826001600160a01b03169052565b506040840151608083015260608401516001600160a01b03811660a08401525060808401516001600160a01b03811660c08401525060a08401516101208060e0850152614ccb610160850183614ac3565b915060c0860151610100603f198685030181870152614cea8483614b06565b935060e08801519150614d07838701836001600160a01b03169052565b8701516001600160a01b0381166101408701529150614d239050565b5060ff8416602084015290506134fe565b82815260406020820152600061453d6040830184614ac3565b848152608060208201526000614d666080830186614ac3565b6001600160a01b03949094166040830152506060015292915050565b85815284602082015260a060408201526000614da160a0830186614ac3565b6001600160a01b0394909416606083015250608001529392505050565b604051601f8201601f1916810167ffffffffffffffff81118282101715614de757614de7614f8a565b604052919050565b60008219821115614e0257614e02614f74565b500190565b600082614e2257634e487b7160e01b81526012600452602481fd5b500490565b600181815b80851115614e62578160001904821115614e4857614e48614f74565b80851615614e5557918102915b93841c9390800290614e2c565b509250929050565b60006134fe8383600082614e80575060016142fb565b81614e8d575060006142fb565b8160018114614ea35760028114614ead57614ec9565b60019150506142fb565b60ff841115614ebe57614ebe614f74565b50506001821b6142fb565b5060208310610133831016604e8410600b8410161715614eec575081810a6142fb565b614ef68383614e27565b8060001904821115614f0a57614f0a614f74565b029392505050565b6000816000190483118215151615614f2c57614f2c614f74565b500290565b600082821015614f4357614f43614f74565b500390565b60005b83811015614f63578181015183820152602001614f4b565b838111156140fc5750506000910152565b634e487b7160e01b600052601160045260246000fd5b634e487b7160e01b600052604160045260246000fd5b6001600160a01b0381168114614fb557600080fd5b50565b67ffffffffffffffff81168114614fb557600080fd5b60ff81168114614fb557600080fdfea26469706673582212203824283dc520c8756dc21c337bd28327007eda6c238cf38698102afb5fe10fbc64736f6c63430008040033

Block Transaction Gas Used Reward
Age Block Fee Address BC Fee Address Voting Power Jailed Incoming
Block Uncle Number Difficulty Gas Used Reward
Loading
Make sure to use the "Vote Down" button for any spammy posts, and the "Vote Up" for interesting conversations.