Address Details
contract

0x7ae2f384fE14EaD85779f9224558862D6d3E4f28

Contract Name
StableToken
Creator
0x56fd3f–9b8d81 at 0x4170a9–a52044
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
2 Transactions
Transfers
0 Transfers
Gas Used
56,037
Last Balance Update
23065563
This contract has been verified via Sourcify. View contract in Sourcify repository
Contract name:
StableToken




Optimization enabled
true
Compiler version
v0.5.17+commit.d19bba13




Optimization runs
10000
EVM Version
istanbul




Verified at
2023-05-25T18:03:02.945601Z

lib/mento-core/contracts/StableToken.sol

// SPDX-License-Identifier: GPL-3.0-or-later
pragma solidity ^0.5.13;

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

import "./interfaces/IStableToken.sol";
import "./interfaces/ICeloToken.sol";
import "./common/interfaces/ICeloVersionedContract.sol";
import "./common/CalledByVm.sol";
import "./common/Initializable.sol";
import "./common/FixidityLib.sol";
import "./common/Freezable.sol";
import "./common/UsingRegistry.sol";
import "./common/UsingPrecompiles.sol";

/**
 * @title An ERC20 compliant token with adjustable supply.
 */
// solhint-disable-next-line max-line-length
contract StableToken is
  ICeloVersionedContract,
  Ownable,
  Initializable,
  UsingRegistry,
  UsingPrecompiles,
  Freezable,
  CalledByVm,
  IStableToken,
  IERC20,
  ICeloToken
{
  using FixidityLib for FixidityLib.Fraction;
  using SafeMath for uint256;

  event InflationFactorUpdated(uint256 factor, uint256 lastUpdated);

  event InflationParametersUpdated(uint256 rate, uint256 updatePeriod, uint256 lastUpdated);

  event Transfer(address indexed from, address indexed to, uint256 value);

  event TransferComment(string comment);

  bytes32 private constant GRANDA_MENTO_REGISTRY_ID = keccak256(abi.encodePacked("GrandaMento"));
  bytes32 private constant BROKER_REGISTRY_ID = keccak256(abi.encodePacked("Broker"));

  string internal name_;
  string internal symbol_;
  uint8 internal decimals_;

  // Stored as units. Value can be found using unitsToValue().
  mapping(address => uint256) internal balances;
  uint256 internal totalSupply_;

  // Stored as values. Units can be found using valueToUnits().
  mapping(address => mapping(address => uint256)) internal allowed;

  // STABILITY FEE PARAMETERS

  // The `rate` is how much the `factor` is adjusted by per `updatePeriod`.
  // The `factor` describes units/value of StableToken, and is greater than or equal to 1.
  // The `updatePeriod` governs how often the `factor` is updated.
  // `factorLastUpdated` indicates when the inflation factor was last updated.
  struct InflationState {
    FixidityLib.Fraction rate;
    FixidityLib.Fraction factor;
    uint256 updatePeriod;
    uint256 factorLastUpdated;
  }

  // solhint-disable-next-line state-visibility
  InflationState inflationState;

  // The registry ID of the exchange contract with permission to mint and burn this token.
  // Unique per StableToken instance.
  // solhint-disable-next-line state-visibility
  bytes32 exchangeRegistryId;

  /**
   * @notice Recomputes and updates inflation factor if more than `updatePeriod`
   * has passed since last update.
   */
  modifier updateInflationFactor() {
    FixidityLib.Fraction memory updatedInflationFactor;
    uint256 lastUpdated;

    (updatedInflationFactor, lastUpdated) = getUpdatedInflationFactor();

    if (lastUpdated != inflationState.factorLastUpdated) {
      inflationState.factor = updatedInflationFactor;
      inflationState.factorLastUpdated = lastUpdated;
      emit InflationFactorUpdated(inflationState.factor.unwrap(), inflationState.factorLastUpdated);
    }
    _;
  }

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

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

  /**
   * @param _name The name of the stable token (English)
   * @param _symbol A short symbol identifying the token (e.g. "cUSD")
   * @param _decimals Tokens are divisible to this many decimal places.
   * @param registryAddress Address of the Registry contract.
   * @param inflationRate Weekly inflation rate.
   * @param inflationFactorUpdatePeriod How often the inflation factor is updated, in seconds.
   * @param initialBalanceAddresses Array of addresses with an initial balance.
   * @param initialBalanceValues Array of balance values corresponding to initialBalanceAddresses.
   * @param exchangeIdentifier String identifier of exchange in registry (for specific fiat pairs)
   */
  function initialize(
    string calldata _name,
    string calldata _symbol,
    uint8 _decimals,
    address registryAddress,
    uint256 inflationRate,
    uint256 inflationFactorUpdatePeriod,
    address[] calldata initialBalanceAddresses,
    uint256[] calldata initialBalanceValues,
    string calldata exchangeIdentifier
  ) external initializer {
    require(inflationRate != 0, "Must provide a non-zero inflation rate");
    require(inflationFactorUpdatePeriod > 0, "inflationFactorUpdatePeriod must be > 0");

    _transferOwnership(msg.sender);

    totalSupply_ = 0;
    name_ = _name;
    symbol_ = _symbol;
    decimals_ = _decimals;

    inflationState.rate = FixidityLib.wrap(inflationRate);
    inflationState.factor = FixidityLib.fixed1();
    inflationState.updatePeriod = inflationFactorUpdatePeriod;
    // solhint-disable-next-line not-rely-on-time
    inflationState.factorLastUpdated = now;

    require(initialBalanceAddresses.length == initialBalanceValues.length, "Array length mismatch");
    for (uint256 i = 0; i < initialBalanceAddresses.length; i = i.add(1)) {
      _mint(initialBalanceAddresses[i], initialBalanceValues[i]);
    }
    setRegistry(registryAddress);
    exchangeRegistryId = keccak256(abi.encodePacked(exchangeIdentifier));
  }

  /**
   * @notice Updates Inflation Parameters.
   * @param rate New rate.
   * @param updatePeriod How often inflationFactor is updated.
   */
  function setInflationParameters(uint256 rate, uint256 updatePeriod) external onlyOwner updateInflationFactor {
    require(rate != 0, "Must provide a non-zero inflation rate.");
    require(updatePeriod > 0, "updatePeriod must be > 0");
    inflationState.rate = FixidityLib.wrap(rate);
    inflationState.updatePeriod = updatePeriod;

    emit InflationParametersUpdated(
      rate,
      updatePeriod,
      // solhint-disable-next-line not-rely-on-time
      now
    );
  }

  /**
   * @notice Increase the allowance of another user.
   * @param spender The address which is being approved to spend StableToken.
   * @param value The increment of the amount of StableToken approved to the spender.
   * @return True if the transaction succeeds.
   */
  function increaseAllowance(address spender, uint256 value) external updateInflationFactor returns (bool) {
    require(spender != address(0), "reserved address 0x0 cannot have allowance");
    uint256 oldValue = allowed[msg.sender][spender];
    uint256 newValue = oldValue.add(value);
    allowed[msg.sender][spender] = newValue;
    emit Approval(msg.sender, spender, newValue);
    return true;
  }

  /**
   * @notice Decrease the allowance of another user.
   * @param spender The address which is being approved to spend StableToken.
   * @param value The decrement of the amount of StableToken approved to the spender.
   * @return True if the transaction succeeds.
   */
  function decreaseAllowance(address spender, uint256 value) external updateInflationFactor returns (bool) {
    uint256 oldValue = allowed[msg.sender][spender];
    uint256 newValue = oldValue.sub(value);
    allowed[msg.sender][spender] = newValue;
    emit Approval(msg.sender, spender, newValue);
    return true;
  }

  /**
   * @notice Approve a user to transfer StableToken on behalf of another user.
   * @param spender The address which is being approved to spend StableToken.
   * @param value The amount of StableToken approved to the spender.
   * @return True if the transaction succeeds.
   */
  function approve(address spender, uint256 value) external updateInflationFactor returns (bool) {
    require(spender != address(0), "reserved address 0x0 cannot have allowance");
    allowed[msg.sender][spender] = value;
    emit Approval(msg.sender, spender, value);
    return true;
  }

  /**
   * @notice Mints new StableToken and gives it to 'to'.
   * @param to The account for which to mint tokens.
   * @param value The amount of StableToken to mint.
   */
  function mint(address to, uint256 value) external updateInflationFactor returns (bool) {
    require(
      msg.sender == registry.getAddressFor(BROKER_REGISTRY_ID) ||
        msg.sender == registry.getAddressFor(getExchangeRegistryId()) ||
        msg.sender == registry.getAddressFor(VALIDATORS_REGISTRY_ID) ||
        msg.sender == registry.getAddressFor(GRANDA_MENTO_REGISTRY_ID),
      "Sender not authorized to mint"
    );
    return _mint(to, value);
  }

  /**
   * @notice Mints new StableToken and gives it to 'to'.
   * @param to The account for which to mint tokens.
   * @param value The amount of StableToken to mint.
   */
  function _mint(address to, uint256 value) private returns (bool) {
    require(to != address(0), "0 is a reserved address");
    if (value == 0) {
      return true;
    }

    uint256 units = _valueToUnits(inflationState.factor, value);
    totalSupply_ = totalSupply_.add(units);
    balances[to] = balances[to].add(units);
    emit Transfer(address(0), to, value);
    return true;
  }

  /**
   * @notice Transfer token for a specified address
   * @param to The address to transfer to.
   * @param value The amount to be transferred.
   * @param comment The transfer comment.
   * @return True if the transaction succeeds.
   */
  function transferWithComment(
    address to,
    uint256 value,
    string calldata comment
  ) external updateInflationFactor onlyWhenNotFrozen returns (bool) {
    bool succeeded = transfer(to, value);
    emit TransferComment(comment);
    return succeeded;
  }

  /**
   * @notice Burns StableToken from the balance of msg.sender.
   * @param value The amount of StableToken to burn.
   */
  function burn(uint256 value) external updateInflationFactor returns (bool) {
    require(
      msg.sender == registry.getAddressFor(BROKER_REGISTRY_ID) ||
        msg.sender == registry.getAddressFor(getExchangeRegistryId()) ||
        msg.sender == registry.getAddressFor(GRANDA_MENTO_REGISTRY_ID),
      "Sender not authorized to burn"
    );
    uint256 units = _valueToUnits(inflationState.factor, value);
    require(units <= balances[msg.sender], "value exceeded balance of sender");
    totalSupply_ = totalSupply_.sub(units);
    balances[msg.sender] = balances[msg.sender].sub(units);
    emit Transfer(msg.sender, address(0), units);
    return true;
  }

  /**
   * @notice Transfers StableToken from one address to another on behalf of a user.
   * @param from The address to transfer StableToken from.
   * @param to The address to transfer StableToken to.
   * @param value The amount of StableToken to transfer.
   * @return True if the transaction succeeds.
   */
  function transferFrom(
    address from,
    address to,
    uint256 value
  ) external updateInflationFactor onlyWhenNotFrozen returns (bool) {
    uint256 units = _valueToUnits(inflationState.factor, value);
    require(to != address(0), "transfer attempted to reserved address 0x0");
    require(units <= balances[from], "transfer value exceeded balance of sender");
    require(value <= allowed[from][msg.sender], "transfer value exceeded sender's allowance for recipient");

    balances[to] = balances[to].add(units);
    balances[from] = balances[from].sub(units);
    allowed[from][msg.sender] = allowed[from][msg.sender].sub(value);
    emit Transfer(from, to, value);
    return true;
  }

  /**
   * @return The name of the stable token.
   */
  function name() external view returns (string memory) {
    return name_;
  }

  /**
   * @return The symbol of the stable token.
   */
  function symbol() external view returns (string memory) {
    return symbol_;
  }

  /**
   * @return The number of decimal places to which StableToken is divisible.
   */
  function decimals() external view returns (uint8) {
    return decimals_;
  }

  /**
   * @notice Gets the amount of owner's StableToken allowed to be spent by spender.
   * @param accountOwner The owner of the StableToken.
   * @param spender The spender of the StableToken.
   * @return The amount of StableToken owner is allowing spender to spend.
   */
  function allowance(address accountOwner, address spender) external view returns (uint256) {
    return allowed[accountOwner][spender];
  }

  /**
   * @notice Gets the balance of the specified address using the presently stored inflation factor.
   * @param accountOwner The address to query the balance of.
   * @return The balance of the specified address.
   */
  function balanceOf(address accountOwner) external view returns (uint256) {
    return unitsToValue(balances[accountOwner]);
  }

  /**
   * @return The total value of StableToken in existence
   * @dev Though totalSupply_ is stored in units, this returns value.
   */
  function totalSupply() external view returns (uint256) {
    return unitsToValue(totalSupply_);
  }

  /**
   * @notice gets inflation parameters.
   * @return rate
   * @return factor
   * @return updatePeriod
   * @return factorLastUpdated
   */
  function getInflationParameters()
    external
    view
    returns (
      uint256,
      uint256,
      uint256,
      uint256
    )
  {
    return (
      inflationState.rate.unwrap(),
      inflationState.factor.unwrap(),
      inflationState.updatePeriod,
      inflationState.factorLastUpdated
    );
  }

  /**
   * @notice Returns the units for a given value given the current inflation factor.
   * @param value The value to convert to units.
   * @return The units corresponding to `value` given the current inflation factor.
   * @dev We don't compute the updated inflationFactor here because
   * we assume any function calling this will have updated the inflation factor.
   */
  function valueToUnits(uint256 value) external view returns (uint256) {
    FixidityLib.Fraction memory updatedInflationFactor;

    (updatedInflationFactor, ) = getUpdatedInflationFactor();
    return _valueToUnits(updatedInflationFactor, value);
  }

  /**
   * @notice Returns the exchange id in the registry of the corresponding fiat pair exchange.
   * @dev When this storage is uninitialized, it falls back to the default EXCHANGE_REGISTRY_ID.
   * exchangeRegistryId was introduced after the initial release of cUSD's StableToken,
   * so exchangeRegistryId will be uninitialized for that contract. If cUSD's StableToken
   * exchangeRegistryId were to be correctly initialized, this function could be deprecated
   * in favor of using exchangeRegistryId directly.
   * @return Registry id for the corresponding exchange.
   */
  function getExchangeRegistryId() public view returns (bytes32) {
    if (exchangeRegistryId == bytes32(0)) {
      return EXCHANGE_REGISTRY_ID;
    } else {
      return exchangeRegistryId;
    }
  }

  /**
   * @notice Returns the value of a given number of units given the current inflation factor.
   * @param units The units to convert to value.
   * @return The value corresponding to `units` given the current inflation factor.
   */
  function unitsToValue(uint256 units) public view returns (uint256) {
    FixidityLib.Fraction memory updatedInflationFactor;

    (updatedInflationFactor, ) = getUpdatedInflationFactor();

    // We're ok using FixidityLib.divide here because updatedInflationFactor is
    // not going to surpass maxFixedDivisor any time soon.
    // Quick upper-bound estimation: if annual inflation were 5% (an order of
    // magnitude more than the initial proposal of 0.5%), in 500 years, the
    // inflation factor would be on the order of 10**10, which is still a safe
    // divisor.
    return FixidityLib.newFixed(units).divide(updatedInflationFactor).fromFixed();
  }

  /**
   * @notice Returns the units for a given value given the current inflation factor.
   * @param inflationFactor The current inflation factor.
   * @param value The value to convert to units.
   * @return The units corresponding to `value` given the current inflation factor.
   * @dev We assume any function calling this will have updated the inflation factor.
   */
  function _valueToUnits(FixidityLib.Fraction memory inflationFactor, uint256 value) private pure returns (uint256) {
    return inflationFactor.multiply(FixidityLib.newFixed(value)).fromFixed();
  }

  /**
   * @notice Computes the up-to-date inflation factor.
   * @return Current inflation factor.
   * @return Last time when the returned inflation factor was updated.
   */
  function getUpdatedInflationFactor() private view returns (FixidityLib.Fraction memory, uint256) {
    /* solhint-disable not-rely-on-time */
    if (now < inflationState.factorLastUpdated.add(inflationState.updatePeriod)) {
      return (inflationState.factor, inflationState.factorLastUpdated);
    }

    uint256 numerator;
    uint256 denominator;

    // TODO: handle retroactive updates given decreases to updatePeriod
    uint256 timesToApplyInflation = now.sub(inflationState.factorLastUpdated).div(inflationState.updatePeriod);

    (numerator, denominator) = fractionMulExp(
      inflationState.factor.unwrap(),
      FixidityLib.fixed1().unwrap(),
      inflationState.rate.unwrap(),
      FixidityLib.fixed1().unwrap(),
      timesToApplyInflation,
      decimals_
    );

    // This should never happen. If something went wrong updating the
    // inflation factor, keep the previous factor
    if (numerator == 0 || denominator == 0) {
      return (inflationState.factor, inflationState.factorLastUpdated);
    }

    FixidityLib.Fraction memory currentInflationFactor = FixidityLib.wrap(numerator).divide(
      FixidityLib.wrap(denominator)
    );
    uint256 lastUpdated = inflationState.factorLastUpdated.add(
      inflationState.updatePeriod.mul(now.sub(inflationState.factorLastUpdated)).div(inflationState.updatePeriod)
    );
    return (currentInflationFactor, lastUpdated);
    /* solhint-enable not-rely-on-time */
  }

  /**
   * @notice Transfers `value` from `msg.sender` to `to`
   * @param to The address to transfer to.
   * @param value The amount to be transferred.
   */
  // solhint-disable-next-line no-simple-event-func-name
  function transfer(address to, uint256 value) public updateInflationFactor onlyWhenNotFrozen returns (bool) {
    return _transfer(to, value);
  }

  /**
   * @notice Transfers StableToken from one address to another
   * @param to The address to transfer StableToken to.
   * @param value The amount of StableToken to be transferred.
   */
  function _transfer(address to, uint256 value) internal returns (bool) {
    require(to != address(0), "transfer attempted to reserved address 0x0");
    uint256 units = _valueToUnits(inflationState.factor, value);
    require(balances[msg.sender] >= units, "transfer value exceeded balance of sender");
    balances[msg.sender] = balances[msg.sender].sub(units);
    balances[to] = balances[to].add(units);
    emit Transfer(msg.sender, to, value);
    return true;
  }

  /**
   * @notice Reserve balance for making payments for gas in this StableToken currency.
   * @param from The account to reserve balance from
   * @param value The amount of balance to reserve
   * @dev Note that this function is called by the protocol when paying for tx fees in this
   * currency. After the tx is executed, gas is refunded to the sender and credited to the
   * various tx fee recipients via a call to `creditGasFees`. Note too that the events emitted
   * by `creditGasFees` reflect the *net* gas fee payments for the transaction.
   */
  function debitGasFees(address from, uint256 value) external onlyVm onlyWhenNotFrozen updateInflationFactor {
    uint256 units = _valueToUnits(inflationState.factor, value);
    balances[from] = balances[from].sub(units);
    totalSupply_ = totalSupply_.sub(units);
  }

  /**
   * @notice Alternative function to credit balance after making payments
   * for gas in this StableToken currency.
   * @param from The account to debit balance from
   * @param feeRecipient Coinbase address
   * @param gatewayFeeRecipient Gateway address
   * @param communityFund Community fund address
   * @param tipTxFee Coinbase fee
   * @param baseTxFee Community fund fee
   * @param gatewayFee Gateway fee
   * @dev Note that this function is called by the protocol when paying for tx fees in this
   * currency. Before the tx is executed, gas is debited from the sender via a call to
   * `debitGasFees`. Note too that the events emitted by `creditGasFees` reflect the *net* gas fee
   * payments for the transaction.
   */
  function creditGasFees(
    address from,
    address feeRecipient,
    address gatewayFeeRecipient,
    address communityFund,
    uint256 refund,
    uint256 tipTxFee,
    uint256 gatewayFee,
    uint256 baseTxFee
  ) external onlyVm onlyWhenNotFrozen {
    uint256 units = _valueToUnits(inflationState.factor, refund);
    balances[from] = balances[from].add(units);

    units = units.add(_creditGas(from, communityFund, baseTxFee));
    units = units.add(_creditGas(from, feeRecipient, tipTxFee));
    units = units.add(_creditGas(from, gatewayFeeRecipient, gatewayFee));
    totalSupply_ = totalSupply_.add(units);
  }

  function _creditGas(
    address from,
    address to,
    uint256 value
  ) internal returns (uint256) {
    if (to == address(0)) {
      return 0;
    }
    uint256 units = _valueToUnits(inflationState.factor, value);
    balances[to] = balances[to].add(units);
    emit Transfer(from, to, value);
    return units;
  }
}
        

