Contract 0xFE700D523094Cc6C673d78F1446AE0743C89586E 4

DeFi  
 
 
Txn Hash Method
Block
From
To
Value [Txn Fee]
0xc08c4f4352e901ea7aa4320bafa5168cb52ade7253d73ae63e99ecfb45797c30Change Liquidity206789812021-10-27 20:18:21331 days 19 hrs ago0x424198579844b0d6f13c3a6b83b9cf987af9c545 IN  Tetu: Liquidity Balancer0 MATIC0.00419817636
0x5726975a78bb6a93f83e6dd74e6f128cd044814f3e49f9e34c780c3847c9aa8cChange Liquidity206786892021-10-27 20:08:17331 days 19 hrs ago0x424198579844b0d6f13c3a6b83b9cf987af9c545 IN  Tetu: Liquidity Balancer0 MATIC0.00419817636
0x0305d6661653b81512c0c0d52c545983709e148a2a32830526160080c343bd5bChange Liquidity206783972021-10-27 19:58:13331 days 19 hrs ago0x424198579844b0d6f13c3a6b83b9cf987af9c545 IN  Tetu: Liquidity Balancer0 MATIC0.0050797929643.56
0xc5df635f4e5885d03f7a87c5653ecd13654b31e1c5fbaa9f30c15e2f6ae22923Change Liquidity206781702021-10-27 19:46:33331 days 19 hrs ago0x424198579844b0d6f13c3a6b83b9cf987af9c545 IN  Tetu: Liquidity Balancer0 MATIC0.00419817636
0x083948550a61fadd6ecb995014e6e2c1c99780303613b807abbbdfa71eac49cbChange Liquidity206779402021-10-27 19:36:29331 days 20 hrs ago0x424198579844b0d6f13c3a6b83b9cf987af9c545 IN  Tetu: Liquidity Balancer0 MATIC0.00419817636
0x2d3e3ffe96b0e8cc700af737afa740e42012803ebcb591ac7c570c4ec45ba658Change Liquidity206777072021-10-27 19:26:23331 days 20 hrs ago0x424198579844b0d6f13c3a6b83b9cf987af9c545 IN  Tetu: Liquidity Balancer0 MATIC0.0069969660
0x26cb8ac271cfc937fe369c0b0b5cf6add1dfc990e276857e2b841bc7925ee866Change Liquidity206774772021-10-27 19:16:19331 days 20 hrs ago0x424198579844b0d6f13c3a6b83b9cf987af9c545 IN  Tetu: Liquidity Balancer0 MATIC0.00419817636
0xfa03eaf227a3d66f2819bda49afd6202473aa89e36339c5603637fb6ff683684Change Liquidity206772462021-10-27 19:06:13331 days 20 hrs ago0x424198579844b0d6f13c3a6b83b9cf987af9c545 IN  Tetu: Liquidity Balancer0 MATIC0.00419817636
0xbc384af096210ae549b9ae4b0fb921fb9d167f49e928aa0fccb5652089976dc8Change Liquidity206770142021-10-27 18:56:09331 days 20 hrs ago0x424198579844b0d6f13c3a6b83b9cf987af9c545 IN  Tetu: Liquidity Balancer0 MATIC0.00419817636
0x21d4732a5c2f6f830b0b577b0cec42f65cc325d2058045b681f2813c910a36e6Change Liquidity206767212021-10-27 18:46:03331 days 20 hrs ago0x424198579844b0d6f13c3a6b83b9cf987af9c545 IN  Tetu: Liquidity Balancer0 MATIC0.00419817636
0xf90025e1068bc9bc08a1f01201aaf2537ed0c8d46b3ddbe7d4aaa2fa009e7f52Change Liquidity206765162021-10-27 18:35:59331 days 21 hrs ago0x424198579844b0d6f13c3a6b83b9cf987af9c545 IN  Tetu: Liquidity Balancer0 MATIC0.00419817636
0x2967cdd91e063429e789356ad912d7c699944d0a259814adf7e4f27e9aa59579Change Liquidity206762542021-10-27 18:25:45331 days 21 hrs ago0x424198579844b0d6f13c3a6b83b9cf987af9c545 IN  Tetu: Liquidity Balancer0 MATIC0.00419817636
0x9a194a923dc1cbce8dc29a196695e82718a060fae62e01460fdb8854edb40ef4Change Liquidity206759612021-10-27 18:15:39331 days 21 hrs ago0x424198579844b0d6f13c3a6b83b9cf987af9c545 IN  Tetu: Liquidity Balancer0 MATIC0.00419817636
0x1878f56b563ba8efe38a5672e30e65fe0917f7bdc08f54774dba470f473b30faChange Liquidity206757202021-10-27 18:05:35331 days 21 hrs ago0x424198579844b0d6f13c3a6b83b9cf987af9c545 IN  Tetu: Liquidity Balancer0 MATIC0.00419817636
0x6f2a93c140928eedcfb5f026fd63ccab701d208d8ae6f0b754aa427f5db69787Change Liquidity206754982021-10-27 17:55:29331 days 21 hrs ago0x424198579844b0d6f13c3a6b83b9cf987af9c545 IN  Tetu: Liquidity Balancer0 MATIC0.00419817636
0xfd113fd350f59939d375969c29c4a98b2a324237d33481b8b8258b50bdc48479Change Liquidity206752042021-10-27 17:45:25331 days 21 hrs ago0x424198579844b0d6f13c3a6b83b9cf987af9c545 IN  Tetu: Liquidity Balancer0 MATIC0.00419817636
0x2c229468f6091ea28b5439c4b23ab427e53821a72208e24ee01f80a0265eba5fChange Liquidity206749382021-10-27 17:31:47331 days 22 hrs ago0x424198579844b0d6f13c3a6b83b9cf987af9c545 IN  Tetu: Liquidity Balancer0 MATIC0.00629726454
0xc6fe515a6e8df5ef5e8e618ab152eb283f3dcd108a578798802c141ab3a0ac7fChange Liquidity206747002021-10-27 17:21:41331 days 22 hrs ago0x424198579844b0d6f13c3a6b83b9cf987af9c545 IN  Tetu: Liquidity Balancer0 MATIC0.00629726454
0xfec02e08460dccf8083f34db44f187df7250be1e01ab047b581afba6ce8bb613Change Liquidity206744822021-10-27 17:11:35331 days 22 hrs ago0x424198579844b0d6f13c3a6b83b9cf987af9c545 IN  Tetu: Liquidity Balancer0 MATIC0.0069969660
0x4f118ede89213cd5b8bb01e0be62b7bc771770279a3c9dd07cb118d25e22866fChange Liquidity206742392021-10-27 17:01:31331 days 22 hrs ago0x424198579844b0d6f13c3a6b83b9cf987af9c545 IN  Tetu: Liquidity Balancer0 MATIC0.00419817636
0x2c844439779d68d0e79974955760abe3de3bd7a0e35db4e000ea3d6629e3f846Change Liquidity206740062021-10-27 16:51:25331 days 22 hrs ago0x424198579844b0d6f13c3a6b83b9cf987af9c545 IN  Tetu: Liquidity Balancer0 MATIC0.00419817636
0xcc4080d2a057e14ec4f5c4ebf6c5ff07142559f3b45a2d690ccf0595b83537a8Change Liquidity206737762021-10-27 16:41:21331 days 22 hrs ago0x424198579844b0d6f13c3a6b83b9cf987af9c545 IN  Tetu: Liquidity Balancer0 MATIC0.0006996966
0x405142c50920e0080e8df57fc7de6d1b11d06b36114653fb42f4e408bc354027Change Liquidity206734812021-10-27 16:31:15331 days 23 hrs ago0x424198579844b0d6f13c3a6b83b9cf987af9c545 IN  Tetu: Liquidity Balancer0 MATIC0.004617993639.6
0x30ef27ba91e42f86bdd25cdaba04afad25a1bb2c8c0d29fede55b5ef2e42b3f4Change Liquidity206732822021-10-27 16:20:15331 days 23 hrs ago0x424198579844b0d6f13c3a6b83b9cf987af9c545 IN  Tetu: Liquidity Balancer0 MATIC0.00419817636
0x2899a59fcd9bb6b50b0386f76dff1bbeac3ad0b2b1bc2f672ca13eb4ae0ea977Change Liquidity206729862021-10-27 16:09:57331 days 23 hrs ago0x424198579844b0d6f13c3a6b83b9cf987af9c545 IN  Tetu: Liquidity Balancer0 MATIC0.00419817636
[ Download CSV Export 
Parent Txn Hash Block From To Value
Loading

Contract Source Code Verified (Exact Match)

Contract Name:
LiquidityBalancer

Compiler Version
v0.8.4+commit.c7e474f2

Optimization Enabled:
Yes with 200 runs

Other Settings:
default evmVersion

Contract Source Code (Solidity Standard Json-Input format)

File 1 of 16 : LiquidityBalancer.sol
// SPDX-License-Identifier: ISC
/**
* By using this software, you understand, acknowledge and accept that Tetu
* and/or the underlying software are provided “as is” and “as available”
* basis and without warranties or representations of any kind either expressed
* or implied. Any use of this open source software released under the ISC
* Internet Systems Consortium license is done at your own risk to the fullest
* extent permissible pursuant to applicable law any and all liability as well
* as all warranties, including any fitness for a particular purpose with respect
* to Tetu and/or the underlying software and the use thereof are disclaimed.
*/

pragma solidity 0.8.4;

import "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol";
import "@openzeppelin/contracts/utils/Address.sol";
import "@openzeppelin/contracts/utils/math/SafeMath.sol";
import "@openzeppelin/contracts/token/ERC20/ERC20.sol";
import "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";
import "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol";
import "@openzeppelin/contracts/utils/math/Math.sol";
import "../base/governance/Controllable.sol";
import "../third_party/uniswap/IUniswapV2Pair.sol";
import "../third_party/uniswap/IUniswapV2Router02.sol";

/// @title LiquidityBalancer sells a portion of the available amount of
///        TETU Tokens when the price hits the target price and immediately
///        adds equilibrated amount of both tokens to liquidity.
///        After each sale the target price increases.
/// @author belbix
contract LiquidityBalancer is Controllable {
  using SafeERC20 for IERC20;
  using Address for address;
  using SafeMath for uint256;

  string public constant VERSION = "1.0.0";
  uint256 constant internal PRECISION = 10 ** 18;
  uint256 public targetPriceUpdateNumerator = 100; // 0.1 % by default
  uint256 public targetTvlUpdateNumerator = 100; // 0.1 % by default
  uint256 public removeLiqRatioNumerator = 100; // 0.1 % by default
  uint256 constant public DENOMINATOR = 100000;

  mapping(address => uint256) public priceTargets;
  mapping(address => uint256) public lpTvlTargets;
  mapping(address => address) public routers;
  address[] internal route;

  event PriceTargetChanged(address token, uint256 target);
  event LpTvlTargetChanged(address lp, uint256 target);
  event RouterChanged(address lp, address router);
  event PriceNumeratorChanged(uint256 value);
  event TvlNumeratorChanged(uint256 value);
  event RemLiqNumeratorChanged(uint256 value);
  event Swap(address tokenIn, address tokenOut, uint256 amount);
  event LiqAdded(address lp, uint256 amount0, uint256 amount1);
  event LiqRemoved(address lp, uint256 amount);
  event TokenMoved(address token, uint256 amount);

  constructor(address _controller) {
    Controllable.initializeControllable(_controller);
  }

  modifier onlyHardWorkerOrController() {
    require(IController(controller()).isHardWorker(msg.sender)
      || controller() == msg.sender, "only hardworker or controller");
    _;
  }

  function changeLiquidity(address _token, address _lp) external onlyHardWorkerOrController {
    require(priceTargets[_token] != 0, "zero price target");
    require(lpTvlTargets[_lp] != 0, "zero lp tvl target");

    IUniswapV2Pair pair = IUniswapV2Pair(_lp);
    address oppositeToken = (_token == pair.token0()) ? pair.token1() : pair.token0();

    uint256 sellAmount = needToSell(_token, _lp);
    uint256 remAmount = needToRemove(_token, _lp);

    if (remAmount > 0) {
      removeLiquidity(_lp, remAmount, _token, oppositeToken);
      // buy target tokens
      route.push(oppositeToken);
      route.push(_token);
      swap(
        routers[_lp],
        route,
        IERC20(oppositeToken).balanceOf(address(this))
      );
      // update target price for avoid a tons of rebalancing cycles
      // also it means that we hit our global goal - price and TVL balanced
      (,, uint256 price,) = getLpInfo(_lp, _token);
      priceTargets[_token] = price;
      route.pop();
      route.pop();
      updateLpTvlTarget(_lp);
    } else if (sellAmount > 0) {
      // sell target token for opposite token
      route.push(_token);
      route.push(oppositeToken);
      swap(
        routers[_lp],
        route,
        sellAmount
      );
      route.pop();
      route.pop();
      addLiquidity(_lp, _token, oppositeToken);
      updatePriceTarget(_token);
    }
  }

  function needToSell(address _token, address _lp) public view returns (uint256) {
    uint256 tokenBalance = IERC20(_token).balanceOf(address(this));
    (, uint256 oppositeReserve, uint256 price, uint256 tokenReserve) = getLpInfo(_lp, _token);

    uint256 sellAmount = computeSellAmount(tokenReserve, oppositeReserve, priceTargets[_token]);

    uint256 sellCap = 0;
    // not enough money
    if (tokenBalance > sellAmount) {
      uint256 needForAddingLiq = computeOutputAmount(tokenReserve, oppositeReserve, sellAmount)
      .mul(PRECISION).div(priceTargets[_token]);
      uint256 balAfterSwap = tokenBalance.sub(sellAmount);
      // after the sell we will not have enough money for adding the liquidity
      // don't sell in this case
      // need to create an accurate amount computation
      if (balAfterSwap > needForAddingLiq) {
        sellCap = balAfterSwap.sub(needForAddingLiq);
      }
    }

    // after swap you should have amount for adding liquidity
    sellAmount = Math.min(sellAmount, sellCap);

    if (sellAmount > 0 && price > priceTargets[_token]) {
      // don't sell more than a half for adding a liquidity after sell
      return Math.min(sellAmount, sellCap);
    } else {
      return 0;
    }
  }

  function needToRemove(address _token, address _lp) public view returns (uint256) {
    uint256 lpBalance = IERC20(_lp).balanceOf(address(this));
    (, uint256 oppositeTokenStacked, ,) = getLpInfo(_lp, _token);
    uint256 currentTvl = oppositeTokenStacked.mul(2);

    uint256 remAmount = computeRemAmount(currentTvl, _lp);
    remAmount = Math.min(remAmount, lpBalance);

    if (remAmount > 0 && lpBalance >= remAmount && currentTvl > lpTvlTargets[_lp]) {
      uint256 result = Math.min(remAmount, lpBalance);
      result = result.mul(removeLiqRatioNumerator).div(DENOMINATOR);
      return result;
    } else {
      return 0;
    }
  }

  function computeSellAmount(
    uint256 tokenReserve,
    uint256 oppositeReserve,
    uint256 targetPrice
  ) internal pure returns (uint256) {
    if (targetPrice == 0) {
      return 0;
    }
    // ignore fees
    uint base = oppositeReserve.mul(tokenReserve).div(targetPrice).mul(PRECISION);
    uint256 sqrtBase = sqrt(base);
    if (sqrtBase < tokenReserve) {
      // in this case the price lower than target price, need to sell
      return 0;
    }
    return sqrtBase.sub(tokenReserve);
  }

  function computeOutputAmount(
    uint256 tokenReserve,
    uint256 oppositeReserve,
    uint256 inputAmount
  ) internal pure returns (uint256){
    if (tokenReserve == 0 && inputAmount == 0) {
      return 0;
    }
    return inputAmount.mul(oppositeReserve).div(tokenReserve.add(inputAmount));
  }

  function computeRemAmount(uint256 currentTvl, address _lp) internal view returns (uint256) {
    if (currentTvl == 0 || currentTvl < lpTvlTargets[_lp]) {
      // no remove require
      return 0;
    }
    uint256 remAmountRate = currentTvl.sub(lpTvlTargets[_lp]).mul(PRECISION).div(currentTvl);
    return ERC20(address(_lp)).totalSupply().mul(remAmountRate).div(PRECISION);
  }

  function updateLpTvlTarget(address _lp) internal {
    lpTvlTargets[_lp] = lpTvlTargets[_lp].add(
      lpTvlTargets[_lp].mul(targetTvlUpdateNumerator).div(DENOMINATOR)
    );
  }

  function updatePriceTarget(address _token) internal {
    priceTargets[_token] = priceTargets[_token].add(
      priceTargets[_token].mul(targetPriceUpdateNumerator).div(DENOMINATOR)
    );
  }

  // https://uniswap.org/docs/v2/smart-contracts/router02/#swapexacttokensfortokens
  function swap(address _router, address[] memory _route, uint256 _amount) internal {
    require(_router != address(0), "zero router");
    uint256 bal = IERC20(_route[0]).balanceOf(address(this));
    require(bal >= _amount, "not enough balance");
    IERC20(_route[0]).safeApprove(_router, 0);
    IERC20(_route[0]).safeApprove(_router, _amount);
    //slither-disable-next-line unused-return
    IUniswapV2Router02(_router).swapExactTokensForTokens(
      _amount,
      0,
      _route,
      address(this),
      block.timestamp
    );
    emit Swap(_route[0], _route[1], _amount);
  }

  function addLiquidity(address _lp, address token, address oppositeToken) internal {
    address routerAddress = routers[_lp];
    IUniswapV2Router02 router = IUniswapV2Router02(routerAddress);

    uint256 amount0 = IERC20(token).balanceOf(address(this));
    uint256 amount1 = IERC20(oppositeToken).balanceOf(address(this));

    IERC20(token).safeApprove(routerAddress, 0);
    IERC20(token).safeApprove(routerAddress, amount0);
    IERC20(oppositeToken).safeApprove(routerAddress, 0);
    IERC20(oppositeToken).safeApprove(routerAddress, amount1);
    //slither-disable-next-line unused-return
    router.addLiquidity(
      token,
      oppositeToken,
      amount0,
      amount1,
      1,
      1,
      address(this),
      block.timestamp
    );
    require(IERC20(oppositeToken).balanceOf(address(this)) == 0, "added not all");
    emit LiqAdded(_lp, amount0, amount1);
  }

  function removeLiquidity(address _lp, uint256 _amount, address token0, address token1) internal {
    uint256 bal = IERC20(_lp).balanceOf(address(this));
    require(bal >= _amount, "not enough balance");
    address routerAddress = routers[_lp];
    IUniswapV2Router02 router = IUniswapV2Router02(routerAddress);

    IERC20(_lp).safeApprove(routerAddress, 0);
    IERC20(_lp).safeApprove(routerAddress, _amount);
    //slither-disable-next-line unused-return
    router.removeLiquidity(
      token0,
      token1,
      _amount,
      1,
      1,
      address(this),
      block.timestamp
    );

    emit LiqRemoved(_lp, _amount);
  }

  function getLpInfo(address pairAddress, address targetToken)
  internal view returns (address oppositeToken, uint256 oppositeTokenStacked, uint256 price, uint256 tokenStacked) {
    IUniswapV2Pair pair = IUniswapV2Pair(pairAddress);
    address token0 = pair.token0();
    address token1 = pair.token1();
    uint256 token0Decimals = ERC20(token0).decimals();
    uint256 token1Decimals = ERC20(token1).decimals();

    (uint256 reserve0, uint256 reserve1,) = pair.getReserves();

    // both reserves should have the same decimals
    reserve0 = reserve0.mul(PRECISION).div(10 ** token0Decimals);
    reserve1 = reserve1.mul(PRECISION).div(10 ** token1Decimals);

    tokenStacked = (targetToken == token0) ? reserve0 : reserve1;
    oppositeTokenStacked = (targetToken == token0) ? reserve1 : reserve0;
    oppositeToken = (targetToken == token0) ? token1 : token0;

    if (targetToken == token0) {
      price = reserve1
      .mul(PRECISION)
      .div(reserve0);
    } else {
      price = reserve0
      .mul(PRECISION)
      .div(reserve1);
    }
    return (oppositeToken, oppositeTokenStacked, price, tokenStacked);
  }

  // uniswap square root implementation
  // babylonian method (https://en.wikipedia.org/wiki/Methods_of_computing_square_roots#Babylonian_method)
  function sqrt(uint256 y) internal pure returns (uint256 z) {
    if (y <= 0) {
      return 0;
    }
    if (y > 3) {
      z = y;
      uint256 x = y.div(2).add(1);
      while (x < z) {
        z = x;
        x = y.div(x).add(x).div(2);
      }
    } else if (y != 0) {
      z = 1;
    }
    return z;
  }

  // ***************** GOVERNANCE ACTIONS *********************

  // move tokens to controller where money will be protected with time lock
  function moveTokensToController(address _token, uint256 amount) external onlyControllerOrGovernance {
    uint256 tokenBalance = IERC20(_token).balanceOf(address(this));
    require(tokenBalance >= amount, "not enough balance");
    IERC20(_token).safeTransfer(controller(), amount);
    emit TokenMoved(_token, amount);
  }

  // should have PRECISION_DECIMALS
  function setTargetPrice(address _token, uint256 _target) external onlyControllerOrGovernance {
    require(_target != 0, "wrong target");
    require(_token != address(0), "wrong token");
    priceTargets[_token] = _target;
    emit PriceTargetChanged(_token, _target);
  }

  // should have PRECISION_DECIMALS
  function setTargetLpTvl(address _lp, uint256 _target) external onlyControllerOrGovernance {
    require(_target != 0, "wrong target");
    require(_lp != address(0), "wrong lp");
    lpTvlTargets[_lp] = _target;
    emit LpTvlTargetChanged(_lp, _target);
  }

  function setRouter(address _lp, address _router) external onlyControllerOrGovernance {
    require(_lp != address(0), "wrong lp");
    require(_router != address(0), "wrong router");
    routers[_lp] = _router;
    emit RouterChanged(_lp, _router);
  }

  function setTargetPriceUpdateNumerator(uint256 _numerator) external onlyControllerOrGovernance {
    require(_numerator > 0, "zero not allowed");
    require(_numerator < DENOMINATOR, "should be lower than denominator");
    targetPriceUpdateNumerator = _numerator;
    emit PriceNumeratorChanged(_numerator);
  }

  function setTargetTvlUpdateNumerator(uint256 _numerator) external onlyControllerOrGovernance {
    require(_numerator > 0, "zero not allowed");
    require(_numerator < DENOMINATOR, "should be lower than denominator");
    targetTvlUpdateNumerator = _numerator;
    emit TvlNumeratorChanged(_numerator);
  }

  function setRemoveLiqRatioNumerator(uint256 _numerator) external onlyControllerOrGovernance {
    require(_numerator > 0, "zero not allowed");
    require(_numerator <= DENOMINATOR, "should be lower or equal than denominator");
    removeLiqRatioNumerator = _numerator;
    emit RemLiqNumeratorChanged(_numerator);
  }

}

File 2 of 16 : Initializable.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.0;

/**
 * @dev This is a base contract to aid in writing upgradeable contracts, or any kind of contract that will be deployed
 * behind a proxy. Since a proxied contract can't have a constructor, it's common to move constructor logic to an
 * external initializer function, usually called `initialize`. It then becomes necessary to protect this initializer
 * function so it can only be called once. The {initializer} modifier provided by this contract will have this effect.
 *
 * TIP: To avoid leaving the proxy in an uninitialized state, the initializer function should be called as early as
 * possible by providing the encoded function call as the `_data` argument to {ERC1967Proxy-constructor}.
 *
 * CAUTION: When used with inheritance, manual care must be taken to not invoke a parent initializer twice, or to ensure
 * that all initializers are idempotent. This is not verified automatically as constructors are by Solidity.
 */
abstract contract Initializable {
    /**
     * @dev Indicates that the contract has been initialized.
     */
    bool private _initialized;

    /**
     * @dev Indicates that the contract is in the process of being initialized.
     */
    bool private _initializing;

    /**
     * @dev Modifier to protect an initializer function from being invoked twice.
     */
    modifier initializer() {
        require(_initializing || !_initialized, "Initializable: contract is already initialized");

        bool isTopLevelCall = !_initializing;
        if (isTopLevelCall) {
            _initializing = true;
            _initialized = true;
        }

        _;

        if (isTopLevelCall) {
            _initializing = false;
        }
    }
}

File 3 of 16 : 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);
    }

    function _verifyCallResult(
        bool success,
        bytes memory returndata,
        string memory errorMessage
    ) private 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 4 of 16 : SafeMath.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.0;

