ETH Price: $2,542.95 (+4.82%)

Contract

0x3A2b8cC91aF8bf45F3Ec61E779ee1c2ba6b7E694
 

Multichain Info

No addresses found
Transaction Hash
Method
Block
From
To
Unstake203117922024-07-15 12:04:1149 days ago1721045051IN
0x3A2b8cC9...ba6b7E694
0 ETH0.000345075.24057159
Easy Swap199685932024-05-28 13:14:1197 days ago1716902051IN
0x3A2b8cC9...ba6b7E694
0 ETH0.0013329212.33371639
Easy Swap199396172024-05-24 12:02:59101 days ago1716552179IN
0x3A2b8cC9...ba6b7E694
0 ETH0.000684456.33259313
Easy Swap199188272024-05-21 14:18:11104 days ago1716301091IN
0x3A2b8cC9...ba6b7E694
0 ETH0.0025020519.99085999
Unstake198817252024-05-16 9:44:59109 days ago1715852699IN
0x3A2b8cC9...ba6b7E694
0 ETH0.000324564.35382832
Unstake198817212024-05-16 9:44:11109 days ago1715852651IN
0x3A2b8cC9...ba6b7E694
0 ETH0.000177474.5047943
Unstake198817192024-05-16 9:43:47109 days ago1715852627IN
0x3A2b8cC9...ba6b7E694
0 ETH0.000324364.60119179
Easy Remove196935262024-04-20 2:03:35135 days ago1713578615IN
0x3A2b8cC9...ba6b7E694
0 ETH0.00053356.10168749
Easy Remove196935182024-04-20 2:01:59135 days ago1713578519IN
0x3A2b8cC9...ba6b7E694
0 ETH0.000653476.32332476
Easy Remove196935012024-04-20 1:58:35135 days ago1713578315IN
0x3A2b8cC9...ba6b7E694
0 ETH0.000666826.49588572
Easy Add196628792024-04-15 19:04:59140 days ago1713207899IN
0x3A2b8cC9...ba6b7E694
0 ETH0.0041640638.70058632
Unlock Exchange196628472024-04-15 18:58:35140 days ago1713207515IN
0x3A2b8cC9...ba6b7E694
0 ETH0.0005994220.08670232
Unstake196172522024-04-09 9:39:47146 days ago1712655587IN
0x3A2b8cC9...ba6b7E694
0 ETH0.0020467824.67582931
Unstake196149082024-04-09 1:47:23146 days ago1712627243IN
0x3A2b8cC9...ba6b7E694
0 ETH0.0022060822.05315523
Unstake196071762024-04-07 23:46:59147 days ago1712533619IN
0x3A2b8cC9...ba6b7E694
0 ETH0.0006267210.90965222
Unstake196071702024-04-07 23:45:47147 days ago1712533547IN
0x3A2b8cC9...ba6b7E694
0 ETH0.0007422910.52960564
Unstake195204982024-03-26 18:51:47160 days ago1711479107IN
0x3A2b8cC9...ba6b7E694
0 ETH0.0030433836.69607313
Unstake194687682024-03-19 12:22:59167 days ago1710850979IN
0x3A2b8cC9...ba6b7E694
0 ETH0.0037091244.71676798
Unstake194574012024-03-17 22:02:11169 days ago1710712931IN
0x3A2b8cC9...ba6b7E694
0 ETH0.0027929633.67172258
Unstake194534402024-03-17 8:40:11169 days ago1710664811IN
0x3A2b8cC9...ba6b7E694
0 ETH0.0021202826.59800966
Unstake194475632024-03-16 12:49:47170 days ago1710593387IN
0x3A2b8cC9...ba6b7E694
0 ETH0.002896532.87150465
Unstake191910682024-02-09 14:08:35206 days ago1707487715IN
0x3A2b8cC9...ba6b7E694
0 ETH0.0027576891.4018668
Unstake191910672024-02-09 14:08:23206 days ago1707487703IN
0x3A2b8cC9...ba6b7E694
0 ETH0.0070301284.75441125
Unstake190713042024-01-23 18:58:47223 days ago1706036327IN
0x3A2b8cC9...ba6b7E694
0 ETH0.0011052715.67851589
Lock Exchange190412022024-01-19 13:27:23227 days ago1705670843IN
0x3A2b8cC9...ba6b7E694
0 ETH0.0011925339.99509304
View all transactions

View more zero value Internal Transactions in Advanced View mode

Advanced mode:
Loading...
Loading

Contract Source Code Verified (Exact Match)

Contract Name:
StablePlaza

Compiler Version
v0.8.13+commit.abaa5c0e

Optimization Enabled:
Yes with 200 runs

Other Settings:
default evmVersion, MIT license
File 1 of 14 : StablePlaza.sol
// SPDX-License-Identifier: MIT
pragma solidity 0.8.13;

import "IStablePlaza.sol";
import "IStakingContract.sol";
import "IStablePlazaAddCallee.sol";
import "IStablePlazaSwapCallee.sol";
import "IStablePlazaRemoveCallee.sol";
import "Ownable.sol";
import "ERC20.sol";
import "IERC20.sol";
import "SafeERC20.sol";
import "ERC20Burnable.sol";
import "IERC20Metadata.sol";

