Address Details
contract

0x2eFdB1371857e3765eca0Ca7EE5d8079a2D32229

Contract Name
Reserve
Creator
0xfcf982–bb718e at 0xfbeb05–a4ef40
Balance
0 CELO
Locked CELO Balance
0.00 CELO
Voting CELO Balance
0.00 CELO
Pending Unlocked Gold
0.00 CELO
Tokens
Fetching tokens...
Transactions
0 Transactions
Transfers
0 Transfers
Gas Used
Fetching gas used...
Last Balance Update
14465694
This contract has been verified via Sourcify. View contract in Sourcify repository
Contract name:
Reserve




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




Optimization runs
10000
EVM Version
istanbul




Verified at
2022-12-05T18:09:09.736996Z

contracts/Reserve.sol

pragma solidity ^0.5.13;

import "openzeppelin-solidity/contracts/math/SafeMath.sol";
import "openzeppelin-solidity/contracts/ownership/Ownable.sol";
import "openzeppelin-solidity/contracts/utils/Address.sol";

import "./interfaces/IReserve.sol";
import "./interfaces/ISortedOracles.sol";

import "./common/FixidityLib.sol";
import "./common/Initializable.sol";
import "./common/UsingRegistry.sol";
import "./common/interfaces/ICeloVersionedContract.sol";
import "./common/ReentrancyGuard.sol";

/**
 * @title Ensures price stability of StableTokens with respect to their pegs
 */
// solhint-disable-next-line max-states-count
contract Reserve is IReserve, ICeloVersionedContract, Ownable, Initializable, UsingRegistry, ReentrancyGuard {
  using SafeMath for uint256;
  using FixidityLib for FixidityLib.Fraction;
  using Address for address payable; // prettier-ignore

  struct TobinTaxCache {
    uint128 numerator;
    uint128 timestamp;
  }

  mapping(address => bool) public isToken;
  address[] private _tokens;
  TobinTaxCache public tobinTaxCache;
  uint256 public tobinTaxStalenessThreshold;
  uint256 public tobinTax;
  uint256 public tobinTaxReserveRatio;
  mapping(address => bool) public isSpender;

  mapping(address => bool) public isOtherReserveAddress;
  address[] public otherReserveAddresses;

  bytes32[] public assetAllocationSymbols;
  mapping(bytes32 => uint256) public assetAllocationWeights;

  uint256 public lastSpendingDay;
  uint256 public spendingLimit;
  FixidityLib.Fraction private spendingRatio;

  uint256 public frozenReserveGoldStartBalance;
  uint256 public frozenReserveGoldStartDay;
  uint256 public frozenReserveGoldDays;

  mapping(address => bool) public isExchangeSpender;
  address[] public exchangeSpenderAddresses;
  mapping(address => FixidityLib.Fraction) private collateralAssetDailySpendingRatio;
  mapping(address => uint256) public collateralAssetLastSpendingDay;
  address[] public collateralAssets;
  mapping(address => bool) public isCollateralAsset;

  event TobinTaxStalenessThresholdSet(uint256 value);
  event DailySpendingRatioSet(uint256 ratio);
  event TokenAdded(address indexed token);
  event TokenRemoved(address indexed token, uint256 index);
  event SpenderAdded(address indexed spender);
  event SpenderRemoved(address indexed spender);
  event OtherReserveAddressAdded(address indexed otherReserveAddress);
  event OtherReserveAddressRemoved(address indexed otherReserveAddress, uint256 index);
  event AssetAllocationSet(bytes32[] symbols, uint256[] weights);
  event ReserveGoldTransferred(address indexed spender, address indexed to, uint256 value);
  event TobinTaxSet(uint256 value);
  event TobinTaxReserveRatioSet(uint256 value);
  event ExchangeSpenderAdded(address indexed exchangeSpender);
  event ExchangeSpenderRemoved(address indexed exchangeSpender);
  event DailySpendingRatioForCollateralAssetSet(address collateralAsset, uint256 collateralAssetDailySpendingRatios);
  event ReserveCollateralAssetsTransferred(address indexed spender, address indexed to, uint256 value, address token);
  event CollateralAssetRemoved(address collateralAsset);
  event CollateralAssetAdded(address collateralAsset);

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

  modifier isStableToken(address token) {
    require(isToken[token], "token addr was never registered");
    _;
  }

  /**
   * @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 (2, 1, 0, 0);
  }

  function() external payable {} // solhint-disable no-empty-blocks

  /**
   * @notice Used in place of the constructor to allow the contract to be upgradable via proxy.
   * @param registryAddress The address of the registry core smart contract.
   * @param _tobinTaxStalenessThreshold The initial number of seconds to cache tobin tax value for.
   * @param _spendingRatioForCelo The relative daily spending limit for the reserve spender.
   * @param _frozenGold The balance of reserve gold that is frozen.
   * @param _frozenDays The number of days during which the frozen gold thaws.
   * @param _assetAllocationSymbols The symbols of the reserve assets.
   * @param _assetAllocationWeights The reserve asset weights.
   * @param _tobinTax The tobin tax value as a fixidity fraction.
   * @param _tobinTaxReserveRatio When to turn on the tobin tax, as a fixidity fraction.
   * @param _collateralAssets The relative daily spending limit
   * of an ERC20 collateral asset for the reserve spender.
   * @param _collateralAssetDailySpendingRatios The address of an ERC20 collateral asset
   */
  function initialize(
    address registryAddress,
    uint256 _tobinTaxStalenessThreshold,
    uint256 _spendingRatioForCelo,
    uint256 _frozenGold,
    uint256 _frozenDays,
    bytes32[] calldata _assetAllocationSymbols,
    uint256[] calldata _assetAllocationWeights,
    uint256 _tobinTax,
    uint256 _tobinTaxReserveRatio,
    address[] calldata _collateralAssets,
    uint256[] calldata _collateralAssetDailySpendingRatios
  ) external initializer {
    _transferOwnership(msg.sender);
    setRegistry(registryAddress);
    setTobinTaxStalenessThreshold(_tobinTaxStalenessThreshold);
    setDailySpendingRatio(_spendingRatioForCelo);
    setFrozenGold(_frozenGold, _frozenDays);
    setAssetAllocations(_assetAllocationSymbols, _assetAllocationWeights);
    setTobinTax(_tobinTax);
    setTobinTaxReserveRatio(_tobinTaxReserveRatio);
    for (uint256 i = 0; i < _collateralAssets.length; i++) {
      addCollateralAsset(_collateralAssets[i]);
    }
    setDailySpendingRatioForCollateralAssets(_collateralAssets, _collateralAssetDailySpendingRatios);
  }

  /**
   * @notice Sets the number of seconds to cache the tobin tax value for.
   * @param value The number of seconds to cache the tobin tax value for.
   */
  function setTobinTaxStalenessThreshold(uint256 value) public onlyOwner {
    require(value > 0, "value was zero");
    tobinTaxStalenessThreshold = value;
    emit TobinTaxStalenessThresholdSet(value);
  }

  /**
   * @notice Sets the tobin tax.
   * @param value The tobin tax.
   */
  function setTobinTax(uint256 value) public onlyOwner {
    require(FixidityLib.wrap(value).lte(FixidityLib.fixed1()), "tobin tax cannot be larger than 1");
    tobinTax = value;
    emit TobinTaxSet(value);
  }

  /**
   * @notice Sets the reserve ratio at which the tobin tax sets in.
   * @param value The reserve ratio at which the tobin tax sets in.
   */
  function setTobinTaxReserveRatio(uint256 value) public onlyOwner {
    tobinTaxReserveRatio = value;
    emit TobinTaxReserveRatioSet(value);
  }

  /**
   * @notice Set the ratio of reserve that is spendable per day.
   * @param ratio Spending ratio as unwrapped Fraction.
   */
  function setDailySpendingRatio(uint256 ratio) public onlyOwner {
    spendingRatio = FixidityLib.wrap(ratio);
    require(spendingRatio.lte(FixidityLib.fixed1()), "spending ratio cannot be larger than 1");
    emit DailySpendingRatioSet(ratio);
  }

  /**
   * @notice Set the ratio of reserve for a given collateral asset
   * that is spendable per day.
   * @param _collateralAssets Collection of the addresses of collateral assets
   * we're setting a limit for.
   * @param collateralAssetDailySpendingRatios Collection of the relative daily spending limits
   * of collateral assets.
   */
  function setDailySpendingRatioForCollateralAssets(
    address[] memory _collateralAssets,
    uint256[] memory collateralAssetDailySpendingRatios
  ) public onlyOwner {
    require(
      _collateralAssets.length == collateralAssetDailySpendingRatios.length,
      "token addresses and spending ratio lengths have to be the same"
    );
    for (uint256 i = 0; i < _collateralAssets.length; i++) {
      if (_collateralAssets[i] != address(0) && collateralAssetDailySpendingRatios[i] != 0) {
        require(
          checkIsCollateralAsset(_collateralAssets[i]),
          "the address specified is not a reserve collateral asset"
        );
        require(
          FixidityLib.wrap(collateralAssetDailySpendingRatios[i]).lte(FixidityLib.fixed1()),
          "spending ratio cannot be larger than 1"
        );
        collateralAssetDailySpendingRatio[_collateralAssets[i]] = FixidityLib.wrap(
          collateralAssetDailySpendingRatios[i]
        );
        emit DailySpendingRatioForCollateralAssetSet(_collateralAssets[i], collateralAssetDailySpendingRatios[i]);
      }
    }
  }

  /**
   * @notice Get daily spending ratio.
   * @return Spending ratio as unwrapped Fraction.
   */
  function getDailySpendingRatio() public view returns (uint256) {
    return spendingRatio.unwrap();
  }

  /**
   * @notice Get daily spending ratio of a collateral asset.
   * @param collateralAsset The address of a collateral asset we're getting a spending ratio for.
   * @return Daily spending ratio for the collateral asset as unwrapped Fraction.
   */
  function getDailySpendingRatioForCollateralAsset(address collateralAsset) public view returns (uint256) {
    return collateralAssetDailySpendingRatio[collateralAsset].unwrap();
  }

  /**
   * @notice Sets the balance of reserve gold frozen from transfer.
   * @param frozenGold The amount of CELO frozen.
   * @param frozenDays The number of days the frozen CELO thaws over.
   */
  function setFrozenGold(uint256 frozenGold, uint256 frozenDays) public onlyOwner {
    require(frozenGold <= address(this).balance, "Cannot freeze more than balance");
    frozenReserveGoldStartBalance = frozenGold;
    frozenReserveGoldStartDay = now / 1 days;
    frozenReserveGoldDays = frozenDays;
  }

  /**
   * @notice Sets target allocations for CELO and a diversified basket of non-Celo assets.
   * @param symbols The symbol of each asset in the Reserve portfolio.
   * @param weights The weight for the corresponding asset as unwrapped Fixidity.Fraction.
   */
  function setAssetAllocations(bytes32[] memory symbols, uint256[] memory weights) public onlyOwner {
    require(symbols.length == weights.length, "Array length mismatch");
    FixidityLib.Fraction memory sum = FixidityLib.wrap(0);
    for (uint256 i = 0; i < weights.length; i = i.add(1)) {
      sum = sum.add(FixidityLib.wrap(weights[i]));
    }
    require(sum.equals(FixidityLib.fixed1()), "Sum of asset allocation must be 1");
    for (uint256 i = 0; i < assetAllocationSymbols.length; i = i.add(1)) {
      delete assetAllocationWeights[assetAllocationSymbols[i]];
    }
    assetAllocationSymbols = symbols;
    for (uint256 i = 0; i < symbols.length; i = i.add(1)) {
      require(assetAllocationWeights[symbols[i]] == 0, "Cannot set weight twice");
      assetAllocationWeights[symbols[i]] = weights[i];
    }
    // NOTE: The CELO asset launched as "Celo Gold" (cGLD), but was renamed to
    // just CELO by the community.
    // TODO: Change "cGLD" to "CELO" in this file, after ensuring that any
    // off chain tools working with asset allocation weights are aware of this
    // change.
    require(assetAllocationWeights["cGLD"] != 0, "Must set cGLD asset weight");
    emit AssetAllocationSet(symbols, weights);
  }

  /**
   * @notice Add a token that the reserve will stabilize.
   * @param token The address of the token being stabilized.
   * @return Returns true if the transaction succeeds.
   */
  function addToken(address token) external onlyOwner nonReentrant returns (bool) {
    require(!isToken[token], "token addr already registered");
    isToken[token] = true;
    _tokens.push(token);
    emit TokenAdded(token);
    return true;
  }

  /**
   * @notice Remove a token that the reserve will no longer stabilize.
   * @param token The address of the token no longer being stabilized.
   * @param index The index of the token in _tokens.
   * @return Returns true if the transaction succeeds.
   */
  function removeToken(address token, uint256 index) external onlyOwner isStableToken(token) returns (bool) {
    require(index < _tokens.length && _tokens[index] == token, "index into tokens list not mapped to token");
    isToken[token] = false;
    address lastItem = _tokens[_tokens.length.sub(1)];
    _tokens[index] = lastItem;
    _tokens.length = _tokens.length.sub(1);
    emit TokenRemoved(token, index);
    return true;
  }

  /**
   * @notice Add a reserve address whose balance shall be included in the reserve ratio.
   * @param reserveAddress The reserve address to add.
   * @return Returns true if the transaction succeeds.
   */
  function addOtherReserveAddress(address reserveAddress) external onlyOwner nonReentrant returns (bool) {
    require(!isOtherReserveAddress[reserveAddress], "reserve addr already added");
    isOtherReserveAddress[reserveAddress] = true;
    otherReserveAddresses.push(reserveAddress);
    emit OtherReserveAddressAdded(reserveAddress);
    return true;
  }

  /**
   * @notice Remove reserve address whose balance shall no longer be included in the reserve ratio.
   * @param reserveAddress The reserve address to remove.
   * @param index The index of the reserve address in otherReserveAddresses.
   * @return Returns true if the transaction succeeds.
   */
  function removeOtherReserveAddress(address reserveAddress, uint256 index) external onlyOwner returns (bool) {
    require(isOtherReserveAddress[reserveAddress], "reserve addr was never added");
    require(
      index < otherReserveAddresses.length && otherReserveAddresses[index] == reserveAddress,
      "index into reserve list not mapped to address"
    );
    isOtherReserveAddress[reserveAddress] = false;
    address lastItem = otherReserveAddresses[otherReserveAddresses.length.sub(1)];
    otherReserveAddresses[index] = lastItem;
    otherReserveAddresses.length = otherReserveAddresses.length.sub(1);
    emit OtherReserveAddressRemoved(reserveAddress, index);
    return true;
  }

  /**
   * @notice Gives an address permission to spend Reserve funds.
   * @param spender The address that is allowed to spend Reserve funds.
   */
  function addSpender(address spender) external onlyOwner {
    require(address(0) != spender, "Spender can't be null");
    isSpender[spender] = true;
    emit SpenderAdded(spender);
  }

  /**
   * @notice Takes away an address's permission to spend Reserve funds.
   * @param spender The address that is to be no longer allowed to spend Reserve funds.
   */
  function removeSpender(address spender) external onlyOwner {
    isSpender[spender] = false;
    emit SpenderRemoved(spender);
  }

  /**
   * @notice Checks if an address is able to spend as an exchange.
   * @dev isExchangeSpender was introduced after cUSD, so the cUSD Exchange is not included in it.
   * If cUSD's Exchange were to be added to isExchangeSpender, the check with the
   * registry could be removed.
   * @param spender The address to be checked.
   */
  modifier isAllowedToSpendExchange(address spender) {
    require(
      isExchangeSpender[spender] || (registry.getAddressForOrDie(EXCHANGE_REGISTRY_ID) == spender),
      "Address not allowed to spend"
    );
    _;
  }

  /**
   * @notice Gives an address permission to spend Reserve without limit.
   * @param spender The address that is allowed to spend Reserve funds.
   */
  function addExchangeSpender(address spender) external onlyOwner {
    require(address(0) != spender, "Spender can't be null");
    require(!isExchangeSpender[spender], "Address is already Exchange Spender");
    isExchangeSpender[spender] = true;
    exchangeSpenderAddresses.push(spender);
    emit ExchangeSpenderAdded(spender);
  }

  /**
   * @notice Takes away an address's permission to spend Reserve funds without limits.
   * @param spender The address that is to be no longer allowed to spend Reserve funds.
   * @param index The index in exchangeSpenderAddresses of spender.
   */
  function removeExchangeSpender(address spender, uint256 index) external onlyOwner {
    isExchangeSpender[spender] = false;
    uint256 numAddresses = exchangeSpenderAddresses.length;
    require(index < numAddresses, "Index is invalid");
    require(spender == exchangeSpenderAddresses[index], "Index does not match spender");
    uint256 newNumAddresses = numAddresses.sub(1);

    if (index != newNumAddresses) {
      exchangeSpenderAddresses[index] = exchangeSpenderAddresses[newNumAddresses];
    }

    exchangeSpenderAddresses[newNumAddresses] = address(0x0);
    exchangeSpenderAddresses.length = newNumAddresses;
    emit ExchangeSpenderRemoved(spender);
  }

  /**
   * @notice Returns addresses of exchanges permitted to spend Reserve funds.
   * Because exchangeSpenderAddresses was introduced after cUSD, cUSD's exchange
   * is not included in this list.
   * @return An array of addresses permitted to spend Reserve funds.
   */
  function getExchangeSpenders() external view returns (address[] memory) {
    return exchangeSpenderAddresses;
  }

  /**
   * @notice Transfer gold to a whitelisted address subject to reserve spending limits.
   * @param to The address that will receive the gold.
   * @param value The amount of gold to transfer.
   * @return Returns true if the transaction succeeds.
   */
  function transferGold(address payable to, uint256 value) external returns (bool) {
    require(isSpender[msg.sender], "sender not allowed to transfer Reserve funds");
    require(isOtherReserveAddress[to], "can only transfer to other reserve address");
    uint256 currentDay = now / 1 days;
    if (currentDay > lastSpendingDay) {
      uint256 balance = getUnfrozenReserveGoldBalance();
      lastSpendingDay = currentDay;
      spendingLimit = spendingRatio.multiply(FixidityLib.newFixed(balance)).fromFixed();
    }
    require(spendingLimit >= value, "Exceeding spending limit");
    spendingLimit = spendingLimit.sub(value);
    return _transferGold(to, value);
  }

  /**
   * @notice Transfer collateral asset subject to reserve spending limits to the trader,
   * if the limit is set, othersise the limit is 100%.
   * @param collateralAsset The token address you're transferring.
   * @param to The address that will receive the funds.
   * @param value The amount of collateral assets to transfer.
   * @return Returns true if the transaction succeeds.
   */
  function transferCollateralAsset(
    address collateralAsset,
    address payable to,
    uint256 value
  ) external returns (bool) {
    require(isSpender[msg.sender], "sender not allowed to transfer Reserve funds");
    require(to != address(0), "can not transfer to 0 address");
    require(
      getDailySpendingRatioForCollateralAsset(collateralAsset) > 0,
      "this asset has no spending ratio, therefore can't be transferred"
    );
    uint256 spendingLimitForThisAsset;
    uint256 currentDay = now / 1 days;
    if (currentDay > collateralAssetLastSpendingDay[collateralAsset]) {
      uint256 balance = getReserveAddressesCollateralAssetBalance(collateralAsset);
      collateralAssetLastSpendingDay[collateralAsset] = currentDay;
      spendingLimitForThisAsset = collateralAssetDailySpendingRatio[collateralAsset]
        .multiply(FixidityLib.newFixed(balance))
        .fromFixed();
    }
    require(spendingLimitForThisAsset >= value, "Exceeding spending limit");
    spendingLimitForThisAsset = spendingLimitForThisAsset.sub(value);
    return _transferCollateralAsset(collateralAsset, to, value);
  }

  /**
   * @notice Transfer collateral asset to any address.
   * @param collateralAsset The token address you're transferring.
   * @param to The address that will receive the funds.
   * @param value The amount of collateral assets to transfer.
   * @return Returns true if the transaction succeeds.
   */
  function _transferCollateralAsset(
    address collateralAsset,
    address payable to,
    uint256 value
  ) internal returns (bool) {
    require(value <= getReserveAddressesCollateralAssetBalance(collateralAsset), "Exceeding the amount reserve holds");
    IERC20(collateralAsset).transfer(to, value);
    emit ReserveCollateralAssetsTransferred(msg.sender, to, value, collateralAsset);
    return true;
  }

  /**
   * @notice Transfer unfrozen gold to any address.
   * @param to The address that will receive the gold.
   * @param value The amount of gold to transfer.
   * @return Returns true if the transaction succeeds.
   */
  function _transferGold(address payable to, uint256 value) internal returns (bool) {
    require(value <= getUnfrozenBalance(), "Exceeding unfrozen reserves");
    to.sendValue(value);
    emit ReserveGoldTransferred(msg.sender, to, value);
    return true;
  }

  /**
   * @notice Transfer unfrozen gold to any address, used for one side of CP-DOTO.
   * @dev Transfers are not subject to a daily spending limit.
   * @param to The address that will receive the gold.
   * @param value The amount of gold to transfer.
   * @return Returns true if the transaction succeeds.
   */
  function transferExchangeGold(address payable to, uint256 value)
    external
    isAllowedToSpendExchange(msg.sender)
    returns (bool)
  {
    return _transferGold(to, value);
  }

  /**
   * @notice Returns the tobin tax, recomputing it if it's stale.
   * @return The numerator - tobin tax amount as a fraction.
   * @return The denominator - tobin tax amount as a fraction.
   */
  function getOrComputeTobinTax() external nonReentrant returns (uint256, uint256) {
    // solhint-disable-next-line not-rely-on-time
    if (now.sub(tobinTaxCache.timestamp) > tobinTaxStalenessThreshold) {
      tobinTaxCache.numerator = uint128(computeTobinTax().unwrap());
      tobinTaxCache.timestamp = uint128(now); // solhint-disable-line not-rely-on-time
    }
    return (uint256(tobinTaxCache.numerator), FixidityLib.fixed1().unwrap());
  }

  /**
   * @notice Returns the list of stabilized token addresses.
   * @return An array of addresses of stabilized tokens.
   */
  function getTokens() external view returns (address[] memory) {
    return _tokens;
  }

  /**
   * @notice Returns the list other addresses included in the reserve total.
   * @return An array of other addresses included in the reserve total.
   */
  function getOtherReserveAddresses() external view returns (address[] memory) {
    return otherReserveAddresses;
  }

  /**
   * @notice Returns a list of token symbols that have been allocated.
   * @return An array of token symbols that have been allocated.
   */
  function getAssetAllocationSymbols() external view returns (bytes32[] memory) {
    return assetAllocationSymbols;
  }

  /**
   * @notice Returns a list of weights used for the allocation of reserve assets.
   * @return An array of a list of weights used for the allocation of reserve assets.
   */
  function getAssetAllocationWeights() external view returns (uint256[] memory) {
    uint256[] memory weights = new uint256[](assetAllocationSymbols.length);
    for (uint256 i = 0; i < assetAllocationSymbols.length; i = i.add(1)) {
      weights[i] = assetAllocationWeights[assetAllocationSymbols[i]];
    }
    return weights;
  }

  /**
   * @notice Returns the amount of unfrozen CELO in the reserve.
   * @return The total unfrozen CELO in the reserve.
   */
  function getUnfrozenBalance() public view returns (uint256) {
    uint256 balance = address(this).balance;
    uint256 frozenReserveGold = getFrozenReserveGoldBalance();
    return balance > frozenReserveGold ? balance.sub(frozenReserveGold) : 0;
  }

  /**
   * @notice Returns the amount of CELO included in the reserve.
   * @return The CELO amount included in the reserve.
   */
  function getReserveGoldBalance() public view returns (uint256) {
    return address(this).balance.add(getOtherReserveAddressesGoldBalance());
  }

  /**
   * @notice Returns the amount of CELO included in other reserve addresses.
   * @return The CELO amount included in other reserve addresses.
   */
  function getOtherReserveAddressesGoldBalance() public view returns (uint256) {
    uint256 reserveGoldBalance = 0;
    for (uint256 i = 0; i < otherReserveAddresses.length; i = i.add(1)) {
      reserveGoldBalance = reserveGoldBalance.add(otherReserveAddresses[i].balance);
    }
    return reserveGoldBalance;
  }

  /**
   * @notice Returns the amount of unfrozen CELO included in the reserve.
   * @return The unfrozen CELO amount included in the reserve.
   */
  function getUnfrozenReserveGoldBalance() public view returns (uint256) {
    return getUnfrozenBalance().add(getOtherReserveAddressesGoldBalance());
  }

  /**
   * @notice Returns the amount of particular collateral asset
   * in reserve including other reserve addresses.
   * @param collateralAsset the asset we're checking a balance of
   * @return The balance of particular collateral asset.
   */
  function getReserveAddressesCollateralAssetBalance(address collateralAsset) public view returns (uint256) {
    require(checkIsCollateralAsset(collateralAsset), "specified address is not a collateral asset");
    uint256 reserveCollateralAssetBalance = 0;
    for (uint256 i = 0; i < otherReserveAddresses.length; i++) {
      reserveCollateralAssetBalance = reserveCollateralAssetBalance.add(
        IERC20(collateralAsset).balanceOf(otherReserveAddresses[i])
      );
    }
    return reserveCollateralAssetBalance.add(IERC20(collateralAsset).balanceOf(address(this)));
  }

  /**
   * @notice Add a collateral asset in the reserve.
   * @param collateralAsset The address of the token being added.
   * @return Returns true if the transaction succeeds.
   */
  function addCollateralAsset(address collateralAsset) public onlyOwner returns (bool) {
    require(!checkIsCollateralAsset(collateralAsset), "specified address is already added as a collateral asset");
    require(collateralAsset != address(0), "can't be a zero address");
    isCollateralAsset[collateralAsset] = true;
    collateralAssets.push(collateralAsset);
    emit CollateralAssetAdded(collateralAsset);
    return true;
  }

  /**
   * @notice Remove a collateral asset in the reserve.
   * @param collateralAsset The address of the token being removed.
   * @param index The index of the token being removed.
   * @return Returns true if the transaction succeeds.
   */
  function removeCollateralAsset(address collateralAsset, uint256 index) external onlyOwner returns (bool) {
    require(checkIsCollateralAsset(collateralAsset), "specified address is not a collateral asset");
    require(
      index < collateralAssets.length && collateralAssets[index] == collateralAsset,
      "index into collateralAssets list not mapped to token"
    );
    collateralAssets[index] = collateralAssets[collateralAssets.length - 1];
    collateralAssets.pop();
    delete isCollateralAsset[collateralAsset];
    emit CollateralAssetRemoved(collateralAsset);
    return true;
  }

  /**
   * @notice Check if a collateral asset is added to the reserve.
   * @param collateralAsset The address of the token being checked.
   * @return Returns true if the token was added as a collateral asset.
   */
  function checkIsCollateralAsset(address collateralAsset) public view returns (bool) {
    return isCollateralAsset[collateralAsset];
  }

  /**
   * @notice Returns the amount of frozen CELO in the reserve.
   * @return The total frozen CELO in the reserve.
   */
  function getFrozenReserveGoldBalance() public view returns (uint256) {
    uint256 currentDay = now / 1 days;
    uint256 frozenDays = currentDay.sub(frozenReserveGoldStartDay);
    if (frozenDays >= frozenReserveGoldDays) return 0;
    return frozenReserveGoldStartBalance.sub(frozenReserveGoldStartBalance.mul(frozenDays).div(frozenReserveGoldDays));
  }

  /**
   * @notice Computes the ratio of current reserve balance to total stable token valuation.
   * @return Reserve ratio in a fixed point format.
   */
  function getReserveRatio() public view returns (uint256) {
    address sortedOraclesAddress = registry.getAddressForOrDie(SORTED_ORACLES_REGISTRY_ID);
    ISortedOracles sortedOracles = ISortedOracles(sortedOraclesAddress);
    uint256 reserveGoldBalance = getUnfrozenReserveGoldBalance();
    uint256 stableTokensValueInGold = 0;
    FixidityLib.Fraction memory cgldWeight = FixidityLib.wrap(assetAllocationWeights["cGLD"]);

    for (uint256 i = 0; i < _tokens.length; i = i.add(1)) {
      uint256 stableAmount;
      uint256 goldAmount;
      (stableAmount, goldAmount) = sortedOracles.medianRate(_tokens[i]);

      if (goldAmount != 0) {
        // tokens with no oracle reports don't count towards collateralization ratio
        uint256 stableTokenSupply = IERC20(_tokens[i]).totalSupply();
        uint256 aStableTokenValueInGold = stableTokenSupply.mul(goldAmount).div(stableAmount);
        stableTokensValueInGold = stableTokensValueInGold.add(aStableTokenValueInGold);
      }
    }
    return
      FixidityLib
        .newFixed(reserveGoldBalance)
        .divide(cgldWeight)
        .divide(FixidityLib.newFixed(stableTokensValueInGold))
        .unwrap();
  }

  /*
   * Internal functions
   */

  /**
   * @notice Computes a tobin tax based on the reserve ratio.
   * @return The tobin tax expresesed as a fixidity fraction.
   */
  function computeTobinTax() private view returns (FixidityLib.Fraction memory) {
    FixidityLib.Fraction memory ratio = FixidityLib.wrap(getReserveRatio());
    if (ratio.gte(FixidityLib.wrap(tobinTaxReserveRatio))) {
      return FixidityLib.wrap(0);
    } else {
      return FixidityLib.wrap(tobinTax);
    }
  }

  function isStableAsset(address token) external view returns (bool) {
    return isToken[token];
  }
}
        

