Address Details
contract

0x9A470D789BCd392ae4c8f22DB8425b5eF139906C

Contract Name
Exchange
Creator
0xf3eb91–a79239 at 0x298d1b–076fb2
Balance
0 CELO ( )
Locked CELO Balance
0.00 CELO
Voting CELO Balance
0.00 CELO
Pending Unlocked Gold
0.00 CELO
Tokens
Fetching tokens...
Transactions
0 Transactions
Transfers
0 Transfers
Gas Used
Fetching gas used...
Last Balance Update
25141490
This contract has been verified via Sourcify. View contract in Sourcify repository
Contract name:
Exchange




Optimization enabled
false
Compiler version
v0.5.13+commit.5b0b510c




EVM Version
istanbul




Verified at
2022-09-19T21:21:37.593467Z

/Users/mchrzan/celo/celo-monorepo/packages/protocol/contracts/stability/Exchange.sol

pragma solidity ^0.5.13;

import "openzeppelin-solidity/contracts/math/SafeMath.sol";
import "openzeppelin-solidity/contracts/ownership/Ownable.sol";
import "./interfaces/IExchange.sol";
import "./interfaces/ISortedOracles.sol";
import "./interfaces/IReserve.sol";
import "./interfaces/IStableToken.sol";
import "../common/Initializable.sol";
import "../common/FixidityLib.sol";
import "../common/Freezable.sol";
import "../common/UsingRegistry.sol";
import "../common/interfaces/ICeloVersionedContract.sol";
import "../common/libraries/ReentrancyGuard.sol";

/**
 * @title Contract that allows to exchange StableToken for GoldToken and vice versa
 * using a Constant Product Market Maker Model
 */
contract Exchange is
  IExchange,
  ICeloVersionedContract,
  Initializable,
  Ownable,
  UsingRegistry,
  ReentrancyGuard,
  Freezable
{
  using SafeMath for uint256;
  using FixidityLib for FixidityLib.Fraction;

  event Exchanged(address indexed exchanger, uint256 sellAmount, uint256 buyAmount, bool soldGold);
  event UpdateFrequencySet(uint256 updateFrequency);
  event MinimumReportsSet(uint256 minimumReports);
  event StableTokenSet(address indexed stable);
  event SpreadSet(uint256 spread);
  event ReserveFractionSet(uint256 reserveFraction);
  event BucketsUpdated(uint256 goldBucket, uint256 stableBucket);

  FixidityLib.Fraction public spread;

  // Fraction of the Reserve that is committed to the gold bucket when updating
  // buckets.
  FixidityLib.Fraction public reserveFraction;

  address public stable;

  // Size of the Uniswap gold bucket
  uint256 public goldBucket;
  // Size of the Uniswap stable token bucket
  uint256 public stableBucket;

  uint256 public lastBucketUpdate = 0;
  uint256 public updateFrequency;
  uint256 public minimumReports;

  bytes32 public stableTokenRegistryId;

  modifier updateBucketsIfNecessary() {
    _updateBucketsIfNecessary();
    _;
  }

  /**
   * @notice Returns the storage, major, minor, and patch version of the contract.
   * @return The storage, major, minor, and patch version of the contract.
   */
  function getVersionNumber() external pure returns (uint256, uint256, uint256, uint256) {
    return (1, 2, 0, 0);
  }

  /**
   * @notice Sets initialized == true on implementation contracts
   * @param test Set to true to skip implementation initialization
   */
  constructor(bool test) public Initializable(test) {}

  /**
   * @notice Used in place of the constructor to allow the contract to be upgradable via proxy.
   * @param registryAddress The address of the registry core smart contract.
   * @param stableTokenIdentifier String identifier of stabletoken in registry
   * @param _spread Spread charged on exchanges
   * @param _reserveFraction Fraction to commit to the gold bucket
   * @param _updateFrequency The time period that needs to elapse between bucket
   * updates
   * @param _minimumReports The minimum number of fresh reports that need to be
   * present in the oracle to update buckets
   * commit to the gold bucket
   */
  function initialize(
    address registryAddress,
    string calldata stableTokenIdentifier,
    uint256 _spread,
    uint256 _reserveFraction,
    uint256 _updateFrequency,
    uint256 _minimumReports
  ) external initializer {
    _transferOwnership(msg.sender);
    setRegistry(registryAddress);
    stableTokenRegistryId = keccak256(abi.encodePacked(stableTokenIdentifier));
    setSpread(_spread);
    setReserveFraction(_reserveFraction);
    setUpdateFrequency(_updateFrequency);
    setMinimumReports(_minimumReports);
  }

  /**
   * @notice Ensures stable token address is set in storage and initializes buckets.
   * @dev Will revert if stable token is not registered or does not have oracle reports.
   */
  function activateStable() external onlyOwner {
    require(stable == address(0), "StableToken address already activated");
    _setStableToken(registry.getAddressForOrDie(stableTokenRegistryId));
    _updateBucketsIfNecessary();
  }

  /**
   * @notice Exchanges a specific amount of one token for an unspecified amount
   * (greater than a threshold) of another.
   * @param sellAmount The number of tokens to send to the exchange.
   * @param minBuyAmount The minimum number of tokens for the exchange to send in return.
   * @param sellGold True if the caller is sending CELO to the exchange, false otherwise.
   * @return The number of tokens sent by the exchange.
   * @dev The caller must first have approved `sellAmount` to the exchange.
   * @dev This function can be frozen via the Freezable interface.
   */
  function sell(uint256 sellAmount, uint256 minBuyAmount, bool sellGold)
    public
    onlyWhenNotFrozen
    updateBucketsIfNecessary
    nonReentrant
    returns (uint256)
  {
    (uint256 buyTokenBucket, uint256 sellTokenBucket) = _getBuyAndSellBuckets(sellGold);
    uint256 buyAmount = _getBuyTokenAmount(buyTokenBucket, sellTokenBucket, sellAmount);

    require(buyAmount >= minBuyAmount, "Calculated buyAmount was less than specified minBuyAmount");

    _exchange(sellAmount, buyAmount, sellGold);
    return buyAmount;
  }

  /**
   * @dev DEPRECATED - Use `buy` or `sell`.
   * @notice Exchanges a specific amount of one token for an unspecified amount
   * (greater than a threshold) of another.
   * @param sellAmount The number of tokens to send to the exchange.
   * @param minBuyAmount The minimum number of tokens for the exchange to send in return.
   * @param sellGold True if the caller is sending CELO to the exchange, false otherwise.
   * @return The number of tokens sent by the exchange.
   * @dev The caller must first have approved `sellAmount` to the exchange.
   * @dev This function can be frozen via the Freezable interface.
   */
  function exchange(uint256 sellAmount, uint256 minBuyAmount, bool sellGold)
    external
    returns (uint256)
  {
    return sell(sellAmount, minBuyAmount, sellGold);
  }

  /**
   * @notice Exchanges an unspecified amount (up to a threshold) of one token for
   * a specific amount of another.
   * @param buyAmount The number of tokens for the exchange to send in return.
   * @param maxSellAmount The maximum number of tokens to send to the exchange.
   * @param buyGold True if the exchange is sending CELO to the caller, false otherwise.
   * @return The number of tokens sent to the exchange.
   * @dev The caller must first have approved `maxSellAmount` to the exchange.
   * @dev This function can be frozen via the Freezable interface.
   */
  function buy(uint256 buyAmount, uint256 maxSellAmount, bool buyGold)
    external
    onlyWhenNotFrozen
    updateBucketsIfNecessary
    nonReentrant
    returns (uint256)
  {
    bool sellGold = !buyGold;
    (uint256 buyTokenBucket, uint256 sellTokenBucket) = _getBuyAndSellBuckets(sellGold);
    uint256 sellAmount = _getSellTokenAmount(buyTokenBucket, sellTokenBucket, buyAmount);

    require(
      sellAmount <= maxSellAmount,
      "Calculated sellAmount was greater than specified maxSellAmount"
    );

    _exchange(sellAmount, buyAmount, sellGold);
    return sellAmount;
  }

  /**
   * @notice Exchanges a specific amount of one token for a specific amount of another.
   * @param sellAmount The number of tokens to send to the exchange.
   * @param buyAmount The number of tokens for the exchange to send in return.
   * @param sellGold True if the msg.sender is sending CELO to the exchange, false otherwise.
   */
  function _exchange(uint256 sellAmount, uint256 buyAmount, bool sellGold) private {
    IReserve reserve = IReserve(registry.getAddressForOrDie(RESERVE_REGISTRY_ID));

    if (sellGold) {
      goldBucket = goldBucket.add(sellAmount);
      stableBucket = stableBucket.sub(buyAmount);
      require(
        getGoldToken().transferFrom(msg.sender, address(reserve), sellAmount),
        "Transfer of sell token failed"
      );
      require(IStableToken(stable).mint(msg.sender, buyAmount), "Mint of stable token failed");
    } else {
      stableBucket = stableBucket.add(sellAmount);
      goldBucket = goldBucket.sub(buyAmount);
      require(
        IERC20(stable).transferFrom(msg.sender, address(this), sellAmount),
        "Transfer of sell token failed"
      );
      IStableToken(stable).burn(sellAmount);

      require(reserve.transferExchangeGold(msg.sender, buyAmount), "Transfer of buyToken failed");
    }

    emit Exchanged(msg.sender, sellAmount, buyAmount, sellGold);
  }

  /**
   * @notice Returns the amount of buy tokens a user would get for sellAmount of the sell token.
   * @param sellAmount The amount of sellToken the user is selling to the exchange.
   * @param sellGold `true` if gold is the sell token.
   * @return The corresponding buyToken amount.
   */
  function getBuyTokenAmount(uint256 sellAmount, bool sellGold) external view returns (uint256) {
    (uint256 buyTokenBucket, uint256 sellTokenBucket) = getBuyAndSellBuckets(sellGold);
    return _getBuyTokenAmount(buyTokenBucket, sellTokenBucket, sellAmount);
  }

  /**
   * @notice Returns the amount of sell tokens a user would need to exchange to receive buyAmount of
   * buy tokens.
   * @param buyAmount The amount of buyToken the user would like to purchase.
   * @param sellGold `true` if gold is the sell token.
   * @return The corresponding sellToken amount.
   */
  function getSellTokenAmount(uint256 buyAmount, bool sellGold) external view returns (uint256) {
    (uint256 buyTokenBucket, uint256 sellTokenBucket) = getBuyAndSellBuckets(sellGold);
    return _getSellTokenAmount(buyTokenBucket, sellTokenBucket, buyAmount);
  }

  /**
   * @notice Returns the buy token and sell token bucket sizes, in order. The ratio of
   * the two also represents the exchange rate between the two.
   * @param sellGold `true` if gold is the sell token.
   * @return (buyTokenBucket, sellTokenBucket)
   */
  function getBuyAndSellBuckets(bool sellGold) public view returns (uint256, uint256) {
    uint256 currentGoldBucket = goldBucket;
    uint256 currentStableBucket = stableBucket;

    if (shouldUpdateBuckets()) {
      (currentGoldBucket, currentStableBucket) = getUpdatedBuckets();
    }

    if (sellGold) {
      return (currentStableBucket, currentGoldBucket);
    } else {
      return (currentGoldBucket, currentStableBucket);
    }
  }

  /**
    * @notice Allows owner to set the update frequency
    * @param newUpdateFrequency The new update frequency
    */
  function setUpdateFrequency(uint256 newUpdateFrequency) public onlyOwner {
    updateFrequency = newUpdateFrequency;
    emit UpdateFrequencySet(newUpdateFrequency);
  }

  /**
    * @notice Allows owner to set the minimum number of reports required
    * @param newMininumReports The new update minimum number of reports required
    */
  function setMinimumReports(uint256 newMininumReports) public onlyOwner {
    minimumReports = newMininumReports;
    emit MinimumReportsSet(newMininumReports);
  }

  /**
    * @notice Allows owner to set the Stable Token address
    * @param newStableToken The new address for Stable Token
    */
  function setStableToken(address newStableToken) public onlyOwner {
    _setStableToken(newStableToken);
  }

  /**
    * @notice Allows owner to set the spread
    * @param newSpread The new value for the spread
    */
  function setSpread(uint256 newSpread) public onlyOwner {
    spread = FixidityLib.wrap(newSpread);
    require(
      FixidityLib.lte(spread, FixidityLib.fixed1()),
      "Spread must be less than or equal to 1"
    );
    emit SpreadSet(newSpread);
  }

  /**
    * @notice Allows owner to set the Reserve Fraction
    * @param newReserveFraction The new value for the reserve fraction
    */
  function setReserveFraction(uint256 newReserveFraction) public onlyOwner {
    reserveFraction = FixidityLib.wrap(newReserveFraction);
    require(reserveFraction.lt(FixidityLib.fixed1()), "reserve fraction must be smaller than 1");
    emit ReserveFractionSet(newReserveFraction);
  }

  function _setStableToken(address newStableToken) internal {
    stable = newStableToken;
    emit StableTokenSet(newStableToken);
  }

  /**
   * @notice Returns the buy token and sell token bucket sizes, in order. The ratio of
   * the two also represents the exchange rate between the two.
   * @param sellGold `true` if gold is the sell token.
   * @return (buyTokenBucket, sellTokenBucket)
   */
  function _getBuyAndSellBuckets(bool sellGold) private view returns (uint256, uint256) {
    if (sellGold) {
      return (stableBucket, goldBucket);
    } else {
      return (goldBucket, stableBucket);
    }
  }

  /**
   * @dev Returns the amount of buy tokens a user would get for sellAmount of the sell.
   * @param buyTokenBucket The buy token bucket size.
   * @param sellTokenBucket The sell token bucket size.
   * @param sellAmount The amount the user is selling to the exchange.
   * @return The corresponding buy amount.
   */
  function _getBuyTokenAmount(uint256 buyTokenBucket, uint256 sellTokenBucket, uint256 sellAmount)
    private
    view
    returns (uint256)
  {
    if (sellAmount == 0) return 0;

    FixidityLib.Fraction memory reducedSellAmount = getReducedSellAmount(sellAmount);
    FixidityLib.Fraction memory numerator = reducedSellAmount.multiply(
      FixidityLib.newFixed(buyTokenBucket)
    );
    FixidityLib.Fraction memory denominator = FixidityLib.newFixed(sellTokenBucket).add(
      reducedSellAmount
    );

    // Can't use FixidityLib.divide because denominator can easily be greater
    // than maxFixedDivisor.
    // Fortunately, we expect an integer result, so integer division gives us as
    // much precision as we could hope for.
    return numerator.unwrap().div(denominator.unwrap());
  }

  /**
   * @notice Returns the amount of sell tokens a user would need to exchange to receive buyAmount of
   * buy tokens.
   * @param buyTokenBucket The buy token bucket size.
   * @param sellTokenBucket The sell token bucket size.
   * @param buyAmount The amount the user is buying from the exchange.
   * @return The corresponding sell amount.
   */
  function _getSellTokenAmount(uint256 buyTokenBucket, uint256 sellTokenBucket, uint256 buyAmount)
    private
    view
    returns (uint256)
  {
    if (buyAmount == 0) return 0;

    FixidityLib.Fraction memory numerator = FixidityLib.newFixed(buyAmount.mul(sellTokenBucket));
    FixidityLib.Fraction memory denominator = FixidityLib
      .newFixed(buyTokenBucket.sub(buyAmount))
      .multiply(FixidityLib.fixed1().subtract(spread));

    // See comment in _getBuyTokenAmount
    return numerator.unwrap().div(denominator.unwrap());
  }

  function getUpdatedBuckets() private view returns (uint256, uint256) {
    uint256 updatedGoldBucket = getUpdatedGoldBucket();
    uint256 exchangeRateNumerator;
    uint256 exchangeRateDenominator;
    (exchangeRateNumerator, exchangeRateDenominator) = getOracleExchangeRate();
    uint256 updatedStableBucket = exchangeRateNumerator.mul(updatedGoldBucket).div(
      exchangeRateDenominator
    );
    return (updatedGoldBucket, updatedStableBucket);
  }

  function getUpdatedGoldBucket() private view returns (uint256) {
    uint256 reserveGoldBalance = getReserve().getUnfrozenReserveGoldBalance();
    return reserveFraction.multiply(FixidityLib.newFixed(reserveGoldBalance)).fromFixed();
  }

  /**
   * @notice If conditions are met, updates the Uniswap bucket sizes to track
   * the price reported by the Oracle.
   */
  function _updateBucketsIfNecessary() private {
    if (shouldUpdateBuckets()) {
      // solhint-disable-next-line not-rely-on-time
      lastBucketUpdate = now;

      (goldBucket, stableBucket) = getUpdatedBuckets();
      emit BucketsUpdated(goldBucket, stableBucket);
    }
  }

  /**
   * @notice Calculates the sell amount reduced by the spread.
   * @param sellAmount The original sell amount.
   * @return The reduced sell amount, computed as (1 - spread) * sellAmount
   */
  function getReducedSellAmount(uint256 sellAmount)
    private
    view
    returns (FixidityLib.Fraction memory)
  {
    return FixidityLib.fixed1().subtract(spread).multiply(FixidityLib.newFixed(sellAmount));
  }

  /*
   * @notice Checks conditions required for bucket updates.
   * @return Whether or not buckets should be updated.
   */
  function shouldUpdateBuckets() private view returns (bool) {
    ISortedOracles sortedOracles = ISortedOracles(
      registry.getAddressForOrDie(SORTED_ORACLES_REGISTRY_ID)
    );
    (bool isReportExpired, ) = sortedOracles.isOldestReportExpired(stable);
    // solhint-disable-next-line not-rely-on-time
    bool timePassed = now >= lastBucketUpdate.add(updateFrequency);
    bool enoughReports = sortedOracles.numRates(stable) >= minimumReports;
    // solhint-disable-next-line not-rely-on-time
    bool medianReportRecent = sortedOracles.medianTimestamp(stable) > now.sub(updateFrequency);
    return timePassed && enoughReports && medianReportRecent && !isReportExpired;
  }

  function getOracleExchangeRate() private view returns (uint256, uint256) {
    uint256 rateNumerator;
    uint256 rateDenominator;
    (rateNumerator, rateDenominator) = ISortedOracles(
      registry.getAddressForOrDie(SORTED_ORACLES_REGISTRY_ID)
    )
      .medianRate(stable);
    require(rateDenominator > 0, "exchange rate denominator must be greater than 0");
    return (rateNumerator, rateDenominator);
  }
}
        