contract StablePlaza is IStablePlaza, IStakingContract, Ownable, ERC20Burnable {
  using SafeERC20 for IERC20;

  // constants
  uint8 constant BASE_DECIMALS = 6;                 // decimals used for all USD based tokens and the LP token itself
  uint256 constant NR_OF_TOKENS = 4;                // the amount of tokens listed on the exchange
  uint16 constant TRADE_LOCK_MASK = 0x0001;         // bitmask - 1st bit is used to indicate trade is in progress
  uint16 constant ADMIN_LOCK_MASK = 0x0002;         // bitmask - 2nd bit is used to indicate admin lock is active
  uint16 constant ADMIN_UNLOCK_MASK = 0xFFFD;       // bitmask - inverse of admin lock mask
  uint64 constant MIN_SHARES = 232830643653;        // initial amount of shares belonging to nobody to ensure adequate scaling (1000 DFP2 equivalent)
  uint256 constant LP_FACTOR_ADD = 201_000_000;     // factor to get from real LPs to virtual LPs for liquidity add (201)
  uint256 constant LP_FACTOR_REMOVE = 202_493_812;  // factor to get from real LPs to virtual LPs for liquidity remove (~202.49)
  uint256 constant NORMALIZE_FACTOR = 1_000_000;    // normalization factor for the LP_FACTORS
  uint256 constant SECONDS_PER_DAY = 86400;         // the number of seconds in a day

  // immutables
  IERC20 public immutable stakingToken;             // token that is accepted as stake

  // contract state variables
  Token[NR_OF_TOKENS] public tokens;                // tokens listed on the exchange
  uint64[NR_OF_TOKENS] public reserves;             // scaled reserves of listed tokens
  uint64[NR_OF_TOKENS] public denormFactors;        // (de)normalization factors to get to 6 decimals
  mapping(address => StakerData) public stakerData; // data per staker
  mapping(IERC20 => uint256) private offsetIndex;   // helper variable to save gas on index collection
  address public admin;                             // admin with exchange (un)lock power

  Config public SPconfig = Config({
    locked: ADMIN_LOCK_MASK,            // 2nd bit is admin lock
    feeLevel: 3,                        // 3 out of 10000     --> 0.03% total fee
    flashLoanFeeLevel: 3,               // 3 out of 10000     --> 0.03% total fee
    stakerFeeFraction: 85,              // 85 out of 256      --> 0.01% stakers cut
    maxLockingBonus: 2,                 // factor of 2        --> 200% max bonus
    maxLockingTime: 180,                // max time           --> 180 days
    Delta: 0,                           // virtual liquidity  --> needs to be initialised
    unclaimedRewards: 1_000_000,        // 1$ of minimum liquidity belonging to nobody
    totalSupply: 0                      // Initialise withouth LP tokens
  });

  StakingState public stakingState = StakingState({
    totalShares: MIN_SHARES,            // Shares owned by nobody for adequate scaling
    rewardsPerShare: 0,                 // Start at zero rewards per share
    lastSyncedUnclaimedRewards: 0       // Start unsynced
  });

  /**
   * @notice Sets up exchange with the configuration of the listed tokens and the staking token.
   * @dev Initialize with ordered list of 4 token addresses.
   * Doesn't do any checks. Make sure you ONLY add well behaved ERC20s!! Does not support fee on transfer tokens.
   * @param tokensToList Ordered list of the 4 stable token addresses.
   * @param stakingTokenAddress Contract address of the ERC20 token that can be staked. Balance needs to fit in 96 bits.
   */
  constructor(IERC20[] memory tokensToList, IERC20 stakingTokenAddress) ERC20("StablePlaza", "XSP") {
    // Store the staking token address (DFP2 token is used here)
    stakingToken = stakingTokenAddress;

    // Configure the listed tokens
    uint64 d;
    IERC20 previous;
    IERC20 current;
    if (tokensToList.length != NR_OF_TOKENS) { revert(); } // dev: bad nr of tokens
    for (uint256 i; i < NR_OF_TOKENS; ) {
      // verify validity & collect data
      current = tokensToList[i];
      if (previous >= current) { revert(); } // dev: require ordered list
      d = uint64(10**(IERC20Metadata(address(current)).decimals() - BASE_DECIMALS));

      // write to storage
      denormFactors[i] = d;
      offsetIndex[current] = i + 1;
      Token storage t = tokens[i];
      t.token = current;
      t.denormFactor = d;

      // update iteration variables
      previous = current;
      unchecked { ++i; }
    }
  }

  // used for exchange (un)lock functions which may only be called by admin or owner
  modifier onlyAdmin() {
    if (msg.sender != admin && msg.sender != owner()) { revert AdminRightsRequired(); }
    _;
  }

  // LP tokens are scaled to 6 decimals which should suffice for USD based tokens
  function decimals() public view virtual override returns (uint8) { return BASE_DECIMALS; }

  /**
   * @inheritdoc IStablePlaza
   */
  function getIndex(IERC20 token) external view override returns (uint256 index)
  {
    index = offsetIndex[token];
    if (index == 0) { revert TokenNotFound(); }
    --index;
  }

  /**
   * @inheritdoc IStablePlaza
   */
  function getTokenFromIndex(uint256 index) external view override returns (IERC20 token)
  {
    token = tokens[index].token;
  }

  /**
   * @inheritdoc IStablePlaza
   */
  function getOutFromIn(
    uint256 inputIndex,
    uint256 outputIndex,
    uint256 inputAmount
  )
    public view override returns(uint256 maxOutputAmount)
  {
    // gather reserve data & calculate resulting output amount from constant product curve
    (uint256 R0, uint256 R1, uint256 d0, uint256 d1, Config memory c) = _getPairReservesAndConfig(inputIndex, outputIndex);
    uint256 oneMinusFee = 10_000 - c.feeLevel;
    uint256 Delta = uint256(c.Delta);

    inputAmount = inputAmount / d0;
    maxOutputAmount = oneMinusFee * inputAmount * (R1 + Delta) / ((R0 + Delta) * 10_000 + oneMinusFee * inputAmount) * d1;
    if (maxOutputAmount > R1 * d1) maxOutputAmount = R1 * d1;
  }

  /**
   * @inheritdoc IStablePlaza
   */
  function getInFromOut(
    uint256 inputIndex,
    uint256 outputIndex,
    uint256 outputAmount
  )
    public view override returns(uint256 minInputAmount)
  {
    // gather reserve data & calculate required input amount followin constant product cuve
    (uint256 R0, uint256 R1, uint256 d0, uint256 d1, Config memory c) = _getPairReservesAndConfig(inputIndex, outputIndex);

    outputAmount = (outputAmount - 1) / d1 + 1;
    if (outputAmount > R1) { revert InsufficientLiquidity(); }
    minInputAmount = ((R0 + c.Delta) * outputAmount * 10_000 / (((R1 + c.Delta) - outputAmount) * (10_000 - c.feeLevel)) + 1) * d0;
  }

  /**
   * @inheritdoc IStablePlaza
   */
  function getLPsFromInput(
    uint256 tokenIndex,
    uint256 inputAmount
  )
    public view override returns(uint256 maxLPamount)
  {
    // collect data reusing the function designed for swap data
    (uint256 R, uint256 d, Config memory c) = _getReservesAndConfig(tokenIndex);
    inputAmount = inputAmount / d;

    // Prevent excessive liquidity add, for which the approximations become bad.
    // At the limit, users can more than double existing liquidity.
    if (inputAmount >= R + c.Delta >> 5) { revert ExcessiveLiquidityInput(); }

    // See https://en.wikipedia.org/wiki/Binomial_series for the below algorithm
    // Computes the 6th power binomial series approximation of R.
    //
    //                 X   3 X^2   7 X^3   77 X^4   231 X^5   1463 X^6
    // (1+X)^1/4 - 1 ≈ - - ----- + ----- - ------ + ------- - --------
    //                 4    32      128     2048     8192      65536
    //
    // Note that we need to terminate at an even order to guarantee an underestimate
    // for safety. The approximation is accurate up to 10^-8.
    uint256 X = (inputAmount << 128) / (R + c.Delta);  // 0.128 bits
    uint256 X_ = X * X >> 128;                         // X**2  0.128 bits
    uint256 R_ = (X >> 2) - (X_ * 3 >> 5);             // R2    0.128 bits
    X_ = X_ * X >> 128;                                // X**3  0.128 bits
    R_ = R_ + (X_ * 7 >> 7);                           // R3    0.128 bits
    X_ = X_ * X >> 128;                                // X**4  0.128 bits
    R_ = R_ - (X_ * 77 >> 11);                         // R4    0.128 bits
    X_ = X_ * X >> 128;                                // X**5  0.128 bits
    R_ = R_ + (X_ * 231 >> 13);                        // R5    0.128 bits
    X_ = X_ * X >> 128;                                // X**6  0.128 bits
    R_ = R_ - (X_ * 1463 >> 16);                       // R6    0.128 bits

    // calculate maximum LP tokens to be generated
    maxLPamount = (R_ * LP_FACTOR_ADD * (totalSupply() + c.unclaimedRewards) / NORMALIZE_FACTOR) >> 128;
  }

  /**
   * @inheritdoc IStablePlaza
   */
  function getInputFromLPs(
    uint256 tokenIndex,
    uint256 LPamount,
    bool fromCallback
  )
    public view override returns(uint256 minInputAmount)
  {
    // collect data reusing the function designed for swap data
    uint256 F_ = 1 << 120;
    (uint256 R, uint256 d, Config memory c) = _getReservesAndConfig(tokenIndex);

    // check for out of bounds
    uint256 correction = fromCallback ? LPamount : 0;
    uint256 totalLPs = (totalSupply() - correction + c.unclaimedRewards) * LP_FACTOR_ADD / NORMALIZE_FACTOR;
    if (LPamount > totalLPs >> 6) { revert ExcessiveLiquidityInput(); }

    // raise (1+R) to the power of 4
    F_ += (LPamount << 120) / totalLPs;      // (1+R)        (2.120 bits)
    F_ = F_ * F_ >> 120;                     // (1+R)**2     (4.120 bits)
    F_ = F_ * F_ >> 120;                     // (1+R)**4     (8.120 bits)

    // calculate mimumum amount of input tokens corresponding to this amount of LPs
    minInputAmount = (((F_ - (1 << 120)) * (R + c.Delta) >> 120) + 1) * d;
  }

 /**
  * @inheritdoc IStablePlaza
  */
  function getOutputFromLPs(
    uint256 tokenIndex,
    uint256 LPamount
  )
    public view override returns(uint256 maxOutputAmount)
  {
    // collect required data
    uint256 F_ = 1 << 128;
    (uint256 R, uint256 d, Config memory c) = _getReservesAndConfig(tokenIndex);

    // calculates intermediate variable F = (1-R)^4 and then the resulting maximum output amount
    F_ -= (LPamount << 128) * NORMALIZE_FACTOR / (LP_FACTOR_REMOVE * (totalSupply() + c.unclaimedRewards));  // (1-R)      (0.128 bits)
    F_ = F_ * F_ >> 128;                                                                                     // (1-R)**2   (0.128 bits)
    F_ = F_ * F_ >> 128;                                                                                     // (1-R)**4   (0.128 bits)
    maxOutputAmount = (R + c.Delta) * ((1 << 128) - F_) >> 128;

    // apply clamping and scaling
    maxOutputAmount = maxOutputAmount > R ? R : maxOutputAmount;
    maxOutputAmount *= d;
  }

  /**
   * @inheritdoc IStablePlaza
   */
  function getLPsFromOutput(
    uint256 tokenIndex,
    uint256 outputAmount
  )
    public view override returns(uint256 minLPamount)
  {
    // collect data reusing the function designed for swap data
    (uint256 R, uint256 d, Config memory c) = _getReservesAndConfig(tokenIndex);
    outputAmount = (outputAmount - 1) / d + 1;
    if (outputAmount > R) { revert InsufficientLiquidity(); }

    // apply binomial series as in {getLPsFromInput} but now for value below 1
    uint256 X = (outputAmount << 128) / (R + c.Delta);  // X     0.128 bits
    uint256 X_ = X * X >> 128;                          // X**2  0.128 bits
    uint256 R_ = (X >> 2) + (X_ * 3 >> 5);              // R2    0.128 bits
    X_ = X_ * X >> 128;                                 // X**3  0.128 bits
    R_ = R_ + (X_ * 7 >> 7);                            // R3    0.128 bits
    X_ = X_ * X >> 128;                                 // X**4  0.128 bits
    R_ = R_ + (X_ * 77 >> 11);                          // R4    0.128 bits
    X_ = X_ * X >> 128;                                 // X**5  0.128 bits
    R_ = R_ + (X_ * 231 >> 13);                         // R5    0.128 bits
    X_ = X_ * X >> 128;                                 // X**6  0.128 bits
    R_ = R_ + (X_ * 1463 >> 16);                        // R6    0.128 bits

    // calculate minimum amount of LP tokens to be burnt
    minLPamount = (R_ * LP_FACTOR_REMOVE * (totalSupply() + c.unclaimedRewards) / NORMALIZE_FACTOR >> 128) + 1;
  }

  /**
   * @inheritdoc IStablePlaza
   */
  function easySwap(
    uint256 pairSelector,
    uint256 inputAmount,
    uint256 minOutputAmount,
    address destination
  )
    external override returns (uint256 actualOutputAmount)
  {
    // calculate actual amount of tokens that can be traded for the input tokens
    uint256 index0 = pairSelector & 0xFF;
    uint256 index1 = pairSelector >> 8;
    actualOutputAmount = getOutFromIn(index0, index1, inputAmount);
    if (actualOutputAmount < minOutputAmount) { revert InsufficientOutput(); }

    // pull in the input tokens and call low level swap function
    tokens[index0].token.safeTransferFrom(msg.sender, address(this), inputAmount);
    swap(pairSelector, actualOutputAmount, destination, new bytes(0));
  }

  /**
   * @inheritdoc IStablePlaza
   */
  function swap(
    uint256 pairSelector,
    uint256 outputAmount,
    address destination,
    bytes memory data
  )
    public override
  {
    // check that the exchange is unlocked and thus open for business
    Config memory c = SPconfig;
    if (c.locked != 0) { revert ExchangeLocked(); }
    SPconfig.locked = TRADE_LOCK_MASK;

    // gather data from storage
    SwapVariables memory v;
    uint256 index0 = pairSelector & 0xFF;
    uint256 index1 = pairSelector >> 8;
    v.token0 = tokens[index0];
    v.token1 = tokens[index1];
    uint256 allReserves;
    uint256 d0 = uint256(v.token0.denormFactor);
    assembly { allReserves := sload(reserves.slot) }

    // optimistically transfer token and callback if required
    v.token1.token.safeTransfer(destination, outputAmount);
    if (data.length != 0) {
      uint256 amountToPay = (index0 != index1) ? getInFromOut(index0, index1, outputAmount) : (((outputAmount - 1) / d0 + 1) * (c.flashLoanFeeLevel + 10_000) / 10_000) * d0;
      IStablePlazaSwapCallee(msg.sender).stablePlazaSwapCall(v.token1.token, outputAmount, v.token0.token, amountToPay, data);
    }

    { // calculate normalized reserves prior to the trade
      uint256 R0 = ((allReserves >> index0 * 64) & 0xFFFFFFFFFFFFFFFF);
      uint256 R1 = ((allReserves >> index1 * 64) & 0xFFFFFFFFFFFFFFFF);

      // check / calculate balances after the trade and calculate amount received
      v.balance0 = v.token0.token.balanceOf(address(this)) / d0;

      if (index1 == index0) { // repayment check for flashloan
        uint256 scaledOutputAmount = (outputAmount - 1) / d0 + 1;
        v.inputAmount = v.balance0 - (R0 - scaledOutputAmount);
        if (v.balance0 < R0 + scaledOutputAmount * c.flashLoanFeeLevel / 10_000) { revert InsufficientFlashloanRepayment(); }
      }
      else { // invariant check for token swap
        uint256 Delta = uint256(c.Delta);
        v.inputAmount = v.balance0 - R0;
        v.balance1 = R1 - ((outputAmount - 1) / v.token1.denormFactor + 1);
        uint256 B0 = (v.balance0 + Delta) * 10_000 - v.inputAmount * c.feeLevel;
        uint256 B1 = (v.balance1 + Delta);
        if (B0 * B1 < (R0 + Delta) * (R1 + Delta) * 10_000) { revert InvariantViolation(); }
      }
    }

    // update both token reserves with a single write to storage (token0 is second to capture flash loan balance)
    allReserves = (allReserves & (type(uint256).max - (0xFFFFFFFFFFFFFFFF << index1 * 64))) | ((v.balance1 & 0xFFFFFFFFFFFFFFFF) << index1 * 64);
    allReserves = (allReserves & (type(uint256).max - (0xFFFFFFFFFFFFFFFF << index0 * 64))) | ((v.balance0 & 0xFFFFFFFFFFFFFFFF) << index0 * 64);
    assembly { sstore(reserves.slot, allReserves) }

    // update other storage values
    SPconfig.unclaimedRewards = c.unclaimedRewards + uint64(v.inputAmount * c.feeLevel / 10_000 * c.stakerFeeFraction / 256);
    SPconfig.locked = 0;

    // update event log
    if (index1 == index0) { emit FlashLoan(msg.sender, v.token0.token, outputAmount, v.inputAmount * d0); }
    else { emit Swap(msg.sender, v.token0.token, v.token1.token, v.inputAmount * d0, outputAmount, destination); }
  }

  /**
   * @inheritdoc IStablePlaza
   */
  function easyAdd(
    uint256 tokenIndex,
    uint256 inputAmount,
    uint256 minLP,
    address destination
  )
    external override returns (uint256 actualLP)
  {
    // calculate LP tokens that can be generated from the input tokens
    actualLP = getLPsFromInput(tokenIndex, inputAmount);
    if (actualLP < minLP) { revert InsufficientOutput(); }

    // pull in tokens and call addLiquidity function
    tokens[tokenIndex].token.safeTransferFrom(msg.sender, address(this), inputAmount);
    addLiquidity(tokenIndex, actualLP, destination, new bytes(0));
  }

  /**
   * @inheritdoc IStablePlaza
   */
  function addLiquidity(
    uint256 tokenIndex,
    uint256 LPamount,
    address destination,
    bytes memory data
  )
    public override
  {
    // check that the exchange is unlocked and thus open for business
    Config memory c = SPconfig;
    if (c.locked != 0) { revert ExchangeLocked(); }
    SPconfig.locked = TRADE_LOCK_MASK;

    // collect all required data from storage
    uint256 allReserves;
    assembly { allReserves := sload(reserves.slot) }
    Token memory token = tokens[tokenIndex];
    uint256 R = ((allReserves >> tokenIndex * 64) & 0xFFFFFFFFFFFFFFFF);
    uint256 d = uint256(token.denormFactor);
    uint256 t = totalSupply();

    // optimistically mint tokens and call callback if requested
    _mint(destination, LPamount);
    if (data.length != 0) {
      uint256 amountToPay = getInputFromLPs(tokenIndex, LPamount, true);
      IStablePlazaAddCallee(msg.sender).stablePlazaAddCall(LPamount, token.token, amountToPay, data);
    }

    // lookup input token balance
    uint256 B = token.token.balanceOf(address(this)) / d;

    { // verify sufficient liquidity was added to pay for the requested LP tokens
      uint256 LP0_ = (t + c.unclaimedRewards) * LP_FACTOR_ADD / NORMALIZE_FACTOR;     // should still fit in 64 bits
      uint256 LP1_ = LP0_ + LPamount;                                                 // should still fit in 64 bits

      LP0_ = LP0_ * LP0_;                           // LP0**2 (fits in 128 bits)
      LP0_ = LP0_ * LP0_ >> 128;                    // LP0**4 (fits in 128 bits)
      LP1_ = LP1_ * LP1_;                           // LP1**2 (fits in 128 bits)
      LP1_ = LP1_ * LP1_ >> 128;                    // LP1**4 (fits in 128 bits)
      if ((B + c.Delta) * LP0_ < (R + c.Delta) * LP1_) { revert InvariantViolation(); }
    }

    // update reserves
    allReserves = (allReserves & (type(uint256).max - (0xFFFFFFFFFFFFFFFF << tokenIndex * 64))) | ((B & 0xFFFFFFFFFFFFFFFF) << tokenIndex * 64);
    assembly { sstore(reserves.slot, allReserves) }

    // update config state
    SPconfig.Delta = uint64(_calcDelta(allReserves));
    SPconfig.totalSupply = uint64(t + LPamount);
    SPconfig.locked = 0;

    // update event log
    emit LiquidityAdded(destination, token.token, (B - R) * d, LPamount);
  }

  /**
   * @inheritdoc IStablePlaza
   */
  function easyRemove(
    uint256 tokenIndex,
    uint256 LPamount,
    uint256 minOutputAmount,
    address destination
  )
    external override returns (uint256 actualOutput)
  {
    // calculate tokens that may be withdrawn with given LP amount
    actualOutput = getOutputFromLPs(tokenIndex, LPamount);
    if (actualOutput < minOutputAmount) { revert InsufficientOutput(); }

    // burns the LP tokens and call the remove liquidity function
    _burn(msg.sender, LPamount);
    removeLiquidity(tokenIndex, actualOutput, destination, new bytes(0));
  }

 /**
  * @inheritdoc IStablePlaza
  */
  function removeLiquidity(
    uint256 tokenIndex,
    uint256 outputAmount,
    address destination,
    bytes memory data
  )
    public override
  {
    // check that the exchange is unlocked and thus open for business
    Config memory c = SPconfig;
    if (c.locked & TRADE_LOCK_MASK != 0) { revert ExchangeLocked(); }
    SPconfig.locked = TRADE_LOCK_MASK;

    // optimistically transfer token and callback if required
    Token memory token = tokens[tokenIndex];
    token.token.safeTransfer(destination, outputAmount);
    if (data.length != 0) {
      uint256 LPtoBurn = getLPsFromOutput(tokenIndex, outputAmount);
      IStablePlazaRemoveCallee(msg.sender).stablePlazaRemoveCall(token.token, outputAmount, LPtoBurn, data);
    }

    // gather all data needed in calculations
    uint256 allReserves;
    assembly { allReserves := sload(reserves.slot) }
    uint256 R = ((allReserves >> tokenIndex * 64) & 0xFFFFFFFFFFFFFFFF);
    uint256 d = uint256(token.denormFactor);
    uint256 LPtokens = totalSupply();
    uint256 previousSupply = uint256(c.totalSupply);

    // normalize outputAmount to 6 decimals, rounding up
    outputAmount = (outputAmount - 1) / d + 1;

    { // verify sufficient liquidity was added to pay for the requested LP tokens
      uint256 Delta = uint256(c.Delta);
      uint256 LP0_ = (previousSupply + c.unclaimedRewards) * LP_FACTOR_REMOVE / NORMALIZE_FACTOR;  // should still fit in 64 bits
      uint256 LP1_ = LP0_ + LPtokens - previousSupply;                                             // should still fit in 64 bits

      LP0_ = LP0_ * LP0_;                     // LP0**2 (fits in 128 bits)
      LP0_ = LP0_ * LP0_ >> 128;              // LP0**4 (fits in 128 bits)
      LP1_ = LP1_ * LP1_;                     // LP1**2 (fits in 128 bits)
      LP1_ = LP1_ * LP1_ >> 128;              // LP1**4 (fits in 128 bits)
      if ((R - outputAmount + Delta) * LP0_ < (R + Delta) * LP1_) { revert InvariantViolation(); }
    }

    // update exchange reserves
    allReserves = (allReserves & (type(uint256).max - (0xFFFFFFFFFFFFFFFF << tokenIndex * 64))) | (((R - outputAmount) & 0xFFFFFFFFFFFFFFFF) << tokenIndex * 64);
    assembly { sstore(reserves.slot, allReserves) }

    // update other state variables
    SPconfig.Delta = uint64(_calcDelta(allReserves));
    SPconfig.totalSupply = uint64(LPtokens);
    SPconfig.locked = 0;

    // update event log
    emit LiquidityRemoved(msg.sender, token.token, outputAmount * d, previousSupply - LPtokens);
  }

  /**
   * @inheritdoc IStakingContract
   */
  function stake(
    uint256 amountToStake,
    uint32 voluntaryLockupTime
  )
    external override
  {
    // collect tokens
    if (amountToStake == 0) { revert ZeroStakeAdditionIsNotSupported(); }
    stakingToken.safeTransferFrom(msg.sender, address(this), amountToStake);

    // claim rewards if an active stake is already present
    StakerData memory d = stakerData[msg.sender];
    if (d.stakedAmount != 0) { unstake(0); }

    // gather other data for calculations
    Config memory c = SPconfig;
    StakingState memory s = stakingState;

    // sync unclaimed rewards
    uint256 unsyncedRewards = uint256(c.unclaimedRewards) - s.lastSyncedUnclaimedRewards;
    s.rewardsPerShare += uint96((unsyncedRewards << 80) / s.totalShares);

    // calculate equivalent shares and apply clamping
    uint256 maxLockTime = uint256(c.maxLockingTime) * SECONDS_PER_DAY;
    uint256 lockupTime = voluntaryLockupTime > maxLockTime ? maxLockTime : voluntaryLockupTime;
    uint64 sharesEq = uint64((amountToStake >> 32) * ((1 << 32) + uint256(c.maxLockingBonus) * lockupTime * lockupTime * (1 << 32) / (maxLockTime * maxLockTime)) >> 32);
    uint32 unlockTime = d.unlockTime > uint32(block.timestamp + lockupTime) ? d.unlockTime : uint32(block.timestamp + lockupTime);

    // write new staker data to storage
    StakerData storage D = stakerData[msg.sender];
    D.stakedAmount = d.stakedAmount + uint64(amountToStake >> 32);     // This covers all DFP2 ever in circulation
    D.sharesEquivalent = d.sharesEquivalent + sharesEq;                // Includes bonus for locking liquidity
    D.rewardsPerShareWhenStaked = s.rewardsPerShare;                   // Sync with global rewards counter
    D.unlockTime = unlockTime;                                         // When we can unstake again

    // write updated global staking state to storage
    s.totalShares += sharesEq;
    s.lastSyncedUnclaimedRewards = c.unclaimedRewards;
    stakingState = s;

    // update event log
    emit Staked(msg.sender, amountToStake, sharesEq);
  }

  /**
   * @inheritdoc IStakingContract
   */
  function unstake(
    uint256 amountToUnstake
  )
    public override
  {
    // gather required data & check unstake is allowed
    Config memory c = SPconfig;
    StakingState memory s = stakingState;
    StakerData memory d = stakerData[msg.sender];
    if (amountToUnstake != 0 && block.timestamp < d.unlockTime) { revert StakeIsStillLocked(); }

    // gather unclaimed rewards and calculate global rewards per share and rewards for the caller
    uint256 newRewards = uint256(c.unclaimedRewards) - s.lastSyncedUnclaimedRewards;
    s.rewardsPerShare += uint96((newRewards << 80) / s.totalShares);
    uint256 rewards = uint256(s.rewardsPerShare - d.rewardsPerShareWhenStaked) * d.sharesEquivalent >> 80;

    // update reward related states and write unclaimed rewards to storage
    d.rewardsPerShareWhenStaked = s.rewardsPerShare;
    c.unclaimedRewards -= uint64(rewards);
    s.lastSyncedUnclaimedRewards = c.unclaimedRewards;
    SPconfig.unclaimedRewards = c.unclaimedRewards;

    uint64 sharesDestroyed;
    if (amountToUnstake != 0) {
      // calculate remaining & destroyed stake/shares based on average bonus
      uint256 bonus = (uint256(d.sharesEquivalent) << 64) / d.stakedAmount;
      uint256 remainder = ((uint256(d.stakedAmount) << 32) - amountToUnstake) >> 32;
      uint256 sharesRemainder = remainder * bonus >> 64;
      sharesDestroyed = d.sharesEquivalent - uint64(sharesRemainder);

      // update stake / share related state
      s.totalShares -= sharesDestroyed;
      d.stakedAmount = uint64(remainder);
      d.sharesEquivalent = uint64(sharesRemainder);

      // transfer tokens
      stakingToken.safeTransfer(msg.sender, amountToUnstake);
    }

    // write updated user data and global staking state to storage
    stakingState = s;
    if (d.stakedAmount == 0) { delete stakerData[msg.sender]; }
    else { stakerData[msg.sender] = d; }

    // mint rewards
    _mint(msg.sender, rewards);

    // update event log
    emit Unstaked(msg.sender, amountToUnstake, sharesDestroyed, rewards);
  }

  /**
   * @notice Sets exchange lock, under which swap and liquidity add (but not remove) are disabled.
   * @dev Can only be called by the admin of the contract.
   */
  function lockExchange() external onlyAdmin() {
    SPconfig.locked = SPconfig.locked | ADMIN_LOCK_MASK;
    emit LockChanged(msg.sender, SPconfig.locked);
  }

  /**
   * @notice Resets exchange lock.
   * @dev Can only be called by the admin of the contract.
   */
  function unlockExchange() external onlyAdmin() {
    SPconfig.locked = SPconfig.locked & ADMIN_UNLOCK_MASK;
    emit LockChanged(msg.sender, SPconfig.locked);
  }

 /**
  * @notice Change one token in the pool for another.
  * @dev Can only be called by the owner of the contract.
  * @param outgoingIndex Index of the token to be delisted from the exchange
  * @param incomingAddress Address of the token to be listed on the exchange
  */
  function changeListedToken(uint8 outgoingIndex, IERC20 incomingAddress)
  external onlyOwner()
  {
    if (reserves[outgoingIndex] != 0) { revert TokenReserveNotEmpty(); }
    IERC20 outgoingAddress = tokens[outgoingIndex].token;

    // build new token properties struct and store at correct index
    Token memory token;
    token.token = incomingAddress;
    token.denormFactor = uint64(10**(IERC20Metadata(address(incomingAddress)).decimals() - BASE_DECIMALS));
    denormFactors[outgoingIndex] = token.denormFactor;
    tokens[outgoingIndex] = token;

    // update offsetIndex helper variable
    delete offsetIndex[outgoingAddress];
    offsetIndex[incomingAddress] = outgoingIndex + 1;

    // update event log
    emit ListingChange(outgoingAddress, incomingAddress);
  }

  /**
   * @notice Sets admin address for emergency exchange locking.
   * @dev Can only be called by the owner of the contract.
   * @param adminAddress Address of the admin to set
   */
  function setAdmin(address adminAddress) external onlyOwner() {
    admin = adminAddress;
    emit AdminChanged(adminAddress);
  }

  /**
   * @notice Update configurable parameters of the contract.
   * @dev Can only be called by the owner of the contract.
   * @param newFeeLevel The new fee level to use for swaps / liquidity adds, as parts out of 10000 (max fee 2.55%)
   * @param newFlashLoanFeeLevel The new fee level to use for flashloans, as parts out of 10000 (max fee 2.55%)
   * @param newStakerFeeFraction The new cut of the fee for the stakers (parts out of 256)
   * @param newMaxLockingBonus The new bonus that can be achieved by staking longer
   * @param newMaxLockingTime The new time at which maximum bonus is achieved
   */
  function updateConfig(
    uint8 newFeeLevel,
    uint8 newFlashLoanFeeLevel,
    uint8 newStakerFeeFraction,
    uint8 newMaxLockingBonus,
    uint16 newMaxLockingTime
  ) external onlyOwner() {
    // load current config from storage and update relevant parameters
    Config storage C = SPconfig;
    C.feeLevel = newFeeLevel;
    C.flashLoanFeeLevel = newFlashLoanFeeLevel;
    C.stakerFeeFraction = newStakerFeeFraction;
    C.maxLockingBonus = newMaxLockingBonus;
    C.maxLockingTime = newMaxLockingTime;

    // update event log
    emit ConfigUpdated(newFeeLevel, newFlashLoanFeeLevel, newStakerFeeFraction, newMaxLockingBonus, newMaxLockingTime);
  }

  /**
   * @notice Initialise the contract.
   * @dev Can only be called once and can only be called by the owner of the contract.
   */
  function initialise() external onlyOwner() {
    if (SPconfig.Delta != 0) { revert(); } // dev: already initialised
    uint256 reserve;
    uint256 allReserves;
    uint256 toMint;
    for (uint256 i; i < NR_OF_TOKENS; ) {
      Token memory token = tokens[i];
      reserve = token.token.balanceOf(address(this)) / token.denormFactor;
      allReserves = (allReserves & (type(uint256).max - (0xFFFFFFFFFFFFFFFF << i * 64))) | ((reserve & 0xFFFFFFFFFFFFFFFF) << i * 64);
      toMint += reserve;
      unchecked { ++i; }
    }
    assembly { sstore(reserves.slot, allReserves) }
    SPconfig.Delta = uint64(_calcDelta(allReserves));
    SPconfig.totalSupply = uint64(toMint);
    _mint(msg.sender, toMint);
  }

  /**
   * @notice Calculate the virtual liquidity required to project onto desired curve.
   * @dev Used when liquidity is added or removed.
   */
  function _calcDelta(uint256 allReserves) internal pure returns (uint256 Delta) {
    for (uint256 i; i < NR_OF_TOKENS; ) {
      Delta += (allReserves >> i * 64) & 0xFFFFFFFFFFFFFFFF;
      unchecked { ++i; }
    }
    Delta = Delta * 50;
  }

  /**
   * @notice Returns the normalized reserves with denormFactors for a trading pair as well as exchange config struct.
   * @dev Helper function to retrieve parameters used in calculations in multiple places.
   */
  function _getPairReservesAndConfig(uint256 inputIndex, uint256 outputIndex)
  internal view returns (
    uint256 R0,
    uint256 R1,
    uint256 d0,
    uint256 d1,
    Config memory config )
  {
    // gather data
    config = SPconfig;
    uint256 allReserves;
    uint256 allDenormFactors;
    assembly { allReserves := sload(reserves.slot) }
    assembly { allDenormFactors := sload(denormFactors.slot) }

    // bitmask relevant reserves from storage slot
    R0 = (allReserves >> inputIndex * 64) & 0xFFFFFFFFFFFFFFFF;
    R1 = (allReserves >> outputIndex * 64) & 0xFFFFFFFFFFFFFFFF;

    // bitmask relevant denormFactors from storage slot
    d0 = (allDenormFactors >> inputIndex * 64) & 0xFFFFFFFFFFFFFFFF;
    d1 = (allDenormFactors >> outputIndex * 64) & 0xFFFFFFFFFFFFFFFF;
  }

  /**
   * @notice Calculates the normalized reserves for a trading pair and the oneMinusFee helper variable.
   * @dev Helper function to retrieve parameters used in calculations in multiple places.
   */
  function _getReservesAndConfig(uint256 tokenIndex)
  internal view returns (uint256 R, uint256 d, Config memory config) {
    R = reserves[tokenIndex];
    d = denormFactors[tokenIndex];
    config = SPconfig;
  }
}