// CAUTION
// This version of SafeMath should only be used with Solidity 0.8 or later,
// because it relies on the compiler's built in overflow checks.

/**
 * @dev Wrappers over Solidity's arithmetic operations.
 *
 * NOTE: `SafeMath` is no longer needed starting with Solidity 0.8. The compiler
 * now has built in overflow checking.
 */
library SafeMath {
    /**
     * @dev Returns the addition of two unsigned integers, with an overflow flag.
     *
     * _Available since v3.4._
     */
    function tryAdd(uint256 a, uint256 b) internal pure returns (bool, uint256) {
        unchecked {
            uint256 c = a + b;
            if (c < a) return (false, 0);
            return (true, c);
        }
    }

    /**
     * @dev Returns the substraction of two unsigned integers, with an overflow flag.
     *
     * _Available since v3.4._
     */
    function trySub(uint256 a, uint256 b) internal pure returns (bool, uint256) {
        unchecked {
            if (b > a) return (false, 0);
            return (true, a - b);
        }
    }

    /**
     * @dev Returns the multiplication of two unsigned integers, with an overflow flag.
     *
     * _Available since v3.4._
     */
    function tryMul(uint256 a, uint256 b) internal pure returns (bool, uint256) {
        unchecked {
            // Gas optimization: this is cheaper than requiring 'a' not being zero, but the
            // benefit is lost if 'b' is also tested.
            // See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522
            if (a == 0) return (true, 0);
            uint256 c = a * b;
            if (c / a != b) return (false, 0);
            return (true, c);
        }
    }

    /**
     * @dev Returns the division of two unsigned integers, with a division by zero flag.
     *
     * _Available since v3.4._
     */
    function tryDiv(uint256 a, uint256 b) internal pure returns (bool, uint256) {
        unchecked {
            if (b == 0) return (false, 0);
            return (true, a / b);
        }
    }

    /**
     * @dev Returns the remainder of dividing two unsigned integers, with a division by zero flag.
     *
     * _Available since v3.4._
     */
    function tryMod(uint256 a, uint256 b) internal pure returns (bool, uint256) {
        unchecked {
            if (b == 0) return (false, 0);
            return (true, a % b);
        }
    }

    /**
     * @dev Returns the addition of two unsigned integers, reverting on
     * overflow.
     *
     * Counterpart to Solidity's `+` operator.
     *
     * Requirements:
     *
     * - Addition cannot overflow.
     */
    function add(uint256 a, uint256 b) internal pure returns (uint256) {
        return a + b;
    }

    /**
     * @dev Returns the subtraction of two unsigned integers, reverting on
     * overflow (when the result is negative).
     *
     * Counterpart to Solidity's `-` operator.
     *
     * Requirements:
     *
     * - Subtraction cannot overflow.
     */
    function sub(uint256 a, uint256 b) internal pure returns (uint256) {
        return a - b;
    }

    /**
     * @dev Returns the multiplication of two unsigned integers, reverting on
     * overflow.
     *
     * Counterpart to Solidity's `*` operator.
     *
     * Requirements:
     *
     * - Multiplication cannot overflow.
     */
    function mul(uint256 a, uint256 b) internal pure returns (uint256) {
        return a * b;
    }

    /**
     * @dev Returns the integer division of two unsigned integers, reverting on
     * division by zero. The result is rounded towards zero.
     *
     * Counterpart to Solidity's `/` operator.
     *
     * Requirements:
     *
     * - The divisor cannot be zero.
     */
    function div(uint256 a, uint256 b) internal pure returns (uint256) {
        return a / b;
    }

    /**
     * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
     * reverting when dividing by zero.
     *
     * Counterpart to Solidity's `%` operator. This function uses a `revert`
     * opcode (which leaves remaining gas untouched) while Solidity uses an
     * invalid opcode to revert (consuming all remaining gas).
     *
     * Requirements:
     *
     * - The divisor cannot be zero.
     */
    function mod(uint256 a, uint256 b) internal pure returns (uint256) {
        return a % b;
    }

    /**
     * @dev Returns the subtraction of two unsigned integers, reverting with custom message on
     * overflow (when the result is negative).
     *
     * CAUTION: This function is deprecated because it requires allocating memory for the error
     * message unnecessarily. For custom revert reasons use {trySub}.
     *
     * Counterpart to Solidity's `-` operator.
     *
     * Requirements:
     *
     * - Subtraction cannot overflow.
     */
    function sub(
        uint256 a,
        uint256 b,
        string memory errorMessage
    ) internal pure returns (uint256) {
        unchecked {
            require(b <= a, errorMessage);
            return a - b;
        }
    }

    /**
     * @dev Returns the integer division of two unsigned integers, reverting with custom message on
     * division by zero. The result is rounded towards zero.
     *
     * Counterpart to Solidity's `/` operator. Note: this function uses a
     * `revert` opcode (which leaves remaining gas untouched) while Solidity
     * uses an invalid opcode to revert (consuming all remaining gas).
     *
     * Requirements:
     *
     * - The divisor cannot be zero.
     */
    function div(
        uint256 a,
        uint256 b,
        string memory errorMessage
    ) internal pure returns (uint256) {
        unchecked {
            require(b > 0, errorMessage);
            return a / b;
        }
    }

    /**
     * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
     * reverting with custom message when dividing by zero.
     *
     * CAUTION: This function is deprecated because it requires allocating memory for the error
     * message unnecessarily. For custom revert reasons use {tryMod}.
     *
     * Counterpart to Solidity's `%` operator. This function uses a `revert`
     * opcode (which leaves remaining gas untouched) while Solidity uses an
     * invalid opcode to revert (consuming all remaining gas).
     *
     * Requirements:
     *
     * - The divisor cannot be zero.
     */
    function mod(
        uint256 a,
        uint256 b,
        string memory errorMessage
    ) internal pure returns (uint256) {
        unchecked {
            require(b > 0, errorMessage);
            return a % b;
        }
    }
}