/contracts/interfaces/IStableToken.sol

pragma solidity ^0.5.13;

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

  function burn(uint256) external returns (bool);

  function setInflationParameters(uint256, uint256) external;

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

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

  function getInflationParameters()
    external
    view
    returns (
      uint256,
      uint256,
      uint256,
      uint256
    );

  function getExchangeRegistryId() external view returns (bytes32);

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

/contracts/interfaces/ISortedOracles.sol

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 previousMedianRate(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/openzeppelin-contracts/contracts/utils/Address.sol

pragma solidity ^0.5.5;

/**
 * @dev Collection of functions related to the address type
 */
library Address {
    /**
     * @dev Returns true if `account` is a contract.
     *
     * [IMPORTANT]
     * ====
     * It is unsafe to assume that an address for which this function returns
     * false is an externally-owned account (EOA) and not a contract.
     *
     * Among others, `isContract` will return false for the following 
     * types of addresses:
     *
     *  - an externally-owned account
     *  - a contract in construction
     *  - an address where a contract will be created
     *  - an address where a contract lived, but was destroyed
     * ====
     */
    function isContract(address account) internal view returns (bool) {
        // According to EIP-1052, 0x0 is the value returned for not-yet created accounts
        // and 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470 is returned
        // for accounts without code, i.e. `keccak256('')`
        bytes32 codehash;
        bytes32 accountHash = 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470;
        // solhint-disable-next-line no-inline-assembly
        assembly { codehash := extcodehash(account) }
        return (codehash != accountHash && codehash != 0x0);
    }

    /**
     * @dev Converts an `address` into `address payable`. Note that this is
     * simply a type cast: the actual underlying value is not changed.
     *
     * _Available since v2.4.0._
     */
    function toPayable(address account) internal pure returns (address payable) {
        return address(uint160(account));
    }

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

        // solhint-disable-next-line avoid-call-value
        (bool success, ) = recipient.call.value(amount)("");
        require(success, "Address: unable to send value, recipient may have reverted");
    }
}
          

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

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

/contracts/interfaces/IReserve.sol

pragma solidity ^0.5.13;

interface IReserve {
  function setTobinTaxStalenessThreshold(uint256) external;

  function addToken(address) external returns (bool);

  function removeToken(address, uint256) external returns (bool);

  function transferGold(address payable, uint256) external returns (bool);

  function transferExchangeGold(address payable, uint256) external returns (bool);

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

/contracts/interfaces/IExchange.sol

pragma solidity ^0.5.13;

interface IExchange {
  function buy(
    uint256,
    uint256,
    bool
  ) external returns (uint256);

  function sell(
    uint256,
    uint256,
    bool
  ) external returns (uint256);

  function exchange(
    uint256,
    uint256,
    bool
  ) external returns (uint256);

  function setUpdateFrequency(uint256) external;

  function getBuyTokenAmount(uint256, bool) external view returns (uint256);

  function getSellTokenAmount(uint256, bool) external view returns (uint256);

  function getBuyAndSellBuckets(bool) external view returns (uint256, uint256);
}
          

/contracts/common/linkedlists/SortedLinkedListWithMedian.sol

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

/contracts/common/linkedlists/SortedLinkedList.sol

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

/contracts/common/linkedlists/LinkedList.sol

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

/contracts/common/interfaces/IRegistry.sol

pragma solidity ^0.5.13;

interface IRegistry {
  function setAddressFor(string calldata, address) external;

  function getAddressForOrDie(bytes32) external view returns (address);

  function getAddressFor(bytes32) external view returns (address);

  function getAddressForStringOrDie(string calldata identifier) external view returns (address);

  function getAddressForString(string calldata identifier) external view returns (address);