/Users/mchrzan/celo/celo-monorepo/packages/protocol/contracts/common/FixidityLib.sol

pragma solidity ^0.5.13;

/**
 * @title FixidityLib
 * @author Gadi Guy, Alberto Cuesta Canada
 * @notice This library provides fixed point arithmetic with protection against
 * overflow.
 * All operations are done with uint256 and the operands must have been created
 * with any of the newFrom* functions, which shift the comma digits() to the
 * right and check for limits, or with wrap() which expects a number already
 * in the internal representation of a fraction.
 * When using this library be sure to use maxNewFixed() as the upper limit for
 * creation of fixed point numbers.
 * @dev All contained functions are pure and thus marked internal to be inlined
 * on consuming contracts at compile time for gas efficiency.
 */
library FixidityLib {
  struct Fraction {
    uint256 value;
  }

  /**
   * @notice Number of positions that the comma is shifted to the right.
   */
  function digits() internal pure returns (uint8) {
    return 24;
  }

  uint256 private constant FIXED1_UINT = 1000000000000000000000000;

  /**
   * @notice This is 1 in the fixed point units used in this library.
   * @dev Test fixed1() equals 10^digits()
   * Hardcoded to 24 digits.
   */
  function fixed1() internal pure returns (Fraction memory) {
    return Fraction(FIXED1_UINT);
  }

  /**
   * @notice Wrap a uint256 that represents a 24-decimal fraction in a Fraction
   * struct.
   * @param x Number that already represents a 24-decimal fraction.
   * @return A Fraction struct with contents x.
   */
  function wrap(uint256 x) internal pure returns (Fraction memory) {
    return Fraction(x);
  }

  /**
   * @notice Unwraps the uint256 inside of a Fraction struct.
   */
  function unwrap(Fraction memory x) internal pure returns (uint256) {
    return x.value;
  }

  /**
   * @notice The amount of decimals lost on each multiplication operand.
   * @dev Test mulPrecision() equals sqrt(fixed1)
   */
  function mulPrecision() internal pure returns (uint256) {
    return 1000000000000;
  }

  /**
   * @notice Maximum value that can be converted to fixed point. Optimize for deployment.
   * @dev
   * Test maxNewFixed() equals maxUint256() / fixed1()
   */
  function maxNewFixed() internal pure returns (uint256) {
    return 115792089237316195423570985008687907853269984665640564;
  }

  /**
   * @notice Converts a uint256 to fixed point Fraction
   * @dev Test newFixed(0) returns 0
   * Test newFixed(1) returns fixed1()
   * Test newFixed(maxNewFixed()) returns maxNewFixed() * fixed1()
   * Test newFixed(maxNewFixed()+1) fails
   */
  function newFixed(uint256 x) internal pure returns (Fraction memory) {
    require(x <= maxNewFixed(), "can't create fixidity number larger than maxNewFixed()");
    return Fraction(x * FIXED1_UINT);
  }

  /**
   * @notice Converts a uint256 in the fixed point representation of this
   * library to a non decimal. All decimal digits will be truncated.
   */
  function fromFixed(Fraction memory x) internal pure returns (uint256) {
    return x.value / FIXED1_UINT;
  }

  /**
   * @notice Converts two uint256 representing a fraction to fixed point units,
   * equivalent to multiplying dividend and divisor by 10^digits().
   * @param numerator numerator must be <= maxNewFixed()
   * @param denominator denominator must be <= maxNewFixed() and denominator can't be 0
   * @dev
   * Test newFixedFraction(1,0) fails
   * Test newFixedFraction(0,1) returns 0
   * Test newFixedFraction(1,1) returns fixed1()
   * Test newFixedFraction(1,fixed1()) returns 1
   */
  function newFixedFraction(uint256 numerator, uint256 denominator)
    internal
    pure
    returns (Fraction memory)
  {
    Fraction memory convertedNumerator = newFixed(numerator);
    Fraction memory convertedDenominator = newFixed(denominator);
    return divide(convertedNumerator, convertedDenominator);
  }

  /**
   * @notice Returns the integer part of a fixed point number.
   * @dev
   * Test integer(0) returns 0
   * Test integer(fixed1()) returns fixed1()
   * Test integer(newFixed(maxNewFixed())) returns maxNewFixed()*fixed1()
   */
  function integer(Fraction memory x) internal pure returns (Fraction memory) {
    return Fraction((x.value / FIXED1_UINT) * FIXED1_UINT); // Can't overflow
  }

  /**
   * @notice Returns the fractional part of a fixed point number.
   * In the case of a negative number the fractional is also negative.
   * @dev
   * Test fractional(0) returns 0
   * Test fractional(fixed1()) returns 0
   * Test fractional(fixed1()-1) returns 10^24-1
   */
  function fractional(Fraction memory x) internal pure returns (Fraction memory) {
    return Fraction(x.value - (x.value / FIXED1_UINT) * FIXED1_UINT); // Can't overflow
  }

  /**
   * @notice x+y.
   * @dev The maximum value that can be safely used as an addition operator is defined as
   * maxFixedAdd = maxUint256()-1 / 2, or
   * 57896044618658097711785492504343953926634992332820282019728792003956564819967.
   * Test add(maxFixedAdd,maxFixedAdd) equals maxFixedAdd + maxFixedAdd
   * Test add(maxFixedAdd+1,maxFixedAdd+1) throws
   */
  function add(Fraction memory x, Fraction memory y) internal pure returns (Fraction memory) {
    uint256 z = x.value + y.value;
    require(z >= x.value, "add overflow detected");
    return Fraction(z);
  }

  /**
   * @notice x-y.
   * @dev
   * Test subtract(6, 10) fails
   */
  function subtract(Fraction memory x, Fraction memory y) internal pure returns (Fraction memory) {
    require(x.value >= y.value, "substraction underflow detected");
    return Fraction(x.value - y.value);
  }

  /**
   * @notice x*y. If any of the operators is higher than the max multiplier value it
   * might overflow.
   * @dev The maximum value that can be safely used as a multiplication operator
   * (maxFixedMul) is calculated as sqrt(maxUint256()*fixed1()),
   * or 340282366920938463463374607431768211455999999999999
   * Test multiply(0,0) returns 0
   * Test multiply(maxFixedMul,0) returns 0
   * Test multiply(0,maxFixedMul) returns 0
   * Test multiply(fixed1()/mulPrecision(),fixed1()*mulPrecision()) returns fixed1()
   * Test multiply(maxFixedMul,maxFixedMul) is around maxUint256()
   * Test multiply(maxFixedMul+1,maxFixedMul+1) fails
   */
  function multiply(Fraction memory x, Fraction memory y) internal pure returns (Fraction memory) {
    if (x.value == 0 || y.value == 0) return Fraction(0);
    if (y.value == FIXED1_UINT) return x;
    if (x.value == FIXED1_UINT) return y;

    // Separate into integer and fractional parts
    // x = x1 + x2, y = y1 + y2
    uint256 x1 = integer(x).value / FIXED1_UINT;
    uint256 x2 = fractional(x).value;
    uint256 y1 = integer(y).value / FIXED1_UINT;
    uint256 y2 = fractional(y).value;

    // (x1 + x2) * (y1 + y2) = (x1 * y1) + (x1 * y2) + (x2 * y1) + (x2 * y2)
    uint256 x1y1 = x1 * y1;
    if (x1 != 0) require(x1y1 / x1 == y1, "overflow x1y1 detected");

    // x1y1 needs to be multiplied back by fixed1
    // solium-disable-next-line mixedcase
    uint256 fixed_x1y1 = x1y1 * FIXED1_UINT;
    if (x1y1 != 0) require(fixed_x1y1 / x1y1 == FIXED1_UINT, "overflow x1y1 * fixed1 detected");
    x1y1 = fixed_x1y1;

    uint256 x2y1 = x2 * y1;
    if (x2 != 0) require(x2y1 / x2 == y1, "overflow x2y1 detected");

    uint256 x1y2 = x1 * y2;
    if (x1 != 0) require(x1y2 / x1 == y2, "overflow x1y2 detected");

    x2 = x2 / mulPrecision();
    y2 = y2 / mulPrecision();
    uint256 x2y2 = x2 * y2;
    if (x2 != 0) require(x2y2 / x2 == y2, "overflow x2y2 detected");

    // result = fixed1() * x1 * y1 + x1 * y2 + x2 * y1 + x2 * y2 / fixed1();
    Fraction memory result = Fraction(x1y1);
    result = add(result, Fraction(x2y1)); // Add checks for overflow
    result = add(result, Fraction(x1y2)); // Add checks for overflow
    result = add(result, Fraction(x2y2)); // Add checks for overflow
    return result;
  }

  /**
   * @notice 1/x
   * @dev
   * Test reciprocal(0) fails
   * Test reciprocal(fixed1()) returns fixed1()
   * Test reciprocal(fixed1()*fixed1()) returns 1 // Testing how the fractional is truncated
   * Test reciprocal(1+fixed1()*fixed1()) returns 0 // Testing how the fractional is truncated
   * Test reciprocal(newFixedFraction(1, 1e24)) returns newFixed(1e24)
   */
  function reciprocal(Fraction memory x) internal pure returns (Fraction memory) {
    require(x.value != 0, "can't call reciprocal(0)");
    return Fraction((FIXED1_UINT * FIXED1_UINT) / x.value); // Can't overflow
  }

  /**
   * @notice x/y. If the dividend is higher than the max dividend value, it
   * might overflow. You can use multiply(x,reciprocal(y)) instead.
   * @dev The maximum value that can be safely used as a dividend (maxNewFixed) is defined as
   * divide(maxNewFixed,newFixedFraction(1,fixed1())) is around maxUint256().
   * This yields the value 115792089237316195423570985008687907853269984665640564.
   * Test maxNewFixed equals maxUint256()/fixed1()
   * Test divide(maxNewFixed,1) equals maxNewFixed*(fixed1)
   * Test divide(maxNewFixed+1,multiply(mulPrecision(),mulPrecision())) throws
   * Test divide(fixed1(),0) fails
   * Test divide(maxNewFixed,1) = maxNewFixed*(10^digits())
   * Test divide(maxNewFixed+1,1) throws
   */
  function divide(Fraction memory x, Fraction memory y) internal pure returns (Fraction memory) {
    require(y.value != 0, "can't divide by 0");
    uint256 X = x.value * FIXED1_UINT;
    require(X / FIXED1_UINT == x.value, "overflow at divide");
    return Fraction(X / y.value);
  }

  /**
   * @notice x > y
   */
  function gt(Fraction memory x, Fraction memory y) internal pure returns (bool) {
    return x.value > y.value;
  }

  /**
   * @notice x >= y
   */
  function gte(Fraction memory x, Fraction memory y) internal pure returns (bool) {
    return x.value >= y.value;
  }

  /**
   * @notice x < y
   */
  function lt(Fraction memory x, Fraction memory y) internal pure returns (bool) {
    return x.value < y.value;
  }

  /**
   * @notice x <= y
   */
  function lte(Fraction memory x, Fraction memory y) internal pure returns (bool) {
    return x.value <= y.value;
  }

  /**
   * @notice x == y
   */
  function equals(Fraction memory x, Fraction memory y) internal pure returns (bool) {
    return x.value == y.value;
  }

  /**
   * @notice x <= 1
   */
  function isProperFraction(Fraction memory x) internal pure returns (bool) {
    return lte(x, fixed1());
  }
}
          