File 5 of 16 : ERC20.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.0;

import "./IERC20.sol";
import "./extensions/IERC20Metadata.sol";
import "../../utils/Context.sol";

/**
 * @dev Implementation of the {IERC20} interface.
 *
 * This implementation is agnostic to the way tokens are created. This means
 * that a supply mechanism has to be added in a derived contract using {_mint}.
 * For a generic mechanism see {ERC20PresetMinterPauser}.
 *
 * TIP: For a detailed writeup see our guide
 * https://forum.zeppelin.solutions/t/how-to-implement-erc20-supply-mechanisms/226[How
 * to implement supply mechanisms].
 *
 * We have followed general OpenZeppelin guidelines: functions revert instead
 * of returning `false` on failure. This behavior is nonetheless conventional
 * and does not conflict with the expectations of ERC20 applications.
 *
 * Additionally, an {Approval} event is emitted on calls to {transferFrom}.
 * This allows applications to reconstruct the allowance for all accounts just
 * by listening to said events. Other implementations of the EIP may not emit
 * these events, as it isn't required by the specification.
 *
 * Finally, the non-standard {decreaseAllowance} and {increaseAllowance}
 * functions have been added to mitigate the well-known issues around setting
 * allowances. See {IERC20-approve}.
 */
contract ERC20 is Context, IERC20, IERC20Metadata {
    mapping(address => uint256) private _balances;

    mapping(address => mapping(address => uint256)) private _allowances;

    uint256 private _totalSupply;

    string private _name;
    string private _symbol;

    /**
     * @dev Sets the values for {name} and {symbol}.
     *
     * The default value of {decimals} is 18. To select a different value for
     * {decimals} you should overload it.
     *
     * All two of these values are immutable: they can only be set once during
     * construction.
     */
    constructor(string memory name_, string memory symbol_) {
        _name = name_;
        _symbol = symbol_;
    }

    /**
     * @dev Returns the name of the token.
     */
    function name() public view virtual override returns (string memory) {
        return _name;
    }

    /**
     * @dev Returns the symbol of the token, usually a shorter version of the
     * name.
     */
    function symbol() public view virtual override returns (string memory) {
        return _symbol;
    }

    /**
     * @dev Returns the number of decimals used to get its user representation.
     * For example, if `decimals` equals `2`, a balance of `505` tokens should
     * be displayed to a user as `5,05` (`505 / 10 ** 2`).
     *
     * Tokens usually opt for a value of 18, imitating the relationship between
     * Ether and Wei. This is the value {ERC20} uses, unless this function is
     * overridden;
     *
     * NOTE: This information is only used for _display_ purposes: it in
     * no way affects any of the arithmetic of the contract, including
     * {IERC20-balanceOf} and {IERC20-transfer}.
     */
    function decimals() public view virtual override returns (uint8) {
        return 18;
    }

    /**
     * @dev See {IERC20-totalSupply}.
     */
    function totalSupply() public view virtual override returns (uint256) {
        return _totalSupply;
    }

    /**
     * @dev See {IERC20-balanceOf}.
     */
    function balanceOf(address account) public view virtual override returns (uint256) {
        return _balances[account];
    }

    /**
     * @dev See {IERC20-transfer}.
     *
     * Requirements:
     *
     * - `recipient` cannot be the zero address.
     * - the caller must have a balance of at least `amount`.
     */
    function transfer(address recipient, uint256 amount) public virtual override returns (bool) {
        _transfer(_msgSender(), recipient, amount);
        return true;
    }

    /**
     * @dev See {IERC20-allowance}.
     */
    function allowance(address owner, address spender) public view virtual override returns (uint256) {
        return _allowances[owner][spender];
    }

    /**
     * @dev See {IERC20-approve}.
     *
     * Requirements:
     *
     * - `spender` cannot be the zero address.
     */
    function approve(address spender, uint256 amount) public virtual override returns (bool) {
        _approve(_msgSender(), spender, amount);
        return true;
    }

    /**
     * @dev See {IERC20-transferFrom}.
     *
     * Emits an {Approval} event indicating the updated allowance. This is not
     * required by the EIP. See the note at the beginning of {ERC20}.
     *
     * Requirements:
     *
     * - `sender` and `recipient` cannot be the zero address.
     * - `sender` must have a balance of at least `amount`.
     * - the caller must have allowance for ``sender``'s tokens of at least
     * `amount`.
     */
    function transferFrom(
        address sender,
        address recipient,
        uint256 amount
    ) public virtual override returns (bool) {
        _transfer(sender, recipient, amount);

        uint256 currentAllowance = _allowances[sender][_msgSender()];
        require(currentAllowance >= amount, "ERC20: transfer amount exceeds allowance");
        unchecked {
            _approve(sender, _msgSender(), currentAllowance - amount);
        }

        return true;
    }

    /**
     * @dev Atomically increases the allowance granted to `spender` by the caller.
     *
     * This is an alternative to {approve} that can be used as a mitigation for
     * problems described in {IERC20-approve}.
     *
     * Emits an {Approval} event indicating the updated allowance.
     *
     * Requirements:
     *
     * - `spender` cannot be the zero address.
     */
    function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) {
        _approve(_msgSender(), spender, _allowances[_msgSender()][spender] + addedValue);
        return true;
    }

    /**
     * @dev Atomically decreases the allowance granted to `spender` by the caller.
     *
     * This is an alternative to {approve} that can be used as a mitigation for
     * problems described in {IERC20-approve}.
     *
     * Emits an {Approval} event indicating the updated allowance.
     *
     * Requirements:
     *
     * - `spender` cannot be the zero address.
     * - `spender` must have allowance for the caller of at least
     * `subtractedValue`.
     */
    function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) {
        uint256 currentAllowance = _allowances[_msgSender()][spender];
        require(currentAllowance >= subtractedValue, "ERC20: decreased allowance below zero");
        unchecked {
            _approve(_msgSender(), spender, currentAllowance - subtractedValue);
        }

        return true;
    }

    /**
     * @dev Moves `amount` of tokens from `sender` to `recipient`.
     *
     * This internal function is equivalent to {transfer}, and can be used to
     * e.g. implement automatic token fees, slashing mechanisms, etc.
     *
     * Emits a {Transfer} event.
     *
     * Requirements:
     *
     * - `sender` cannot be the zero address.
     * - `recipient` cannot be the zero address.
     * - `sender` must have a balance of at least `amount`.
     */
    function _transfer(
        address sender,
        address recipient,
        uint256 amount
    ) internal virtual {
        require(sender != address(0), "ERC20: transfer from the zero address");
        require(recipient != address(0), "ERC20: transfer to the zero address");

        _beforeTokenTransfer(sender, recipient, amount);

        uint256 senderBalance = _balances[sender];
        require(senderBalance >= amount, "ERC20: transfer amount exceeds balance");
        unchecked {
            _balances[sender] = senderBalance - amount;
        }
        _balances[recipient] += amount;

        emit Transfer(sender, recipient, amount);

        _afterTokenTransfer(sender, recipient, amount);
    }

    /** @dev Creates `amount` tokens and assigns them to `account`, increasing
     * the total supply.
     *
     * Emits a {Transfer} event with `from` set to the zero address.
     *
     * Requirements:
     *
     * - `account` cannot be the zero address.
     */
    function _mint(address account, uint256 amount) internal virtual {
        require(account != address(0), "ERC20: mint to the zero address");

        _beforeTokenTransfer(address(0), account, amount);

        _totalSupply += amount;
        _balances[account] += amount;
        emit Transfer(address(0), account, amount);

        _afterTokenTransfer(address(0), account, amount);
    }

    /**
     * @dev Destroys `amount` tokens from `account`, reducing the
     * total supply.
     *
     * Emits a {Transfer} event with `to` set to the zero address.
     *
     * Requirements:
     *
     * - `account` cannot be the zero address.
     * - `account` must have at least `amount` tokens.
     */
    function _burn(address account, uint256 amount) internal virtual {
        require(account != address(0), "ERC20: burn from the zero address");

        _beforeTokenTransfer(account, address(0), amount);

        uint256 accountBalance = _balances[account];
        require(accountBalance >= amount, "ERC20: burn amount exceeds balance");
        unchecked {
            _balances[account] = accountBalance - amount;
        }
        _totalSupply -= amount;

        emit Transfer(account, address(0), amount);

        _afterTokenTransfer(account, address(0), amount);
    }

    /**
     * @dev Sets `amount` as the allowance of `spender` over the `owner` s tokens.
     *
     * This internal function is equivalent to `approve`, and can be used to
     * e.g. set automatic allowances for certain subsystems, etc.
     *
     * Emits an {Approval} event.
     *
     * Requirements:
     *
     * - `owner` cannot be the zero address.
     * - `spender` cannot be the zero address.
     */
    function _approve(
        address owner,
        address spender,
        uint256 amount
    ) internal virtual {
        require(owner != address(0), "ERC20: approve from the zero address");
        require(spender != address(0), "ERC20: approve to the zero address");

        _allowances[owner][spender] = amount;
        emit Approval(owner, spender, amount);
    }

    /**
     * @dev Hook that is called before any transfer of tokens. This includes
     * minting and burning.
     *
     * Calling conditions:
     *
     * - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens
     * will be transferred to `to`.
     * - when `from` is zero, `amount` tokens will be minted for `to`.
     * - when `to` is zero, `amount` of ``from``'s tokens will be burned.
     * - `from` and `to` are never both zero.
     *
     * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].
     */
    function _beforeTokenTransfer(
        address from,
        address to,
        uint256 amount
    ) internal virtual {}

    /**
     * @dev Hook that is called after any transfer of tokens. This includes
     * minting and burning.
     *
     * Calling conditions:
     *
     * - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens
     * has been transferred to `to`.
     * - when `from` is zero, `amount` tokens have been minted for `to`.
     * - when `to` is zero, `amount` of ``from``'s tokens have been burned.
     * - `from` and `to` are never both zero.
     *
     * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].
     */
    function _afterTokenTransfer(
        address from,
        address to,
        uint256 amount
    ) internal virtual {}
}