  function isOneOf(bytes32[] calldata, address) external view returns (bool);
}
          

/contracts/common/interfaces/IFreezer.sol

pragma solidity ^0.5.13;

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

/contracts/common/interfaces/ICeloVersionedContract.sol

pragma solidity ^0.5.13;

interface ICeloVersionedContract {
  /**
   * @notice Returns the storage, major, minor, and patch version of the contract.
   * @return 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
    );
}
          

/contracts/common/UsingRegistry.sol

pragma solidity ^0.5.13;

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

import "./interfaces/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));
  }
}
          

/contracts/common/ReentrancyGuard.sol

pragma solidity ^0.5.13;

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

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

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

/contracts/common/Initializable.sol

pragma solidity ^0.5.13;

contract Initializable {
  bool public initialized;

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

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

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

Contract ABI

[{"type":"constructor","stateMutability":"nonpayable","payable":false,"inputs":[{"type":"bool","name":"test","internalType":"bool"}]},{"type":"event","name":"AssetAllocationSet","inputs":[{"type":"bytes32[]","name":"symbols","internalType":"bytes32[]","indexed":false},{"type":"uint256[]","name":"weights","internalType":"uint256[]","indexed":false}],"anonymous":false},{"type":"event","name":"CollateralAssetAdded","inputs":[{"type":"address","name":"collateralAsset","internalType":"address","indexed":false}],"anonymous":false},{"type":"event","name":"CollateralAssetRemoved","inputs":[{"type":"address","name":"collateralAsset","internalType":"address","indexed":false}],"anonymous":false},{"type":"event","name":"DailySpendingRatioForCollateralAssetSet","inputs":[{"type":"address","name":"collateralAsset","internalType":"address","indexed":false},{"type":"uint256","name":"collateralAssetDailySpendingRatios","internalType":"uint256","indexed":false}],"anonymous":false},{"type":"event","name":"DailySpendingRatioSet","inputs":[{"type":"uint256","name":"ratio","internalType":"uint256","indexed":false}],"anonymous":false},{"type":"event","name":"ExchangeSpenderAdded","inputs":[{"type":"address","name":"exchangeSpender","internalType":"address","indexed":true}],"anonymous":false},{"type":"event","name":"ExchangeSpenderRemoved","inputs":[{"type":"address","name":"exchangeSpender","internalType":"address","indexed":true}],"anonymous":false},{"type":"event","name":"OtherReserveAddressAdded","inputs":[{"type":"address","name":"otherReserveAddress","internalType":"address","indexed":true}],"anonymous":false},{"type":"event","name":"OtherReserveAddressRemoved","inputs":[{"type":"address","name":"otherReserveAddress","internalType":"address","indexed":true},{"type":"uint256","name":"index","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":"ReserveCollateralAssetsTransferred","inputs":[{"type":"address","name":"spender","internalType":"address","indexed":true},{"type":"address","name":"to","internalType":"address","indexed":true},{"type":"uint256","name":"value","internalType":"uint256","indexed":false},{"type":"address","name":"token","internalType":"address","indexed":false}],"anonymous":false},{"type":"event","name":"ReserveGoldTransferred","inputs":[{"type":"address","name":"spender","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":"SpenderAdded","inputs":[{"type":"address","name":"spender","internalType":"address","indexed":true}],"anonymous":false},{"type":"event","name":"SpenderRemoved","inputs":[{"type":"address","name":"spender","internalType":"address","indexed":true}],"anonymous":false},{"type":"event","name":"TobinTaxReserveRatioSet","inputs":[{"type":"uint256","name":"value","internalType":"uint256","indexed":false}],"anonymous":false},{"type":"event","name":"TobinTaxSet","inputs":[{"type":"uint256","name":"value","internalType":"uint256","indexed":false}],"anonymous":false},{"type":"event","name":"TobinTaxStalenessThresholdSet","inputs":[{"type":"uint256","name":"value","internalType":"uint256","indexed":false}],"anonymous":false},{"type":"event","name":"TokenAdded","inputs":[{"type":"address","name":"token","internalType":"address","indexed":true}],"anonymous":false},{"type":"event","name":"TokenRemoved","inputs":[{"type":"address","name":"token","internalType":"address","indexed":true},{"type":"uint256","name":"index","internalType":"uint256","indexed":false}],"anonymous":false},{"type":"fallback","stateMutability":"payable","payable":true},{"type":"function","stateMutability":"nonpayable","payable":false,"outputs":[{"type":"bool","name":"","internalType":"bool"}],"name":"addCollateralAsset","inputs":[{"type":"address","name":"collateralAsset","internalType":"address"}],"constant":false},{"type":"function","stateMutability":"nonpayable","payable":false,"outputs":[],"name":"addExchangeSpender","inputs":[{"type":"address","name":"spender","internalType":"address"}],"constant":false},{"type":"function","stateMutability":"nonpayable","payable":false,"outputs":[{"type":"bool","name":"","internalType":"bool"}],"name":"addOtherReserveAddress","inputs":[{"type":"address","name":"reserveAddress","internalType":"address"}],"constant":false},{"type":"function","stateMutability":"nonpayable","payable":false,"outputs":[],"name":"addSpender","inputs":[{"type":"address","name":"spender","internalType":"address"}],"constant":false},{"type":"function","stateMutability":"nonpayable","payable":false,"outputs":[{"type":"bool","name":"","internalType":"bool"}],"name":"addToken","inputs":[{"type":"address","name":"token","internalType":"address"}],"constant":false},{"type":"function","stateMutability":"view","payable":false,"outputs":[{"type":"bytes32","name":"","internalType":"bytes32"}],"name":"assetAllocationSymbols","inputs":[{"type":"uint256","name":"","internalType":"uint256"}],"constant":true},{"type":"function","stateMutability":"view","payable":false,"outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"assetAllocationWeights","inputs":[{"type":"bytes32","name":"","internalType":"bytes32"}],"constant":true},{"type":"function","stateMutability":"view","payable":false,"outputs":[{"type":"bool","name":"","internalType":"bool"}],"name":"checkIsCollateralAsset","inputs":[{"type":"address","name":"collateralAsset","internalType":"address"}],"constant":true},{"type":"function","stateMutability":"view","payable":false,"outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"collateralAssetLastSpendingDay","inputs":[{"type":"address","name":"","internalType":"address"}],"constant":true},{"type":"function","stateMutability":"view","payable":false,"outputs":[{"type":"address","name":"","internalType":"address"}],"name":"collateralAssets","inputs":[{"type":"uint256","name":"","internalType":"uint256"}],"constant":true},{"type":"function","stateMutability":"view","payable":false,"outputs":[{"type":"address","name":"","internalType":"address"}],"name":"exchangeSpenderAddresses","inputs":[{"type":"uint256","name":"","internalType":"uint256"}],"constant":true},{"type":"function","stateMutability":"view","payable":false,"outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"frozenReserveGoldDays","inputs":[],"constant":true},{"type":"function","stateMutability":"view","payable":false,"outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"frozenReserveGoldStartBalance","inputs":[],"constant":true},{"type":"function","stateMutability":"view","payable":false,"outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"frozenReserveGoldStartDay","inputs":[],"constant":true},{"type":"function","stateMutability":"view","payable":false,"outputs":[{"type":"bytes32[]","name":"","internalType":"bytes32[]"}],"name":"getAssetAllocationSymbols","inputs":[],"constant":true},{"type":"function","stateMutability":"view","payable":false,"outputs":[{"type":"uint256[]","name":"","internalType":"uint256[]"}],"name":"getAssetAllocationWeights","inputs":[],"constant":true},{"type":"function","stateMutability":"view","payable":false,"outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"getDailySpendingRatio","inputs":[],"constant":true},{"type":"function","stateMutability":"view","payable":false,"outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"getDailySpendingRatioForCollateralAsset","inputs":[{"type":"address","name":"collateralAsset","internalType":"address"}],"constant":true},{"type":"function","stateMutability":"view","payable":false,"outputs":[{"type":"address[]","name":"","internalType":"address[]"}],"name":"getExchangeSpenders","inputs":[],"constant":true},{"type":"function","stateMutability":"view","payable":false,"outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"getFrozenReserveGoldBalance","inputs":[],"constant":true},{"type":"function","stateMutability":"nonpayable","payable":false,"outputs":[{"type":"uint256","name":"","internalType":"uint256"},{"type":"uint256","name":"","internalType":"uint256"}],"name":"getOrComputeTobinTax","inputs":[],"constant":false},{"type":"function","stateMutability":"view","payable":false,"outputs":[{"type":"address[]","name":"","internalType":"address[]"}],"name":"getOtherReserveAddresses","inputs":[],"constant":true},{"type":"function","stateMutability":"view","payable":false,"outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"getOtherReserveAddressesGoldBalance","inputs":[],"constant":true},{"type":"function","stateMutability":"view","payable":false,"outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"getReserveAddressesCollateralAssetBalance","inputs":[{"type":"address","name":"collateralAsset","internalType":"address"}],"constant":true},{"type":"function","stateMutability":"view","payable":false,"outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"getReserveGoldBalance","inputs":[],"constant":true},{"type":"function","stateMutability":"view","payable":false,"outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"getReserveRatio","inputs":[],"constant":true},{"type":"function","stateMutability":"view","payable":false,"outputs":[{"type":"address[]","name":"","internalType":"address[]"}],"name":"getTokens","inputs":[],"constant":true},{"type":"function","stateMutability":"view","payable":false,"outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"getUnfrozenBalance","inputs":[],"constant":true},{"type":"function","stateMutability":"view","payable":false,"outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"getUnfrozenReserveGoldBalance","inputs":[],"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":"nonpayable","payable":false,"outputs":[],"name":"initialize","inputs":[{"type":"address","name":"registryAddress","internalType":"address"},{"type":"uint256","name":"_tobinTaxStalenessThreshold","internalType":"uint256"},{"type":"uint256","name":"_spendingRatioForCelo","internalType":"uint256"},{"type":"uint256","name":"_frozenGold","internalType":"uint256"},{"type":"uint256","name":"_frozenDays","internalType":"uint256"},{"type":"bytes32[]","name":"_assetAllocationSymbols","internalType":"bytes32[]"},{"type":"uint256[]","name":"_assetAllocationWeights","internalType":"uint256[]"},{"type":"uint256","name":"_tobinTax","internalType":"uint256"},{"type":"uint256","name":"_tobinTaxReserveRatio","internalType":"uint256"},{"type":"address[]","name":"_collateralAssets","internalType":"address[]"},{"type":"uint256[]","name":"_collateralAssetDailySpendingRatios","internalType":"uint256[]"}],"constant":false},{"type":"function","stateMutability":"view","payable":false,"outputs":[{"type":"bool","name":"","internalType":"bool"}],"name":"initialized","inputs":[],"constant":true},{"type":"function","stateMutability":"view","payable":false,"outputs":[{"type":"bool","name":"","internalType":"bool"}],"name":"isCollateralAsset","inputs":[{"type":"address","name":"","internalType":"address"}],"constant":true},{"type":"function","stateMutability":"view","payable":false,"outputs":[{"type":"bool","name":"","internalType":"bool"}],"name":"isExchangeSpender","inputs":[{"type":"address","name":"","internalType":"address"}],"constant":true},{"type":"function","stateMutability":"view","payable":false,"outputs":[{"type":"bool","name":"","internalType":"bool"}],"name":"isOtherReserveAddress","inputs":[{"type":"address","name":"","internalType":"address"}],"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":"bool","name":"","internalType":"bool"}],"name":"isSpender","inputs":[{"type":"address","name":"","internalType":"address"}],"constant":true},{"type":"function","stateMutability":"view","payable":false,"outputs":[{"type":"bool","name":"","internalType":"bool"}],"name":"isStableAsset","inputs":[{"type":"address","name":"token","internalType":"address"}],"constant":true},{"type":"function","stateMutability":"view","payable":false,"outputs":[{"type":"bool","name":"","internalType":"bool"}],"name":"isToken","inputs":[{"type":"address","name":"","internalType":"address"}],"constant":true},{"type":"function","stateMutability":"view","payable":false,"outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"lastSpendingDay","inputs":[],"constant":true},{"type":"function","stateMutability":"view","payable":false,"outputs":[{"type":"address","name":"","internalType":"address"}],"name":"otherReserveAddresses","inputs":[{"type":"uint256","name":"","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":[{"type":"bool","name":"","internalType":"bool"}],"name":"removeCollateralAsset","inputs":[{"type":"address","name":"collateralAsset","internalType":"address"},{"type":"uint256","name":"index","internalType":"uint256"}],"constant":false},{"type":"function","stateMutability":"nonpayable","payable":false,"outputs":[],"name":"removeExchangeSpender","inputs":[{"type":"address","name":"spender","internalType":"address"},{"type":"uint256","name":"index","internalType":"uint256"}],"constant":false},{"type":"function","stateMutability":"nonpayable","payable":false,"outputs":[{"type":"bool","name":"","internalType":"bool"}],"name":"removeOtherReserveAddress","inputs":[{"type":"address","name":"reserveAddress","internalType":"address"},{"type":"uint256","name":"index","internalType":"uint256"}],"constant":false},{"type":"function","stateMutability":"nonpayable","payable":false,"outputs":[],"name":"removeSpender","inputs":[{"type":"address","name":"spender","internalType":"address"}],"constant":false},{"type":"function","stateMutability":"nonpayable","payable":false,"outputs":[{"type":"bool","name":"","internalType":"bool"}],"name":"removeToken","inputs":[{"type":"address","name":"token","internalType":"address"},{"type":"uint256","name":"index","internalType":"uint256"}],"constant":false},{"type":"function","stateMutability":"nonpayable","payable":false,"outputs":[],"name":"renounceOwnership","inputs":[],"constant":false},{"type":"function","stateMutability":"nonpayable","payable":false,"outputs":[],"name":"setAssetAllocations","inputs":[{"type":"bytes32[]","name":"symbols","internalType":"bytes32[]"},{"type":"uint256[]","name":"weights","internalType":"uint256[]"}],"constant":false},{"type":"function","stateMutability":"nonpayable","payable":false,"outputs":[],"name":"setDailySpendingRatio","inputs":[{"type":"uint256","name":"ratio","internalType":"uint256"}],"constant":false},{"type":"function","stateMutability":"nonpayable","payable":false,"outputs":[],"name":"setDailySpendingRatioForCollateralAssets","inputs":[{"type":"address[]","name":"_collateralAssets","internalType":"address[]"},{"type":"uint256[]","name":"collateralAssetDailySpendingRatios","internalType":"uint256[]"}],"constant":false},{"type":"function","stateMutability":"nonpayable","payable":false,"outputs":[],"name":"setFrozenGold","inputs":[{"type":"uint256","name":"frozenGold","internalType":"uint256"},{"type":"uint256","name":"frozenDays","internalType":"uint256"}],"constant":false},{"type":"function","stateMutability":"nonpayable","payable":false,"outputs":[],"name":"setRegistry","inputs":[{"type":"address","name":"registryAddress","internalType":"address"}],"constant":false},{"type":"function","stateMutability":"nonpayable","payable":false,"outputs":[],"name":"setTobinTax","inputs":[{"type":"uint256","name":"value","internalType":"uint256"}],"constant":false},{"type":"function","stateMutability":"nonpayable","payable":false,"outputs":[],"name":"setTobinTaxReserveRatio","inputs":[{"type":"uint256","name":"value","internalType":"uint256"}],"constant":false},{"type":"function","stateMutability":"nonpayable","payable":false,"outputs":[],"name":"setTobinTaxStalenessThreshold","inputs":[{"type":"uint256","name":"value","internalType":"uint256"}],"constant":false},{"type":"function","stateMutability":"view","payable":false,"outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"spendingLimit","inputs":[],"constant":true},{"type":"function","stateMutability":"view","payable":false,"outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"tobinTax","inputs":[],"constant":true},{"type":"function","stateMutability":"view","payable":false,"outputs":[{"type":"uint128","name":"numerator","internalType":"uint128"},{"type":"uint128","name":"timestamp","internalType":"uint128"}],"name":"tobinTaxCache","inputs":[],"constant":true},{"type":"function","stateMutability":"view","payable":false,"outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"tobinTaxReserveRatio","inputs":[],"constant":true},{"type":"function","stateMutability":"view","payable":false,"outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"tobinTaxStalenessThreshold","inputs":[],"constant":true},{"type":"function","stateMutability":"nonpayable","payable":false,"outputs":[{"type":"bool","name":"","internalType":"bool"}],"name":"transferCollateralAsset","inputs":[{"type":"address","name":"collateralAsset","internalType":"address"},{"type":"address","name":"to","internalType":"address payable"},{"type":"uint256","name":"value","internalType":"uint256"}],"constant":false},{"type":"function","stateMutability":"nonpayable","payable":false,"outputs":[{"type":"bool","name":"","internalType":"bool"}],"name":"transferExchangeGold","inputs":[{"type":"address","name":"to","internalType":"address payable"},{"type":"uint256","name":"value","internalType":"uint256"}],"constant":false},{"type":"function","stateMutability":"nonpayable","payable":false,"outputs":[{"type":"bool","name":"","internalType":"bool"}],"name":"transferGold","inputs":[{"type":"address","name":"to","internalType":"address payable"},{"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}]
              

Contract Creation Code

0x60806040523480156200001157600080fd5b506040516200550938038062005509833981810160405260208110156200003757600080fd5b50518060006200004f6001600160e01b03620000c016565b600080546001600160a01b0319166001600160a01b0383169081178255604051929350917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0908290a35080620000b3576000805460ff60a01b1916600160a01b1790555b50506001600255620000c4565b3390565b61543580620000d46000396000f3fe6080604052600436106103f95760003560e01c80637b5220751161020d578063ad62ad1011610128578063e6b76e9c116100bb578063f0b7182b1161008a578063f2fde38b1161006f578063f2fde38b146111be578063f7165fee146111f1578063fa9ed95a1461121b576103f9565b8063f0b7182b14611158578063f240dae31461118b576103f9565b8063e6b76e9c146110a1578063e7e31e7a146110cb578063e83b373b146110fe578063ec4f797b1461112e576103f9565b8063d48bfca7116100f7578063d48bfca71461102f578063e30f579d14611062578063e33a88e714611077578063e50a6c1e1461108c576103f9565b8063ad62ad1014610e65578063b003dcf114610e8f578063ca56d33b14610ec8578063cae182fe14610ffc576103f9565b80638f32d59b116101a0578063a1ab55b31161016f578063a1ab55b314610dc0578063a8b94b8d14610dea578063a91ee0dc14610e1d578063aa6ca80814610e50576103f9565b80638f32d59b14610d30578063965366f314610d455780639a206ece14610d785780639c3e2f0f14610dab576103f9565b80638b7df8d4116101dc5780638b7df8d414610cbe5780638ce5877c14610cd35780638d9a5e6f14610d065780638da5cb5b14610d1b576103f9565b80637b52207514610c4c57806381b861a614610c7f5780638438796a14610c94578063894098d614610ca9576103f9565b806339d7f76e116103185780635c4a3145116102ab57806372a6b8b01161027a57806376769a601161025f57806376769a6014610c0d5780637897a78e14610c225780637b10399914610c37576103f9565b806372a6b8b014610a50578063765c1fe914610bf8576103f9565b80635c4a3145146109b457806370022cb4146109ed5780637090db4e14610a26578063715018a614610a3b576103f9565b806350614ba0116102e757806350614ba01461090757806354255be01461093a57806356b6d0d5146109755780635a18b08b1461098a576103f9565b806339d7f76e14610846578063408993651461085b5780634cea8ded146108a15780634f8e6e23146108d4576103f9565b8063158ef93e11610390578063220159681161035f578063220159681461078757806322796e83146107ba5780632aa1c16d146107fe57806338345dec14610813576103f9565b8063158ef93e146106d857806317f9a6f7146106ed57806319f373611461071b5780631c39c7d51461074e576103f9565b80630db279be116103cc5780630db279be146104dc57806311bb0dcd146105065780631218f9821461063a57806313baf1e61461069f576103f9565b806301da32bd146103fb57806303a0fea31461042557806303d835f314610472578063042b7a5414610499575b005b34801561040757600080fd5b506103f96004803603602081101561041e57600080fd5b5035611230565b34801561043157600080fd5b5061045e6004803603604081101561044857600080fd5b506001600160a01b03813516906020013561132e565b604080519115158252519081900360200190f35b34801561047e57600080fd5b50610487611489565b60408051918252519081900360200190f35b3480156104a557600080fd5b5061045e600480360360608110156104bc57600080fd5b506001600160a01b0381358116916020810135909116906040013561148f565b3480156104e857600080fd5b50610487600480360360208110156104ff57600080fd5b5035611696565b34801561051257600080fd5b506103f96004803603604081101561052957600080fd5b81019060208101813564010000000081111561054457600080fd5b82018360208201111561055657600080fd5b8035906020019184602083028401116401000000008311171561057857600080fd5b91908080602002602001604051908101604052809392919081815260200183836020028082843760009201919091525092959493602081019350359150506401000000008111156105c857600080fd5b8201836020820111156105da57600080fd5b803590602001918460208302840111640100000000831117156105fc57600080fd5b9190808060200260200160405190810160405280939291908181526020018383602002808284376000920191909152509295506116b4945050505050565b34801561064657600080fd5b5061064f61193a565b60408051602080825283518183015283519192839290830191858101910280838360005b8381101561068b578181015183820152602001610673565b505050509050019250505060405180910390f35b3480156106ab57600080fd5b5061045e600480360360408110156106c257600080fd5b506001600160a01b03813516906020013561199d565b3480156106e457600080fd5b5061045e611be9565b3480156106f957600080fd5b50610702611c0a565b6040805192835260208301919091528051918290030190f35b34801561072757600080fd5b5061045e6004803603602081101561073e57600080fd5b50356001600160a01b0316611d47565b34801561075a57600080fd5b5061045e6004803603604081101561077157600080fd5b506001600160a01b038135169060200135611d5c565b34801561079357600080fd5b5061045e600480360360208110156107aa57600080fd5b50356001600160a01b0316611ed0565b3480156107c657600080fd5b506107cf6120a5565b604080516fffffffffffffffffffffffffffffffff938416815291909216602082015281519081900390910190f35b34801561080a57600080fd5b506104876120d5565b34801561081f57600080fd5b506104876004803603602081101561083657600080fd5b50356001600160a01b031661214b565b34801561085257600080fd5b5061048761230c565b34801561086757600080fd5b506108856004803603602081101561087e57600080fd5b5035612312565b604080516001600160a01b039092168252519081900360200190f35b3480156108ad57600080fd5b5061045e600480360360208110156108c457600080fd5b50356001600160a01b0316612339565b3480156108e057600080fd5b5061045e600480360360208110156108f757600080fd5b50356001600160a01b031661234e565b34801561091357600080fd5b506104876004803603602081101561092a57600080fd5b50356001600160a01b031661236c565b34801561094657600080fd5b5061094f61237e565b604080519485526020850193909352838301919091526060830152519081900360800190f35b34801561098157600080fd5b5061048761238b565b34801561099657600080fd5b50610885600480360360208110156109ad57600080fd5b50356126b7565b3480156109c057600080fd5b5061045e600480360360408110156109d757600080fd5b506001600160a01b0381351690602001356126c4565b3480156109f957600080fd5b5061045e60048036036040811015610a1057600080fd5b506001600160a01b03813516906020013561290d565b348015610a3257600080fd5b50610487612b65565b348015610a4757600080fd5b506103f9612b6b565b348015610a5c57600080fd5b506103f96004803603610160811015610a7457600080fd5b6001600160a01b03823516916020810135916040820135916060810135916080820135919081019060c0810160a0820135640100000000811115610ab757600080fd5b820183602082011115610ac957600080fd5b80359060200191846020830284011164010000000083111715610aeb57600080fd5b919390929091602081019035640100000000811115610b0957600080fd5b820183602082011115610b1b57600080fd5b80359060200191846020830284011164010000000083111715610b3d57600080fd5b919390928235926020810135929190606081019060400135640100000000811115610b6757600080fd5b820183602082011115610b7957600080fd5b80359060200191846020830284011164010000000083111715610b9b57600080fd5b919390929091602081019035640100000000811115610bb957600080fd5b820183602082011115610bcb57600080fd5b80359060200191846020830284011164010000000083111715610bed57600080fd5b509092509050612c26565b348015610c0457600080fd5b50610487612e39565b348015610c1957600080fd5b50610487612e9b565b348015610c2e57600080fd5b50610487612ea1565b348015610c4357600080fd5b50610885612ec2565b348015610c5857600080fd5b5061045e60048036036020811015610c6f57600080fd5b50356001600160a01b0316612ed1565b348015610c8b57600080fd5b50610487612ee6565b348015610ca057600080fd5b5061064f612eec565b348015610cb557600080fd5b50610487612f43565b348015610cca57600080fd5b50610487612f49565b348015610cdf57600080fd5b506103f960048036036020811015610cf657600080fd5b50356001600160a01b0316612f6a565b348015610d1257600080fd5b5061048761300c565b348015610d2757600080fd5b50610885613026565b348015610d3c57600080fd5b5061045e613035565b348015610d5157600080fd5b5061045e60048036036020811015610d6857600080fd5b50356001600160a01b0316613059565b348015610d8457600080fd5b5061045e60048036036020811015610d9b57600080fd5b50356001600160a01b031661320e565b348015610db757600080fd5b5061064f613223565b348015610dcc57600080fd5b506103f960048036036020811015610de357600080fd5b5035613283565b348015610df657600080fd5b5061048760048036036020811015610e0d57600080fd5b50356001600160a01b031661336c565b348015610e2957600080fd5b506103f960048036036020811015610e4057600080fd5b50356001600160a01b031661339b565b348015610e5c57600080fd5b5061064f6134b1565b348015610e7157600080fd5b506103f960048036036020811015610e8857600080fd5b5035613511565b348015610e9b57600080fd5b506103f960048036036040811015610eb257600080fd5b506001600160a01b0381351690602001356135a5565b348015610ed457600080fd5b506103f960048036036040811015610eeb57600080fd5b810190602081018135640100000000811115610f0657600080fd5b820183602082011115610f1857600080fd5b80359060200191846020830284011164010000000083111715610f3a57600080fd5b9190808060200260200160405190810160405280939291908181526020018383602002808284376000920191909152509295949360208101935035915050640100000000811115610f8a57600080fd5b820183602082011115610f9c57600080fd5b80359060200191846020830284011164010000000083111715610fbe57600080fd5b919080806020026020016040519081016040528093929190818152602001838360200280828437600092019190915250929550613802945050505050565b34801561100857600080fd5b5061045e6004803603602081101561101f57600080fd5b50356001600160a01b0316613c06565b34801561103b57600080fd5b5061045e6004803603602081101561105257600080fd5b50356001600160a01b0316613c1b565b34801561106e57600080fd5b50610487613dea565b34801561108357600080fd5b50610487613e16565b34801561109857600080fd5b5061064f613e1c565b3480156110ad57600080fd5b506103f9600480360360208110156110c457600080fd5b5035613eb8565b3480156110d757600080fd5b506103f9600480360360208110156110ee57600080fd5b50356001600160a01b0316613f9b565b34801561110a57600080fd5b506103f96004803603604081101561112157600080fd5b508035906020013561409b565b34801561113a57600080fd5b506104876004803603602081101561115157600080fd5b503561415d565b34801561116457600080fd5b506103f96004803603602081101561117b57600080fd5b50356001600160a01b031661416f565b34801561119757600080fd5b5061045e600480360360208110156111ae57600080fd5b50356001600160a01b031661431f565b3480156111ca57600080fd5b506103f9600480360360208110156111e157600080fd5b50356001600160a01b031661433d565b3480156111fd57600080fd5b506108856004803603602081101561121457600080fd5b50356143a2565b34801561122757600080fd5b506104876143af565b611238613035565b611289576040805162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015290519081900360640190fd5b611292816143b5565b516010556112bd6112a16143cf565b604080516020810190915260105481529063ffffffff6143f316565b6112f85760405162461bcd60e51b81526004018080602001828103825260268152602001806152bc6026913960400191505060405180910390fd5b6040805182815290517fb08f0607338ad77f5b08ccf831e533cefcc2d373c173e87a8f61144f1d82be1e9181900360200190a150565b3360008181526014602052604081205490919060ff16806114265750600154604080517f45786368616e676500000000000000000000000000000000000000000000000060208083019190915282518083036008018152602883018085528151918301919091207fdcf0aaed00000000000000000000000000000000000000000000000000000000909152602c83015291516001600160a01b0380861694169263dcf0aaed92604c8082019391829003018186803b1580156113ef57600080fd5b505afa158015611403573d6000803e3d6000fd5b505050506040513d602081101561141957600080fd5b50516001600160a01b0316145b611477576040805162461bcd60e51b815260206004820152601c60248201527f41646472657373206e6f7420616c6c6f77656420746f207370656e6400000000604482015290519081900360640190fd5b61148184846143fb565b949350505050565b60115481565b3360009081526009602052604081205460ff166114dd5760405162461bcd60e51b815260040180806020018281038252602c8152602001806153aa602c913960400191505060405180910390fd5b6001600160a01b038316611538576040805162461bcd60e51b815260206004820152601d60248201527f63616e206e6f74207472616e7366657220746f20302061646472657373000000604482015290519081900360640190fd5b60006115438561336c565b1161157f5760405162461bcd60e51b81526004018080602001828103825260408152602001806153166040913960400191505060405180910390fd5b6001600160a01b0384166000908152601760205260408120546201518042049081111561161a5760006115b18761214b565b6001600160a01b038816600090815260176020526040902083905590506116166116116115dd836144bb565b6001600160a01b038a166000908152601660209081526040918290208251918201909252905481529063ffffffff61452916565b61489b565b9250505b8382101561166f576040805162461bcd60e51b815260206004820152601860248201527f457863656564696e67207370656e64696e67206c696d69740000000000000000604482015290519081900360640190fd5b61167f828563ffffffff6148ac16565b915061168c8686866148ee565b9695505050505050565b600c81815481106116a357fe5b600091825260209091200154905081565b6116bc613035565b61170d576040805162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015290519081900360640190fd5b805182511461174d5760405162461bcd60e51b815260040180806020018281038252603e8152602001806150eb603e913960400191505060405180910390fd5b60005b82518110156119355760006001600160a01b031683828151811061177057fe5b60200260200101516001600160a01b0316141580156117a3575081818151811061179657fe5b6020026020010151600014155b1561192d576117c48382815181106117b757fe5b602002602001015161431f565b6117ff5760405162461bcd60e51b81526004018080602001828103825260378152602001806151296037913960400191505060405180910390fd5b61183261180a6143cf565b61182684848151811061181957fe5b60200260200101516143b5565b9063ffffffff6143f316565b61186d5760405162461bcd60e51b81526004018080602001828103825260268152602001806152bc6026913960400191505060405180910390fd5b61187c82828151811061181957fe5b6016600085848151811061188c57fe5b60200260200101516001600160a01b03166001600160a01b03168152602001908152602001600020600082015181600001559050507f15ff5079dfbf448e4bb45ac83498c2ecb0833ad35916946bb683ccb49f8013a38382815181106118ee57fe5b602002602001015183838151811061190257fe5b602090810291909101810151604080516001600160a01b039094168452918301528051918290030190a15b600101611750565b505050565b6060601580548060200260200160405190810160405280929190818152602001828054801561199257602002820191906000526020600020905b81546001600160a01b03168152600190910190602001808311611974575b505050505090505b90565b60006119a7613035565b6119f8576040805162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015290519081900360640190fd5b6001600160a01b038316600090815260036020526040902054839060ff16611a67576040805162461bcd60e51b815260206004820152601f60248201527f746f6b656e206164647220776173206e65766572207265676973746572656400604482015290519081900360640190fd5b60045483108015611aa15750836001600160a01b031660048481548110611a8a57fe5b6000918252602090912001546001600160a01b0316145b611adc5760405162461bcd60e51b815260040180806020018281038252602a815260200180615356602a913960400191505060405180910390fd5b6001600160a01b0384166000908152600360205260408120805460ff1916905560048054611b1190600163ffffffff6148ac16565b81548110611b1b57fe5b600091825260209091200154600480546001600160a01b039092169250829186908110611b4457fe5b600091825260209091200180547fffffffffffffffffffffffff0000000000000000000000000000000000000000166001600160a01b0392909216919091179055600454611b939060016148ac565b611b9e60048261500f565b506040805185815290516001600160a01b038716917fbe9bb4bdca0a094babd75e3a98b1d2e2390633430d0a2f6e2b9970e2ee03fb2e919081900360200190a2506001949350505050565b60005474010000000000000000000000000000000000000000900460ff1681565b600280546001019081905560065460055460009283929091611c5390429070010000000000000000000000000000000090046fffffffffffffffffffffffffffffffff166148ac565b1115611cc857611c69611c64614a17565b614a7a565b60058054426fffffffffffffffffffffffffffffffff908116700100000000000000000000000000000000029381167fffffffffffffffffffffffffffffffff0000000000000000000000000000000090921691909117169190911790555b6005546fffffffffffffffffffffffffffffffff16611ce8611c646143cf565b925092506002548114611d42576040805162461bcd60e51b815260206004820152600e60248201527f7265656e7472616e742063616c6c000000000000000000000000000000000000604482015290519081900360640190fd5b509091565b60036020526000908152604090205460ff1681565b3360009081526009602052604081205460ff16611daa5760405162461bcd60e51b815260040180806020018281038252602c8152602001806153aa602c913960400191505060405180910390fd5b6001600160a01b0383166000908152600a602052604090205460ff16611e015760405162461bcd60e51b815260040180806020018281038252602a815260200180615380602a913960400191505060405180910390fd5b600e5462015180420490811115611e53576000611e1c612f49565b600e8390559050611e4e611611611e32836144bb565b604080516020810190915260105481529063ffffffff61452916565b600f55505b82600f541015611eaa576040805162461bcd60e51b815260206004820152601860248201527f457863656564696e67207370656e64696e67206c696d69740000000000000000604482015290519081900360640190fd5b600f54611ebd908463ffffffff6148ac16565b600f5561148184846143fb565b92915050565b6000611eda613035565b611f2b576040805162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015290519081900360640190fd5b60028054600101908190556001600160a01b0383166000908152600a602052604090205460ff1615611fa4576040805162461bcd60e51b815260206004820152601a60248201527f72657365727665206164647220616c7265616479206164646564000000000000604482015290519081900360640190fd5b6001600160a01b0383166000818152600a6020526040808220805460ff19166001908117909155600b8054918201815583527f0175b7a638427703f0dbe7bb9bbf987a2551717b34e79f33b5b1008d1fa01db90180547fffffffffffffffffffffffff00000000000000000000000000000000000000001684179055517fd78793225285ecf9cf5f0f84b1cdc335c2cb4d6810ff0b9fd156ad6026c89cea9190a260019150600254811461209f576040805162461bcd60e51b815260206004820152600e60248201527f7265656e7472616e742063616c6c000000000000000000000000000000000000604482015290519081900360640190fd5b50919050565b6005546fffffffffffffffffffffffffffffffff8082169170010000000000000000000000000000000090041682565b6012546000906201518042049082906120f590839063ffffffff6148ac16565b9050601354811061210b5760009250505061199a565b61214461213560135461212984601154614a7e90919063ffffffff16565b9063ffffffff614ad716565b6011549063ffffffff6148ac16565b9250505090565b60006121568261431f565b6121915760405162461bcd60e51b815260040180806020018281038252602b8152602001806153d6602b913960400191505060405180910390fd5b6000805b600b548110156122675761225d846001600160a01b03166370a08231600b84815481106121be57fe5b60009182526020918290200154604080517fffffffff0000000000000000000000000000000000000000000000000000000060e086901b1681526001600160a01b0390921660048301525160248083019392829003018186803b15801561222457600080fd5b505afa158015612238573d6000803e3d6000fd5b505050506040513d602081101561224e57600080fd5b5051839063ffffffff614b1916565b9150600101612195565b50604080517f70a082310000000000000000000000000000000000000000000000000000000081523060048201529051612305916001600160a01b038616916370a0823191602480820192602092909190829003018186803b1580156122cc57600080fd5b505afa1580156122e0573d6000803e3d6000fd5b505050506040513d60208110156122f657600080fd5b5051829063ffffffff614b1916565b9392505050565b600f5481565b600b818154811061231f57fe5b6000918252602090912001546001600160a01b0316905081565b60146020526000908152604090205460ff1681565b6001600160a01b031660009081526003602052604090205460ff1690565b60176020526000908152604090205481565b6002600160008090919293565b600154604080517f536f727465644f7261636c6573000000000000000000000000000000000000006020808301919091528251808303600d018152602d83018085528151918301919091207fdcf0aaed000000000000000000000000000000000000000000000000000000009091526031830152915160009384936001600160a01b039091169263dcf0aaed9260518083019392829003018186803b15801561243357600080fd5b505afa158015612447573d6000803e3d6000fd5b505050506040513d602081101561245d57600080fd5b5051905080600061246c612f49565b90506000612478615033565b7f63474c4400000000000000000000000000000000000000000000000000000000600052600d6020527f486533e5ef5711c6fceba0b8e8d907d58b0d418a02599d00d65a64e01c112d77546124cc906143b5565b905060005b60045481101561268457600080866001600160a01b031663ef90e1b0600485815481106124fa57fe5b600091825260209091200154604080517fffffffff0000000000000000000000000000000000000000000000000000000060e085901b1681526001600160a01b0390921660048301528051602480840193829003018186803b15801561255f57600080fd5b505afa158015612573573d6000803e3d6000fd5b505050506040513d604081101561258957600080fd5b50805160209091015190925090508015612669576000600484815481106125ac57fe5b60009182526020918290200154604080517f18160ddd00000000000000000000000000000000000000000000000000000000815290516001600160a01b03909216926318160ddd92600480840193829003018186803b15801561260e57600080fd5b505afa158015612622573d6000803e3d6000fd5b505050506040513d602081101561263857600080fd5b50519050600061265284612129848663ffffffff614a7e16565b9050612664878263ffffffff614b1916565b965050505b5061267d905081600163ffffffff614b1916565b90506124d1565b506126ad611c64612694846144bb565b6126a1846126a1886144bb565b9063ffffffff614b7316565b9550505050505090565b6015818154811061231f57fe5b60006126ce613035565b61271f576040805162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015290519081900360640190fd5b6001600160a01b0383166000908152600a602052604090205460ff1661278c576040805162461bcd60e51b815260206004820152601c60248201527f72657365727665206164647220776173206e6576657220616464656400000000604482015290519081900360640190fd5b600b54821080156127c65750826001600160a01b0316600b83815481106127af57fe5b6000918252602090912001546001600160a01b0316145b6128015760405162461bcd60e51b815260040180806020018281038252602d815260200180615257602d913960400191505060405180910390fd5b6001600160a01b0383166000908152600a60205260408120805460ff19169055600b805461283690600163ffffffff6148ac16565b8154811061284057fe5b600091825260209091200154600b80546001600160a01b03909216925082918590811061286957fe5b600091825260209091200180547fffffffffffffffffffffffff0000000000000000000000000000000000000000166001600160a01b0392909216919091179055600b546128b89060016148ac565b6128c3600b8261500f565b506040805184815290516001600160a01b038616917f89b4ee5cecfdfb246ede373c10283b5038afe56a531fc1d2f3ed8c5507a52fcb919081900360200190a25060019392505050565b6000612917613035565b612968576040805162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015290519081900360640190fd5b6129718361431f565b6129ac5760405162461bcd60e51b815260040180806020018281038252602b8152602001806153d6602b913960400191505060405180910390fd5b601854821080156129e65750826001600160a01b0316601883815481106129cf57fe5b6000918252602090912001546001600160a01b0316145b612a215760405162461bcd60e51b81526004018080602001828103825260348152602001806152e26034913960400191505060405180910390fd5b601880547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff8101908110612a5157fe5b600091825260209091200154601880546001600160a01b039092169184908110612a7757fe5b9060005260206000200160006101000a8154816001600160a01b0302191690836001600160a01b031602179055506018805480612ab057fe5b6000828152602080822083017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff90810180547fffffffffffffffffffffffff00000000000000000000000000000000000000001690559092019092556001600160a01b03851680835260198252604092839020805460ff19169055825190815291517f4336391ada1af9dcb966fed43ebafa4404719b6d8e42c765ab28e3abc9a24e7a9281900390910190a150600192915050565b60135481565b612b73613035565b612bc4576040805162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015290519081900360640190fd5b600080546040516001600160a01b03909116907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0908390a3600080547fffffffffffffffffffffffff0000000000000000000000000000000000000000169055565b60005474010000000000000000000000000000000000000000900460ff1615612c96576040805162461bcd60e51b815260206004820152601c60248201527f636f6e747261637420616c726561647920696e697469616c697a656400000000604482015290519081900360640190fd5b600080547fffffffffffffffffffffff00ffffffffffffffffffffffffffffffffffffffff1674010000000000000000000000000000000000000000179055612cde33614c57565b612ce78f61339b565b612cf08e613283565b612cf98d611230565b612d038c8c61409b565b612d708a8a8080602002602001604051908101604052809392919081815260200183836020028082843760009201919091525050604080516020808e0282810182019093528d82529093508d92508c91829185019084908082843760009201919091525061380292505050565b612d7986613eb8565b612d8285613511565b60005b83811015612dba57612db1858583818110612d9c57fe5b905060200201356001600160a01b0316613059565b50600101612d85565b50612e28848480806020026020016040519081016040528093929190818152602001838360200280828437600092019190915250506040805160208088028281018201909352878252909350879250869182918501908490808284376000920191909152506116b492505050565b505050505050505050505050505050565b600080805b600b54811015612e9557612e7b600b8281548110612e5857fe5b60009182526020909120015483906001600160a01b03163163ffffffff614b1916565b9150612e8e81600163ffffffff614b1916565b9050612e3e565b50905090565b60085481565b60408051602081019091526010548152600090612ebd90614a7a565b905090565b6001546001600160a01b031681565b600a6020526000908152604090205460ff1681565b60125481565b6060600c80548060200260200160405190810160405280929190818152602001828054801561199257602002820191906000526020600020905b815481526020019060010190808311612f26575050505050905090565b60075481565b6000612ebd612f56612e39565b612f5e613dea565b9063ffffffff614b1916565b612f72613035565b612fc3576040805162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015290519081900360640190fd5b6001600160a01b038116600081815260096020526040808220805460ff19169055517fab8cff50266d80b9c9d9703af934ca455b9218286bf4fcaa05653a564c499e4b9190a250565b6000612ebd613019612e39565b479063ffffffff614b1916565b6000546001600160a01b031690565b600080546001600160a01b031661304a614d0f565b6001600160a01b031614905090565b6000613063613035565b6130b4576040805162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015290519081900360640190fd5b6130bd8261431f565b156130f95760405162461bcd60e51b81526004018080602001828103825260388152602001806152846038913960400191505060405180910390fd5b6001600160a01b038216613154576040805162461bcd60e51b815260206004820152601760248201527f63616e27742062652061207a65726f2061646472657373000000000000000000604482015290519081900360640190fd5b6001600160a01b0382166000818152601960209081526040808320805460ff191660019081179091556018805491820181559093527fb13d2d76d1f4b7be834882e410b3e3a8afaf69f83600ae24db354391d2378d2e90920180547fffffffffffffffffffffffff00000000000000000000000000000000000000001684179055815192835290517f0c7515883121475b5d9289febf21a9de4ad53f18349a856d90c7acd6e099600b9281900390910190a1506001919050565b60096020526000908152604090205460ff1681565b6060600b805480602002602001604051908101604052809291908181526020018280548015611992576020028201919060005260206000209081546001600160a01b03168152600190910190602001808311611974575050505050905090565b61328b613035565b6132dc576040805162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015290519081900360640190fd5b60008111613331576040805162461bcd60e51b815260206004820152600e60248201527f76616c756520776173207a65726f000000000000000000000000000000000000604482015290519081900360640190fd5b60068190556040805182815290517f7bfe94ca3147f135fcd6d94ebf61d33fa34fbe904f933ccae66911b9548544f29181900360200190a150565b6001600160a01b03811660009081526016602090815260408083208151928301909152548152611eca90614a7a565b6133a3613035565b6133f4576040805162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015290519081900360640190fd5b6001600160a01b03811661344f576040805162461bcd60e51b815260206004820181905260248201527f43616e6e6f7420726567697374657220746865206e756c6c2061646472657373604482015290519081900360640190fd5b600180547fffffffffffffffffffffffff0000000000000000000000000000000000000000166001600160a01b0383169081179091556040517f27fe5f0c1c3b1ed427cc63d0f05759ffdecf9aec9e18d31ef366fc8a6cb5dc3b90600090a250565b60606004805480602002602001604051908101604052809291908181526020018280548015611992576020028201919060005260206000209081546001600160a01b03168152600190910190602001808311611974575050505050905090565b613519613035565b61356a576040805162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015290519081900360640190fd5b60088190556040805182815290517f4da8e8b2223fbbb897200fb9dfb6b986c1b4188621114d407ee8ec363569fc379181900360200190a150565b6135ad613035565b6135fe576040805162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015290519081900360640190fd5b6001600160a01b0382166000908152601460205260409020805460ff19169055601554808210613675576040805162461bcd60e51b815260206004820152601060248201527f496e64657820697320696e76616c696400000000000000000000000000000000604482015290519081900360640190fd5b6015828154811061368257fe5b6000918252602090912001546001600160a01b038481169116146136ed576040805162461bcd60e51b815260206004820152601c60248201527f496e64657820646f6573206e6f74206d61746368207370656e64657200000000604482015290519081900360640190fd5b600061370082600163ffffffff6148ac16565b905080831461376b576015818154811061371657fe5b600091825260209091200154601580546001600160a01b03909216918590811061373c57fe5b9060005260206000200160006101000a8154816001600160a01b0302191690836001600160a01b031602179055505b60006015828154811061377a57fe5b600091825260209091200180547fffffffffffffffffffffffff0000000000000000000000000000000000000000166001600160a01b0392909216919091179055806137c760158261500f565b506040516001600160a01b038516907f20aaa18caa668680a42b328a15fd50d580bac65d8bd346e104355473c6373ff390600090a250505050565b61380a613035565b61385b576040805162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015290519081900360640190fd5b80518251146138b1576040805162461bcd60e51b815260206004820152601560248201527f4172726179206c656e677468206d69736d617463680000000000000000000000604482015290519081900360640190fd5b6138b9615033565b6138c360006143b5565b905060005b825181101561390a576138f06138e384838151811061181957fe5b839063ffffffff614d1316565b915061390381600163ffffffff614b1916565b90506138c8565b506139236139166143cf565b829063ffffffff614d8c16565b61395e5760405162461bcd60e51b81526004018080602001828103825260218152602001806152156021913960400191505060405180910390fd5b60005b600c548110156139b457600d6000600c838154811061397c57fe5b90600052602060002001548152602001908152602001600020600090556139ad600182614b1990919063ffffffff16565b9050613961565b5082516139c890600c906020860190615046565b5060005b8351811015613aa957600d60008583815181106139e557fe5b6020026020010151815260200190815260200160002054600014613a50576040805162461bcd60e51b815260206004820152601760248201527f43616e6e6f742073657420776569676874207477696365000000000000000000604482015290519081900360640190fd5b828181518110613a5c57fe5b6020026020010151600d6000868481518110613a7457fe5b6020026020010151815260200190815260200160002081905550613aa2600182614b1990919063ffffffff16565b90506139cc565b507f63474c4400000000000000000000000000000000000000000000000000000000600052600d6020527f486533e5ef5711c6fceba0b8e8d907d58b0d418a02599d00d65a64e01c112d7754613b46576040805162461bcd60e51b815260206004820152601a60248201527f4d757374207365742063474c4420617373657420776569676874000000000000604482015290519081900360640190fd5b7f55b488abd19ae7621712324d3d42c2ef7a9575f64f5503103286a1161fb408558383604051808060200180602001838103835285818151815260200191508051906020019060200280838360005b83811015613bad578181015183820152602001613b95565b50505050905001838103825284818151815260200191508051906020019060200280838360005b83811015613bec578181015183820152602001613bd4565b5050505090500194505050505060405180910390a1505050565b60196020526000908152604090205460ff1681565b6000613c25613035565b613c76576040805162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015290519081900360640190fd5b60028054600101908190556001600160a01b03831660009081526003602052604090205460ff1615613cef576040805162461bcd60e51b815260206004820152601d60248201527f746f6b656e206164647220616c72656164792072656769737465726564000000604482015290519081900360640190fd5b6001600160a01b038316600081815260036020526040808220805460ff1916600190811790915560048054918201815583527f8a35acfbc15ff81a39ae7d344fd709f28e8600b4aa8c65c6b64bfe7fe36bd19b0180547fffffffffffffffffffffffff00000000000000000000000000000000000000001684179055517f784c8f4dbf0ffedd6e72c76501c545a70f8b203b30a26ce542bf92ba87c248a49190a260019150600254811461209f576040805162461bcd60e51b815260206004820152600e60248201527f7265656e7472616e742063616c6c000000000000000000000000000000000000604482015290519081900360640190fd5b60004781613df66120d5565b9050808211613e06576000612144565b612144828263ffffffff6148ac16565b60065481565b606080600c80549050604051908082528060200260200182016040528015613e4e578160200160208202803883390190505b50905060005b600c54811015612e9557600d6000600c8381548110613e6f57fe5b9060005260206000200154815260200190815260200160002054828281518110613e9557fe5b6020908102919091010152613eb181600163ffffffff614b1916565b9050613e54565b613ec0613035565b613f11576040805162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015290519081900360640190fd5b613f25613f1c6143cf565b611826836143b5565b613f605760405162461bcd60e51b81526004018080602001828103825260218152602001806150ca6021913960400191505060405180910390fd5b60078190556040805182815290517ffe69856ffb1b1d6cb00c1d8151726e6e95032b1666282eeb293ecadd58b29a6e9181900360200190a150565b613fa3613035565b613ff4576040805162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015290519081900360640190fd5b6001600160a01b03811661404f576040805162461bcd60e51b815260206004820152601560248201527f5370656e6465722063616e2774206265206e756c6c0000000000000000000000604482015290519081900360640190fd5b6001600160a01b038116600081815260096020526040808220805460ff19166001179055517f3139419c41cdd7abca84fa19dd21118cd285d3e2ce1a9444e8161ce9fa62fdcd9190a250565b6140a3613035565b6140f4576040805162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015290519081900360640190fd5b47821115614149576040805162461bcd60e51b815260206004820152601f60248201527f43616e6e6f7420667265657a65206d6f7265207468616e2062616c616e636500604482015290519081900360640190fd5b601182905562015180420460125560135550565b600d6020526000908152604090205481565b614177613035565b6141c8576040805162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015290519081900360640190fd5b6001600160a01b038116614223576040805162461bcd60e51b815260206004820152601560248201527f5370656e6465722063616e2774206265206e756c6c0000000000000000000000604482015290519081900360640190fd5b6001600160a01b03811660009081526014602052604090205460ff161561427b5760405162461bcd60e51b81526004018080602001828103825260238152602001806151bc6023913960400191505060405180910390fd5b6001600160a01b038116600081815260146020526040808220805460ff1916600190811790915560158054918201815583527f55f448fdea98c4d29eb340757ef0a66cd03dbb9538908a6a81d96026b71ec4750180547fffffffffffffffffffffffff00000000000000000000000000000000000000001684179055517f71bccdb89fff4d914e3d2e472b327e3debaf4c4d6f1dfe528f430447e4cbcf5f9190a250565b6001600160a01b031660009081526019602052604090205460ff1690565b614345613035565b614396576040805162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015290519081900360640190fd5b61439f81614c57565b50565b6018818154811061231f57fe5b600e5481565b6143bd615033565b50604080516020810190915290815290565b6143d7615033565b50604080516020810190915269d3c21bcecceda1000000815290565b519051111590565b6000614405613dea565b821115614459576040805162461bcd60e51b815260206004820152601b60248201527f457863656564696e6720756e66726f7a656e2072657365727665730000000000604482015290519081900360640190fd5b6144726001600160a01b0384168363ffffffff614d9316565b6040805183815290516001600160a01b0385169133917f4dd1abe16ad3d4f829372dc77766ca2cce34e205af9b10f8cc1fab370425864f9181900360200190a350600192915050565b6144c3615033565b6144cb614e78565b8211156145095760405162461bcd60e51b81526004018080602001828103825260368152602001806151df6036913960400191505060405180910390fd5b50604080516020810190915269d3c21bcecceda100000082028152919050565b614531615033565b8251158061453e57508151155b156145585750604080516020810190915260008152611eca565b815169d3c21bcecceda10000001415614572575081611eca565b825169d3c21bcecceda1000000141561458c575080611eca565b600069d3c21bcecceda10000006145a285614e93565b51816145aa57fe5b04905060006145b885614ec8565b519050600069d3c21bcecceda10000006145d186614e93565b51816145d957fe5b04905060006145e786614ec8565b519050838202841561465057828582816145fd57fe5b0414614650576040805162461bcd60e51b815260206004820152601660248201527f6f766572666c6f77207831793120646574656374656400000000000000000000604482015290519081900360640190fd5b69d3c21bcecceda1000000810281156146ca5769d3c21bcecceda100000082828161467757fe5b04146146ca576040805162461bcd60e51b815260206004820152601f60248201527f6f766572666c6f772078317931202a2066697865643120646574656374656400604482015290519081900360640190fd5b905080848402851561473357848682816146e057fe5b0414614733576040805162461bcd60e51b815260206004820152601660248201527f6f766572666c6f77207832793120646574656374656400000000000000000000604482015290519081900360640190fd5b8684028715614799578488828161474657fe5b0414614799576040805162461bcd60e51b815260206004820152601660248201527f6f766572666c6f77207831793220646574656374656400000000000000000000604482015290519081900360640190fd5b6147a1614f02565b87816147a957fe5b0496506147b4614f02565b85816147bc57fe5b049450868502871561482557858882816147d257fe5b0414614825576040805162461bcd60e51b815260206004820152601660248201527f6f766572666c6f77207832793220646574656374656400000000000000000000604482015290519081900360640190fd5b61482d615033565b604051806020016040528087815250905061485681604051806020016040528087815250614d13565b905061487081604051806020016040528086815250614d13565b905061488a81604051806020016040528085815250614d13565b9d9c50505050505050505050505050565b5169d3c21bcecceda1000000900490565b600061230583836040518060400160405280601e81526020017f536166654d6174683a207375627472616374696f6e206f766572666c6f770000815250614f0b565b60006148f98461214b565b8211156149375760405162461bcd60e51b81526004018080602001828103825260228152602001806151606022913960400191505060405180910390fd5b836001600160a01b031663a9059cbb84846040518363ffffffff1660e01b815260040180836001600160a01b03166001600160a01b0316815260200182815260200192505050602060405180830381600087803b15801561499757600080fd5b505af11580156149ab573d6000803e3d6000fd5b505050506040513d60208110156149c157600080fd5b5050604080518381526001600160a01b03868116602083015282519086169233927fc171b15fb47a5beb3e11b1951d4518544f699edd6acd893d8695c91703922b60929081900390910190a35060019392505050565b614a1f615033565b614a27615033565b614a37614a3261238b565b6143b5565b9050614a54614a476008546143b5565b829063ffffffff614fa216565b15614a6b57614a6360006143b5565b91505061199a565b614a636007546143b5565b5090565b5190565b600082614a8d57506000611eca565b82820282848281614a9a57fe5b04146123055760405162461bcd60e51b81526004018080602001828103825260218152602001806152366021913960400191505060405180910390fd5b600061230583836040518060400160405280601a81526020017f536166654d6174683a206469766973696f6e206279207a65726f000000000000815250614faa565b600082820183811015612305576040805162461bcd60e51b815260206004820152601b60248201527f536166654d6174683a206164646974696f6e206f766572666c6f770000000000604482015290519081900360640190fd5b614b7b615033565b8151614bce576040805162461bcd60e51b815260206004820152601160248201527f63616e2774206469766964652062792030000000000000000000000000000000604482015290519081900360640190fd5b825169d3c21bcecceda10000008181029190820414614c34576040805162461bcd60e51b815260206004820152601260248201527f6f766572666c6f77206174206469766964650000000000000000000000000000604482015290519081900360640190fd5b604051806020016040528084600001518381614c4c57fe5b049052949350505050565b6001600160a01b038116614c9c5760405162461bcd60e51b81526004018080602001828103825260268152602001806150a46026913960400191505060405180910390fd5b600080546040516001600160a01b03808516939216917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e091a3600080547fffffffffffffffffffffffff0000000000000000000000000000000000000000166001600160a01b0392909216919091179055565b3390565b614d1b615033565b8151835190810190811015614d77576040805162461bcd60e51b815260206004820152601560248201527f616464206f766572666c6f772064657465637465640000000000000000000000604482015290519081900360640190fd5b60408051602081019091529081529392505050565b5190511490565b80471015614de8576040805162461bcd60e51b815260206004820152601d60248201527f416464726573733a20696e73756666696369656e742062616c616e6365000000604482015290519081900360640190fd5b6040516000906001600160a01b0384169083908381818185875af1925050503d8060008114614e33576040519150601f19603f3d011682016040523d82523d6000602084013e614e38565b606091505b50509050806119355760405162461bcd60e51b815260040180806020018281038252603a815260200180615182603a913960400191505060405180910390fd5b7601357c299a88ea76a58924d52ce4f26a85af186c2b9e7490565b614e9b615033565b604051806020016040528069d3c21bcecceda100000080856000015181614ebe57fe5b0402905292915050565b614ed0615033565b604051806020016040528069d3c21bcecceda100000080856000015181614ef357fe5b95519504029093039092525090565b64e8d4a5100090565b60008184841115614f9a5760405162461bcd60e51b81526004018080602001828103825283818151815260200191508051906020019080838360005b83811015614f5f578181015183820152602001614f47565b50505050905090810190601f168015614f8c5780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b505050900390565b519051101590565b60008183614ff95760405162461bcd60e51b8152602060048201818152835160248401528351909283926044909101919085019080838360008315614f5f578181015183820152602001614f47565b50600083858161500557fe5b0495945050505050565b81548183558181111561193557600083815260209020611935918101908301615089565b6040518060200160405280600081525090565b828054828255906000526020600020908101928215615081579160200282015b82811115615081578251825591602001919060010190615066565b50614a769291505b61199a91905b80821115614a76576000815560010161508f56fe4f776e61626c653a206e6577206f776e657220697320746865207a65726f2061646472657373746f62696e207461782063616e6e6f74206265206c6172676572207468616e2031746f6b656e2061646472657373657320616e64207370656e64696e6720726174696f206c656e67746873206861766520746f206265207468652073616d65746865206164647265737320737065636966696564206973206e6f742061207265736572766520636f6c6c61746572616c206173736574457863656564696e672074686520616d6f756e74207265736572766520686f6c6473416464726573733a20756e61626c6520746f2073656e642076616c75652c20726563697069656e74206d617920686176652072657665727465644164647265737320697320616c72656164792045786368616e6765205370656e64657263616e277420637265617465206669786964697479206e756d626572206c6172676572207468616e206d61784e65774669786564282953756d206f6620617373657420616c6c6f636174696f6e206d7573742062652031536166654d6174683a206d756c7469706c69636174696f6e206f766572666c6f77696e64657820696e746f2072657365727665206c697374206e6f74206d617070656420746f2061646472657373737065636966696564206164647265737320697320616c7265616479206164646564206173206120636f6c6c61746572616c2061737365747370656e64696e6720726174696f2063616e6e6f74206265206c6172676572207468616e2031696e64657820696e746f20636f6c6c61746572616c417373657473206c697374206e6f74206d617070656420746f20746f6b656e7468697320617373657420686173206e6f207370656e64696e6720726174696f2c207468657265666f72652063616e2774206265207472616e73666572726564696e64657820696e746f20746f6b656e73206c697374206e6f74206d617070656420746f20746f6b656e63616e206f6e6c79207472616e7366657220746f206f746865722072657365727665206164647265737373656e646572206e6f7420616c6c6f77656420746f207472616e7366657220526573657276652066756e64737370656369666965642061646472657373206973206e6f74206120636f6c6c61746572616c206173736574a265627a7a72315820d34fc1551b1ba685399e22867d0c506058f12667876589b364e1847c3a893f4164736f6c634300051100320000000000000000000000000000000000000000000000000000000000000000

Deployed ByteCode

0x6080604052600436106103f95760003560e01c80637b5220751161020d578063ad62ad1011610128578063e6b76e9c116100bb578063f0b7182b1161008a578063f2fde38b1161006f578063f2fde38b146111be578063f7165fee146111f1578063fa9ed95a1461121b576103f9565b8063f0b7182b14611158578063f240dae31461118b576103f9565b8063e6b76e9c146110a1578063e7e31e7a146110cb578063e83b373b146110fe578063ec4f797b1461112e576103f9565b8063d48bfca7116100f7578063d48bfca71461102f578063e30f579d14611062578063e33a88e714611077578063e50a6c1e1461108c576103f9565b8063ad62ad1014610e65578063b003dcf114610e8f578063ca56d33b14610ec8578063cae182fe14610ffc576103f9565b80638f32d59b116101a0578063a1ab55b31161016f578063a1ab55b314610dc0578063a8b94b8d14610dea578063a91ee0dc14610e1d578063aa6ca80814610e50576103f9565b80638f32d59b14610d30578063965366f314610d455780639a206ece14610d785780639c3e2f0f14610dab576103f9565b80638b7df8d4116101dc5780638b7df8d414610cbe5780638ce5877c14610cd35780638d9a5e6f14610d065780638da5cb5b14610d1b576103f9565b80637b52207514610c4c57806381b861a614610c7f5780638438796a14610c94578063894098d614610ca9576103f9565b806339d7f76e116103185780635c4a3145116102ab57806372a6b8b01161027a57806376769a601161025f57806376769a6014610c0d5780637897a78e14610c225780637b10399914610c37576103f9565b806372a6b8b014610a50578063765c1fe914610bf8576103f9565b80635c4a3145146109b457806370022cb4146109ed5780637090db4e14610a26578063715018a614610a3b576103f9565b806350614ba0116102e757806350614ba01461090757806354255be01461093a57806356b6d0d5146109755780635a18b08b1461098a576103f9565b806339d7f76e14610846578063408993651461085b5780634cea8ded146108a15780634f8e6e23146108d4576103f9565b8063158ef93e11610390578063220159681161035f578063220159681461078757806322796e83146107ba5780632aa1c16d146107fe57806338345dec14610813576103f9565b8063158ef93e146106d857806317f9a6f7146106ed57806319f373611461071b5780631c39c7d51461074e576103f9565b80630db279be116103cc5780630db279be146104dc57806311bb0dcd146105065780631218f9821461063a57806313baf1e61461069f576103f9565b806301da32bd146103fb57806303a0fea31461042557806303d835f314610472578063042b7a5414610499575b005b34801561040757600080fd5b506103f96004803603602081101561041e57600080fd5b5035611230565b34801561043157600080fd5b5061045e6004803603604081101561044857600080fd5b506001600160a01b03813516906020013561132e565b604080519115158252519081900360200190f35b34801561047e57600080fd5b50610487611489565b60408051918252519081900360200190f35b3480156104a557600080fd5b5061045e600480360360608110156104bc57600080fd5b506001600160a01b0381358116916020810135909116906040013561148f565b3480156104e857600080fd5b50610487600480360360208110156104ff57600080fd5b5035611696565b34801561051257600080fd5b506103f96004803603604081101561052957600080fd5b81019060208101813564010000000081111561054457600080fd5b82018360208201111561055657600080fd5b8035906020019184602083028401116401000000008311171561057857600080fd5b91908080602002602001604051908101604052809392919081815260200183836020028082843760009201919091525092959493602081019350359150506401000000008111156105c857600080fd5b8201836020820111156105da57600080fd5b803590602001918460208302840111640100000000831117156105fc57600080fd5b9190808060200260200160405190810160405280939291908181526020018383602002808284376000920191909152509295506116b4945050505050565b34801561064657600080fd5b5061064f61193a565b60408051602080825283518183015283519192839290830191858101910280838360005b8381101561068b578181015183820152602001610673565b505050509050019250505060405180910390f35b3480156106ab57600080fd5b5061045e600480360360408110156106c257600080fd5b506001600160a01b03813516906020013561199d565b3480156106e457600080fd5b5061045e611be9565b3480156106f957600080fd5b50610702611c0a565b6040805192835260208301919091528051918290030190f35b34801561072757600080fd5b5061045e6004803603602081101561073e57600080fd5b50356001600160a01b0316611d47565b34801561075a57600080fd5b5061045e6004803603604081101561077157600080fd5b506001600160a01b038135169060200135611d5c565b34801561079357600080fd5b5061045e600480360360208110156107aa57600080fd5b50356001600160a01b0316611ed0565b3480156107c657600080fd5b506107cf6120a5565b604080516fffffffffffffffffffffffffffffffff938416815291909216602082015281519081900390910190f35b34801561080a57600080fd5b506104876120d5565b34801561081f57600080fd5b506104876004803603602081101561083657600080fd5b50356001600160a01b031661214b565b34801561085257600080fd5b5061048761230c565b34801561086757600080fd5b506108856004803603602081101561087e57600080fd5b5035612312565b604080516001600160a01b039092168252519081900360200190f35b3480156108ad57600080fd5b5061045e600480360360208110156108c457600080fd5b50356001600160a01b0316612339565b3480156108e057600080fd5b5061045e600480360360208110156108f757600080fd5b50356001600160a01b031661234e565b34801561091357600080fd5b506104876004803603602081101561092a57600080fd5b50356001600160a01b031661236c565b34801561094657600080fd5b5061094f61237e565b604080519485526020850193909352838301919091526060830152519081900360800190f35b34801561098157600080fd5b5061048761238b565b34801561099657600080fd5b50610885600480360360208110156109ad57600080fd5b50356126b7565b3480156109c057600080fd5b5061045e600480360360408110156109d757600080fd5b506001600160a01b0381351690602001356126c4565b3480156109f957600080fd5b5061045e60048036036040811015610a1057600080fd5b506001600160a01b03813516906020013561290d565b348015610a3257600080fd5b50610487612b65565b348015610a4757600080fd5b506103f9612b6b565b348015610a5c57600080fd5b506103f96004803603610160811015610a7457600080fd5b6001600160a01b03823516916020810135916040820135916060810135916080820135919081019060c0810160a0820135640100000000811115610ab757600080fd5b820183602082011115610ac957600080fd5b80359060200191846020830284011164010000000083111715610aeb57600080fd5b919390929091602081019035640100000000811115610b0957600080fd5b820183602082011115610b1b57600080fd5b80359060200191846020830284011164010000000083111715610b3d57600080fd5b919390928235926020810135929190606081019060400135640100000000811115610b6757600080fd5b820183602082011115610b7957600080fd5b80359060200191846020830284011164010000000083111715610b9b57600080fd5b919390929091602081019035640100000000811115610bb957600080fd5b820183602082011115610bcb57600080fd5b80359060200191846020830284011164010000000083111715610bed57600080fd5b509092509050612c26565b348015610c0457600080fd5b50610487612e39565b348015610c1957600080fd5b50610487612e9b565b348015610c2e57600080fd5b50610487612ea1565b348015610c4357600080fd5b50610885612ec2565b348015610c5857600080fd5b5061045e60048036036020811015610c6f57600080fd5b50356001600160a01b0316612ed1565b348015610c8b57600080fd5b50610487612ee6565b348015610ca057600080fd5b5061064f612eec565b348015610cb557600080fd5b50610487612f43565b348015610cca57600080fd5b50610487612f49565b348015610cdf57600080fd5b506103f960048036036020811015610cf657600080fd5b50356001600160a01b0316612f6a565b348015610d1257600080fd5b5061048761300c565b348015610d2757600080fd5b50610885613026565b348015610d3c57600080fd5b5061045e613035565b348015610d5157600080fd5b5061045e60048036036020811015610d6857600080fd5b50356001600160a01b0316613059565b348015610d8457600080fd5b5061045e60048036036020811015610d9b57600080fd5b50356001600160a01b031661320e565b348015610db757600080fd5b5061064f613223565b348015610dcc57600080fd5b506103f960048036036020811015610de357600080fd5b5035613283565b348015610df657600080fd5b5061048760048036036020811015610e0d57600080fd5b50356001600160a01b031661336c565b348015610e2957600080fd5b506103f960048036036020811015610e4057600080fd5b50356001600160a01b031661339b565b348015610e5c57600080fd5b5061064f6134b1565b348015610e7157600080fd5b506103f960048036036020811015610e8857600080fd5b5035613511565b348015610e9b57600080fd5b506103f960048036036040811015610eb257600080fd5b506001600160a01b0381351690602001356135a5565b348015610ed457600080fd5b506103f960048036036040811015610eeb57600080fd5b810190602081018135640100000000811115610f0657600080fd5b820183602082011115610f1857600080fd5b80359060200191846020830284011164010000000083111715610f3a57600080fd5b9190808060200260200160405190810160405280939291908181526020018383602002808284376000920191909152509295949360208101935035915050640100000000811115610f8a57600080fd5b820183602082011115610f9c57600080fd5b80359060200191846020830284011164010000000083111715610fbe57600080fd5b919080806020026020016040519081016040528093929190818152602001838360200280828437600092019190915250929550613802945050505050565b34801561100857600080fd5b5061045e6004803603602081101561101f57600080fd5b50356001600160a01b0316613c06565b34801561103b57600080fd5b5061045e6004803603602081101561105257600080fd5b50356001600160a01b0316613c1b565b34801561106e57600080fd5b50610487613dea565b34801561108357600080fd5b50610487613e16565b34801561109857600080fd5b5061064f613e1c565b3480156110ad57600080fd5b506103f9600480360360208110156110c457600080fd5b5035613eb8565b3480156110d757600080fd5b506103f9600480360360208110156110ee57600080fd5b50356001600160a01b0316613f9b565b34801561110a57600080fd5b506103f96004803603604081101561112157600080fd5b508035906020013561409b565b34801561113a57600080fd5b506104876004803603602081101561115157600080fd5b503561415d565b34801561116457600080fd5b506103f96004803603602081101561117b57600080fd5b50356001600160a01b031661416f565b34801561119757600080fd5b5061045e600480360360208110156111ae57600080fd5b50356001600160a01b031661431f565b3480156111ca57600080fd5b506103f9600480360360208110156111e157600080fd5b50356001600160a01b031661433d565b3480156111fd57600080fd5b506108856004803603602081101561121457600080fd5b50356143a2565b34801561122757600080fd5b506104876143af565b611238613035565b611289576040805162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015290519081900360640190fd5b611292816143b5565b516010556112bd6112a16143cf565b604080516020810190915260105481529063ffffffff6143f316565b6112f85760405162461bcd60e51b81526004018080602001828103825260268152602001806152bc6026913960400191505060405180910390fd5b6040805182815290517fb08f0607338ad77f5b08ccf831e533cefcc2d373c173e87a8f61144f1d82be1e9181900360200190a150565b3360008181526014602052604081205490919060ff16806114265750600154604080517f45786368616e676500000000000000000000000000000000000000000000000060208083019190915282518083036008018152602883018085528151918301919091207fdcf0aaed00000000000000000000000000000000000000000000000000000000909152602c83015291516001600160a01b0380861694169263dcf0aaed92604c8082019391829003018186803b1580156113ef57600080fd5b505afa158015611403573d6000803e3d6000fd5b505050506040513d602081101561141957600080fd5b50516001600160a01b0316145b611477576040805162461bcd60e51b815260206004820152601c60248201527f41646472657373206e6f7420616c6c6f77656420746f207370656e6400000000604482015290519081900360640190fd5b61148184846143fb565b949350505050565b60115481565b3360009081526009602052604081205460ff166114dd5760405162461bcd60e51b815260040180806020018281038252602c8152602001806153aa602c913960400191505060405180910390fd5b6001600160a01b038316611538576040805162461bcd60e51b815260206004820152601d60248201527f63616e206e6f74207472616e7366657220746f20302061646472657373000000604482015290519081900360640190fd5b60006115438561336c565b1161157f5760405162461bcd60e51b81526004018080602001828103825260408152602001806153166040913960400191505060405180910390fd5b6001600160a01b0384166000908152601760205260408120546201518042049081111561161a5760006115b18761214b565b6001600160a01b038816600090815260176020526040902083905590506116166116116115dd836144bb565b6001600160a01b038a166000908152601660209081526040918290208251918201909252905481529063ffffffff61452916565b61489b565b9250505b8382101561166f576040805162461bcd60e51b815260206004820152601860248201527f457863656564696e67207370656e64696e67206c696d69740000000000000000604482015290519081900360640190fd5b61167f828563ffffffff6148ac16565b915061168c8686866148ee565b9695505050505050565b600c81815481106116a357fe5b600091825260209091200154905081565b6116bc613035565b61170d576040805162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015290519081900360640190fd5b805182511461174d5760405162461bcd60e51b815260040180806020018281038252603e8152602001806150eb603e913960400191505060405180910390fd5b60005b82518110156119355760006001600160a01b031683828151811061177057fe5b60200260200101516001600160a01b0316141580156117a3575081818151811061179657fe5b6020026020010151600014155b1561192d576117c48382815181106117b757fe5b602002602001015161431f565b6117ff5760405162461bcd60e51b81526004018080602001828103825260378152602001806151296037913960400191505060405180910390fd5b61183261180a6143cf565b61182684848151811061181957fe5b60200260200101516143b5565b9063ffffffff6143f316565b61186d5760405162461bcd60e51b81526004018080602001828103825260268152602001806152bc6026913960400191505060405180910390fd5b61187c82828151811061181957fe5b6016600085848151811061188c57fe5b60200260200101516001600160a01b03166001600160a01b03168152602001908152602001600020600082015181600001559050507f15ff5079dfbf448e4bb45ac83498c2ecb0833ad35916946bb683ccb49f8013a38382815181106118ee57fe5b602002602001015183838151811061190257fe5b602090810291909101810151604080516001600160a01b039094168452918301528051918290030190a15b600101611750565b505050565b6060601580548060200260200160405190810160405280929190818152602001828054801561199257602002820191906000526020600020905b81546001600160a01b03168152600190910190602001808311611974575b505050505090505b90565b60006119a7613035565b6119f8576040805162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015290519081900360640190fd5b6001600160a01b038316600090815260036020526040902054839060ff16611a67576040805162461bcd60e51b815260206004820152601f60248201527f746f6b656e206164647220776173206e65766572207265676973746572656400604482015290519081900360640190fd5b60045483108015611aa15750836001600160a01b031660048481548110611a8a57fe5b6000918252602090912001546001600160a01b0316145b611adc5760405162461bcd60e51b815260040180806020018281038252602a815260200180615356602a913960400191505060405180910390fd5b6001600160a01b0384166000908152600360205260408120805460ff1916905560048054611b1190600163ffffffff6148ac16565b81548110611b1b57fe5b600091825260209091200154600480546001600160a01b039092169250829186908110611b4457fe5b600091825260209091200180547fffffffffffffffffffffffff0000000000000000000000000000000000000000166001600160a01b0392909216919091179055600454611b939060016148ac565b611b9e60048261500f565b506040805185815290516001600160a01b038716917fbe9bb4bdca0a094babd75e3a98b1d2e2390633430d0a2f6e2b9970e2ee03fb2e919081900360200190a2506001949350505050565b60005474010000000000000000000000000000000000000000900460ff1681565b600280546001019081905560065460055460009283929091611c5390429070010000000000000000000000000000000090046fffffffffffffffffffffffffffffffff166148ac565b1115611cc857611c69611c64614a17565b614a7a565b60058054426fffffffffffffffffffffffffffffffff908116700100000000000000000000000000000000029381167fffffffffffffffffffffffffffffffff0000000000000000000000000000000090921691909117169190911790555b6005546fffffffffffffffffffffffffffffffff16611ce8611c646143cf565b925092506002548114611d42576040805162461bcd60e51b815260206004820152600e60248201527f7265656e7472616e742063616c6c000000000000000000000000000000000000604482015290519081900360640190fd5b509091565b60036020526000908152604090205460ff1681565b3360009081526009602052604081205460ff16611daa5760405162461bcd60e51b815260040180806020018281038252602c8152602001806153aa602c913960400191505060405180910390fd5b6001600160a01b0383166000908152600a602052604090205460ff16611e015760405162461bcd60e51b815260040180806020018281038252602a815260200180615380602a913960400191505060405180910390fd5b600e5462015180420490811115611e53576000611e1c612f49565b600e8390559050611e4e611611611e32836144bb565b604080516020810190915260105481529063ffffffff61452916565b600f55505b82600f541015611eaa576040805162461bcd60e51b815260206004820152601860248201527f457863656564696e67207370656e64696e67206c696d69740000000000000000604482015290519081900360640190fd5b600f54611ebd908463ffffffff6148ac16565b600f5561148184846143fb565b92915050565b6000611eda613035565b611f2b576040805162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015290519081900360640190fd5b60028054600101908190556001600160a01b0383166000908152600a602052604090205460ff1615611fa4576040805162461bcd60e51b815260206004820152601a60248201527f72657365727665206164647220616c7265616479206164646564000000000000604482015290519081900360640190fd5b6001600160a01b0383166000818152600a6020526040808220805460ff19166001908117909155600b8054918201815583527f0175b7a638427703f0dbe7bb9bbf987a2551717b34e79f33b5b1008d1fa01db90180547fffffffffffffffffffffffff00000000000000000000000000000000000000001684179055517fd78793225285ecf9cf5f0f84b1cdc335c2cb4d6810ff0b9fd156ad6026c89cea9190a260019150600254811461209f576040805162461bcd60e51b815260206004820152600e60248201527f7265656e7472616e742063616c6c000000000000000000000000000000000000604482015290519081900360640190fd5b50919050565b6005546fffffffffffffffffffffffffffffffff8082169170010000000000000000000000000000000090041682565b6012546000906201518042049082906120f590839063ffffffff6148ac16565b9050601354811061210b5760009250505061199a565b61214461213560135461212984601154614a7e90919063ffffffff16565b9063ffffffff614ad716565b6011549063ffffffff6148ac16565b9250505090565b60006121568261431f565b6121915760405162461bcd60e51b815260040180806020018281038252602b8152602001806153d6602b913960400191505060405180910390fd5b6000805b600b548110156122675761225d846001600160a01b03166370a08231600b84815481106121be57fe5b60009182526020918290200154604080517fffffffff0000000000000000000000000000000000000000000000000000000060e086901b1681526001600160a01b0390921660048301525160248083019392829003018186803b15801561222457600080fd5b505afa158015612238573d6000803e3d6000fd5b505050506040513d602081101561224e57600080fd5b5051839063ffffffff614b1916565b9150600101612195565b50604080517f70a082310000000000000000000000000000000000000000000000000000000081523060048201529051612305916001600160a01b038616916370a0823191602480820192602092909190829003018186803b1580156122cc57600080fd5b505afa1580156122e0573d6000803e3d6000fd5b505050506040513d60208110156122f657600080fd5b5051829063ffffffff614b1916565b9392505050565b600f5481565b600b818154811061231f57fe5b6000918252602090912001546001600160a01b0316905081565b60146020526000908152604090205460ff1681565b6001600160a01b031660009081526003602052604090205460ff1690565b60176020526000908152604090205481565b6002600160008090919293565b600154604080517f536f727465644f7261636c6573000000000000000000000000000000000000006020808301919091528251808303600d018152602d83018085528151918301919091207fdcf0aaed000000000000000000000000000000000000000000000000000000009091526031830152915160009384936001600160a01b039091169263dcf0aaed9260518083019392829003018186803b15801561243357600080fd5b505afa158015612447573d6000803e3d6000fd5b505050506040513d602081101561245d57600080fd5b5051905080600061246c612f49565b90506000612478615033565b7f63474c4400000000000000000000000000000000000000000000000000000000600052600d6020527f486533e5ef5711c6fceba0b8e8d907d58b0d418a02599d00d65a64e01c112d77546124cc906143b5565b905060005b60045481101561268457600080866001600160a01b031663ef90e1b0600485815481106124fa57fe5b600091825260209091200154604080517fffffffff0000000000000000000000000000000000000000000000000000000060e085901b1681526001600160a01b0390921660048301528051602480840193829003018186803b15801561255f57600080fd5b505afa158015612573573d6000803e3d6000fd5b505050506040513d604081101561258957600080fd5b50805160209091015190925090508015612669576000600484815481106125ac57fe5b60009182526020918290200154604080517f18160ddd00000000000000000000000000000000000000000000000000000000815290516001600160a01b03909216926318160ddd92600480840193829003018186803b15801561260e57600080fd5b505afa158015612622573d6000803e3d6000fd5b505050506040513d602081101561263857600080fd5b50519050600061265284612129848663ffffffff614a7e16565b9050612664878263ffffffff614b1916565b965050505b5061267d905081600163ffffffff614b1916565b90506124d1565b506126ad611c64612694846144bb565b6126a1846126a1886144bb565b9063ffffffff614b7316565b9550505050505090565b6015818154811061231f57fe5b60006126ce613035565b61271f576040805162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015290519081900360640190fd5b6001600160a01b0383166000908152600a602052604090205460ff1661278c576040805162461bcd60e51b815260206004820152601c60248201527f72657365727665206164647220776173206e6576657220616464656400000000604482015290519081900360640190fd5b600b54821080156127c65750826001600160a01b0316600b83815481106127af57fe5b6000918252602090912001546001600160a01b0316145b6128015760405162461bcd60e51b815260040180806020018281038252602d815260200180615257602d913960400191505060405180910390fd5b6001600160a01b0383166000908152600a60205260408120805460ff19169055600b805461283690600163ffffffff6148ac16565b8154811061284057fe5b600091825260209091200154600b80546001600160a01b03909216925082918590811061286957fe5b600091825260209091200180547fffffffffffffffffffffffff0000000000000000000000000000000000000000166001600160a01b0392909216919091179055600b546128b89060016148ac565b6128c3600b8261500f565b506040805184815290516001600160a01b038616917f89b4ee5cecfdfb246ede373c10283b5038afe56a531fc1d2f3ed8c5507a52fcb919081900360200190a25060019392505050565b6000612917613035565b612968576040805162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015290519081900360640190fd5b6129718361431f565b6129ac5760405162461bcd60e51b815260040180806020018281038252602b8152602001806153d6602b913960400191505060405180910390fd5b601854821080156129e65750826001600160a01b0316601883815481106129cf57fe5b6000918252602090912001546001600160a01b0316145b612a215760405162461bcd60e51b81526004018080602001828103825260348152602001806152e26034913960400191505060405180910390fd5b601880547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff8101908110612a5157fe5b600091825260209091200154601880546001600160a01b039092169184908110612a7757fe5b9060005260206000200160006101000a8154816001600160a01b0302191690836001600160a01b031602179055506018805480612ab057fe5b6000828152602080822083017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff90810180547fffffffffffffffffffffffff00000000000000000000000000000000000000001690559092019092556001600160a01b03851680835260198252604092839020805460ff19169055825190815291517f4336391ada1af9dcb966fed43ebafa4404719b6d8e42c765ab28e3abc9a24e7a9281900390910190a150600192915050565b60135481565b612b73613035565b612bc4576040805162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015290519081900360640190fd5b600080546040516001600160a01b03909116907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0908390a3600080547fffffffffffffffffffffffff0000000000000000000000000000000000000000169055565b60005474010000000000000000000000000000000000000000900460ff1615612c96576040805162461bcd60e51b815260206004820152601c60248201527f636f6e747261637420616c726561647920696e697469616c697a656400000000604482015290519081900360640190fd5b600080547fffffffffffffffffffffff00ffffffffffffffffffffffffffffffffffffffff1674010000000000000000000000000000000000000000179055612cde33614c57565b612ce78f61339b565b612cf08e613283565b612cf98d611230565b612d038c8c61409b565b612d708a8a8080602002602001604051908101604052809392919081815260200183836020028082843760009201919091525050604080516020808e0282810182019093528d82529093508d92508c91829185019084908082843760009201919091525061380292505050565b612d7986613eb8565b612d8285613511565b60005b83811015612dba57612db1858583818110612d9c57fe5b905060200201356001600160a01b0316613059565b50600101612d85565b50612e28848480806020026020016040519081016040528093929190818152602001838360200280828437600092019190915250506040805160208088028281018201909352878252909350879250869182918501908490808284376000920191909152506116b492505050565b505050505050505050505050505050565b600080805b600b54811015612e9557612e7b600b8281548110612e5857fe5b60009182526020909120015483906001600160a01b03163163ffffffff614b1916565b9150612e8e81600163ffffffff614b1916565b9050612e3e565b50905090565b60085481565b60408051602081019091526010548152600090612ebd90614a7a565b905090565b6001546001600160a01b031681565b600a6020526000908152604090205460ff1681565b60125481565b6060600c80548060200260200160405190810160405280929190818152602001828054801561199257602002820191906000526020600020905b815481526020019060010190808311612f26575050505050905090565b60075481565b6000612ebd612f56612e39565b612f5e613dea565b9063ffffffff614b1916565b612f72613035565b612fc3576040805162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015290519081900360640190fd5b6001600160a01b038116600081815260096020526040808220805460ff19169055517fab8cff50266d80b9c9d9703af934ca455b9218286bf4fcaa05653a564c499e4b9190a250565b6000612ebd613019612e39565b479063ffffffff614b1916565b6000546001600160a01b031690565b600080546001600160a01b031661304a614d0f565b6001600160a01b031614905090565b6000613063613035565b6130b4576040805162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015290519081900360640190fd5b6130bd8261431f565b156130f95760405162461bcd60e51b81526004018080602001828103825260388152602001806152846038913960400191505060405180910390fd5b6001600160a01b038216613154576040805162461bcd60e51b815260206004820152601760248201527f63616e27742062652061207a65726f2061646472657373000000000000000000604482015290519081900360640190fd5b6001600160a01b0382166000818152601960209081526040808320805460ff191660019081179091556018805491820181559093527fb13d2d76d1f4b7be834882e410b3e3a8afaf69f83600ae24db354391d2378d2e90920180547fffffffffffffffffffffffff00000000000000000000000000000000000000001684179055815192835290517f0c7515883121475b5d9289febf21a9de4ad53f18349a856d90c7acd6e099600b9281900390910190a1506001919050565b60096020526000908152604090205460ff1681565b6060600b805480602002602001604051908101604052809291908181526020018280548015611992576020028201919060005260206000209081546001600160a01b03168152600190910190602001808311611974575050505050905090565b61328b613035565b6132dc576040805162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015290519081900360640190fd5b60008111613331576040805162461bcd60e51b815260206004820152600e60248201527f76616c756520776173207a65726f000000000000000000000000000000000000604482015290519081900360640190fd5b60068190556040805182815290517f7bfe94ca3147f135fcd6d94ebf61d33fa34fbe904f933ccae66911b9548544f29181900360200190a150565b6001600160a01b03811660009081526016602090815260408083208151928301909152548152611eca90614a7a565b6133a3613035565b6133f4576040805162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015290519081900360640190fd5b6001600160a01b03811661344f576040805162461bcd60e51b815260206004820181905260248201527f43616e6e6f7420726567697374657220746865206e756c6c2061646472657373604482015290519081900360640190fd5b600180547fffffffffffffffffffffffff0000000000000000000000000000000000000000166001600160a01b0383169081179091556040517f27fe5f0c1c3b1ed427cc63d0f05759ffdecf9aec9e18d31ef366fc8a6cb5dc3b90600090a250565b60606004805480602002602001604051908101604052809291908181526020018280548015611992576020028201919060005260206000209081546001600160a01b03168152600190910190602001808311611974575050505050905090565b613519613035565b61356a576040805162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015290519081900360640190fd5b60088190556040805182815290517f4da8e8b2223fbbb897200fb9dfb6b986c1b4188621114d407ee8ec363569fc379181900360200190a150565b6135ad613035565b6135fe576040805162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015290519081900360640190fd5b6001600160a01b0382166000908152601460205260409020805460ff19169055601554808210613675576040805162461bcd60e51b815260206004820152601060248201527f496e64657820697320696e76616c696400000000000000000000000000000000604482015290519081900360640190fd5b6015828154811061368257fe5b6000918252602090912001546001600160a01b038481169116146136ed576040805162461bcd60e51b815260206004820152601c60248201527f496e64657820646f6573206e6f74206d61746368207370656e64657200000000604482015290519081900360640190fd5b600061370082600163ffffffff6148ac16565b905080831461376b576015818154811061371657fe5b600091825260209091200154601580546001600160a01b03909216918590811061373c57fe5b9060005260206000200160006101000a8154816001600160a01b0302191690836001600160a01b031602179055505b60006015828154811061377a57fe5b600091825260209091200180547fffffffffffffffffffffffff0000000000000000000000000000000000000000166001600160a01b0392909216919091179055806137c760158261500f565b506040516001600160a01b038516907f20aaa18caa668680a42b328a15fd50d580bac65d8bd346e104355473c6373ff390600090a250505050565b61380a613035565b61385b576040805162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015290519081900360640190fd5b80518251146138b1576040805162461bcd60e51b815260206004820152601560248201527f4172726179206c656e677468206d69736d617463680000000000000000000000604482015290519081900360640190fd5b6138b9615033565b6138c360006143b5565b905060005b825181101561390a576138f06138e384838151811061181957fe5b839063ffffffff614d1316565b915061390381600163ffffffff614b1916565b90506138c8565b506139236139166143cf565b829063ffffffff614d8c16565b61395e5760405162461bcd60e51b81526004018080602001828103825260218152602001806152156021913960400191505060405180910390fd5b60005b600c548110156139b457600d6000600c838154811061397c57fe5b90600052602060002001548152602001908152602001600020600090556139ad600182614b1990919063ffffffff16565b9050613961565b5082516139c890600c906020860190615046565b5060005b8351811015613aa957600d60008583815181106139e557fe5b6020026020010151815260200190815260200160002054600014613a50576040805162461bcd60e51b815260206004820152601760248201527f43616e6e6f742073657420776569676874207477696365000000000000000000604482015290519081900360640190fd5b828181518110613a5c57fe5b6020026020010151600d6000868481518110613a7457fe5b6020026020010151815260200190815260200160002081905550613aa2600182614b1990919063ffffffff16565b90506139cc565b507f63474c4400000000000000000000000000000000000000000000000000000000600052600d6020527f486533e5ef5711c6fceba0b8e8d907d58b0d418a02599d00d65a64e01c112d7754613b46576040805162461bcd60e51b815260206004820152601a60248201527f4d757374207365742063474c4420617373657420776569676874000000000000604482015290519081900360640190fd5b7f55b488abd19ae7621712324d3d42c2ef7a9575f64f5503103286a1161fb408558383604051808060200180602001838103835285818151815260200191508051906020019060200280838360005b83811015613bad578181015183820152602001613b95565b50505050905001838103825284818151815260200191508051906020019060200280838360005b83811015613bec578181015183820152602001613bd4565b5050505090500194505050505060405180910390a1505050565b60196020526000908152604090205460ff1681565b6000613c25613035565b613c76576040805162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015290519081900360640190fd5b60028054600101908190556001600160a01b03831660009081526003602052604090205460ff1615613cef576040805162461bcd60e51b815260206004820152601d60248201527f746f6b656e206164647220616c72656164792072656769737465726564000000604482015290519081900360640190fd5b6001600160a01b038316600081815260036020526040808220805460ff1916600190811790915560048054918201815583527f8a35acfbc15ff81a39ae7d344fd709f28e8600b4aa8c65c6b64bfe7fe36bd19b0180547fffffffffffffffffffffffff00000000000000000000000000000000000000001684179055517f784c8f4dbf0ffedd6e72c76501c545a70f8b203b30a26ce542bf92ba87c248a49190a260019150600254811461209f576040805162461bcd60e51b815260206004820152600e60248201527f7265656e7472616e742063616c6c000000000000000000000000000000000000604482015290519081900360640190fd5b60004781613df66120d5565b9050808211613e06576000612144565b612144828263ffffffff6148ac16565b60065481565b606080600c80549050604051908082528060200260200182016040528015613e4e578160200160208202803883390190505b50905060005b600c54811015612e9557600d6000600c8381548110613e6f57fe5b9060005260206000200154815260200190815260200160002054828281518110613e9557fe5b6020908102919091010152613eb181600163ffffffff614b1916565b9050613e54565b613ec0613035565b613f11576040805162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015290519081900360640190fd5b613f25613f1c6143cf565b611826836143b5565b613f605760405162461bcd60e51b81526004018080602001828103825260218152602001806150ca6021913960400191505060405180910390fd5b60078190556040805182815290517ffe69856ffb1b1d6cb00c1d8151726e6e95032b1666282eeb293ecadd58b29a6e9181900360200190a150565b613fa3613035565b613ff4576040805162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015290519081900360640190fd5b6001600160a01b03811661404f576040805162461bcd60e51b815260206004820152601560248201527f5370656e6465722063616e2774206265206e756c6c0000000000000000000000604482015290519081900360640190fd5b6001600160a01b038116600081815260096020526040808220805460ff19166001179055517f3139419c41cdd7abca84fa19dd21118cd285d3e2ce1a9444e8161ce9fa62fdcd9190a250565b6140a3613035565b6140f4576040805162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015290519081900360640190fd5b47821115614149576040805162461bcd60e51b815260206004820152601f60248201527f43616e6e6f7420667265657a65206d6f7265207468616e2062616c616e636500604482015290519081900360640190fd5b601182905562015180420460125560135550565b600d6020526000908152604090205481565b614177613035565b6141c8576040805162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015290519081900360640190fd5b6001600160a01b038116614223576040805162461bcd60e51b815260206004820152601560248201527f5370656e6465722063616e2774206265206e756c6c0000000000000000000000604482015290519081900360640190fd5b6001600160a01b03811660009081526014602052604090205460ff161561427b5760405162461bcd60e51b81526004018080602001828103825260238152602001806151bc6023913960400191505060405180910390fd5b6001600160a01b038116600081815260146020526040808220805460ff1916600190811790915560158054918201815583527f55f448fdea98c4d29eb340757ef0a66cd03dbb9538908a6a81d96026b71ec4750180547fffffffffffffffffffffffff00000000000000000000000000000000000000001684179055517f71bccdb89fff4d914e3d2e472b327e3debaf4c4d6f1dfe528f430447e4cbcf5f9190a250565b6001600160a01b031660009081526019602052604090205460ff1690565b614345613035565b614396576040805162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015290519081900360640190fd5b61439f81614c57565b50565b6018818154811061231f57fe5b600e5481565b6143bd615033565b50604080516020810190915290815290565b6143d7615033565b50604080516020810190915269d3c21bcecceda1000000815290565b519051111590565b6000614405613dea565b821115614459576040805162461bcd60e51b815260206004820152601b60248201527f457863656564696e6720756e66726f7a656e2072657365727665730000000000604482015290519081900360640190fd5b6144726001600160a01b0384168363ffffffff614d9316565b6040805183815290516001600160a01b0385169133917f4dd1abe16ad3d4f829372dc77766ca2cce34e205af9b10f8cc1fab370425864f9181900360200190a350600192915050565b6144c3615033565b6144cb614e78565b8211156145095760405162461bcd60e51b81526004018080602001828103825260368152602001806151df6036913960400191505060405180910390fd5b50604080516020810190915269d3c21bcecceda100000082028152919050565b614531615033565b8251158061453e57508151155b156145585750604080516020810190915260008152611eca565b815169d3c21bcecceda10000001415614572575081611eca565b825169d3c21bcecceda1000000141561458c575080611eca565b600069d3c21bcecceda10000006145a285614e93565b51816145aa57fe5b04905060006145b885614ec8565b519050600069d3c21bcecceda10000006145d186614e93565b51816145d957fe5b04905060006145e786614ec8565b519050838202841561465057828582816145fd57fe5b0414614650576040805162461bcd60e51b815260206004820152601660248201527f6f766572666c6f77207831793120646574656374656400000000000000000000604482015290519081900360640190fd5b69d3c21bcecceda1000000810281156146ca5769d3c21bcecceda100000082828161467757fe5b04146146ca576040805162461bcd60e51b815260206004820152601f60248201527f6f766572666c6f772078317931202a2066697865643120646574656374656400604482015290519081900360640190fd5b905080848402851561473357848682816146e057fe5b0414614733576040805162461bcd60e51b815260206004820152601660248201527f6f766572666c6f77207832793120646574656374656400000000000000000000604482015290519081900360640190fd5b8684028715614799578488828161474657fe5b0414614799576040805162461bcd60e51b815260206004820152601660248201527f6f766572666c6f77207831793220646574656374656400000000000000000000604482015290519081900360640190fd5b6147a1614f02565b87816147a957fe5b0496506147b4614f02565b85816147bc57fe5b049450868502871561482557858882816147d257fe5b0414614825576040805162461bcd60e51b815260206004820152601660248201527f6f766572666c6f77207832793220646574656374656400000000000000000000604482015290519081900360640190fd5b61482d615033565b604051806020016040528087815250905061485681604051806020016040528087815250614d13565b905061487081604051806020016040528086815250614d13565b905061488a81604051806020016040528085815250614d13565b9d9c50505050505050505050505050565b5169d3c21bcecceda1000000900490565b600061230583836040518060400160405280601e81526020017f536166654d6174683a207375627472616374696f6e206f766572666c6f770000815250614f0b565b60006148f98461214b565b8211156149375760405162461bcd60e51b81526004018080602001828103825260228152602001806151606022913960400191505060405180910390fd5b836001600160a01b031663a9059cbb84846040518363ffffffff1660e01b815260040180836001600160a01b03166001600160a01b0316815260200182815260200192505050602060405180830381600087803b15801561499757600080fd5b505af11580156149ab573d6000803e3d6000fd5b505050506040513d60208110156149c157600080fd5b5050604080518381526001600160a01b03868116602083015282519086169233927fc171b15fb47a5beb3e11b1951d4518544f699edd6acd893d8695c91703922b60929081900390910190a35060019392505050565b614a1f615033565b614a27615033565b614a37614a3261238b565b6143b5565b9050614a54614a476008546143b5565b829063ffffffff614fa216565b15614a6b57614a6360006143b5565b91505061199a565b614a636007546143b5565b5090565b5190565b600082614a8d57506000611eca565b82820282848281614a9a57fe5b04146123055760405162461bcd60e51b81526004018080602001828103825260218152602001806152366021913960400191505060405180910390fd5b600061230583836040518060400160405280601a81526020017f536166654d6174683a206469766973696f6e206279207a65726f000000000000815250614faa565b600082820183811015612305576040805162461bcd60e51b815260206004820152601b60248201527f536166654d6174683a206164646974696f6e206f766572666c6f770000000000604482015290519081900360640190fd5b614b7b615033565b8151614bce576040805162461bcd60e51b815260206004820152601160248201527f63616e2774206469766964652062792030000000000000000000000000000000604482015290519081900360640190fd5b825169d3c21bcecceda10000008181029190820414614c34576040805162461bcd60e51b815260206004820152601260248201527f6f766572666c6f77206174206469766964650000000000000000000000000000604482015290519081900360640190fd5b604051806020016040528084600001518381614c4c57fe5b049052949350505050565b6001600160a01b038116614c9c5760405162461bcd60e51b81526004018080602001828103825260268152602001806150a46026913960400191505060405180910390fd5b600080546040516001600160a01b03808516939216917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e091a3600080547fffffffffffffffffffffffff0000000000000000000000000000000000000000166001600160a01b0392909216919091179055565b3390565b614d1b615033565b8151835190810190811015614d77576040805162461bcd60e51b815260206004820152601560248201527f616464206f766572666c6f772064657465637465640000000000000000000000604482015290519081900360640190fd5b60408051602081019091529081529392505050565b5190511490565b80471015614de8576040805162461bcd60e51b815260206004820152601d60248201527f416464726573733a20696e73756666696369656e742062616c616e6365000000604482015290519081900360640190fd5b6040516000906001600160a01b0384169083908381818185875af1925050503d8060008114614e33576040519150601f19603f3d011682016040523d82523d6000602084013e614e38565b606091505b50509050806119355760405162461bcd60e51b815260040180806020018281038252603a815260200180615182603a913960400191505060405180910390fd5b7601357c299a88ea76a58924d52ce4f26a85af186c2b9e7490565b614e9b615033565b604051806020016040528069d3c21bcecceda100000080856000015181614ebe57fe5b0402905292915050565b614ed0615033565b604051806020016040528069d3c21bcecceda100000080856000015181614ef357fe5b95519504029093039092525090565b64e8d4a5100090565b60008184841115614f9a5760405162461bcd60e51b81526004018080602001828103825283818151815260200191508051906020019080838360005b83811015614f5f578181015183820152602001614f47565b50505050905090810190601f168015614f8c5780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b505050900390565b519051101590565b60008183614ff95760405162461bcd60e51b8152602060048201818152835160248401528351909283926044909101919085019080838360008315614f5f578181015183820152602001614f47565b50600083858161500557fe5b0495945050505050565b81548183558181111561193557600083815260209020611935918101908301615089565b6040518060200160405280600081525090565b828054828255906000526020600020908101928215615081579160200282015b82811115615081578251825591602001919060010190615066565b50614a769291505b61199a91905b80821115614a76576000815560010161508f56fe4f776e61626c653a206e6577206f776e657220697320746865207a65726f2061646472657373746f62696e207461782063616e6e6f74206265206c6172676572207468616e2031746f6b656e2061646472657373657320616e64207370656e64696e6720726174696f206c656e67746873206861766520746f206265207468652073616d65746865206164647265737320737065636966696564206973206e6f742061207265736572766520636f6c6c61746572616c206173736574457863656564696e672074686520616d6f756e74207265736572766520686f6c6473416464726573733a20756e61626c6520746f2073656e642076616c75652c20726563697069656e74206d617920686176652072657665727465644164647265737320697320616c72656164792045786368616e6765205370656e64657263616e277420637265617465206669786964697479206e756d626572206c6172676572207468616e206d61784e65774669786564282953756d206f6620617373657420616c6c6f636174696f6e206d7573742062652031536166654d6174683a206d756c7469706c69636174696f6e206f766572666c6f77696e64657820696e746f2072657365727665206c697374206e6f74206d617070656420746f2061646472657373737065636966696564206164647265737320697320616c7265616479206164646564206173206120636f6c6c61746572616c2061737365747370656e64696e6720726174696f2063616e6e6f74206265206c6172676572207468616e2031696e64657820696e746f20636f6c6c61746572616c417373657473206c697374206e6f74206d617070656420746f20746f6b656e7468697320617373657420686173206e6f207370656e64696e6720726174696f2c207468657265666f72652063616e2774206265207472616e73666572726564696e64657820696e746f20746f6b656e73206c697374206e6f74206d617070656420746f20746f6b656e63616e206f6e6c79207472616e7366657220746f206f746865722072657365727665206164647265737373656e646572206e6f7420616c6c6f77656420746f207472616e7366657220526573657276652066756e64737370656369666965642061646472657373206973206e6f74206120636f6c6c61746572616c206173736574a265627a7a72315820d34fc1551b1ba685399e22867d0c506058f12667876589b364e1847c3a893f4164736f6c63430005110032