/lib/mento-core/contracts/common/CalledByVm.sol

// SPDX-License-Identifier: GPL-3.0-or-later
pragma solidity ^0.5.13;

contract CalledByVm {
  modifier onlyVm() {
    require(msg.sender == address(0), "Only VM can call");
    _;
  }
}
          

/lib/mento-core/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
   */
  // solhint-disable-next-line code-complexity
  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
    // solhint-disable-next-line var-name-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");
    // solhint-disable-next-line var-name-mixedcase
    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());
  }
}
          

/lib/mento-core/contracts/common/Freezable.sol

// SPDX-License-Identifier: GPL-3.0-or-later
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");
    _;
  }
}
          

/lib/mento-core/contracts/common/Initializable.sol

// SPDX-License-Identifier: GPL-3.0-or-later
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;
    _;
  }
}
          

/lib/mento-core/contracts/common/UsingPrecompiles.sol

// SPDX-License-Identifier: GPL-3.0-or-later
// solhint-disable state-visibility
pragma solidity ^0.5.13;

import "openzeppelin-solidity/contracts/math/SafeMath.sol";
import "./interfaces/ICeloVersionedContract.sol";

contract UsingPrecompiles {
  using SafeMath for uint256;

  address constant TRANSFER = address(0xff - 2);
  address constant FRACTION_MUL = address(0xff - 3);
  address constant PROOF_OF_POSSESSION = address(0xff - 4);
  address constant GET_VALIDATOR = address(0xff - 5);
  address constant NUMBER_VALIDATORS = address(0xff - 6);
  address constant EPOCH_SIZE = address(0xff - 7);
  address constant BLOCK_NUMBER_FROM_HEADER = address(0xff - 8);
  address constant HASH_HEADER = address(0xff - 9);
  address constant GET_PARENT_SEAL_BITMAP = address(0xff - 10);
  address constant GET_VERIFIED_SEAL_BITMAP = address(0xff - 11);

  /**
   * @notice calculate a * b^x for fractions a, b to `decimals` precision
   * @param aNumerator Numerator of first fraction
   * @param aDenominator Denominator of first fraction
   * @param bNumerator Numerator of exponentiated fraction
   * @param bDenominator Denominator of exponentiated fraction
   * @param exponent exponent to raise b to
   * @param _decimals precision
   * @return Numerator of the computed quantity (not reduced).
   * @return Denominator of the computed quantity (not reduced).
   */
  function fractionMulExp(
    uint256 aNumerator,
    uint256 aDenominator,
    uint256 bNumerator,
    uint256 bDenominator,
    uint256 exponent,
    uint256 _decimals
  ) public view returns (uint256, uint256) {
    require(aDenominator != 0 && bDenominator != 0, "a denominator is zero");
    uint256 returnNumerator;
    uint256 returnDenominator;
    bool success;
    bytes memory out;
    (success, out) = FRACTION_MUL.staticcall(
      abi.encodePacked(aNumerator, aDenominator, bNumerator, bDenominator, exponent, _decimals)
    );
    require(success, "error calling fractionMulExp precompile");
    returnNumerator = getUint256FromBytes(out, 0);
    returnDenominator = getUint256FromBytes(out, 32);
    return (returnNumerator, returnDenominator);
  }

  /**
   * @notice Returns the current epoch size in blocks.
   * @return The current epoch size in blocks.
   */
  function getEpochSize() public view returns (uint256) {
    bytes memory out;
    bool success;
    (success, out) = EPOCH_SIZE.staticcall(abi.encodePacked());
    require(success, "error calling getEpochSize precompile");
    return getUint256FromBytes(out, 0);
  }

  /**
   * @notice Returns the epoch number at a block.
   * @param blockNumber Block number where epoch number is calculated.
   * @return Epoch number.
   */
  function getEpochNumberOfBlock(uint256 blockNumber) public view returns (uint256) {
    return epochNumberOfBlock(blockNumber, getEpochSize());
  }

  /**
   * @notice Returns the epoch number at a block.
   * @return Current epoch number.
   */
  function getEpochNumber() public view returns (uint256) {
    return getEpochNumberOfBlock(block.number);
  }

  /**
   * @notice Returns the epoch number at a block.
   * @param blockNumber Block number where epoch number is calculated.
   * @param epochSize The epoch size in blocks.
   * @return Epoch number.
   */
  function epochNumberOfBlock(uint256 blockNumber, uint256 epochSize) internal pure returns (uint256) {
    // Follows GetEpochNumber from celo-blockchain/blob/master/consensus/istanbul/utils.go
    uint256 epochNumber = blockNumber / epochSize;
    if (blockNumber % epochSize == 0) {
      return epochNumber;
    } else {
      return epochNumber.add(1);
    }
  }

  /**
   * @notice Gets a validator address from the current validator set.
   * @param index Index of requested validator in the validator set.
   * @return Address of validator at the requested index.
   */
  function validatorSignerAddressFromCurrentSet(uint256 index) public view returns (address) {
    bytes memory out;
    bool success;
    (success, out) = GET_VALIDATOR.staticcall(abi.encodePacked(index, uint256(block.number)));
    require(success, "error calling validatorSignerAddressFromCurrentSet precompile");
    return address(getUint256FromBytes(out, 0));
  }

  /**
   * @notice Gets a validator address from the validator set at the given block number.
   * @param index Index of requested validator in the validator set.
   * @param blockNumber Block number to retrieve the validator set from.
   * @return Address of validator at the requested index.
   */
  function validatorSignerAddressFromSet(uint256 index, uint256 blockNumber) public view returns (address) {
    bytes memory out;
    bool success;
    (success, out) = GET_VALIDATOR.staticcall(abi.encodePacked(index, blockNumber));
    require(success, "error calling validatorSignerAddressFromSet precompile");
    return address(getUint256FromBytes(out, 0));
  }

  /**
   * @notice Gets the size of the current elected validator set.
   * @return Size of the current elected validator set.
   */
  function numberValidatorsInCurrentSet() public view returns (uint256) {
    bytes memory out;
    bool success;
    (success, out) = NUMBER_VALIDATORS.staticcall(abi.encodePacked(uint256(block.number)));
    require(success, "error calling numberValidatorsInCurrentSet precompile");
    return getUint256FromBytes(out, 0);
  }

  /**
   * @notice Gets the size of the validator set that must sign the given block number.
   * @param blockNumber Block number to retrieve the validator set from.
   * @return Size of the validator set.
   */
  function numberValidatorsInSet(uint256 blockNumber) public view returns (uint256) {
    bytes memory out;
    bool success;
    (success, out) = NUMBER_VALIDATORS.staticcall(abi.encodePacked(blockNumber));
    require(success, "error calling numberValidatorsInSet precompile");
    return getUint256FromBytes(out, 0);
  }

  /**
   * @notice Checks a BLS proof of possession.
   * @param sender The address signed by the BLS key to generate the proof of possession.
   * @param blsKey The BLS public key that the validator is using for consensus, should pass proof
   *   of possession. 48 bytes.
   * @param blsPop The BLS public key proof-of-possession, which consists of a signature on the
   *   account address. 96 bytes.
   * @return True upon success.
   */
  function checkProofOfPossession(
    address sender,
    bytes memory blsKey,
    bytes memory blsPop
  ) public view returns (bool) {
    bool success;
    (success, ) = PROOF_OF_POSSESSION.staticcall(abi.encodePacked(sender, blsKey, blsPop));
    return success;
  }

  /**
   * @notice Parses block number out of header.
   * @param header RLP encoded header
   * @return Block number.
   */
  function getBlockNumberFromHeader(bytes memory header) public view returns (uint256) {
    bytes memory out;
    bool success;
    (success, out) = BLOCK_NUMBER_FROM_HEADER.staticcall(abi.encodePacked(header));
    require(success, "error calling getBlockNumberFromHeader precompile");
    return getUint256FromBytes(out, 0);
  }

  /**
   * @notice Computes hash of header.
   * @param header RLP encoded header
   * @return Header hash.
   */
  function hashHeader(bytes memory header) public view returns (bytes32) {
    bytes memory out;
    bool success;
    (success, out) = HASH_HEADER.staticcall(abi.encodePacked(header));
    require(success, "error calling hashHeader precompile");
    return getBytes32FromBytes(out, 0);
  }

  /**
   * @notice Gets the parent seal bitmap from the header at the given block number.
   * @param blockNumber Block number to retrieve. Must be within 4 epochs of the current number.
   * @return Bitmap parent seal with set bits at indices corresponding to signing validators.
   */
  function getParentSealBitmap(uint256 blockNumber) public view returns (bytes32) {
    bytes memory out;
    bool success;
    (success, out) = GET_PARENT_SEAL_BITMAP.staticcall(abi.encodePacked(blockNumber));
    require(success, "error calling getParentSealBitmap precompile");
    return getBytes32FromBytes(out, 0);
  }

  /**
   * @notice Verifies the BLS signature on the header and returns the seal bitmap.
   * The validator set used for verification is retrieved based on the parent hash field of the
   * header.  If the parent hash is not in the blockchain, verification fails.
   * @param header RLP encoded header
   * @return Bitmap parent seal with set bits at indices correspoinding to signing validators.
   */
  function getVerifiedSealBitmapFromHeader(bytes memory header) public view returns (bytes32) {
    bytes memory out;
    bool success;
    (success, out) = GET_VERIFIED_SEAL_BITMAP.staticcall(abi.encodePacked(header));
    require(success, "error calling getVerifiedSealBitmapFromHeader precompile");
    return getBytes32FromBytes(out, 0);
  }

  /**
   * @notice Converts bytes to uint256.
   * @param bs byte[] data
   * @param start offset into byte data to convert
   * @return uint256 data
   */
  function getUint256FromBytes(bytes memory bs, uint256 start) internal pure returns (uint256) {
    return uint256(getBytes32FromBytes(bs, start));
  }

  /**
   * @notice Converts bytes to bytes32.
   * @param bs byte[] data
   * @param start offset into byte data to convert
   * @return bytes32 data
   */
  function getBytes32FromBytes(bytes memory bs, uint256 start) internal pure returns (bytes32) {
    require(bs.length >= start.add(32), "slicing out of range");
    bytes32 x;
    // solhint-disable-next-line no-inline-assembly
    assembly {
      x := mload(add(bs, add(start, 32)))
    }
    return x;
  }

  /**
   * @notice Returns the minimum number of required signers for a given block number.
   * @dev Computed in celo-blockchain as int(math.Ceil(float64(2*valSet.Size()) / 3))
   */
  function minQuorumSize(uint256 blockNumber) public view returns (uint256) {
    return numberValidatorsInSet(blockNumber).mul(2).add(2).div(3);
  }

  /**
   * @notice Computes byzantine quorum from current validator set size
   * @return Byzantine quorum of validators.
   */
  function minQuorumSizeInCurrentSet() public view returns (uint256) {
    return minQuorumSize(block.number);
  }
}
          

/lib/mento-core/contracts/common/UsingRegistry.sol

// SPDX-License-Identifier: GPL-3.0-or-later
pragma solidity ^0.5.13;

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

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

import "../interfaces/IExchange.sol";
import "../interfaces/IReserve.sol";
import "../interfaces/ISortedOracles.sol";
import "../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 getExchange() internal view returns (IExchange) {
    return IExchange(registry.getAddressForOrDie(EXCHANGE_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 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));
  }
}
          

/lib/mento-core/contracts/common/interfaces/ICeloVersionedContract.sol

// SPDX-License-Identifier: GPL-3.0-or-later
pragma solidity ^0.5.13;

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

/lib/mento-core/contracts/common/interfaces/IFreezer.sol

// SPDX-License-Identifier: GPL-3.0-or-later
pragma solidity ^0.5.13;

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

/lib/mento-core/contracts/common/interfaces/IRegistry.sol

// SPDX-License-Identifier: GPL-3.0-or-later
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);
}
          

/lib/mento-core/contracts/common/linkedlists/LinkedList.sol

// SPDX-License-Identifier: GPL-3.0-or-later
pragma solidity ^0.5.13;

import "openzeppelin-solidity/contracts/math/SafeMath.sol";

/**
 * @title Maintains a doubly linked list keyed by bytes32.
 * @dev Following the `next` pointers will lead you to the head, rather than the tail.
 */
library LinkedList {
  using SafeMath for uint256;

  struct Element {
    bytes32 previousKey;
    bytes32 nextKey;
    bool exists;
  }

  struct List {
    bytes32 head;
    bytes32 tail;
    uint256 numElements;
    mapping(bytes32 => Element) elements;
  }

  /**
   * @notice Inserts an element into a doubly linked list.
   * @param list A storage pointer to the underlying list.
   * @param key The key of the element to insert.
   * @param previousKey The key of the element that comes before the element to insert.
   * @param nextKey The key of the element that comes after the element to insert.
   */
  function insert(
    List storage list,
    bytes32 key,
    bytes32 previousKey,
    bytes32 nextKey
  ) internal {
    require(key != bytes32(0), "Key must be defined");
    require(!contains(list, key), "Can't insert an existing element");
    require(previousKey != key && nextKey != key, "Key cannot be the same as previousKey or nextKey");

    Element storage element = list.elements[key];
    element.exists = true;

    if (list.numElements == 0) {
      list.tail = key;
      list.head = key;
    } else {
      require(previousKey != bytes32(0) || nextKey != bytes32(0), "Either previousKey or nextKey must be defined");

      element.previousKey = previousKey;
      element.nextKey = nextKey;

      if (previousKey != bytes32(0)) {
        require(contains(list, previousKey), "If previousKey is defined, it must exist in the list");
        Element storage previousElement = list.elements[previousKey];
        require(previousElement.nextKey == nextKey, "previousKey must be adjacent to nextKey");
        previousElement.nextKey = key;
      } else {
        list.tail = key;
      }

      if (nextKey != bytes32(0)) {
        require(contains(list, nextKey), "If nextKey is defined, it must exist in the list");
        Element storage nextElement = list.elements[nextKey];
        require(nextElement.previousKey == previousKey, "previousKey must be adjacent to nextKey");
        nextElement.previousKey = key;
      } else {
        list.head = key;
      }
    }

    list.numElements = list.numElements.add(1);
  }

  /**
   * @notice Inserts an element at the tail of the doubly linked list.
   * @param list A storage pointer to the underlying list.
   * @param key The key of the element to insert.
   */
  function push(List storage list, bytes32 key) internal {
    insert(list, key, bytes32(0), list.tail);
  }

  /**
   * @notice Removes an element from the doubly linked list.
   * @param list A storage pointer to the underlying list.
   * @param key The key of the element to remove.
   */
  function remove(List storage list, bytes32 key) internal {
    Element storage element = list.elements[key];
    require(key != bytes32(0) && contains(list, key), "key not in list");
    if (element.previousKey != bytes32(0)) {
      Element storage previousElement = list.elements[element.previousKey];
      previousElement.nextKey = element.nextKey;
    } else {
      list.tail = element.nextKey;
    }

    if (element.nextKey != bytes32(0)) {
      Element storage nextElement = list.elements[element.nextKey];
      nextElement.previousKey = element.previousKey;
    } else {
      list.head = element.previousKey;
    }

    delete list.elements[key];
    list.numElements = list.numElements.sub(1);
  }

  /**
   * @notice Updates an element in the list.
   * @param list A storage pointer to the underlying list.
   * @param key The element key.
   * @param previousKey The key of the element that comes before the updated element.
   * @param nextKey The key of the element that comes after the updated element.
   */
  function update(
    List storage list,
    bytes32 key,
    bytes32 previousKey,
    bytes32 nextKey
  ) internal {
    require(key != bytes32(0) && key != previousKey && key != nextKey && contains(list, key), "key on in list");
    remove(list, key);
    insert(list, key, previousKey, nextKey);
  }

  /**
   * @notice Returns whether or not a particular key is present in the sorted list.
   * @param list A storage pointer to the underlying list.
   * @param key The element key.
   * @return Whether or not the key is in the sorted list.
   */
  function contains(List storage list, bytes32 key) internal view returns (bool) {
    return list.elements[key].exists;
  }

  /**
   * @notice Returns the keys of the N elements at the head of the list.
   * @param list A storage pointer to the underlying list.
   * @param n The number of elements to return.
   * @return The keys of the N elements at the head of the list.
   * @dev Reverts if n is greater than the number of elements in the list.
   */
  function headN(List storage list, uint256 n) internal view returns (bytes32[] memory) {
    require(n <= list.numElements, "not enough elements");
    bytes32[] memory keys = new bytes32[](n);
    bytes32 key = list.head;
    for (uint256 i = 0; i < n; i = i.add(1)) {
      keys[i] = key;
      key = list.elements[key].previousKey;
    }
    return keys;
  }

  /**
   * @notice Gets all element keys from the doubly linked list.
   * @param list A storage pointer to the underlying list.
   * @return All element keys from head to tail.
   */
  function getKeys(List storage list) internal view returns (bytes32[] memory) {
    return headN(list, list.numElements);
  }
}
          