/Users/mchrzan/celo/celo-monorepo/packages/protocol/contracts/common/Freezable.sol

pragma solidity ^0.5.13;

import "./UsingRegistry.sol";

contract Freezable is UsingRegistry {
  // onlyWhenNotFrozen functions can only be called when `frozen` is false, otherwise they will
  // revert.
  modifier onlyWhenNotFrozen() {
    require(!getFreezer().isFrozen(address(this)), "can't call when contract is frozen");
    _;
  }
}
          

/Users/mchrzan/celo/celo-monorepo/packages/protocol/contracts/common/Initializable.sol

pragma solidity ^0.5.13;

contract Initializable {
  bool public initialized;

  constructor(bool testingDeployment) public {
    if (!testingDeployment) {
      initialized = true;
    }
  }

  modifier initializer() {
    require(!initialized, "contract already initialized");
    initialized = true;
    _;
  }
}
          

/Users/mchrzan/celo/celo-monorepo/packages/protocol/contracts/common/UsingRegistry.sol

pragma solidity ^0.5.13;

import "openzeppelin-solidity/contracts/ownership/Ownable.sol";
import "openzeppelin-solidity/contracts/token/ERC20/IERC20.sol";

import "./interfaces/IAccounts.sol";
import "./interfaces/IFeeCurrencyWhitelist.sol";
import "./interfaces/IFreezer.sol";
import "./interfaces/IRegistry.sol";

import "../governance/interfaces/IElection.sol";
import "../governance/interfaces/IGovernance.sol";
import "../governance/interfaces/ILockedGold.sol";
import "../governance/interfaces/IValidators.sol";

import "../identity/interfaces/IRandom.sol";
import "../identity/interfaces/IAttestations.sol";

import "../stability/interfaces/IExchange.sol";
import "../stability/interfaces/IReserve.sol";
import "../stability/interfaces/ISortedOracles.sol";
import "../stability/interfaces/IStableToken.sol";

contract UsingRegistry is Ownable {
  event RegistrySet(address indexed registryAddress);

  // solhint-disable state-visibility
  bytes32 constant ACCOUNTS_REGISTRY_ID = keccak256(abi.encodePacked("Accounts"));
  bytes32 constant ATTESTATIONS_REGISTRY_ID = keccak256(abi.encodePacked("Attestations"));
  bytes32 constant DOWNTIME_SLASHER_REGISTRY_ID = keccak256(abi.encodePacked("DowntimeSlasher"));
  bytes32 constant DOUBLE_SIGNING_SLASHER_REGISTRY_ID = keccak256(
    abi.encodePacked("DoubleSigningSlasher")
  );
  bytes32 constant ELECTION_REGISTRY_ID = keccak256(abi.encodePacked("Election"));
  bytes32 constant EXCHANGE_REGISTRY_ID = keccak256(abi.encodePacked("Exchange"));
  bytes32 constant FEE_CURRENCY_WHITELIST_REGISTRY_ID = keccak256(
    abi.encodePacked("FeeCurrencyWhitelist")
  );
  bytes32 constant FREEZER_REGISTRY_ID = keccak256(abi.encodePacked("Freezer"));
  bytes32 constant GOLD_TOKEN_REGISTRY_ID = keccak256(abi.encodePacked("GoldToken"));
  bytes32 constant GOVERNANCE_REGISTRY_ID = keccak256(abi.encodePacked("Governance"));
  bytes32 constant GOVERNANCE_SLASHER_REGISTRY_ID = keccak256(
    abi.encodePacked("GovernanceSlasher")
  );
  bytes32 constant LOCKED_GOLD_REGISTRY_ID = keccak256(abi.encodePacked("LockedGold"));
  bytes32 constant RESERVE_REGISTRY_ID = keccak256(abi.encodePacked("Reserve"));
  bytes32 constant RANDOM_REGISTRY_ID = keccak256(abi.encodePacked("Random"));
  bytes32 constant SORTED_ORACLES_REGISTRY_ID = keccak256(abi.encodePacked("SortedOracles"));
  bytes32 constant STABLE_TOKEN_REGISTRY_ID = keccak256(abi.encodePacked("StableToken"));
  bytes32 constant VALIDATORS_REGISTRY_ID = keccak256(abi.encodePacked("Validators"));
  // solhint-enable state-visibility

  IRegistry public registry;

  modifier onlyRegisteredContract(bytes32 identifierHash) {
    require(registry.getAddressForOrDie(identifierHash) == msg.sender, "only registered contract");
    _;
  }

  modifier onlyRegisteredContracts(bytes32[] memory identifierHashes) {
    require(registry.isOneOf(identifierHashes, msg.sender), "only registered contracts");
    _;
  }

  /**
   * @notice Updates the address pointing to a Registry contract.
   * @param registryAddress The address of a registry contract for routing to other contracts.
   */
  function setRegistry(address registryAddress) public onlyOwner {
    require(registryAddress != address(0), "Cannot register the null address");
    registry = IRegistry(registryAddress);
    emit RegistrySet(registryAddress);
  }

  function getAccounts() internal view returns (IAccounts) {
    return IAccounts(registry.getAddressForOrDie(ACCOUNTS_REGISTRY_ID));
  }

  function getAttestations() internal view returns (IAttestations) {
    return IAttestations(registry.getAddressForOrDie(ATTESTATIONS_REGISTRY_ID));
  }

  function getElection() internal view returns (IElection) {
    return IElection(registry.getAddressForOrDie(ELECTION_REGISTRY_ID));
  }

  function getExchange() internal view returns (IExchange) {
    return IExchange(registry.getAddressForOrDie(EXCHANGE_REGISTRY_ID));
  }

  function getFeeCurrencyWhitelistRegistry() internal view returns (IFeeCurrencyWhitelist) {
    return IFeeCurrencyWhitelist(registry.getAddressForOrDie(FEE_CURRENCY_WHITELIST_REGISTRY_ID));
  }

  function getFreezer() internal view returns (IFreezer) {
    return IFreezer(registry.getAddressForOrDie(FREEZER_REGISTRY_ID));
  }

  function getGoldToken() internal view returns (IERC20) {
    return IERC20(registry.getAddressForOrDie(GOLD_TOKEN_REGISTRY_ID));
  }

  function getGovernance() internal view returns (IGovernance) {
    return IGovernance(registry.getAddressForOrDie(GOVERNANCE_REGISTRY_ID));
  }

  function getLockedGold() internal view returns (ILockedGold) {
    return ILockedGold(registry.getAddressForOrDie(LOCKED_GOLD_REGISTRY_ID));
  }

  function getRandom() internal view returns (IRandom) {
    return IRandom(registry.getAddressForOrDie(RANDOM_REGISTRY_ID));
  }

  function getReserve() internal view returns (IReserve) {
    return IReserve(registry.getAddressForOrDie(RESERVE_REGISTRY_ID));
  }

  function getSortedOracles() internal view returns (ISortedOracles) {
    return ISortedOracles(registry.getAddressForOrDie(SORTED_ORACLES_REGISTRY_ID));
  }

  function getStableToken() internal view returns (IStableToken) {
    return IStableToken(registry.getAddressForOrDie(STABLE_TOKEN_REGISTRY_ID));
  }

  function getValidators() internal view returns (IValidators) {
    return IValidators(registry.getAddressForOrDie(VALIDATORS_REGISTRY_ID));
  }
}
          

/Users/mchrzan/celo/celo-monorepo/packages/protocol/contracts/common/interfaces/IAccounts.sol

pragma solidity ^0.5.13;

interface IAccounts {
  function isAccount(address) external view returns (bool);
  function voteSignerToAccount(address) external view returns (address);
  function validatorSignerToAccount(address) external view returns (address);
  function attestationSignerToAccount(address) external view returns (address);
  function signerToAccount(address) external view returns (address);
  function getAttestationSigner(address) external view returns (address);
  function getValidatorSigner(address) external view returns (address);
  function getVoteSigner(address) external view returns (address);
  function hasAuthorizedVoteSigner(address) external view returns (bool);
  function hasAuthorizedValidatorSigner(address) external view returns (bool);
  function hasAuthorizedAttestationSigner(address) external view returns (bool);

  function setAccountDataEncryptionKey(bytes calldata) external;
  function setMetadataURL(string calldata) external;
  function setName(string calldata) external;
  function setWalletAddress(address, uint8, bytes32, bytes32) external;
  function setAccount(string calldata, bytes calldata, address, uint8, bytes32, bytes32) external;

  function getDataEncryptionKey(address) external view returns (bytes memory);
  function getWalletAddress(address) external view returns (address);
  function getMetadataURL(address) external view returns (string memory);
  function batchGetMetadataURL(address[] calldata)
    external
    view
    returns (uint256[] memory, bytes memory);
  function getName(address) external view returns (string memory);

  function authorizeVoteSigner(address, uint8, bytes32, bytes32) external;
  function authorizeValidatorSigner(address, uint8, bytes32, bytes32) external;
  function authorizeValidatorSignerWithPublicKey(address, uint8, bytes32, bytes32, bytes calldata)
    external;
  function authorizeValidatorSignerWithKeys(
    address,
    uint8,
    bytes32,
    bytes32,
    bytes calldata,
    bytes calldata,
    bytes calldata
  ) external;
  function authorizeAttestationSigner(address, uint8, bytes32, bytes32) external;
  function createAccount() external returns (bool);

  function setPaymentDelegation(address, uint256) external;
  function getPaymentDelegation(address) external view returns (address, uint256);
}
          

/Users/mchrzan/celo/celo-monorepo/packages/protocol/contracts/common/interfaces/ICeloVersionedContract.sol

pragma solidity ^0.5.13;

interface ICeloVersionedContract {
  /**
   * @notice Returns the storage, major, minor, and patch version of the contract.
   * @return The storage, major, minor, and patch version of the contract.
   */
  function getVersionNumber() external pure returns (uint256, uint256, uint256, uint256);
}
          

/Users/mchrzan/celo/celo-monorepo/packages/protocol/contracts/common/interfaces/IFeeCurrencyWhitelist.sol

pragma solidity ^0.5.13;

interface IFeeCurrencyWhitelist {
  function addToken(address) external;
  function getWhitelist() external view returns (address[] memory);
}
          

/Users/mchrzan/celo/celo-monorepo/packages/protocol/contracts/common/interfaces/IFreezer.sol

pragma solidity ^0.5.13;

interface IFreezer {
  function isFrozen(address) external view returns (bool);
}
          

/Users/mchrzan/celo/celo-monorepo/packages/protocol/contracts/common/interfaces/IRegistry.sol

pragma solidity ^0.5.13;

interface IRegistry {
  function setAddressFor(string calldata, address) external;
  function getAddressForOrDie(bytes32) external view returns (address);
  function getAddressFor(bytes32) external view returns (address);
  function getAddressForStringOrDie(string calldata identifier) external view returns (address);
  function getAddressForString(string calldata identifier) external view returns (address);
  function isOneOf(bytes32[] calldata, address) external view returns (bool);
}
          

/Users/mchrzan/celo/celo-monorepo/packages/protocol/contracts/common/libraries/ReentrancyGuard.sol

pragma solidity ^0.5.13;

/**
 * @title Helps contracts guard against reentrancy attacks.
 * @author Remco Bloemen <remco@2π.com>, Eenae <alexey@mixbytes.io>
 * @dev If you mark a function `nonReentrant`, you should also
 * mark it `external`.
 */
contract ReentrancyGuard {
  /// @dev counter to allow mutex lock with only one SSTORE operation
  uint256 private _guardCounter;

  constructor() internal {
    // The counter starts at one to prevent changing it from zero to a non-zero
    // value, which is a more expensive operation.
    _guardCounter = 1;
  }

  /**
   * @dev Prevents a contract from calling itself, directly or indirectly.
   * Calling a `nonReentrant` function from another `nonReentrant`
   * function is not supported. It is possible to prevent this from happening
   * by making the `nonReentrant` function external, and make it call a
   * `private` function that does the actual work.
   */
  modifier nonReentrant() {
    _guardCounter += 1;
    uint256 localCounter = _guardCounter;
    _;
    require(localCounter == _guardCounter, "reentrant call");
  }
}
          

/Users/mchrzan/celo/celo-monorepo/packages/protocol/contracts/governance/interfaces/IElection.sol

pragma solidity ^0.5.13;

interface IElection {
  function electValidatorSigners() external view returns (address[] memory);
  function electNValidatorSigners(uint256, uint256) external view returns (address[] memory);
  function vote(address, uint256, address, address) external returns (bool);
  function activate(address) external returns (bool);
  function revokeActive(address, uint256, address, address, uint256) external returns (bool);
  function revokeAllActive(address, address, address, uint256) external returns (bool);
  function revokePending(address, uint256, address, address, uint256) external returns (bool);
  function markGroupIneligible(address) external;
  function markGroupEligible(address, address, address) external;
  function forceDecrementVotes(
    address,
    uint256,
    address[] calldata,
    address[] calldata,
    uint256[] calldata
  ) external returns (uint256);

  // view functions
  function getElectableValidators() external view returns (uint256, uint256);
  function getElectabilityThreshold() external view returns (uint256);
  function getNumVotesReceivable(address) external view returns (uint256);
  function getTotalVotes() external view returns (uint256);
  function getActiveVotes() external view returns (uint256);
  function getTotalVotesByAccount(address) external view returns (uint256);
  function getPendingVotesForGroupByAccount(address, address) external view returns (uint256);
  function getActiveVotesForGroupByAccount(address, address) external view returns (uint256);
  function getTotalVotesForGroupByAccount(address, address) external view returns (uint256);
  function getActiveVoteUnitsForGroupByAccount(address, address) external view returns (uint256);
  function getTotalVotesForGroup(address) external view returns (uint256);
  function getActiveVotesForGroup(address) external view returns (uint256);
  function getPendingVotesForGroup(address) external view returns (uint256);
  function getGroupEligibility(address) external view returns (bool);
  function getGroupEpochRewards(address, uint256, uint256[] calldata)
    external
    view
    returns (uint256);
  function getGroupsVotedForByAccount(address) external view returns (address[] memory);
  function getEligibleValidatorGroups() external view returns (address[] memory);
  function getTotalVotesForEligibleValidatorGroups()
    external
    view
    returns (address[] memory, uint256[] memory);
  function getCurrentValidatorSigners() external view returns (address[] memory);
  function canReceiveVotes(address, uint256) external view returns (bool);
  function hasActivatablePendingVotes(address, address) external view returns (bool);