File 6 of 16 : 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 7 of 16 : 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 8 of 16 : Math.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.0;

/**
 * @dev Standard math utilities missing in the Solidity language.
 */
library Math {
    /**
     * @dev Returns the largest of two numbers.
     */
    function max(uint256 a, uint256 b) internal pure returns (uint256) {
        return a >= b ? a : b;
    }

    /**
     * @dev Returns the smallest of two numbers.
     */
    function min(uint256 a, uint256 b) internal pure returns (uint256) {
        return a < b ? a : b;
    }

    /**
     * @dev Returns the average of two numbers. The result is rounded towards
     * zero.
     */
    function average(uint256 a, uint256 b) internal pure returns (uint256) {
        // (a + b) / 2 can overflow, so we distribute.
        return (a / 2) + (b / 2) + (((a % 2) + (b % 2)) / 2);
    }

    /**
     * @dev Returns the ceiling of the division of two numbers.
     *
     * This differs from standard division with `/` in that it rounds up instead
     * of rounding down.
     */
    function ceilDiv(uint256 a, uint256 b) internal pure returns (uint256) {
        // (a + b - 1) / b can overflow on addition, so we distribute.
        return a / b + (a % b == 0 ? 0 : 1);
    }
}

File 9 of 16 : Controllable.sol
// SPDX-License-Identifier: ISC
/**
* By using this software, you understand, acknowledge and accept that Tetu
* and/or the underlying software are provided “as is” and “as available”
* basis and without warranties or representations of any kind either expressed
* or implied. Any use of this open source software released under the ISC
* Internet Systems Consortium license is done at your own risk to the fullest
* extent permissible pursuant to applicable law any and all liability as well
* as all warranties, including any fitness for a particular purpose with respect
* to Tetu and/or the underlying software and the use thereof are disclaimed.
*/