File 2 of 14 : IStablePlaza.sol
// SPDX-License-Identifier: MIT
pragma solidity >=0.6.0;

import "IERC20.sol";

/**
 * @title StablePlaza exchange contract, a low-cost multi token DEX for stable coins.
 * @author Jazzer9F
 */
interface IStablePlaza {
  error TokenNotFound();                        // 0xcbdb7b30
  error ExchangeLocked();                       // 0x2903d20f
  error InsufficientOutput();                   // 0xbb2875c3
  error InvariantViolation();                   // 0x302e29cb
  error StakeIsStillLocked();                   // 0x828aa811
  error AdminRightsRequired();                  // 0x9c60c1ef
  error TokenReserveNotEmpty();                 // 0x51692a42
  error InsufficientLiquidity();                // 0xbb55fd27
  error ExcessiveLiquidityInput();              // 0x5bdb0437
  error InsufficientFlashloanRepayment();       // 0x56cc0682
  error ZeroStakeAdditionIsNotSupported();      // 0xa38d3034

  // exchange configuration
  struct Config {
    uint16 locked;                    // 1st bit is function lock, 2nd bit is admin lock (16 bits to align the rest properly)
    uint8 feeLevel;                   // parts out of 10000 levied as fee on swaps / liquidity add (max fee 2.55%)
    uint8 flashLoanFeeLevel;          // parts out of 10000 levied as fee on flash loans (max fee 2.55%)
    uint8 stakerFeeFraction;          // cut of the fee for the stakers (parts out of 256)
    uint8 maxLockingBonus;            // bonus that can be achieved by staking longer
    uint16 maxLockingTime;            // time at which maximum bonus is achieved [days]
    uint64 Delta;                     // virtual liquidity, projecting onto desired curve
    uint64 unclaimedRewards;          // liquidity rewards that have no owner yet
    uint64 totalSupply;               // copy of the totalSupply for flash removals
  }

  // listed token data
  struct Token {
    IERC20 token;                     // ERC20 contract address of listed token
    uint64 denormFactor;              // factor to scale as if it used 6 decimals
  }

  // used to group variables in swap function
  struct SwapVariables {              // struct keeping variables relevant to swap together
    Token token0;                     // token used as input into the swap
    Token token1;                     // token used as output of the swap
    uint256 balance0;                 // balance of input token
    uint256 balance1;                 // balance of output token
    uint256 inputAmount;              // amount of input token supplied into swap
  }

  // global staking variables squeezed in 256 bits
  struct StakingState {
    uint64 totalShares;                 // total staking shares issued currently
    uint96 rewardsPerShare;             // rewards accumulated per staked token (16.80 bits)
    uint64 lastSyncedUnclaimedRewards;  // unclaimed rewards at last (un)stake
  }

  // struct holding data for each staker
  struct StakerData {
    uint64 stakedAmount;                // amount of staked tokens belonging to this staker (times 2^32)
    uint64 sharesEquivalent;            // equivalent shares of stake (locking longer grants more shares)
    uint96 rewardsPerShareWhenStaked;   // baseline rewards when this stake began (16.80 bits)
    uint32 unlockTime;                  // timestamp when stake can be unstaked
  }

  /**
   * @notice Retrieve the index of a token in the pool.
   * @param token The address of the token to retrieve the index of
   * @return index The index of the token in the pool
   */
  function getIndex(IERC20 token) external view returns (uint256 index);

  /**
   * @notice Retrieve the token corresponding to a certain index.
   * @param index The index of the token in the pool
   * @return token The address of the token to retrieve the index of
   */
  function getTokenFromIndex(uint256 index) external view returns (IERC20 token);

  /**
   * @notice Calculates the maximum outputToken that can be asked for a certain amount of inputToken.
   * @param inputIndex The index of the inputToken on StablePlaza tokens array
   * @param outputIndex The index of the outputToken on StablePlaza tokens array
   * @param inputAmount The amount of inputToken to be used
   * @return maxOutputAmount The maximum amount of outputToken that can be asked for
   */
  function getOutFromIn(
    uint256 inputIndex,
    uint256 outputIndex,
    uint256 inputAmount
  ) external view returns(uint256 maxOutputAmount);

  /**
   * @notice Calculates the minimum input required to swap a certain output
   * @param inputIndex The index of the inputToken on StablePlaza tokens array
   * @param outputIndex The index of the outputToken on StablePlaza tokens array
   * @param outputAmount The amount of outputToken desired
   * @return minInputAmount The minimum amount of inputToken required
   */
  function getInFromOut(
    uint256 inputIndex,
    uint256 outputIndex,
    uint256 outputAmount
  ) external view returns(uint256 minInputAmount);

  /**
   * @notice Calculates the amount of LP tokens generated for given input amount
   * @param tokenIndex The index of the token in the reserves array
   * @param inputAmount The amount of the input token added as new liquidity
   * @return maxLPamount The maximum amount of LP tokens generated
   */
  function getLPsFromInput(
    uint256 tokenIndex,
    uint256 inputAmount
  ) external view returns(uint256 maxLPamount);

  /**
   * @notice Calculates the amount of input tokens required to generate a certain amount of LP tokens
   * @param tokenIndex The index of the token in the reserves array
   * @param LPamount The amount of LP tokens to be generated
   * @param fromCallback Set to true if this function is called from IStablePlazaAddCallee to compensate for preminted LPs
   * @return minInputAmount The minimum amount of input tokens required
   */
  function getInputFromLPs(
    uint256 tokenIndex,
    uint256 LPamount,
    bool fromCallback
  ) external view returns(uint256 minInputAmount);

  /**
   * @notice Calculates the amount tokens released when withdrawing a certain amount of LP tokens
   * @param tokenIndex The index of the token in the reserves array
   * @param LPamount The amount of LP tokens of the caller to be burnt
   * @return maxOutputAmount The amount of tokens that can be withdrawn for this amount of LP tokens
   */
  function getOutputFromLPs(
    uint256 tokenIndex,
    uint256 LPamount
  ) external view returns(uint256 maxOutputAmount);

  /**
   * @notice Calculates the amount of LP tokens required for to withdraw given amount of tokens
   * @param tokenIndex The index of the token in the reserves array
   * @param outputAmount The amount of tokens the caller wishes to receive
   * @return minLPamount The minimum amount of LP tokens required
   */
  function getLPsFromOutput(
    uint256 tokenIndex,
    uint256 outputAmount
  ) external view returns(uint256 minLPamount);

  /**
   * @notice Function to allow users to swap between any two tokens listed on the DEX. Confirms the trade meets the user requirements and then invokes {swap}.
   * @dev If the amount of output tokens falls below the `minOutputAmount` due to slippage, the swap will fail.
   * @param pairSelector The index of the input token + 256 times the index of the output token
   * @param inputAmount Amount of tokens inputed into the swap
   * @param minOutputAmount Minimum desired amount of output tokens
   * @param destination Address to send the amount of output tokens to
   * @return actualOutput The actual amount of output tokens send to the destination address
   */
  function easySwap(
    uint256 pairSelector,
    uint256 inputAmount,
    uint256 minOutputAmount,
    address destination
  ) external returns (uint256 actualOutput);

  /**
   * @notice Low level function to allow users to swap between any two tokens listed on the DEX. User needs to prepay or pay in the callback function. Does not protect against overpaying. For use in smart contracts which perform safety checks.
   * @dev Follows the constant product (x*y=k) swap invariant hyperbole with virtual liquidity.
   * @param pairSelector The index of the input token + 256 times the index of the output token
   * @param outputAmount Desired amount of output received from the swap
   * @param destination Address to send the amount of output output tokens to
   * @param data When not empty, swap callback function is invoked and this data array is passed through
   */
  function swap(
    uint256 pairSelector,
    uint256 outputAmount,
    address destination,
    bytes calldata data
  ) external;

  /**
   * @notice Single sided liquidity add which takes some tokens from the user, adds them to the liquidity pool and converts them into LP tokens.
   * @notice Adding followed by withdrawing incurs a penalty of ~0.74% when the exchange is in balance. The penalty can be mitigated or even be converted into a gain by adding to a token that is underrepresented and withdrawing from a token that is overrepresented in the exchange.
   * @dev Mathematically works like adding all tokens and swapping back to 1 token at no fee.
   *
   *         R = (1 + X_supplied/X_initial)^(1/4) - 1
   *         LP_minted = R * LP_total
   *
   * Adding liquidity incurs two forms of price impact.
   *   1. Impact from single sided add which is modeled with 3 internal swaps
   *   2. Impact from the numerical approximation required for calculation
   *
   * Price impact from swaps is limited to 1.5% in the most extreme cases, slippage due to approximation is in the order of 10-8.
   * @dev Takes payment and then invokes {addLiquidity}
   * @param tokenIndex Index of the token to be added
   * @param inputAmount Amount of input tokens to add to the pool
   * @param minLP Minimum accepted amount of LP tokens to receive in return
   * @param destination Address that LP tokens will be credited to
   * @return actualLP Actual amount of LP tokens received in return
   */
  function easyAdd(
    uint256 tokenIndex,
    uint256 inputAmount,
    uint256 minLP,
    address destination
  ) external returns (uint256 actualLP);

  /**
   * @notice Low level liquidity add function that assumes required token amount is already payed or payed in the callback.
   * @dev Doesn't protect the user from overpaying. Only for use in smart contracts which perform safety checks.
   * @param tokenIndex Index of the token to be added
   * @param LPamount Amount of liquidity tokens to be minted
   * @param destination Address that LP tokens will be credited to
   * @param data When not empty, addLiquidity callback function is invoked and this data array is passed through
   */
  function addLiquidity(
    uint256 tokenIndex,
    uint256 LPamount,
    address destination,
    bytes calldata data
  ) external;

  /**
   * @notice Single sided liquidity withdrawal.
   * @notice Adding followed by withdrawing incurs a penalty of ~0.74% when the exchange is in balance. The penalty can be mitigated or even be converted into a gain by adding to a token that is underrepresented and withdrawing from a token that is overrepresented in the exchange.
   * @dev Mathematically withdraws all 4 tokens in ratio and then swaps 3 back in at no fees.
   * Calculates the following:
   *
   *        R = LP_burnt / LP_initial
   *        X_out = X_initial * (1 - (1 - R)^4)
   *
   * No fee is applied for withdrawals.
   * @param tokenIndex Index of the token to be withdrawn, ranging from 0 to 3
   * @param LPamount Amount of LP tokens to exchange for the token to be withdrawn
   * @param minOutputAmount Minimum desired amount of tokens to receive in return
   * @param destination Address where the withdrawn liquidity is sent to
   * @return actualOutput Actual amount of tokens received in return
   */
  function easyRemove(
   uint256 tokenIndex,
   uint256 LPamount,
   uint256 minOutputAmount,
   address destination
  ) external returns (uint256 actualOutput);

  /**
   * @notice Low level liquidity remove function providing callback functionality. Doesn't protect the user from overpaying. Only for use in smart contracts which perform required calculations.
   * @param tokenIndex Index of the token to be withdrawn, ranging from 0 to 3
   * @param outputAmount Amount of tokens to be withdrawn from the pool
   * @param destination Address where the withdrawn liquidity is sent to
   * @param data Any data is passed through to the callback function
   */
  function removeLiquidity(
    uint256 tokenIndex,
    uint256 outputAmount,
    address destination,
    bytes calldata data
  ) external;

  /**
   * @notice Emit Swap event when tokens are swapped
   * @param sender Address of the caller
   * @param inputToken Input token of the swap
   * @param outputToken Output token of the swap
   * @param inputAmount Amount of input tokens inputed into the swap function
   * @param outputAmount Amount of output tokens received from the swap function
   * @param destination Address the amount of output tokens were sent to
   */
  event Swap(
    address sender,
    IERC20 inputToken,
    IERC20 outputToken,
    uint256 inputAmount,
    uint256 outputAmount,
    address destination
  );

  /**
   * @notice Emit Swap event when tokens are swapped
   * @param lender Address of the caller
   * @param token Token that was loaned out
   * @param amountLoaned The amount that was loaned out Output token of the swap
   * @param amountRepayed The amount that was repayed (includes fee)
   */
  event FlashLoan(
    address lender,
    IERC20 token,
    uint256 amountLoaned,
    uint256 amountRepayed
  );

  /**
   * @notice Emit LiquidityAdded event when liquidity is added
   * @param sender Address of the caller
   * @param token The token the liquidity was added in
   * @param tokenAmount Amount of tokens added
   * @param LPs Actual ammount of LP tokens minted
   */
  event LiquidityAdded(
    address sender,
    IERC20 token,
    uint256 tokenAmount,
    uint256 LPs
  );

  /**
   * @notice Emit LiquidityRemoved event when liquidity is removed
   * @param creditor Address of the entity withdrawing their liquidity
   * @param token The token the liquidity was removed from
   * @param tokenAmount Amount of tokens removed
   * @param LPs Actual ammount of LP tokens burned
   */
  event LiquidityRemoved(
    address creditor,
    IERC20 token,
    uint256 tokenAmount,
    uint256 LPs
  );

  /**
   * @notice Emit ListingChange event when listed tokens change
   * @param removedToken Token that used to be listed before this event
   * @param replacementToken Token that is listed from now on
   */
  event ListingChange(
    IERC20 removedToken,
    IERC20 replacementToken
  );

  /**
   * @notice Emit adminChanged event when the exchange admin address is changed
   * @param newAdmin Address of new admin, who can (un)lock the exchange
   */
  event AdminChanged(
    address newAdmin
  );

  /**
   * @notice Emit LockChanged event when the exchange is (un)locked by an admin
   * @param exchangeAdmin Address of the admin making the change
   * @param newLockValue The updated value of the lock variable
   */
  event LockChanged(
    address exchangeAdmin,
    uint256 newLockValue
  );

  /**
   * @notice Emit configUpdated event when parameters are changed
   * @param newFeeLevel Fee for swapping and adding liquidity (bps)
   * @param newFlashLoanFeeLevel Fee for flashloans (bps)
   * @param newStakerFeeFraction Fraction out of 256 of fee that is shared with stakers (-)
   * @param newMaxLockingBonus Maximum staker bonus for locking liquidity longer (-)
   * @param newMaxLockingTime Amount of time for which the maximum bonus is given (d)
   */
  event ConfigUpdated(
    uint8 newFeeLevel,
    uint8 newFlashLoanFeeLevel,
    uint8 newStakerFeeFraction,
    uint8 newMaxLockingBonus,
    uint16 newMaxLockingTime
  );
}

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

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 `to`.
     *
     * Returns a boolean value indicating whether the operation succeeded.
     *
     * Emits a {Transfer} event.
     */
    function transfer(address to, uint256 amount) external returns (bool);

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

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

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

    /**
     * @dev Emitted when `value` tokens are moved from one account (`from`) to
     * another (`to`).
     *
     * Note that `value` may be zero.
     */
    event Transfer(address indexed from, address indexed to, uint256 value);

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

File 4 of 14 : IStakingContract.sol
// SPDX-License-Identifier: MIT
pragma solidity >=0.6.0;

/**
 * @title StablePlaza staking interface
 * @author Jazzer9F
 */
interface IStakingContract {

 /**
  * @notice Stake configured staking token to receive a split of the the trading fee in return.
  * @param amountToStake Amount of tokens to stake
  * @param voluntaryLockupTime A voluntary lockup period to receive a fee splitting bonus.
  * Please note that it is impossible to unstake before the `voluntaryLockupTime` has expired.
  */
  function stake(
    uint256 amountToStake,
    uint32 voluntaryLockupTime
  ) external;

 /**
  * @notice Unstake tokens that have previously been staked. Rewards are in LP tokens.
  * @dev Only possible if the optional `voluntaryLockupTime` has expired.
  * @param amountToUnstake Amount of tokens to unstake
  */
  function unstake(
    uint256 amountToUnstake
  ) external;

 /**
  * @notice Emit Staked event when new tokens are staked
  * @param staker Address of the caller
  * @param stakedAmount Amount of tokens staked
  * @param sharesEquivalent The amount of tokens staked plus any bonuses due to voluntary locking
  */
  event Staked(
    address staker,
    uint256 stakedAmount,
    uint64 sharesEquivalent
  );

 /**
  * @notice Emit Unstaked event when new tokens are unstaked
  * @param staker Address of the caller
  * @param unstakedAmount Amount of tokens unstaked
  * @param sharesDestroyed The amount of tokens unstaked plus any bonuses due to voluntary locking
  * @param rewards Staking rewards in LP tokens returned to the caller
  */
  event Unstaked(
    address staker,
    uint256 unstakedAmount,
    uint64 sharesDestroyed,
    uint256 rewards
  );
}

File 5 of 14 : IStablePlazaAddCallee.sol
// SPDX-License-Identifier: MIT
pragma solidity >=0.6.0;

import "IERC20.sol";

interface IStablePlazaAddCallee {
   /**
    * @notice Called to `msg.sender` after executing a swap via IStablePlaza#swap.
    * @dev By the end of this callback the tokens owed for the LP tokens should have been payed.
    * @param LPamount Amount of LP tokens credited to the requested address.
    * @param tokenToPay The token that should be used to pay for the LP tokens.
    * @param amountToPay The amount of tokens required to repay the exchange.
    * @param data Any data passed through by the caller via the IStablePlaza#addLiquidity call
    */
    function stablePlazaAddCall(uint256 LPamount, IERC20 tokenToPay, uint256 amountToPay, bytes calldata data) external;
}

File 6 of 14 : IStablePlazaSwapCallee.sol
// SPDX-License-Identifier: MIT
pragma solidity >=0.6.0;

import "IERC20.sol";

interface IStablePlazaSwapCallee {
   /**
    * @notice Called to `msg.sender` after executing a swap via IStablePlaza#swap.
    * @dev By the end of this callback the tokens owed for the swap should have been payed.
    * @param outputToken The token that was credited to the requested destination.
    * @param outputAmount Amount of output tokens that was credited to the destination.
    * @param tokenToPay The token that should be used to pay for the trade.
    * @param amountToPay Minimum amount required to repay the exchange.
    * @param data Any data passed through by the caller via the IStablePlaza#swap call
    */
    function stablePlazaSwapCall(IERC20 outputToken, uint256 outputAmount, IERC20 tokenToPay, uint256 amountToPay, bytes calldata data) external;
}

File 7 of 14 : IStablePlazaRemoveCallee.sol
// SPDX-License-Identifier: MIT
pragma solidity >=0.6.0;

import "IERC20.sol";