  // only owner
  function setElectableValidators(uint256, uint256) external returns (bool);
  function setMaxNumGroupsVotedFor(uint256) external returns (bool);
  function setElectabilityThreshold(uint256) external returns (bool);

  // only VM
  function distributeEpochRewards(address, uint256, address, address) external;
}
          

/Users/mchrzan/celo/celo-monorepo/packages/protocol/contracts/governance/interfaces/IGovernance.sol

pragma solidity ^0.5.13;

interface IGovernance {
  function isVoting(address) external view returns (bool);
}
          

/Users/mchrzan/celo/celo-monorepo/packages/protocol/contracts/governance/interfaces/ILockedGold.sol

pragma solidity ^0.5.13;

interface ILockedGold {
  function incrementNonvotingAccountBalance(address, uint256) external;
  function decrementNonvotingAccountBalance(address, uint256) external;
  function getAccountTotalLockedGold(address) external view returns (uint256);
  function getTotalLockedGold() external view returns (uint256);
  function getPendingWithdrawals(address)
    external
    view
    returns (uint256[] memory, uint256[] memory);
  function getTotalPendingWithdrawals(address) external view returns (uint256);
  function lock() external payable;
  function unlock(uint256) external;
  function relock(uint256, uint256) external;
  function withdraw(uint256) external;
  function slash(
    address account,
    uint256 penalty,
    address reporter,
    uint256 reward,
    address[] calldata lessers,
    address[] calldata greaters,
    uint256[] calldata indices
  ) external;
  function isSlasher(address) external view returns (bool);
}
          

/Users/mchrzan/celo/celo-monorepo/packages/protocol/contracts/governance/interfaces/IValidators.sol

pragma solidity ^0.5.13;

interface IValidators {
  function registerValidator(bytes calldata, bytes calldata, bytes calldata)
    external
    returns (bool);
  function deregisterValidator(uint256) external returns (bool);
  function affiliate(address) external returns (bool);
  function deaffiliate() external returns (bool);
  function updateBlsPublicKey(bytes calldata, bytes calldata) external returns (bool);
  function registerValidatorGroup(uint256) external returns (bool);
  function deregisterValidatorGroup(uint256) external returns (bool);
  function addMember(address) external returns (bool);
  function addFirstMember(address, address, address) external returns (bool);
  function removeMember(address) external returns (bool);
  function reorderMember(address, address, address) external returns (bool);
  function updateCommission() external;
  function setNextCommissionUpdate(uint256) external;
  function resetSlashingMultiplier() external;

  // only owner
  function setCommissionUpdateDelay(uint256) external;
  function setMaxGroupSize(uint256) external returns (bool);
  function setMembershipHistoryLength(uint256) external returns (bool);
  function setValidatorScoreParameters(uint256, uint256) external returns (bool);
  function setGroupLockedGoldRequirements(uint256, uint256) external returns (bool);
  function setValidatorLockedGoldRequirements(uint256, uint256) external returns (bool);
  function setSlashingMultiplierResetPeriod(uint256) external;

  // view functions
  function getMaxGroupSize() external view returns (uint256);
  function getCommissionUpdateDelay() external view returns (uint256);
  function getValidatorScoreParameters() external view returns (uint256, uint256);
  function getMembershipHistory(address)
    external
    view
    returns (uint256[] memory, address[] memory, uint256, uint256);
  function calculateEpochScore(uint256) external view returns (uint256);
  function calculateGroupEpochScore(uint256[] calldata) external view returns (uint256);
  function getAccountLockedGoldRequirement(address) external view returns (uint256);
  function meetsAccountLockedGoldRequirements(address) external view returns (bool);
  function getValidatorBlsPublicKeyFromSigner(address) external view returns (bytes memory);
  function getValidator(address account)
    external
    view
    returns (bytes memory, bytes memory, address, uint256, address);
  function getValidatorGroup(address)
    external
    view
    returns (address[] memory, uint256, uint256, uint256, uint256[] memory, uint256, uint256);
  function getGroupNumMembers(address) external view returns (uint256);
  function getTopGroupValidators(address, uint256) external view returns (address[] memory);
  function getGroupsNumMembers(address[] calldata accounts)
    external
    view
    returns (uint256[] memory);
  function getNumRegisteredValidators() external view returns (uint256);
  function groupMembershipInEpoch(address, uint256, uint256) external view returns (address);

  // only registered contract
  function updateEcdsaPublicKey(address, address, bytes calldata) external returns (bool);
  function updatePublicKeys(address, address, bytes calldata, bytes calldata, bytes calldata)
    external
    returns (bool);
  function getValidatorLockedGoldRequirements() external view returns (uint256, uint256);
  function getGroupLockedGoldRequirements() external view returns (uint256, uint256);
  function getRegisteredValidators() external view returns (address[] memory);
  function getRegisteredValidatorSigners() external view returns (address[] memory);
  function getRegisteredValidatorGroups() external view returns (address[] memory);
  function isValidatorGroup(address) external view returns (bool);
  function isValidator(address) external view returns (bool);
  function getValidatorGroupSlashingMultiplier(address) external view returns (uint256);
  function getMembershipInLastEpoch(address) external view returns (address);
  function getMembershipInLastEpochFromSigner(address) external view returns (address);

  // only VM
  function updateValidatorScoreFromSigner(address, uint256) external;
  function distributeEpochPaymentsFromSigner(address, uint256) external returns (uint256);

  // only slasher
  function forceDeaffiliateIfValidator(address) external;
  function halveSlashingMultiplier(address) external;

}
          

/Users/mchrzan/celo/celo-monorepo/packages/protocol/contracts/identity/interfaces/IAttestations.sol

pragma solidity ^0.5.13;

interface IAttestations {
  function request(bytes32, uint256, address) external;
  function selectIssuers(bytes32) external;
  function complete(bytes32, uint8, bytes32, bytes32) external;
  function revoke(bytes32, uint256) external;
  function withdraw(address) external;
  function approveTransfer(bytes32, uint256, address, address, bool) external;

  // view functions
  function getUnselectedRequest(bytes32, address) external view returns (uint32, uint32, address);
  function getAttestationIssuers(bytes32, address) external view returns (address[] memory);
  function getAttestationStats(bytes32, address) external view returns (uint32, uint32);
  function batchGetAttestationStats(bytes32[] calldata)
    external
    view
    returns (uint256[] memory, address[] memory, uint64[] memory, uint64[] memory);
  function getAttestationState(bytes32, address, address)
    external
    view
    returns (uint8, uint32, address);
  function getCompletableAttestations(bytes32, address)
    external
    view
    returns (uint32[] memory, address[] memory, uint256[] memory, bytes memory);
  function getAttestationRequestFee(address) external view returns (uint256);
  function getMaxAttestations() external view returns (uint256);
  function validateAttestationCode(bytes32, address, uint8, bytes32, bytes32)
    external
    view
    returns (address);
  function lookupAccountsForIdentifier(bytes32) external view returns (address[] memory);
  function requireNAttestationsRequested(bytes32, address, uint32) external view;

  // only owner
  function setAttestationRequestFee(address, uint256) external;
  function setAttestationExpiryBlocks(uint256) external;
  function setSelectIssuersWaitBlocks(uint256) external;
  function setMaxAttestations(uint256) external;
}
          

/Users/mchrzan/celo/celo-monorepo/packages/protocol/contracts/identity/interfaces/IRandom.sol

pragma solidity ^0.5.13;

interface IRandom {
  function revealAndCommit(bytes32, bytes32, address) external;
  function randomnessBlockRetentionWindow() external view returns (uint256);
  function random() external view returns (bytes32);
  function getBlockRandomness(uint256) external view returns (bytes32);
}
          

/Users/mchrzan/celo/celo-monorepo/packages/protocol/contracts/stability/interfaces/IExchange.sol

pragma solidity ^0.5.13;

interface IExchange {
  function buy(uint256, uint256, bool) external returns (uint256);
  function sell(uint256, uint256, bool) external returns (uint256);
  function exchange(uint256, uint256, bool) external returns (uint256);
  function setUpdateFrequency(uint256) external;
  function getBuyTokenAmount(uint256, bool) external view returns (uint256);
  function getSellTokenAmount(uint256, bool) external view returns (uint256);
  function getBuyAndSellBuckets(bool) external view returns (uint256, uint256);
}
          

/Users/mchrzan/celo/celo-monorepo/packages/protocol/contracts/stability/interfaces/IReserve.sol

pragma solidity ^0.5.13;

interface IReserve {
  function setTobinTaxStalenessThreshold(uint256) external;
  function addToken(address) external returns (bool);
  function removeToken(address, uint256) external returns (bool);
  function transferGold(address payable, uint256) external returns (bool);
  function transferExchangeGold(address payable, uint256) external returns (bool);
  function getReserveGoldBalance() external view returns (uint256);
  function getUnfrozenReserveGoldBalance() external view returns (uint256);
  function getOrComputeTobinTax() external returns (uint256, uint256);
  function getTokens() external view returns (address[] memory);
  function getReserveRatio() external view returns (uint256);
  function addExchangeSpender(address) external;
  function removeExchangeSpender(address, uint256) external;
  function addSpender(address) external;
  function removeSpender(address) external;
}
          

/Users/mchrzan/celo/celo-monorepo/packages/protocol/contracts/stability/interfaces/ISortedOracles.sol

pragma solidity ^0.5.13;

interface ISortedOracles {
  function addOracle(address, address) external;
  function removeOracle(address, address, uint256) external;
  function report(address, uint256, address, address) external;
  function removeExpiredReports(address, uint256) external;
  function isOldestReportExpired(address token) external view returns (bool, address);
  function numRates(address) external view returns (uint256);
  function medianRate(address) external view returns (uint256, uint256);
  function numTimestamps(address) external view returns (uint256);
  function medianTimestamp(address) external view returns (uint256);
}
          

/Users/mchrzan/celo/celo-monorepo/packages/protocol/contracts/stability/interfaces/IStableToken.sol

pragma solidity ^0.5.13;

/**
 * @title This interface describes the functions specific to Celo Stable Tokens, and in the
 * absence of interface inheritance is intended as a companion to IERC20.sol and ICeloToken.sol.
 */
interface IStableToken {
  function mint(address, uint256) external returns (bool);
  function burn(uint256) external returns (bool);
  function setInflationParameters(uint256, uint256) external;
  function valueToUnits(uint256) external view returns (uint256);
  function unitsToValue(uint256) external view returns (uint256);
  function getInflationParameters() external view returns (uint256, uint256, uint256, uint256);

  // NOTE: duplicated with IERC20.sol, remove once interface inheritance is supported.
  function balanceOf(address) external view returns (uint256);
}
          

/openzeppelin-solidity/contracts/GSN/Context.sol

pragma solidity ^0.5.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 GSN 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.
 */
contract Context {
    // Empty internal constructor, to prevent people from mistakenly deploying
    // an instance of this contract, which should be used via inheritance.
    constructor () internal { }
    // solhint-disable-previous-line no-empty-blocks

    function _msgSender() internal view returns (address payable) {
        return msg.sender;
    }

    function _msgData() internal view returns (bytes memory) {
        this; // silence state mutability warning without generating bytecode - see https://github.com/ethereum/solidity/issues/2691
        return msg.data;
    }
}
          

/openzeppelin-solidity/contracts/math/SafeMath.sol

pragma solidity ^0.5.0;

/**
 * @dev Wrappers over Solidity's arithmetic operations with added overflow
 * checks.
 *
 * Arithmetic operations in Solidity wrap on overflow. This can easily result
 * in bugs, because programmers usually assume that an overflow raises an
 * error, which is the standard behavior in high level programming languages.
 * `SafeMath` restores this intuition by reverting the transaction when an
 * operation overflows.
 *
 * Using this library instead of the unchecked operations eliminates an entire
 * class of bugs, so it's recommended to use it always.
 */
library SafeMath {
    /**
     * @dev Returns the addition of two unsigned integers, reverting on
     * overflow.
     *
     * Counterpart to Solidity's `+` operator.
     *
     * Requirements:
     * - Addition cannot overflow.
     */
    function add(uint256 a, uint256 b) internal pure returns (uint256) {
        uint256 c = a + b;
        require(c >= a, "SafeMath: addition overflow");

        return c;
    }

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

    /**
     * @dev Returns the subtraction of two unsigned integers, reverting with custom message on
     * overflow (when the result is negative).
     *
     * Counterpart to Solidity's `-` operator.
     *
     * Requirements:
     * - Subtraction cannot overflow.
     *
     * _Available since v2.4.0._
     */
    function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
        require(b <= a, errorMessage);
        uint256 c = a - b;

        return c;
    }

    /**
     * @dev Returns the multiplication of two unsigned integers, reverting on
     * overflow.
     *
     * Counterpart to Solidity's `*` operator.
     *
     * Requirements:
     * - Multiplication cannot overflow.
     */
    function mul(uint256 a, uint256 b) internal pure returns (uint256) {
        // Gas optimization: this is cheaper than requiring 'a' not being zero, but the
        // benefit is lost if 'b' is also tested.
        // See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522
        if (a == 0) {
            return 0;
        }

        uint256 c = a * b;
        require(c / a == b, "SafeMath: multiplication overflow");

        return c;
    }

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

    /**
     * @dev Returns the integer division of two unsigned integers. Reverts with custom message on
     * division by zero. The result is rounded towards zero.
     *
     * Counterpart to Solidity's `/` operator. Note: this function uses a
     * `revert` opcode (which leaves remaining gas untouched) while Solidity
     * uses an invalid opcode to revert (consuming all remaining gas).
     *
     * Requirements:
     * - The divisor cannot be zero.
     *
     * _Available since v2.4.0._
     */
    function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
        // Solidity only automatically asserts when dividing by 0
        require(b > 0, errorMessage);
        uint256 c = a / b;
        // assert(a == b * c + a % b); // There is no case in which this doesn't hold

        return c;
    }

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

    /**
     * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
     * Reverts with custom message when dividing by zero.
     *
     * Counterpart to Solidity's `%` operator. This function uses a `revert`
     * opcode (which leaves remaining gas untouched) while Solidity uses an
     * invalid opcode to revert (consuming all remaining gas).
     *
     * Requirements:
     * - The divisor cannot be zero.
     *
     * _Available since v2.4.0._
     */
    function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
        require(b != 0, errorMessage);
        return a % b;
    }
}
          

