Contract 0xbeD10b8f63c910BF0E3744DC308E728a095eAF2d

 
Txn Hash Method
Block
From
To
Value [Txn Fee]
0xdd236127cb223e2abc465eb932a2153a2312eccdfaa142d3ddcdda9ebcf97a0aFlash Close472900732022-09-19 22:17:496 days 8 hrs ago0x719154cee29258f668336b12cfe15dd73f79f0bf IN  0xbed10b8f63c910bf0e3744dc308e728a095eaf2d0 FTM0.003839424273
0x7eed5c1f1a91f894c28703de6a0da878f505cd9a6dc929e6b686acbc08e0e89aFlash Close472874362022-09-19 21:24:026 days 9 hrs ago0x719154cee29258f668336b12cfe15dd73f79f0bf IN  0xbed10b8f63c910bf0e3744dc308e728a095eaf2d0 FTM0.0033854575
0xa11a7badae30d80ef13bda341bf0e9c253c0e41481c5cd791b8586246b5488d8Flash Close472873192022-09-19 21:20:346 days 9 hrs ago0x719154cee29258f668336b12cfe15dd73f79f0bf IN  0xbed10b8f63c910bf0e3744dc308e728a095eaf2d0 FTM0.0034199375
0x2f721bf982ee0074dead08ae713e7cb0df6884bb43f0a3ac71bfe5012102d872Flash Close471313422022-09-17 16:45:038 days 13 hrs ago0x703518c0b200f99feca73743693b96f3f2d02e90 IN  0xbed10b8f63c910bf0e3744dc308e728a095eaf2d0 FTM0.003716783095
0x2405a90308a0b7c504585b3b9059b770369f92e82066f5ff82c2067d2112d41eFlash Close467845032022-09-11 22:52:5314 days 7 hrs ago0x5defe4f60965528030ee48bba305ed017ab84998 IN  0xbed10b8f63c910bf0e3744dc308e728a095eaf2d0 FTM0.005183663114
0x79d1a3c4a9263f34c050f1137cde62cad6de18b7e10afcddd3b79bd57ab9f07dFlash Close467652652022-09-11 15:21:5614 days 15 hrs ago0x81ba93b26bce8ca5d649b6607df15e6d45462d8f IN  0xbed10b8f63c910bf0e3744dc308e728a095eaf2d0 FTM0.003847796903
0x641c1d0bf01a9c6988e57837045fcc0a54893c6fa810fae326324f29c8187522Flash Close467649912022-09-11 15:16:3314 days 15 hrs ago0x81ba93b26bce8ca5d649b6607df15e6d45462d8f IN  0xbed10b8f63c910bf0e3744dc308e728a095eaf2d0 FTM0.003512251315
0x7ab97bd976f28713b11d08b12fc6a6b8d01402133477e834e88d3007a7c5d3afFlash Close464450642022-09-06 2:20:4320 days 4 hrs ago0xb3e1ef38c290016dbfc3d13d1c91c32b6ec0c0c7 IN  0xbed10b8f63c910bf0e3744dc308e728a095eaf2d0 FTM0.006756029946
0xde1fe00a38d83edafdb836f64c2c9a45246c463b23203b987de30605e90b58e7Flash Close464002622022-09-05 10:12:2820 days 20 hrs ago0xf97f7ab7ad98590ecbf9d1870d976bb1acecb696 IN  0xbed10b8f63c910bf0e3744dc308e728a095eaf2d0 FTM0.017114235618
0x316784cd20225633f3e9e38f61fe2e4d381c29b6711c49459458c35b3fe0a17cFlash Close464002362022-09-05 10:11:4720 days 20 hrs ago0x893bbf6520261f004e7a151fe041c9c661e2e583 IN  0xbed10b8f63c910bf0e3744dc308e728a095eaf2d0 FTM0.009269869891
0x4d2d0b53e27d36ea26f8e0c666fabce1d83f4d25e5144408871d4ff6daf92348Flash Close464001982022-09-05 10:11:0520 days 20 hrs ago0x74a94f6e2d88849ed0cac07f5b7c9a05bc516ddc IN  0xbed10b8f63c910bf0e3744dc308e728a095eaf2d0 FTM0.004739128644
0x1ff004050c424ebe4ef8715f06171fe6cd33cdf53cf17adbaf53276c2c658a8aFlash Close464001602022-09-05 10:10:1120 days 20 hrs ago0xc86b68363d1537f9b5936338bde83d4343710bfe IN  0xbed10b8f63c910bf0e3744dc308e728a095eaf2d0 FTM0.009716161678
0x8fcb667771451e60129f7060746f1564846abd2f274664fecf68b5c670e4ba98Flash Close464001402022-09-05 10:09:3320 days 20 hrs ago0x6b9d90a764e26763fab590890296659dcf1bc6cb IN  0xbed10b8f63c910bf0e3744dc308e728a095eaf2d0 FTM0.066316467415
0x9f49dbb6b8eb231c47817087d98cd8e25e6214e2093dce0db472c9c516b0da45Flash Close464000842022-09-05 10:08:1420 days 20 hrs ago0xe6ca63cd295c84d6f184192dc8023960772dd321 IN  0xbed10b8f63c910bf0e3744dc308e728a095eaf2d0 FTM0.066031721018
0x65b7b6ae9a482e106233295afa5863429e1955d00634b50c03af51a4f0328f53Flash Close464000462022-09-05 10:07:0220 days 20 hrs ago0x80f60cd83827e9f77d381955d8cd8c7143f626af IN  0xbed10b8f63c910bf0e3744dc308e728a095eaf2d0 FTM0.066088454057
0xb6d8c5f3857f998f78f384ffd1a25203e9625cf0fe7f35d3aa51a74be796b8f1Flash Close461994032022-09-02 11:22:3923 days 19 hrs ago0x338578ba554f9d76ed9372da609e9d5dfd904559 IN  0xbed10b8f63c910bf0e3744dc308e728a095eaf2d0 FTM0.049586069491
0x6977bc1692c19d046589a4e5bdf9a67862cdbbfa3eb5995b7af587ecf01f866eFlash Close461926972022-09-02 9:03:2123 days 21 hrs ago0x1fac6eee2197c98d1ef0f166eccffa8632e9a279 IN  0xbed10b8f63c910bf0e3744dc308e728a095eaf2d0 FTM0.003276088
0x9da68a9e99d3c99982aa31536da459cdf677a156136a8beddf73caa610e278f4Flash Close458938592022-08-29 0:30:2428 days 6 hrs ago0xa297bb9a7aa2aec77f62dcd93ea6db256d8643db IN  0xbed10b8f63c910bf0e3744dc308e728a095eaf2d0 FTM0.07680394262
0xf07ceaee4fa1bf63252aa747474248ff62853e637f30e22a61914cc5c008b676Flash Close458837492022-08-28 20:40:5328 days 10 hrs ago0xc875a15956b4a47c8e85791d9891577eec762bc2 IN  0xbed10b8f63c910bf0e3744dc308e728a095eaf2d0 FTM0.169413842844
0xf58d8cffcc0276d284afdbd6758dfb46950d89bade974da8d588540cc81e31fbFlash Close458837232022-08-28 20:40:0328 days 10 hrs ago0xc875a15956b4a47c8e85791d9891577eec762bc2 IN  0xbed10b8f63c910bf0e3744dc308e728a095eaf2d0 FTM0.035149593458
0xf46b4740729c8d6f811fa27858c48e55fd54422dd2f81db41728179b2481012dFlash Close457892222022-08-27 12:05:3029 days 18 hrs ago0x5246eadea6925ef6a861e3e2860665306a8a6233 IN  0xbed10b8f63c910bf0e3744dc308e728a095eaf2d0 FTM0.003517865732
0x8b1c014385eff00e112d599a784f9e8c933f1ae403cf09d431fbe2366fc03b5eFlash Close457276752022-08-26 14:50:5030 days 15 hrs ago0x56d79fe635196e734ce29d7a8ccd8014865e790c IN  0xbed10b8f63c910bf0e3744dc308e728a095eaf2d0 FTM0.0742575
0x4f1571037327ffe9dc65bc6df081e0ea8e4a8999fdb87844d6fec81e500a841dFlash Close457273492022-08-26 14:43:3430 days 15 hrs ago0x56d79fe635196e734ce29d7a8ccd8014865e790c IN  0xbed10b8f63c910bf0e3744dc308e728a095eaf2d0 FTM0.419064457
0xfce54db14dd29ed8920e2296c6ad9fdc3cf8a5090d7879ced559a8eaaf06c2f9Flash Close455079162022-08-23 11:00:3133 days 19 hrs ago0x56af52a9611afda072a73afd0e1ff4c4e35ee94a IN  0xbed10b8f63c910bf0e3744dc308e728a095eaf2d0 FTM0.003721029998
0x4150e4de24ef123276f66e6ddec5941f351223a10a2554f8b9dc65748f40a7a2Flash Close452615692022-08-19 22:00:4137 days 8 hrs ago0xbdec7287c08c0c153f9843c4796d59e3bf7178e4 IN  0xbed10b8f63c910bf0e3744dc308e728a095eaf2d0 FTM0.00405910408
[ Download CSV Export 
Latest 25 internal transaction
Parent Txn Hash Block From To Value
0x7eed5c1f1a91f894c28703de6a0da878f505cd9a6dc929e6b686acbc08e0e89a472874362022-09-19 21:24:026 days 9 hrs ago 0xbed10b8f63c910bf0e3744dc308e728a095eaf2d SpookySwap: Router0.017642928201141609 FTM
0x7eed5c1f1a91f894c28703de6a0da878f505cd9a6dc929e6b686acbc08e0e89a472874362022-09-19 21:24:026 days 9 hrs ago 0xbed10b8f63c910bf0e3744dc308e728a095eaf2d0x719154cee29258f668336b12cfe15dd73f79f0bf0.087027827491546952 FTM
0x7eed5c1f1a91f894c28703de6a0da878f505cd9a6dc929e6b686acbc08e0e89a472874362022-09-19 21:24:026 days 9 hrs ago 0x5110ec1e9f9ee08ea8b884eb3be4faace8960fd8 0xbed10b8f63c910bf0e3744dc308e728a095eaf2d0.104670755692688561 FTM
0xa11a7badae30d80ef13bda341bf0e9c253c0e41481c5cd791b8586246b5488d8472873192022-09-19 21:20:346 days 9 hrs ago 0xbed10b8f63c910bf0e3744dc308e728a095eaf2d SpookySwap: Router0.000043966721468088 FTM
0xa11a7badae30d80ef13bda341bf0e9c253c0e41481c5cd791b8586246b5488d8472873192022-09-19 21:20:346 days 9 hrs ago 0xbed10b8f63c910bf0e3744dc308e728a095eaf2d0x719154cee29258f668336b12cfe15dd73f79f0bf0.099965878240639716 FTM
0xa11a7badae30d80ef13bda341bf0e9c253c0e41481c5cd791b8586246b5488d8472873192022-09-19 21:20:346 days 9 hrs ago 0x5110ec1e9f9ee08ea8b884eb3be4faace8960fd8 0xbed10b8f63c910bf0e3744dc308e728a095eaf2d0.100009844962107804 FTM
0x2f721bf982ee0074dead08ae713e7cb0df6884bb43f0a3ac71bfe5012102d872471313422022-09-17 16:45:038 days 13 hrs ago 0xbed10b8f63c910bf0e3744dc308e728a095eaf2d SpookySwap: Router4.051922743846897128 FTM
0x2f721bf982ee0074dead08ae713e7cb0df6884bb43f0a3ac71bfe5012102d872471313422022-09-17 16:45:038 days 13 hrs ago 0xbed10b8f63c910bf0e3744dc308e728a095eaf2d0x703518c0b200f99feca73743693b96f3f2d02e903.224576004898095642 FTM
0x2f721bf982ee0074dead08ae713e7cb0df6884bb43f0a3ac71bfe5012102d872471313422022-09-17 16:45:038 days 13 hrs ago 0x5110ec1e9f9ee08ea8b884eb3be4faace8960fd8 0xbed10b8f63c910bf0e3744dc308e728a095eaf2d7.27649874874499277 FTM
0x641c1d0bf01a9c6988e57837045fcc0a54893c6fa810fae326324f29c8187522467649912022-09-11 15:16:3314 days 15 hrs ago 0xbed10b8f63c910bf0e3744dc308e728a095eaf2d SpookySwap: Router0.020278042469397603 FTM
0x641c1d0bf01a9c6988e57837045fcc0a54893c6fa810fae326324f29c8187522467649912022-09-11 15:16:3314 days 15 hrs ago 0xbed10b8f63c910bf0e3744dc308e728a095eaf2d0x81ba93b26bce8ca5d649b6607df15e6d45462d8f0.007032371845831109 FTM
0x641c1d0bf01a9c6988e57837045fcc0a54893c6fa810fae326324f29c8187522467649912022-09-11 15:16:3314 days 15 hrs ago 0x5110ec1e9f9ee08ea8b884eb3be4faace8960fd8 0xbed10b8f63c910bf0e3744dc308e728a095eaf2d0.027310414315228712 FTM
0xde1fe00a38d83edafdb836f64c2c9a45246c463b23203b987de30605e90b58e7464002622022-09-05 10:12:2820 days 20 hrs ago 0xbed10b8f63c910bf0e3744dc308e728a095eaf2d SpookySwap: Router3.831883850882451427 FTM
0xde1fe00a38d83edafdb836f64c2c9a45246c463b23203b987de30605e90b58e7464002622022-09-05 10:12:2820 days 20 hrs ago 0xbed10b8f63c910bf0e3744dc308e728a095eaf2d0xf97f7ab7ad98590ecbf9d1870d976bb1acecb6967.311331700215545728 FTM
0xde1fe00a38d83edafdb836f64c2c9a45246c463b23203b987de30605e90b58e7464002622022-09-05 10:12:2820 days 20 hrs ago 0x5110ec1e9f9ee08ea8b884eb3be4faace8960fd8 0xbed10b8f63c910bf0e3744dc308e728a095eaf2d11.143215551097997155 FTM
0x316784cd20225633f3e9e38f61fe2e4d381c29b6711c49459458c35b3fe0a17c464002362022-09-05 10:11:4720 days 20 hrs ago 0xbed10b8f63c910bf0e3744dc308e728a095eaf2d SpookySwap: Router3.833922651257877912 FTM
0x316784cd20225633f3e9e38f61fe2e4d381c29b6711c49459458c35b3fe0a17c464002362022-09-05 10:11:4720 days 20 hrs ago 0xbed10b8f63c910bf0e3744dc308e728a095eaf2d0x893bbf6520261f004e7a151fe041c9c661e2e5838.293980329922506093 FTM
0x316784cd20225633f3e9e38f61fe2e4d381c29b6711c49459458c35b3fe0a17c464002362022-09-05 10:11:4720 days 20 hrs ago 0x5110ec1e9f9ee08ea8b884eb3be4faace8960fd8 0xbed10b8f63c910bf0e3744dc308e728a095eaf2d12.127902981180384005 FTM
0x4d2d0b53e27d36ea26f8e0c666fabce1d83f4d25e5144408871d4ff6daf92348464001982022-09-05 10:11:0520 days 20 hrs ago 0xbed10b8f63c910bf0e3744dc308e728a095eaf2d SpookySwap: Router4.215589512851139023 FTM
0x4d2d0b53e27d36ea26f8e0c666fabce1d83f4d25e5144408871d4ff6daf92348464001982022-09-05 10:11:0520 days 20 hrs ago 0xbed10b8f63c910bf0e3744dc308e728a095eaf2d0x74a94f6e2d88849ed0cac07f5b7c9a05bc516ddc11.991771021874306389 FTM
0x4d2d0b53e27d36ea26f8e0c666fabce1d83f4d25e5144408871d4ff6daf92348464001982022-09-05 10:11:0520 days 20 hrs ago 0x5110ec1e9f9ee08ea8b884eb3be4faace8960fd8 0xbed10b8f63c910bf0e3744dc308e728a095eaf2d16.207360534725445412 FTM
0x1ff004050c424ebe4ef8715f06171fe6cd33cdf53cf17adbaf53276c2c658a8a464001602022-09-05 10:10:1120 days 20 hrs ago 0xbed10b8f63c910bf0e3744dc308e728a095eaf2d SpookySwap: Router3.835459036336159312 FTM
0x1ff004050c424ebe4ef8715f06171fe6cd33cdf53cf17adbaf53276c2c658a8a464001602022-09-05 10:10:1120 days 20 hrs ago 0xbed10b8f63c910bf0e3744dc308e728a095eaf2d0xc86b68363d1537f9b5936338bde83d4343710bfe10.200389706223220325 FTM
0x1ff004050c424ebe4ef8715f06171fe6cd33cdf53cf17adbaf53276c2c658a8a464001602022-09-05 10:10:1120 days 20 hrs ago 0x5110ec1e9f9ee08ea8b884eb3be4faace8960fd8 0xbed10b8f63c910bf0e3744dc308e728a095eaf2d14.035848742559379637 FTM
0x8fcb667771451e60129f7060746f1564846abd2f274664fecf68b5c670e4ba98464001402022-09-05 10:09:3320 days 20 hrs ago 0xbed10b8f63c910bf0e3744dc308e728a095eaf2d SpookySwap: Router3.835467319622210689 FTM
[ Download CSV Export 
Loading

Contract Source Code Verified (Exact Match)

Contract Name:
FliquidatorFTM

Compiler Version
v0.8.4+commit.c7e474f2

Optimization Enabled:
Yes with 500 runs

Other Settings:
default evmVersion

Contract Source Code (Solidity Standard Json-Input format)

File 1 of 22 : FliquidatorFTM.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/LibUniversalERC20FTM.sol";
import "../libraries/FlashLoans.sol";
import "../libraries/Errors.sol";

import "./nft-bonds/interfaces/INFTGame.sol";

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

contract FliquidatorFTM is Claimable, ReentrancyGuard {
  using SafeERC20 for IERC20;
  using LibUniversalERC20FTM for IERC20;

  address public constant FTM = 0xFFfFfFffFFfffFFfFFfFFFFFffFFFffffFfFFFfF;

  // 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;
  address public nftGame;

  /**
   * @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 Log a change in fuji admin address
  */
  event NFTGameChanged(address newNFTGame);

  /**
   * @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 == FTM) {
      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 == FTM ? 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 == FTM ? _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 == FTM ? _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);

    _afterDebtActionCallback(address(_userAddr), vAssets.borrowAsset, (_amount - protocolFee));
  }

  /**
   * @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 == FTM) {
        _collateralAssetDecimals = 18;
      } else {
        _collateralAssetDecimals = IERC20Extended(_collateralAsset).decimals();
      }
      if (_borrowAsset == FTM) {
        _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 == FTM) {
      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 == FTM) {
      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 == FTM || _collateralAsset == weth) {
      path = new address[](2);
      path[0] = weth;
      path[1] = _borrowAsset;
    } else if (_borrowAsset == FTM || _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);

        _afterDebtActionCallback(_addrs[i], _vAssets.borrowAsset, _borrowBals[i]);
      }
    }
  }

  /**
   * @dev Internal hook function after debt change calls.
   * Used to plug functionality. 
   */
  function _afterDebtActionCallback(address user, address debtAsset, uint256 _amount) internal {
    if (nftGame != address(0)) {
      INFTGame game = INFTGame(nftGame);
      uint256 phase = game.getPhase();
      uint256 _borrowAssetDecimals = IERC20Extended(debtAsset).decimals();
      if (phase == 1 && game.isValidVault(address(this))) {
        game.checkStateOfPoints(user, _amount, true, _borrowAssetDecimals);
      }
    }
  }

  // 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);
  }

  /**
  * @dev Sets the NFT Bond Logic address
  * @param _nftgame: new NFT Game address
  * Emits a {NFTGameChanged} event.
  */
  function setNFTGame(address _nftgame) external isAuthorized {
    nftGame = _nftgame;
    emit NFTGameChanged(_nftgame);
  }
}

File 2 of 22 : 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 22 : IERC20.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.0;

/**
 * @dev Interface of the ERC20 standard as defined in the EIP.
 */
interface IERC20 {
    /**
     * @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 `recipient`.
     *
     * Returns a boolean value indicating whether the operation succeeded.
     *
     * Emits a {Transfer} event.
     */
    function transfer(address recipient, 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 `sender` to `recipient` 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 sender,
        address recipient,
        uint256 amount
    ) external returns (bool);

    /**
     * @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);
}

File 4 of 22 : SafeERC20.sol
// SPDX-License-Identifier: MIT

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 22 : IERC1155.sol
// SPDX-License-Identifier: MIT

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 22 : ReentrancyGuard.sol
// SPDX-License-Identifier: MIT

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 make 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 22 : 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 22 : 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 22 : 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 22 : 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 22 : 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 22 : 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 22 : 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 22 : 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 22 : LibUniversalERC20FTM.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 LibUniversalERC20FTM {
  using SafeERC20 for IERC20;

  IERC20 private constant _FTM_ADDRESS = IERC20(0xFFfFfFffFFfffFFfFFfFFFFFffFFFffffFfFFFfF);
  IERC20 private constant _ZERO_ADDRESS = IERC20(0x0000000000000000000000000000000000000000);

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

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

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

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

    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 22 : 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 22 : 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 22 : INFTGame.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

interface INFTGame {

  function getPhase() external view returns (uint256);

  function gamePhaseTimestamps(uint256) external view returns(uint256);

  function isValidVault(address) external view returns(bool);

  function checkStateOfPoints(
    address user,
    uint256 balanceChange,
    bool isPayback,
    uint256 decimals
  ) external;

}

File 19 of 22 : 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 20 of 22 : Address.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.0;

/**
 * @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
     * ====
     */
    function isContract(address account) internal view returns (bool) {
        // This method relies on extcodesize, which returns 0 for contracts in
        // construction, since the code is only stored at the end of the
        // constructor execution.

        uint256 size;
        assembly {
            size := extcodesize(account)
        }
        return size > 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 21 of 22 : IERC165.sol
// SPDX-License-Identifier: MIT

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 22 of 22 : Context.sol
// SPDX-License-Identifier: MIT

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 Security Audit

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":false,"internalType":"address","name":"newNFTGame","type":"address"}],"name":"NFTGameChanged","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":"FTM","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":"nftGame","outputs":[{"internalType":"address","name":"","type":"address"}],"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":"_nftgame","type":"address"}],"name":"setNFTGame","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"}]

608060405234801561001057600080fd5b50600080546001600160a01b031916339081178255604051909182917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0908290a3506001600255600380546001600160801b031916686400000000000000011790556152b8806100816000396000f3fe6080604052600436106101595760003560e01c806391c15432116100bb5780639df97b041161007f578063f2fde38b11610059578063f2fde38b146103cc578063f72dde30146103ec578063fae5a8f01461040c57600080fd5b80639df97b0414610384578063a10364d714610397578063e30c3978146103ac57600080fd5b806391c15432146102fc57806392fede001461031c57806398e1fdb5146103315780639c6ce5aa146103515780639c82f2a41461036457600080fd5b80635003d4b41161011d57806377a7e77d116100f757806377a7e77d146102a357806388d4cbb5146102be5780638da5cb5b146102de57600080fd5b80635003d4b41461024e57806356bae4531461026e578063715018a61461028e57600080fd5b80630fd9be71146101655780632b3297f9146101bc57806339221f50146101f457806346be3413146102175780634e71e0c81461023957600080fd5b3661016057005b600080fd5b34801561017157600080fd5b506003546101969067ffffffffffffffff808216916801000000000000000090041682565b6040805167ffffffffffffffff9384168152929091166020830152015b60405180910390f35b3480156101c857600080fd5b506006546101dc906001600160a01b031681565b6040516001600160a01b0390911681526020016101b3565b34801561020057600080fd5b50610209600281565b6040519081526020016101b3565b34801561022357600080fd5b5061023761023236600461499e565b61041f565b005b34801561024557600080fd5b50610237610506565b34801561025a57600080fd5b50610237610269366004614c42565b6105a0565b34801561027a57600080fd5b50610237610289366004614a70565b610c15565b34801561029a57600080fd5b5061023761102a565b3480156102af57600080fd5b506101dc6001600160a01b0381565b3480156102ca57600080fd5b506007546101dc906001600160a01b031681565b3480156102ea57600080fd5b506000546001600160a01b03166101dc565b34801561030857600080fd5b5061023761031736600461499e565b6110ce565b34801561032857600080fd5b506102376111a5565b34801561033d57600080fd5b5061023761034c366004614d14565b611251565b61023761035f366004614ad6565b611362565b34801561037057600080fd5b5061023761037f36600461499e565b6119f7565b6102376103923660046149d6565b611ace565b3480156103a357600080fd5b50610209606481565b3480156103b857600080fd5b506001546101dc906001600160a01b031681565b3480156103d857600080fd5b506102376103e736600461499e565b6123c1565b3480156103f857600080fd5b5061023761040736600461499e565b612514565b61023761041a366004614a1b565b6125a9565b60005460408051808201909152600381526231313160e81b6020820152906001600160a01b0316331461046e5760405162461bcd60e51b81526004016104659190614ebe565b60405180910390fd5b5060408051808201909152600381526203133360ec1b60208201526001600160a01b0382166104b05760405162461bcd60e51b81526004016104659190614ebe565b50600580546001600160a01b0319166001600160a01b0383169081179091556040519081527f0e05ae75e8b926552cf6fcd744d19f422561e3ced1e426868730852702dbe418906020015b60405180910390a150565b6001546001600160a01b0316336001600160a01b03161461052657600080fd5b6001546001600160a01b03166105446000546001600160a01b031690565b6001600160a01b03167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a360018054600080546001600160a01b03199081166001600160a01b03841617909155169055565b6002805414156105f25760405162461bcd60e51b815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c006044820152606401610465565b6002805560048054604051630f6ec81f60e01b81526001600160a01b0380861693820193909352849290911690630f6ec81f9060240160206040518083038186803b15801561064057600080fd5b505afa158015610654573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906106789190614c22565b6106b55760405162461bcd60e51b815260206004820152600e60248201526d496e76616c6964207661756c742160901b6044820152606401610465565b826001600160a01b03166367ac280a6040518163ffffffff1660e01b8152600401600060405180830381600087803b1580156106f057600080fd5b505af1158015610704573d6000803e3d6000fd5b505050506000836001600160a01b031663acb2d4106040518163ffffffff1660e01b815260040160206040518083038186803b15801561074357600080fd5b505afa158015610757573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061077b91906149ba565b90506000846001600160a01b031663d8df4ce76040518163ffffffff1660e01b815260040160806040518083038186803b1580156107b857600080fd5b505afa1580156107cc573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906107f09190614c78565b6040808201519051627eeac760e11b815233600482015267ffffffffffffffff90911660248201529091506000906001600160a01b0384169062fdd58e9060440160206040518083038186803b15801561084957600080fd5b505afa15801561085d573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906108819190614cfc565b604051631714decd60e01b81523360048201529091506000906001600160a01b03881690631714decd9060240160206040518083038186803b1580156108c657600080fd5b505afa1580156108da573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906108fe9190614cfc565b9050600081116040518060400160405280600381526020016218981b60e91b8152509061093e5760405162461bcd60e51b81526004016104659190614ebe565b50600080891261094e5788610950565b815b60405163486bdfd760e11b8152600481018290526000602482018190529192506001600160a01b038a16906390d7bfae9060440160206040518083038186803b15801561099c57600080fd5b505afa1580156109b0573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906109d49190614cfc565b905080841015604051806040016040528060038152602001620c4c8d60ea1b81525090610a145760405162461bcd60e51b81526004016104659190614ebe565b50604080516001808252818301909252600091602080830190803683370190505090503381600081518110610a5957634e487b7160e01b600052603260045260246000fd5b6001600160a01b0390921660209283029190910190910152604080516101208101909152600090806001815260200188602001516001600160a01b031681526020018581526020018c6001600160a01b0316815260200160006001600160a01b03168152602001838152602001600067ffffffffffffffff811115610aee57634e487b7160e01b600052604160045260246000fd5b604051908082528060200260200182016040528015610b17578160200160208202803683370190505b508152600060208083019190915230604092830152600480548351637fabc90b60e01b815293519495506001600160a01b031693637fabc90b93808301939290829003018186803b158015610b6b57600080fd5b505afa158015610b7f573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610ba391906149ba565b6001600160a01b0316635ccd808c828c6040518363ffffffff1660e01b8152600401610bd0929190614ef1565b600060405180830381600087803b158015610bea57600080fd5b505af1158015610bfe573d6000803e3d6000fd5b505060016002555050505050505050505050505050565b60048054604051630f6ec81f60e01b81526001600160a01b0380861693820193909352849290911690630f6ec81f9060240160206040518083038186803b158015610c5f57600080fd5b505afa158015610c73573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610c979190614c22565b610cd45760405162461bcd60e51b815260206004820152600e60248201526d496e76616c6964207661756c742160901b6044820152606401610465565b600280541415610d265760405162461bcd60e51b815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c006044820152606401610465565b600280819055506000836001600160a01b031663d8df4ce76040518163ffffffff1660e01b815260040160806040518083038186803b158015610d6857600080fd5b505afa158015610d7c573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610da09190614c78565b90506000846001600160a01b031663acb2d4106040518163ffffffff1660e01b815260040160206040518083038186803b158015610ddd57600080fd5b505afa158015610df1573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610e1591906149ba565b9050846001600160a01b03166367ac280a6040518163ffffffff1660e01b8152600401600060405180830381600087803b158015610e5257600080fd5b505af1158015610e66573d6000803e3d6000fd5b505050506000806000610eb08a8a808060200260200160405190810160405280939291908181526020018383602002808284376000920191909152508992508c9150889050612ca0565b925092509250600081116040518060400160405280600381526020016206260760eb1b81525090610ef45760405162461bcd60e51b81526004016104659190614ebe565b506040805161012081018252600281526020878101516001600160a01b03908116828401528284018590528b811660608401526000608084015260a0830187905260c083018690523360e084015230610100840152600480548551637fabc90b60e01b815295519495921693637fabc90b9383830193909290829003018186803b158015610f8157600080fd5b505afa158015610f95573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610fb991906149ba565b6001600160a01b0316635ccd808c828a6040518363ffffffff1660e01b8152600401610fe6929190614ef1565b600060405180830381600087803b15801561100057600080fd5b505af1158015611014573d6000803e3d6000fd5b5050600160025550505050505050505050505050565b6000546001600160a01b031633146110845760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e65726044820152606401610465565b600080546040516001600160a01b03909116907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0908390a3600080546001600160a01b0319169055565b60005460408051808201909152600381526231313160e81b6020820152906001600160a01b031633146111145760405162461bcd60e51b81526004016104659190614ebe565b5060408051808201909152600381526203133360ec1b60208201526001600160a01b0382166111565760405162461bcd60e51b81526004016104659190614ebe565b50600480546001600160a01b0319166001600160a01b0383169081179091556040519081527fa05e64ea7e34b372177317c71229808e25bdbfe5dc3e6bc4fc7ca66c97d93276906020016104fb565b6000546001600160a01b031633146111ff5760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e65726044820152606401610465565b6001546001600160a01b031661121457600080fd5b600180546001600160a01b03191690556040516000907f69737d41162474a7ca514809b07d7becaecf72eae8c23bceb071f0e09af93ffc908290a2565b60005460408051808201909152600381526231313160e81b6020820152906001600160a01b031633146112975760405162461bcd60e51b81526004016104659190614ebe565b506003805467ffffffffffffffff83811668010000000000000000026fffffffffffffffffffffffffffffffff19909216908516171790556040517f4e0575b6657dd07a883013977eb34af3deab3528c640a26ce02097f5351e8b7f90611320906020016020808252600b908201526a333630b9b421b637b9b2a360a91b604082015260600190565b60408051601f198184030181528282528051602091820120835267ffffffffffffffff8087169184019190915284169082015260600160405180910390a15050565b6004805460408051637fabc90b60e01b815290516001600160a01b0390921692637fabc90b928282019260209290829003018186803b1580156113a457600080fd5b505afa1580156113b8573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906113dc91906149ba565b6001600160a01b0316336001600160a01b0316146040518060400160405280600381526020016231313160e81b8152509061142a5760405162461bcd60e51b81526004016104659190614ebe565b506000836001600160a01b031663acb2d4106040518163ffffffff1660e01b815260040160206040518083038186803b15801561146657600080fd5b505afa15801561147a573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061149e91906149ba565b90506000846001600160a01b031663d8df4ce76040518163ffffffff1660e01b815260040160806040518083038186803b1580156114db57600080fd5b505afa1580156114ef573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906115139190614c78565b905060006001600160a01b03801682602001516001600160a01b03161461153b57600061153d565b845b9050856001600160a01b031663e5aa6d05828d8d896040518563ffffffff1660e01b815260040161157093929190614e18565b6000604051808303818588803b15801561158957600080fd5b505af115801561159d573d6000803e3d6000fd5b505060405163e897effb60e01b815260048101899052600093506001600160a01b038a16925063e897effb915060240160206040518083038186803b1580156115e557600080fd5b505afa1580156115f9573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061161d9190614cfc565b9050600061164a8460000151856020015184898b61163b9190615094565b6116459190615094565b6131f3565b90506116cf8d8d80806020026020016040519081016040528093929190818152602001838360200280828437600081840152601f19601f820116905080830192505050505050508c8c808060200260200160405190810160405280939291908181526020018383602002808284376000920191909152508992508d91508a90506135ae565b60405162197ac760e01b8152600481018290526001600160a01b0389169062197ac790602401600060405180830381600087803b15801561170f57600080fd5b505af1158015611723573d6000803e3d6000fd5b50508551602087015161175193509091508461173f8a8c615094565b6117499190615094565b8460016138e4565b506117fa600460009054906101000a90046001600160a01b03166001600160a01b0316637fabc90b6040518163ffffffff1660e01b815260040160206040518083038186803b1580156117a357600080fd5b505afa1580156117b7573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906117db91906149ba565b6117e5888a615094565b60208701516001600160a01b031691906140fa565b60006118076005846150ac565b905061182c8a61181783866151d6565b60208801516001600160a01b031691906140fa565b6118ca600460009054906101000a90046001600160a01b03166001600160a01b0316633b19e84a6040518163ffffffff1660e01b815260040160206040518083038186803b15801561187d57600080fd5b505afa158015611891573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906118b591906149ba565b60208701516001600160a01b031690836140fa565b60005b8d8110156119e65760008f8f838181106118f757634e487b7160e01b600052603260045260246000fd5b905060200201602081019061190c919061499e565b6001600160a01b0316146119d457896001600160a01b03168f8f8381811061194457634e487b7160e01b600052603260045260246000fd5b9050602002016020810190611959919061499e565b6001600160a01b03167f60b8242c7715592d395c118b86e1c56e483030f45fab92e8694eda9f1a837f5e8f8f858181106119a357634e487b7160e01b600052603260045260246000fd5b905060200201358e6040516119cb9291909182526001600160a01b0316602082015260400190565b60405180910390a35b6119df600182615094565b90506118cd565b505050505050505050505050505050565b60005460408051808201909152600381526231313160e81b6020820152906001600160a01b03163314611a3d5760405162461bcd60e51b81526004016104659190614ebe565b5060408051808201909152600381526203133360ec1b60208201526001600160a01b038216611a7f5760405162461bcd60e51b81526004016104659190614ebe565b50600680546001600160a01b0319166001600160a01b0383169081179091556040519081527f7d7719313229e558c5a3893cad2eb86a86a049156d1d9ebd5c63a8eedefd1c03906020016104fb565b6004805460408051637fabc90b60e01b815290516001600160a01b0390921692637fabc90b928282019260209290829003018186803b158015611b1057600080fd5b505afa158015611b24573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611b4891906149ba565b6001600160a01b0316336001600160a01b0316146040518060400160405280600381526020016231313160e81b81525090611b965760405162461bcd60e51b81526004016104659190614ebe565b506000836001600160a01b031663acb2d4106040518163ffffffff1660e01b815260040160206040518083038186803b158015611bd257600080fd5b505afa158015611be6573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611c0a91906149ba565b90506000846001600160a01b031663d8df4ce76040518163ffffffff1660e01b815260040160806040518083038186803b158015611c4757600080fd5b505afa158015611c5b573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611c7f9190614c78565b60035490915060009067ffffffffffffffff680100000000000000008204811691611cab9116876151b7565b611cb591906150ac565b604051636fb1b05360e11b81526001600160a01b03898116600483015291925060009188169063df6360a69060240160206040518083038186803b158015611cfc57600080fd5b505afa158015611d10573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611d349190614cfc565b6060840151604051627eeac760e11b81526001600160a01b038b8116600483015267ffffffffffffffff9092166024820152919250600091839187169062fdd58e9060440160206040518083038186803b158015611d9157600080fd5b505afa158015611da5573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611dc99190614cfc565b611dd39190615094565b90506000611df185600001518660200151868a8c61163b9190615094565b905060006001600160a01b03801686602001516001600160a01b031614611e19576000611e1b565b885b60408051600180825281830190925291925060009190602080830190803683370190505090508b81600081518110611e6357634e487b7160e01b600052603260045260246000fd5b6001600160a01b03928316602091820292909201015260405163e5aa6d0560e01b8152908c169063e5aa6d05908490611ea29085908f90600401614e9c565b6000604051808303818588803b158015611ebb57600080fd5b505af1158015611ecf573d6000803e3d6000fd5b5050505050838a141561207a576040808801519051627eeac760e11b81526001600160a01b038e8116600483015267ffffffffffffffff90921660248201526000918a169062fdd58e9060440160206040518083038186803b158015611f3457600080fd5b505afa158015611f48573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611f6c9190614cfc565b9050886001600160a01b031663f5298aca8e8a60400151846040518463ffffffff1660e01b8152600401611fc8939291906001600160a01b0393909316835267ffffffffffffffff919091166020830152604082015260600190565b600060405180830381600087803b158015611fe257600080fd5b505af1158015611ff6573d6000803e3d6000fd5b505060405162197ac760e01b8152600481018490526001600160a01b038f16925062197ac79150602401600060405180830381600087803b15801561203a57600080fd5b505af115801561204e573d6000803e3d6000fd5b505050506120748d858361206291906151d6565b8a516001600160a01b031691906140fa565b5061214c565b6040808801519051637a94c56560e11b81526001600160a01b038e8116600483015267ffffffffffffffff9092166024820152604481018590529089169063f5298aca90606401600060405180830381600087803b1580156120db57600080fd5b505af11580156120ef573d6000803e3d6000fd5b505060405162197ac760e01b8152600481018690526001600160a01b038e16925062197ac79150602401600060405180830381600087803b15801561213357600080fd5b505af1158015612147573d6000803e3d6000fd5b505050505b865160208801516121759190886121638d8f615094565b61216d9190615094565b8660006138e4565b50612214600460009054906101000a90046001600160a01b03166001600160a01b0316633b19e84a6040518163ffffffff1660e01b815260040160206040518083038186803b1580156121c757600080fd5b505afa1580156121db573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906121ff91906149ba565b60208901516001600160a01b031690886140fa565b6122bc600460009054906101000a90046001600160a01b03166001600160a01b0316637fabc90b6040518163ffffffff1660e01b815260040160206040518083038186803b15801561226557600080fd5b505afa158015612279573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061229d91906149ba565b6122a78b8d615094565b60208a01516001600160a01b031691906140fa565b876001600160a01b031663f5298aca8d8960600151888e6122dd91906151d6565b6040516001600160e01b031960e086901b1681526001600160a01b03909316600484015267ffffffffffffffff90911660248301526044820152606401600060405180830381600087803b15801561233457600080fd5b505af1158015612348573d6000803e3d6000fd5b505050508a6001600160a01b03168c6001600160a01b03167f3eeeaba10d85fe3ba0708f01d644ff55bbdf227dd736ce68eba30cd119514c128c60405161239191815260200190565b60405180910390a36123b38c8860200151878d6123ae91906151d6565b6141d0565b505050505050505050505050565b6000546001600160a01b0316331461241b5760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e65726044820152606401610465565b6001600160a01b0381166124715760405162461bcd60e51b815260206004820152601960248201527f43616e6e6f742070617373207a65726f206164647265737321000000000000006044820152606401610465565b6001546001600160a01b0316156124ca5760405162461bcd60e51b815260206004820152601960248201527f546865726520697320612070656e64696e67206f776e657221000000000000006044820152606401610465565b600180546001600160a01b0319166001600160a01b0383169081179091556040517f69737d41162474a7ca514809b07d7becaecf72eae8c23bceb071f0e09af93ffc90600090a250565b60005460408051808201909152600381526231313160e81b6020820152906001600160a01b0316331461255a5760405162461bcd60e51b81526004016104659190614ebe565b50600780546001600160a01b0319166001600160a01b0383169081179091556040519081527f34e83df4a2403449e089f520b489d0789cc98ee337bea3e0ed8f0c097f6632e0906020016104fb565b6002805414156125fb5760405162461bcd60e51b815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c006044820152606401610465565b6002805560048054604051630f6ec81f60e01b81526001600160a01b0380851693820193909352839290911690630f6ec81f9060240160206040518083038186803b15801561264957600080fd5b505afa15801561265d573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906126819190614c22565b6126be5760405162461bcd60e51b815260206004820152600e60248201526d496e76616c6964207661756c742160901b6044820152606401610465565b6000826001600160a01b031663d8df4ce76040518163ffffffff1660e01b815260040160806040518083038186803b1580156126f957600080fd5b505afa15801561270d573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906127319190614c78565b90506000836001600160a01b031663acb2d4106040518163ffffffff1660e01b815260040160206040518083038186803b15801561276e57600080fd5b505afa158015612782573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906127a691906149ba565b9050836001600160a01b03166367ac280a6040518163ffffffff1660e01b8152600401600060405180830381600087803b1580156127e357600080fd5b505af11580156127f7573d6000803e3d6000fd5b5050505060008060006128418989808060200260200160405190810160405280939291908181526020018383602002808284376000920191909152508992508b9150889050612ca0565b925092509250600081116040518060400160405280600381526020016206260760eb1b815250906128855760405162461bcd60e51b81526004016104659190614ebe565b5060208501516001600160a01b0390811614156128e057803410156040518060400160405280600381526020016231303360e81b815250906128da5760405162461bcd60e51b81526004016104659190614ebe565b506129ba565b6020850151604051636eb1769f60e11b815233600482015230602482015282916001600160a01b03169063dd62ed3e9060440160206040518083038186803b15801561292b57600080fd5b505afa15801561293f573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906129639190614cfc565b10156040518060400160405280600381526020016231303760e81b8152509061299f5760405162461bcd60e51b81526004016104659190614ebe565b5060208501516129ba906001600160a01b03163389846143dd565b60006001600160a01b03801686602001516001600160a01b0316146129e05760006129e2565b815b9050876001600160a01b031663e5aa6d058286856040518463ffffffff1660e01b8152600401612a13929190614e9c565b6000604051808303818588803b158015612a2c57600080fd5b505af1158015612a40573d6000803e3d6000fd5b505060405163e897effb60e01b815260048101869052600093506001600160a01b038c16925063e897effb915060240160206040518083038186803b158015612a8857600080fd5b505afa158015612a9c573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612ac09190614cfc565b90506000612add8860000151896020015184876116459190615094565b9050612aec86868a8d8b6135ae565b60405162197ac760e01b8152600481018290526001600160a01b038b169062197ac790602401600060405180830381600087803b158015612b2c57600080fd5b505af1158015612b40573d6000803e3d6000fd5b5050895160208b0151612b5b93509091506117498588615094565b50612b7f33612b6a8487615094565b60208b01516001600160a01b031691906140fa565b60005b8651811015612c8c5760006001600160a01b0316878281518110612bb657634e487b7160e01b600052603260045260246000fd5b60200260200101516001600160a01b031614612c7a578a6001600160a01b0316878281518110612bf657634e487b7160e01b600052603260045260246000fd5b60200260200101516001600160a01b03167f60b8242c7715592d395c118b86e1c56e483030f45fab92e8694eda9f1a837f5e888481518110612c4857634e487b7160e01b600052603260045260246000fd5b602002602001015133604051612c719291909182526001600160a01b0316602082015260400190565b60405180910390a35b612c85600182615094565b9050612b82565b505060016002555050505050505050505050565b6060806000865167ffffffffffffffff811115612ccd57634e487b7160e01b600052604160045260246000fd5b604051908082528060200260200182016040528015612cf6578160200160208202803683370190505b5092506000875167ffffffffffffffff811115612d2357634e487b7160e01b600052604160045260246000fd5b604051908082528060200260200182016040528015612d4c578160200160208202803683370190505b5090506000885167ffffffffffffffff811115612d7957634e487b7160e01b600052604160045260246000fd5b604051908082528060200260200182016040528015612da2578160200160208202803683370190505b50905060005b8951811015612e3857886040015167ffffffffffffffff16828281518110612de057634e487b7160e01b600052603260045260246000fd5b602002602001018181525050886060015167ffffffffffffffff16838281518110612e1b57634e487b7160e01b600052603260045260246000fd5b6020908102919091010152612e31600182615094565b9050612da8565b506040516313849cfd60e21b81526001600160a01b03871690634e1273f490612e67908c908690600401614e6e565b60006040518083038186803b158015612e7f57600080fd5b505afa158015612e93573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f19168201604052612ebb9190810190614b7a565b93506000866001600160a01b0316634e1273f48b846040518363ffffffff1660e01b8152600401612eed929190614e6e565b60006040518083038186803b158015612f0557600080fd5b505afa158015612f19573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f19168201604052612f419190810190614b7a565b90506000805b8b518110156131e457896001600160a01b03166390d7bfae888381518110612f7f57634e487b7160e01b600052603260045260246000fd5b602002602001015160016040518363ffffffff1660e01b8152600401612fb19291909182521515602082015260400190565b60206040518083038186803b158015612fc957600080fd5b505afa158015612fdd573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906130019190614cfc565b91508183828151811061302457634e487b7160e01b600052603260045260246000fd5b6020026020010151101561318f578b818151811061305257634e487b7160e01b600052603260045260246000fd5b602002602001015188828151811061307a57634e487b7160e01b600052603260045260246000fd5b60200260200101906001600160a01b031690816001600160a01b031681525050896001600160a01b031663df6360a68983815181106130c957634e487b7160e01b600052603260045260246000fd5b60200260200101516040518263ffffffff1660e01b81526004016130fc91906001600160a01b0391909116815260200190565b60206040518083038186803b15801561311457600080fd5b505afa158015613128573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061314c9190614cfc565b87828151811061316c57634e487b7160e01b600052603260045260246000fd5b602002602001015161317e9190615094565b6131889087615094565b95506131d2565b60008882815181106131b157634e487b7160e01b600052603260045260246000fd5b60200260200101906001600160a01b031690816001600160a01b0316815250505b6131dd600182615094565b9050612f47565b50505050509450945094915050565b600080600660009054906101000a90046001600160a01b03166001600160a01b031663ad5c46486040518163ffffffff1660e01b815260040160206040518083038186803b15801561324457600080fd5b505afa158015613258573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061327c91906149ba565b905060606001600160a01b0386811614806132a85750816001600160a01b0316866001600160a01b0316145b1561335657604080516002808252606082018352909160208301908036833701905050905081816000815181106132ef57634e487b7160e01b600052603260045260246000fd5b60200260200101906001600160a01b031690816001600160a01b031681525050848160018151811061333157634e487b7160e01b600052603260045260246000fd5b60200260200101906001600160a01b031690816001600160a01b0316815250506134ef565b6001600160a01b03858116148061337e5750816001600160a01b0316856001600160a01b0316145b1561340757604080516002808252606082018352909160208301908036833701905050905085816000815181106133c557634e487b7160e01b600052603260045260246000fd5b60200260200101906001600160a01b031690816001600160a01b031681525050818160018151811061333157634e487b7160e01b600052603260045260246000fd5b604080516003808252608082019092529060208201606080368337019050509050858160008151811061344a57634e487b7160e01b600052603260045260246000fd5b60200260200101906001600160a01b031690816001600160a01b031681525050818160018151811061348c57634e487b7160e01b600052603260045260246000fd5b60200260200101906001600160a01b031690816001600160a01b03168152505084816002815181106134ce57634e487b7160e01b600052603260045260246000fd5b60200260200101906001600160a01b031690816001600160a01b0316815250505b6006546040516307c0329d60e21b81526000916001600160a01b031690631f00ca74906135229088908690600401614fd9565b60006040518083038186803b15801561353a57600080fd5b505afa15801561354e573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f191682016040526135769190810190614b7a565b90508060008151811061359957634e487b7160e01b600052603260045260246000fd5b602002602001015193505050505b9392505050565b60008060005b87518110156138da5760006001600160a01b03168882815181106135e857634e487b7160e01b600052603260045260246000fd5b60200260200101516001600160a01b0316146138c857846001600160a01b031663e897effb88838151811061362d57634e487b7160e01b600052603260045260246000fd5b60200260200101516040518263ffffffff1660e01b815260040161365391815260200190565b60206040518083038186803b15801561366b57600080fd5b505afa15801561367f573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906136a39190614cfc565b92506136e586600001518760200151858a85815181106136d357634e487b7160e01b600052603260045260246000fd5b60200260200101516116459190615094565b9150836001600160a01b031663f5298aca89838151811061371657634e487b7160e01b600052603260045260246000fd5b602002602001015188606001518a858151811061374357634e487b7160e01b600052603260045260246000fd5b60209081029190910101516040516001600160e01b031960e086901b1681526001600160a01b03909316600484015267ffffffffffffffff90911660248301526044820152606401600060405180830381600087803b1580156137a557600080fd5b505af11580156137b9573d6000803e3d6000fd5b50505050836001600160a01b031663f5298aca8983815181106137ec57634e487b7160e01b600052603260045260246000fd5b60209081029190910101516040808a015190516001600160e01b031960e085901b1681526001600160a01b03909216600483015267ffffffffffffffff16602482015260448101859052606401600060405180830381600087803b15801561385357600080fd5b505af1158015613867573d6000803e3d6000fd5b505050506138c888828151811061388e57634e487b7160e01b600052603260045260246000fd5b602002602001015187602001518984815181106138bb57634e487b7160e01b600052603260045260246000fd5b60200260200101516141d0565b6138d3600182615094565b90506135b4565b5050505050505050565b60008115613b43576000806001600160a01b038881161415613909576012915061397d565b876001600160a01b031663313ce5676040518163ffffffff1660e01b815260040160206040518083038186803b15801561394257600080fd5b505afa158015613956573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061397a9190614d4c565b91505b6001600160a01b03878116141561399657506012613a0a565b866001600160a01b031663313ce5676040518163ffffffff1660e01b815260040160206040518083038186803b1580156139cf57600080fd5b505afa1580156139e3573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613a079190614d4c565b90505b600086613a1b60ff8416600a61510f565b613a2590886151b7565b613a2f91906150ac565b60055460405163721adea760e01b81526001600160a01b038c811660048301528b8116602483015260ff871660448301529293506000929091169063721adea79060640160206040518083038186803b158015613a8b57600080fd5b505afa158015613a9f573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613ac39190614cfc565b90506000818311613add57613ad883836151d6565b613ae7565b613ae782846151d6565b9050600282613af76064846151b7565b613b0191906150ac565b106040518060400160405280600381526020016231323960e81b81525090613b3c5760405162461bcd60e51b81526004016104659190614ebe565b5050505050505b600654604080516315ab88c960e31b815290516000926001600160a01b03169163ad5c4648916004808301926020929190829003018186803b158015613b8857600080fd5b505afa158015613b9c573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613bc091906149ba565b90506060806001600160a01b038981161415613cfc5760408051600280825260608201835290916020830190803683370190505091508282600081518110613c1857634e487b7160e01b600052603260045260246000fd5b60200260200101906001600160a01b031690816001600160a01b0316815250508782600181518110613c5a57634e487b7160e01b600052603260045260246000fd5b6001600160a01b03928316602091820292909201015260065460405163fb3bdb4160e01b815291169063fb3bdb41908890613c9f908b90879030904290600401614ff2565b6000604051808303818588803b158015613cb857600080fd5b505af1158015613ccc573d6000803e3d6000fd5b50505050506040513d6000823e601f3d908101601f19168201604052613cf59190810190614b7a565b90506140b9565b6001600160a01b038881161415613e475760408051600280825260608201835290916020830190803683370190505091508882600081518110613d4f57634e487b7160e01b600052603260045260246000fd5b60200260200101906001600160a01b031690816001600160a01b0316815250508282600181518110613d9157634e487b7160e01b600052603260045260246000fd5b6001600160a01b039283166020918202929092010152600654613db9918b811691168861445d565b600654604051632512eca560e11b81526001600160a01b0390911690634a25d94a90613df1908a908a90879030904290600401615027565b600060405180830381600087803b158015613e0b57600080fd5b505af1158015613e1f573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f19168201604052613cf59190810190614b7a565b826001600160a01b0316896001600160a01b03161480613e785750826001600160a01b0316886001600160a01b0316145b15613f265760408051600280825260608201835290916020830190803683370190505091508882600081518110613ebf57634e487b7160e01b600052603260045260246000fd5b60200260200101906001600160a01b031690816001600160a01b0316815250508782600181518110613f0157634e487b7160e01b600052603260045260246000fd5b60200260200101906001600160a01b031690816001600160a01b03168152505061400e565b6040805160038082526080820190925290602082016060803683370190505091508882600081518110613f6957634e487b7160e01b600052603260045260246000fd5b60200260200101906001600160a01b031690816001600160a01b0316815250508282600181518110613fab57634e487b7160e01b600052603260045260246000fd5b60200260200101906001600160a01b031690816001600160a01b0316815250508782600281518110613fed57634e487b7160e01b600052603260045260246000fd5b60200260200101906001600160a01b031690816001600160a01b0316815250505b600654614028906001600160a01b038b811691168861445d565b600654604051634401edf760e11b81526001600160a01b0390911690638803dbee90614060908a908a90879030904290600401615027565b600060405180830381600087803b15801561407a57600080fd5b505af115801561408e573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f191682016040526140b69190810190614b7a565b90505b806000815181106140da57634e487b7160e01b600052603260045260246000fd5b6020026020010151866140ed91906151d6565b9998505050505050505050565b80156141cb5761410983614589565b156141b7576000826001600160a01b03168260405160006040518083038185875af1925050503d806000811461415b576040519150601f19603f3d011682016040523d82523d6000602084013e614160565b606091505b50509050806141b15760405162461bcd60e51b815260206004820152601460248201527f4661696c656420746f2073656e642045746865720000000000000000000000006044820152606401610465565b50505050565b6141cb6001600160a01b03841683836145af565b505050565b6007546001600160a01b0316156141cb57600754604080516301d9da0560e71b815290516001600160a01b0390921691600091839163eced028091600480820192602092909190829003018186803b15801561422b57600080fd5b505afa15801561423f573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906142639190614cfc565b90506000846001600160a01b031663313ce5676040518163ffffffff1660e01b815260040160206040518083038186803b1580156142a057600080fd5b505afa1580156142b4573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906142d89190614d4c565b60ff16905081600114801561435f5750604051630642194560e41b81523060048201526001600160a01b0384169063642194509060240160206040518083038186803b15801561432757600080fd5b505afa15801561433b573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061435f9190614c22565b156143d5576040516304a59e4560e51b81526001600160a01b0387811660048301526024820186905260016044830152606482018390528416906394b3c8a090608401600060405180830381600087803b1580156143bc57600080fd5b505af11580156143d0573d6000803e3d6000fd5b505050505b505050505050565b6040516001600160a01b03808516602483015283166044820152606481018290526141b19085906323b872dd60e01b906084015b60408051601f198184030181529190526020810180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff166001600160e01b0319909316929092179091526145df565b61446683614589565b156144b35760405162461bcd60e51b815260206004820152601560248201527f417070726f76652063616c6c6564206f6e2045544800000000000000000000006044820152606401610465565b806144cd576141cb6001600160a01b0384168360006146b1565b604051636eb1769f60e11b81523060048201526001600160a01b0383811660248301526000919085169063dd62ed3e9060440160206040518083038186803b15801561451857600080fd5b505afa15801561452c573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906145509190614cfc565b9050818110156141b1578015614575576145756001600160a01b0385168460006146b1565b6141b16001600160a01b03851684846146b1565b60006001600160a01b03821615806145a957506001600160a01b03828116145b92915050565b6040516001600160a01b0383166024820152604481018290526141cb90849063a9059cbb60e01b90606401614411565b6000614634826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b03166147dc9092919063ffffffff16565b8051909150156141cb57808060200190518101906146529190614c22565b6141cb5760405162461bcd60e51b815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e6044820152691bdd081cdd58d8d9595960b21b6064820152608401610465565b80158061473a5750604051636eb1769f60e11b81523060048201526001600160a01b03838116602483015284169063dd62ed3e9060440160206040518083038186803b15801561470057600080fd5b505afa158015614714573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906147389190614cfc565b155b6147ac5760405162461bcd60e51b815260206004820152603660248201527f5361666545524332303a20617070726f76652066726f6d206e6f6e2d7a65726f60448201527f20746f206e6f6e2d7a65726f20616c6c6f77616e6365000000000000000000006064820152608401610465565b6040516001600160a01b0383166024820152604481018290526141cb90849063095ea7b360e01b90606401614411565b60606147eb84846000856147f3565b949350505050565b6060824710156148545760405162461bcd60e51b815260206004820152602660248201527f416464726573733a20696e73756666696369656e742062616c616e636520666f6044820152651c8818d85b1b60d21b6064820152608401610465565b843b6148a25760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e74726163740000006044820152606401610465565b600080866001600160a01b031685876040516148be9190614dfc565b60006040518083038185875af1925050503d80600081146148fb576040519150601f19603f3d011682016040523d82523d6000602084013e614900565b606091505b509150915061491082828661491b565b979650505050505050565b6060831561492a5750816135a7565b82511561493a5782518084602001fd5b8160405162461bcd60e51b81526004016104659190614ebe565b60008083601f840112614965578182fd5b50813567ffffffffffffffff81111561497c578182fd5b6020830191508360208260051b850101111561499757600080fd5b9250929050565b6000602082840312156149af578081fd5b81356135a781615245565b6000602082840312156149cb578081fd5b81516135a781615245565b600080600080608085870312156149eb578283fd5b84356149f681615245565b93506020850135614a0681615245565b93969395505050506040820135916060013590565b600080600060408486031215614a2f578283fd5b833567ffffffffffffffff811115614a45578384fd5b614a5186828701614954565b9094509250506020840135614a6581615245565b809150509250925092565b60008060008060608587031215614a85578384fd5b843567ffffffffffffffff811115614a9b578485fd5b614aa787828801614954565b9095509350506020850135614abb81615245565b91506040850135614acb81615273565b939692955090935050565b60008060008060008060008060c0898b031215614af1578384fd5b883567ffffffffffffffff80821115614b08578586fd5b614b148c838d01614954565b909a50985060208b0135915080821115614b2c578586fd5b50614b398b828c01614954565b9097509550506040890135614b4d81615245565b93506060890135614b5d81615245565b979a969950949793969295929450505060808201359160a0013590565b60006020808385031215614b8c578182fd5b825167ffffffffffffffff80821115614ba3578384fd5b818501915085601f830112614bb6578384fd5b815181811115614bc857614bc861522f565b8060051b9150614bd9848301615063565b8181528481019084860184860187018a1015614bf3578788fd5b8795505b83861015614c15578051835260019590950194918601918601614bf7565b5098975050505050505050565b600060208284031215614c33578081fd5b815180151581146135a7578182fd5b600080600060608486031215614c56578081fd5b833592506020840135614c6881615245565b91506040840135614a6581615273565b600060808284031215614c89578081fd5b6040516080810181811067ffffffffffffffff82111715614cac57614cac61522f565b6040528251614cba81615245565b81526020830151614cca81615245565b60208201526040830151614cdd8161525d565b60408201526060830151614cf08161525d565b60608201529392505050565b600060208284031215614d0d578081fd5b5051919050565b60008060408385031215614d26578182fd5b8235614d318161525d565b91506020830135614d418161525d565b809150509250929050565b600060208284031215614d5d578081fd5b81516135a781615273565b6000815180845260208085019450808401835b83811015614da05781516001600160a01b031687529582019590820190600101614d7b565b509495945050505050565b6000815180845260208085019450808401835b83811015614da057815187529582019590820190600101614dbe565b60038110614df857634e487b7160e01b600052602160045260246000fd5b9052565b60008251614e0e8184602087016151ed565b9190910192915050565b6040808252810183905260008460608301825b86811015614e5b578235614e3e81615245565b6001600160a01b0316825260209283019290910190600101614e2b565b5060209390930193909352509392505050565b604081526000614e816040830185614d68565b8281036020840152614e938185614dab565b95945050505050565b604081526000614eaf6040830185614d68565b90508260208301529392505050565b6020815260008251806020840152614edd8160408501602087016151ed565b601f01601f19169190910160400192915050565b60408152614f03604082018451614dda565b60006020840151614f1f60608401826001600160a01b03169052565b506040840151608083015260608401516001600160a01b03811660a08401525060808401516001600160a01b03811660c08401525060a08401516101208060e0850152614f70610160850183614d68565b915060c0860151610100603f198685030181870152614f8f8483614dab565b935060e08801519150614fac838701836001600160a01b03169052565b8701516001600160a01b0381166101408701529150614fc89050565b5060ff8416602084015290506135a7565b8281526040602082015260006147eb6040830184614d68565b84815260806020820152600061500b6080830186614d68565b6001600160a01b03949094166040830152506060015292915050565b85815284602082015260a06040820152600061504660a0830186614d68565b6001600160a01b0394909416606083015250608001529392505050565b604051601f8201601f1916810167ffffffffffffffff8111828210171561508c5761508c61522f565b604052919050565b600082198211156150a7576150a7615219565b500190565b6000826150c757634e487b7160e01b81526012600452602481fd5b500490565b600181815b808511156151075781600019048211156150ed576150ed615219565b808516156150fa57918102915b93841c93908002906150d1565b509250929050565b60006135a78383600082615125575060016145a9565b81615132575060006145a9565b816001811461514857600281146151525761516e565b60019150506145a9565b60ff84111561516357615163615219565b50506001821b6145a9565b5060208310610133831016604e8410600b8410161715615191575081810a6145a9565b61519b83836150cc565b80600019048211156151af576151af615219565b029392505050565b60008160001904831182151516156151d1576151d1615219565b500290565b6000828210156151e8576151e8615219565b500390565b60005b838110156152085781810151838201526020016151f0565b838111156141b15750506000910152565b634e487b7160e01b600052601160045260246000fd5b634e487b7160e01b600052604160045260246000fd5b6001600160a01b038116811461525a57600080fd5b50565b67ffffffffffffffff8116811461525a57600080fd5b60ff8116811461525a57600080fdfea2646970667358221220a058b5c0c4bf25e856395692f8b9128f65e6576f3bbdd3f0c5bfce009668dec964736f6c63430008040033

Block Transaction Gas Used Reward
Age Block Fee Address BC Fee Address Voting Power Jailed Incoming
Validator ID :
0 FTM

Amount Staked
0

Amount Delegated
0

Staking Total
0

Staking Start Epoch
0

Staking Start Time
0

Proof of Importance
0

Origination Score
0

Validation Score
0

Active
0

Online
0

Downtime
0 s
Address Amount claimed Rewards Created On Epoch Created On
Block Uncle Number Difficulty Gas Used Reward
Loading
Loading
Make sure to use the "Vote Down" button for any spammy posts, and the "Vote Up" for interesting conversations.