interface IStablePlazaRemoveCallee {
   /**
    * @notice Called to `msg.sender` after executing a swap via IStablePlaza#swap.
    * @dev By the end of this callback the LP tokens owed should have been burnt.
    * @param outputToken The token that is credited to the caller.
    * @param outputAmount Amount of output tokens credited to the requested address.
    * @param LPtoBurn Amount of LP tokens that should be burnt to pay for the trade.
    * @param data Any data passed through by the caller via the IStablePlaza#addLiquidity call
    */
    function stablePlazaRemoveCall(IERC20 outputToken, uint256 outputAmount, uint256 LPtoBurn, bytes calldata data) external;
}

File 8 of 14 : Ownable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (access/Ownable.sol)

pragma solidity ^0.8.0;

import "Context.sol";

/**
 * @dev Contract module which provides a basic access control mechanism, where
 * there is an account (an owner) that can be granted exclusive access to
 * specific functions.
 *
 * By default, the owner account will be the one that deploys the contract. This
 * can later be changed with {transferOwnership}.
 *
 * This module is used through inheritance. It will make available the modifier
 * `onlyOwner`, which can be applied to your functions to restrict their use to
 * the owner.
 */
abstract contract Ownable is Context {
    address private _owner;

    event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);

    /**
     * @dev Initializes the contract setting the deployer as the initial owner.
     */
    constructor() {
        _transferOwnership(_msgSender());
    }

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

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

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

    /**
     * @dev Transfers ownership of the contract to a new account (`newOwner`).
     * Can only be called by the current owner.
     */
    function transferOwnership(address newOwner) public virtual onlyOwner {
        require(newOwner != address(0), "Ownable: new owner is the zero address");
        _transferOwnership(newOwner);
    }

    /**
     * @dev Transfers ownership of the contract to a new account (`newOwner`).
     * Internal function without access restriction.
     */
    function _transferOwnership(address newOwner) internal virtual {
        address oldOwner = _owner;
        _owner = newOwner;
        emit OwnershipTransferred(oldOwner, newOwner);
    }
}

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

pragma solidity ^0.8.0;

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

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

File 10 of 14 : ERC20.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.5.0) (token/ERC20/ERC20.sol)

pragma solidity ^0.8.0;