/openzeppelin-solidity/contracts/ownership/Ownable.sol

pragma solidity ^0.5.0;

import "../GSN/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.
 *
 * 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.
 */
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 () internal {
        address msgSender = _msgSender();
        _owner = msgSender;
        emit OwnershipTransferred(address(0), msgSender);
    }

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

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

    /**
     * @dev Returns true if the caller is the current owner.
     */
    function isOwner() public view returns (bool) {
        return _msgSender() == _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 onlyOwner {
        emit OwnershipTransferred(_owner, address(0));
        _owner = 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 onlyOwner {
        _transferOwnership(newOwner);
    }

    /**
     * @dev Transfers ownership of the contract to a new account (`newOwner`).
     */
    function _transferOwnership(address newOwner) internal {
        require(newOwner != address(0), "Ownable: new owner is the zero address");
        emit OwnershipTransferred(_owner, newOwner);
        _owner = newOwner;
    }
}
          

/openzeppelin-solidity/contracts/token/ERC20/IERC20.sol

pragma solidity ^0.5.0;

/**
 * @dev Interface of the ERC20 standard as defined in the EIP. Does not include
 * the optional functions; to access them see {ERC20Detailed}.
 */
interface IERC20 {
    /**
     * @dev Returns the amount of tokens in existence.
     */
    function totalSupply() external view returns (uint256);

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

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

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

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

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

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

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

Contract ABI

[{"type":"constructor","stateMutability":"nonpayable","payable":false,"inputs":[{"type":"bool","name":"test","internalType":"bool"}]},{"type":"event","name":"BucketsUpdated","inputs":[{"type":"uint256","name":"goldBucket","internalType":"uint256","indexed":false},{"type":"uint256","name":"stableBucket","internalType":"uint256","indexed":false}],"anonymous":false},{"type":"event","name":"Exchanged","inputs":[{"type":"address","name":"exchanger","internalType":"address","indexed":true},{"type":"uint256","name":"sellAmount","internalType":"uint256","indexed":false},{"type":"uint256","name":"buyAmount","internalType":"uint256","indexed":false},{"type":"bool","name":"soldGold","internalType":"bool","indexed":false}],"anonymous":false},{"type":"event","name":"MinimumReportsSet","inputs":[{"type":"uint256","name":"minimumReports","internalType":"uint256","indexed":false}],"anonymous":false},{"type":"event","name":"OwnershipTransferred","inputs":[{"type":"address","name":"previousOwner","internalType":"address","indexed":true},{"type":"address","name":"newOwner","internalType":"address","indexed":true}],"anonymous":false},{"type":"event","name":"RegistrySet","inputs":[{"type":"address","name":"registryAddress","internalType":"address","indexed":true}],"anonymous":false},{"type":"event","name":"ReserveFractionSet","inputs":[{"type":"uint256","name":"reserveFraction","internalType":"uint256","indexed":false}],"anonymous":false},{"type":"event","name":"SpreadSet","inputs":[{"type":"uint256","name":"spread","internalType":"uint256","indexed":false}],"anonymous":false},{"type":"event","name":"StableTokenSet","inputs":[{"type":"address","name":"stable","internalType":"address","indexed":true}],"anonymous":false},{"type":"event","name":"UpdateFrequencySet","inputs":[{"type":"uint256","name":"updateFrequency","internalType":"uint256","indexed":false}],"anonymous":false},{"type":"function","stateMutability":"nonpayable","payable":false,"outputs":[],"name":"activateStable","inputs":[],"constant":false},{"type":"function","stateMutability":"nonpayable","payable":false,"outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"buy","inputs":[{"type":"uint256","name":"buyAmount","internalType":"uint256"},{"type":"uint256","name":"maxSellAmount","internalType":"uint256"},{"type":"bool","name":"buyGold","internalType":"bool"}],"constant":false},{"type":"function","stateMutability":"nonpayable","payable":false,"outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"exchange","inputs":[{"type":"uint256","name":"sellAmount","internalType":"uint256"},{"type":"uint256","name":"minBuyAmount","internalType":"uint256"},{"type":"bool","name":"sellGold","internalType":"bool"}],"constant":false},{"type":"function","stateMutability":"view","payable":false,"outputs":[{"type":"uint256","name":"","internalType":"uint256"},{"type":"uint256","name":"","internalType":"uint256"}],"name":"getBuyAndSellBuckets","inputs":[{"type":"bool","name":"sellGold","internalType":"bool"}],"constant":true},{"type":"function","stateMutability":"view","payable":false,"outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"getBuyTokenAmount","inputs":[{"type":"uint256","name":"sellAmount","internalType":"uint256"},{"type":"bool","name":"sellGold","internalType":"bool"}],"constant":true},{"type":"function","stateMutability":"view","payable":false,"outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"getSellTokenAmount","inputs":[{"type":"uint256","name":"buyAmount","internalType":"uint256"},{"type":"bool","name":"sellGold","internalType":"bool"}],"constant":true},{"type":"function","stateMutability":"pure","payable":false,"outputs":[{"type":"uint256","name":"","internalType":"uint256"},{"type":"uint256","name":"","internalType":"uint256"},{"type":"uint256","name":"","internalType":"uint256"},{"type":"uint256","name":"","internalType":"uint256"}],"name":"getVersionNumber","inputs":[],"constant":true},{"type":"function","stateMutability":"view","payable":false,"outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"goldBucket","inputs":[],"constant":true},{"type":"function","stateMutability":"nonpayable","payable":false,"outputs":[],"name":"initialize","inputs":[{"type":"address","name":"registryAddress","internalType":"address"},{"type":"string","name":"stableTokenIdentifier","internalType":"string"},{"type":"uint256","name":"_spread","internalType":"uint256"},{"type":"uint256","name":"_reserveFraction","internalType":"uint256"},{"type":"uint256","name":"_updateFrequency","internalType":"uint256"},{"type":"uint256","name":"_minimumReports","internalType":"uint256"}],"constant":false},{"type":"function","stateMutability":"view","payable":false,"outputs":[{"type":"bool","name":"","internalType":"bool"}],"name":"initialized","inputs":[],"constant":true},{"type":"function","stateMutability":"view","payable":false,"outputs":[{"type":"bool","name":"","internalType":"bool"}],"name":"isOwner","inputs":[],"constant":true},{"type":"function","stateMutability":"view","payable":false,"outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"lastBucketUpdate","inputs":[],"constant":true},{"type":"function","stateMutability":"view","payable":false,"outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"minimumReports","inputs":[],"constant":true},{"type":"function","stateMutability":"view","payable":false,"outputs":[{"type":"address","name":"","internalType":"address"}],"name":"owner","inputs":[],"constant":true},{"type":"function","stateMutability":"view","payable":false,"outputs":[{"type":"address","name":"","internalType":"contract IRegistry"}],"name":"registry","inputs":[],"constant":true},{"type":"function","stateMutability":"nonpayable","payable":false,"outputs":[],"name":"renounceOwnership","inputs":[],"constant":false},{"type":"function","stateMutability":"view","payable":false,"outputs":[{"type":"uint256","name":"value","internalType":"uint256"}],"name":"reserveFraction","inputs":[],"constant":true},{"type":"function","stateMutability":"nonpayable","payable":false,"outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"sell","inputs":[{"type":"uint256","name":"sellAmount","internalType":"uint256"},{"type":"uint256","name":"minBuyAmount","internalType":"uint256"},{"type":"bool","name":"sellGold","internalType":"bool"}],"constant":false},{"type":"function","stateMutability":"nonpayable","payable":false,"outputs":[],"name":"setMinimumReports","inputs":[{"type":"uint256","name":"newMininumReports","internalType":"uint256"}],"constant":false},{"type":"function","stateMutability":"nonpayable","payable":false,"outputs":[],"name":"setRegistry","inputs":[{"type":"address","name":"registryAddress","internalType":"address"}],"constant":false},{"type":"function","stateMutability":"nonpayable","payable":false,"outputs":[],"name":"setReserveFraction","inputs":[{"type":"uint256","name":"newReserveFraction","internalType":"uint256"}],"constant":false},{"type":"function","stateMutability":"nonpayable","payable":false,"outputs":[],"name":"setSpread","inputs":[{"type":"uint256","name":"newSpread","internalType":"uint256"}],"constant":false},{"type":"function","stateMutability":"nonpayable","payable":false,"outputs":[],"name":"setStableToken","inputs":[{"type":"address","name":"newStableToken","internalType":"address"}],"constant":false},{"type":"function","stateMutability":"nonpayable","payable":false,"outputs":[],"name":"setUpdateFrequency","inputs":[{"type":"uint256","name":"newUpdateFrequency","internalType":"uint256"}],"constant":false},{"type":"function","stateMutability":"view","payable":false,"outputs":[{"type":"uint256","name":"value","internalType":"uint256"}],"name":"spread","inputs":[],"constant":true},{"type":"function","stateMutability":"view","payable":false,"outputs":[{"type":"address","name":"","internalType":"address"}],"name":"stable","inputs":[],"constant":true},{"type":"function","stateMutability":"view","payable":false,"outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"stableBucket","inputs":[],"constant":true},{"type":"function","stateMutability":"view","payable":false,"outputs":[{"type":"bytes32","name":"","internalType":"bytes32"}],"name":"stableTokenRegistryId","inputs":[],"constant":true},{"type":"function","stateMutability":"nonpayable","payable":false,"outputs":[],"name":"transferOwnership","inputs":[{"type":"address","name":"newOwner","internalType":"address"}],"constant":false},{"type":"function","stateMutability":"view","payable":false,"outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"updateFrequency","inputs":[],"constant":true}]
              

Contract Creation Code

0x608060405260006008553480156200001657600080fd5b5060405162003e6238038062003e62833981810160405260208110156200003c57600080fd5b810190808051906020019092919050505080806200006f5760016000806101000a81548160ff0219169083151502179055505b506000620000826200013060201b60201c565b905080600060016101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055508073ffffffffffffffffffffffffffffffffffffffff16600073ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a35060016002819055505062000138565b600033905090565b613d1a80620001486000396000f3fe608060405234801561001057600080fd5b50600436106101da5760003560e01c806381bb18ec11610104578063c3434883116100a2578063db1bc87b11610071578063db1bc87b146107a8578063dda57b93146107ec578063e0c8b50a1461080a578063f2fde38b14610828576101da565b8063c343488314610657578063cf317778146106af578063d1a2bc1114610770578063d404f7f81461077a576101da565b80638f32d59b116100de5780638f32d59b146105755780639ed02b5814610597578063a91ee0dc146105e5578063b66a261c14610629576101da565b806381bb18ec146104b55780638ab1a5d4146104d35780638da5cb5b1461052b576101da565b806354255be01161017c5780636a5eaf471161014b5780636a5eaf47146103e8578063715018a61461041657806378ba9cfd146104205780637b1039991461046b576101da565b806354255be01461035b5780635c25c76c1461038e57806362f09084146103ac578063673ea086146103ca576101da565b806325ac2de6116101b857806325ac2de6146102695780632bc7d67a146102875780634a1be6cb146102df5780634c0226a21461030d576101da565b8063158ef93e146101df57806322503ce51461020157806322be3de11461021f575b600080fd5b6101e761086c565b604051808215151515815260200191505060405180910390f35b61020961087e565b6040518082815260200191505060405180910390f35b610227610884565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b6102716108aa565b6040518082815260200191505060405180910390f35b6102c96004803603606081101561029d57600080fd5b8101908080359060200190929190803590602001909291908035151590602001909291905050506108b0565b6040518082815260200191505060405180910390f35b61030b600480360360208110156102f557600080fd5b81019080803590602001909291905050506108c6565b005b6103456004803603604081101561032357600080fd5b8101908080359060200190929190803515159060200190929190505050610981565b6040518082815260200191505060405180910390f35b6103636109a8565b6040518085815260200184815260200183815260200182815260200194505050505060405180910390f35b6103966109cf565b6040518082815260200191505060405180910390f35b6103b46109db565b6040518082815260200191505060405180910390f35b6103d26109e1565b6040518082815260200191505060405180910390f35b610414600480360360208110156103fe57600080fd5b81019080803590602001909291905050506109e7565b005b61041e610b38565b005b61044e6004803603602081101561043657600080fd5b81019080803515159060200190929190505050610c72565b604051808381526020018281526020019250505060405180910390f35b610473610cc2565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b6104bd610ce8565b6040518082815260200191505060405180910390f35b610515600480360360608110156104e957600080fd5b810190808035906020019092919080359060200190929190803515159060200190929190505050610cee565b6040518082815260200191505060405180910390f35b610533610f2d565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b61057d610f56565b604051808215151515815260200191505060405180910390f35b6105cf600480360360408110156105ad57600080fd5b8101908080359060200190929190803515159060200190929190505050610fb4565b6040518082815260200191505060405180910390f35b610627600480360360208110156105fb57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610fdb565b005b6106556004803603602081101561063f57600080fd5b810190808035906020019092919050505061117f565b005b6106996004803603606081101561066d57600080fd5b8101908080359060200190929190803590602001909291908035151590602001909291905050506112c7565b6040518082815260200191505060405180910390f35b61076e600480360360c08110156106c557600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff1690602001909291908035906020019064010000000081111561070257600080fd5b82018360208201111561071457600080fd5b8035906020019184600183028401116401000000008311171561073657600080fd5b90919293919293908035906020019092919080359060200190929190803590602001909291908035906020019092919050505061150d565b005b61077861161e565b005b6107a66004803603602081101561079057600080fd5b8101908080359060200190929190505050611801565b005b6107ea600480360360208110156107be57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff1690602001909291905050506118bc565b005b6107f4611942565b6040518082815260200191505060405180910390f35b61081261194e565b6040518082815260200191505060405180910390f35b61086a6004803603602081101561083e57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050611954565b005b6000809054906101000a900460ff1681565b600a5481565b600560009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b60075481565b60006108bd848484610cee565b90509392505050565b6108ce610f56565b610940576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260208152602001807f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657281525060200191505060405180910390fd5b806009819055507f90c0a4a142fbfbc2ae8c21f50729a2f4bc56e85a66c1a1b6654f1e85092a54a6816040518082815260200191505060405180910390a150565b600080600061098f84610c72565b9150915061099e8282876119da565b9250505092915050565b60008060008060016002600080839350829250819150809050935093509350935090919293565b60038060000154905081565b60065481565b60095481565b6109ef610f56565b610a61576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260208152602001807f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657281525060200191505060405180910390fd5b610a6a81611aa7565b600460008201518160000155905050610aa9610a84611ac5565b6004604051806020016040529081600082015481525050611aeb90919063ffffffff16565b610afe576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526027815260200180613cbf6027913960400191505060405180910390fd5b7fb690f84efb1d9039c2834effb7bebc792a85bfec7ef84f4b269528454f363ccf816040518082815260200191505060405180910390a150565b610b40610f56565b610bb2576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260208152602001807f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657281525060200191505060405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff16600060019054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a360008060016101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550565b6000806000600654905060006007549050610c8b611b00565b15610ca157610c98611efd565b80925081935050505b8415610cb4578082935093505050610cbd565b81819350935050505b915091565b600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b600b5481565b6000610cf8611f56565b73ffffffffffffffffffffffffffffffffffffffff1663e5839836306040518263ffffffff1660e01b8152600401808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060206040518083038186803b158015610d7457600080fd5b505afa158015610d88573d6000803e3d6000fd5b505050506040513d6020811015610d9e57600080fd5b810190808051906020019092919050505015610e05576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526022815260200180613bb26022913960400191505060405180910390fd5b610e0d612051565b600160026000828254019250508190555060006002549050600080610e31856120c7565b915091506000610e4283838a6120ef565b905086811015610e9d576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526039815260200180613b796039913960400191505060405180910390fd5b610ea888828861218f565b8094505050506002548114610f25576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252600e8152602001807f7265656e7472616e742063616c6c00000000000000000000000000000000000081525060200191505060405180910390fd5b509392505050565b60008060019054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905090565b60008060019054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16610f9861299b565b73ffffffffffffffffffffffffffffffffffffffff1614905090565b6000806000610fc284610c72565b91509150610fd18282876120ef565b9250505092915050565b610fe3610f56565b611055576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260208152602001807f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657281525060200191505060405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff1614156110f8576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260208152602001807f43616e6e6f7420726567697374657220746865206e756c6c206164647265737381525060200191505060405180910390fd5b80600160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055508073ffffffffffffffffffffffffffffffffffffffff167f27fe5f0c1c3b1ed427cc63d0f05759ffdecf9aec9e18d31ef366fc8a6cb5dc3b60405160405180910390a250565b611187610f56565b6111f9576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260208152602001807f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657281525060200191505060405180910390fd5b61120281611aa7565b6003600082015181600001559050506112386003604051806020016040529081600082015481525050611233611ac5565b6129a3565b61128d576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526026815260200180613c996026913960400191505060405180910390fd5b7f8946f328efcc515b5cc3282f6cd95e87a6c0d3508421af0b52d4d3620b3e2db3816040518082815260200191505060405180910390a150565b60006112d1611f56565b73ffffffffffffffffffffffffffffffffffffffff1663e5839836306040518263ffffffff1660e01b8152600401808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060206040518083038186803b15801561134d57600080fd5b505afa158015611361573d6000803e3d6000fd5b505050506040513d602081101561137757600080fd5b8101908080519060200190929190505050156113de576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526022815260200180613bb26022913960400191505060405180910390fd5b6113e6612051565b600160026000828254019250508190555060006002549050600083159050600080611410836120c7565b91509150600061142183838b6119da565b90508781111561147c576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252603e815260200180613c0a603e913960400191505060405180910390fd5b611487818a8661218f565b809550505050506002548114611505576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252600e8152602001807f7265656e7472616e742063616c6c00000000000000000000000000000000000081525060200191505060405180910390fd5b509392505050565b6000809054906101000a900460ff161561158f576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601c8152602001807f636f6e747261637420616c726561647920696e697469616c697a65640000000081525060200191505060405180910390fd5b60016000806101000a81548160ff0219169083151502179055506115b2336129b9565b6115bb87610fdb565b858560405160200180838380828437808301925050509250505060405160208183030381529060405280519060200120600b819055506115fa8461117f565b611603836109e7565b61160c826108c6565b61161581611801565b50505050505050565b611626610f56565b611698576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260208152602001807f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657281525060200191505060405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff16600560009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff161461173f576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526025815260200180613b546025913960400191505060405180910390fd5b6117f7600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663dcf0aaed600b546040518263ffffffff1660e01b81526004018082815260200191505060206040518083038186803b1580156117b757600080fd5b505afa1580156117cb573d6000803e3d6000fd5b505050506040513d60208110156117e157600080fd5b8101908080519060200190929190505050612aff565b6117ff612051565b565b611809610f56565b61187b576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260208152602001807f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657281525060200191505060405180910390fd5b80600a819055507f08523596abc266fb46d9c40ddf78fdfd3c08142252833ddce1a2b46f76521035816040518082815260200191505060405180910390a150565b6118c4610f56565b611936576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260208152602001807f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657281525060200191505060405180910390fd5b61193f81612aff565b50565b60048060000154905081565b60085481565b61195c610f56565b6119ce576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260208152602001807f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657281525060200191505060405180910390fd5b6119d7816129b9565b50565b6000808214156119ed5760009050611aa0565b6119f5613b1a565b611a10611a0b8585612b8690919063ffffffff16565b612c0c565b9050611a1a613b1a565b611a76611a4d6003604051806020016040529081600082015481525050611a3f611ac5565b612c9690919063ffffffff16565b611a68611a63878a612d3d90919063ffffffff16565b612c0c565b612d8790919063ffffffff16565b9050611a9b611a84826131e6565b611a8d846131e6565b6131f490919063ffffffff16565b925050505b9392505050565b611aaf613b1a565b6040518060200160405280838152509050919050565b611acd613b1a565b604051806020016040528069d3c21bcecceda1000000815250905090565b60008160000151836000015110905092915050565b600080600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663dcf0aaed60405160200180807f536f727465644f7261636c657300000000000000000000000000000000000000815250600d019050604051602081830303815290604052805190602001206040518263ffffffff1660e01b81526004018082815260200191505060206040518083038186803b158015611bbc57600080fd5b505afa158015611bd0573d6000803e3d6000fd5b505050506040513d6020811015611be657600080fd5b8101908080519060200190929190505050905060008173ffffffffffffffffffffffffffffffffffffffff1663ffe736bf600560009054906101000a900473ffffffffffffffffffffffffffffffffffffffff166040518263ffffffff1660e01b8152600401808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001915050604080518083038186803b158015611c9957600080fd5b505afa158015611cad573d6000803e3d6000fd5b505050506040513d6040811015611cc357600080fd5b8101908080519060200190929190805190602001909291905050505090506000611cfa60095460085461323e90919063ffffffff16565b42101590506000600a548473ffffffffffffffffffffffffffffffffffffffff1663bbc66a94600560009054906101000a900473ffffffffffffffffffffffffffffffffffffffff166040518263ffffffff1660e01b8152600401808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060206040518083038186803b158015611da357600080fd5b505afa158015611db7573d6000803e3d6000fd5b505050506040513d6020811015611dcd57600080fd5b8101908080519060200190929190505050101590506000611df960095442612d3d90919063ffffffff16565b8573ffffffffffffffffffffffffffffffffffffffff1663071b48fc600560009054906101000a900473ffffffffffffffffffffffffffffffffffffffff166040518263ffffffff1660e01b8152600401808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060206040518083038186803b158015611e9857600080fd5b505afa158015611eac573d6000803e3d6000fd5b505050506040513d6020811015611ec257600080fd5b8101908080519060200190929190505050119050828015611ee05750815b8015611ee95750805b8015611ef3575083155b9550505050505090565b6000806000611f0a6132c6565b9050600080611f17613392565b80925081935050506000611f4682611f388686612b8690919063ffffffff16565b6131f490919063ffffffff16565b9050838195509550505050509091565b6000600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663dcf0aaed60405160200180807f467265657a6572000000000000000000000000000000000000000000000000008152506007019050604051602081830303815290604052805190602001206040518263ffffffff1660e01b81526004018082815260200191505060206040518083038186803b15801561201157600080fd5b505afa158015612025573d6000803e3d6000fd5b505050506040513d602081101561203b57600080fd5b8101908080519060200190929190505050905090565b612059611b00565b156120c5574260088190555061206d611efd565b60066000600760008491905055839190505550507fa18ec663cb684011386aa866c4dacb32d2d2ad859a35d3440b6ce7200a76bad8600654600754604051808381526020018281526020019250505060405180910390a15b565b60008082156120df57600754600654915091506120ea565b600654600754915091505b915091565b6000808214156121025760009050612188565b61210a613b1a565b612113836135db565b905061211d613b1a565b61213861212987612c0c565b83612d8790919063ffffffff16565b9050612142613b1a565b61215d8361214f88612c0c565b61363490919063ffffffff16565b905061218261216b826131e6565b612174846131e6565b6131f490919063ffffffff16565b93505050505b9392505050565b6000600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663dcf0aaed60405160200180807f52657365727665000000000000000000000000000000000000000000000000008152506007019050604051602081830303815290604052805190602001206040518263ffffffff1660e01b81526004018082815260200191505060206040518083038186803b15801561224a57600080fd5b505afa15801561225e573d6000803e3d6000fd5b505050506040513d602081101561227457600080fd5b81019080805190602001909291905050509050811561258d576122a28460065461323e90919063ffffffff16565b6006819055506122bd83600754612d3d90919063ffffffff16565b6007819055506122cb6136dd565b73ffffffffffffffffffffffffffffffffffffffff166323b872dd3383876040518463ffffffff1660e01b8152600401808473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020018373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020018281526020019350505050602060405180830381600087803b15801561238557600080fd5b505af1158015612399573d6000803e3d6000fd5b505050506040513d60208110156123af57600080fd5b8101908080519060200190929190505050612432576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601d8152602001807f5472616e73666572206f662073656c6c20746f6b656e206661696c656400000081525060200191505060405180910390fd5b600560009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166340c10f1933856040518363ffffffff1660e01b8152600401808373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200182815260200192505050602060405180830381600087803b1580156124db57600080fd5b505af11580156124ef573d6000803e3d6000fd5b505050506040513d602081101561250557600080fd5b8101908080519060200190929190505050612588576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601b8152602001807f4d696e74206f6620737461626c6520746f6b656e206661696c6564000000000081525060200191505060405180910390fd5b612933565b6125a28460075461323e90919063ffffffff16565b6007819055506125bd83600654612d3d90919063ffffffff16565b600681905550600560009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166323b872dd3330876040518463ffffffff1660e01b8152600401808473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020018373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020018281526020019350505050602060405180830381600087803b1580156126a057600080fd5b505af11580156126b4573d6000803e3d6000fd5b505050506040513d60208110156126ca57600080fd5b810190808051906020019092919050505061274d576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601d8152602001807f5472616e73666572206f662073656c6c20746f6b656e206661696c656400000081525060200191505060405180910390fd5b600560009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166342966c68856040518263ffffffff1660e01b815260040180828152602001915050602060405180830381600087803b1580156127c257600080fd5b505af11580156127d6573d6000803e3d6000fd5b505050506040513d60208110156127ec57600080fd5b8101908080519060200190929190505050508073ffffffffffffffffffffffffffffffffffffffff166303a0fea333856040518363ffffffff1660e01b8152600401808373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200182815260200192505050602060405180830381600087803b15801561288557600080fd5b505af1158015612899573d6000803e3d6000fd5b505050506040513d60208110156128af57600080fd5b8101908080519060200190929190505050612932576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601b8152602001807f5472616e73666572206f6620627579546f6b656e206661696c6564000000000081525060200191505060405180910390fd5b5b3373ffffffffffffffffffffffffffffffffffffffff167f402ac9185b4616422c2794bf5b118bfcc68ed496d52c0d9841dfa114fdeb05ba8585856040518084815260200183815260200182151515158152602001935050505060405180910390a250505050565b600033905090565b6000816000015183600001511115905092915050565b600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff161415612a3f576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526026815260200180613b2e6026913960400191505060405180910390fd5b8073ffffffffffffffffffffffffffffffffffffffff16600060019054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a380600060016101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050565b80600560006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055508073ffffffffffffffffffffffffffffffffffffffff167f119a23392e161a0bc5f9d5f3e2a6040c45b40d43a36973e10ea1de916f3d8a8a60405160405180910390a250565b600080831415612b995760009050612c06565b6000828402905082848281612baa57fe5b0414612c01576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526021815260200180613c786021913960400191505060405180910390fd5b809150505b92915050565b612c14613b1a565b612c1c6137d8565b821115612c74576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526036815260200180613bd46036913960400191505060405180910390fd5b604051806020016040528069d3c21bcecceda100000084028152509050919050565b612c9e613b1a565b816000015183600001511015612d1c576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601f8152602001807f737562737472616374696f6e20756e646572666c6f772064657465637465640081525060200191505060405180910390fd5b60405180602001604052808360000151856000015103815250905092915050565b6000612d7f83836040518060400160405280601e81526020017f536166654d6174683a207375627472616374696f6e206f766572666c6f7700008152506137f7565b905092915050565b612d8f613b1a565b600083600001511480612da6575060008260000151145b15612dc2576040518060200160405280600081525090506131e0565b69d3c21bcecceda100000082600001511415612de0578290506131e0565b69d3c21bcecceda100000083600001511415612dfe578190506131e0565b600069d3c21bcecceda1000000612e14856138b7565b6000015181612e1f57fe5b0490506000612e2d856138ee565b600001519050600069d3c21bcecceda1000000612e49866138b7565b6000015181612e5457fe5b0490506000612e62866138ee565b6000015190506000828502905060008514612ef65782858281612e8157fe5b0414612ef5576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260168152602001807f6f766572666c6f7720783179312064657465637465640000000000000000000081525060200191505060405180910390fd5b5b600069d3c21bcecceda10000008202905060008214612f985769d3c21bcecceda1000000828281612f2357fe5b0414612f97576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601f8152602001807f6f766572666c6f772078317931202a206669786564312064657465637465640081525060200191505060405180910390fd5b5b80915060008486029050600086146130295784868281612fb457fe5b0414613028576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260168152602001807f6f766572666c6f7720783279312064657465637465640000000000000000000081525060200191505060405180910390fd5b5b60008488029050600088146130b7578488828161304257fe5b04146130b6576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260168152602001807f6f766572666c6f7720783179322064657465637465640000000000000000000081525060200191505060405180910390fd5b5b6130bf61392b565b87816130c757fe5b0496506130d261392b565b85816130da57fe5b049450600085880290506000881461316b57858882816130f657fe5b041461316a576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260168152602001807f6f766572666c6f7720783279322064657465637465640000000000000000000081525060200191505060405180910390fd5b5b613173613b1a565b604051806020016040528087815250905061319c81604051806020016040528087815250613634565b90506131b681604051806020016040528086815250613634565b90506131d081604051806020016040528085815250613634565b9050809a50505050505050505050505b92915050565b600081600001519050919050565b600061323683836040518060400160405280601a81526020017f536166654d6174683a206469766973696f6e206279207a65726f000000000000815250613938565b905092915050565b6000808284019050838110156132bc576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601b8152602001807f536166654d6174683a206164646974696f6e206f766572666c6f77000000000081525060200191505060405180910390fd5b8091505092915050565b6000806132d16139fe565b73ffffffffffffffffffffffffffffffffffffffff16638b7df8d46040518163ffffffff1660e01b815260040160206040518083038186803b15801561331657600080fd5b505afa15801561332a573d6000803e3d6000fd5b505050506040513d602081101561334057600080fd5b8101908080519060200190929190505050905061338c61338761336283612c0c565b6004604051806020016040529081600082015481525050612d8790919063ffffffff16565b613af9565b91505090565b600080600080600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663dcf0aaed60405160200180807f536f727465644f7261636c657300000000000000000000000000000000000000815250600d019050604051602081830303815290604052805190602001206040518263ffffffff1660e01b81526004018082815260200191505060206040518083038186803b15801561345157600080fd5b505afa158015613465573d6000803e3d6000fd5b505050506040513d602081101561347b57600080fd5b810190808051906020019092919050505073ffffffffffffffffffffffffffffffffffffffff1663ef90e1b0600560009054906101000a900473ffffffffffffffffffffffffffffffffffffffff166040518263ffffffff1660e01b8152600401808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001915050604080518083038186803b15801561352957600080fd5b505afa15801561353d573d6000803e3d6000fd5b505050506040513d604081101561355357600080fd5b8101908080519060200190929190805190602001909291905050508092508193505050600081116135cf576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526030815260200180613c486030913960400191505060405180910390fd5b81819350935050509091565b6135e3613b1a565b61362d6135ef83612c0c565b61361f6003604051806020016040529081600082015481525050613611611ac5565b612c9690919063ffffffff16565b612d8790919063ffffffff16565b9050919050565b61363c613b1a565b60008260000151846000015101905083600001518110156136c5576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260158152602001807f616464206f766572666c6f77206465746563746564000000000000000000000081525060200191505060405180910390fd5b60405180602001604052808281525091505092915050565b6000600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663dcf0aaed60405160200180807f476f6c64546f6b656e00000000000000000000000000000000000000000000008152506009019050604051602081830303815290604052805190602001206040518263ffffffff1660e01b81526004018082815260200191505060206040518083038186803b15801561379857600080fd5b505afa1580156137ac573d6000803e3d6000fd5b505050506040513d60208110156137c257600080fd5b8101908080519060200190929190505050905090565b60007601357c299a88ea76a58924d52ce4f26a85af186c2b9e74905090565b60008383111582906138a4576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825283818151815260200191508051906020019080838360005b8381101561386957808201518184015260208101905061384e565b50505050905090810190601f1680156138965780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b5060008385039050809150509392505050565b6138bf613b1a565b604051806020016040528069d3c21bcecceda1000000808560000151816138e257fe5b04028152509050919050565b6138f6613b1a565b604051806020016040528069d3c21bcecceda10000008085600001518161391957fe5b04028460000151038152509050919050565b600064e8d4a51000905090565b600080831182906139e4576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825283818151815260200191508051906020019080838360005b838110156139a957808201518184015260208101905061398e565b50505050905090810190601f1680156139d65780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b5060008385816139f057fe5b049050809150509392505050565b6000600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663dcf0aaed60405160200180807f52657365727665000000000000000000000000000000000000000000000000008152506007019050604051602081830303815290604052805190602001206040518263ffffffff1660e01b81526004018082815260200191505060206040518083038186803b158015613ab957600080fd5b505afa158015613acd573d6000803e3d6000fd5b505050506040513d6020811015613ae357600080fd5b8101908080519060200190929190505050905090565b600069d3c21bcecceda1000000826000015181613b1257fe5b049050919050565b604051806020016040528060008152509056fe4f776e61626c653a206e6577206f776e657220697320746865207a65726f2061646472657373537461626c65546f6b656e206164647265737320616c72656164792061637469766174656443616c63756c6174656420627579416d6f756e7420776173206c657373207468616e20737065636966696564206d696e427579416d6f756e7463616e27742063616c6c207768656e20636f6e74726163742069732066726f7a656e63616e277420637265617465206669786964697479206e756d626572206c6172676572207468616e206d61784e65774669786564282943616c63756c617465642073656c6c416d6f756e74207761732067726561746572207468616e20737065636966696564206d617853656c6c416d6f756e7465786368616e676520726174652064656e6f6d696e61746f72206d7573742062652067726561746572207468616e2030536166654d6174683a206d756c7469706c69636174696f6e206f766572666c6f77537072656164206d757374206265206c657373207468616e206f7220657175616c20746f203172657365727665206672616374696f6e206d75737420626520736d616c6c6572207468616e2031a265627a7a72315820a8f5f5453405979847c53f1568cb7fabd77f32a16f00127e9e87d712aba32bae64736f6c634300050d00320000000000000000000000000000000000000000000000000000000000000000

Deployed ByteCode

0x608060405234801561001057600080fd5b50600436106101da5760003560e01c806381bb18ec11610104578063c3434883116100a2578063db1bc87b11610071578063db1bc87b146107a8578063dda57b93146107ec578063e0c8b50a1461080a578063f2fde38b14610828576101da565b8063c343488314610657578063cf317778146106af578063d1a2bc1114610770578063d404f7f81461077a576101da565b80638f32d59b116100de5780638f32d59b146105755780639ed02b5814610597578063a91ee0dc146105e5578063b66a261c14610629576101da565b806381bb18ec146104b55780638ab1a5d4146104d35780638da5cb5b1461052b576101da565b806354255be01161017c5780636a5eaf471161014b5780636a5eaf47146103e8578063715018a61461041657806378ba9cfd146104205780637b1039991461046b576101da565b806354255be01461035b5780635c25c76c1461038e57806362f09084146103ac578063673ea086146103ca576101da565b806325ac2de6116101b857806325ac2de6146102695780632bc7d67a146102875780634a1be6cb146102df5780634c0226a21461030d576101da565b8063158ef93e146101df57806322503ce51461020157806322be3de11461021f575b600080fd5b6101e761086c565b604051808215151515815260200191505060405180910390f35b61020961087e565b6040518082815260200191505060405180910390f35b610227610884565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b6102716108aa565b6040518082815260200191505060405180910390f35b6102c96004803603606081101561029d57600080fd5b8101908080359060200190929190803590602001909291908035151590602001909291905050506108b0565b6040518082815260200191505060405180910390f35b61030b600480360360208110156102f557600080fd5b81019080803590602001909291905050506108c6565b005b6103456004803603604081101561032357600080fd5b8101908080359060200190929190803515159060200190929190505050610981565b6040518082815260200191505060405180910390f35b6103636109a8565b6040518085815260200184815260200183815260200182815260200194505050505060405180910390f35b6103966109cf565b6040518082815260200191505060405180910390f35b6103b46109db565b6040518082815260200191505060405180910390f35b6103d26109e1565b6040518082815260200191505060405180910390f35b610414600480360360208110156103fe57600080fd5b81019080803590602001909291905050506109e7565b005b61041e610b38565b005b61044e6004803603602081101561043657600080fd5b81019080803515159060200190929190505050610c72565b604051808381526020018281526020019250505060405180910390f35b610473610cc2565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b6104bd610ce8565b6040518082815260200191505060405180910390f35b610515600480360360608110156104e957600080fd5b810190808035906020019092919080359060200190929190803515159060200190929190505050610cee565b6040518082815260200191505060405180910390f35b610533610f2d565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b61057d610f56565b604051808215151515815260200191505060405180910390f35b6105cf600480360360408110156105ad57600080fd5b8101908080359060200190929190803515159060200190929190505050610fb4565b6040518082815260200191505060405180910390f35b610627600480360360208110156105fb57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610fdb565b005b6106556004803603602081101561063f57600080fd5b810190808035906020019092919050505061117f565b005b6106996004803603606081101561066d57600080fd5b8101908080359060200190929190803590602001909291908035151590602001909291905050506112c7565b6040518082815260200191505060405180910390f35b61076e600480360360c08110156106c557600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff1690602001909291908035906020019064010000000081111561070257600080fd5b82018360208201111561071457600080fd5b8035906020019184600183028401116401000000008311171561073657600080fd5b90919293919293908035906020019092919080359060200190929190803590602001909291908035906020019092919050505061150d565b005b61077861161e565b005b6107a66004803603602081101561079057600080fd5b8101908080359060200190929190505050611801565b005b6107ea600480360360208110156107be57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff1690602001909291905050506118bc565b005b6107f4611942565b6040518082815260200191505060405180910390f35b61081261194e565b6040518082815260200191505060405180910390f35b61086a6004803603602081101561083e57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050611954565b005b6000809054906101000a900460ff1681565b600a5481565b600560009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b60075481565b60006108bd848484610cee565b90509392505050565b6108ce610f56565b610940576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260208152602001807f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657281525060200191505060405180910390fd5b806009819055507f90c0a4a142fbfbc2ae8c21f50729a2f4bc56e85a66c1a1b6654f1e85092a54a6816040518082815260200191505060405180910390a150565b600080600061098f84610c72565b9150915061099e8282876119da565b9250505092915050565b60008060008060016002600080839350829250819150809050935093509350935090919293565b60038060000154905081565b60065481565b60095481565b6109ef610f56565b610a61576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260208152602001807f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657281525060200191505060405180910390fd5b610a6a81611aa7565b600460008201518160000155905050610aa9610a84611ac5565b6004604051806020016040529081600082015481525050611aeb90919063ffffffff16565b610afe576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526027815260200180613cbf6027913960400191505060405180910390fd5b7fb690f84efb1d9039c2834effb7bebc792a85bfec7ef84f4b269528454f363ccf816040518082815260200191505060405180910390a150565b610b40610f56565b610bb2576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260208152602001807f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657281525060200191505060405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff16600060019054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a360008060016101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550565b6000806000600654905060006007549050610c8b611b00565b15610ca157610c98611efd565b80925081935050505b8415610cb4578082935093505050610cbd565b81819350935050505b915091565b600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b600b5481565b6000610cf8611f56565b73ffffffffffffffffffffffffffffffffffffffff1663e5839836306040518263ffffffff1660e01b8152600401808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060206040518083038186803b158015610d7457600080fd5b505afa158015610d88573d6000803e3d6000fd5b505050506040513d6020811015610d9e57600080fd5b810190808051906020019092919050505015610e05576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526022815260200180613bb26022913960400191505060405180910390fd5b610e0d612051565b600160026000828254019250508190555060006002549050600080610e31856120c7565b915091506000610e4283838a6120ef565b905086811015610e9d576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526039815260200180613b796039913960400191505060405180910390fd5b610ea888828861218f565b8094505050506002548114610f25576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252600e8152602001807f7265656e7472616e742063616c6c00000000000000000000000000000000000081525060200191505060405180910390fd5b509392505050565b60008060019054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905090565b60008060019054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16610f9861299b565b73ffffffffffffffffffffffffffffffffffffffff1614905090565b6000806000610fc284610c72565b91509150610fd18282876120ef565b9250505092915050565b610fe3610f56565b611055576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260208152602001807f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657281525060200191505060405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff1614156110f8576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260208152602001807f43616e6e6f7420726567697374657220746865206e756c6c206164647265737381525060200191505060405180910390fd5b80600160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055508073ffffffffffffffffffffffffffffffffffffffff167f27fe5f0c1c3b1ed427cc63d0f05759ffdecf9aec9e18d31ef366fc8a6cb5dc3b60405160405180910390a250565b611187610f56565b6111f9576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260208152602001807f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657281525060200191505060405180910390fd5b61120281611aa7565b6003600082015181600001559050506112386003604051806020016040529081600082015481525050611233611ac5565b6129a3565b61128d576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526026815260200180613c996026913960400191505060405180910390fd5b7f8946f328efcc515b5cc3282f6cd95e87a6c0d3508421af0b52d4d3620b3e2db3816040518082815260200191505060405180910390a150565b60006112d1611f56565b73ffffffffffffffffffffffffffffffffffffffff1663e5839836306040518263ffffffff1660e01b8152600401808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060206040518083038186803b15801561134d57600080fd5b505afa158015611361573d6000803e3d6000fd5b505050506040513d602081101561137757600080fd5b8101908080519060200190929190505050156113de576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526022815260200180613bb26022913960400191505060405180910390fd5b6113e6612051565b600160026000828254019250508190555060006002549050600083159050600080611410836120c7565b91509150600061142183838b6119da565b90508781111561147c576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252603e815260200180613c0a603e913960400191505060405180910390fd5b611487818a8661218f565b809550505050506002548114611505576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252600e8152602001807f7265656e7472616e742063616c6c00000000000000000000000000000000000081525060200191505060405180910390fd5b509392505050565b6000809054906101000a900460ff161561158f576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601c8152602001807f636f6e747261637420616c726561647920696e697469616c697a65640000000081525060200191505060405180910390fd5b60016000806101000a81548160ff0219169083151502179055506115b2336129b9565b6115bb87610fdb565b858560405160200180838380828437808301925050509250505060405160208183030381529060405280519060200120600b819055506115fa8461117f565b611603836109e7565b61160c826108c6565b61161581611801565b50505050505050565b611626610f56565b611698576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260208152602001807f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657281525060200191505060405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff16600560009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff161461173f576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526025815260200180613b546025913960400191505060405180910390fd5b6117f7600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663dcf0aaed600b546040518263ffffffff1660e01b81526004018082815260200191505060206040518083038186803b1580156117b757600080fd5b505afa1580156117cb573d6000803e3d6000fd5b505050506040513d60208110156117e157600080fd5b8101908080519060200190929190505050612aff565b6117ff612051565b565b611809610f56565b61187b576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260208152602001807f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657281525060200191505060405180910390fd5b80600a819055507f08523596abc266fb46d9c40ddf78fdfd3c08142252833ddce1a2b46f76521035816040518082815260200191505060405180910390a150565b6118c4610f56565b611936576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260208152602001807f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657281525060200191505060405180910390fd5b61193f81612aff565b50565b60048060000154905081565b60085481565b61195c610f56565b6119ce576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260208152602001807f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657281525060200191505060405180910390fd5b6119d7816129b9565b50565b6000808214156119ed5760009050611aa0565b6119f5613b1a565b611a10611a0b8585612b8690919063ffffffff16565b612c0c565b9050611a1a613b1a565b611a76611a4d6003604051806020016040529081600082015481525050611a3f611ac5565b612c9690919063ffffffff16565b611a68611a63878a612d3d90919063ffffffff16565b612c0c565b612d8790919063ffffffff16565b9050611a9b611a84826131e6565b611a8d846131e6565b6131f490919063ffffffff16565b925050505b9392505050565b611aaf613b1a565b6040518060200160405280838152509050919050565b611acd613b1a565b604051806020016040528069d3c21bcecceda1000000815250905090565b60008160000151836000015110905092915050565b600080600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663dcf0aaed60405160200180807f536f727465644f7261636c657300000000000000000000000000000000000000815250600d019050604051602081830303815290604052805190602001206040518263ffffffff1660e01b81526004018082815260200191505060206040518083038186803b158015611bbc57600080fd5b505afa158015611bd0573d6000803e3d6000fd5b505050506040513d6020811015611be657600080fd5b8101908080519060200190929190505050905060008173ffffffffffffffffffffffffffffffffffffffff1663ffe736bf600560009054906101000a900473ffffffffffffffffffffffffffffffffffffffff166040518263ffffffff1660e01b8152600401808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001915050604080518083038186803b158015611c9957600080fd5b505afa158015611cad573d6000803e3d6000fd5b505050506040513d6040811015611cc357600080fd5b8101908080519060200190929190805190602001909291905050505090506000611cfa60095460085461323e90919063ffffffff16565b42101590506000600a548473ffffffffffffffffffffffffffffffffffffffff1663bbc66a94600560009054906101000a900473ffffffffffffffffffffffffffffffffffffffff166040518263ffffffff1660e01b8152600401808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060206040518083038186803b158015611da357600080fd5b505afa158015611db7573d6000803e3d6000fd5b505050506040513d6020811015611dcd57600080fd5b8101908080519060200190929190505050101590506000611df960095442612d3d90919063ffffffff16565b8573ffffffffffffffffffffffffffffffffffffffff1663071b48fc600560009054906101000a900473ffffffffffffffffffffffffffffffffffffffff166040518263ffffffff1660e01b8152600401808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060206040518083038186803b158015611e9857600080fd5b505afa158015611eac573d6000803e3d6000fd5b505050506040513d6020811015611ec257600080fd5b8101908080519060200190929190505050119050828015611ee05750815b8015611ee95750805b8015611ef3575083155b9550505050505090565b6000806000611f0a6132c6565b9050600080611f17613392565b80925081935050506000611f4682611f388686612b8690919063ffffffff16565b6131f490919063ffffffff16565b9050838195509550505050509091565b6000600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663dcf0aaed60405160200180807f467265657a6572000000000000000000000000000000000000000000000000008152506007019050604051602081830303815290604052805190602001206040518263ffffffff1660e01b81526004018082815260200191505060206040518083038186803b15801561201157600080fd5b505afa158015612025573d6000803e3d6000fd5b505050506040513d602081101561203b57600080fd5b8101908080519060200190929190505050905090565b612059611b00565b156120c5574260088190555061206d611efd565b60066000600760008491905055839190505550507fa18ec663cb684011386aa866c4dacb32d2d2ad859a35d3440b6ce7200a76bad8600654600754604051808381526020018281526020019250505060405180910390a15b565b60008082156120df57600754600654915091506120ea565b600654600754915091505b915091565b6000808214156121025760009050612188565b61210a613b1a565b612113836135db565b905061211d613b1a565b61213861212987612c0c565b83612d8790919063ffffffff16565b9050612142613b1a565b61215d8361214f88612c0c565b61363490919063ffffffff16565b905061218261216b826131e6565b612174846131e6565b6131f490919063ffffffff16565b93505050505b9392505050565b6000600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663dcf0aaed60405160200180807f52657365727665000000000000000000000000000000000000000000000000008152506007019050604051602081830303815290604052805190602001206040518263ffffffff1660e01b81526004018082815260200191505060206040518083038186803b15801561224a57600080fd5b505afa15801561225e573d6000803e3d6000fd5b505050506040513d602081101561227457600080fd5b81019080805190602001909291905050509050811561258d576122a28460065461323e90919063ffffffff16565b6006819055506122bd83600754612d3d90919063ffffffff16565b6007819055506122cb6136dd565b73ffffffffffffffffffffffffffffffffffffffff166323b872dd3383876040518463ffffffff1660e01b8152600401808473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020018373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020018281526020019350505050602060405180830381600087803b15801561238557600080fd5b505af1158015612399573d6000803e3d6000fd5b505050506040513d60208110156123af57600080fd5b8101908080519060200190929190505050612432576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601d8152602001807f5472616e73666572206f662073656c6c20746f6b656e206661696c656400000081525060200191505060405180910390fd5b600560009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166340c10f1933856040518363ffffffff1660e01b8152600401808373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200182815260200192505050602060405180830381600087803b1580156124db57600080fd5b505af11580156124ef573d6000803e3d6000fd5b505050506040513d602081101561250557600080fd5b8101908080519060200190929190505050612588576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601b8152602001807f4d696e74206f6620737461626c6520746f6b656e206661696c6564000000000081525060200191505060405180910390fd5b612933565b6125a28460075461323e90919063ffffffff16565b6007819055506125bd83600654612d3d90919063ffffffff16565b600681905550600560009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166323b872dd3330876040518463ffffffff1660e01b8152600401808473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020018373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020018281526020019350505050602060405180830381600087803b1580156126a057600080fd5b505af11580156126b4573d6000803e3d6000fd5b505050506040513d60208110156126ca57600080fd5b810190808051906020019092919050505061274d576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601d8152602001807f5472616e73666572206f662073656c6c20746f6b656e206661696c656400000081525060200191505060405180910390fd5b600560009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166342966c68856040518263ffffffff1660e01b815260040180828152602001915050602060405180830381600087803b1580156127c257600080fd5b505af11580156127d6573d6000803e3d6000fd5b505050506040513d60208110156127ec57600080fd5b8101908080519060200190929190505050508073ffffffffffffffffffffffffffffffffffffffff166303a0fea333856040518363ffffffff1660e01b8152600401808373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200182815260200192505050602060405180830381600087803b15801561288557600080fd5b505af1158015612899573d6000803e3d6000fd5b505050506040513d60208110156128af57600080fd5b8101908080519060200190929190505050612932576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601b8152602001807f5472616e73666572206f6620627579546f6b656e206661696c6564000000000081525060200191505060405180910390fd5b5b3373ffffffffffffffffffffffffffffffffffffffff167f402ac9185b4616422c2794bf5b118bfcc68ed496d52c0d9841dfa114fdeb05ba8585856040518084815260200183815260200182151515158152602001935050505060405180910390a250505050565b600033905090565b6000816000015183600001511115905092915050565b600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff161415612a3f576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526026815260200180613b2e6026913960400191505060405180910390fd5b8073ffffffffffffffffffffffffffffffffffffffff16600060019054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a380600060016101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050565b80600560006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055508073ffffffffffffffffffffffffffffffffffffffff167f119a23392e161a0bc5f9d5f3e2a6040c45b40d43a36973e10ea1de916f3d8a8a60405160405180910390a250565b600080831415612b995760009050612c06565b6000828402905082848281612baa57fe5b0414612c01576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526021815260200180613c786021913960400191505060405180910390fd5b809150505b92915050565b612c14613b1a565b612c1c6137d8565b821115612c74576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526036815260200180613bd46036913960400191505060405180910390fd5b604051806020016040528069d3c21bcecceda100000084028152509050919050565b612c9e613b1a565b816000015183600001511015612d1c576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601f8152602001807f737562737472616374696f6e20756e646572666c6f772064657465637465640081525060200191505060405180910390fd5b60405180602001604052808360000151856000015103815250905092915050565b6000612d7f83836040518060400160405280601e81526020017f536166654d6174683a207375627472616374696f6e206f766572666c6f7700008152506137f7565b905092915050565b612d8f613b1a565b600083600001511480612da6575060008260000151145b15612dc2576040518060200160405280600081525090506131e0565b69d3c21bcecceda100000082600001511415612de0578290506131e0565b69d3c21bcecceda100000083600001511415612dfe578190506131e0565b600069d3c21bcecceda1000000612e14856138b7565b6000015181612e1f57fe5b0490506000612e2d856138ee565b600001519050600069d3c21bcecceda1000000612e49866138b7565b6000015181612e5457fe5b0490506000612e62866138ee565b6000015190506000828502905060008514612ef65782858281612e8157fe5b0414612ef5576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260168152602001807f6f766572666c6f7720783179312064657465637465640000000000000000000081525060200191505060405180910390fd5b5b600069d3c21bcecceda10000008202905060008214612f985769d3c21bcecceda1000000828281612f2357fe5b0414612f97576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601f8152602001807f6f766572666c6f772078317931202a206669786564312064657465637465640081525060200191505060405180910390fd5b5b80915060008486029050600086146130295784868281612fb457fe5b0414613028576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260168152602001807f6f766572666c6f7720783279312064657465637465640000000000000000000081525060200191505060405180910390fd5b5b60008488029050600088146130b7578488828161304257fe5b04146130b6576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260168152602001807f6f766572666c6f7720783179322064657465637465640000000000000000000081525060200191505060405180910390fd5b5b6130bf61392b565b87816130c757fe5b0496506130d261392b565b85816130da57fe5b049450600085880290506000881461316b57858882816130f657fe5b041461316a576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260168152602001807f6f766572666c6f7720783279322064657465637465640000000000000000000081525060200191505060405180910390fd5b5b613173613b1a565b604051806020016040528087815250905061319c81604051806020016040528087815250613634565b90506131b681604051806020016040528086815250613634565b90506131d081604051806020016040528085815250613634565b9050809a50505050505050505050505b92915050565b600081600001519050919050565b600061323683836040518060400160405280601a81526020017f536166654d6174683a206469766973696f6e206279207a65726f000000000000815250613938565b905092915050565b6000808284019050838110156132bc576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601b8152602001807f536166654d6174683a206164646974696f6e206f766572666c6f77000000000081525060200191505060405180910390fd5b8091505092915050565b6000806132d16139fe565b73ffffffffffffffffffffffffffffffffffffffff16638b7df8d46040518163ffffffff1660e01b815260040160206040518083038186803b15801561331657600080fd5b505afa15801561332a573d6000803e3d6000fd5b505050506040513d602081101561334057600080fd5b8101908080519060200190929190505050905061338c61338761336283612c0c565b6004604051806020016040529081600082015481525050612d8790919063ffffffff16565b613af9565b91505090565b600080600080600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663dcf0aaed60405160200180807f536f727465644f7261636c657300000000000000000000000000000000000000815250600d019050604051602081830303815290604052805190602001206040518263ffffffff1660e01b81526004018082815260200191505060206040518083038186803b15801561345157600080fd5b505afa158015613465573d6000803e3d6000fd5b505050506040513d602081101561347b57600080fd5b810190808051906020019092919050505073ffffffffffffffffffffffffffffffffffffffff1663ef90e1b0600560009054906101000a900473ffffffffffffffffffffffffffffffffffffffff166040518263ffffffff1660e01b8152600401808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001915050604080518083038186803b15801561352957600080fd5b505afa15801561353d573d6000803e3d6000fd5b505050506040513d604081101561355357600080fd5b8101908080519060200190929190805190602001909291905050508092508193505050600081116135cf576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526030815260200180613c486030913960400191505060405180910390fd5b81819350935050509091565b6135e3613b1a565b61362d6135ef83612c0c565b61361f6003604051806020016040529081600082015481525050613611611ac5565b612c9690919063ffffffff16565b612d8790919063ffffffff16565b9050919050565b61363c613b1a565b60008260000151846000015101905083600001518110156136c5576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260158152602001807f616464206f766572666c6f77206465746563746564000000000000000000000081525060200191505060405180910390fd5b60405180602001604052808281525091505092915050565b6000600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663dcf0aaed60405160200180807f476f6c64546f6b656e00000000000000000000000000000000000000000000008152506009019050604051602081830303815290604052805190602001206040518263ffffffff1660e01b81526004018082815260200191505060206040518083038186803b15801561379857600080fd5b505afa1580156137ac573d6000803e3d6000fd5b505050506040513d60208110156137c257600080fd5b8101908080519060200190929190505050905090565b60007601357c299a88ea76a58924d52ce4f26a85af186c2b9e74905090565b60008383111582906138a4576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825283818151815260200191508051906020019080838360005b8381101561386957808201518184015260208101905061384e565b50505050905090810190601f1680156138965780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b5060008385039050809150509392505050565b6138bf613b1a565b604051806020016040528069d3c21bcecceda1000000808560000151816138e257fe5b04028152509050919050565b6138f6613b1a565b604051806020016040528069d3c21bcecceda10000008085600001518161391957fe5b04028460000151038152509050919050565b600064e8d4a51000905090565b600080831182906139e4576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825283818151815260200191508051906020019080838360005b838110156139a957808201518184015260208101905061398e565b50505050905090810190601f1680156139d65780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b5060008385816139f057fe5b049050809150509392505050565b6000600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663dcf0aaed60405160200180807f52657365727665000000000000000000000000000000000000000000000000008152506007019050604051602081830303815290604052805190602001206040518263ffffffff1660e01b81526004018082815260200191505060206040518083038186803b158015613ab957600080fd5b505afa158015613acd573d6000803e3d6000fd5b505050506040513d6020811015613ae357600080fd5b8101908080519060200190929190505050905090565b600069d3c21bcecceda1000000826000015181613b1257fe5b049050919050565b604051806020016040528060008152509056fe4f776e61626c653a206e6577206f776e657220697320746865207a65726f2061646472657373537461626c65546f6b656e206164647265737320616c72656164792061637469766174656443616c63756c6174656420627579416d6f756e7420776173206c657373207468616e20737065636966696564206d696e427579416d6f756e7463616e27742063616c6c207768656e20636f6e74726163742069732066726f7a656e63616e277420637265617465206669786964697479206e756d626572206c6172676572207468616e206d61784e65774669786564282943616c63756c617465642073656c6c416d6f756e74207761732067726561746572207468616e20737065636966696564206d617853656c6c416d6f756e7465786368616e676520726174652064656e6f6d696e61746f72206d7573742062652067726561746572207468616e2030536166654d6174683a206d756c7469706c69636174696f6e206f766572666c6f77537072656164206d757374206265206c657373207468616e206f7220657175616c20746f203172657365727665206672616374696f6e206d75737420626520736d616c6c6572207468616e2031a265627a7a72315820a8f5f5453405979847c53f1568cb7fabd77f32a16f00127e9e87d712aba32bae64736f6c634300050d0032