/lib/mento-core/contracts/common/linkedlists/SortedLinkedList.sol

// SPDX-License-Identifier: GPL-3.0-or-later
pragma solidity ^0.5.13;

import "openzeppelin-solidity/contracts/math/SafeMath.sol";
import "./LinkedList.sol";

/**
 * @title Maintains a sorted list of unsigned ints keyed by bytes32.
 */
library SortedLinkedList {
  using SafeMath for uint256;
  using LinkedList for LinkedList.List;

  struct List {
    LinkedList.List list;
    mapping(bytes32 => uint256) values;
  }

  /**
   * @notice Inserts an element into a doubly linked list.
   * @param list A storage pointer to the underlying list.
   * @param key The key of the element to insert.
   * @param value The element value.
   * @param lesserKey The key of the element less than the element to insert.
   * @param greaterKey The key of the element greater than the element to insert.
   */
  function insert(
    List storage list,
    bytes32 key,
    uint256 value,
    bytes32 lesserKey,
    bytes32 greaterKey
  ) internal {
    require(key != bytes32(0) && key != lesserKey && key != greaterKey && !contains(list, key), "invalid key");
    require(
      (lesserKey != bytes32(0) || greaterKey != bytes32(0)) || list.list.numElements == 0,
      "greater and lesser key zero"
    );
    require(contains(list, lesserKey) || lesserKey == bytes32(0), "invalid lesser key");
    require(contains(list, greaterKey) || greaterKey == bytes32(0), "invalid greater key");
    (lesserKey, greaterKey) = getLesserAndGreater(list, value, lesserKey, greaterKey);
    list.list.insert(key, lesserKey, greaterKey);
    list.values[key] = value;
  }

  /**
   * @notice Removes an element from the doubly linked list.
   * @param list A storage pointer to the underlying list.
   * @param key The key of the element to remove.
   */
  function remove(List storage list, bytes32 key) internal {
    list.list.remove(key);
    list.values[key] = 0;
  }

  /**
   * @notice Updates an element in the list.
   * @param list A storage pointer to the underlying list.
   * @param key The element key.
   * @param value The element value.
   * @param lesserKey The key of the element will be just left of `key` after the update.
   * @param greaterKey The key of the element will be just right of `key` after the update.
   * @dev Note that only one of "lesserKey" or "greaterKey" needs to be correct to reduce friction.
   */
  function update(
    List storage list,
    bytes32 key,
    uint256 value,
    bytes32 lesserKey,
    bytes32 greaterKey
  ) internal {
    remove(list, key);
    insert(list, key, value, lesserKey, greaterKey);
  }

  /**
   * @notice Inserts an element at the tail of the doubly linked list.
   * @param list A storage pointer to the underlying list.
   * @param key The key of the element to insert.
   */
  function push(List storage list, bytes32 key) internal {
    insert(list, key, 0, bytes32(0), list.list.tail);
  }

  /**
   * @notice Removes N elements from the head of the list and returns their keys.
   * @param list A storage pointer to the underlying list.
   * @param n The number of elements to pop.
   * @return The keys of the popped elements.
   */
  function popN(List storage list, uint256 n) internal returns (bytes32[] memory) {
    require(n <= list.list.numElements, "not enough elements");
    bytes32[] memory keys = new bytes32[](n);
    for (uint256 i = 0; i < n; i = i.add(1)) {
      bytes32 key = list.list.head;
      keys[i] = key;
      remove(list, key);
    }
    return keys;
  }

  /**
   * @notice Returns whether or not a particular key is present in the sorted list.
   * @param list A storage pointer to the underlying list.
   * @param key The element key.
   * @return Whether or not the key is in the sorted list.
   */
  function contains(List storage list, bytes32 key) internal view returns (bool) {
    return list.list.contains(key);
  }

  /**
   * @notice Returns the value for a particular key in the sorted list.
   * @param list A storage pointer to the underlying list.
   * @param key The element key.
   * @return The element value.
   */
  function getValue(List storage list, bytes32 key) internal view returns (uint256) {
    return list.values[key];
  }

  /**
   * @notice Gets all elements from the doubly linked list.
   * @param list A storage pointer to the underlying list.
   * @return Array of all keys in the list.
   * @return Values corresponding to keys, which will be ordered largest to smallest.
   */
  function getElements(List storage list) internal view returns (bytes32[] memory, uint256[] memory) {
    bytes32[] memory keys = getKeys(list);
    uint256[] memory values = new uint256[](keys.length);
    for (uint256 i = 0; i < keys.length; i = i.add(1)) {
      values[i] = list.values[keys[i]];
    }
    return (keys, values);
  }

  /**
   * @notice Gets all element keys from the doubly linked list.
   * @param list A storage pointer to the underlying list.
   * @return All element keys from head to tail.
   */
  function getKeys(List storage list) internal view returns (bytes32[] memory) {
    return list.list.getKeys();
  }

  /**
   * @notice Returns first N greatest elements of the list.
   * @param list A storage pointer to the underlying list.
   * @param n The number of elements to return.
   * @return The keys of the first n elements.
   * @dev Reverts if n is greater than the number of elements in the list.
   */
  function headN(List storage list, uint256 n) internal view returns (bytes32[] memory) {
    return list.list.headN(n);
  }

  /**
   * @notice Returns the keys of the elements greaterKey than and less than the provided value.
   * @param list A storage pointer to the underlying list.
   * @param value The element value.
   * @param lesserKey The key of the element which could be just left of the new value.
   * @param greaterKey The key of the element which could be just right of the new value.
   * @return The correct lesserKey keys.
   * @return The correct greaterKey keys.
   */
  function getLesserAndGreater(
    List storage list,
    uint256 value,
    bytes32 lesserKey,
    bytes32 greaterKey
  ) private view returns (bytes32, bytes32) {
    // Check for one of the following conditions and fail if none are met:
    //   1. The value is less than the current lowest value
    //   2. The value is greater than the current greatest value
    //   3. The value is just greater than the value for `lesserKey`
    //   4. The value is just less than the value for `greaterKey`
    if (lesserKey == bytes32(0) && isValueBetween(list, value, lesserKey, list.list.tail)) {
      return (lesserKey, list.list.tail);
    } else if (greaterKey == bytes32(0) && isValueBetween(list, value, list.list.head, greaterKey)) {
      return (list.list.head, greaterKey);
    } else if (
      lesserKey != bytes32(0) && isValueBetween(list, value, lesserKey, list.list.elements[lesserKey].nextKey)
    ) {
      return (lesserKey, list.list.elements[lesserKey].nextKey);
    } else if (
      greaterKey != bytes32(0) && isValueBetween(list, value, list.list.elements[greaterKey].previousKey, greaterKey)
    ) {
      return (list.list.elements[greaterKey].previousKey, greaterKey);
    } else {
      require(false, "get lesser and greater failure");
    }
  }

  /**
   * @notice Returns whether or not a given element is between two other elements.
   * @param list A storage pointer to the underlying list.
   * @param value The element value.
   * @param lesserKey The key of the element whose value should be lesserKey.
   * @param greaterKey The key of the element whose value should be greaterKey.
   * @return True if the given element is between the two other elements.
   */
  function isValueBetween(
    List storage list,
    uint256 value,
    bytes32 lesserKey,
    bytes32 greaterKey
  ) private view returns (bool) {
    bool isLesser = lesserKey == bytes32(0) || list.values[lesserKey] <= value;
    bool isGreater = greaterKey == bytes32(0) || list.values[greaterKey] >= value;
    return isLesser && isGreater;
  }
}
          

/lib/mento-core/contracts/common/linkedlists/SortedLinkedListWithMedian.sol

// SPDX-License-Identifier: GPL-3.0-or-later
pragma solidity ^0.5.13;

import "openzeppelin-solidity/contracts/math/SafeMath.sol";
import "./LinkedList.sol";
import "./SortedLinkedList.sol";

/**
 * @title Maintains a sorted list of unsigned ints keyed by bytes32.
 */
library SortedLinkedListWithMedian {
  using SafeMath for uint256;
  using SortedLinkedList for SortedLinkedList.List;

  enum MedianAction {
    None,
    Lesser,
    Greater
  }

  enum MedianRelation {
    Undefined,
    Lesser,
    Greater,
    Equal
  }

  struct List {
    SortedLinkedList.List list;
    bytes32 median;
    mapping(bytes32 => MedianRelation) relation;
  }

  /**
   * @notice Inserts an element into a doubly linked list.
   * @param list A storage pointer to the underlying list.
   * @param key The key of the element to insert.
   * @param value The element value.
   * @param lesserKey The key of the element less than the element to insert.
   * @param greaterKey The key of the element greater than the element to insert.
   */
  function insert(
    List storage list,
    bytes32 key,
    uint256 value,
    bytes32 lesserKey,
    bytes32 greaterKey
  ) internal {
    list.list.insert(key, value, lesserKey, greaterKey);
    LinkedList.Element storage element = list.list.list.elements[key];

    MedianAction action = MedianAction.None;
    if (list.list.list.numElements == 1) {
      list.median = key;
      list.relation[key] = MedianRelation.Equal;
    } else if (list.list.list.numElements % 2 == 1) {
      // When we have an odd number of elements, and the element that we inserted is less than
      // the previous median, we need to slide the median down one element, since we had previously
      // selected the greater of the two middle elements.
      if (element.previousKey == bytes32(0) || list.relation[element.previousKey] == MedianRelation.Lesser) {
        action = MedianAction.Lesser;
        list.relation[key] = MedianRelation.Lesser;
      } else {
        list.relation[key] = MedianRelation.Greater;
      }
    } else {
      // When we have an even number of elements, and the element that we inserted is greater than
      // the previous median, we need to slide the median up one element, since we always select
      // the greater of the two middle elements.
      if (element.nextKey == bytes32(0) || list.relation[element.nextKey] == MedianRelation.Greater) {
        action = MedianAction.Greater;
        list.relation[key] = MedianRelation.Greater;
      } else {
        list.relation[key] = MedianRelation.Lesser;
      }
    }
    updateMedian(list, action);
  }

  /**
   * @notice Removes an element from the doubly linked list.
   * @param list A storage pointer to the underlying list.
   * @param key The key of the element to remove.
   */
  function remove(List storage list, bytes32 key) internal {
    MedianAction action = MedianAction.None;
    if (list.list.list.numElements == 0) {
      list.median = bytes32(0);
    } else if (list.list.list.numElements % 2 == 0) {
      // When we have an even number of elements, we always choose the higher of the two medians.
      // Thus, if the element we're removing is greaterKey than or equal to the median we need to
      // slide the median left by one.
      if (list.relation[key] == MedianRelation.Greater || list.relation[key] == MedianRelation.Equal) {
        action = MedianAction.Lesser;
      }
    } else {
      // When we don't have an even number of elements, we just choose the median value.
      // Thus, if the element we're removing is less than or equal to the median, we need to slide
      // median right by one.
      if (list.relation[key] == MedianRelation.Lesser || list.relation[key] == MedianRelation.Equal) {
        action = MedianAction.Greater;
      }
    }
    updateMedian(list, action);

    list.list.remove(key);
  }

  /**
   * @notice Updates an element in the list.
   * @param list A storage pointer to the underlying list.
   * @param key The element key.
   * @param value The element value.
   * @param lesserKey The key of the element will be just left of `key` after the update.
   * @param greaterKey The key of the element will be just right of `key` after the update.
   * @dev Note that only one of "lesserKey" or "greaterKey" needs to be correct to reduce friction.
   */
  function update(
    List storage list,
    bytes32 key,
    uint256 value,
    bytes32 lesserKey,
    bytes32 greaterKey
  ) internal {
    remove(list, key);
    insert(list, key, value, lesserKey, greaterKey);
  }

  /**
   * @notice Inserts an element at the tail of the doubly linked list.
   * @param list A storage pointer to the underlying list.
   * @param key The key of the element to insert.
   */
  function push(List storage list, bytes32 key) internal {
    insert(list, key, 0, bytes32(0), list.list.list.tail);
  }

  /**
   * @notice Removes N elements from the head of the list and returns their keys.
   * @param list A storage pointer to the underlying list.
   * @param n The number of elements to pop.
   * @return The keys of the popped elements.
   */
  function popN(List storage list, uint256 n) internal returns (bytes32[] memory) {
    require(n <= list.list.list.numElements, "not enough elements");
    bytes32[] memory keys = new bytes32[](n);
    for (uint256 i = 0; i < n; i = i.add(1)) {
      bytes32 key = list.list.list.head;
      keys[i] = key;
      remove(list, key);
    }
    return keys;
  }

  /**
   * @notice Returns whether or not a particular key is present in the sorted list.
   * @param list A storage pointer to the underlying list.
   * @param key The element key.
   * @return Whether or not the key is in the sorted list.
   */
  function contains(List storage list, bytes32 key) internal view returns (bool) {
    return list.list.contains(key);
  }

  /**
   * @notice Returns the value for a particular key in the sorted list.
   * @param list A storage pointer to the underlying list.
   * @param key The element key.
   * @return The element value.
   */
  function getValue(List storage list, bytes32 key) internal view returns (uint256) {
    return list.list.values[key];
  }

  /**
   * @notice Returns the median value of the sorted list.
   * @param list A storage pointer to the underlying list.
   * @return The median value.
   */
  function getMedianValue(List storage list) internal view returns (uint256) {
    return getValue(list, list.median);
  }

  /**
   * @notice Returns the key of the first element in the list.
   * @param list A storage pointer to the underlying list.
   * @return The key of the first element in the list.
   */
  function getHead(List storage list) internal view returns (bytes32) {
    return list.list.list.head;
  }

  /**
   * @notice Returns the key of the median element in the list.
   * @param list A storage pointer to the underlying list.
   * @return The key of the median element in the list.
   */
  function getMedian(List storage list) internal view returns (bytes32) {
    return list.median;
  }

  /**
   * @notice Returns the key of the last element in the list.
   * @param list A storage pointer to the underlying list.
   * @return The key of the last element in the list.
   */
  function getTail(List storage list) internal view returns (bytes32) {
    return list.list.list.tail;
  }

  /**
   * @notice Returns the number of elements in the list.
   * @param list A storage pointer to the underlying list.
   * @return The number of elements in the list.
   */
  function getNumElements(List storage list) internal view returns (uint256) {
    return list.list.list.numElements;
  }

  /**
   * @notice Gets all elements from the doubly linked list.
   * @param list A storage pointer to the underlying list.
   * @return Array of all keys in the list.
   * @return Values corresponding to keys, which will be ordered largest to smallest.
   * @return Array of relations to median of corresponding list elements.
   */
  function getElements(List storage list)
    internal
    view
    returns (
      bytes32[] memory,
      uint256[] memory,
      MedianRelation[] memory
    )
  {
    bytes32[] memory keys = getKeys(list);
    uint256[] memory values = new uint256[](keys.length);
    MedianRelation[] memory relations = new MedianRelation[](keys.length);
    for (uint256 i = 0; i < keys.length; i = i.add(1)) {
      values[i] = list.list.values[keys[i]];
      relations[i] = list.relation[keys[i]];
    }
    return (keys, values, relations);
  }

  /**
   * @notice Gets all element keys from the doubly linked list.
   * @param list A storage pointer to the underlying list.
   * @return All element keys from head to tail.
   */
  function getKeys(List storage list) internal view returns (bytes32[] memory) {
    return list.list.getKeys();
  }

  /**
   * @notice Moves the median pointer right or left of its current value.
   * @param list A storage pointer to the underlying list.
   * @param action Which direction to move the median pointer.
   */
  function updateMedian(List storage list, MedianAction action) private {
    LinkedList.Element storage previousMedian = list.list.list.elements[list.median];
    if (action == MedianAction.Lesser) {
      list.relation[list.median] = MedianRelation.Greater;
      list.median = previousMedian.previousKey;
    } else if (action == MedianAction.Greater) {
      list.relation[list.median] = MedianRelation.Lesser;
      list.median = previousMedian.nextKey;
    }
    list.relation[list.median] = MedianRelation.Equal;
  }
}
          

/lib/mento-core/contracts/interfaces/ICeloToken.sol

// SPDX-License-Identifier: GPL-3.0-or-later
pragma solidity ^0.5.13;

/**
 * @title This interface describes the non- ERC20 shared interface for all Celo Tokens, and
 * in the absence of interface inheritance is intended as a companion to IERC20.sol.
 */
interface ICeloToken {
  function transferWithComment(
    address,
    uint256,
    string calldata
  ) external returns (bool);

  function name() external view returns (string memory);

  function symbol() external view returns (string memory);

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

/lib/mento-core/contracts/interfaces/IExchange.sol

// SPDX-License-Identifier: GPL-3.0-or-later
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);
}
          

/lib/mento-core/contracts/interfaces/IReserve.sol

// SPDX-License-Identifier: GPL-3.0-or-later
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 transferCollateralAsset(
    address collateralAsset,
    address payable to,
    uint256 value
  ) 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;

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

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

  function getDailySpendingRatioForCollateralAsset(address collateralAsset) external view returns (uint256);

  function isExchangeSpender(address exchange) external view returns (bool);

  function addCollateralAsset(address asset) external returns (bool);

  function transferExchangeCollateralAsset(
    address collateralAsset,
    address payable to,
    uint256 value
  ) external returns (bool);
}
          

/lib/mento-core/contracts/interfaces/ISortedOracles.sol

// SPDX-License-Identifier: GPL-3.0-or-later
pragma solidity ^0.5.13;

import "../common/linkedlists/SortedLinkedListWithMedian.sol";

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

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

  function getTimestamps(address token)
    external
    view
    returns (
      address[] memory,
      uint256[] memory,
      SortedLinkedListWithMedian.MedianRelation[] memory
    );
}
          

/lib/mento-core/contracts/interfaces/IStableToken.sol

// SPDX-License-Identifier: GPL-3.0-or-later
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
    );

  function getExchangeRegistryId() external view returns (bytes32);

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

/lib/mento-core/lib/openzeppelin-contracts/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;
    }
}
          

/lib/mento-core/lib/openzeppelin-contracts/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;
    }
}
          

/lib/mento-core/lib/openzeppelin-contracts/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;
    }
}
          