import "IERC20.sol";
import "IERC20Metadata.sol";
import "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 Contracts guidelines: functions revert
 * instead 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:
     *
     * - `to` cannot be the zero address.
     * - the caller must have a balance of at least `amount`.
     */
    function transfer(address to, uint256 amount) public virtual override returns (bool) {
        address owner = _msgSender();
        _transfer(owner, to, 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}.
     *
     * NOTE: If `amount` is the maximum `uint256`, the allowance is not updated on
     * `transferFrom`. This is semantically equivalent to an infinite approval.
     *
     * Requirements:
     *
     * - `spender` cannot be the zero address.
     */
    function approve(address spender, uint256 amount) public virtual override returns (bool) {
        address owner = _msgSender();
        _approve(owner, 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}.
     *
     * NOTE: Does not update the allowance if the current allowance
     * is the maximum `uint256`.
     *
     * Requirements:
     *
     * - `from` and `to` cannot be the zero address.
     * - `from` must have a balance of at least `amount`.
     * - the caller must have allowance for ``from``'s tokens of at least
     * `amount`.
     */
    function transferFrom(
        address from,
        address to,
        uint256 amount
    ) public virtual override returns (bool) {
        address spender = _msgSender();
        _spendAllowance(from, spender, amount);
        _transfer(from, to, 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) {
        address owner = _msgSender();
        _approve(owner, spender, _allowances[owner][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) {
        address owner = _msgSender();
        uint256 currentAllowance = _allowances[owner][spender];
        require(currentAllowance >= subtractedValue, "ERC20: decreased allowance below zero");
        unchecked {
            _approve(owner, 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:
     *
     * - `from` cannot be the zero address.
     * - `to` cannot be the zero address.
     * - `from` must have a balance of at least `amount`.
     */
    function _transfer(
        address from,
        address to,
        uint256 amount
    ) internal virtual {
        require(from != address(0), "ERC20: transfer from the zero address");
        require(to != address(0), "ERC20: transfer to the zero address");

        _beforeTokenTransfer(from, to, amount);

        uint256 fromBalance = _balances[from];
        require(fromBalance >= amount, "ERC20: transfer amount exceeds balance");
        unchecked {
            _balances[from] = fromBalance - amount;
        }
        _balances[to] += amount;

        emit Transfer(from, to, amount);

        _afterTokenTransfer(from, to, 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 Spend `amount` form the allowance of `owner` toward `spender`.
     *
     * Does not update the allowance amount in case of infinite allowance.
     * Revert if not enough allowance is available.
     *
     * Might emit an {Approval} event.
     */
    function _spendAllowance(
        address owner,
        address spender,
        uint256 amount
    ) internal virtual {
        uint256 currentAllowance = allowance(owner, spender);
        if (currentAllowance != type(uint256).max) {
            require(currentAllowance >= amount, "ERC20: insufficient allowance");
            unchecked {
                _approve(owner, spender, currentAllowance - 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 11 of 14 : IERC20Metadata.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (token/ERC20/extensions/IERC20Metadata.sol)

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 12 of 14 : SafeERC20.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (token/ERC20/utils/SafeERC20.sol)

pragma solidity ^0.8.0;

import "IERC20.sol";
import "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 13 of 14 : Address.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.5.0) (utils/Address.sol)

pragma solidity ^0.8.1;

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

        return account.code.length > 0;
    }

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

File 14 of 14 : ERC20Burnable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.5.0) (token/ERC20/extensions/ERC20Burnable.sol)

pragma solidity ^0.8.0;

import "ERC20.sol";
import "Context.sol";

/**
 * @dev Extension of {ERC20} that allows token holders to destroy both their own
 * tokens and those that they have an allowance for, in a way that can be
 * recognized off-chain (via event analysis).
 */
abstract contract ERC20Burnable is Context, ERC20 {
    /**
     * @dev Destroys `amount` tokens from the caller.
     *
     * See {ERC20-_burn}.
     */
    function burn(uint256 amount) public virtual {
        _burn(_msgSender(), amount);
    }

    /**
     * @dev Destroys `amount` tokens from `account`, deducting from the caller's
     * allowance.
     *
     * See {ERC20-_burn} and {ERC20-allowance}.
     *
     * Requirements:
     *
     * - the caller must have allowance for ``accounts``'s tokens of at least
     * `amount`.
     */
    function burnFrom(address account, uint256 amount) public virtual {
        _spendAllowance(account, _msgSender(), amount);
        _burn(account, amount);
    }
}

Settings
{
  "evmVersion": "istanbul",
  "optimizer": {
    "enabled": true,
    "runs": 200
  },
  "libraries": {
    "StablePlaza.sol": {}
  },
  "outputSelection": {
    "*": {
      "*": [
        "evm.bytecode",
        "evm.deployedBytecode",
        "devdoc",
        "userdoc",
        "metadata",
        "abi"
      ]
    }
  }
}

Contract Security Audit

Contract ABI

[{"inputs":[{"internalType":"contract IERC20[]","name":"tokensToList","type":"address[]"},{"internalType":"contract IERC20","name":"stakingTokenAddress","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"inputs":[],"name":"AdminRightsRequired","type":"error"},{"inputs":[],"name":"ExcessiveLiquidityInput","type":"error"},{"inputs":[],"name":"ExchangeLocked","type":"error"},{"inputs":[],"name":"InsufficientFlashloanRepayment","type":"error"},{"inputs":[],"name":"InsufficientLiquidity","type":"error"},{"inputs":[],"name":"InsufficientOutput","type":"error"},{"inputs":[],"name":"InvariantViolation","type":"error"},{"inputs":[],"name":"StakeIsStillLocked","type":"error"},{"inputs":[],"name":"TokenNotFound","type":"error"},{"inputs":[],"name":"TokenReserveNotEmpty","type":"error"},{"inputs":[],"name":"ZeroStakeAdditionIsNotSupported","type":"error"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"newAdmin","type":"address"}],"name":"AdminChanged","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"owner","type":"address"},{"indexed":true,"internalType":"address","name":"spender","type":"address"},{"indexed":false,"internalType":"uint256","name":"value","type":"uint256"}],"name":"Approval","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint8","name":"newFeeLevel","type":"uint8"},{"indexed":false,"internalType":"uint8","name":"newFlashLoanFeeLevel","type":"uint8"},{"indexed":false,"internalType":"uint8","name":"newStakerFeeFraction","type":"uint8"},{"indexed":false,"internalType":"uint8","name":"newMaxLockingBonus","type":"uint8"},{"indexed":false,"internalType":"uint16","name":"newMaxLockingTime","type":"uint16"}],"name":"ConfigUpdated","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"lender","type":"address"},{"indexed":false,"internalType":"contract IERC20","name":"token","type":"address"},{"indexed":false,"internalType":"uint256","name":"amountLoaned","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"amountRepayed","type":"uint256"}],"name":"FlashLoan","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"sender","type":"address"},{"indexed":false,"internalType":"contract IERC20","name":"token","type":"address"},{"indexed":false,"internalType":"uint256","name":"tokenAmount","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"LPs","type":"uint256"}],"name":"LiquidityAdded","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"creditor","type":"address"},{"indexed":false,"internalType":"contract IERC20","name":"token","type":"address"},{"indexed":false,"internalType":"uint256","name":"tokenAmount","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"LPs","type":"uint256"}],"name":"LiquidityRemoved","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"contract IERC20","name":"removedToken","type":"address"},{"indexed":false,"internalType":"contract IERC20","name":"replacementToken","type":"address"}],"name":"ListingChange","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"exchangeAdmin","type":"address"},{"indexed":false,"internalType":"uint256","name":"newLockValue","type":"uint256"}],"name":"LockChanged","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"previousOwner","type":"address"},{"indexed":true,"internalType":"address","name":"newOwner","type":"address"}],"name":"OwnershipTransferred","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"staker","type":"address"},{"indexed":false,"internalType":"uint256","name":"stakedAmount","type":"uint256"},{"indexed":false,"internalType":"uint64","name":"sharesEquivalent","type":"uint64"}],"name":"Staked","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"sender","type":"address"},{"indexed":false,"internalType":"contract IERC20","name":"inputToken","type":"address"},{"indexed":false,"internalType":"contract IERC20","name":"outputToken","type":"address"},{"indexed":false,"internalType":"uint256","name":"inputAmount","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"outputAmount","type":"uint256"},{"indexed":false,"internalType":"address","name":"destination","type":"address"}],"name":"Swap","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"from","type":"address"},{"indexed":true,"internalType":"address","name":"to","type":"address"},{"indexed":false,"internalType":"uint256","name":"value","type":"uint256"}],"name":"Transfer","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"staker","type":"address"},{"indexed":false,"internalType":"uint256","name":"unstakedAmount","type":"uint256"},{"indexed":false,"internalType":"uint64","name":"sharesDestroyed","type":"uint64"},{"indexed":false,"internalType":"uint256","name":"rewards","type":"uint256"}],"name":"Unstaked","type":"event"},{"inputs":[],"name":"SPconfig","outputs":[{"internalType":"uint16","name":"locked","type":"uint16"},{"internalType":"uint8","name":"feeLevel","type":"uint8"},{"internalType":"uint8","name":"flashLoanFeeLevel","type":"uint8"},{"internalType":"uint8","name":"stakerFeeFraction","type":"uint8"},{"internalType":"uint8","name":"maxLockingBonus","type":"uint8"},{"internalType":"uint16","name":"maxLockingTime","type":"uint16"},{"internalType":"uint64","name":"Delta","type":"uint64"},{"internalType":"uint64","name":"unclaimedRewards","type":"uint64"},{"internalType":"uint64","name":"totalSupply","type":"uint64"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenIndex","type":"uint256"},{"internalType":"uint256","name":"LPamount","type":"uint256"},{"internalType":"address","name":"destination","type":"address"},{"internalType":"bytes","name":"data","type":"bytes"}],"name":"addLiquidity","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"admin","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"owner","type":"address"},{"internalType":"address","name":"spender","type":"address"}],"name":"allowance","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"spender","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"approve","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"account","type":"address"}],"name":"balanceOf","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"burn","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"account","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"burnFrom","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint8","name":"outgoingIndex","type":"uint8"},{"internalType":"contract IERC20","name":"incomingAddress","type":"address"}],"name":"changeListedToken","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"decimals","outputs":[{"internalType":"uint8","name":"","type":"uint8"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"spender","type":"address"},{"internalType":"uint256","name":"subtractedValue","type":"uint256"}],"name":"decreaseAllowance","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"denormFactors","outputs":[{"internalType":"uint64","name":"","type":"uint64"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenIndex","type":"uint256"},{"internalType":"uint256","name":"inputAmount","type":"uint256"},{"internalType":"uint256","name":"minLP","type":"uint256"},{"internalType":"address","name":"destination","type":"address"}],"name":"easyAdd","outputs":[{"internalType":"uint256","name":"actualLP","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenIndex","type":"uint256"},{"internalType":"uint256","name":"LPamount","type":"uint256"},{"internalType":"uint256","name":"minOutputAmount","type":"uint256"},{"internalType":"address","name":"destination","type":"address"}],"name":"easyRemove","outputs":[{"internalType":"uint256","name":"actualOutput","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"pairSelector","type":"uint256"},{"internalType":"uint256","name":"inputAmount","type":"uint256"},{"internalType":"uint256","name":"minOutputAmount","type":"uint256"},{"internalType":"address","name":"destination","type":"address"}],"name":"easySwap","outputs":[{"internalType":"uint256","name":"actualOutputAmount","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"inputIndex","type":"uint256"},{"internalType":"uint256","name":"outputIndex","type":"uint256"},{"internalType":"uint256","name":"outputAmount","type":"uint256"}],"name":"getInFromOut","outputs":[{"internalType":"uint256","name":"minInputAmount","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"contract IERC20","name":"token","type":"address"}],"name":"getIndex","outputs":[{"internalType":"uint256","name":"index","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenIndex","type":"uint256"},{"internalType":"uint256","name":"LPamount","type":"uint256"},{"internalType":"bool","name":"fromCallback","type":"bool"}],"name":"getInputFromLPs","outputs":[{"internalType":"uint256","name":"minInputAmount","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenIndex","type":"uint256"},{"internalType":"uint256","name":"inputAmount","type":"uint256"}],"name":"getLPsFromInput","outputs":[{"internalType":"uint256","name":"maxLPamount","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenIndex","type":"uint256"},{"internalType":"uint256","name":"outputAmount","type":"uint256"}],"name":"getLPsFromOutput","outputs":[{"internalType":"uint256","name":"minLPamount","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"inputIndex","type":"uint256"},{"internalType":"uint256","name":"outputIndex","type":"uint256"},{"internalType":"uint256","name":"inputAmount","type":"uint256"}],"name":"getOutFromIn","outputs":[{"internalType":"uint256","name":"maxOutputAmount","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenIndex","type":"uint256"},{"internalType":"uint256","name":"LPamount","type":"uint256"}],"name":"getOutputFromLPs","outputs":[{"internalType":"uint256","name":"maxOutputAmount","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"index","type":"uint256"}],"name":"getTokenFromIndex","outputs":[{"internalType":"contract IERC20","name":"token","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"spender","type":"address"},{"internalType":"uint256","name":"addedValue","type":"uint256"}],"name":"increaseAllowance","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"initialise","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"lockExchange","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"name","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenIndex","type":"uint256"},{"internalType":"uint256","name":"outputAmount","type":"uint256"},{"internalType":"address","name":"destination","type":"address"},{"internalType":"bytes","name":"data","type":"bytes"}],"name":"removeLiquidity","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"renounceOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"reserves","outputs":[{"internalType":"uint64","name":"","type":"uint64"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"adminAddress","type":"address"}],"name":"setAdmin","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"amountToStake","type":"uint256"},{"internalType":"uint32","name":"voluntaryLockupTime","type":"uint32"}],"name":"stake","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"stakerData","outputs":[{"internalType":"uint64","name":"stakedAmount","type":"uint64"},{"internalType":"uint64","name":"sharesEquivalent","type":"uint64"},{"internalType":"uint96","name":"rewardsPerShareWhenStaked","type":"uint96"},{"internalType":"uint32","name":"unlockTime","type":"uint32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"stakingState","outputs":[{"internalType":"uint64","name":"totalShares","type":"uint64"},{"internalType":"uint96","name":"rewardsPerShare","type":"uint96"},{"internalType":"uint64","name":"lastSyncedUnclaimedRewards","type":"uint64"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"stakingToken","outputs":[{"internalType":"contract IERC20","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"pairSelector","type":"uint256"},{"internalType":"uint256","name":"outputAmount","type":"uint256"},{"internalType":"address","name":"destination","type":"address"},{"internalType":"bytes","name":"data","type":"bytes"}],"name":"swap","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"symbol","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"tokens","outputs":[{"internalType":"contract IERC20","name":"token","type":"address"},{"internalType":"uint64","name":"denormFactor","type":"uint64"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"totalSupply","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"transfer","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"from","type":"address"},{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"transferFrom","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"unlockExchange","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"amountToUnstake","type":"uint256"}],"name":"unstake","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint8","name":"newFeeLevel","type":"uint8"},{"internalType":"uint8","name":"newFlashLoanFeeLevel","type":"uint8"},{"internalType":"uint8","name":"newStakerFeeFraction","type":"uint8"},{"internalType":"uint8","name":"newMaxLockingBonus","type":"uint8"},{"internalType":"uint16","name":"newMaxLockingTime","type":"uint16"}],"name":"updateConfig","outputs":[],"stateMutability":"nonpayable","type":"function"}]

600260a0819052600360c081905260e0526055610100526101205260b4610140526000610160819052620f4240610180526101a0819052720f4240000000000000000000b4025503030002600f55610220604052643635c9adc56101c08190526101e082905261020091909152601080546001600160e01b03191690911790553480156200008c57600080fd5b5060405162004e2e38038062004e2e833981016040819052620000af9162000423565b6040518060400160405280600b81526020016a537461626c65506c617a6160a81b8152506040518060400160405280600381526020016205853560ec1b8152506200010962000103620002f660201b60201c565b620002fa565b81516200011e9060049060208501906200034a565b508051620001349060059060208401906200034a565b5050506001600160a01b0381166080528151600090819081906004146200015a57600080fd5b60005b6004811015620002ea578581815181106200017c576200017c62000509565b60200260200101519150816001600160a01b0316836001600160a01b031610620001a557600080fd5b6006826001600160a01b031663313ce5676040518163ffffffff1660e01b8152600401602060405180830381865afa158015620001e6573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906200020c91906200051f565b62000218919062000561565b6200022590600a62000686565b935083600b82600481106200023e576200023e62000509565b600491828204019190066008026101000a8154816001600160401b0302191690836001600160401b031602179055508060016200027c919062000697565b6001600160a01b0383166000908152600d602052604081209190915560068260048110620002ae57620002ae62000509565b0180546001600160401b038716600160a01b026001600160e01b03199091166001600160a01b038616171790555090915081906001016200015d565b505050505050620006ee565b3390565b600080546001600160a01b038381166001600160a01b0319831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b8280546200035890620006b2565b90600052602060002090601f0160209004810192826200037c5760008555620003c7565b82601f106200039757805160ff1916838001178555620003c7565b82800160010185558215620003c7579182015b82811115620003c7578251825591602001919060010190620003aa565b50620003d5929150620003d9565b5090565b5b80821115620003d55760008155600101620003da565b634e487b7160e01b600052604160045260246000fd5b80516001600160a01b03811681146200041e57600080fd5b919050565b600080604083850312156200043757600080fd5b82516001600160401b03808211156200044f57600080fd5b818501915085601f8301126200046457600080fd5b81516020828211156200047b576200047b620003f0565b8160051b604051601f19603f83011681018181108682111715620004a357620004a3620003f0565b604052928352818301935084810182019289841115620004c257600080fd5b948201945b83861015620004eb57620004db8662000406565b85529482019493820193620004c7565b9650620004fc905087820162000406565b9450505050509250929050565b634e487b7160e01b600052603260045260246000fd5b6000602082840312156200053257600080fd5b815160ff811681146200054457600080fd5b9392505050565b634e487b7160e01b600052601160045260246000fd5b600060ff821660ff8416808210156200057e576200057e6200054b565b90039392505050565b600181815b80851115620005c8578160001904821115620005ac57620005ac6200054b565b80851615620005ba57918102915b93841c93908002906200058c565b509250929050565b600082620005e15750600162000680565b81620005f05750600062000680565b8160018114620006095760028114620006145762000634565b600191505062000680565b60ff8411156200062857620006286200054b565b50506001821b62000680565b5060208310610133831016604e8410600b841016171562000659575081810a62000680565b62000665838362000587565b80600019048211156200067c576200067c6200054b565b0290505b92915050565b60006200054460ff841683620005d0565b60008219821115620006ad57620006ad6200054b565b500190565b600181811c90821680620006c757607f821691505b602082108103620006e857634e487b7160e01b600052602260045260246000fd5b50919050565b608051614716620007186000396000818161054201528181611942015261258501526147166000f3fe608060405234801561001057600080fd5b50600436106102895760003560e01c8063728425a71161015c578063a457c2d7116100ce578063cebe7a5111610087578063cebe7a5114610725578063dbd340fd1461072d578063dd62ed3e14610740578063e082f1d414610779578063f2fde38b146107db578063f851a440146107ee57600080fd5b8063a457c2d714610632578063a9059cbb14610645578063ad2f17f014610658578063b2d66e661461066b578063b31610db1461067e578063ce9972aa1461069157600080fd5b806379cc67901161012057806379cc6790146105b55780638334278d146105c85780638806ed28146105f35780638da5cb5b1461060657806395d89b41146106175780639946ce7d1461061f57600080fd5b8063728425a71461047757806372f702f31461053d57806377423c3f1461057c57806378a96cc01461058f57806378ddd01c146105a257600080fd5b8063313ce56711610200578063592e6f59116101b9578063592e6f5914610410578063634573c914610418578063691ea2f01461042b578063704b6c021461043357806370a0823114610446578063715018a61461046f57600080fd5b8063313ce5671461037b578063395093511461038a57806342966c681461039d5780634b5992df146103b05780634f64b2be146103c35780635562c0b9146103fd57600080fd5b80631138e524116102525780631138e524146103145780631166180f1461032757806318160ddd1461033a578063198a3d751461034257806323b872dd146103555780632e17de781461036857600080fd5b8062af4f581461028e578063022c0d9f146102b457806306fdde03146102c9578063095ea7b3146102de578063106290a914610301575b600080fd5b6102a161029c366004613e8f565b610801565b6040519081526020015b60405180910390f35b6102c76102c2366004613edc565b6108ec565b005b6102d1610fba565b6040516102ab919061400a565b6102f16102ec36600461401d565b61104c565b60405190151581526020016102ab565b6102a161030f366004613e8f565b611066565b6102c7610322366004614058565b611221565b6102a16103353660046140d0565b611328565b6003546102a1565b6102c7610350366004614111565b6113a9565b6102f161036336600461414a565b61160a565b6102c761037636600461418b565b611630565b604051600681526020016102ab565b6102f161039836600461401d565b611ae4565b6102c76103ab36600461418b565b611b23565b6102c76103be366004613edc565b611b30565b6103d66103d136600461418b565b611f65565b604080516001600160a01b0390931683526001600160401b039091166020830152016102ab565b6102a161040b3660046141a4565b611f96565b6102c761209d565b6102a16104263660046140d0565b612264565b6102c76122de565b6102c76104413660046141d0565b612374565b6102a16104543660046141d0565b6001600160a01b031660009081526001602052604090205490565b6102c76123f2565b600f546104de9061ffff8082169160ff62010000820481169263010000008304821692600160201b8104831692600160281b82041691600160301b820416906001600160401b03600160401b8204811691600160801b8104821691600160c01b9091041689565b6040805161ffff9a8b16815260ff998a16602082015297891690880152948716606087015292909516608085015290941660a08301526001600160401b0392831660c083015292821660e08201529116610100820152610120016102ab565b6105647f000000000000000000000000000000000000000000000000000000000000000081565b6040516001600160a01b0390911681526020016102ab565b6102a161058a3660046141fb565b612428565b6102c761059d366004614234565b612557565b6102a16105b0366004613e8f565b61299c565b6102c76105c336600461401d565b612b50565b6105db6105d636600461418b565b612b69565b6040516001600160401b0390911681526020016102ab565b6102c7610601366004613edc565b612b9c565b6000546001600160a01b0316610564565b6102d1612f6f565b61056461062d36600461418b565b612f7e565b6102f161064036600461401d565b612fa4565b6102f161065336600461401d565b613041565b6105db61066636600461418b565b61304f565b6102a16106793660046141a4565b61305f565b6102a161068c3660046141d0565b613141565b6106e661069f3660046141d0565b600c602052600090815260409020546001600160401b0380821691600160401b810490911690600160801b81046001600160601b031690600160e01b900463ffffffff1684565b604080516001600160401b0395861681529490931660208501526001600160601b039091169183019190915263ffffffff1660608201526080016102ab565b6102c7613184565b6102a161073b3660046140d0565b613218565b6102a161074e366004614262565b6001600160a01b03918216600090815260026020908152604080832093909416825291909152205490565b6010546107a9906001600160401b03808216916001600160601b03600160401b82041691600160a01b9091041683565b604080516001600160401b0394851681526001600160601b0390931660208401529216918101919091526060016102ab565b6102c76107e93660046141d0565b61326f565b600e54610564906001600160a01b031681565b6000600160801b81808061081487613307565b9250925092508060e001516001600160401b031661083160035490565b61083b9190614296565b61084990630c11cf746142ae565b61085a620f4240608089901b6142ae565b61086491906142cd565b61086e90856142ef565b9350608061087c85806142ae565b901c9350608061088c85806142ae565b901c935060806108a085600160801b6142ef565b60c08301516108b8906001600160401b031686614296565b6108c291906142ae565b901c94508285116108d357846108d5565b825b94506108e182866142ae565b979650505050505050565b6040805161012081018252600f5461ffff80821680845260ff6201000084048116602086015263010000008404811695850195909552600160201b830485166060850152600160281b83049094166080840152600160301b82041660a08301526001600160401b03600160401b8204811660c0840152600160801b8204811660e0840152600160c01b90910416610100820152901561099e57604051632903d20f60e01b815260040160405180910390fd5b600f805461ffff191660011790556109b4613deb565b60ff8616600887901c600682600481106109d0576109d0614306565b604080518082019091529101546001600160a01b0381168252600160a01b90046001600160401b03166020820152835260068160048110610a1357610a13614306565b604080518082019091529101546001600160a01b0380821683526001600160401b03600160a01b909204821660208085019190915286810184905286510151600a549351921691610a669116898b61341d565b865115610b4c576000838503610ad75781612710886040015160ff16612710610a8f919061431c565b61ffff1684610a9f60018f6142ef565b610aa991906142cd565b610ab4906001614296565b610abe91906142ae565b610ac891906142cd565b610ad291906142ae565b610ae2565b610ae285858c611f96565b60208701515187515160405163339668bd60e21b8152929350339263ce59a2f492610b189290918f919087908f90600401614342565b600060405180830381600087803b158015610b3257600080fd5b505af1158015610b46573d6000803e3d6000fd5b50505050505b6000610b598560406142ae565b83901c6001600160401b031690506000610b748560406142ae565b8751516040516370a0823160e01b81523060048201529186901c6001600160401b0316925084916001600160a01b03909116906370a0823190602401602060405180830381865afa158015610bcd573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610bf1919061437c565b610bfb91906142cd565b6040880152858503610c9e57600083610c1560018e6142ef565b610c1f91906142cd565b610c2a906001614296565b9050610c3681846142ef565b8860400151610c4591906142ef565b6080890152604089015161271090610c609060ff16836142ae565b610c6a91906142cd565b610c749084614296565b88604001511015610c9857604051632b66034160e11b815260040160405180910390fd5b50610db4565b60008860c001516001600160401b03169050828860400151610cc091906142ef565b608089015260208089015101516001600160401b0316610ce160018e6142ef565b610ceb91906142cd565b610cf6906001614296565b610d0090836142ef565b606089015260208901516080890151600091610d219160ff909116906142ae565b828a60400151610d319190614296565b610d3d906127106142ae565b610d4791906142ef565b90506000828a60600151610d5b9190614296565b9050610d678385614296565b610d718487614296565b610d7b91906142ae565b610d87906127106142ae565b610d9182846142ae565b1015610db05760405163302e29cb60e01b815260040160405180910390fd5b5050505b50610dc290508360406142ae565b60608601516001600160401b0316901b610ddd8460406142ae565b610df3906001600160401b03901b6000196142ef565b8316179150836040610e0591906142ae565b85604001516001600160401b0316901b846040610e2291906142ae565b610e38906001600160401b03901b6000196142ef565b831617915081600a55610100866060015160ff16612710886020015160ff168860800151610e6691906142ae565b610e7091906142cd565b610e7a91906142ae565b610e8491906142cd565b8660e00151610e939190614395565b600f805477ffffffffffffffff0000000000000000000000000000ffff1916600160801b6001600160401b03939093169290920261ffff1916919091179055838303610f2f5784515160808601517f0d7d75e01ab95780d3cd1c8ec0dd6c2ce19e3a20427eec8bf53283b6fb8e95f09133918c90610f129086906142ae565b604051610f2294939291906143b7565b60405180910390a1610fae565b84515160208601515160808701517f54787c404bb33c88e86f4baf88183a3b0141d0a848e6a9f7a13b66ae3a9b73d19233929091610f6e9086906142ae565b604080516001600160a01b0395861681529385166020850152918416838301526060830152608082018d9052918b1660a082015290519081900360c00190a15b50505050505050505050565b606060048054610fc9906143e0565b80601f0160208091040260200160405190810160405280929190818152602001828054610ff5906143e0565b80156110425780601f1061101757610100808354040283529160200191611042565b820191906000526020600020905b81548152906001019060200180831161102557829003601f168201915b5050505050905090565b60003361105a818585613480565b60019150505b92915050565b60008060008061107586613307565b9194509250905061108682866142cd565b945060058160c001516001600160401b0316846110a39190614296565b901c85106110c457604051635bdb043760e01b815260040160405180910390fd5b60008160c001516001600160401b0316846110df9190614296565b6110ed90608088901b6142cd565b9050600060806110fd83806142ae565b901c9050600060056111108360036142ae565b61111f911c600285901c6142ef565b9050608061112d84846142ae565b901c9150600761113d83826142ae565b611148911c82614296565b9050608061115684846142ae565b901c9150600b61116783604d6142ae565b611172911c826142ef565b9050608061118084846142ae565b901c9150600d6111918360e76142ae565b61119c911c82614296565b905060806111aa84846142ae565b901c915060106111bc836105b76142ae565b6111c7911c826142ef565b90506080620f42408560e001516001600160401b03166111e660035490565b6111f09190614296565b6111fe630bfb0440856142ae565b61120891906142ae565b61121291906142cd565b901c9998505050505050505050565b6000546001600160a01b031633146112545760405162461bcd60e51b815260040161124b9061441a565b60405180910390fd5b600f805463ffff000019166201000060ff88811691820263ff00000019169290921763010000008884169081029190911765ffff000000001916600160201b88851690810265ff0000000000191691909117600160281b9488169485021767ffff0000000000001916600160301b61ffff881690810291909117865560408051948552602085019390935291830152606082019290925260808101919091527fab32cd9fb93a711b53fd941231e782a7e8c23f9e73c5976134571374067657379060a00160405180910390a1505050505050565b60006113348585611066565b9050828110156113575760405163bb2875c360e01b815260040160405180910390fd5b6113833330866006896004811061137057611370614306565b01546001600160a01b03169291906135a4565b6040805160008152602081019091526113a190869083908590611b30565b949350505050565b6000546001600160a01b031633146113d35760405162461bcd60e51b815260040161124b9061441a565b600a8260ff16600481106113e9576113e9614306565b60048104919091015460039091166008026101000a90046001600160401b031615611427576040516328b4952160e11b815260040160405180910390fd5b600060068360ff166004811061143f5761143f614306565b01546001600160a01b03169050611466604080518082019091526000808252602082015290565b6001600160a01b0383168082526040805163313ce56760e01b815290516006929163313ce5679160048083019260209291908290030181865afa1580156114b1573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906114d5919061444f565b6114df919061446c565b6114ea90600a614573565b6001600160401b031660208201819052600b60ff86166004811061151057611510614306565b600491828204019190066008026101000a8154816001600160401b0302191690836001600160401b031602179055508060068560ff166004811061155657611556614306565b8251910180546020938401516001600160401b0316600160a01b026001600160e01b03199091166001600160a01b039384161717905583166000908152600d90915260408120556115a8846001614582565b6001600160a01b038481166000818152600d602090815260409182902060ff9590951690945580519286168352928201527fd8a4aa5cac6f5d77bea3b5279ffb5a9d816de1ae526cbb093fbb861b96771480910160405180910390a150505050565b6000336116188582856135e2565b61162385858561366e565b60019150505b9392505050565b6040805161012081018252600f5461ffff808216835260ff620100008304811660208086019190915263010000008404821685870152600160201b84048216606080870191909152600160281b8504909216608080870191909152600160301b850490931660a08601526001600160401b03600160401b808604821660c0880152600160801b808704831660e0890152600160c01b90960482166101008801528751808501895260105480841682526001600160601b03838204811683870152600160a01b9091048416828b0152336000908152600c86528a90208a519788018b5254808516885292830490931693860193909352948504169583019590955263ffffffff600160e01b909304929092169181019190915290919083158015906117635750806060015163ffffffff1642105b156117815760405163828aa81160e01b815260040160405180910390fd5b600082604001516001600160401b03168460e001516001600160401b03166117a991906142ef565b83519091506117c5906001600160401b0316605083901b6142cd565b836020018181516117d691906145a7565b6001600160601b03169052506020808301516040840151918501516000926050926001600160401b03169161180b91906145c9565b6001600160601b031661181e91906142ae565b60208601516001600160601b0316604086015260e0870180519190921c925082919061184b9083906145f1565b6001600160401b0390811690915260e0870180518216604088015251600f805491909216600160801b0267ffffffffffffffff60801b19909116179055506000861561196d57600084600001516001600160401b0316604086602001516001600160401b0316901b6118bd91906142cd565b90506000602089602088600001516001600160401b0316901b6118e091906142ef565b901c9050600060406118f284846142ae565b901c905080876020015161190691906145f1565b9350838860000181815161191a91906145f1565b6001600160401b03908116909152838116895282166020890152506119696001600160a01b037f000000000000000000000000000000000000000000000000000000000000000016338c61341d565b5050505b845160108054602088015160408901516001600160401b03908116600160a01b0267ffffffffffffffff60a01b196001600160601b03909316600160401b026001600160a01b03199094169582169590951792909217169290921790558451166000036119e957336000908152600c6020526040812055611a82565b336000908152600c6020908152604091829020865181549288015193880151606089015163ffffffff16600160e01b026001600160e01b036001600160601b03909216600160801b02919091166fffffffffffffffffffffffffffffffff6001600160401b03968716600160401b026fffffffffffffffffffffffffffffffff1990961696909316959095179390931716929092171790555b611a8c338361383c565b60408051338152602081018990526001600160401b038316818301526060810184905290517f359201c0867e6e9e8f7c6443b760a3caa6d2c74569228aa343d188b91eee0f109181900360800190a150505050505050565b3360008181526002602090815260408083206001600160a01b038716845290915281205490919061105a9082908690611b1e908790614296565b613480565b611b2d338261391b565b50565b6040805161012081018252600f5461ffff80821680845260ff6201000084048116602086015263010000008404811695850195909552600160201b830485166060850152600160281b83049094166080840152600160301b82041660a08301526001600160401b03600160401b8204811660c0840152600160801b8204811660e0840152600160c01b909104166101008201529015611be257604051632903d20f60e01b815260040160405180910390fd5b600f805461ffff19166001179055600a54600060068760048110611c0857611c08614306565b60408051808201825291909201546001600160a01b0381168252600160a01b90046001600160401b031660208201529150600090611c479089906142ae565b60208301516001600160401b039185901c82169250166000611c6860035490565b9050611c74888a61383c565b865115611cea576000611c898b8b6001612428565b8551604051631cecb28f60e11b815291925033916339d9651e91611cb6918e919086908e90600401614611565b600060405180830381600087803b158015611cd057600080fd5b505af1158015611ce4573d6000803e3d6000fd5b50505050505b83516040516370a0823160e01b815230600482015260009184916001600160a01b03909116906370a0823190602401602060405180830381865afa158015611d36573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611d5a919061437c565b611d6491906142cd565b90506000620f4240630bfb04408960e001516001600160401b031685611d8a9190614296565b611d9491906142ae565b611d9e91906142cd565b90506000611dac8c83614296565b9050611db882806142ae565b91506080611dc683806142ae565b901c9150611dd481806142ae565b90506080611de282806142ae565b901c9050808960c001516001600160401b031687611e009190614296565b611e0a91906142ae565b828a60c001516001600160401b031685611e249190614296565b611e2e91906142ae565b1015611e4d5760405163302e29cb60e01b815260040160405180910390fd5b50611e5b90508b60406142ae565b6001600160401b038216901b611e728c60406142ae565b611e88906001600160401b03901b6000196142ef565b871617955085600a55611e9a86613a69565b600f80546001600160401b0392909216600160401b026fffffffffffffffff000000000000000019909216919091179055611ed58a83614296565b600f805462010000600160c01b0316600160c01b6001600160401b03939093169290920261ffff191691909117905584517f36f3b2e1a21c19137dd82ec243b0708a1d26b3d1fa1dc49c44c4c366a5878138908a9085611f3588866142ef565b611f3f91906142ae565b8d604051611f5094939291906143b7565b60405180910390a15050505050505050505050565b60068160048110611f7557600080fd5b01546001600160a01b0381169150600160a01b90046001600160401b031682565b600080600080600080611fa98989613aae565b9450945094509450945081600188611fc191906142ef565b611fcb91906142cd565b611fd6906001614296565b965083871115611ff95760405163bb55fd2760e01b815260040160405180910390fd5b82816020015160ff1661271061200f9190614648565b61ffff16888360c001516001600160401b03168761202d9190614296565b61203791906142ef565b61204191906142ae565b888360c001516001600160401b03168861205b9190614296565b61206591906142ae565b612071906127106142ae565b61207b91906142cd565b612086906001614296565b61209091906142ae565b9998505050505050505050565b6000546001600160a01b031633146120c75760405162461bcd60e51b815260040161124b9061441a565b600f54600160401b90046001600160401b0316156120e457600080fd5b6000806000805b60048110156121fc5760006006826004811061210957612109614306565b60408051808201825291909201546001600160a01b038116808352600160a01b9091046001600160401b03166020830181905292516370a0823160e01b8152306004820152919350906370a0823190602401602060405180830381865afa158015612178573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061219c919061437c565b6121a691906142cd565b94506121b38260406142ae565b6001600160401b038616901b6121ca8360406142ae565b6121e0906001600160401b03901b6000196142ef565b851617935084836121f19190614296565b9250506001016120eb565b5081600a5561220a82613a69565b600f805477ffffffffffffffff0000000000000000ffffffffffffffff16600160401b6001600160401b03938416026001600160c01b031617600160c01b9284169290920291909117905561225f338261383c565b505050565b600060ff8516600886901c61227a82828861305f565b92508483101561229d5760405163bb2875c360e01b815260040160405180910390fd5b6122b63330886006866004811061137057611370614306565b6040805160008152602081019091526122d4908890859087906108ec565b5050949350505050565b600e546001600160a01b0316331480159061230457506000546001600160a01b03163314155b1561232257604051639c60c1ef60e01b815260040160405180910390fd5b600f805461fffd811661ffff1990911681179091556040805133815260208101929092527f57c0a369a1527577385e79bbeda6dcfb6bf51dad991efc02e392f31b5533f2a791015b60405180910390a1565b6000546001600160a01b0316331461239e5760405162461bcd60e51b815260040161124b9061441a565b600e80546001600160a01b0319166001600160a01b0383169081179091556040519081527f7ce7ec0b50378fb6c0186ffb5f48325f6593fcb4ca4386f21861af3129188f5c9060200160405180910390a150565b6000546001600160a01b0316331461241c5760405162461bcd60e51b815260040161124b9061441a565b6124266000613bc5565b565b6000600160781b81808061243b88613307565b92509250925060008661244f576000612451565b875b90506000620f4240630bfb04408460e001516001600160401b03168461247660035490565b61248091906142ef565b61248a9190614296565b61249491906142ae565b61249e91906142cd565b9050600681901c8911156124c557604051635bdb043760e01b815260040160405180910390fd5b6124d38160788b901b6142cd565b6124dd9087614296565b955060786124eb87806142ae565b901c955060786124fb87806142ae565b901c95508360788460c001516001600160401b03168761251b9190614296565b612529600160781b8a6142ef565b61253391906142ae565b61253f911c6001614296565b61254991906142ae565b9a9950505050505050505050565b81600003612578576040516328e34c0d60e21b815260040160405180910390fd5b6125ad6001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000163330856135a4565b336000908152600c6020908152604091829020825160808101845290546001600160401b03808216808452600160401b830490911693830193909352600160801b81046001600160601b031693820193909352600160e01b90920463ffffffff16606083015215612622576126226000611630565b6040805161012081018252600f5461ffff808216835262010000820460ff90811660208086019190915263010000008404821685870152600160201b84048216606080870191909152600160281b85049092166080860152600160301b840490921660a0850152600160401b8084046001600160401b0390811660c0870152600160801b8504811660e08701908152600160c01b90950481166101008701528651928301875260105480821684529182046001600160601b031693830193909352600160a01b90048216948101859052915192939192600092612707929091166142ef565b8251909150612723906001600160401b0316605083901b6142cd565b8260200181815161273491906145a7565b6001600160601b031690525060a083015160009061275a90620151809061ffff166142ae565b90506000818763ffffffff1611612777578663ffffffff16612779565b815b90506000602061278984806142ae565b8384896080015160ff1661279d91906142ae565b6127a791906142ae565b6127b590600160201b6142ae565b6127bf91906142cd565b6127cd90600160201b614296565b6127db9060208c901c6142ae565b901c905060006127eb8342614296565b63ffffffff16886060015163ffffffff16116128105761280b8342614296565b612816565b87606001515b336000908152600c602090815260409091208a519293509161283b918d901c90614395565b815467ffffffffffffffff19166001600160401b03919091161781556020890151612867908490614395565b8154602089015168010000000000000000600160e01b0319909116600160401b6001600160401b0393909316929092026bffffffffffffffffffffffff60801b191691909117600160801b6001600160601b0390921691909102176001600160e01b0316600160e01b63ffffffff8416021781558651839088906128ec908390614395565b6001600160401b0390811690915260e08a0151811660408a81018290528a51601080546020808f0151600160a01b90960267ffffffffffffffff60a01b196001600160601b03909716600160401b026001600160a01b031990931694881694909417919091179490941691909117905580513381529182018f9052918616918101919091527f8ad6eb5dc91cf8d77faac3807dcd17313996f79ffdec0f60ceebeb9d343964249150606001611f50565b6000806000806129ab86613307565b91945092509050816129be6001876142ef565b6129c891906142cd565b6129d3906001614296565b9450828511156129f65760405163bb55fd2760e01b815260040160405180910390fd5b60008160c001516001600160401b031684612a119190614296565b612a1f90608088901b6142cd565b905060006080612a2f83806142ae565b901c905060006005612a428360036142ae565b612a51911c600285901c614296565b90506080612a5f84846142ae565b901c91506007612a6f83826142ae565b612a7a911c82614296565b90506080612a8884846142ae565b901c9150600b612a9983604d6142ae565b612aa4911c82614296565b90506080612ab284846142ae565b901c9150600d612ac38360e76142ae565b612ace911c82614296565b90506080612adc84846142ae565b901c91506010612aee836105b76142ae565b612af9911c82614296565b90506080620f42408560e001516001600160401b0316612b1860035490565b612b229190614296565b612b30630c11cf74856142ae565b612b3a91906142ae565b612b4491906142cd565b612090911c6001614296565b612b5b8233836135e2565b612b65828261391b565b5050565b600a8160048110612b7957600080fd5b60049182820401919006600802915054906101000a90046001600160401b031681565b6040805161012081018252600f5461ffff808216835260ff6201000083048116602085015263010000008304811694840194909452600160201b820484166060840152600160281b82049093166080830152600160301b810490921660a08201526001600160401b03600160401b8304811660c0830152600160801b8304811660e0830152600160c01b8304166101008201529060011615612c5157604051632903d20f60e01b815260040160405180910390fd5b600f805461ffff19166001179055600060068660048110612c7457612c74614306565b604080518082019091529101546001600160a01b038116808352600160a01b9091046001600160401b03166020830152909150612cb290858761341d565b825115612d24576000612cc5878761299c565b825160405162b93a6160e61b81529192503391632e4e984091612cf0918a9086908a90600401614663565b600060405180830381600087803b158015612d0a57600080fd5b505af1158015612d1e573d6000803e3d6000fd5b50505050505b600a546000612d348860406142ae565b60208401516001600160401b039184901c82169250166000612d5560035490565b6101008701519091506001600160401b031682612d7360018c6142ef565b612d7d91906142cd565b612d88906001614296565b995060008760c001516001600160401b031690506000620f4240630c11cf748a60e001516001600160401b031685612dc09190614296565b612dca91906142ae565b612dd491906142cd565b9050600083612de38684614296565b612ded91906142ef565b9050612df982806142ae565b91506080612e0783806142ae565b901c9150612e1581806142ae565b90506080612e2382806142ae565b901c905080612e328489614296565b612e3c91906142ae565b82848f8a612e4a91906142ef565b612e549190614296565b612e5e91906142ae565b1015612e7d5760405163302e29cb60e01b815260040160405180910390fd5b5050508a6040612e8d91906142ae565b612e978b866142ef565b6001600160401b0316901b612ead8c60406142ae565b612ec3906001600160401b03901b6000196142ef565b861617945084600a55612ed585613a69565b600f805477ffffffffffffffff0000000000000000ffffffffffffffff16600160401b6001600160401b03938416026001600160c01b031617600160c01b928516929092029190911761ffff1916905585517f3b5c196aff80bb96c03b41c96906b66827014de931d1b36e0ede6ee8caeb4bf9903390612f55868e6142ae565b612f5f86866142ef565b604051611f5094939291906143b7565b606060058054610fc9906143e0565b600060068260048110612f9357612f93614306565b01546001600160a01b031692915050565b3360008181526002602090815260408083206001600160a01b0387168452909152812054909190838110156130295760405162461bcd60e51b815260206004820152602560248201527f45524332303a2064656372656173656420616c6c6f77616e63652062656c6f77604482015264207a65726f60d81b606482015260840161124b565b6130368286868403613480565b506001949350505050565b60003361105a81858561366e565b600b8160048110612b7957600080fd5b6000806000806000806130728989613aae565b945094509450945094506000816020015160ff166127106130939190614648565b60c083015161ffff9190911691506001600160401b03166130b4858a6142cd565b9850836130c18a846142ae565b6130cb838a614296565b6130d7906127106142ae565b6130e19190614296565b6130eb8389614296565b6130f58c866142ae565b6130ff91906142ae565b61310991906142cd565b61311391906142ae565b975061311f84876142ae565b8811156131335761313084876142ae565b97505b505050505050509392505050565b6001600160a01b0381166000908152600d60205260408120549081900361317b57604051630cbdb7b360e41b815260040160405180910390fd5b61106081614690565b600e546001600160a01b031633148015906131aa57506000546001600160a01b03163314155b156131c857604051639c60c1ef60e01b815260040160405180910390fd5b600f805461ffff19811661ffff9182161760021791829055604080513381529290911660208301527f57c0a369a1527577385e79bbeda6dcfb6bf51dad991efc02e392f31b5533f2a7910161236a565b60006132248585610801565b9050828110156132475760405163bb2875c360e01b815260040160405180910390fd5b613251338561391b565b6040805160008152602081019091526113a190869083908590612b9c565b6000546001600160a01b031633146132995760405162461bcd60e51b815260040161124b9061441a565b6001600160a01b0381166132fe5760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b606482015260840161124b565b611b2d81613bc5565b600080613312613e43565b600a846004811061332557613325614306565b600491828204019190066008029054906101000a90046001600160401b03166001600160401b03169250600b846004811061336257613362614306565b6004810491909101546040805161012081018252600f5461ffff808216835262010000820460ff908116602085015263010000008304811694840194909452600160201b820484166060840152600160281b82049093166080830152600160301b810490921660a08201526001600160401b03600160401b8304811660c0830152600160801b8304811660e0830152600160c01b9092048216610100808301919091529698600390941660080290960a909104169450915050565b6040516001600160a01b03831660248201526044810182905261225f90849063a9059cbb60e01b906064015b60408051601f198184030181529190526020810180516001600160e01b03166001600160e01b031990931692909217909152613c15565b6001600160a01b0383166134e25760405162461bcd60e51b8152602060048201526024808201527f45524332303a20617070726f76652066726f6d20746865207a65726f206164646044820152637265737360e01b606482015260840161124b565b6001600160a01b0382166135435760405162461bcd60e51b815260206004820152602260248201527f45524332303a20617070726f766520746f20746865207a65726f206164647265604482015261737360f01b606482015260840161124b565b6001600160a01b0383811660008181526002602090815260408083209487168084529482529182902085905590518481527f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925910160405180910390a3505050565b6040516001600160a01b03808516602483015283166044820152606481018290526135dc9085906323b872dd60e01b90608401613449565b50505050565b6001600160a01b0383811660009081526002602090815260408083209386168352929052205460001981146135dc57818110156136615760405162461bcd60e51b815260206004820152601d60248201527f45524332303a20696e73756666696369656e7420616c6c6f77616e6365000000604482015260640161124b565b6135dc8484848403613480565b6001600160a01b0383166136d25760405162461bcd60e51b815260206004820152602560248201527f45524332303a207472616e736665722066726f6d20746865207a65726f206164604482015264647265737360d81b606482015260840161124b565b6001600160a01b0382166137345760405162461bcd60e51b815260206004820152602360248201527f45524332303a207472616e7366657220746f20746865207a65726f206164647260448201526265737360e81b606482015260840161124b565b6001600160a01b038316600090815260016020526040902054818110156137ac5760405162461bcd60e51b815260206004820152602660248201527f45524332303a207472616e7366657220616d6f756e7420657863656564732062604482015265616c616e636560d01b606482015260840161124b565b6001600160a01b038085166000908152600160205260408082208585039055918516815290812080548492906137e3908490614296565b92505081905550826001600160a01b0316846001600160a01b03167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef8460405161382f91815260200190565b60405180910390a36135dc565b6001600160a01b0382166138925760405162461bcd60e51b815260206004820152601f60248201527f45524332303a206d696e7420746f20746865207a65726f206164647265737300604482015260640161124b565b80600360008282546138a49190614296565b90915550506001600160a01b038216600090815260016020526040812080548392906138d1908490614296565b90915550506040518181526001600160a01b038316906000907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef9060200160405180910390a35050565b6001600160a01b03821661397b5760405162461bcd60e51b815260206004820152602160248201527f45524332303a206275726e2066726f6d20746865207a65726f206164647265736044820152607360f81b606482015260840161124b565b6001600160a01b038216600090815260016020526040902054818110156139ef5760405162461bcd60e51b815260206004820152602260248201527f45524332303a206275726e20616d6f756e7420657863656564732062616c616e604482015261636560f01b606482015260840161124b565b6001600160a01b0383166000908152600160205260408120838303905560038054849290613a1e9084906142ef565b90915550506040518281526000906001600160a01b038516907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef9060200160405180910390a3505050565b6000805b6004811015613aa257613a818160406142ae565b83901c6001600160401b031682613a989190614296565b9150600101613a6d565b506110608160326142ae565b600080600080613abc613e43565b506040805161012081018252600f5461ffff808216835260ff6201000083048116602085015263010000008304811684860152600160201b830481166060850152600160281b8304166080840152600160301b82041660a08301526001600160401b03600160401b8204811660c0840152600160801b8204811660e0840152600160c01b90910416610100820152600a54600b549192909190613b60908a906142ae565b82901c6001600160401b03169650613b798860406142ae565b82901c6001600160401b03169550613b928960406142ae565b81901c6001600160401b03169450613bab8860406142ae565b81901c6001600160401b0316935050509295509295909350565b600080546001600160a01b038381166001600160a01b0319831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b6000613c6a826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b0316613ce79092919063ffffffff16565b80519091501561225f5780806020019051810190613c8891906146a7565b61225f5760405162461bcd60e51b815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e6044820152691bdd081cdd58d8d9595960b21b606482015260840161124b565b60606113a18484600085856001600160a01b0385163b613d495760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e7472616374000000604482015260640161124b565b600080866001600160a01b03168587604051613d6591906146c4565b60006040518083038185875af1925050503d8060008114613da2576040519150601f19603f3d011682016040523d82523d6000602084013e613da7565b606091505b50915091506108e182828660608315613dc1575081611629565b825115613dd15782518084602001fd5b8160405162461bcd60e51b815260040161124b919061400a565b6040805160e08101909152600060a0820181815260c083019190915281908152602001613e28604080518082019091526000808252602082015290565b81526020016000815260200160008152602001600081525090565b6040805161012081018252600080825260208201819052918101829052606081018290526080810182905260a0810182905260c0810182905260e0810182905261010081019190915290565b60008060408385031215613ea257600080fd5b50508035926020909101359150565b6001600160a01b0381168114611b2d57600080fd5b634e487b7160e01b600052604160045260246000fd5b60008060008060808587031215613ef257600080fd5b84359350602085013592506040850135613f0b81613eb1565b915060608501356001600160401b0380821115613f2757600080fd5b818701915087601f830112613f3b57600080fd5b813581811115613f4d57613f4d613ec6565b604051601f8201601f19908116603f01168101908382118183101715613f7557613f75613ec6565b816040528281528a6020848701011115613f8e57600080fd5b82602086016020830137600060208483010152809550505050505092959194509250565b60005b83811015613fcd578181015183820152602001613fb5565b838111156135dc5750506000910152565b60008151808452613ff6816020860160208601613fb2565b601f01601f19169290920160200192915050565b6020815260006116296020830184613fde565b6000806040838503121561403057600080fd5b823561403b81613eb1565b946020939093013593505050565b60ff81168114611b2d57600080fd5b600080600080600060a0868803121561407057600080fd5b853561407b81614049565b9450602086013561408b81614049565b9350604086013561409b81614049565b925060608601356140ab81614049565b9150608086013561ffff811681146140c257600080fd5b809150509295509295909350565b600080600080608085870312156140e657600080fd5b843593506020850135925060408501359150606085013561410681613eb1565b939692955090935050565b6000806040838503121561412457600080fd5b823561412f81614049565b9150602083013561413f81613eb1565b809150509250929050565b60008060006060848603121561415f57600080fd5b833561416a81613eb1565b9250602084013561417a81613eb1565b929592945050506040919091013590565b60006020828403121561419d57600080fd5b5035919050565b6000806000606084860312156141b957600080fd5b505081359360208301359350604090920135919050565b6000602082840312156141e257600080fd5b813561162981613eb1565b8015158114611b2d57600080fd5b60008060006060848603121561421057600080fd5b83359250602084013591506040840135614229816141ed565b809150509250925092565b6000806040838503121561424757600080fd5b82359150602083013563ffffffff8116811461413f57600080fd5b6000806040838503121561427557600080fd5b823561412f81613eb1565b634e487b7160e01b600052601160045260246000fd5b600082198211156142a9576142a9614280565b500190565b60008160001904831182151516156142c8576142c8614280565b500290565b6000826142ea57634e487b7160e01b600052601260045260246000fd5b500490565b60008282101561430157614301614280565b500390565b634e487b7160e01b600052603260045260246000fd5b600061ffff80831681851680830382111561433957614339614280565b01949350505050565b6001600160a01b03868116825260208201869052841660408201526060810183905260a0608082018190526000906108e190830184613fde565b60006020828403121561438e57600080fd5b5051919050565b60006001600160401b0380831681851680830382111561433957614339614280565b6001600160a01b0394851681529290931660208301526040820152606081019190915260800190565b600181811c908216806143f457607f821691505b60208210810361441457634e487b7160e01b600052602260045260246000fd5b50919050565b6020808252818101527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604082015260600190565b60006020828403121561446157600080fd5b815161162981614049565b600060ff821660ff84168082101561448657614486614280565b90039392505050565b600181815b808511156144ca5781600019048211156144b0576144b0614280565b808516156144bd57918102915b93841c9390800290614494565b509250929050565b6000826144e157506001611060565b816144ee57506000611060565b8160018114614504576002811461450e5761452a565b6001915050611060565b60ff84111561451f5761451f614280565b50506001821b611060565b5060208310610133831016604e8410600b841016171561454d575081810a611060565b614557838361448f565b806000190482111561456b5761456b614280565b029392505050565b600061162960ff8416836144d2565b600060ff821660ff84168060ff0382111561459f5761459f614280565b019392505050565b60006001600160601b0380831681851680830382111561433957614339614280565b60006001600160601b03838116908316818110156145e9576145e9614280565b039392505050565b60006001600160401b03838116908316818110156145e9576145e9614280565b84815260018060a01b038416602082015282604082015260806060820152600061463e6080830184613fde565b9695505050505050565b600061ffff838116908316818110156145e9576145e9614280565b60018060a01b038516815283602082015282604082015260806060820152600061463e6080830184613fde565b60008161469f5761469f614280565b506000190190565b6000602082840312156146b957600080fd5b8151611629816141ed565b600082516146d6818460208701613fb2565b919091019291505056fea2646970667358221220b01ccf0ae9c5f0c0240b74de5aad52d043e33b67180d7c443dd75bcc6b74048d64736f6c634300080d003300000000000000000000000000000000000000000000000000000000000000400000000000000000000000002f57430a6ceda85a67121757785877b4a71b8e6d00000000000000000000000000000000000000000000000000000000000000040000000000000000000000004fabb145d64652a948d72533023f6e7a623c7c530000000000000000000000006b175474e89094c44da98b954eedeac495271d0f000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48000000000000000000000000dac17f958d2ee523a2206206994597c13d831ec7

Deployed Bytecode

0x608060405234801561001057600080fd5b50600436106102895760003560e01c8063728425a71161015c578063a457c2d7116100ce578063cebe7a5111610087578063cebe7a5114610725578063dbd340fd1461072d578063dd62ed3e14610740578063e082f1d414610779578063f2fde38b146107db578063f851a440146107ee57600080fd5b8063a457c2d714610632578063a9059cbb14610645578063ad2f17f014610658578063b2d66e661461066b578063b31610db1461067e578063ce9972aa1461069157600080fd5b806379cc67901161012057806379cc6790146105b55780638334278d146105c85780638806ed28146105f35780638da5cb5b1461060657806395d89b41146106175780639946ce7d1461061f57600080fd5b8063728425a71461047757806372f702f31461053d57806377423c3f1461057c57806378a96cc01461058f57806378ddd01c146105a257600080fd5b8063313ce56711610200578063592e6f59116101b9578063592e6f5914610410578063634573c914610418578063691ea2f01461042b578063704b6c021461043357806370a0823114610446578063715018a61461046f57600080fd5b8063313ce5671461037b578063395093511461038a57806342966c681461039d5780634b5992df146103b05780634f64b2be146103c35780635562c0b9146103fd57600080fd5b80631138e524116102525780631138e524146103145780631166180f1461032757806318160ddd1461033a578063198a3d751461034257806323b872dd146103555780632e17de781461036857600080fd5b8062af4f581461028e578063022c0d9f146102b457806306fdde03146102c9578063095ea7b3146102de578063106290a914610301575b600080fd5b6102a161029c366004613e8f565b610801565b6040519081526020015b60405180910390f35b6102c76102c2366004613edc565b6108ec565b005b6102d1610fba565b6040516102ab919061400a565b6102f16102ec36600461401d565b61104c565b60405190151581526020016102ab565b6102a161030f366004613e8f565b611066565b6102c7610322366004614058565b611221565b6102a16103353660046140d0565b611328565b6003546102a1565b6102c7610350366004614111565b6113a9565b6102f161036336600461414a565b61160a565b6102c761037636600461418b565b611630565b604051600681526020016102ab565b6102f161039836600461401d565b611ae4565b6102c76103ab36600461418b565b611b23565b6102c76103be366004613edc565b611b30565b6103d66103d136600461418b565b611f65565b604080516001600160a01b0390931683526001600160401b039091166020830152016102ab565b6102a161040b3660046141a4565b611f96565b6102c761209d565b6102a16104263660046140d0565b612264565b6102c76122de565b6102c76104413660046141d0565b612374565b6102a16104543660046141d0565b6001600160a01b031660009081526001602052604090205490565b6102c76123f2565b600f546104de9061ffff8082169160ff62010000820481169263010000008304821692600160201b8104831692600160281b82041691600160301b820416906001600160401b03600160401b8204811691600160801b8104821691600160c01b9091041689565b6040805161ffff9a8b16815260ff998a16602082015297891690880152948716606087015292909516608085015290941660a08301526001600160401b0392831660c083015292821660e08201529116610100820152610120016102ab565b6105647f0000000000000000000000002f57430a6ceda85a67121757785877b4a71b8e6d81565b6040516001600160a01b0390911681526020016102ab565b6102a161058a3660046141fb565b612428565b6102c761059d366004614234565b612557565b6102a16105b0366004613e8f565b61299c565b6102c76105c336600461401d565b612b50565b6105db6105d636600461418b565b612b69565b6040516001600160401b0390911681526020016102ab565b6102c7610601366004613edc565b612b9c565b6000546001600160a01b0316610564565b6102d1612f6f565b61056461062d36600461418b565b612f7e565b6102f161064036600461401d565b612fa4565b6102f161065336600461401d565b613041565b6105db61066636600461418b565b61304f565b6102a16106793660046141a4565b61305f565b6102a161068c3660046141d0565b613141565b6106e661069f3660046141d0565b600c602052600090815260409020546001600160401b0380821691600160401b810490911690600160801b81046001600160601b031690600160e01b900463ffffffff1684565b604080516001600160401b0395861681529490931660208501526001600160601b039091169183019190915263ffffffff1660608201526080016102ab565b6102c7613184565b6102a161073b3660046140d0565b613218565b6102a161074e366004614262565b6001600160a01b03918216600090815260026020908152604080832093909416825291909152205490565b6010546107a9906001600160401b03808216916001600160601b03600160401b82041691600160a01b9091041683565b604080516001600160401b0394851681526001600160601b0390931660208401529216918101919091526060016102ab565b6102c76107e93660046141d0565b61326f565b600e54610564906001600160a01b031681565b6000600160801b81808061081487613307565b9250925092508060e001516001600160401b031661083160035490565b61083b9190614296565b61084990630c11cf746142ae565b61085a620f4240608089901b6142ae565b61086491906142cd565b61086e90856142ef565b9350608061087c85806142ae565b901c9350608061088c85806142ae565b901c935060806108a085600160801b6142ef565b60c08301516108b8906001600160401b031686614296565b6108c291906142ae565b901c94508285116108d357846108d5565b825b94506108e182866142ae565b979650505050505050565b6040805161012081018252600f5461ffff80821680845260ff6201000084048116602086015263010000008404811695850195909552600160201b830485166060850152600160281b83049094166080840152600160301b82041660a08301526001600160401b03600160401b8204811660c0840152600160801b8204811660e0840152600160c01b90910416610100820152901561099e57604051632903d20f60e01b815260040160405180910390fd5b600f805461ffff191660011790556109b4613deb565b60ff8616600887901c600682600481106109d0576109d0614306565b604080518082019091529101546001600160a01b0381168252600160a01b90046001600160401b03166020820152835260068160048110610a1357610a13614306565b604080518082019091529101546001600160a01b0380821683526001600160401b03600160a01b909204821660208085019190915286810184905286510151600a549351921691610a669116898b61341d565b865115610b4c576000838503610ad75781612710886040015160ff16612710610a8f919061431c565b61ffff1684610a9f60018f6142ef565b610aa991906142cd565b610ab4906001614296565b610abe91906142ae565b610ac891906142cd565b610ad291906142ae565b610ae2565b610ae285858c611f96565b60208701515187515160405163339668bd60e21b8152929350339263ce59a2f492610b189290918f919087908f90600401614342565b600060405180830381600087803b158015610b3257600080fd5b505af1158015610b46573d6000803e3d6000fd5b50505050505b6000610b598560406142ae565b83901c6001600160401b031690506000610b748560406142ae565b8751516040516370a0823160e01b81523060048201529186901c6001600160401b0316925084916001600160a01b03909116906370a0823190602401602060405180830381865afa158015610bcd573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610bf1919061437c565b610bfb91906142cd565b6040880152858503610c9e57600083610c1560018e6142ef565b610c1f91906142cd565b610c2a906001614296565b9050610c3681846142ef565b8860400151610c4591906142ef565b6080890152604089015161271090610c609060ff16836142ae565b610c6a91906142cd565b610c749084614296565b88604001511015610c9857604051632b66034160e11b815260040160405180910390fd5b50610db4565b60008860c001516001600160401b03169050828860400151610cc091906142ef565b608089015260208089015101516001600160401b0316610ce160018e6142ef565b610ceb91906142cd565b610cf6906001614296565b610d0090836142ef565b606089015260208901516080890151600091610d219160ff909116906142ae565b828a60400151610d319190614296565b610d3d906127106142ae565b610d4791906142ef565b90506000828a60600151610d5b9190614296565b9050610d678385614296565b610d718487614296565b610d7b91906142ae565b610d87906127106142ae565b610d9182846142ae565b1015610db05760405163302e29cb60e01b815260040160405180910390fd5b5050505b50610dc290508360406142ae565b60608601516001600160401b0316901b610ddd8460406142ae565b610df3906001600160401b03901b6000196142ef565b8316179150836040610e0591906142ae565b85604001516001600160401b0316901b846040610e2291906142ae565b610e38906001600160401b03901b6000196142ef565b831617915081600a55610100866060015160ff16612710886020015160ff168860800151610e6691906142ae565b610e7091906142cd565b610e7a91906142ae565b610e8491906142cd565b8660e00151610e939190614395565b600f805477ffffffffffffffff0000000000000000000000000000ffff1916600160801b6001600160401b03939093169290920261ffff1916919091179055838303610f2f5784515160808601517f0d7d75e01ab95780d3cd1c8ec0dd6c2ce19e3a20427eec8bf53283b6fb8e95f09133918c90610f129086906142ae565b604051610f2294939291906143b7565b60405180910390a1610fae565b84515160208601515160808701517f54787c404bb33c88e86f4baf88183a3b0141d0a848e6a9f7a13b66ae3a9b73d19233929091610f6e9086906142ae565b604080516001600160a01b0395861681529385166020850152918416838301526060830152608082018d9052918b1660a082015290519081900360c00190a15b50505050505050505050565b606060048054610fc9906143e0565b80601f0160208091040260200160405190810160405280929190818152602001828054610ff5906143e0565b80156110425780601f1061101757610100808354040283529160200191611042565b820191906000526020600020905b81548152906001019060200180831161102557829003601f168201915b5050505050905090565b60003361105a818585613480565b60019150505b92915050565b60008060008061107586613307565b9194509250905061108682866142cd565b945060058160c001516001600160401b0316846110a39190614296565b901c85106110c457604051635bdb043760e01b815260040160405180910390fd5b60008160c001516001600160401b0316846110df9190614296565b6110ed90608088901b6142cd565b9050600060806110fd83806142ae565b901c9050600060056111108360036142ae565b61111f911c600285901c6142ef565b9050608061112d84846142ae565b901c9150600761113d83826142ae565b611148911c82614296565b9050608061115684846142ae565b901c9150600b61116783604d6142ae565b611172911c826142ef565b9050608061118084846142ae565b901c9150600d6111918360e76142ae565b61119c911c82614296565b905060806111aa84846142ae565b901c915060106111bc836105b76142ae565b6111c7911c826142ef565b90506080620f42408560e001516001600160401b03166111e660035490565b6111f09190614296565b6111fe630bfb0440856142ae565b61120891906142ae565b61121291906142cd565b901c9998505050505050505050565b6000546001600160a01b031633146112545760405162461bcd60e51b815260040161124b9061441a565b60405180910390fd5b600f805463ffff000019166201000060ff88811691820263ff00000019169290921763010000008884169081029190911765ffff000000001916600160201b88851690810265ff0000000000191691909117600160281b9488169485021767ffff0000000000001916600160301b61ffff881690810291909117865560408051948552602085019390935291830152606082019290925260808101919091527fab32cd9fb93a711b53fd941231e782a7e8c23f9e73c5976134571374067657379060a00160405180910390a1505050505050565b60006113348585611066565b9050828110156113575760405163bb2875c360e01b815260040160405180910390fd5b6113833330866006896004811061137057611370614306565b01546001600160a01b03169291906135a4565b6040805160008152602081019091526113a190869083908590611b30565b949350505050565b6000546001600160a01b031633146113d35760405162461bcd60e51b815260040161124b9061441a565b600a8260ff16600481106113e9576113e9614306565b60048104919091015460039091166008026101000a90046001600160401b031615611427576040516328b4952160e11b815260040160405180910390fd5b600060068360ff166004811061143f5761143f614306565b01546001600160a01b03169050611466604080518082019091526000808252602082015290565b6001600160a01b0383168082526040805163313ce56760e01b815290516006929163313ce5679160048083019260209291908290030181865afa1580156114b1573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906114d5919061444f565b6114df919061446c565b6114ea90600a614573565b6001600160401b031660208201819052600b60ff86166004811061151057611510614306565b600491828204019190066008026101000a8154816001600160401b0302191690836001600160401b031602179055508060068560ff166004811061155657611556614306565b8251910180546020938401516001600160401b0316600160a01b026001600160e01b03199091166001600160a01b039384161717905583166000908152600d90915260408120556115a8846001614582565b6001600160a01b038481166000818152600d602090815260409182902060ff9590951690945580519286168352928201527fd8a4aa5cac6f5d77bea3b5279ffb5a9d816de1ae526cbb093fbb861b96771480910160405180910390a150505050565b6000336116188582856135e2565b61162385858561366e565b60019150505b9392505050565b6040805161012081018252600f5461ffff808216835260ff620100008304811660208086019190915263010000008404821685870152600160201b84048216606080870191909152600160281b8504909216608080870191909152600160301b850490931660a08601526001600160401b03600160401b808604821660c0880152600160801b808704831660e0890152600160c01b90960482166101008801528751808501895260105480841682526001600160601b03838204811683870152600160a01b9091048416828b0152336000908152600c86528a90208a519788018b5254808516885292830490931693860193909352948504169583019590955263ffffffff600160e01b909304929092169181019190915290919083158015906117635750806060015163ffffffff1642105b156117815760405163828aa81160e01b815260040160405180910390fd5b600082604001516001600160401b03168460e001516001600160401b03166117a991906142ef565b83519091506117c5906001600160401b0316605083901b6142cd565b836020018181516117d691906145a7565b6001600160601b03169052506020808301516040840151918501516000926050926001600160401b03169161180b91906145c9565b6001600160601b031661181e91906142ae565b60208601516001600160601b0316604086015260e0870180519190921c925082919061184b9083906145f1565b6001600160401b0390811690915260e0870180518216604088015251600f805491909216600160801b0267ffffffffffffffff60801b19909116179055506000861561196d57600084600001516001600160401b0316604086602001516001600160401b0316901b6118bd91906142cd565b90506000602089602088600001516001600160401b0316901b6118e091906142ef565b901c9050600060406118f284846142ae565b901c905080876020015161190691906145f1565b9350838860000181815161191a91906145f1565b6001600160401b03908116909152838116895282166020890152506119696001600160a01b037f0000000000000000000000002f57430a6ceda85a67121757785877b4a71b8e6d16338c61341d565b5050505b845160108054602088015160408901516001600160401b03908116600160a01b0267ffffffffffffffff60a01b196001600160601b03909316600160401b026001600160a01b03199094169582169590951792909217169290921790558451166000036119e957336000908152600c6020526040812055611a82565b336000908152600c6020908152604091829020865181549288015193880151606089015163ffffffff16600160e01b026001600160e01b036001600160601b03909216600160801b02919091166fffffffffffffffffffffffffffffffff6001600160401b03968716600160401b026fffffffffffffffffffffffffffffffff1990961696909316959095179390931716929092171790555b611a8c338361383c565b60408051338152602081018990526001600160401b038316818301526060810184905290517f359201c0867e6e9e8f7c6443b760a3caa6d2c74569228aa343d188b91eee0f109181900360800190a150505050505050565b3360008181526002602090815260408083206001600160a01b038716845290915281205490919061105a9082908690611b1e908790614296565b613480565b611b2d338261391b565b50565b6040805161012081018252600f5461ffff80821680845260ff6201000084048116602086015263010000008404811695850195909552600160201b830485166060850152600160281b83049094166080840152600160301b82041660a08301526001600160401b03600160401b8204811660c0840152600160801b8204811660e0840152600160c01b909104166101008201529015611be257604051632903d20f60e01b815260040160405180910390fd5b600f805461ffff19166001179055600a54600060068760048110611c0857611c08614306565b60408051808201825291909201546001600160a01b0381168252600160a01b90046001600160401b031660208201529150600090611c479089906142ae565b60208301516001600160401b039185901c82169250166000611c6860035490565b9050611c74888a61383c565b865115611cea576000611c898b8b6001612428565b8551604051631cecb28f60e11b815291925033916339d9651e91611cb6918e919086908e90600401614611565b600060405180830381600087803b158015611cd057600080fd5b505af1158015611ce4573d6000803e3d6000fd5b50505050505b83516040516370a0823160e01b815230600482015260009184916001600160a01b03909116906370a0823190602401602060405180830381865afa158015611d36573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611d5a919061437c565b611d6491906142cd565b90506000620f4240630bfb04408960e001516001600160401b031685611d8a9190614296565b611d9491906142ae565b611d9e91906142cd565b90506000611dac8c83614296565b9050611db882806142ae565b91506080611dc683806142ae565b901c9150611dd481806142ae565b90506080611de282806142ae565b901c9050808960c001516001600160401b031687611e009190614296565b611e0a91906142ae565b828a60c001516001600160401b031685611e249190614296565b611e2e91906142ae565b1015611e4d5760405163302e29cb60e01b815260040160405180910390fd5b50611e5b90508b60406142ae565b6001600160401b038216901b611e728c60406142ae565b611e88906001600160401b03901b6000196142ef565b871617955085600a55611e9a86613a69565b600f80546001600160401b0392909216600160401b026fffffffffffffffff000000000000000019909216919091179055611ed58a83614296565b600f805462010000600160c01b0316600160c01b6001600160401b03939093169290920261ffff191691909117905584517f36f3b2e1a21c19137dd82ec243b0708a1d26b3d1fa1dc49c44c4c366a5878138908a9085611f3588866142ef565b611f3f91906142ae565b8d604051611f5094939291906143b7565b60405180910390a15050505050505050505050565b60068160048110611f7557600080fd5b01546001600160a01b0381169150600160a01b90046001600160401b031682565b600080600080600080611fa98989613aae565b9450945094509450945081600188611fc191906142ef565b611fcb91906142cd565b611fd6906001614296565b965083871115611ff95760405163bb55fd2760e01b815260040160405180910390fd5b82816020015160ff1661271061200f9190614648565b61ffff16888360c001516001600160401b03168761202d9190614296565b61203791906142ef565b61204191906142ae565b888360c001516001600160401b03168861205b9190614296565b61206591906142ae565b612071906127106142ae565b61207b91906142cd565b612086906001614296565b61209091906142ae565b9998505050505050505050565b6000546001600160a01b031633146120c75760405162461bcd60e51b815260040161124b9061441a565b600f54600160401b90046001600160401b0316156120e457600080fd5b6000806000805b60048110156121fc5760006006826004811061210957612109614306565b60408051808201825291909201546001600160a01b038116808352600160a01b9091046001600160401b03166020830181905292516370a0823160e01b8152306004820152919350906370a0823190602401602060405180830381865afa158015612178573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061219c919061437c565b6121a691906142cd565b94506121b38260406142ae565b6001600160401b038616901b6121ca8360406142ae565b6121e0906001600160401b03901b6000196142ef565b851617935084836121f19190614296565b9250506001016120eb565b5081600a5561220a82613a69565b600f805477ffffffffffffffff0000000000000000ffffffffffffffff16600160401b6001600160401b03938416026001600160c01b031617600160c01b9284169290920291909117905561225f338261383c565b505050565b600060ff8516600886901c61227a82828861305f565b92508483101561229d5760405163bb2875c360e01b815260040160405180910390fd5b6122b63330886006866004811061137057611370614306565b6040805160008152602081019091526122d4908890859087906108ec565b5050949350505050565b600e546001600160a01b0316331480159061230457506000546001600160a01b03163314155b1561232257604051639c60c1ef60e01b815260040160405180910390fd5b600f805461fffd811661ffff1990911681179091556040805133815260208101929092527f57c0a369a1527577385e79bbeda6dcfb6bf51dad991efc02e392f31b5533f2a791015b60405180910390a1565b6000546001600160a01b0316331461239e5760405162461bcd60e51b815260040161124b9061441a565b600e80546001600160a01b0319166001600160a01b0383169081179091556040519081527f7ce7ec0b50378fb6c0186ffb5f48325f6593fcb4ca4386f21861af3129188f5c9060200160405180910390a150565b6000546001600160a01b0316331461241c5760405162461bcd60e51b815260040161124b9061441a565b6124266000613bc5565b565b6000600160781b81808061243b88613307565b92509250925060008661244f576000612451565b875b90506000620f4240630bfb04408460e001516001600160401b03168461247660035490565b61248091906142ef565b61248a9190614296565b61249491906142ae565b61249e91906142cd565b9050600681901c8911156124c557604051635bdb043760e01b815260040160405180910390fd5b6124d38160788b901b6142cd565b6124dd9087614296565b955060786124eb87806142ae565b901c955060786124fb87806142ae565b901c95508360788460c001516001600160401b03168761251b9190614296565b612529600160781b8a6142ef565b61253391906142ae565b61253f911c6001614296565b61254991906142ae565b9a9950505050505050505050565b81600003612578576040516328e34c0d60e21b815260040160405180910390fd5b6125ad6001600160a01b037f0000000000000000000000002f57430a6ceda85a67121757785877b4a71b8e6d163330856135a4565b336000908152600c6020908152604091829020825160808101845290546001600160401b03808216808452600160401b830490911693830193909352600160801b81046001600160601b031693820193909352600160e01b90920463ffffffff16606083015215612622576126226000611630565b6040805161012081018252600f5461ffff808216835262010000820460ff90811660208086019190915263010000008404821685870152600160201b84048216606080870191909152600160281b85049092166080860152600160301b840490921660a0850152600160401b8084046001600160401b0390811660c0870152600160801b8504811660e08701908152600160c01b90950481166101008701528651928301875260105480821684529182046001600160601b031693830193909352600160a01b90048216948101859052915192939192600092612707929091166142ef565b8251909150612723906001600160401b0316605083901b6142cd565b8260200181815161273491906145a7565b6001600160601b031690525060a083015160009061275a90620151809061ffff166142ae565b90506000818763ffffffff1611612777578663ffffffff16612779565b815b90506000602061278984806142ae565b8384896080015160ff1661279d91906142ae565b6127a791906142ae565b6127b590600160201b6142ae565b6127bf91906142cd565b6127cd90600160201b614296565b6127db9060208c901c6142ae565b901c905060006127eb8342614296565b63ffffffff16886060015163ffffffff16116128105761280b8342614296565b612816565b87606001515b336000908152600c602090815260409091208a519293509161283b918d901c90614395565b815467ffffffffffffffff19166001600160401b03919091161781556020890151612867908490614395565b8154602089015168010000000000000000600160e01b0319909116600160401b6001600160401b0393909316929092026bffffffffffffffffffffffff60801b191691909117600160801b6001600160601b0390921691909102176001600160e01b0316600160e01b63ffffffff8416021781558651839088906128ec908390614395565b6001600160401b0390811690915260e08a0151811660408a81018290528a51601080546020808f0151600160a01b90960267ffffffffffffffff60a01b196001600160601b03909716600160401b026001600160a01b031990931694881694909417919091179490941691909117905580513381529182018f9052918616918101919091527f8ad6eb5dc91cf8d77faac3807dcd17313996f79ffdec0f60ceebeb9d343964249150606001611f50565b6000806000806129ab86613307565b91945092509050816129be6001876142ef565b6129c891906142cd565b6129d3906001614296565b9450828511156129f65760405163bb55fd2760e01b815260040160405180910390fd5b60008160c001516001600160401b031684612a119190614296565b612a1f90608088901b6142cd565b905060006080612a2f83806142ae565b901c905060006005612a428360036142ae565b612a51911c600285901c614296565b90506080612a5f84846142ae565b901c91506007612a6f83826142ae565b612a7a911c82614296565b90506080612a8884846142ae565b901c9150600b612a9983604d6142ae565b612aa4911c82614296565b90506080612ab284846142ae565b901c9150600d612ac38360e76142ae565b612ace911c82614296565b90506080612adc84846142ae565b901c91506010612aee836105b76142ae565b612af9911c82614296565b90506080620f42408560e001516001600160401b0316612b1860035490565b612b229190614296565b612b30630c11cf74856142ae565b612b3a91906142ae565b612b4491906142cd565b612090911c6001614296565b612b5b8233836135e2565b612b65828261391b565b5050565b600a8160048110612b7957600080fd5b60049182820401919006600802915054906101000a90046001600160401b031681565b6040805161012081018252600f5461ffff808216835260ff6201000083048116602085015263010000008304811694840194909452600160201b820484166060840152600160281b82049093166080830152600160301b810490921660a08201526001600160401b03600160401b8304811660c0830152600160801b8304811660e0830152600160c01b8304166101008201529060011615612c5157604051632903d20f60e01b815260040160405180910390fd5b600f805461ffff19166001179055600060068660048110612c7457612c74614306565b604080518082019091529101546001600160a01b038116808352600160a01b9091046001600160401b03166020830152909150612cb290858761341d565b825115612d24576000612cc5878761299c565b825160405162b93a6160e61b81529192503391632e4e984091612cf0918a9086908a90600401614663565b600060405180830381600087803b158015612d0a57600080fd5b505af1158015612d1e573d6000803e3d6000fd5b50505050505b600a546000612d348860406142ae565b60208401516001600160401b039184901c82169250166000612d5560035490565b6101008701519091506001600160401b031682612d7360018c6142ef565b612d7d91906142cd565b612d88906001614296565b995060008760c001516001600160401b031690506000620f4240630c11cf748a60e001516001600160401b031685612dc09190614296565b612dca91906142ae565b612dd491906142cd565b9050600083612de38684614296565b612ded91906142ef565b9050612df982806142ae565b91506080612e0783806142ae565b901c9150612e1581806142ae565b90506080612e2382806142ae565b901c905080612e328489614296565b612e3c91906142ae565b82848f8a612e4a91906142ef565b612e549190614296565b612e5e91906142ae565b1015612e7d5760405163302e29cb60e01b815260040160405180910390fd5b5050508a6040612e8d91906142ae565b612e978b866142ef565b6001600160401b0316901b612ead8c60406142ae565b612ec3906001600160401b03901b6000196142ef565b861617945084600a55612ed585613a69565b600f805477ffffffffffffffff0000000000000000ffffffffffffffff16600160401b6001600160401b03938416026001600160c01b031617600160c01b928516929092029190911761ffff1916905585517f3b5c196aff80bb96c03b41c96906b66827014de931d1b36e0ede6ee8caeb4bf9903390612f55868e6142ae565b612f5f86866142ef565b604051611f5094939291906143b7565b606060058054610fc9906143e0565b600060068260048110612f9357612f93614306565b01546001600160a01b031692915050565b3360008181526002602090815260408083206001600160a01b0387168452909152812054909190838110156130295760405162461bcd60e51b815260206004820152602560248201527f45524332303a2064656372656173656420616c6c6f77616e63652062656c6f77604482015264207a65726f60d81b606482015260840161124b565b6130368286868403613480565b506001949350505050565b60003361105a81858561366e565b600b8160048110612b7957600080fd5b6000806000806000806130728989613aae565b945094509450945094506000816020015160ff166127106130939190614648565b60c083015161ffff9190911691506001600160401b03166130b4858a6142cd565b9850836130c18a846142ae565b6130cb838a614296565b6130d7906127106142ae565b6130e19190614296565b6130eb8389614296565b6130f58c866142ae565b6130ff91906142ae565b61310991906142cd565b61311391906142ae565b975061311f84876142ae565b8811156131335761313084876142ae565b97505b505050505050509392505050565b6001600160a01b0381166000908152600d60205260408120549081900361317b57604051630cbdb7b360e41b815260040160405180910390fd5b61106081614690565b600e546001600160a01b031633148015906131aa57506000546001600160a01b03163314155b156131c857604051639c60c1ef60e01b815260040160405180910390fd5b600f805461ffff19811661ffff9182161760021791829055604080513381529290911660208301527f57c0a369a1527577385e79bbeda6dcfb6bf51dad991efc02e392f31b5533f2a7910161236a565b60006132248585610801565b9050828110156132475760405163bb2875c360e01b815260040160405180910390fd5b613251338561391b565b6040805160008152602081019091526113a190869083908590612b9c565b6000546001600160a01b031633146132995760405162461bcd60e51b815260040161124b9061441a565b6001600160a01b0381166132fe5760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b606482015260840161124b565b611b2d81613bc5565b600080613312613e43565b600a846004811061332557613325614306565b600491828204019190066008029054906101000a90046001600160401b03166001600160401b03169250600b846004811061336257613362614306565b6004810491909101546040805161012081018252600f5461ffff808216835262010000820460ff908116602085015263010000008304811694840194909452600160201b820484166060840152600160281b82049093166080830152600160301b810490921660a08201526001600160401b03600160401b8304811660c0830152600160801b8304811660e0830152600160c01b9092048216610100808301919091529698600390941660080290960a909104169450915050565b6040516001600160a01b03831660248201526044810182905261225f90849063a9059cbb60e01b906064015b60408051601f198184030181529190526020810180516001600160e01b03166001600160e01b031990931692909217909152613c15565b6001600160a01b0383166134e25760405162461bcd60e51b8152602060048201526024808201527f45524332303a20617070726f76652066726f6d20746865207a65726f206164646044820152637265737360e01b606482015260840161124b565b6001600160a01b0382166135435760405162461bcd60e51b815260206004820152602260248201527f45524332303a20617070726f766520746f20746865207a65726f206164647265604482015261737360f01b606482015260840161124b565b6001600160a01b0383811660008181526002602090815260408083209487168084529482529182902085905590518481527f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925910160405180910390a3505050565b6040516001600160a01b03808516602483015283166044820152606481018290526135dc9085906323b872dd60e01b90608401613449565b50505050565b6001600160a01b0383811660009081526002602090815260408083209386168352929052205460001981146135dc57818110156136615760405162461bcd60e51b815260206004820152601d60248201527f45524332303a20696e73756666696369656e7420616c6c6f77616e6365000000604482015260640161124b565b6135dc8484848403613480565b6001600160a01b0383166136d25760405162461bcd60e51b815260206004820152602560248201527f45524332303a207472616e736665722066726f6d20746865207a65726f206164604482015264647265737360d81b606482015260840161124b565b6001600160a01b0382166137345760405162461bcd60e51b815260206004820152602360248201527f45524332303a207472616e7366657220746f20746865207a65726f206164647260448201526265737360e81b606482015260840161124b565b6001600160a01b038316600090815260016020526040902054818110156137ac5760405162461bcd60e51b815260206004820152602660248201527f45524332303a207472616e7366657220616d6f756e7420657863656564732062604482015265616c616e636560d01b606482015260840161124b565b6001600160a01b038085166000908152600160205260408082208585039055918516815290812080548492906137e3908490614296565b92505081905550826001600160a01b0316846001600160a01b03167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef8460405161382f91815260200190565b60405180910390a36135dc565b6001600160a01b0382166138925760405162461bcd60e51b815260206004820152601f60248201527f45524332303a206d696e7420746f20746865207a65726f206164647265737300604482015260640161124b565b80600360008282546138a49190614296565b90915550506001600160a01b038216600090815260016020526040812080548392906138d1908490614296565b90915550506040518181526001600160a01b038316906000907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef9060200160405180910390a35050565b6001600160a01b03821661397b5760405162461bcd60e51b815260206004820152602160248201527f45524332303a206275726e2066726f6d20746865207a65726f206164647265736044820152607360f81b606482015260840161124b565b6001600160a01b038216600090815260016020526040902054818110156139ef5760405162461bcd60e51b815260206004820152602260248201527f45524332303a206275726e20616d6f756e7420657863656564732062616c616e604482015261636560f01b606482015260840161124b565b6001600160a01b0383166000908152600160205260408120838303905560038054849290613a1e9084906142ef565b90915550506040518281526000906001600160a01b038516907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef9060200160405180910390a3505050565b6000805b6004811015613aa257613a818160406142ae565b83901c6001600160401b031682613a989190614296565b9150600101613a6d565b506110608160326142ae565b600080600080613abc613e43565b506040805161012081018252600f5461ffff808216835260ff6201000083048116602085015263010000008304811684860152600160201b830481166060850152600160281b8304166080840152600160301b82041660a08301526001600160401b03600160401b8204811660c0840152600160801b8204811660e0840152600160c01b90910416610100820152600a54600b549192909190613b60908a906142ae565b82901c6001600160401b03169650613b798860406142ae565b82901c6001600160401b03169550613b928960406142ae565b81901c6001600160401b03169450613bab8860406142ae565b81901c6001600160401b0316935050509295509295909350565b600080546001600160a01b038381166001600160a01b0319831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b6000613c6a826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b0316613ce79092919063ffffffff16565b80519091501561225f5780806020019051810190613c8891906146a7565b61225f5760405162461bcd60e51b815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e6044820152691bdd081cdd58d8d9595960b21b606482015260840161124b565b60606113a18484600085856001600160a01b0385163b613d495760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e7472616374000000604482015260640161124b565b600080866001600160a01b03168587604051613d6591906146c4565b60006040518083038185875af1925050503d8060008114613da2576040519150601f19603f3d011682016040523d82523d6000602084013e613da7565b606091505b50915091506108e182828660608315613dc1575081611629565b825115613dd15782518084602001fd5b8160405162461bcd60e51b815260040161124b919061400a565b6040805160e08101909152600060a0820181815260c083019190915281908152602001613e28604080518082019091526000808252602082015290565b81526020016000815260200160008152602001600081525090565b6040805161012081018252600080825260208201819052918101829052606081018290526080810182905260a0810182905260c0810182905260e0810182905261010081019190915290565b60008060408385031215613ea257600080fd5b50508035926020909101359150565b6001600160a01b0381168114611b2d57600080fd5b634e487b7160e01b600052604160045260246000fd5b60008060008060808587031215613ef257600080fd5b84359350602085013592506040850135613f0b81613eb1565b915060608501356001600160401b0380821115613f2757600080fd5b818701915087601f830112613f3b57600080fd5b813581811115613f4d57613f4d613ec6565b604051601f8201601f19908116603f01168101908382118183101715613f7557613f75613ec6565b816040528281528a6020848701011115613f8e57600080fd5b82602086016020830137600060208483010152809550505050505092959194509250565b60005b83811015613fcd578181015183820152602001613fb5565b838111156135dc5750506000910152565b60008151808452613ff6816020860160208601613fb2565b601f01601f19169290920160200192915050565b6020815260006116296020830184613fde565b6000806040838503121561403057600080fd5b823561403b81613eb1565b946020939093013593505050565b60ff81168114611b2d57600080fd5b600080600080600060a0868803121561407057600080fd5b853561407b81614049565b9450602086013561408b81614049565b9350604086013561409b81614049565b925060608601356140ab81614049565b9150608086013561ffff811681146140c257600080fd5b809150509295509295909350565b600080600080608085870312156140e657600080fd5b843593506020850135925060408501359150606085013561410681613eb1565b939692955090935050565b6000806040838503121561412457600080fd5b823561412f81614049565b9150602083013561413f81613eb1565b809150509250929050565b60008060006060848603121561415f57600080fd5b833561416a81613eb1565b9250602084013561417a81613eb1565b929592945050506040919091013590565b60006020828403121561419d57600080fd5b5035919050565b6000806000606084860312156141b957600080fd5b505081359360208301359350604090920135919050565b6000602082840312156141e257600080fd5b813561162981613eb1565b8015158114611b2d57600080fd5b60008060006060848603121561421057600080fd5b83359250602084013591506040840135614229816141ed565b809150509250925092565b6000806040838503121561424757600080fd5b82359150602083013563ffffffff8116811461413f57600080fd5b6000806040838503121561427557600080fd5b823561412f81613eb1565b634e487b7160e01b600052601160045260246000fd5b600082198211156142a9576142a9614280565b500190565b60008160001904831182151516156142c8576142c8614280565b500290565b6000826142ea57634e487b7160e01b600052601260045260246000fd5b500490565b60008282101561430157614301614280565b500390565b634e487b7160e01b600052603260045260246000fd5b600061ffff80831681851680830382111561433957614339614280565b01949350505050565b6001600160a01b03868116825260208201869052841660408201526060810183905260a0608082018190526000906108e190830184613fde565b60006020828403121561438e57600080fd5b5051919050565b60006001600160401b0380831681851680830382111561433957614339614280565b6001600160a01b0394851681529290931660208301526040820152606081019190915260800190565b600181811c908216806143f457607f821691505b60208210810361441457634e487b7160e01b600052602260045260246000fd5b50919050565b6020808252818101527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604082015260600190565b60006020828403121561446157600080fd5b815161162981614049565b600060ff821660ff84168082101561448657614486614280565b90039392505050565b600181815b808511156144ca5781600019048211156144b0576144b0614280565b808516156144bd57918102915b93841c9390800290614494565b509250929050565b6000826144e157506001611060565b816144ee57506000611060565b8160018114614504576002811461450e5761452a565b6001915050611060565b60ff84111561451f5761451f614280565b50506001821b611060565b5060208310610133831016604e8410600b841016171561454d575081810a611060565b614557838361448f565b806000190482111561456b5761456b614280565b029392505050565b600061162960ff8416836144d2565b600060ff821660ff84168060ff0382111561459f5761459f614280565b019392505050565b60006001600160601b0380831681851680830382111561433957614339614280565b60006001600160601b03838116908316818110156145e9576145e9614280565b039392505050565b60006001600160401b03838116908316818110156145e9576145e9614280565b84815260018060a01b038416602082015282604082015260806060820152600061463e6080830184613fde565b9695505050505050565b600061ffff838116908316818110156145e9576145e9614280565b60018060a01b038516815283602082015282604082015260806060820152600061463e6080830184613fde565b60008161469f5761469f614280565b506000190190565b6000602082840312156146b957600080fd5b8151611629816141ed565b600082516146d6818460208701613fb2565b919091019291505056fea2646970667358221220b01ccf0ae9c5f0c0240b74de5aad52d043e33b67180d7c443dd75bcc6b74048d64736f6c634300080d0033

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

00000000000000000000000000000000000000000000000000000000000000400000000000000000000000002f57430a6ceda85a67121757785877b4a71b8e6d00000000000000000000000000000000000000000000000000000000000000040000000000000000000000004fabb145d64652a948d72533023f6e7a623c7c530000000000000000000000006b175474e89094c44da98b954eedeac495271d0f000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48000000000000000000000000dac17f958d2ee523a2206206994597c13d831ec7

-----Decoded View---------------
Arg [0] : tokensToList (address[]): 0x4Fabb145d64652a948d72533023f6E7A623C7C53,0x6B175474E89094C44Da98b954EedeAC495271d0F,0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48,0xdAC17F958D2ee523a2206206994597C13D831ec7
Arg [1] : stakingTokenAddress (address): 0x2F57430a6ceDA85a67121757785877b4a71b8E6D

-----Encoded View---------------
7 Constructor Arguments found :
Arg [0] : 0000000000000000000000000000000000000000000000000000000000000040
Arg [1] : 0000000000000000000000002f57430a6ceda85a67121757785877b4a71b8e6d
Arg [2] : 0000000000000000000000000000000000000000000000000000000000000004
Arg [3] : 0000000000000000000000004fabb145d64652a948d72533023f6e7a623c7c53
Arg [4] : 0000000000000000000000006b175474e89094c44da98b954eedeac495271d0f
Arg [5] : 000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48
Arg [6] : 000000000000000000000000dac17f958d2ee523a2206206994597c13d831ec7


Block Transaction Difficulty Gas Used Reward
View All Blocks Produced

Block Uncle Number Difficulty Gas Used Reward
View All Uncles
Loading...
Loading
Loading...
Loading

Validator Index Block Amount
View All Withdrawals

Transaction Hash Block Value Eth2 PubKey Valid
View All Deposits
Loading...
Loading
[ Download: CSV Export  ]

A contract address hosts a smart contract, which is a set of code stored on the blockchain that runs when predetermined conditions are met. Learn more about addresses in our Knowledge Base.