pragma solidity 0.8.4;

import "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol";
import "../interface/IController.sol";
import "../interface/IControllable.sol";

/// @title Implement basic functionality for any contract that require strict control
/// @dev Can be used with upgradeable pattern.
///      Require call initializeControllable() in any case.
/// @author belbix
abstract contract Controllable is Initializable, IControllable {
  bytes32 internal constant _CONTROLLER_SLOT = 0x5165972ef41194f06c5007493031d0b927c20741adcb74403b954009fd2c3617;
  bytes32 internal constant _CREATED_SLOT = 0x6f55f470bdc9cb5f04223fd822021061668e4dccb43e8727b295106dc9769c8a;

  /// @notice Controller address changed
  event UpdateController(address oldValue, address newValue);

  constructor() {
    assert(_CONTROLLER_SLOT == bytes32(uint256(keccak256("eip1967.controllable.controller")) - 1));
    assert(_CREATED_SLOT == bytes32(uint256(keccak256("eip1967.controllable.created")) - 1));
  }

  /// @notice Initialize contract after setup it as proxy implementation
  ///         Save block.timestamp in the "created" variable
  /// @dev Use it only once after first logic setup
  /// @param _controller Controller address
  function initializeControllable(address _controller) public initializer {
    setController(_controller);
    setCreated(block.timestamp);
  }

  function isController(address _adr) public override view returns (bool) {
    return _adr == controller();
  }

  /// @notice Return true is given address is setup as governance in Controller
  /// @param _adr Address for check
  /// @return true if given address is governance
  function isGovernance(address _adr) public override view returns (bool) {
    return IController(controller()).governance() == _adr;
  }

  // ************ MODIFIERS **********************

  /// @dev Allow operation only for Controller
  modifier onlyController() {
    require(controller() == msg.sender, "not controller");
    _;
  }

  /// @dev Allow operation only for Controller or Governance
  modifier onlyControllerOrGovernance() {
    require(isController(msg.sender) || isGovernance(msg.sender), "not controller or gov");
    _;
  }

  /// @dev Only smart contracts will be affected by this modifier
  ///      If it is a contract it should be whitelisted
  modifier onlyAllowedUsers() {
    require(IController(controller()).isAllowedUser(msg.sender), "not allowed");
    _;
  }

  /// @dev Only Reward Distributor allowed. Governance is Reward Distributor by default.
  modifier onlyRewardDistribution() {
    require(IController(controller()).isRewardDistributor(msg.sender), "only distr");
    _;
  }

  // ************* SETTERS/GETTERS *******************

  /// @notice Return controller address saved in the contract slot
  /// @return adr Controller address
  function controller() public view returns (address adr) {
    bytes32 slot = _CONTROLLER_SLOT;
    assembly {
      adr := sload(slot)
    }
  }

  /// @dev Set a controller address to contract slot
  /// @param _newController Controller address
  function setController(address _newController) internal {
    require(_newController != address(0), "zero address");
    emit UpdateController(controller(), _newController);
    bytes32 slot = _CONTROLLER_SLOT;
    assembly {
      sstore(slot, _newController)
    }
  }

  /// @notice Return creation timestamp
  /// @return ts Creation timestamp
  function created() external view returns (uint256 ts) {
    bytes32 slot = _CREATED_SLOT;
    assembly {
      ts := sload(slot)
    }
  }

  /// @dev Filled only once when contract initialized
  /// @param _created block.timestamp
  function setCreated(uint256 _created) private {
    bytes32 slot = _CREATED_SLOT;
    assembly {
      sstore(slot, _created)
    }
  }

}

File 10 of 16 : IUniswapV2Pair.sol
// SPDX-License-Identifier: UNLICENSED
/**
 *Submitted for verification at Etherscan.io on 2020-05-05
*/

// File: contracts/interfaces/IUniswapV2Pair.sol

pragma solidity 0.8.4;

interface IUniswapV2Pair {
    event Approval(address indexed owner, address indexed spender, uint value);
    event Transfer(address indexed from, address indexed to, uint value);

    function name() external pure returns (string memory);
    function symbol() external pure returns (string memory);
    function decimals() external pure returns (uint8);
    function totalSupply() external view returns (uint);
    function balanceOf(address owner) external view returns (uint);
    function allowance(address owner, address spender) external view returns (uint);

    function approve(address spender, uint value) external returns (bool);
    function transfer(address to, uint value) external returns (bool);
    function transferFrom(address from, address to, uint value) external returns (bool);

    function DOMAIN_SEPARATOR() external view returns (bytes32);
    function PERMIT_TYPEHASH() external pure returns (bytes32);
    function nonces(address owner) external view returns (uint);

    function permit(address owner, address spender, uint value, uint deadline, uint8 v, bytes32 r, bytes32 s) external;

    event Mint(address indexed sender, uint amount0, uint amount1);
    event Burn(address indexed sender, uint amount0, uint amount1, address indexed to);
    event Swap(
        address indexed sender,
        uint amount0In,
        uint amount1In,
        uint amount0Out,
        uint amount1Out,
        address indexed to
    );
    event Sync(uint112 reserve0, uint112 reserve1);

    function MINIMUM_LIQUIDITY() external pure returns (uint);
    function factory() external view returns (address);
    function token0() external view returns (address);
    function token1() external view returns (address);
    function getReserves() external view returns (uint112 reserve0, uint112 reserve1, uint32 blockTimestampLast);
    function price0CumulativeLast() external view returns (uint);
    function price1CumulativeLast() external view returns (uint);
    function kLast() external view returns (uint);

    function mint(address to) external returns (uint liquidity);
    function burn(address to) external returns (uint amount0, uint amount1);
    function swap(uint amount0Out, uint amount1Out, address to, bytes calldata data) external;
    function skim(address to) external;
    function sync() external;

    function initialize(address, address) external;
}

File 11 of 16 : IUniswapV2Router02.sol
// SPDX-License-Identifier: UNLICENSED
pragma solidity 0.8.4;

import "./IUniswapV2Router01.sol";

interface IUniswapV2Router02 {
    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);

    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 12 of 16 : IERC20Metadata.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.0;

import "../IERC20.sol";

/**
 * @dev Interface for the optional metadata functions from the ERC20 standard.
 *
 * _Available since v4.1._
 */
interface IERC20Metadata is IERC20 {
    /**
     * @dev Returns the name of the token.
     */
    function name() external view returns (string memory);

    /**
     * @dev Returns the symbol of the token.
     */
    function symbol() external view returns (string memory);

    /**
     * @dev Returns the decimals places of the token.
     */
    function decimals() external view returns (uint8);
}

File 13 of 16 : 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;
    }
}

File 14 of 16 : IController.sol
// SPDX-License-Identifier: ISC
/**
* By using this software, you understand, acknowledge and accept that Tetu
* and/or the underlying software are provided “as is” and “as available”
* basis and without warranties or representations of any kind either expressed
* or implied. Any use of this open source software released under the ISC
* Internet Systems Consortium license is done at your own risk to the fullest
* extent permissible pursuant to applicable law any and all liability as well
* as all warranties, including any fitness for a particular purpose with respect
* to Tetu and/or the underlying software and the use thereof are disclaimed.
*/

pragma solidity 0.8.4;

interface IController {

  function addVaultAndStrategy(address _vault, address _strategy) external;

  function addStrategy(address _strategy) external;

  function governance() external view returns (address);

  function dao() external view returns (address);

  function bookkeeper() external view returns (address);

  function feeRewardForwarder() external view returns (address);

  function mintHelper() external view returns (address);

  function rewardToken() external view returns (address);

  function fundToken() external view returns (address);

  function psVault() external view returns (address);

  function fund() external view returns (address);

  function announcer() external view returns (address);

  function whiteList(address _target) external view returns (bool);

  function vaults(address _target) external view returns (bool);

  function strategies(address _target) external view returns (bool);

  function psNumerator() external view returns (uint256);

  function psDenominator() external view returns (uint256);

  function fundNumerator() external view returns (uint256);

  function fundDenominator() external view returns (uint256);

  function isAllowedUser(address _adr) external view returns (bool);

  function isDao(address _adr) external view returns (bool);

  function isHardWorker(address _adr) external view returns (bool);