/lib/mento-core/lib/openzeppelin-contracts/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":"Approval","inputs":[{"type":"address","name":"owner","internalType":"address","indexed":true},{"type":"address","name":"spender","internalType":"address","indexed":true},{"type":"uint256","name":"value","internalType":"uint256","indexed":false}],"anonymous":false},{"type":"event","name":"InflationFactorUpdated","inputs":[{"type":"uint256","name":"factor","internalType":"uint256","indexed":false},{"type":"uint256","name":"lastUpdated","internalType":"uint256","indexed":false}],"anonymous":false},{"type":"event","name":"InflationParametersUpdated","inputs":[{"type":"uint256","name":"rate","internalType":"uint256","indexed":false},{"type":"uint256","name":"updatePeriod","internalType":"uint256","indexed":false},{"type":"uint256","name":"lastUpdated","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":"Transfer","inputs":[{"type":"address","name":"from","internalType":"address","indexed":true},{"type":"address","name":"to","internalType":"address","indexed":true},{"type":"uint256","name":"value","internalType":"uint256","indexed":false}],"anonymous":false},{"type":"event","name":"TransferComment","inputs":[{"type":"string","name":"comment","internalType":"string","indexed":false}],"anonymous":false},{"type":"function","stateMutability":"view","payable":false,"outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"allowance","inputs":[{"type":"address","name":"accountOwner","internalType":"address"},{"type":"address","name":"spender","internalType":"address"}],"constant":true},{"type":"function","stateMutability":"nonpayable","payable":false,"outputs":[{"type":"bool","name":"","internalType":"bool"}],"name":"approve","inputs":[{"type":"address","name":"spender","internalType":"address"},{"type":"uint256","name":"value","internalType":"uint256"}],"constant":false},{"type":"function","stateMutability":"view","payable":false,"outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"balanceOf","inputs":[{"type":"address","name":"accountOwner","internalType":"address"}],"constant":true},{"type":"function","stateMutability":"nonpayable","payable":false,"outputs":[{"type":"bool","name":"","internalType":"bool"}],"name":"burn","inputs":[{"type":"uint256","name":"value","internalType":"uint256"}],"constant":false},{"type":"function","stateMutability":"view","payable":false,"outputs":[{"type":"bool","name":"","internalType":"bool"}],"name":"checkProofOfPossession","inputs":[{"type":"address","name":"sender","internalType":"address"},{"type":"bytes","name":"blsKey","internalType":"bytes"},{"type":"bytes","name":"blsPop","internalType":"bytes"}],"constant":true},{"type":"function","stateMutability":"nonpayable","payable":false,"outputs":[],"name":"creditGasFees","inputs":[{"type":"address","name":"from","internalType":"address"},{"type":"address","name":"feeRecipient","internalType":"address"},{"type":"address","name":"gatewayFeeRecipient","internalType":"address"},{"type":"address","name":"communityFund","internalType":"address"},{"type":"uint256","name":"refund","internalType":"uint256"},{"type":"uint256","name":"tipTxFee","internalType":"uint256"},{"type":"uint256","name":"gatewayFee","internalType":"uint256"},{"type":"uint256","name":"baseTxFee","internalType":"uint256"}],"constant":false},{"type":"function","stateMutability":"nonpayable","payable":false,"outputs":[],"name":"debitGasFees","inputs":[{"type":"address","name":"from","internalType":"address"},{"type":"uint256","name":"value","internalType":"uint256"}],"constant":false},{"type":"function","stateMutability":"view","payable":false,"outputs":[{"type":"uint8","name":"","internalType":"uint8"}],"name":"decimals","inputs":[],"constant":true},{"type":"function","stateMutability":"nonpayable","payable":false,"outputs":[{"type":"bool","name":"","internalType":"bool"}],"name":"decreaseAllowance","inputs":[{"type":"address","name":"spender","internalType":"address"},{"type":"uint256","name":"value","internalType":"uint256"}],"constant":false},{"type":"function","stateMutability":"view","payable":false,"outputs":[{"type":"uint256","name":"","internalType":"uint256"},{"type":"uint256","name":"","internalType":"uint256"}],"name":"fractionMulExp","inputs":[{"type":"uint256","name":"aNumerator","internalType":"uint256"},{"type":"uint256","name":"aDenominator","internalType":"uint256"},{"type":"uint256","name":"bNumerator","internalType":"uint256"},{"type":"uint256","name":"bDenominator","internalType":"uint256"},{"type":"uint256","name":"exponent","internalType":"uint256"},{"type":"uint256","name":"_decimals","internalType":"uint256"}],"constant":true},{"type":"function","stateMutability":"view","payable":false,"outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"getBlockNumberFromHeader","inputs":[{"type":"bytes","name":"header","internalType":"bytes"}],"constant":true},{"type":"function","stateMutability":"view","payable":false,"outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"getEpochNumber","inputs":[],"constant":true},{"type":"function","stateMutability":"view","payable":false,"outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"getEpochNumberOfBlock","inputs":[{"type":"uint256","name":"blockNumber","internalType":"uint256"}],"constant":true},{"type":"function","stateMutability":"view","payable":false,"outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"getEpochSize","inputs":[],"constant":true},{"type":"function","stateMutability":"view","payable":false,"outputs":[{"type":"bytes32","name":"","internalType":"bytes32"}],"name":"getExchangeRegistryId","inputs":[],"constant":true},{"type":"function","stateMutability":"view","payable":false,"outputs":[{"type":"uint256","name":"","internalType":"uint256"},{"type":"uint256","name":"","internalType":"uint256"},{"type":"uint256","name":"","internalType":"uint256"},{"type":"uint256","name":"","internalType":"uint256"}],"name":"getInflationParameters","inputs":[],"constant":true},{"type":"function","stateMutability":"view","payable":false,"outputs":[{"type":"bytes32","name":"","internalType":"bytes32"}],"name":"getParentSealBitmap","inputs":[{"type":"uint256","name":"blockNumber","internalType":"uint256"}],"constant":true},{"type":"function","stateMutability":"view","payable":false,"outputs":[{"type":"bytes32","name":"","internalType":"bytes32"}],"name":"getVerifiedSealBitmapFromHeader","inputs":[{"type":"bytes","name":"header","internalType":"bytes"}],"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":"bytes32","name":"","internalType":"bytes32"}],"name":"hashHeader","inputs":[{"type":"bytes","name":"header","internalType":"bytes"}],"constant":true},{"type":"function","stateMutability":"nonpayable","payable":false,"outputs":[{"type":"bool","name":"","internalType":"bool"}],"name":"increaseAllowance","inputs":[{"type":"address","name":"spender","internalType":"address"},{"type":"uint256","name":"value","internalType":"uint256"}],"constant":false},{"type":"function","stateMutability":"nonpayable","payable":false,"outputs":[],"name":"initialize","inputs":[{"type":"string","name":"_name","internalType":"string"},{"type":"string","name":"_symbol","internalType":"string"},{"type":"uint8","name":"_decimals","internalType":"uint8"},{"type":"address","name":"registryAddress","internalType":"address"},{"type":"uint256","name":"inflationRate","internalType":"uint256"},{"type":"uint256","name":"inflationFactorUpdatePeriod","internalType":"uint256"},{"type":"address[]","name":"initialBalanceAddresses","internalType":"address[]"},{"type":"uint256[]","name":"initialBalanceValues","internalType":"uint256[]"},{"type":"string","name":"exchangeIdentifier","internalType":"string"}],"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":"minQuorumSize","inputs":[{"type":"uint256","name":"blockNumber","internalType":"uint256"}],"constant":true},{"type":"function","stateMutability":"view","payable":false,"outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"minQuorumSizeInCurrentSet","inputs":[],"constant":true},{"type":"function","stateMutability":"nonpayable","payable":false,"outputs":[{"type":"bool","name":"","internalType":"bool"}],"name":"mint","inputs":[{"type":"address","name":"to","internalType":"address"},{"type":"uint256","name":"value","internalType":"uint256"}],"constant":false},{"type":"function","stateMutability":"view","payable":false,"outputs":[{"type":"string","name":"","internalType":"string"}],"name":"name","inputs":[],"constant":true},{"type":"function","stateMutability":"view","payable":false,"outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"numberValidatorsInCurrentSet","inputs":[],"constant":true},{"type":"function","stateMutability":"view","payable":false,"outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"numberValidatorsInSet","inputs":[{"type":"uint256","name":"blockNumber","internalType":"uint256"}],"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":"nonpayable","payable":false,"outputs":[],"name":"setInflationParameters","inputs":[{"type":"uint256","name":"rate","internalType":"uint256"},{"type":"uint256","name":"updatePeriod","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":"view","payable":false,"outputs":[{"type":"string","name":"","internalType":"string"}],"name":"symbol","inputs":[],"constant":true},{"type":"function","stateMutability":"view","payable":false,"outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"totalSupply","inputs":[],"constant":true},{"type":"function","stateMutability":"nonpayable","payable":false,"outputs":[{"type":"bool","name":"","internalType":"bool"}],"name":"transfer","inputs":[{"type":"address","name":"to","internalType":"address"},{"type":"uint256","name":"value","internalType":"uint256"}],"constant":false},{"type":"function","stateMutability":"nonpayable","payable":false,"outputs":[{"type":"bool","name":"","internalType":"bool"}],"name":"transferFrom","inputs":[{"type":"address","name":"from","internalType":"address"},{"type":"address","name":"to","internalType":"address"},{"type":"uint256","name":"value","internalType":"uint256"}],"constant":false},{"type":"function","stateMutability":"nonpayable","payable":false,"outputs":[],"name":"transferOwnership","inputs":[{"type":"address","name":"newOwner","internalType":"address"}],"constant":false},{"type":"function","stateMutability":"nonpayable","payable":false,"outputs":[{"type":"bool","name":"","internalType":"bool"}],"name":"transferWithComment","inputs":[{"type":"address","name":"to","internalType":"address"},{"type":"uint256","name":"value","internalType":"uint256"},{"type":"string","name":"comment","internalType":"string"}],"constant":false},{"type":"function","stateMutability":"view","payable":false,"outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"unitsToValue","inputs":[{"type":"uint256","name":"units","internalType":"uint256"}],"constant":true},{"type":"function","stateMutability":"view","payable":false,"outputs":[{"type":"address","name":"","internalType":"address"}],"name":"validatorSignerAddressFromCurrentSet","inputs":[{"type":"uint256","name":"index","internalType":"uint256"}],"constant":true},{"type":"function","stateMutability":"view","payable":false,"outputs":[{"type":"address","name":"","internalType":"address"}],"name":"validatorSignerAddressFromSet","inputs":[{"type":"uint256","name":"index","internalType":"uint256"},{"type":"uint256","name":"blockNumber","internalType":"uint256"}],"constant":true},{"type":"function","stateMutability":"view","payable":false,"outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"valueToUnits","inputs":[{"type":"uint256","name":"value","internalType":"uint256"}],"constant":true}]
              

Contract Creation Code

0x60806040523480156200001157600080fd5b506040516200503a3803806200503a833981810160405260208110156200003757600080fd5b50518060006200004f6001600160e01b03620000bb16565b600080546001600160a01b0319166001600160a01b0383169081178255604051929350917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0908290a35080620000b3576000805460ff60a01b1916600160a01b1790555b5050620000bf565b3390565b614f6b80620000cf6000396000f3fe608060405234801561001057600080fd5b50600436106102ff5760003560e01c806370a082311161019c578063a457c2d7116100ee578063df4da46111610097578063ec68307211610071578063ec68307214610d2a578063f2fde38b14610d7e578063fae8db0a14610da4576102ff565b8063df4da46114610c80578063e1d6aceb14610c88578063e50e652d14610d0d576102ff565b8063a91ee0dc116100c8578063a91ee0dc14610c0f578063af31f58714610c35578063dd62ed3e14610c52576102ff565b8063a457c2d714610baf578063a67f874714610bdb578063a9059cbb14610be3576102ff565b80638a8836261161015057806395d89b411161012a57806395d89b4114610b825780639a7b3be714610b8a5780639b2b592f14610b92576102ff565b80638a88362614610acc5780638da5cb5b14610b725780638f32d59b14610b7a576102ff565b80637385e5da116101815780637385e5da14610ab45780637b10399914610abc57806387ee8a0f14610ac4576102ff565b806370a0823114610a86578063715018a614610aac576102ff565b806339509351116102555780634b2c2f44116102095780635d180adb116101e35780635d180adb1461096457806367960e91146109875780636a30b25314610a2d576102ff565b80634b2c2f441461086457806354255be01461090a57806358cf967214610938576102ff565b806340a12f641161023a57806340a12f641461081357806340c10f191461081b57806342966c6814610847576102ff565b806339509351146107ca5780633b1eb4bf146107f6576102ff565b806318160ddd116102b757806323b872dd1161029157806323b872dd1461063957806323f0ab651461066f578063313ce567146107ac576102ff565b806318160ddd146104315780631e4f0e0314610439578063222836ad14610616576102ff565b8063123633ea116102e8578063123633ea146103c157806312c6c099146103fa578063158ef93e14610429576102ff565b806306fdde0314610304578063095ea7b314610381575b600080fd5b61030c610dc1565b6040805160208082528351818301528351919283929083019185019080838360005b8381101561034657818101518382015260200161032e565b50505050905090810190601f1680156103735780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b6103ad6004803603604081101561039757600080fd5b506001600160a01b038135169060200135610e73565b604080519115158252519081900360200190f35b6103de600480360360208110156103d757600080fd5b5035610fa4565b604080516001600160a01b039092168252519081900360200190f35b6104176004803603602081101561041057600080fd5b50356110b3565b60408051918252519081900360200190f35b6103ad6110d9565b6104176110fa565b610614600480360361012081101561045057600080fd5b81019060208101813564010000000081111561046b57600080fd5b82018360208201111561047d57600080fd5b8035906020019184600183028401116401000000008311171561049f57600080fd5b9193909290916020810190356401000000008111156104bd57600080fd5b8201836020820111156104cf57600080fd5b803590602001918460018302840111640100000000831117156104f157600080fd5b9193909260ff833516926001600160a01b036020820135169260408201359260608301359260a08101906080013564010000000081111561053157600080fd5b82018360208201111561054357600080fd5b8035906020019184602083028401116401000000008311171561056557600080fd5b91939092909160208101903564010000000081111561058357600080fd5b82018360208201111561059557600080fd5b803590602001918460208302840111640100000000831117156105b757600080fd5b9193909290916020810190356401000000008111156105d557600080fd5b8201836020820111156105e757600080fd5b8035906020019184600183028401116401000000008311171561060957600080fd5b50909250905061110c565b005b6106146004803603604081101561062c57600080fd5b50803590602001356113ac565b6103ad6004803603606081101561064f57600080fd5b506001600160a01b0381358116916020810135909116906040013561156e565b6103ad6004803603606081101561068557600080fd5b6001600160a01b0382351691908101906040810160208201356401000000008111156106b057600080fd5b8201836020820111156106c257600080fd5b803590602001918460018302840111640100000000831117156106e457600080fd5b91908080601f016020809104026020016040519081016040528093929190818152602001838380828437600092019190915250929594936020810193503591505064010000000081111561073757600080fd5b82018360208201111561074957600080fd5b8035906020019184600183028401116401000000008311171561076b57600080fd5b91908080601f0160208091040260200160405190810160405280939291908181526020018383808284376000920191909152509295506118dc945050505050565b6107b4611a76565b6040805160ff9092168252519081900360200190f35b6103ad600480360360408110156107e057600080fd5b506001600160a01b038135169060200135611a7f565b6104176004803603602081101561080c57600080fd5b5035611be8565b610417611c01565b6103ad6004803603604081101561083157600080fd5b506001600160a01b038135169060200135611c62565b6103ad6004803603602081101561085d57600080fd5b5035612076565b6104176004803603602081101561087a57600080fd5b81019060208101813564010000000081111561089557600080fd5b8201836020820111156108a757600080fd5b803590602001918460018302840111640100000000831117156108c957600080fd5b91908080601f0160208091040260200160405190810160405280939291908181526020018383808284376000920191909152509295506124a3945050505050565b6109126125fb565b604080519485526020850193909352838301919091526060830152519081900360800190f35b6106146004803603604081101561094e57600080fd5b506001600160a01b038135169060200135612608565b6103de6004803603604081101561097a57600080fd5b5080359060200135612820565b6104176004803603602081101561099d57600080fd5b8101906020810181356401000000008111156109b857600080fd5b8201836020820111156109ca57600080fd5b803590602001918460018302840111640100000000831117156109ec57600080fd5b91908080601f016020809104026020016040519081016040528093929190818152602001838380828437600092019190915250929550612928945050505050565b6106146004803603610100811015610a4457600080fd5b506001600160a01b0381358116916020810135821691604082013581169160608101359091169060808101359060a08101359060c08101359060e00135612a75565b61041760048036036020811015610a9c57600080fd5b50356001600160a01b0316612c4e565b610614612c70565b610417612d2b565b6103de612d36565b610417612d45565b61041760048036036020811015610ae257600080fd5b810190602081018135640100000000811115610afd57600080fd5b820183602082011115610b0f57600080fd5b80359060200191846001830284011164010000000083111715610b3157600080fd5b91908080601f016020809104026020016040519081016040528093929190818152602001838380828437600092019190915250929550612e5d945050505050565b6103de612faa565b6103ad612fb9565b61030c612fdd565b61041761305c565b61041760048036036020811015610ba857600080fd5b5035613067565b6103ad60048036036040811015610bc557600080fd5b506001600160a01b03813516906020013561316d565b610912613225565b6103ad60048036036040811015610bf957600080fd5b506001600160a01b038135169060200135613274565b61061460048036036020811015610c2557600080fd5b50356001600160a01b03166133c6565b61041760048036036020811015610c4b57600080fd5b50356134dc565b61041760048036036040811015610c6857600080fd5b506001600160a01b0381358116916020013516613512565b61041761353d565b6103ad60048036036060811015610c9e57600080fd5b6001600160a01b0382351691602081013591810190606081016040820135640100000000811115610cce57600080fd5b820183602082011115610ce057600080fd5b80359060200191846001830284011164010000000083111715610d0257600080fd5b509092509050613628565b61041760048036036020811015610d2357600080fd5b50356137e9565b610d65600480360360c0811015610d4057600080fd5b5080359060208101359060408101359060608101359060808101359060a00135613827565b6040805192835260208301919091528051918290030190f35b61061460048036036020811015610d9457600080fd5b50356001600160a01b03166139e4565b61041760048036036020811015610dba57600080fd5b5035613a49565b60028054604080516020601f7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff6101006001871615020190941685900493840181900481028201810190925282815260609390929091830182828015610e685780601f10610e3d57610100808354040283529160200191610e68565b820191906000526020600020905b815481529060010190602001808311610e4b57829003601f168201915b505050505090505b90565b6000610e7d614acb565b6000610e87613b4f565b600b5491935091508114610ef65781516009819055600b82905560408051602081019091529081527f08f3ed03ec9e579d1f6ab2f9e0d3dc661704696deabe37a6b6df7014f1b30a9790610eda90613cbf565b600b546040805192835260208301919091528051918290030190a15b6001600160a01b038516610f3b5760405162461bcd60e51b815260040180806020018281038252602a815260200180614d95602a913960400191505060405180910390fd5b3360008181526007602090815260408083206001600160a01b038a1680855290835292819020889055805188815290519293927f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925929181900390910190a3506001949350505050565b60408051602080820184905243828401528251808303840181526060928301938490528051600094859360fa939282918401908083835b60208310610ffa5780518252601f199092019160209182019101610fdb565b6001836020036101000a038019825116818451168082178552505050505050905001915050600060405180830381855afa9150503d806000811461105a576040519150601f19603f3d011682016040523d82523d6000602084013e61105f565b606091505b5092509050806110a05760405162461bcd60e51b815260040180806020018281038252603d815260200180614ced603d913960400191505060405180910390fd5b6110ab826000613cc3565b949350505050565b60006110bd614acb565b6110c5613b4f565b5090506110d28184613ccf565b9392505050565b60005474010000000000000000000000000000000000000000900460ff1681565b60006111076006546134dc565b905090565b60005474010000000000000000000000000000000000000000900460ff161561117c576040805162461bcd60e51b815260206004820152601c60248201527f636f6e747261637420616c726561647920696e697469616c697a656400000000604482015290519081900360640190fd5b600080547fffffffffffffffffffffff00ffffffffffffffffffffffffffffffffffffffff1674010000000000000000000000000000000000000000179055876111f75760405162461bcd60e51b8152600401808060200182810382526026815260200180614c106026913960400191505060405180910390fd5b600087116112365760405162461bcd60e51b8152600401808060200182810382526027815260200180614bc36027913960400191505060405180910390fd5b61123f33613ced565b600060065561125060028f8f614ade565b5061125d60038d8d614ade565b50600480547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff001660ff8c1617905561129488613da5565b516008556112a0613dbf565b51600955600a87905542600b55848314611301576040805162461bcd60e51b815260206004820152601560248201527f4172726179206c656e677468206d69736d617463680000000000000000000000604482015290519081900360640190fd5b60005b8581101561135c5761134387878381811061131b57fe5b905060200201356001600160a01b031686868481811061133757fe5b90506020020135613de3565b5061135581600163ffffffff613f0a16565b9050611304565b50611366896133c6565b818160405160200180838380828437808301925050509250505060405160208183030381529060405280519060200120600c819055505050505050505050505050505050565b6113b4612fb9565b611405576040805162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015290519081900360640190fd5b61140d614acb565b6000611417613b4f565b600b54919350915081146114865781516009819055600b82905560408051602081019091529081527f08f3ed03ec9e579d1f6ab2f9e0d3dc661704696deabe37a6b6df7014f1b30a979061146a90613cbf565b600b546040805192835260208301919091528051918290030190a15b836114c25760405162461bcd60e51b8152600401808060200182810382526027815260200180614c366027913960400191505060405180910390fd5b60008311611517576040805162461bcd60e51b815260206004820152601860248201527f757064617465506572696f64206d757374206265203e20300000000000000000604482015290519081900360640190fd5b61152084613da5565b51600855600a8390556040805185815260208101859052428183015290517fa0035d6667ffb7d387c86c7228141c4a877e8ed831b267ac928a2f5b651c155d9181900360600190a150505050565b6000611578614acb565b6000611582613b4f565b600b54919350915081146115f15781516009819055600b82905560408051602081019091529081527f08f3ed03ec9e579d1f6ab2f9e0d3dc661704696deabe37a6b6df7014f1b30a97906115d590613cbf565b600b546040805192835260208301919091528051918290030190a15b6115f9613f64565b6001600160a01b031663e5839836306040518263ffffffff1660e01b815260040180826001600160a01b03166001600160a01b0316815260200191505060206040518083038186803b15801561164e57600080fd5b505afa158015611662573d6000803e3d6000fd5b505050506040513d602081101561167857600080fd5b5051156116b65760405162461bcd60e51b8152600401808060200182810382526022815260200180614c956022913960400191505060405180910390fd5b604080516020810190915260095481526000906116d39086613ccf565b90506001600160a01b03861661171a5760405162461bcd60e51b815260040180806020018281038252602a815260200180614eea602a913960400191505060405180910390fd5b6001600160a01b0387166000908152600560205260409020548111156117715760405162461bcd60e51b8152600401808060200182810382526029815260200180614de06029913960400191505060405180910390fd5b6001600160a01b03871660009081526007602090815260408083203384529091529020548511156117d35760405162461bcd60e51b8152600401808060200182810382526038815260200180614e096038913960400191505060405180910390fd5b6001600160a01b0386166000908152600560205260409020546117fc908263ffffffff613f0a16565b6001600160a01b038088166000908152600560205260408082209390935590891681522054611831908263ffffffff61403916565b6001600160a01b038816600090815260056020908152604080832093909355600781528282203383529052205461186e908663ffffffff61403916565b6001600160a01b0380891660008181526007602090815260408083203384528252918290209490945580518981529051928a169391927fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef929181900390910190a35060019695505050505050565b60008060fb6001600160a01b031685858560405160200180846001600160a01b03166001600160a01b031660601b815260140183805190602001908083835b6020831061193a5780518252601f19909201916020918201910161191b565b51815160209384036101000a7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff018019909216911617905285519190930192850191508083835b602083106119a05780518252601f199092019160209182019101611981565b6001836020036101000a03801982511681845116808217855250505050505090500193505050506040516020818303038152906040526040518082805190602001908083835b60208310611a055780518252601f1990920191602091820191016119e6565b6001836020036101000a038019825116818451168082178552505050505050905001915050600060405180830381855afa9150503d8060008114611a65576040519150601f19603f3d011682016040523d82523d6000602084013e611a6a565b606091505b50909695505050505050565b60045460ff1690565b6000611a89614acb565b6000611a93613b4f565b600b5491935091508114611b025781516009819055600b82905560408051602081019091529081527f08f3ed03ec9e579d1f6ab2f9e0d3dc661704696deabe37a6b6df7014f1b30a9790611ae690613cbf565b600b546040805192835260208301919091528051918290030190a15b6001600160a01b038516611b475760405162461bcd60e51b815260040180806020018281038252602a815260200180614d95602a913960400191505060405180910390fd5b3360009081526007602090815260408083206001600160a01b038916845290915281205490611b7c828763ffffffff613f0a16565b3360008181526007602090815260408083206001600160a01b038d16808552908352928190208590558051858152905194955091937f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b9259281900390910190a35060019695505050505050565b6000611bfb82611bf661353d565b61407b565b92915050565b600c54600090611c595760405160200180807f45786368616e67650000000000000000000000000000000000000000000000008152506008019050604051602081830303815290604052805190602001209050610e70565b50600c54610e70565b6000611c6c614acb565b6000611c76613b4f565b600b5491935091508114611ce55781516009819055600b82905560408051602081019091529081527f08f3ed03ec9e579d1f6ab2f9e0d3dc661704696deabe37a6b6df7014f1b30a9790611cc990613cbf565b600b546040805192835260208301919091528051918290030190a15b600154604080517f42726f6b6572000000000000000000000000000000000000000000000000000060208083019190915282518083036006018152602683018085528151918301919091207fdd92723300000000000000000000000000000000000000000000000000000000909152602a83015291516001600160a01b039093169263dd92723392604a80840193919291829003018186803b158015611d8a57600080fd5b505afa158015611d9e573d6000803e3d6000fd5b505050506040513d6020811015611db457600080fd5b50516001600160a01b0316331480611e4c57506001546001600160a01b031663dd927233611de0611c01565b6040518263ffffffff1660e01b81526004018082815260200191505060206040518083038186803b158015611e1457600080fd5b505afa158015611e28573d6000803e3d6000fd5b505050506040513d6020811015611e3e57600080fd5b50516001600160a01b031633145b80611f2f5750600154604080517f56616c696461746f7273000000000000000000000000000000000000000000006020808301919091528251808303600a018152602a83018085528151918301919091207fdd92723300000000000000000000000000000000000000000000000000000000909152602e83015291516001600160a01b039093169263dd92723392604e80840193919291829003018186803b158015611ef757600080fd5b505afa158015611f0b573d6000803e3d6000fd5b505050506040513d6020811015611f2157600080fd5b50516001600160a01b031633145b806120125750600154604080517f4772616e64614d656e746f0000000000000000000000000000000000000000006020808301919091528251808303600b018152602b83018085528151918301919091207fdd92723300000000000000000000000000000000000000000000000000000000909152602f83015291516001600160a01b039093169263dd92723392604f80840193919291829003018186803b158015611fda57600080fd5b505afa158015611fee573d6000803e3d6000fd5b505050506040513d602081101561200457600080fd5b50516001600160a01b031633145b612063576040805162461bcd60e51b815260206004820152601d60248201527f53656e646572206e6f7420617574686f72697a656420746f206d696e74000000604482015290519081900360640190fd5b61206d8585613de3565b95945050505050565b6000612080614acb565b600061208a613b4f565b600b54919350915081146120f95781516009819055600b82905560408051602081019091529081527f08f3ed03ec9e579d1f6ab2f9e0d3dc661704696deabe37a6b6df7014f1b30a97906120dd90613cbf565b600b546040805192835260208301919091528051918290030190a15b600154604080517f42726f6b6572000000000000000000000000000000000000000000000000000060208083019190915282518083036006018152602683018085528151918301919091207fdd92723300000000000000000000000000000000000000000000000000000000909152602a83015291516001600160a01b039093169263dd92723392604a80840193919291829003018186803b15801561219e57600080fd5b505afa1580156121b2573d6000803e3d6000fd5b505050506040513d60208110156121c857600080fd5b50516001600160a01b031633148061226057506001546001600160a01b031663dd9272336121f4611c01565b6040518263ffffffff1660e01b81526004018082815260200191505060206040518083038186803b15801561222857600080fd5b505afa15801561223c573d6000803e3d6000fd5b505050506040513d602081101561225257600080fd5b50516001600160a01b031633145b806123435750600154604080517f4772616e64614d656e746f0000000000000000000000000000000000000000006020808301919091528251808303600b018152602b83018085528151918301919091207fdd92723300000000000000000000000000000000000000000000000000000000909152602f83015291516001600160a01b039093169263dd92723392604f80840193919291829003018186803b15801561230b57600080fd5b505afa15801561231f573d6000803e3d6000fd5b505050506040513d602081101561233557600080fd5b50516001600160a01b031633145b612394576040805162461bcd60e51b815260206004820152601d60248201527f53656e646572206e6f7420617574686f72697a656420746f206275726e000000604482015290519081900360640190fd5b604080516020810190915260095481526000906123b19086613ccf565b33600090815260056020526040902054909150811115612418576040805162461bcd60e51b815260206004820181905260248201527f76616c75652065786365656465642062616c616e6365206f662073656e646572604482015290519081900360640190fd5b60065461242b908263ffffffff61403916565b6006553360009081526005602052604090205461244e908263ffffffff61403916565b336000818152600560209081526040808320949094558351858152935191937fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef929081900390910190a3506001949350505050565b60006060600060f46001600160a01b0316846040516020018082805190602001908083835b602083106124e75780518252601f1990920191602091820191016124c8565b6001836020036101000a0380198251168184511680821785525050505050509050019150506040516020818303038152906040526040518082805190602001908083835b6020831061254a5780518252601f19909201916020918201910161252b565b6001836020036101000a038019825116818451168082178552505050505050905001915050600060405180830381855afa9150503d80600081146125aa576040519150601f19603f3d011682016040523d82523d6000602084013e6125af565b606091505b5092509050806125f05760405162461bcd60e51b8152600401808060200182810382526038815260200180614c5d6038913960400191505060405180910390fd5b6110ab8260006140b8565b6001600281600090919293565b331561265b576040805162461bcd60e51b815260206004820152601060248201527f4f6e6c7920564d2063616e2063616c6c00000000000000000000000000000000604482015290519081900360640190fd5b612663613f64565b6001600160a01b031663e5839836306040518263ffffffff1660e01b815260040180826001600160a01b03166001600160a01b0316815260200191505060206040518083038186803b1580156126b857600080fd5b505afa1580156126cc573d6000803e3d6000fd5b505050506040513d60208110156126e257600080fd5b5051156127205760405162461bcd60e51b8152600401808060200182810382526022815260200180614c956022913960400191505060405180910390fd5b612728614acb565b6000612732613b4f565b600b54919350915081146127a15781516009819055600b82905560408051602081019091529081527f08f3ed03ec9e579d1f6ab2f9e0d3dc661704696deabe37a6b6df7014f1b30a979061278590613cbf565b600b546040805192835260208301919091528051918290030190a15b604080516020810190915260095481526000906127be9085613ccf565b6001600160a01b0386166000908152600560205260409020549091506127ea908263ffffffff61403916565b6001600160a01b038616600090815260056020526040902055600654612816908263ffffffff61403916565b6006555050505050565b6040805160208082018590528183018490528251808303840181526060928301938490528051600094859360fa939282918401908083835b602083106128775780518252601f199092019160209182019101612858565b6001836020036101000a038019825116818451168082178552505050505050905001915050600060405180830381855afa9150503d80600081146128d7576040519150601f19603f3d011682016040523d82523d6000602084013e6128dc565b606091505b50925090508061291d5760405162461bcd60e51b8152600401808060200182810382526036815260200180614d5f6036913960400191505060405180910390fd5b61206d826000613cc3565b60006060600060f66001600160a01b0316846040516020018082805190602001908083835b6020831061296c5780518252601f19909201916020918201910161294d565b6001836020036101000a0380198251168184511680821785525050505050509050019150506040516020818303038152906040526040518082805190602001908083835b602083106129cf5780518252601f1990920191602091820191016129b0565b6001836020036101000a038019825116818451168082178552505050505050905001915050600060405180830381855afa9150503d8060008114612a2f576040519150601f19603f3d011682016040523d82523d6000602084013e612a34565b606091505b5092509050806125f05760405162461bcd60e51b8152600401808060200182810382526023815260200180614f146023913960400191505060405180910390fd5b3315612ac8576040805162461bcd60e51b815260206004820152601060248201527f4f6e6c7920564d2063616e2063616c6c00000000000000000000000000000000604482015290519081900360640190fd5b612ad0613f64565b6001600160a01b031663e5839836306040518263ffffffff1660e01b815260040180826001600160a01b03166001600160a01b0316815260200191505060206040518083038186803b158015612b2557600080fd5b505afa158015612b39573d6000803e3d6000fd5b505050506040513d6020811015612b4f57600080fd5b505115612b8d5760405162461bcd60e51b8152600401808060200182810382526022815260200180614c956022913960400191505060405180910390fd5b60408051602081019091526009548152600090612baa9086613ccf565b6001600160a01b038a16600090815260056020526040902054909150612bd6908263ffffffff613f0a16565b6001600160a01b038a16600090815260056020526040902055612c0a612bfd8a8885614129565b829063ffffffff613f0a16565b9050612c1a612bfd8a8a87614129565b9050612c2a612bfd8a8986614129565b600654909150612c40908263ffffffff613f0a16565b600655505050505050505050565b6001600160a01b038116600090815260056020526040812054611bfb906134dc565b612c78612fb9565b612cc9576040805162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015290519081900360640190fd5b600080546040516001600160a01b03909116907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0908390a3600080547fffffffffffffffffffffffff0000000000000000000000000000000000000000169055565b6000611107436137e9565b6001546001600160a01b031681565b60006060600060f96001600160a01b031643604051602001808281526020019150506040516020818303038152906040526040518082805190602001908083835b60208310612da55780518252601f199092019160209182019101612d86565b6001836020036101000a038019825116818451168082178552505050505050905001915050600060405180830381855afa9150503d8060008114612e05576040519150601f19603f3d011682016040523d82523d6000602084013e612e0a565b606091505b509250905080612e4b5760405162461bcd60e51b8152600401808060200182810382526035815260200180614d2a6035913960400191505060405180910390fd5b612e56826000613cc3565b9250505090565b60006060600060f76001600160a01b0316846040516020018082805190602001908083835b60208310612ea15780518252601f199092019160209182019101612e82565b6001836020036101000a0380198251168184511680821785525050505050509050019150506040516020818303038152906040526040518082805190602001908083835b60208310612f045780518252601f199092019160209182019101612ee5565b6001836020036101000a038019825116818451168082178552505050505050905001915050600060405180830381855afa9150503d8060008114612f64576040519150601f19603f3d011682016040523d82523d6000602084013e612f69565b606091505b5092509050806110a05760405162461bcd60e51b8152600401808060200182810382526031815260200180614eb96031913960400191505060405180910390fd5b6000546001600160a01b031690565b600080546001600160a01b0316612fce6141e9565b6001600160a01b031614905090565b60038054604080516020601f60027fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff610100600188161502019095169490940493840181900481028201810190925282815260609390929091830182828015610e685780601f10610e3d57610100808354040283529160200191610e68565b600061110743611be8565b60006060600060f96001600160a01b031684604051602001808281526020019150506040516020818303038152906040526040518082805190602001908083835b602083106130c75780518252601f1990920191602091820191016130a8565b6001836020036101000a038019825116818451168082178552505050505050905001915050600060405180830381855afa9150503d8060008114613127576040519150601f19603f3d011682016040523d82523d6000602084013e61312c565b606091505b5092509050806110a05760405162461bcd60e51b815260040180806020018281038252602e815260200180614b95602e913960400191505060405180910390fd5b6000613177614acb565b6000613181613b4f565b600b54919350915081146131f05781516009819055600b82905560408051602081019091529081527f08f3ed03ec9e579d1f6ab2f9e0d3dc661704696deabe37a6b6df7014f1b30a97906131d490613cbf565b600b546040805192835260208301919091528051918290030190a15b3360009081526007602090815260408083206001600160a01b038916845290915281205490611b7c828763ffffffff61403916565b6040805160208101909152600854815260009081908190819061324790613cbf565b6040805160208101909152600954815261326090613cbf565b600a54600b54929791965094509092509050565b600061327e614acb565b6000613288613b4f565b600b54919350915081146132f75781516009819055600b82905560408051602081019091529081527f08f3ed03ec9e579d1f6ab2f9e0d3dc661704696deabe37a6b6df7014f1b30a97906132db90613cbf565b600b546040805192835260208301919091528051918290030190a15b6132ff613f64565b6001600160a01b031663e5839836306040518263ffffffff1660e01b815260040180826001600160a01b03166001600160a01b0316815260200191505060206040518083038186803b15801561335457600080fd5b505afa158015613368573d6000803e3d6000fd5b505050506040513d602081101561337e57600080fd5b5051156133bc5760405162461bcd60e51b8152600401808060200182810382526022815260200180614c956022913960400191505060405180910390fd5b61206d85856141ed565b6133ce612fb9565b61341f576040805162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015290519081900360640190fd5b6001600160a01b03811661347a576040805162461bcd60e51b815260206004820181905260248201527f43616e6e6f7420726567697374657220746865206e756c6c2061646472657373604482015290519081900360640190fd5b600180547fffffffffffffffffffffffff0000000000000000000000000000000000000000166001600160a01b0383169081179091556040517f27fe5f0c1c3b1ed427cc63d0f05759ffdecf9aec9e18d31ef366fc8a6cb5dc3b90600090a250565b60006134e6614acb565b6134ee613b4f565b5090506110d261350d8261350186614353565b9063ffffffff6143c116565b6144a5565b6001600160a01b03918216600090815260076020908152604080832093909416825291909152205490565b604080516000808252602082019283905281519092606092849260f89290819081908082805b602083106135825780518252601f199092019160209182019101613563565b6001836020036101000a038019825116818451168082178552505050505050905001915050600060405180830381855afa9150503d80600081146135e2576040519150601f19603f3d011682016040523d82523d6000602084013e6135e7565b606091505b509250905080612e4b5760405162461bcd60e51b8152600401808060200182810382526025815260200180614e686025913960400191505060405180910390fd5b6000613632614acb565b600061363c613b4f565b600b54919350915081146136ab5781516009819055600b82905560408051602081019091529081527f08f3ed03ec9e579d1f6ab2f9e0d3dc661704696deabe37a6b6df7014f1b30a979061368f90613cbf565b600b546040805192835260208301919091528051918290030190a15b6136b3613f64565b6001600160a01b031663e5839836306040518263ffffffff1660e01b815260040180826001600160a01b03166001600160a01b0316815260200191505060206040518083038186803b15801561370857600080fd5b505afa15801561371c573d6000803e3d6000fd5b505050506040513d602081101561373257600080fd5b5051156137705760405162461bcd60e51b8152600401808060200182810382526022815260200180614c956022913960400191505060405180910390fd5b600061377c8888613274565b90507fe5d4e30fb8364e57bc4d662a07d0cf36f4c34552004c4c3624620a2c1d1c03dc868660405180806020018281038252848482818152602001925080828437600083820152604051601f909101601f19169092018290039550909350505050a1979650505050505050565b6000611bfb600361381b600261380f600261380388613067565b9063ffffffff6144b616565b9063ffffffff613f0a16565b9063ffffffff61450f16565b600080861580159061383857508415155b613889576040805162461bcd60e51b815260206004820152601560248201527f612064656e6f6d696e61746f72206973207a65726f0000000000000000000000604482015290519081900360640190fd5b6000806000606060fc6001600160a01b03168c8c8c8c8c8c6040516020018087815260200186815260200185815260200184815260200183815260200182815260200196505050505050506040516020818303038152906040526040518082805190602001908083835b602083106139125780518252601f1990920191602091820191016138f3565b6001836020036101000a038019825116818451168082178552505050505050905001915050600060405180830381855afa9150503d8060008114613972576040519150601f19603f3d011682016040523d82523d6000602084013e613977565b606091505b509092509050816139b95760405162461bcd60e51b8152600401808060200182810382526027815260200180614e416027913960400191505060405180910390fd5b6139c4816000613cc3565b93506139d1816020613cc3565b939c939b50929950505050505050505050565b6139ec612fb9565b613a3d576040805162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015290519081900360640190fd5b613a4681613ced565b50565b60006060600060f56001600160a01b031684604051602001808281526020019150506040516020818303038152906040526040518082805190602001908083835b60208310613aa95780518252601f199092019160209182019101613a8a565b6001836020036101000a038019825116818451168082178552505050505050905001915050600060405180830381855afa9150503d8060008114613b09576040519150601f19603f3d011682016040523d82523d6000602084013e613b0e565b606091505b5092509050806125f05760405162461bcd60e51b815260040180806020018281038252602c815260200180614e8d602c913960400191505060405180910390fd5b613b57614acb565b600a54600b54600091613b70919063ffffffff613f0a16565b421015613b92575050600b546040805160208101909152600954815290613cbb565b600a54600b5460009182918291613bb49161381b90429063ffffffff61403916565b60408051602081019091526009548152909150613c1590613bd490613cbf565b613be4613bdf613dbf565b613cbf565b60408051602081019091526008548152613bfd90613cbf565b613c08613bdf613dbf565b600454869060ff16613827565b9093509150821580613c25575081155b15613c4a575050600b546040805160208101909152600954815293509150613cbb9050565b613c52614acb565b613c67613c5e84613da5565b61350186613da5565b90506000613cb0613ca160086002015461381b613c926008600301544261403990919063ffffffff16565b600a549063ffffffff6144b616565b600b549063ffffffff613f0a16565b919650909450505050505b9091565b5190565b60006110d283836140b8565b60006110d261350d613ce084614353565b859063ffffffff61455116565b6001600160a01b038116613d325760405162461bcd60e51b8152600401808060200182810382526026815260200180614bea6026913960400191505060405180910390fd5b600080546040516001600160a01b03808516939216917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e091a3600080547fffffffffffffffffffffffff0000000000000000000000000000000000000000166001600160a01b0392909216919091179055565b613dad614acb565b50604080516020810190915290815290565b613dc7614acb565b50604080516020810190915269d3c21bcecceda1000000815290565b60006001600160a01b038316613e40576040805162461bcd60e51b815260206004820152601760248201527f3020697320612072657365727665642061646472657373000000000000000000604482015290519081900360640190fd5b81613e4d57506001611bfb565b60408051602081019091526009548152600090613e6a9084613ccf565b600654909150613e80908263ffffffff613f0a16565b6006556001600160a01b038416600090815260056020526040902054613eac908263ffffffff613f0a16565b6001600160a01b03851660008181526005602090815260408083209490945583518781529351929391927fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef9281900390910190a35060019392505050565b6000828201838110156110d2576040805162461bcd60e51b815260206004820152601b60248201527f536166654d6174683a206164646974696f6e206f766572666c6f770000000000604482015290519081900360640190fd5b600154604080517f467265657a65720000000000000000000000000000000000000000000000000060208083019190915282518083036007018152602783018085528151918301919091207fdcf0aaed00000000000000000000000000000000000000000000000000000000909152602b83015291516000936001600160a01b03169263dcf0aaed92604b8082019391829003018186803b15801561400857600080fd5b505afa15801561401c573d6000803e3d6000fd5b505050506040513d602081101561403257600080fd5b5051905090565b60006110d283836040518060400160405280601e81526020017f536166654d6174683a207375627472616374696f6e206f766572666c6f7700008152506148c3565b60008082848161408757fe5b04905082848161409357fe5b0661409f579050611bfb565b6140b081600163ffffffff613f0a16565b915050611bfb565b60006140cb82602063ffffffff613f0a16565b83511015614120576040805162461bcd60e51b815260206004820152601460248201527f736c6963696e67206f7574206f662072616e6765000000000000000000000000604482015290519081900360640190fd5b50016020015190565b60006001600160a01b038316614141575060006110d2565b6040805160208101909152600954815260009061415e9084613ccf565b6001600160a01b03851660009081526005602052604090205490915061418a908263ffffffff613f0a16565b6001600160a01b0380861660008181526005602090815260409182902094909455805187815290519193928916927fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef92918290030190a3949350505050565b3390565b60006001600160a01b0383166142345760405162461bcd60e51b815260040180806020018281038252602a815260200180614eea602a913960400191505060405180910390fd5b604080516020810190915260095481526000906142519084613ccf565b336000908152600560205260409020549091508111156142a25760405162461bcd60e51b8152600401808060200182810382526029815260200180614de06029913960400191505060405180910390fd5b336000908152600560205260409020546142c2908263ffffffff61403916565b33600090815260056020526040808220929092556001600160a01b038616815220546142f4908263ffffffff613f0a16565b6001600160a01b0385166000818152600560209081526040918290209390935580518681529051919233927fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef9281900390910190a35060019392505050565b61435b614acb565b61436361495a565b8211156143a15760405162461bcd60e51b8152600401808060200182810382526036815260200180614cb76036913960400191505060405180910390fd5b50604080516020810190915269d3c21bcecceda100000082028152919050565b6143c9614acb565b815161441c576040805162461bcd60e51b815260206004820152601160248201527f63616e2774206469766964652062792030000000000000000000000000000000604482015290519081900360640190fd5b825169d3c21bcecceda10000008181029190820414614482576040805162461bcd60e51b815260206004820152601260248201527f6f766572666c6f77206174206469766964650000000000000000000000000000604482015290519081900360640190fd5b60405180602001604052808460000151838161449a57fe5b049052949350505050565b5169d3c21bcecceda1000000900490565b6000826144c557506000611bfb565b828202828482816144d257fe5b04146110d25760405162461bcd60e51b8152600401808060200182810382526021815260200180614dbf6021913960400191505060405180910390fd5b60006110d283836040518060400160405280601a81526020017f536166654d6174683a206469766973696f6e206279207a65726f000000000000815250614975565b614559614acb565b8251158061456657508151155b156145805750604080516020810190915260008152611bfb565b815169d3c21bcecceda1000000141561459a575081611bfb565b825169d3c21bcecceda100000014156145b4575080611bfb565b600069d3c21bcecceda10000006145ca856149da565b51816145d257fe5b04905060006145e085614a0f565b519050600069d3c21bcecceda10000006145f9866149da565b518161460157fe5b049050600061460f86614a0f565b5190508382028415614678578285828161462557fe5b0414614678576040805162461bcd60e51b815260206004820152601660248201527f6f766572666c6f77207831793120646574656374656400000000000000000000604482015290519081900360640190fd5b69d3c21bcecceda1000000810281156146f25769d3c21bcecceda100000082828161469f57fe5b04146146f2576040805162461bcd60e51b815260206004820152601f60248201527f6f766572666c6f772078317931202a2066697865643120646574656374656400604482015290519081900360640190fd5b905080848402851561475b578486828161470857fe5b041461475b576040805162461bcd60e51b815260206004820152601660248201527f6f766572666c6f77207832793120646574656374656400000000000000000000604482015290519081900360640190fd5b86840287156147c1578488828161476e57fe5b04146147c1576040805162461bcd60e51b815260206004820152601660248201527f6f766572666c6f77207831793220646574656374656400000000000000000000604482015290519081900360640190fd5b6147c9614a49565b87816147d157fe5b0496506147dc614a49565b85816147e457fe5b049450868502871561484d57858882816147fa57fe5b041461484d576040805162461bcd60e51b815260206004820152601660248201527f6f766572666c6f77207832793220646574656374656400000000000000000000604482015290519081900360640190fd5b614855614acb565b604051806020016040528087815250905061487e81604051806020016040528087815250614a52565b905061489881604051806020016040528086815250614a52565b90506148b281604051806020016040528085815250614a52565b9d9c50505050505050505050505050565b600081848411156149525760405162461bcd60e51b81526004018080602001828103825283818151815260200191508051906020019080838360005b838110156149175781810151838201526020016148ff565b50505050905090810190601f1680156149445780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b505050900390565b7601357c299a88ea76a58924d52ce4f26a85af186c2b9e7490565b600081836149c45760405162461bcd60e51b81526020600482018181528351602484015283519092839260449091019190850190808383600083156149175781810151838201526020016148ff565b5060008385816149d057fe5b0495945050505050565b6149e2614acb565b604051806020016040528069d3c21bcecceda100000080856000015181614a0557fe5b0402905292915050565b614a17614acb565b604051806020016040528069d3c21bcecceda100000080856000015181614a3a57fe5b95519504029093039092525090565b64e8d4a5100090565b614a5a614acb565b8151835190810190811015614ab6576040805162461bcd60e51b815260206004820152601560248201527f616464206f766572666c6f772064657465637465640000000000000000000000604482015290519081900360640190fd5b60408051602081019091529081529392505050565b6040518060200160405280600081525090565b828054600181600116156101000203166002900490600052602060002090601f016020900481019282601f10614b3d578280017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00823516178555614b6a565b82800160010185558215614b6a579182015b82811115614b6a578235825591602001919060010190614b4f565b50614b76929150614b7a565b5090565b610e7091905b80821115614b765760008155600101614b8056fe6572726f722063616c6c696e67206e756d62657256616c696461746f7273496e53657420707265636f6d70696c65696e666c6174696f6e466163746f72557064617465506572696f64206d757374206265203e20304f776e61626c653a206e6577206f776e657220697320746865207a65726f20616464726573734d7573742070726f766964652061206e6f6e2d7a65726f20696e666c6174696f6e20726174654d7573742070726f766964652061206e6f6e2d7a65726f20696e666c6174696f6e20726174652e6572726f722063616c6c696e672067657456657269666965645365616c4269746d617046726f6d48656164657220707265636f6d70696c6563616e27742063616c6c207768656e20636f6e74726163742069732066726f7a656e63616e277420637265617465206669786964697479206e756d626572206c6172676572207468616e206d61784e6577466978656428296572726f722063616c6c696e672076616c696461746f725369676e65724164647265737346726f6d43757272656e7453657420707265636f6d70696c656572726f722063616c6c696e67206e756d62657256616c696461746f7273496e43757272656e7453657420707265636f6d70696c656572726f722063616c6c696e672076616c696461746f725369676e65724164647265737346726f6d53657420707265636f6d70696c6572657365727665642061646472657373203078302063616e6e6f74206861766520616c6c6f77616e6365536166654d6174683a206d756c7469706c69636174696f6e206f766572666c6f777472616e736665722076616c75652065786365656465642062616c616e6365206f662073656e6465727472616e736665722076616c75652065786365656465642073656e646572277320616c6c6f77616e636520666f7220726563697069656e746572726f722063616c6c696e67206672616374696f6e4d756c45787020707265636f6d70696c656572726f722063616c6c696e672067657445706f636853697a6520707265636f6d70696c656572726f722063616c6c696e6720676574506172656e745365616c4269746d617020707265636f6d70696c656572726f722063616c6c696e6720676574426c6f636b4e756d62657246726f6d48656164657220707265636f6d70696c657472616e7366657220617474656d7074656420746f2072657365727665642061646472657373203078306572726f722063616c6c696e67206861736848656164657220707265636f6d70696c65a265627a7a72315820c0624207327e150a2660f10930355a78304eada0599d51eb94d6dad95e1a4b1364736f6c634300051100320000000000000000000000000000000000000000000000000000000000000000

Deployed ByteCode

0x608060405234801561001057600080fd5b50600436106102ff5760003560e01c806370a082311161019c578063a457c2d7116100ee578063df4da46111610097578063ec68307211610071578063ec68307214610d2a578063f2fde38b14610d7e578063fae8db0a14610da4576102ff565b8063df4da46114610c80578063e1d6aceb14610c88578063e50e652d14610d0d576102ff565b8063a91ee0dc116100c8578063a91ee0dc14610c0f578063af31f58714610c35578063dd62ed3e14610c52576102ff565b8063a457c2d714610baf578063a67f874714610bdb578063a9059cbb14610be3576102ff565b80638a8836261161015057806395d89b411161012a57806395d89b4114610b825780639a7b3be714610b8a5780639b2b592f14610b92576102ff565b80638a88362614610acc5780638da5cb5b14610b725780638f32d59b14610b7a576102ff565b80637385e5da116101815780637385e5da14610ab45780637b10399914610abc57806387ee8a0f14610ac4576102ff565b806370a0823114610a86578063715018a614610aac576102ff565b806339509351116102555780634b2c2f44116102095780635d180adb116101e35780635d180adb1461096457806367960e91146109875780636a30b25314610a2d576102ff565b80634b2c2f441461086457806354255be01461090a57806358cf967214610938576102ff565b806340a12f641161023a57806340a12f641461081357806340c10f191461081b57806342966c6814610847576102ff565b806339509351146107ca5780633b1eb4bf146107f6576102ff565b806318160ddd116102b757806323b872dd1161029157806323b872dd1461063957806323f0ab651461066f578063313ce567146107ac576102ff565b806318160ddd146104315780631e4f0e0314610439578063222836ad14610616576102ff565b8063123633ea116102e8578063123633ea146103c157806312c6c099146103fa578063158ef93e14610429576102ff565b806306fdde0314610304578063095ea7b314610381575b600080fd5b61030c610dc1565b6040805160208082528351818301528351919283929083019185019080838360005b8381101561034657818101518382015260200161032e565b50505050905090810190601f1680156103735780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b6103ad6004803603604081101561039757600080fd5b506001600160a01b038135169060200135610e73565b604080519115158252519081900360200190f35b6103de600480360360208110156103d757600080fd5b5035610fa4565b604080516001600160a01b039092168252519081900360200190f35b6104176004803603602081101561041057600080fd5b50356110b3565b60408051918252519081900360200190f35b6103ad6110d9565b6104176110fa565b610614600480360361012081101561045057600080fd5b81019060208101813564010000000081111561046b57600080fd5b82018360208201111561047d57600080fd5b8035906020019184600183028401116401000000008311171561049f57600080fd5b9193909290916020810190356401000000008111156104bd57600080fd5b8201836020820111156104cf57600080fd5b803590602001918460018302840111640100000000831117156104f157600080fd5b9193909260ff833516926001600160a01b036020820135169260408201359260608301359260a08101906080013564010000000081111561053157600080fd5b82018360208201111561054357600080fd5b8035906020019184602083028401116401000000008311171561056557600080fd5b91939092909160208101903564010000000081111561058357600080fd5b82018360208201111561059557600080fd5b803590602001918460208302840111640100000000831117156105b757600080fd5b9193909290916020810190356401000000008111156105d557600080fd5b8201836020820111156105e757600080fd5b8035906020019184600183028401116401000000008311171561060957600080fd5b50909250905061110c565b005b6106146004803603604081101561062c57600080fd5b50803590602001356113ac565b6103ad6004803603606081101561064f57600080fd5b506001600160a01b0381358116916020810135909116906040013561156e565b6103ad6004803603606081101561068557600080fd5b6001600160a01b0382351691908101906040810160208201356401000000008111156106b057600080fd5b8201836020820111156106c257600080fd5b803590602001918460018302840111640100000000831117156106e457600080fd5b91908080601f016020809104026020016040519081016040528093929190818152602001838380828437600092019190915250929594936020810193503591505064010000000081111561073757600080fd5b82018360208201111561074957600080fd5b8035906020019184600183028401116401000000008311171561076b57600080fd5b91908080601f0160208091040260200160405190810160405280939291908181526020018383808284376000920191909152509295506118dc945050505050565b6107b4611a76565b6040805160ff9092168252519081900360200190f35b6103ad600480360360408110156107e057600080fd5b506001600160a01b038135169060200135611a7f565b6104176004803603602081101561080c57600080fd5b5035611be8565b610417611c01565b6103ad6004803603604081101561083157600080fd5b506001600160a01b038135169060200135611c62565b6103ad6004803603602081101561085d57600080fd5b5035612076565b6104176004803603602081101561087a57600080fd5b81019060208101813564010000000081111561089557600080fd5b8201836020820111156108a757600080fd5b803590602001918460018302840111640100000000831117156108c957600080fd5b91908080601f0160208091040260200160405190810160405280939291908181526020018383808284376000920191909152509295506124a3945050505050565b6109126125fb565b604080519485526020850193909352838301919091526060830152519081900360800190f35b6106146004803603604081101561094e57600080fd5b506001600160a01b038135169060200135612608565b6103de6004803603604081101561097a57600080fd5b5080359060200135612820565b6104176004803603602081101561099d57600080fd5b8101906020810181356401000000008111156109b857600080fd5b8201836020820111156109ca57600080fd5b803590602001918460018302840111640100000000831117156109ec57600080fd5b91908080601f016020809104026020016040519081016040528093929190818152602001838380828437600092019190915250929550612928945050505050565b6106146004803603610100811015610a4457600080fd5b506001600160a01b0381358116916020810135821691604082013581169160608101359091169060808101359060a08101359060c08101359060e00135612a75565b61041760048036036020811015610a9c57600080fd5b50356001600160a01b0316612c4e565b610614612c70565b610417612d2b565b6103de612d36565b610417612d45565b61041760048036036020811015610ae257600080fd5b810190602081018135640100000000811115610afd57600080fd5b820183602082011115610b0f57600080fd5b80359060200191846001830284011164010000000083111715610b3157600080fd5b91908080601f016020809104026020016040519081016040528093929190818152602001838380828437600092019190915250929550612e5d945050505050565b6103de612faa565b6103ad612fb9565b61030c612fdd565b61041761305c565b61041760048036036020811015610ba857600080fd5b5035613067565b6103ad60048036036040811015610bc557600080fd5b506001600160a01b03813516906020013561316d565b610912613225565b6103ad60048036036040811015610bf957600080fd5b506001600160a01b038135169060200135613274565b61061460048036036020811015610c2557600080fd5b50356001600160a01b03166133c6565b61041760048036036020811015610c4b57600080fd5b50356134dc565b61041760048036036040811015610c6857600080fd5b506001600160a01b0381358116916020013516613512565b61041761353d565b6103ad60048036036060811015610c9e57600080fd5b6001600160a01b0382351691602081013591810190606081016040820135640100000000811115610cce57600080fd5b820183602082011115610ce057600080fd5b80359060200191846001830284011164010000000083111715610d0257600080fd5b509092509050613628565b61041760048036036020811015610d2357600080fd5b50356137e9565b610d65600480360360c0811015610d4057600080fd5b5080359060208101359060408101359060608101359060808101359060a00135613827565b6040805192835260208301919091528051918290030190f35b61061460048036036020811015610d9457600080fd5b50356001600160a01b03166139e4565b61041760048036036020811015610dba57600080fd5b5035613a49565b60028054604080516020601f7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff6101006001871615020190941685900493840181900481028201810190925282815260609390929091830182828015610e685780601f10610e3d57610100808354040283529160200191610e68565b820191906000526020600020905b815481529060010190602001808311610e4b57829003601f168201915b505050505090505b90565b6000610e7d614acb565b6000610e87613b4f565b600b5491935091508114610ef65781516009819055600b82905560408051602081019091529081527f08f3ed03ec9e579d1f6ab2f9e0d3dc661704696deabe37a6b6df7014f1b30a9790610eda90613cbf565b600b546040805192835260208301919091528051918290030190a15b6001600160a01b038516610f3b5760405162461bcd60e51b815260040180806020018281038252602a815260200180614d95602a913960400191505060405180910390fd5b3360008181526007602090815260408083206001600160a01b038a1680855290835292819020889055805188815290519293927f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925929181900390910190a3506001949350505050565b60408051602080820184905243828401528251808303840181526060928301938490528051600094859360fa939282918401908083835b60208310610ffa5780518252601f199092019160209182019101610fdb565b6001836020036101000a038019825116818451168082178552505050505050905001915050600060405180830381855afa9150503d806000811461105a576040519150601f19603f3d011682016040523d82523d6000602084013e61105f565b606091505b5092509050806110a05760405162461bcd60e51b815260040180806020018281038252603d815260200180614ced603d913960400191505060405180910390fd5b6110ab826000613cc3565b949350505050565b60006110bd614acb565b6110c5613b4f565b5090506110d28184613ccf565b9392505050565b60005474010000000000000000000000000000000000000000900460ff1681565b60006111076006546134dc565b905090565b60005474010000000000000000000000000000000000000000900460ff161561117c576040805162461bcd60e51b815260206004820152601c60248201527f636f6e747261637420616c726561647920696e697469616c697a656400000000604482015290519081900360640190fd5b600080547fffffffffffffffffffffff00ffffffffffffffffffffffffffffffffffffffff1674010000000000000000000000000000000000000000179055876111f75760405162461bcd60e51b8152600401808060200182810382526026815260200180614c106026913960400191505060405180910390fd5b600087116112365760405162461bcd60e51b8152600401808060200182810382526027815260200180614bc36027913960400191505060405180910390fd5b61123f33613ced565b600060065561125060028f8f614ade565b5061125d60038d8d614ade565b50600480547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff001660ff8c1617905561129488613da5565b516008556112a0613dbf565b51600955600a87905542600b55848314611301576040805162461bcd60e51b815260206004820152601560248201527f4172726179206c656e677468206d69736d617463680000000000000000000000604482015290519081900360640190fd5b60005b8581101561135c5761134387878381811061131b57fe5b905060200201356001600160a01b031686868481811061133757fe5b90506020020135613de3565b5061135581600163ffffffff613f0a16565b9050611304565b50611366896133c6565b818160405160200180838380828437808301925050509250505060405160208183030381529060405280519060200120600c819055505050505050505050505050505050565b6113b4612fb9565b611405576040805162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015290519081900360640190fd5b61140d614acb565b6000611417613b4f565b600b54919350915081146114865781516009819055600b82905560408051602081019091529081527f08f3ed03ec9e579d1f6ab2f9e0d3dc661704696deabe37a6b6df7014f1b30a979061146a90613cbf565b600b546040805192835260208301919091528051918290030190a15b836114c25760405162461bcd60e51b8152600401808060200182810382526027815260200180614c366027913960400191505060405180910390fd5b60008311611517576040805162461bcd60e51b815260206004820152601860248201527f757064617465506572696f64206d757374206265203e20300000000000000000604482015290519081900360640190fd5b61152084613da5565b51600855600a8390556040805185815260208101859052428183015290517fa0035d6667ffb7d387c86c7228141c4a877e8ed831b267ac928a2f5b651c155d9181900360600190a150505050565b6000611578614acb565b6000611582613b4f565b600b54919350915081146115f15781516009819055600b82905560408051602081019091529081527f08f3ed03ec9e579d1f6ab2f9e0d3dc661704696deabe37a6b6df7014f1b30a97906115d590613cbf565b600b546040805192835260208301919091528051918290030190a15b6115f9613f64565b6001600160a01b031663e5839836306040518263ffffffff1660e01b815260040180826001600160a01b03166001600160a01b0316815260200191505060206040518083038186803b15801561164e57600080fd5b505afa158015611662573d6000803e3d6000fd5b505050506040513d602081101561167857600080fd5b5051156116b65760405162461bcd60e51b8152600401808060200182810382526022815260200180614c956022913960400191505060405180910390fd5b604080516020810190915260095481526000906116d39086613ccf565b90506001600160a01b03861661171a5760405162461bcd60e51b815260040180806020018281038252602a815260200180614eea602a913960400191505060405180910390fd5b6001600160a01b0387166000908152600560205260409020548111156117715760405162461bcd60e51b8152600401808060200182810382526029815260200180614de06029913960400191505060405180910390fd5b6001600160a01b03871660009081526007602090815260408083203384529091529020548511156117d35760405162461bcd60e51b8152600401808060200182810382526038815260200180614e096038913960400191505060405180910390fd5b6001600160a01b0386166000908152600560205260409020546117fc908263ffffffff613f0a16565b6001600160a01b038088166000908152600560205260408082209390935590891681522054611831908263ffffffff61403916565b6001600160a01b038816600090815260056020908152604080832093909355600781528282203383529052205461186e908663ffffffff61403916565b6001600160a01b0380891660008181526007602090815260408083203384528252918290209490945580518981529051928a169391927fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef929181900390910190a35060019695505050505050565b60008060fb6001600160a01b031685858560405160200180846001600160a01b03166001600160a01b031660601b815260140183805190602001908083835b6020831061193a5780518252601f19909201916020918201910161191b565b51815160209384036101000a7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff018019909216911617905285519190930192850191508083835b602083106119a05780518252601f199092019160209182019101611981565b6001836020036101000a03801982511681845116808217855250505050505090500193505050506040516020818303038152906040526040518082805190602001908083835b60208310611a055780518252601f1990920191602091820191016119e6565b6001836020036101000a038019825116818451168082178552505050505050905001915050600060405180830381855afa9150503d8060008114611a65576040519150601f19603f3d011682016040523d82523d6000602084013e611a6a565b606091505b50909695505050505050565b60045460ff1690565b6000611a89614acb565b6000611a93613b4f565b600b5491935091508114611b025781516009819055600b82905560408051602081019091529081527f08f3ed03ec9e579d1f6ab2f9e0d3dc661704696deabe37a6b6df7014f1b30a9790611ae690613cbf565b600b546040805192835260208301919091528051918290030190a15b6001600160a01b038516611b475760405162461bcd60e51b815260040180806020018281038252602a815260200180614d95602a913960400191505060405180910390fd5b3360009081526007602090815260408083206001600160a01b038916845290915281205490611b7c828763ffffffff613f0a16565b3360008181526007602090815260408083206001600160a01b038d16808552908352928190208590558051858152905194955091937f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b9259281900390910190a35060019695505050505050565b6000611bfb82611bf661353d565b61407b565b92915050565b600c54600090611c595760405160200180807f45786368616e67650000000000000000000000000000000000000000000000008152506008019050604051602081830303815290604052805190602001209050610e70565b50600c54610e70565b6000611c6c614acb565b6000611c76613b4f565b600b5491935091508114611ce55781516009819055600b82905560408051602081019091529081527f08f3ed03ec9e579d1f6ab2f9e0d3dc661704696deabe37a6b6df7014f1b30a9790611cc990613cbf565b600b546040805192835260208301919091528051918290030190a15b600154604080517f42726f6b6572000000000000000000000000000000000000000000000000000060208083019190915282518083036006018152602683018085528151918301919091207fdd92723300000000000000000000000000000000000000000000000000000000909152602a83015291516001600160a01b039093169263dd92723392604a80840193919291829003018186803b158015611d8a57600080fd5b505afa158015611d9e573d6000803e3d6000fd5b505050506040513d6020811015611db457600080fd5b50516001600160a01b0316331480611e4c57506001546001600160a01b031663dd927233611de0611c01565b6040518263ffffffff1660e01b81526004018082815260200191505060206040518083038186803b158015611e1457600080fd5b505afa158015611e28573d6000803e3d6000fd5b505050506040513d6020811015611e3e57600080fd5b50516001600160a01b031633145b80611f2f5750600154604080517f56616c696461746f7273000000000000000000000000000000000000000000006020808301919091528251808303600a018152602a83018085528151918301919091207fdd92723300000000000000000000000000000000000000000000000000000000909152602e83015291516001600160a01b039093169263dd92723392604e80840193919291829003018186803b158015611ef757600080fd5b505afa158015611f0b573d6000803e3d6000fd5b505050506040513d6020811015611f2157600080fd5b50516001600160a01b031633145b806120125750600154604080517f4772616e64614d656e746f0000000000000000000000000000000000000000006020808301919091528251808303600b018152602b83018085528151918301919091207fdd92723300000000000000000000000000000000000000000000000000000000909152602f83015291516001600160a01b039093169263dd92723392604f80840193919291829003018186803b158015611fda57600080fd5b505afa158015611fee573d6000803e3d6000fd5b505050506040513d602081101561200457600080fd5b50516001600160a01b031633145b612063576040805162461bcd60e51b815260206004820152601d60248201527f53656e646572206e6f7420617574686f72697a656420746f206d696e74000000604482015290519081900360640190fd5b61206d8585613de3565b95945050505050565b6000612080614acb565b600061208a613b4f565b600b54919350915081146120f95781516009819055600b82905560408051602081019091529081527f08f3ed03ec9e579d1f6ab2f9e0d3dc661704696deabe37a6b6df7014f1b30a97906120dd90613cbf565b600b546040805192835260208301919091528051918290030190a15b600154604080517f42726f6b6572000000000000000000000000000000000000000000000000000060208083019190915282518083036006018152602683018085528151918301919091207fdd92723300000000000000000000000000000000000000000000000000000000909152602a83015291516001600160a01b039093169263dd92723392604a80840193919291829003018186803b15801561219e57600080fd5b505afa1580156121b2573d6000803e3d6000fd5b505050506040513d60208110156121c857600080fd5b50516001600160a01b031633148061226057506001546001600160a01b031663dd9272336121f4611c01565b6040518263ffffffff1660e01b81526004018082815260200191505060206040518083038186803b15801561222857600080fd5b505afa15801561223c573d6000803e3d6000fd5b505050506040513d602081101561225257600080fd5b50516001600160a01b031633145b806123435750600154604080517f4772616e64614d656e746f0000000000000000000000000000000000000000006020808301919091528251808303600b018152602b83018085528151918301919091207fdd92723300000000000000000000000000000000000000000000000000000000909152602f83015291516001600160a01b039093169263dd92723392604f80840193919291829003018186803b15801561230b57600080fd5b505afa15801561231f573d6000803e3d6000fd5b505050506040513d602081101561233557600080fd5b50516001600160a01b031633145b612394576040805162461bcd60e51b815260206004820152601d60248201527f53656e646572206e6f7420617574686f72697a656420746f206275726e000000604482015290519081900360640190fd5b604080516020810190915260095481526000906123b19086613ccf565b33600090815260056020526040902054909150811115612418576040805162461bcd60e51b815260206004820181905260248201527f76616c75652065786365656465642062616c616e6365206f662073656e646572604482015290519081900360640190fd5b60065461242b908263ffffffff61403916565b6006553360009081526005602052604090205461244e908263ffffffff61403916565b336000818152600560209081526040808320949094558351858152935191937fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef929081900390910190a3506001949350505050565b60006060600060f46001600160a01b0316846040516020018082805190602001908083835b602083106124e75780518252601f1990920191602091820191016124c8565b6001836020036101000a0380198251168184511680821785525050505050509050019150506040516020818303038152906040526040518082805190602001908083835b6020831061254a5780518252601f19909201916020918201910161252b565b6001836020036101000a038019825116818451168082178552505050505050905001915050600060405180830381855afa9150503d80600081146125aa576040519150601f19603f3d011682016040523d82523d6000602084013e6125af565b606091505b5092509050806125f05760405162461bcd60e51b8152600401808060200182810382526038815260200180614c5d6038913960400191505060405180910390fd5b6110ab8260006140b8565b6001600281600090919293565b331561265b576040805162461bcd60e51b815260206004820152601060248201527f4f6e6c7920564d2063616e2063616c6c00000000000000000000000000000000604482015290519081900360640190fd5b612663613f64565b6001600160a01b031663e5839836306040518263ffffffff1660e01b815260040180826001600160a01b03166001600160a01b0316815260200191505060206040518083038186803b1580156126b857600080fd5b505afa1580156126cc573d6000803e3d6000fd5b505050506040513d60208110156126e257600080fd5b5051156127205760405162461bcd60e51b8152600401808060200182810382526022815260200180614c956022913960400191505060405180910390fd5b612728614acb565b6000612732613b4f565b600b54919350915081146127a15781516009819055600b82905560408051602081019091529081527f08f3ed03ec9e579d1f6ab2f9e0d3dc661704696deabe37a6b6df7014f1b30a979061278590613cbf565b600b546040805192835260208301919091528051918290030190a15b604080516020810190915260095481526000906127be9085613ccf565b6001600160a01b0386166000908152600560205260409020549091506127ea908263ffffffff61403916565b6001600160a01b038616600090815260056020526040902055600654612816908263ffffffff61403916565b6006555050505050565b6040805160208082018590528183018490528251808303840181526060928301938490528051600094859360fa939282918401908083835b602083106128775780518252601f199092019160209182019101612858565b6001836020036101000a038019825116818451168082178552505050505050905001915050600060405180830381855afa9150503d80600081146128d7576040519150601f19603f3d011682016040523d82523d6000602084013e6128dc565b606091505b50925090508061291d5760405162461bcd60e51b8152600401808060200182810382526036815260200180614d5f6036913960400191505060405180910390fd5b61206d826000613cc3565b60006060600060f66001600160a01b0316846040516020018082805190602001908083835b6020831061296c5780518252601f19909201916020918201910161294d565b6001836020036101000a0380198251168184511680821785525050505050509050019150506040516020818303038152906040526040518082805190602001908083835b602083106129cf5780518252601f1990920191602091820191016129b0565b6001836020036101000a038019825116818451168082178552505050505050905001915050600060405180830381855afa9150503d8060008114612a2f576040519150601f19603f3d011682016040523d82523d6000602084013e612a34565b606091505b5092509050806125f05760405162461bcd60e51b8152600401808060200182810382526023815260200180614f146023913960400191505060405180910390fd5b3315612ac8576040805162461bcd60e51b815260206004820152601060248201527f4f6e6c7920564d2063616e2063616c6c00000000000000000000000000000000604482015290519081900360640190fd5b612ad0613f64565b6001600160a01b031663e5839836306040518263ffffffff1660e01b815260040180826001600160a01b03166001600160a01b0316815260200191505060206040518083038186803b158015612b2557600080fd5b505afa158015612b39573d6000803e3d6000fd5b505050506040513d6020811015612b4f57600080fd5b505115612b8d5760405162461bcd60e51b8152600401808060200182810382526022815260200180614c956022913960400191505060405180910390fd5b60408051602081019091526009548152600090612baa9086613ccf565b6001600160a01b038a16600090815260056020526040902054909150612bd6908263ffffffff613f0a16565b6001600160a01b038a16600090815260056020526040902055612c0a612bfd8a8885614129565b829063ffffffff613f0a16565b9050612c1a612bfd8a8a87614129565b9050612c2a612bfd8a8986614129565b600654909150612c40908263ffffffff613f0a16565b600655505050505050505050565b6001600160a01b038116600090815260056020526040812054611bfb906134dc565b612c78612fb9565b612cc9576040805162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015290519081900360640190fd5b600080546040516001600160a01b03909116907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0908390a3600080547fffffffffffffffffffffffff0000000000000000000000000000000000000000169055565b6000611107436137e9565b6001546001600160a01b031681565b60006060600060f96001600160a01b031643604051602001808281526020019150506040516020818303038152906040526040518082805190602001908083835b60208310612da55780518252601f199092019160209182019101612d86565b6001836020036101000a038019825116818451168082178552505050505050905001915050600060405180830381855afa9150503d8060008114612e05576040519150601f19603f3d011682016040523d82523d6000602084013e612e0a565b606091505b509250905080612e4b5760405162461bcd60e51b8152600401808060200182810382526035815260200180614d2a6035913960400191505060405180910390fd5b612e56826000613cc3565b9250505090565b60006060600060f76001600160a01b0316846040516020018082805190602001908083835b60208310612ea15780518252601f199092019160209182019101612e82565b6001836020036101000a0380198251168184511680821785525050505050509050019150506040516020818303038152906040526040518082805190602001908083835b60208310612f045780518252601f199092019160209182019101612ee5565b6001836020036101000a038019825116818451168082178552505050505050905001915050600060405180830381855afa9150503d8060008114612f64576040519150601f19603f3d011682016040523d82523d6000602084013e612f69565b606091505b5092509050806110a05760405162461bcd60e51b8152600401808060200182810382526031815260200180614eb96031913960400191505060405180910390fd5b6000546001600160a01b031690565b600080546001600160a01b0316612fce6141e9565b6001600160a01b031614905090565b60038054604080516020601f60027fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff610100600188161502019095169490940493840181900481028201810190925282815260609390929091830182828015610e685780601f10610e3d57610100808354040283529160200191610e68565b600061110743611be8565b60006060600060f96001600160a01b031684604051602001808281526020019150506040516020818303038152906040526040518082805190602001908083835b602083106130c75780518252601f1990920191602091820191016130a8565b6001836020036101000a038019825116818451168082178552505050505050905001915050600060405180830381855afa9150503d8060008114613127576040519150601f19603f3d011682016040523d82523d6000602084013e61312c565b606091505b5092509050806110a05760405162461bcd60e51b815260040180806020018281038252602e815260200180614b95602e913960400191505060405180910390fd5b6000613177614acb565b6000613181613b4f565b600b54919350915081146131f05781516009819055600b82905560408051602081019091529081527f08f3ed03ec9e579d1f6ab2f9e0d3dc661704696deabe37a6b6df7014f1b30a97906131d490613cbf565b600b546040805192835260208301919091528051918290030190a15b3360009081526007602090815260408083206001600160a01b038916845290915281205490611b7c828763ffffffff61403916565b6040805160208101909152600854815260009081908190819061324790613cbf565b6040805160208101909152600954815261326090613cbf565b600a54600b54929791965094509092509050565b600061327e614acb565b6000613288613b4f565b600b54919350915081146132f75781516009819055600b82905560408051602081019091529081527f08f3ed03ec9e579d1f6ab2f9e0d3dc661704696deabe37a6b6df7014f1b30a97906132db90613cbf565b600b546040805192835260208301919091528051918290030190a15b6132ff613f64565b6001600160a01b031663e5839836306040518263ffffffff1660e01b815260040180826001600160a01b03166001600160a01b0316815260200191505060206040518083038186803b15801561335457600080fd5b505afa158015613368573d6000803e3d6000fd5b505050506040513d602081101561337e57600080fd5b5051156133bc5760405162461bcd60e51b8152600401808060200182810382526022815260200180614c956022913960400191505060405180910390fd5b61206d85856141ed565b6133ce612fb9565b61341f576040805162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015290519081900360640190fd5b6001600160a01b03811661347a576040805162461bcd60e51b815260206004820181905260248201527f43616e6e6f7420726567697374657220746865206e756c6c2061646472657373604482015290519081900360640190fd5b600180547fffffffffffffffffffffffff0000000000000000000000000000000000000000166001600160a01b0383169081179091556040517f27fe5f0c1c3b1ed427cc63d0f05759ffdecf9aec9e18d31ef366fc8a6cb5dc3b90600090a250565b60006134e6614acb565b6134ee613b4f565b5090506110d261350d8261350186614353565b9063ffffffff6143c116565b6144a5565b6001600160a01b03918216600090815260076020908152604080832093909416825291909152205490565b604080516000808252602082019283905281519092606092849260f89290819081908082805b602083106135825780518252601f199092019160209182019101613563565b6001836020036101000a038019825116818451168082178552505050505050905001915050600060405180830381855afa9150503d80600081146135e2576040519150601f19603f3d011682016040523d82523d6000602084013e6135e7565b606091505b509250905080612e4b5760405162461bcd60e51b8152600401808060200182810382526025815260200180614e686025913960400191505060405180910390fd5b6000613632614acb565b600061363c613b4f565b600b54919350915081146136ab5781516009819055600b82905560408051602081019091529081527f08f3ed03ec9e579d1f6ab2f9e0d3dc661704696deabe37a6b6df7014f1b30a979061368f90613cbf565b600b546040805192835260208301919091528051918290030190a15b6136b3613f64565b6001600160a01b031663e5839836306040518263ffffffff1660e01b815260040180826001600160a01b03166001600160a01b0316815260200191505060206040518083038186803b15801561370857600080fd5b505afa15801561371c573d6000803e3d6000fd5b505050506040513d602081101561373257600080fd5b5051156137705760405162461bcd60e51b8152600401808060200182810382526022815260200180614c956022913960400191505060405180910390fd5b600061377c8888613274565b90507fe5d4e30fb8364e57bc4d662a07d0cf36f4c34552004c4c3624620a2c1d1c03dc868660405180806020018281038252848482818152602001925080828437600083820152604051601f909101601f19169092018290039550909350505050a1979650505050505050565b6000611bfb600361381b600261380f600261380388613067565b9063ffffffff6144b616565b9063ffffffff613f0a16565b9063ffffffff61450f16565b600080861580159061383857508415155b613889576040805162461bcd60e51b815260206004820152601560248201527f612064656e6f6d696e61746f72206973207a65726f0000000000000000000000604482015290519081900360640190fd5b6000806000606060fc6001600160a01b03168c8c8c8c8c8c6040516020018087815260200186815260200185815260200184815260200183815260200182815260200196505050505050506040516020818303038152906040526040518082805190602001908083835b602083106139125780518252601f1990920191602091820191016138f3565b6001836020036101000a038019825116818451168082178552505050505050905001915050600060405180830381855afa9150503d8060008114613972576040519150601f19603f3d011682016040523d82523d6000602084013e613977565b606091505b509092509050816139b95760405162461bcd60e51b8152600401808060200182810382526027815260200180614e416027913960400191505060405180910390fd5b6139c4816000613cc3565b93506139d1816020613cc3565b939c939b50929950505050505050505050565b6139ec612fb9565b613a3d576040805162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015290519081900360640190fd5b613a4681613ced565b50565b60006060600060f56001600160a01b031684604051602001808281526020019150506040516020818303038152906040526040518082805190602001908083835b60208310613aa95780518252601f199092019160209182019101613a8a565b6001836020036101000a038019825116818451168082178552505050505050905001915050600060405180830381855afa9150503d8060008114613b09576040519150601f19603f3d011682016040523d82523d6000602084013e613b0e565b606091505b5092509050806125f05760405162461bcd60e51b815260040180806020018281038252602c815260200180614e8d602c913960400191505060405180910390fd5b613b57614acb565b600a54600b54600091613b70919063ffffffff613f0a16565b421015613b92575050600b546040805160208101909152600954815290613cbb565b600a54600b5460009182918291613bb49161381b90429063ffffffff61403916565b60408051602081019091526009548152909150613c1590613bd490613cbf565b613be4613bdf613dbf565b613cbf565b60408051602081019091526008548152613bfd90613cbf565b613c08613bdf613dbf565b600454869060ff16613827565b9093509150821580613c25575081155b15613c4a575050600b546040805160208101909152600954815293509150613cbb9050565b613c52614acb565b613c67613c5e84613da5565b61350186613da5565b90506000613cb0613ca160086002015461381b613c926008600301544261403990919063ffffffff16565b600a549063ffffffff6144b616565b600b549063ffffffff613f0a16565b919650909450505050505b9091565b5190565b60006110d283836140b8565b60006110d261350d613ce084614353565b859063ffffffff61455116565b6001600160a01b038116613d325760405162461bcd60e51b8152600401808060200182810382526026815260200180614bea6026913960400191505060405180910390fd5b600080546040516001600160a01b03808516939216917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e091a3600080547fffffffffffffffffffffffff0000000000000000000000000000000000000000166001600160a01b0392909216919091179055565b613dad614acb565b50604080516020810190915290815290565b613dc7614acb565b50604080516020810190915269d3c21bcecceda1000000815290565b60006001600160a01b038316613e40576040805162461bcd60e51b815260206004820152601760248201527f3020697320612072657365727665642061646472657373000000000000000000604482015290519081900360640190fd5b81613e4d57506001611bfb565b60408051602081019091526009548152600090613e6a9084613ccf565b600654909150613e80908263ffffffff613f0a16565b6006556001600160a01b038416600090815260056020526040902054613eac908263ffffffff613f0a16565b6001600160a01b03851660008181526005602090815260408083209490945583518781529351929391927fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef9281900390910190a35060019392505050565b6000828201838110156110d2576040805162461bcd60e51b815260206004820152601b60248201527f536166654d6174683a206164646974696f6e206f766572666c6f770000000000604482015290519081900360640190fd5b600154604080517f467265657a65720000000000000000000000000000000000000000000000000060208083019190915282518083036007018152602783018085528151918301919091207fdcf0aaed00000000000000000000000000000000000000000000000000000000909152602b83015291516000936001600160a01b03169263dcf0aaed92604b8082019391829003018186803b15801561400857600080fd5b505afa15801561401c573d6000803e3d6000fd5b505050506040513d602081101561403257600080fd5b5051905090565b60006110d283836040518060400160405280601e81526020017f536166654d6174683a207375627472616374696f6e206f766572666c6f7700008152506148c3565b60008082848161408757fe5b04905082848161409357fe5b0661409f579050611bfb565b6140b081600163ffffffff613f0a16565b915050611bfb565b60006140cb82602063ffffffff613f0a16565b83511015614120576040805162461bcd60e51b815260206004820152601460248201527f736c6963696e67206f7574206f662072616e6765000000000000000000000000604482015290519081900360640190fd5b50016020015190565b60006001600160a01b038316614141575060006110d2565b6040805160208101909152600954815260009061415e9084613ccf565b6001600160a01b03851660009081526005602052604090205490915061418a908263ffffffff613f0a16565b6001600160a01b0380861660008181526005602090815260409182902094909455805187815290519193928916927fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef92918290030190a3949350505050565b3390565b60006001600160a01b0383166142345760405162461bcd60e51b815260040180806020018281038252602a815260200180614eea602a913960400191505060405180910390fd5b604080516020810190915260095481526000906142519084613ccf565b336000908152600560205260409020549091508111156142a25760405162461bcd60e51b8152600401808060200182810382526029815260200180614de06029913960400191505060405180910390fd5b336000908152600560205260409020546142c2908263ffffffff61403916565b33600090815260056020526040808220929092556001600160a01b038616815220546142f4908263ffffffff613f0a16565b6001600160a01b0385166000818152600560209081526040918290209390935580518681529051919233927fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef9281900390910190a35060019392505050565b61435b614acb565b61436361495a565b8211156143a15760405162461bcd60e51b8152600401808060200182810382526036815260200180614cb76036913960400191505060405180910390fd5b50604080516020810190915269d3c21bcecceda100000082028152919050565b6143c9614acb565b815161441c576040805162461bcd60e51b815260206004820152601160248201527f63616e2774206469766964652062792030000000000000000000000000000000604482015290519081900360640190fd5b825169d3c21bcecceda10000008181029190820414614482576040805162461bcd60e51b815260206004820152601260248201527f6f766572666c6f77206174206469766964650000000000000000000000000000604482015290519081900360640190fd5b60405180602001604052808460000151838161449a57fe5b049052949350505050565b5169d3c21bcecceda1000000900490565b6000826144c557506000611bfb565b828202828482816144d257fe5b04146110d25760405162461bcd60e51b8152600401808060200182810382526021815260200180614dbf6021913960400191505060405180910390fd5b60006110d283836040518060400160405280601a81526020017f536166654d6174683a206469766973696f6e206279207a65726f000000000000815250614975565b614559614acb565b8251158061456657508151155b156145805750604080516020810190915260008152611bfb565b815169d3c21bcecceda1000000141561459a575081611bfb565b825169d3c21bcecceda100000014156145b4575080611bfb565b600069d3c21bcecceda10000006145ca856149da565b51816145d257fe5b04905060006145e085614a0f565b519050600069d3c21bcecceda10000006145f9866149da565b518161460157fe5b049050600061460f86614a0f565b5190508382028415614678578285828161462557fe5b0414614678576040805162461bcd60e51b815260206004820152601660248201527f6f766572666c6f77207831793120646574656374656400000000000000000000604482015290519081900360640190fd5b69d3c21bcecceda1000000810281156146f25769d3c21bcecceda100000082828161469f57fe5b04146146f2576040805162461bcd60e51b815260206004820152601f60248201527f6f766572666c6f772078317931202a2066697865643120646574656374656400604482015290519081900360640190fd5b905080848402851561475b578486828161470857fe5b041461475b576040805162461bcd60e51b815260206004820152601660248201527f6f766572666c6f77207832793120646574656374656400000000000000000000604482015290519081900360640190fd5b86840287156147c1578488828161476e57fe5b04146147c1576040805162461bcd60e51b815260206004820152601660248201527f6f766572666c6f77207831793220646574656374656400000000000000000000604482015290519081900360640190fd5b6147c9614a49565b87816147d157fe5b0496506147dc614a49565b85816147e457fe5b049450868502871561484d57858882816147fa57fe5b041461484d576040805162461bcd60e51b815260206004820152601660248201527f6f766572666c6f77207832793220646574656374656400000000000000000000604482015290519081900360640190fd5b614855614acb565b604051806020016040528087815250905061487e81604051806020016040528087815250614a52565b905061489881604051806020016040528086815250614a52565b90506148b281604051806020016040528085815250614a52565b9d9c50505050505050505050505050565b600081848411156149525760405162461bcd60e51b81526004018080602001828103825283818151815260200191508051906020019080838360005b838110156149175781810151838201526020016148ff565b50505050905090810190601f1680156149445780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b505050900390565b7601357c299a88ea76a58924d52ce4f26a85af186c2b9e7490565b600081836149c45760405162461bcd60e51b81526020600482018181528351602484015283519092839260449091019190850190808383600083156149175781810151838201526020016148ff565b5060008385816149d057fe5b0495945050505050565b6149e2614acb565b604051806020016040528069d3c21bcecceda100000080856000015181614a0557fe5b0402905292915050565b614a17614acb565b604051806020016040528069d3c21bcecceda100000080856000015181614a3a57fe5b95519504029093039092525090565b64e8d4a5100090565b614a5a614acb565b8151835190810190811015614ab6576040805162461bcd60e51b815260206004820152601560248201527f616464206f766572666c6f772064657465637465640000000000000000000000604482015290519081900360640190fd5b60408051602081019091529081529392505050565b6040518060200160405280600081525090565b828054600181600116156101000203166002900490600052602060002090601f016020900481019282601f10614b3d578280017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00823516178555614b6a565b82800160010185558215614b6a579182015b82811115614b6a578235825591602001919060010190614b4f565b50614b76929150614b7a565b5090565b610e7091905b80821115614b765760008155600101614b8056fe6572726f722063616c6c696e67206e756d62657256616c696461746f7273496e53657420707265636f6d70696c65696e666c6174696f6e466163746f72557064617465506572696f64206d757374206265203e20304f776e61626c653a206e6577206f776e657220697320746865207a65726f20616464726573734d7573742070726f766964652061206e6f6e2d7a65726f20696e666c6174696f6e20726174654d7573742070726f766964652061206e6f6e2d7a65726f20696e666c6174696f6e20726174652e6572726f722063616c6c696e672067657456657269666965645365616c4269746d617046726f6d48656164657220707265636f6d70696c6563616e27742063616c6c207768656e20636f6e74726163742069732066726f7a656e63616e277420637265617465206669786964697479206e756d626572206c6172676572207468616e206d61784e6577466978656428296572726f722063616c6c696e672076616c696461746f725369676e65724164647265737346726f6d43757272656e7453657420707265636f6d70696c656572726f722063616c6c696e67206e756d62657256616c696461746f7273496e43757272656e7453657420707265636f6d70696c656572726f722063616c6c696e672076616c696461746f725369676e65724164647265737346726f6d53657420707265636f6d70696c6572657365727665642061646472657373203078302063616e6e6f74206861766520616c6c6f77616e6365536166654d6174683a206d756c7469706c69636174696f6e206f766572666c6f777472616e736665722076616c75652065786365656465642062616c616e6365206f662073656e6465727472616e736665722076616c75652065786365656465642073656e646572277320616c6c6f77616e636520666f7220726563697069656e746572726f722063616c6c696e67206672616374696f6e4d756c45787020707265636f6d70696c656572726f722063616c6c696e672067657445706f636853697a6520707265636f6d70696c656572726f722063616c6c696e6720676574506172656e745365616c4269746d617020707265636f6d70696c656572726f722063616c6c696e6720676574426c6f636b4e756d62657246726f6d48656164657220707265636f6d70696c657472616e7366657220617474656d7074656420746f2072657365727665642061646472657373203078306572726f722063616c6c696e67206861736848656164657220707265636f6d70696c65a265627a7a72315820c0624207327e150a2660f10930355a78304eada0599d51eb94d6dad95e1a4b1364736f6c63430005110032

External libraries

AddressLinkedList : 0x6200f54d73491d56b8d7a975c9ee18efb4d518df  
AddressSortedLinkedListWithMedian : 0xed477a99035d0c1e11369f1d7a4e587893cc002b