  function isRewardDistributor(address _adr) external view returns (bool);

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

  function isValidStrategy(address _strategy) external view returns (bool);

  // ************ DAO ACTIONS *************
  function setPSNumeratorDenominator(uint256 numerator, uint256 denominator) external;

  function setFundNumeratorDenominator(uint256 numerator, uint256 denominator) external;

  function addToWhiteListMulti(address[] calldata _targets) external;

  function addToWhiteList(address _target) external;

  function removeFromWhiteListMulti(address[] calldata _targets) external;

  function removeFromWhiteList(address _target) external;
}

File 15 of 16 : IControllable.sol
// SPDX-License-Identifier: ISC
/**
* By using this software, you understand, acknowledge and accept that Tetu
* and/or the underlying software are provided “as is” and “as available”
* basis and without warranties or representations of any kind either expressed
* or implied. Any use of this open source software released under the ISC
* Internet Systems Consortium license is done at your own risk to the fullest
* extent permissible pursuant to applicable law any and all liability as well
* as all warranties, including any fitness for a particular purpose with respect
* to Tetu and/or the underlying software and the use thereof are disclaimed.
*/

pragma solidity 0.8.4;

interface IControllable {

  function isController(address _contract) external view returns (bool);

  function isGovernance(address _contract) external view returns (bool);
}

File 16 of 16 : IUniswapV2Router01.sol
// SPDX-License-Identifier: UNLICENSED
pragma solidity 0.8.4;

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

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

Contract Security Audit

Contract ABI

[{"inputs":[{"internalType":"address","name":"_controller","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"lp","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount0","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"amount1","type":"uint256"}],"name":"LiqAdded","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"lp","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"LiqRemoved","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"lp","type":"address"},{"indexed":false,"internalType":"uint256","name":"target","type":"uint256"}],"name":"LpTvlTargetChanged","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"value","type":"uint256"}],"name":"PriceNumeratorChanged","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"token","type":"address"},{"indexed":false,"internalType":"uint256","name":"target","type":"uint256"}],"name":"PriceTargetChanged","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"value","type":"uint256"}],"name":"RemLiqNumeratorChanged","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"lp","type":"address"},{"indexed":false,"internalType":"address","name":"router","type":"address"}],"name":"RouterChanged","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"tokenIn","type":"address"},{"indexed":false,"internalType":"address","name":"tokenOut","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"Swap","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"token","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"TokenMoved","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"value","type":"uint256"}],"name":"TvlNumeratorChanged","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"oldValue","type":"address"},{"indexed":false,"internalType":"address","name":"newValue","type":"address"}],"name":"UpdateController","type":"event"},{"inputs":[],"name":"DENOMINATOR","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"VERSION","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_token","type":"address"},{"internalType":"address","name":"_lp","type":"address"}],"name":"changeLiquidity","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"controller","outputs":[{"internalType":"address","name":"adr","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"created","outputs":[{"internalType":"uint256","name":"ts","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_controller","type":"address"}],"name":"initializeControllable","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_adr","type":"address"}],"name":"isController","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_adr","type":"address"}],"name":"isGovernance","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"lpTvlTargets","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_token","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"moveTokensToController","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_token","type":"address"},{"internalType":"address","name":"_lp","type":"address"}],"name":"needToRemove","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_token","type":"address"},{"internalType":"address","name":"_lp","type":"address"}],"name":"needToSell","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"priceTargets","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"removeLiqRatioNumerator","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"routers","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_numerator","type":"uint256"}],"name":"setRemoveLiqRatioNumerator","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_lp","type":"address"},{"internalType":"address","name":"_router","type":"address"}],"name":"setRouter","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_lp","type":"address"},{"internalType":"uint256","name":"_target","type":"uint256"}],"name":"setTargetLpTvl","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_token","type":"address"},{"internalType":"uint256","name":"_target","type":"uint256"}],"name":"setTargetPrice","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_numerator","type":"uint256"}],"name":"setTargetPriceUpdateNumerator","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_numerator","type":"uint256"}],"name":"setTargetTvlUpdateNumerator","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"targetPriceUpdateNumerator","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"targetTvlUpdateNumerator","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"}]

60806040526064600155606460025560646003553480156200002057600080fd5b5060405162003187380380620031878339810160408190526200004391620002a7565b6200007060017f5165972ef41194f06c5007493031d0b927c20741adcb74403b954009fd2c3618620002d7565b60008051602062003147833981519152146200009c57634e487b7160e01b600052600160045260246000fd5b620000c960017f6f55f470bdc9cb5f04223fd822021061668e4dccb43e8727b295106dc9769c8b620002d7565b6000805160206200316783398151915214620000f557634e487b7160e01b600052600160045260246000fd5b6200010b816200011260201b620014301760201c565b50620002fb565b600054610100900460ff16806200012c575060005460ff16155b620001955760405162461bcd60e51b815260206004820152602e60248201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160448201526d191e481a5b9a5d1a585b1a5e995960921b60648201526084015b60405180910390fd5b600054610100900460ff16158015620001b8576000805461ffff19166101011790555b620001c382620001f2565b620001db426000805160206200316783398151915255565b8015620001ee576000805461ff00191690555b5050565b6001600160a01b038116620002395760405162461bcd60e51b815260206004820152600c60248201526b7a65726f206164647265737360a01b60448201526064016200018c565b7f19b7d592cea0dfda222f6a4ea5c5a8d018ee9c6b1d0a917483a405de94eb26cd62000272600080516020620031478339815191525490565b604080516001600160a01b03928316815291841660208301520160405180910390a16000805160206200314783398151915255565b600060208284031215620002b9578081fd5b81516001600160a01b0381168114620002d0578182fd5b9392505050565b600082821015620002f657634e487b7160e01b81526011600452602481fd5b500390565b612e3c806200030b6000396000f3fe608060405234801561001057600080fd5b506004361061014d5760003560e01c806395561408116100c3578063df3298ee1161007c578063df3298ee146102f9578063e945cdcd1461030c578063ea654a911461031f578063f77c479114610328578063fee3e1a31461033d578063ffa1ad741461035057600080fd5b8063955614081461025d578063b429afeb14610270578063c86f726d14610293578063d7a96e31146102b3578063dee1f0e4146102c6578063df27dd83146102d957600080fd5b8063325a19f111610115578063325a19f1146101b257806341d68b8f146101d9578063503245b3146101ec57806380dd9a1f146101ff578063895f98e414610240578063918f86741461025357600080fd5b806303f503741461015257806309b08394146101785780630babe6941461018157806313a913f91461018a5780632549bce61461019f575b600080fd5b6101656101603660046128a3565b610381565b6040519081526020015b60405180910390f35b61016560035481565b61016560015481565b61019d610198366004612a34565b61051b565b005b61019d6101ad366004612a34565b610619565b7f6f55f470bdc9cb5f04223fd822021061668e4dccb43e8727b295106dc9769c8a54610165565b61019d6101e73660046128a3565b6106f4565b6101656101fa3660046128a3565b61081a565b61022861020d36600461286b565b6006602052600090815260409020546001600160a01b031681565b6040516001600160a01b03909116815260200161016f565b61019d61024e366004612a34565b610957565b610165620186a081565b61019d61026b3660046128db565b610a32565b61028361027e36600461286b565b610b73565b604051901515815260200161016f565b6101656102a136600461286b565b60056020526000908152604090205481565b61019d6102c13660046128a3565b610ba6565b6102836102d436600461286b565b61128c565b6101656102e736600461286b565b60046020526000908152604090205481565b61019d6103073660046128db565b61132e565b61019d61031a36600461286b565b611430565b61016560025481565b600080516020612de783398151915254610228565b61019d61034b3660046128db565b611515565b610374604051806040016040528060058152602001640312e302e360dc1b81525081565b60405161016f9190612af1565b6040516370a0823160e01b815230600482015260009081906001600160a01b038516906370a082319060240160206040518083038186803b1580156103c557600080fd5b505afa1580156103d9573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906103fd9190612a4c565b9050600080600061040e868861161a565b9350935093505060006104478285600460008c6001600160a01b03166001600160a01b0316815260200190815260200160002054611991565b90506000818611156104bb576001600160a01b0389166000908152600460205260408120546104939061048d670de0b6b3a7640000610487888b896119f4565b90611a2e565b90611a3a565b905060006104a18885611a46565b9050818111156104b8576104b58183611a46565b92505b50505b6104c58282611a52565b91506000821180156104ee57506001600160a01b03891660009081526004602052604090205484115b1561050a576104fd8282611a52565b9650505050505050610515565b600096505050505050505b92915050565b61052433610b73565b8061053357506105333361128c565b6105585760405162461bcd60e51b815260040161054f90612b4e565b60405180910390fd5b600081116105785760405162461bcd60e51b815260040161054f90612b24565b620186a08111156105dd5760405162461bcd60e51b815260206004820152602960248201527f73686f756c64206265206c6f776572206f7220657175616c207468616e2064656044820152683737b6b4b730ba37b960b91b606482015260840161054f565b60038190556040518181527fb7522b145a617fcd26070e86bbd582e57d16e51190913001fabac5b7ece84f54906020015b60405180910390a150565b61062233610b73565b8061063157506106313361128c565b61064d5760405162461bcd60e51b815260040161054f90612b4e565b6000811161066d5760405162461bcd60e51b815260040161054f90612b24565b620186a081106106bf5760405162461bcd60e51b815260206004820181905260248201527f73686f756c64206265206c6f776572207468616e2064656e6f6d696e61746f72604482015260640161054f565b60018190556040518181527f03a9f8e0376dc529465c358db1a23f98fff852155efb7fab3ad420a69841f2369060200161060e565b6106fd33610b73565b8061070c575061070c3361128c565b6107285760405162461bcd60e51b815260040161054f90612b4e565b6001600160a01b0382166107695760405162461bcd60e51b8152602060048201526008602482015267077726f6e67206c760c41b604482015260640161054f565b6001600160a01b0381166107ae5760405162461bcd60e51b815260206004820152600c60248201526b3bb937b733903937baba32b960a11b604482015260640161054f565b6001600160a01b0382811660008181526006602090815260409182902080546001600160a01b031916948616948517905581519283528201929092527fc736654a613824c69968e0ec25ac1a428ccd49e15c28e97b5dfd2c6059757e2a91015b60405180910390a15050565b6040516370a0823160e01b815230600482015260009081906001600160a01b038416906370a082319060240160206040518083038186803b15801561085e57600080fd5b505afa158015610872573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906108969190612a4c565b905060006108a4848661161a565b505091505060006108bf600283611a2e90919063ffffffff16565b905060006108cd8287611a68565b90506108d98185611a52565b90506000811180156108eb5750808410155b801561090e57506001600160a01b03861660009081526005602052604090205482115b1561094a57600061091f8286611a52565b905061093d620186a061048d60035484611a2e90919063ffffffff16565b9550610515945050505050565b6000945050505050610515565b61096033610b73565b8061096f575061096f3361128c565b61098b5760405162461bcd60e51b815260040161054f90612b4e565b600081116109ab5760405162461bcd60e51b815260040161054f90612b24565b620186a081106109fd5760405162461bcd60e51b815260206004820181905260248201527f73686f756c64206265206c6f776572207468616e2064656e6f6d696e61746f72604482015260640161054f565b60028190556040518181527f53acc418239d0df52b1e359cb60a6134c942c815555ef1156e1e6089458423359060200161060e565b610a3b33610b73565b80610a4a5750610a4a3361128c565b610a665760405162461bcd60e51b815260040161054f90612b4e565b6040516370a0823160e01b81523060048201526000906001600160a01b038416906370a082319060240160206040518083038186803b158015610aa857600080fd5b505afa158015610abc573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610ae09190612a4c565b905081811015610b025760405162461bcd60e51b815260040161054f90612b7d565b610b2c610b1b600080516020612de78339815191525490565b6001600160a01b0385169084611b56565b604080516001600160a01b0385168152602081018490527fc163505caf05ab04e4eb812d39f551812b2b4ab3c932588109227a663ec6d697910160405180910390a1505050565b6000610b8b600080516020612de78339815191525490565b6001600160a01b0316826001600160a01b0316149050919050565b600080516020612de783398151915254604051635e01d12d60e11b81523360048201526001600160a01b03919091169063bc03a25a9060240160206040518083038186803b158015610bf757600080fd5b505afa158015610c0b573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610c2f91906129c6565b80610c57575033610c4c600080516020612de78339815191525490565b6001600160a01b0316145b610ca35760405162461bcd60e51b815260206004820152601d60248201527f6f6e6c792068617264776f726b6572206f7220636f6e74726f6c6c6572000000604482015260640161054f565b6001600160a01b038216600090815260046020526040902054610cfc5760405162461bcd60e51b81526020600482015260116024820152701e995c9bc81c1c9a58d9481d185c99d95d607a1b604482015260640161054f565b6001600160a01b038116600090815260056020526040902054610d565760405162461bcd60e51b81526020600482015260126024820152711e995c9bc81b1c081d1d9b081d185c99d95d60721b604482015260640161054f565b60008190506000816001600160a01b0316630dfe16816040518163ffffffff1660e01b815260040160206040518083038186803b158015610d9657600080fd5b505afa158015610daa573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610dce9190612887565b6001600160a01b0316846001600160a01b031614610e5c57816001600160a01b0316630dfe16816040518163ffffffff1660e01b815260040160206040518083038186803b158015610e1f57600080fd5b505afa158015610e33573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610e579190612887565b610ecd565b816001600160a01b031663d21220a76040518163ffffffff1660e01b815260040160206040518083038186803b158015610e9557600080fd5b505afa158015610ea9573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610ecd9190612887565b90506000610edb8585610381565b90506000610ee9868661081a565b9050801561110e57610efd85828886611bbe565b60078054600181810183557fa66cc928b5edb82af9bd49922954155ab7b0942694bea4ce44661d9a8736c68891820180546001600160a01b038089166001600160a01b031992831617909255845492830185559190920180548a8416921691909117905586811660009081526006602090815260409182902054845483518184028101840190945280845261104e9591909416939091830182828015610fcc57602002820191906000526020600020905b81546001600160a01b03168152600190910190602001808311610fae575b50506040516370a0823160e01b81523060048201526001600160a01b038a1693506370a082319250602401905060206040518083038186803b15801561101157600080fd5b505afa158015611025573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906110499190612a4c565b611d8a565b600061105a868861161a565b506001600160a01b038a16600090815260046020526040902081905560078054919450925090508061109c57634e487b7160e01b600052603160045260246000fd5b600082815260209020810160001990810180546001600160a01b031916905501905560078054806110dd57634e487b7160e01b600052603160045260246000fd5b600082815260209020810160001990810180546001600160a01b03191690550190556111088661203f565b50611284565b81156112845760078054600181810183557fa66cc928b5edb82af9bd49922954155ab7b0942694bea4ce44661d9a8736c68891820180546001600160a01b03808c166001600160a01b0319928316179092558454928301855591909201805487841692169190911790558681166000908152600660209081526040918290205484548351818402810184019094528084526111ee95919094169390918301828280156111e357602002820191906000526020600020905b81546001600160a01b031681526001909101906020018083116111c5575b505050505084611d8a565b600780548061120d57634e487b7160e01b600052603160045260246000fd5b600082815260209020810160001990810180546001600160a01b0319169055019055600780548061124e57634e487b7160e01b600052603160045260246000fd5b600082815260209020810160001990810180546001600160a01b031916905501905561127b8587856120ad565b611284866123b8565b505050505050565b6000816001600160a01b03166112ae600080516020612de78339815191525490565b6001600160a01b0316635aa6e6756040518163ffffffff1660e01b815260040160206040518083038186803b1580156112e657600080fd5b505afa1580156112fa573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061131e9190612887565b6001600160a01b03161492915050565b61133733610b73565b8061134657506113463361128c565b6113625760405162461bcd60e51b815260040161054f90612b4e565b8061139e5760405162461bcd60e51b815260206004820152600c60248201526b1ddc9bdb99c81d185c99d95d60a21b604482015260640161054f565b6001600160a01b0382166113df5760405162461bcd60e51b8152602060048201526008602482015267077726f6e67206c760c41b604482015260640161054f565b6001600160a01b038216600081815260056020908152604091829020849055815192835282018390527fc8e692076beff3663e7b201f7423c659dd79cd574b93c7630c56921626d06394910161080e565b600054610100900460ff1680611449575060005460ff16155b6114ac5760405162461bcd60e51b815260206004820152602e60248201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160448201526d191e481a5b9a5d1a585b1a5e995960921b606482015260840161054f565b600054610100900460ff161580156114ce576000805461ffff19166101011790555b6114d782612426565b6114ff427f6f55f470bdc9cb5f04223fd822021061668e4dccb43e8727b295106dc9769c8a55565b8015611511576000805461ff00191690555b5050565b61151e33610b73565b8061152d575061152d3361128c565b6115495760405162461bcd60e51b815260040161054f90612b4e565b806115855760405162461bcd60e51b815260206004820152600c60248201526b1ddc9bdb99c81d185c99d95d60a21b604482015260640161054f565b6001600160a01b0382166115c95760405162461bcd60e51b815260206004820152600b60248201526a3bb937b733903a37b5b2b760a91b604482015260640161054f565b6001600160a01b038216600081815260046020908152604091829020849055815192835282018390527fa0d968cadbb4d9d230248e8fe08543bc457479be4571a6ff19bc71f8bb372d69910161080e565b60008060008060008690506000816001600160a01b0316630dfe16816040518163ffffffff1660e01b815260040160206040518083038186803b15801561166057600080fd5b505afa158015611674573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906116989190612887565b90506000826001600160a01b031663d21220a76040518163ffffffff1660e01b815260040160206040518083038186803b1580156116d557600080fd5b505afa1580156116e9573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061170d9190612887565b90506000826001600160a01b031663313ce5676040518163ffffffff1660e01b815260040160206040518083038186803b15801561174a57600080fd5b505afa15801561175e573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906117829190612ab4565b60ff1690506000826001600160a01b031663313ce5676040518163ffffffff1660e01b815260040160206040518083038186803b1580156117c257600080fd5b505afa1580156117d6573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906117fa9190612ab4565b60ff169050600080866001600160a01b0316630902f1ac6040518163ffffffff1660e01b815260040160606040518083038186803b15801561183b57600080fd5b505afa15801561184f573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061187391906129e6565b506001600160701b0391821693501690506118a461189285600a612c94565b61048d84670de0b6b3a7640000611a2e565b91506118c66118b484600a612c94565b61048d83670de0b6b3a7640000611a2e565b9050856001600160a01b03168c6001600160a01b0316146118e757806118e9565b815b9750856001600160a01b03168c6001600160a01b03161461190a578161190c565b805b9950856001600160a01b03168c6001600160a01b03161461192d578561192f565b845b9a50856001600160a01b03168c6001600160a01b03161415611968576119618261048d83670de0b6b3a7640000611a2e565b9850611981565b61197e8161048d84670de0b6b3a7640000611a2e565b98505b5050505050505092959194509250565b6000816119a0575060006119ed565b60006119bc670de0b6b3a76400006104878561048d888a611a2e565b905060006119c9826124d6565b9050858110156119de576000925050506119ed565b6119e88187611a46565b925050505b9392505050565b600083158015611a02575081155b15611a0f575060006119ed565b611a26611a1c8584612547565b61048d8486611a2e565b949350505050565b60006119ed8284612d3c565b60006119ed8284612c31565b60006119ed8284612d5b565b6000818310611a6157816119ed565b5090919050565b6000821580611a8e57506001600160a01b03821660009081526005602052604090205483105b15611a9b57506000610515565b6001600160a01b038216600090815260056020526040812054611ad390859061048d90670de0b6b3a764000090610487908490611a46565b9050611a26670de0b6b3a764000061048d83866001600160a01b03166318160ddd6040518163ffffffff1660e01b815260040160206040518083038186803b158015611b1e57600080fd5b505afa158015611b32573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906104879190612a4c565b6040516001600160a01b038316602482015260448101829052611bb990849063a9059cbb60e01b906064015b60408051601f198184030181529190526020810180516001600160e01b03166001600160e01b031990931692909217909152612553565b505050565b6040516370a0823160e01b81523060048201526000906001600160a01b038616906370a082319060240160206040518083038186803b158015611c0057600080fd5b505afa158015611c14573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611c389190612a4c565b905083811015611c5a5760405162461bcd60e51b815260040161054f90612b7d565b6001600160a01b03808616600081815260066020526040812054909216918291611c85918390612625565b611c996001600160a01b0388168388612625565b604051635d5155ef60e11b81526001600160a01b03868116600483015285811660248301526044820188905260016064830181905260848301523060a48301524260c483015282169063baa2abde9060e4016040805180830381600087803b158015611d0457600080fd5b505af1158015611d18573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611d3c9190612a64565b5050604080516001600160a01b0389168152602081018890527f5dfea218e3a9af8485eab96a9d500e2f49bdfda7130e2aa23b0e50f4522aff2791015b60405180910390a150505050505050565b6001600160a01b038316611dce5760405162461bcd60e51b815260206004820152600b60248201526a3d32b937903937baba32b960a91b604482015260640161054f565b600082600081518110611df157634e487b7160e01b600052603260045260246000fd5b60209081029190910101516040516370a0823160e01b81523060048201526001600160a01b03909116906370a082319060240160206040518083038186803b158015611e3c57600080fd5b505afa158015611e50573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611e749190612a4c565b905081811015611e965760405162461bcd60e51b815260040161054f90612b7d565b611edd84600085600081518110611ebd57634e487b7160e01b600052603260045260246000fd5b60200260200101516001600160a01b03166126259092919063ffffffff16565b611f03848385600081518110611ebd57634e487b7160e01b600052603260045260246000fd5b6040516338ed173960e01b81526001600160a01b038516906338ed173990611f38908590600090889030904290600401612ba9565b600060405180830381600087803b158015611f5257600080fd5b505af1158015611f66573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f19168201604052611f8e9190810190612906565b507fea368a40e9570069bb8e6511d668293ad2e1f03b0d982431fd223de9f3b70ca683600081518110611fd157634e487b7160e01b600052603260045260246000fd5b602002602001015184600181518110611ffa57634e487b7160e01b600052603260045260246000fd5b602002602001015184604051612031939291906001600160a01b039384168152919092166020820152604081019190915260600190565b60405180910390a150505050565b6002546001600160a01b0382166000908152600560205260409020546120919161207291620186a09161048d9190611a2e565b6001600160a01b03831660009081526005602052604090205490612547565b6001600160a01b03909116600090815260056020526040902055565b6001600160a01b038381166000908152600660205260408082205490516370a0823160e01b815230600482015290831692839291908616906370a082319060240160206040518083038186803b15801561210657600080fd5b505afa15801561211a573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061213e9190612a4c565b6040516370a0823160e01b81523060048201529091506000906001600160a01b038616906370a082319060240160206040518083038186803b15801561218357600080fd5b505afa158015612197573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906121bb9190612a4c565b90506121d26001600160a01b038716856000612625565b6121e66001600160a01b0387168584612625565b6121fb6001600160a01b038616856000612625565b61220f6001600160a01b0386168583612625565b60405162e8e33760e81b81526001600160a01b0387811660048301528681166024830152604482018490526064820183905260016084830181905260a48301523060c48301524260e483015284169063e8e337009061010401606060405180830381600087803b15801561228257600080fd5b505af1158015612296573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906122ba9190612a87565b50506040516370a0823160e01b81523060048201526001600160a01b03871691506370a082319060240160206040518083038186803b1580156122fc57600080fd5b505afa158015612310573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906123349190612a4c565b156123715760405162461bcd60e51b815260206004820152600d60248201526c1859191959081b9bdd08185b1b609a1b604482015260640161054f565b604080516001600160a01b0389168152602081018490529081018290527f54090a6a8f3d8bd65358f49dadb8f57c6db04edc67be1f4e4e7dd669f500a60590606001611d79565b6001546001600160a01b03821660009081526004602052604090205461240a916123eb91620186a09161048d9190611a2e565b6001600160a01b03831660009081526004602052604090205490612547565b6001600160a01b03909116600090815260046020526040902055565b6001600160a01b03811661246b5760405162461bcd60e51b815260206004820152600c60248201526b7a65726f206164647265737360a01b604482015260640161054f565b7f19b7d592cea0dfda222f6a4ea5c5a8d018ee9c6b1d0a917483a405de94eb26cd6124a2600080516020612de78339815191525490565b604080516001600160a01b03928316815291841660208301520160405180910390a1600080516020612de783398151915255565b60008082116124e757506000919050565b6003821115612538575080600061250a6001612504846002611a3a565b90612547565b90505b818110156125325790508061252b600261048d836125048782611a3a565b905061250d565b50919050565b8115612542575060015b919050565b60006119ed8284612c19565b60006125a8826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b03166127499092919063ffffffff16565b805190915015611bb957808060200190518101906125c691906129c6565b611bb95760405162461bcd60e51b815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e6044820152691bdd081cdd58d8d9595960b21b606482015260840161054f565b8015806126ae5750604051636eb1769f60e11b81523060048201526001600160a01b03838116602483015284169063dd62ed3e9060440160206040518083038186803b15801561267457600080fd5b505afa158015612688573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906126ac9190612a4c565b155b6127195760405162461bcd60e51b815260206004820152603660248201527f5361666545524332303a20617070726f76652066726f6d206e6f6e2d7a65726f60448201527520746f206e6f6e2d7a65726f20616c6c6f77616e636560501b606482015260840161054f565b6040516001600160a01b038316602482015260448101829052611bb990849063095ea7b360e01b90606401611b82565b6060611a26848460008585843b6127a25760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e7472616374000000604482015260640161054f565b600080866001600160a01b031685876040516127be9190612ad5565b60006040518083038185875af1925050503d80600081146127fb576040519150601f19603f3d011682016040523d82523d6000602084013e612800565b606091505b509150915061281082828661281b565b979650505050505050565b6060831561282a5750816119ed565b82511561283a5782518084602001fd5b8160405162461bcd60e51b815260040161054f9190612af1565b80516001600160701b038116811461254257600080fd5b60006020828403121561287c578081fd5b81356119ed81612dce565b600060208284031215612898578081fd5b81516119ed81612dce565b600080604083850312156128b5578081fd5b82356128c081612dce565b915060208301356128d081612dce565b809150509250929050565b600080604083850312156128ed578182fd5b82356128f881612dce565b946020939093013593505050565b60006020808385031215612918578182fd5b825167ffffffffffffffff8082111561292f578384fd5b818501915085601f830112612942578384fd5b81518181111561295457612954612db8565b8060051b604051601f19603f8301168101818110858211171561297957612979612db8565b604052828152858101935084860182860187018a1015612997578788fd5b8795505b838610156129b957805185526001959095019493860193860161299b565b5098975050505050505050565b6000602082840312156129d7578081fd5b815180151581146119ed578182fd5b6000806000606084860312156129fa578081fd5b612a0384612854565b9250612a1160208501612854565b9150604084015163ffffffff81168114612a29578182fd5b809150509250925092565b600060208284031215612a45578081fd5b5035919050565b600060208284031215612a5d578081fd5b5051919050565b60008060408385031215612a76578182fd5b505080516020909101519092909150565b600080600060608486031215612a9b578283fd5b8351925060208401519150604084015190509250925092565b600060208284031215612ac5578081fd5b815160ff811681146119ed578182fd5b60008251612ae7818460208701612d72565b9190910192915050565b6020815260008251806020840152612b10816040850160208701612d72565b601f01601f19169190910160400192915050565b60208082526010908201526f1e995c9bc81b9bdd08185b1b1bddd95960821b604082015260600190565b6020808252601590820152743737ba1031b7b73a3937b63632b91037b91033b7bb60591b604082015260600190565b6020808252601290820152716e6f7420656e6f7567682062616c616e636560701b604082015260600190565b600060a082018783526020878185015260a0604085015281875180845260c0860191508289019350845b81811015612bf85784516001600160a01b031683529383019391830191600101612bd3565b50506001600160a01b03969096166060850152505050608001529392505050565b60008219821115612c2c57612c2c612da2565b500190565b600082612c4c57634e487b7160e01b81526012600452602481fd5b500490565b600181815b80851115612c8c578160001904821115612c7257612c72612da2565b80851615612c7f57918102915b93841c9390800290612c56565b509250929050565b60006119ed8383600082612caa57506001610515565b81612cb757506000610515565b8160018114612ccd5760028114612cd757612cf3565b6001915050610515565b60ff841115612ce857612ce8612da2565b50506001821b610515565b5060208310610133831016604e8410600b8410161715612d16575081810a610515565b612d208383612c51565b8060001904821115612d3457612d34612da2565b029392505050565b6000816000190483118215151615612d5657612d56612da2565b500290565b600082821015612d6d57612d6d612da2565b500390565b60005b83811015612d8d578181015183820152602001612d75565b83811115612d9c576000848401525b50505050565b634e487b7160e01b600052601160045260246000fd5b634e487b7160e01b600052604160045260246000fd5b6001600160a01b0381168114612de357600080fd5b5056fe5165972ef41194f06c5007493031d0b927c20741adcb74403b954009fd2c3617a26469706673582212204c618de2d5adac9f904fb25af8f6567d78e8bab0eb266caa9ac25a1da1a1daf264736f6c634300080400335165972ef41194f06c5007493031d0b927c20741adcb74403b954009fd2c36176f55f470bdc9cb5f04223fd822021061668e4dccb43e8727b295106dc9769c8a0000000000000000000000006678814c273d5088114b6e40cc49c8db04f9bc29

Constructor Arguments (ABI-Encoded and is the last bytes of the Contract Creation Code above)

0000000000000000000000006678814c273d5088114b6e40cc49c8db04f9bc29

-----Decoded View---------------
Arg [0] : _controller (address): 0x6678814c273d5088114b6e40cc49c8db04f9bc29

-----Encoded View---------------
1 Constructor Arguments found :
Arg [0] : 0000000000000000000000006678814c273d5088114b6e40cc49c8db04f9bc29


Block Transaction Gas Used Reward
Age Block Fee Address BC Fee Address Voting Power Jailed Incoming
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.