Address Details
contract

0xc58eF32b48F8242D0fe9506BD7249c2e19B4A108

Contract Name
Exchange
Creator
0x0cc59e–f1502d at 0x1f4de1–488e47
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
2159393
Contract name:
Exchange




Optimization enabled
false
Compiler version
v0.5.8+commit.23d335f2




Verified at
2020-08-11T19:10:28.404935Z

Contract source code

pragma solidity ^0.5.3;


library SafeMath {
    
    function add(uint256 a, uint256 b) internal pure returns (uint256) {
        uint256 c = a + b;
        require(c >= a, "SafeMath: addition overflow");

        return c;
    }

    
    function sub(uint256 a, uint256 b) internal pure returns (uint256) {
        return sub(a, b, "SafeMath: subtraction overflow");
    }

    
    function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
        require(b <= a, errorMessage);
        uint256 c = a - b;

        return c;
    }

    
    function mul(uint256 a, uint256 b) internal pure returns (uint256) {
        
        
        
        if (a == 0) {
            return 0;
        }

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

        return c;
    }

    
    function div(uint256 a, uint256 b) internal pure returns (uint256) {
        return div(a, b, "SafeMath: division by zero");
    }

    
    function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
        
        require(b > 0, errorMessage);
        uint256 c = a / b;
        

        return c;
    }

    
    function mod(uint256 a, uint256 b) internal pure returns (uint256) {
        return mod(a, b, "SafeMath: modulo by zero");
    }

    
    function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
        require(b != 0, errorMessage);
        return a % b;
    }
}

contract Context {
    
    
    constructor () internal { }
    

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

    function _msgData() internal view returns (bytes memory) {
        this; 
        return msg.data;
    }
}

contract Ownable is Context {
    address private _owner;

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

    
    constructor () internal {
        address msgSender = _msgSender();
        _owner = msgSender;
        emit OwnershipTransferred(address(0), msgSender);
    }

    
    function owner() public view returns (address) {
        return _owner;
    }

    
    modifier onlyOwner() {
        require(isOwner(), "Ownable: caller is not the owner");
        _;
    }

    
    function isOwner() public view returns (bool) {
        return _msgSender() == _owner;
    }

    
    function renounceOwnership() public onlyOwner {
        emit OwnershipTransferred(_owner, address(0));
        _owner = address(0);
    }

    
    function transferOwnership(address newOwner) public onlyOwner {
        _transferOwnership(newOwner);
    }

    
    function _transferOwnership(address newOwner) internal {
        require(newOwner != address(0), "Ownable: new owner is the zero address");
        emit OwnershipTransferred(_owner, newOwner);
        _owner = newOwner;
    }
}

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

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

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

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 balanceOf(address) external view returns (uint256);
}

contract Initializable {
  bool public initialized;

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

library FixidityLib {
  struct Fraction {
    uint256 value;
  }

  
  function digits() internal pure returns (uint8) {
    return 24;
  }

  uint256 private constant FIXED1_UINT = 1000000000000000000000000;

  
  function fixed1() internal pure returns (Fraction memory) {
    return Fraction(FIXED1_UINT);
  }

  
  function wrap(uint256 x) internal pure returns (Fraction memory) {
    return Fraction(x);
  }

  
  function unwrap(Fraction memory x) internal pure returns (uint256) {
    return x.value;
  }

  
  function mulPrecision() internal pure returns (uint256) {
    return 1000000000000;
  }

  
  function maxNewFixed() internal pure returns (uint256) {
    return 115792089237316195423570985008687907853269984665640564;
  }

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

  
  function fromFixed(Fraction memory x) internal pure returns (uint256) {
    return x.value / FIXED1_UINT;
  }

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

  
  function integer(Fraction memory x) internal pure returns (Fraction memory) {
    return Fraction((x.value / FIXED1_UINT) * FIXED1_UINT); 
  }

  
  function fractional(Fraction memory x) internal pure returns (Fraction memory) {
    return Fraction(x.value - (x.value / FIXED1_UINT) * FIXED1_UINT); 
  }

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

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

  
  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;

    
    
    uint256 x1 = integer(x).value / FIXED1_UINT;
    uint256 x2 = fractional(x).value;
    uint256 y1 = integer(y).value / FIXED1_UINT;
    uint256 y2 = fractional(y).value;

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

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

    
    Fraction memory result = Fraction(x1y1);
    result = add(result, Fraction(x2y1)); 
    result = add(result, Fraction(x1y2)); 
    result = add(result, Fraction(x2y2)); 
    return result;
  }

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

  
  function divide(Fraction memory x, Fraction memory y) internal pure returns (Fraction memory) {
    require(y.value != 0, "can't divide by 0");
    uint256 X = x.value * FIXED1_UINT;
    require(X / FIXED1_UINT == x.value, "overflow at divide");
    return Fraction(X / y.value);
  }

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

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

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

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

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

  
  function isProperFraction(Fraction memory x) internal pure returns (bool) {
    return lte(x, fixed1());
  }
}

interface IERC20 {
    
    function totalSupply() external view returns (uint256);

    
    function balanceOf(address account) external view returns (uint256);

    
    function transfer(address recipient, uint256 amount) external returns (bool);

    
    function allowance(address owner, address spender) external view returns (uint256);

    
    function approve(address spender, uint256 amount) external returns (bool);

    
    function transferFrom(address sender, address recipient, uint256 amount) external returns (bool);

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

    
    event Approval(address indexed owner, address indexed spender, uint256 value);
}

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

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

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

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

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

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

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

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

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

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

interface IValidators {
  function getAccountLockedGoldRequirement(address) external view returns (uint256);
  function meetsAccountLockedGoldRequirements(address) external view returns (bool);
  function getGroupNumMembers(address) external view returns (uint256);
  function getGroupsNumMembers(address[] calldata) external view returns (uint256[] memory);
  function getNumRegisteredValidators() external view returns (uint256);
  function getTopGroupValidators(address, uint256) external view returns (address[] memory);
  function updateEcdsaPublicKey(address, address, bytes calldata) external returns (bool);
  function updatePublicKeys(address, address, bytes calldata, bytes calldata, bytes calldata)
    external
    returns (bool);
  function isValidator(address) external view returns (bool);
  function isValidatorGroup(address) external view returns (bool);
  function calculateGroupEpochScore(uint256[] calldata uptimes) external view returns (uint256);
  function groupMembershipInEpoch(address account, uint256 epochNumber, uint256 index)
    external
    view
    returns (address);
  function halveSlashingMultiplier(address group) external;
  function forceDeaffiliateIfValidator(address validator) external;
  function getValidatorGroupSlashingMultiplier(address) external view returns (uint256);
  function affiliate(address group) external returns (bool);
}

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

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

  function setAttestationExpiryBlocks(uint256) external;

  function getMaxAttestations() external view returns (uint256);

  function getUnselectedRequest(bytes32, address) external view returns (uint32, uint32, address);
  function getAttestationRequestFee(address) external view returns (uint256);

  function lookupAccountsForIdentifier(bytes32) external view returns (address[] memory);

  function getAttestationStats(bytes32, address) external view returns (uint32, uint32);

  function getAttestationState(bytes32, address, address)
    external
    view
    returns (uint8, uint32, address);
  function getCompletableAttestations(bytes32, address)
    external
    view
    returns (uint32[] memory, address[] memory, uint256[] memory, bytes memory);
}

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

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

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

  
  function setRegistry(address registryAddress) public onlyOwner {
    require(registryAddress != address(0), "Cannot register the null address");
    registry = IRegistry(registryAddress);
    emit RegistrySet(registryAddress);
  }

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

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

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

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

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

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

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

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

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

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

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

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

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

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

contract Freezable is UsingRegistry {
  
  
  modifier onlyWhenNotFrozen() {
    require(!getFreezer().isFrozen(address(this)), "can't call when contract is frozen");
    _;
  }
}

contract ReentrancyGuard {
  
  uint256 private _guardCounter;

  constructor() internal {
    
    
    _guardCounter = 1;
  }

  
  modifier nonReentrant() {
    _guardCounter += 1;
    uint256 localCounter = _guardCounter;
    _;
    require(localCounter == _guardCounter, "reentrant call");
  }
}

contract Exchange is IExchange, Initializable, Ownable, UsingRegistry, ReentrancyGuard, Freezable {
  using SafeMath for uint256;
  using FixidityLib for FixidityLib.Fraction;

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

  FixidityLib.Fraction public spread;

  
  
  FixidityLib.Fraction public reserveFraction;

  address public stable;

  
  uint256 public goldBucket;
  
  uint256 public stableBucket;

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

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

  
  function initialize(
    address registryAddress,
    address stableToken,
    uint256 _spread,
    uint256 _reserveFraction,
    uint256 _updateFrequency,
    uint256 _minimumReports
  ) external initializer {
    _transferOwnership(msg.sender);
    setRegistry(registryAddress);
    setStableToken(stableToken);
    setSpread(_spread);
    setReserveFraction(_reserveFraction);
    setUpdateFrequency(_updateFrequency);
    setMinimumReports(_minimumReports);
    _updateBucketsIfNecessary();
  }

  
  function exchange(uint256 sellAmount, uint256 minBuyAmount, bool sellGold)
    external
    onlyWhenNotFrozen
    updateBucketsIfNecessary
    nonReentrant
    returns (uint256)
  {
    uint256 buyAmount = _getBuyTokenAmount(sellAmount, sellGold);

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

    IReserve reserve = IReserve(registry.getAddressForOrDie(RESERVE_REGISTRY_ID));

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

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

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

  
  function getBuyTokenAmount(uint256 sellAmount, bool sellGold) external view returns (uint256) {
    uint256 sellTokenBucket;
    uint256 buyTokenBucket;
    (buyTokenBucket, sellTokenBucket) = getBuyAndSellBuckets(sellGold);

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

    
    
    
    
    return numerator.unwrap().div(denominator.unwrap());
  }

  
  function getSellTokenAmount(uint256 buyAmount, bool sellGold) external view returns (uint256) {
    uint256 sellTokenBucket;
    uint256 buyTokenBucket;
    (buyTokenBucket, sellTokenBucket) = getBuyAndSellBuckets(sellGold);

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

    
    return numerator.unwrap().div(denominator.unwrap());
  }

  
  function getBuyAndSellBuckets(bool sellGold) public view returns (uint256, uint256) {
    uint256 currentGoldBucket = goldBucket;
    uint256 currentStableBucket = stableBucket;

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

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

  
  function setUpdateFrequency(uint256 newUpdateFrequency) public onlyOwner {
    updateFrequency = newUpdateFrequency;
    emit UpdateFrequencySet(newUpdateFrequency);
  }

  
  function setMinimumReports(uint256 newMininumReports) public onlyOwner {
    minimumReports = newMininumReports;
    emit MinimumReportsSet(newMininumReports);
  }

  
  function setStableToken(address newStableToken) public onlyOwner {
    stable = newStableToken;
    emit StableTokenSet(newStableToken);
  }

  
  function setSpread(uint256 newSpread) public onlyOwner {
    spread = FixidityLib.wrap(newSpread);
    emit SpreadSet(newSpread);
  }

  
  function setReserveFraction(uint256 newReserveFraction) public onlyOwner {
    reserveFraction = FixidityLib.wrap(newReserveFraction);
    require(reserveFraction.lt(FixidityLib.fixed1()), "reserve fraction must be smaller than 1");
    emit ReserveFractionSet(newReserveFraction);
  }

  
  function _getBuyAndSellBuckets(bool sellGold) private view returns (uint256, uint256) {
    if (sellGold) {
      return (stableBucket, goldBucket);
    } else {
      return (goldBucket, stableBucket);
    }
  }

  
  function _getBuyTokenAmount(uint256 sellAmount, bool sellGold) private view returns (uint256) {
    uint256 sellTokenBucket;
    uint256 buyTokenBucket;
    (buyTokenBucket, sellTokenBucket) = _getBuyAndSellBuckets(sellGold);

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

    
    return numerator.unwrap().div(denominator.unwrap());
  }

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

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

  
  function _updateBucketsIfNecessary() private {
    if (shouldUpdateBuckets()) {
      
      lastBucketUpdate = now;

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

  
  function getReducedSellAmount(uint256 sellAmount)
    private
    view
    returns (FixidityLib.Fraction memory)
  {
    return FixidityLib.fixed1().subtract(spread).multiply(FixidityLib.newFixed(sellAmount));
  }

  
  function shouldUpdateBuckets() private view returns (bool) {
    ISortedOracles sortedOracles = ISortedOracles(
      registry.getAddressForOrDie(SORTED_ORACLES_REGISTRY_ID)
    );
    (bool isReportExpired, ) = sortedOracles.isOldestReportExpired(stable);
    
    bool timePassed = now >= lastBucketUpdate.add(updateFrequency);
    bool enoughReports = sortedOracles.numRates(stable) >= minimumReports;
    
    bool medianReportRecent = sortedOracles.medianTimestamp(stable) > now.sub(updateFrequency);
    return timePassed && enoughReports && medianReportRecent && !isReportExpired;
  }

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

Contract ABI

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

Contract Creation Code

0x6080604052600060085560006100196100c560201b60201c565b905080600060016101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055508073ffffffffffffffffffffffffffffffffffffffff16600073ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a35060016002819055506100cd565b600033905090565b6135e980620000dd6000396000f3fe608060405234801561001057600080fd5b50600436106101735760003560e01c806378ba9cfd116100de578063a91ee0dc11610097578063db1bc87b11610071578063db1bc87b14610601578063dda57b9314610645578063e0c8b50a14610663578063f2fde38b1461068157610173565b8063a91ee0dc14610561578063b66a261c146105a5578063d404f7f8146105d357610173565b806378ba9cfd146103865780637b103999146103d157806386489ba91461041b5780638da5cb5b146104a75780638f32d59b146104f15780639ed02b581461051357610173565b80634c0226a2116101305780634c0226a2146102a65780635c25c76c146102f457806362f0908414610312578063673ea086146103305780636a5eaf471461034e578063715018a61461037c57610173565b8063158ef93e1461017857806322503ce51461019a57806322be3de1146101b857806325ac2de6146102025780632bc7d67a146102205780634a1be6cb14610278575b600080fd5b6101806106c5565b604051808215151515815260200191505060405180910390f35b6101a26106d7565b6040518082815260200191505060405180910390f35b6101c06106dd565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b61020a610703565b6040518082815260200191505060405180910390f35b6102626004803603606081101561023657600080fd5b810190808035906020019092919080359060200190929190803515159060200190929190505050610709565b6040518082815260200191505060405180910390f35b6102a46004803603602081101561028e57600080fd5b8101908080359060200190929190505050611131565b005b6102de600480360360408110156102bc57600080fd5b81019080803590602001909291908035151590602001909291905050506111ec565b6040518082815260200191505060405180910390f35b6102fc6112bc565b6040518082815260200191505060405180910390f35b61031a6112c8565b6040518082815260200191505060405180910390f35b6103386112ce565b6040518082815260200191505060405180910390f35b61037a6004803603602081101561036457600080fd5b81019080803590602001909291905050506112d4565b005b610384611425565b005b6103b46004803603602081101561039c57600080fd5b8101908080351515906020019092919050505061155f565b604051808381526020018281526020019250505060405180910390f35b6103d96115af565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b6104a5600480360360c081101561043157600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803590602001909291908035906020019092919080359060200190929190803590602001909291905050506115d5565b005b6104af6116c0565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b6104f96116e9565b604051808215151515815260200191505060405180910390f35b61054b6004803603604081101561052957600080fd5b8101908080359060200190929190803515159060200190929190505050611747565b6040518082815260200191505060405180910390f35b6105a36004803603602081101561057757600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff1690602001909291905050506117ea565b005b6105d1600480360360208110156105bb57600080fd5b810190808035906020019092919050505061198e565b005b6105ff600480360360208110156105e957600080fd5b8101908080359060200190929190505050611a5a565b005b6106436004803603602081101561061757600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050611b15565b005b61064d611c16565b6040518082815260200191505060405180910390f35b61066b611c22565b6040518082815260200191505060405180910390f35b6106c36004803603602081101561069757600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050611c28565b005b6000809054906101000a900460ff1681565b600a5481565b600560009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b60075481565b6000610713611cae565b73ffffffffffffffffffffffffffffffffffffffff1663e5839836306040518263ffffffff1660e01b8152600401808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060206040518083038186803b15801561078f57600080fd5b505afa1580156107a3573d6000803e3d6000fd5b505050506040513d60208110156107b957600080fd5b810190808051906020019092919050505015610820576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260228152602001806134ee6022913960400191505060405180910390fd5b610828611da9565b600160026000828254019250508190555060006002549050600061084c8685611e1f565b9050848110156108a7576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260398152602001806134b56039913960400191505060405180910390fd5b6000600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663dcf0aaed60405160200180807f52657365727665000000000000000000000000000000000000000000000000008152506007019050604051602081830303815290604052805190602001206040518263ffffffff1660e01b81526004018082815260200191505060206040518083038186803b15801561096257600080fd5b505afa158015610976573d6000803e3d6000fd5b505050506040513d602081101561098c57600080fd5b810190808051906020019092919050505090508415610ca5576109ba87600654611ec290919063ffffffff16565b6006819055506109d582600754611f4a90919063ffffffff16565b6007819055506109e3611f94565b73ffffffffffffffffffffffffffffffffffffffff166323b872dd33838a6040518463ffffffff1660e01b8152600401808473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020018373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020018281526020019350505050602060405180830381600087803b158015610a9d57600080fd5b505af1158015610ab1573d6000803e3d6000fd5b505050506040513d6020811015610ac757600080fd5b8101908080519060200190929190505050610b4a576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601d8152602001807f5472616e73666572206f662073656c6c20746f6b656e206661696c656400000081525060200191505060405180910390fd5b600560009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166340c10f1933846040518363ffffffff1660e01b8152600401808373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200182815260200192505050602060405180830381600087803b158015610bf357600080fd5b505af1158015610c07573d6000803e3d6000fd5b505050506040513d6020811015610c1d57600080fd5b8101908080519060200190929190505050610ca0576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601b8152602001807f4d696e74206f6620737461626c6520746f6b656e206661696c6564000000000081525060200191505060405180910390fd5b61104b565b610cba87600754611ec290919063ffffffff16565b600781905550610cd582600654611f4a90919063ffffffff16565b600681905550600560009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166323b872dd33308a6040518463ffffffff1660e01b8152600401808473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020018373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020018281526020019350505050602060405180830381600087803b158015610db857600080fd5b505af1158015610dcc573d6000803e3d6000fd5b505050506040513d6020811015610de257600080fd5b8101908080519060200190929190505050610e65576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601d8152602001807f5472616e73666572206f662073656c6c20746f6b656e206661696c656400000081525060200191505060405180910390fd5b600560009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166342966c68886040518263ffffffff1660e01b815260040180828152602001915050602060405180830381600087803b158015610eda57600080fd5b505af1158015610eee573d6000803e3d6000fd5b505050506040513d6020811015610f0457600080fd5b8101908080519060200190929190505050508073ffffffffffffffffffffffffffffffffffffffff166303a0fea333846040518363ffffffff1660e01b8152600401808373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200182815260200192505050602060405180830381600087803b158015610f9d57600080fd5b505af1158015610fb1573d6000803e3d6000fd5b505050506040513d6020811015610fc757600080fd5b810190808051906020019092919050505061104a576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601b8152602001807f5472616e73666572206f6620627579546f6b656e206661696c6564000000000081525060200191505060405180910390fd5b5b3373ffffffffffffffffffffffffffffffffffffffff167f402ac9185b4616422c2794bf5b118bfcc68ed496d52c0d9841dfa114fdeb05ba8884886040518084815260200183815260200182151515158152602001935050505060405180910390a281935050506002548114611129576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252600e8152602001807f7265656e7472616e742063616c6c00000000000000000000000000000000000081525060200191505060405180910390fd5b509392505050565b6111396116e9565b6111ab576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260208152602001807f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657281525060200191505060405180910390fd5b806009819055507f90c0a4a142fbfbc2ae8c21f50729a2f4bc56e85a66c1a1b6654f1e85092a54a6816040518082815260200191505060405180910390a150565b60008060006111fa8461155f565b809350819250505061120a61347b565b611225611220848861208f90919063ffffffff16565b612115565b905061122f61347b565b61128b611262600360405180602001604052908160008201548152505061125461219f565b6121c590919063ffffffff16565b61127d6112788a87611f4a90919063ffffffff16565b612115565b61226c90919063ffffffff16565b90506112b0611299826126cb565b6112a2846126cb565b6126d990919063ffffffff16565b94505050505092915050565b60038060000154905081565b60065481565b60095481565b6112dc6116e9565b61134e576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260208152602001807f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657281525060200191505060405180910390fd5b61135781612723565b60046000820151816000015590505061139661137161219f565b600460405180602001604052908160008201548152505061274190919063ffffffff16565b6113eb576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260278152602001806135976027913960400191505060405180910390fd5b7fb690f84efb1d9039c2834effb7bebc792a85bfec7ef84f4b269528454f363ccf816040518082815260200191505060405180910390a150565b61142d6116e9565b61149f576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260208152602001807f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657281525060200191505060405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff16600060019054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a360008060016101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550565b6000806000600654905060006007549050611578612756565b1561158e57611585612b53565b80925081935050505b84156115a15780829350935050506115aa565b81819350935050505b915091565b600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b6000809054906101000a900460ff1615611657576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601c8152602001807f636f6e747261637420616c726561647920696e697469616c697a65640000000081525060200191505060405180910390fd5b60016000806101000a81548160ff02191690831515021790555061167a33612bac565b611683866117ea565b61168c85611b15565b6116958461198e565b61169e836112d4565b6116a782611131565b6116b081611a5a565b6116b8611da9565b505050505050565b60008060019054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905090565b60008060019054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1661172b612cf2565b73ffffffffffffffffffffffffffffffffffffffff1614905090565b60008060006117558461155f565b809350819250505061176561347b565b61176e86612cfa565b905061177861347b565b61179361178484612115565b8361226c90919063ffffffff16565b905061179d61347b565b6117b8836117aa87612115565b612d5390919063ffffffff16565b90506117dd6117c6826126cb565b6117cf846126cb565b6126d990919063ffffffff16565b9550505050505092915050565b6117f26116e9565b611864576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260208152602001807f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657281525060200191505060405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff161415611907576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260208152602001807f43616e6e6f7420726567697374657220746865206e756c6c206164647265737381525060200191505060405180910390fd5b80600160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055508073ffffffffffffffffffffffffffffffffffffffff167f27fe5f0c1c3b1ed427cc63d0f05759ffdecf9aec9e18d31ef366fc8a6cb5dc3b60405160405180910390a250565b6119966116e9565b611a08576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260208152602001807f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657281525060200191505060405180910390fd5b611a1181612723565b6003600082015181600001559050507f8946f328efcc515b5cc3282f6cd95e87a6c0d3508421af0b52d4d3620b3e2db3816040518082815260200191505060405180910390a150565b611a626116e9565b611ad4576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260208152602001807f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657281525060200191505060405180910390fd5b80600a819055507f08523596abc266fb46d9c40ddf78fdfd3c08142252833ddce1a2b46f76521035816040518082815260200191505060405180910390a150565b611b1d6116e9565b611b8f576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260208152602001807f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657281525060200191505060405180910390fd5b80600560006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055508073ffffffffffffffffffffffffffffffffffffffff167f119a23392e161a0bc5f9d5f3e2a6040c45b40d43a36973e10ea1de916f3d8a8a60405160405180910390a250565b60048060000154905081565b60085481565b611c306116e9565b611ca2576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260208152602001807f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657281525060200191505060405180910390fd5b611cab81612bac565b50565b6000600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663dcf0aaed60405160200180807f467265657a6572000000000000000000000000000000000000000000000000008152506007019050604051602081830303815290604052805190602001206040518263ffffffff1660e01b81526004018082815260200191505060206040518083038186803b158015611d6957600080fd5b505afa158015611d7d573d6000803e3d6000fd5b505050506040513d6020811015611d9357600080fd5b8101908080519060200190929190505050905090565b611db1612756565b15611e1d5742600881905550611dc5612b53565b60066000600760008491905055839190505550507fa18ec663cb684011386aa866c4dacb32d2d2ad859a35d3440b6ce7200a76bad8600654600754604051808381526020018281526020019250505060405180910390a15b565b6000806000611e2d84612dfc565b8093508192505050611e3d61347b565b611e4686612cfa565b9050611e5061347b565b611e6b611e5c84612115565b8361226c90919063ffffffff16565b9050611e7561347b565b611e9083611e8287612115565b612d5390919063ffffffff16565b9050611eb5611e9e826126cb565b611ea7846126cb565b6126d990919063ffffffff16565b9550505050505092915050565b600080828401905083811015611f40576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601b8152602001807f536166654d6174683a206164646974696f6e206f766572666c6f77000000000081525060200191505060405180910390fd5b8091505092915050565b6000611f8c83836040518060400160405280601e81526020017f536166654d6174683a207375627472616374696f6e206f766572666c6f770000815250612e24565b905092915050565b6000600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663dcf0aaed60405160200180807f476f6c64546f6b656e00000000000000000000000000000000000000000000008152506009019050604051602081830303815290604052805190602001206040518263ffffffff1660e01b81526004018082815260200191505060206040518083038186803b15801561204f57600080fd5b505afa158015612063573d6000803e3d6000fd5b505050506040513d602081101561207957600080fd5b8101908080519060200190929190505050905090565b6000808314156120a2576000905061210f565b60008284029050828482816120b357fe5b041461210a576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260218152602001806135766021913960400191505060405180910390fd5b809150505b92915050565b61211d61347b565b612125612ee4565b82111561217d576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260368152602001806135106036913960400191505060405180910390fd5b604051806020016040528069d3c21bcecceda100000084028152509050919050565b6121a761347b565b604051806020016040528069d3c21bcecceda1000000815250905090565b6121cd61347b565b81600001518360000151101561224b576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601f8152602001807f737562737472616374696f6e20756e646572666c6f772064657465637465640081525060200191505060405180910390fd5b60405180602001604052808360000151856000015103815250905092915050565b61227461347b565b60008360000151148061228b575060008260000151145b156122a7576040518060200160405280600081525090506126c5565b69d3c21bcecceda1000000826000015114156122c5578290506126c5565b69d3c21bcecceda1000000836000015114156122e3578190506126c5565b600069d3c21bcecceda10000006122f985612f03565b600001518161230457fe5b049050600061231285612f3a565b600001519050600069d3c21bcecceda100000061232e86612f03565b600001518161233957fe5b049050600061234786612f3a565b60000151905060008285029050600085146123db578285828161236657fe5b04146123da576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260168152602001807f6f766572666c6f7720783179312064657465637465640000000000000000000081525060200191505060405180910390fd5b5b600069d3c21bcecceda1000000820290506000821461247d5769d3c21bcecceda100000082828161240857fe5b041461247c576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601f8152602001807f6f766572666c6f772078317931202a206669786564312064657465637465640081525060200191505060405180910390fd5b5b809150600084860290506000861461250e578486828161249957fe5b041461250d576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260168152602001807f6f766572666c6f7720783279312064657465637465640000000000000000000081525060200191505060405180910390fd5b5b600084880290506000881461259c578488828161252757fe5b041461259b576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260168152602001807f6f766572666c6f7720783179322064657465637465640000000000000000000081525060200191505060405180910390fd5b5b6125a4612f77565b87816125ac57fe5b0496506125b7612f77565b85816125bf57fe5b049450600085880290506000881461265057858882816125db57fe5b041461264f576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260168152602001807f6f766572666c6f7720783279322064657465637465640000000000000000000081525060200191505060405180910390fd5b5b61265861347b565b604051806020016040528087815250905061268181604051806020016040528087815250612d53565b905061269b81604051806020016040528086815250612d53565b90506126b581604051806020016040528085815250612d53565b9050809a50505050505050505050505b92915050565b600081600001519050919050565b600061271b83836040518060400160405280601a81526020017f536166654d6174683a206469766973696f6e206279207a65726f000000000000815250612f84565b905092915050565b61272b61347b565b6040518060200160405280838152509050919050565b60008160000151836000015110905092915050565b600080600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663dcf0aaed60405160200180807f536f727465644f7261636c657300000000000000000000000000000000000000815250600d019050604051602081830303815290604052805190602001206040518263ffffffff1660e01b81526004018082815260200191505060206040518083038186803b15801561281257600080fd5b505afa158015612826573d6000803e3d6000fd5b505050506040513d602081101561283c57600080fd5b8101908080519060200190929190505050905060008173ffffffffffffffffffffffffffffffffffffffff1663ffe736bf600560009054906101000a900473ffffffffffffffffffffffffffffffffffffffff166040518263ffffffff1660e01b8152600401808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001915050604080518083038186803b1580156128ef57600080fd5b505afa158015612903573d6000803e3d6000fd5b505050506040513d604081101561291957600080fd5b8101908080519060200190929190805190602001909291905050505090506000612950600954600854611ec290919063ffffffff16565b42101590506000600a548473ffffffffffffffffffffffffffffffffffffffff1663bbc66a94600560009054906101000a900473ffffffffffffffffffffffffffffffffffffffff166040518263ffffffff1660e01b8152600401808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060206040518083038186803b1580156129f957600080fd5b505afa158015612a0d573d6000803e3d6000fd5b505050506040513d6020811015612a2357600080fd5b8101908080519060200190929190505050101590506000612a4f60095442611f4a90919063ffffffff16565b8573ffffffffffffffffffffffffffffffffffffffff1663071b48fc600560009054906101000a900473ffffffffffffffffffffffffffffffffffffffff166040518263ffffffff1660e01b8152600401808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060206040518083038186803b158015612aee57600080fd5b505afa158015612b02573d6000803e3d6000fd5b505050506040513d6020811015612b1857600080fd5b8101908080519060200190929190505050119050828015612b365750815b8015612b3f5750805b8015612b49575083155b9550505050505090565b6000806000612b6061304a565b9050600080612b6d613116565b80925081935050506000612b9c82612b8e868661208f90919063ffffffff16565b6126d990919063ffffffff16565b9050838195509550505050509091565b600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff161415612c32576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252602681526020018061348f6026913960400191505060405180910390fd5b8073ffffffffffffffffffffffffffffffffffffffff16600060019054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a380600060016101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050565b600033905090565b612d0261347b565b612d4c612d0e83612115565b612d3e6003604051806020016040529081600082015481525050612d3061219f565b6121c590919063ffffffff16565b61226c90919063ffffffff16565b9050919050565b612d5b61347b565b6000826000015184600001510190508360000151811015612de4576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260158152602001807f616464206f766572666c6f77206465746563746564000000000000000000000081525060200191505060405180910390fd5b60405180602001604052808281525091505092915050565b6000808215612e145760075460065491509150612e1f565b600654600754915091505b915091565b6000838311158290612ed1576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825283818151815260200191508051906020019080838360005b83811015612e96578082015181840152602081019050612e7b565b50505050905090810190601f168015612ec35780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b5060008385039050809150509392505050565b60007601357c299a88ea76a58924d52ce4f26a85af186c2b9e74905090565b612f0b61347b565b604051806020016040528069d3c21bcecceda100000080856000015181612f2e57fe5b04028152509050919050565b612f4261347b565b604051806020016040528069d3c21bcecceda100000080856000015181612f6557fe5b04028460000151038152509050919050565b600064e8d4a51000905090565b60008083118290613030576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825283818151815260200191508051906020019080838360005b83811015612ff5578082015181840152602081019050612fda565b50505050905090810190601f1680156130225780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b50600083858161303c57fe5b049050809150509392505050565b60008061305561335f565b73ffffffffffffffffffffffffffffffffffffffff16638b7df8d46040518163ffffffff1660e01b815260040160206040518083038186803b15801561309a57600080fd5b505afa1580156130ae573d6000803e3d6000fd5b505050506040513d60208110156130c457600080fd5b8101908080519060200190929190505050905061311061310b6130e683612115565b600460405180602001604052908160008201548152505061226c90919063ffffffff16565b61345a565b91505090565b600080600080600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663dcf0aaed60405160200180807f536f727465644f7261636c657300000000000000000000000000000000000000815250600d019050604051602081830303815290604052805190602001206040518263ffffffff1660e01b81526004018082815260200191505060206040518083038186803b1580156131d557600080fd5b505afa1580156131e9573d6000803e3d6000fd5b505050506040513d60208110156131ff57600080fd5b810190808051906020019092919050505073ffffffffffffffffffffffffffffffffffffffff1663ef90e1b0600560009054906101000a900473ffffffffffffffffffffffffffffffffffffffff166040518263ffffffff1660e01b8152600401808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001915050604080518083038186803b1580156132ad57600080fd5b505afa1580156132c1573d6000803e3d6000fd5b505050506040513d60408110156132d757600080fd5b810190808051906020019092919080519060200190929190505050809250819350505060008111613353576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260308152602001806135466030913960400191505060405180910390fd5b81819350935050509091565b6000600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663dcf0aaed60405160200180807f52657365727665000000000000000000000000000000000000000000000000008152506007019050604051602081830303815290604052805190602001206040518263ffffffff1660e01b81526004018082815260200191505060206040518083038186803b15801561341a57600080fd5b505afa15801561342e573d6000803e3d6000fd5b505050506040513d602081101561344457600080fd5b8101908080519060200190929190505050905090565b600069d3c21bcecceda100000082600001518161347357fe5b049050919050565b604051806020016040528060008152509056fe4f776e61626c653a206e6577206f776e657220697320746865207a65726f206164647265737343616c63756c6174656420627579416d6f756e7420776173206c657373207468616e20737065636966696564206d696e427579416d6f756e7463616e27742063616c6c207768656e20636f6e74726163742069732066726f7a656e63616e277420637265617465206669786964697479206e756d626572206c6172676572207468616e206d61784e65774669786564282965786368616e676520726174652064656e6f6d696e61746f72206d7573742062652067726561746572207468616e2030536166654d6174683a206d756c7469706c69636174696f6e206f766572666c6f7772657365727665206672616374696f6e206d75737420626520736d616c6c6572207468616e2031a165627a7a723058206f2b53decc97249f3bb4ec81e509420cde8b273eef73f0deb8d4179ff96ad7990029

Deployed ByteCode

0x608060405234801561001057600080fd5b50600436106101735760003560e01c806378ba9cfd116100de578063a91ee0dc11610097578063db1bc87b11610071578063db1bc87b14610601578063dda57b9314610645578063e0c8b50a14610663578063f2fde38b1461068157610173565b8063a91ee0dc14610561578063b66a261c146105a5578063d404f7f8146105d357610173565b806378ba9cfd146103865780637b103999146103d157806386489ba91461041b5780638da5cb5b146104a75780638f32d59b146104f15780639ed02b581461051357610173565b80634c0226a2116101305780634c0226a2146102a65780635c25c76c146102f457806362f0908414610312578063673ea086146103305780636a5eaf471461034e578063715018a61461037c57610173565b8063158ef93e1461017857806322503ce51461019a57806322be3de1146101b857806325ac2de6146102025780632bc7d67a146102205780634a1be6cb14610278575b600080fd5b6101806106c5565b604051808215151515815260200191505060405180910390f35b6101a26106d7565b6040518082815260200191505060405180910390f35b6101c06106dd565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b61020a610703565b6040518082815260200191505060405180910390f35b6102626004803603606081101561023657600080fd5b810190808035906020019092919080359060200190929190803515159060200190929190505050610709565b6040518082815260200191505060405180910390f35b6102a46004803603602081101561028e57600080fd5b8101908080359060200190929190505050611131565b005b6102de600480360360408110156102bc57600080fd5b81019080803590602001909291908035151590602001909291905050506111ec565b6040518082815260200191505060405180910390f35b6102fc6112bc565b6040518082815260200191505060405180910390f35b61031a6112c8565b6040518082815260200191505060405180910390f35b6103386112ce565b6040518082815260200191505060405180910390f35b61037a6004803603602081101561036457600080fd5b81019080803590602001909291905050506112d4565b005b610384611425565b005b6103b46004803603602081101561039c57600080fd5b8101908080351515906020019092919050505061155f565b604051808381526020018281526020019250505060405180910390f35b6103d96115af565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b6104a5600480360360c081101561043157600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803590602001909291908035906020019092919080359060200190929190803590602001909291905050506115d5565b005b6104af6116c0565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b6104f96116e9565b604051808215151515815260200191505060405180910390f35b61054b6004803603604081101561052957600080fd5b8101908080359060200190929190803515159060200190929190505050611747565b6040518082815260200191505060405180910390f35b6105a36004803603602081101561057757600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff1690602001909291905050506117ea565b005b6105d1600480360360208110156105bb57600080fd5b810190808035906020019092919050505061198e565b005b6105ff600480360360208110156105e957600080fd5b8101908080359060200190929190505050611a5a565b005b6106436004803603602081101561061757600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050611b15565b005b61064d611c16565b6040518082815260200191505060405180910390f35b61066b611c22565b6040518082815260200191505060405180910390f35b6106c36004803603602081101561069757600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050611c28565b005b6000809054906101000a900460ff1681565b600a5481565b600560009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b60075481565b6000610713611cae565b73ffffffffffffffffffffffffffffffffffffffff1663e5839836306040518263ffffffff1660e01b8152600401808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060206040518083038186803b15801561078f57600080fd5b505afa1580156107a3573d6000803e3d6000fd5b505050506040513d60208110156107b957600080fd5b810190808051906020019092919050505015610820576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260228152602001806134ee6022913960400191505060405180910390fd5b610828611da9565b600160026000828254019250508190555060006002549050600061084c8685611e1f565b9050848110156108a7576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260398152602001806134b56039913960400191505060405180910390fd5b6000600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663dcf0aaed60405160200180807f52657365727665000000000000000000000000000000000000000000000000008152506007019050604051602081830303815290604052805190602001206040518263ffffffff1660e01b81526004018082815260200191505060206040518083038186803b15801561096257600080fd5b505afa158015610976573d6000803e3d6000fd5b505050506040513d602081101561098c57600080fd5b810190808051906020019092919050505090508415610ca5576109ba87600654611ec290919063ffffffff16565b6006819055506109d582600754611f4a90919063ffffffff16565b6007819055506109e3611f94565b73ffffffffffffffffffffffffffffffffffffffff166323b872dd33838a6040518463ffffffff1660e01b8152600401808473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020018373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020018281526020019350505050602060405180830381600087803b158015610a9d57600080fd5b505af1158015610ab1573d6000803e3d6000fd5b505050506040513d6020811015610ac757600080fd5b8101908080519060200190929190505050610b4a576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601d8152602001807f5472616e73666572206f662073656c6c20746f6b656e206661696c656400000081525060200191505060405180910390fd5b600560009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166340c10f1933846040518363ffffffff1660e01b8152600401808373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200182815260200192505050602060405180830381600087803b158015610bf357600080fd5b505af1158015610c07573d6000803e3d6000fd5b505050506040513d6020811015610c1d57600080fd5b8101908080519060200190929190505050610ca0576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601b8152602001807f4d696e74206f6620737461626c6520746f6b656e206661696c6564000000000081525060200191505060405180910390fd5b61104b565b610cba87600754611ec290919063ffffffff16565b600781905550610cd582600654611f4a90919063ffffffff16565b600681905550600560009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166323b872dd33308a6040518463ffffffff1660e01b8152600401808473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020018373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020018281526020019350505050602060405180830381600087803b158015610db857600080fd5b505af1158015610dcc573d6000803e3d6000fd5b505050506040513d6020811015610de257600080fd5b8101908080519060200190929190505050610e65576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601d8152602001807f5472616e73666572206f662073656c6c20746f6b656e206661696c656400000081525060200191505060405180910390fd5b600560009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166342966c68886040518263ffffffff1660e01b815260040180828152602001915050602060405180830381600087803b158015610eda57600080fd5b505af1158015610eee573d6000803e3d6000fd5b505050506040513d6020811015610f0457600080fd5b8101908080519060200190929190505050508073ffffffffffffffffffffffffffffffffffffffff166303a0fea333846040518363ffffffff1660e01b8152600401808373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200182815260200192505050602060405180830381600087803b158015610f9d57600080fd5b505af1158015610fb1573d6000803e3d6000fd5b505050506040513d6020811015610fc757600080fd5b810190808051906020019092919050505061104a576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601b8152602001807f5472616e73666572206f6620627579546f6b656e206661696c6564000000000081525060200191505060405180910390fd5b5b3373ffffffffffffffffffffffffffffffffffffffff167f402ac9185b4616422c2794bf5b118bfcc68ed496d52c0d9841dfa114fdeb05ba8884886040518084815260200183815260200182151515158152602001935050505060405180910390a281935050506002548114611129576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252600e8152602001807f7265656e7472616e742063616c6c00000000000000000000000000000000000081525060200191505060405180910390fd5b509392505050565b6111396116e9565b6111ab576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260208152602001807f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657281525060200191505060405180910390fd5b806009819055507f90c0a4a142fbfbc2ae8c21f50729a2f4bc56e85a66c1a1b6654f1e85092a54a6816040518082815260200191505060405180910390a150565b60008060006111fa8461155f565b809350819250505061120a61347b565b611225611220848861208f90919063ffffffff16565b612115565b905061122f61347b565b61128b611262600360405180602001604052908160008201548152505061125461219f565b6121c590919063ffffffff16565b61127d6112788a87611f4a90919063ffffffff16565b612115565b61226c90919063ffffffff16565b90506112b0611299826126cb565b6112a2846126cb565b6126d990919063ffffffff16565b94505050505092915050565b60038060000154905081565b60065481565b60095481565b6112dc6116e9565b61134e576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260208152602001807f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657281525060200191505060405180910390fd5b61135781612723565b60046000820151816000015590505061139661137161219f565b600460405180602001604052908160008201548152505061274190919063ffffffff16565b6113eb576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260278152602001806135976027913960400191505060405180910390fd5b7fb690f84efb1d9039c2834effb7bebc792a85bfec7ef84f4b269528454f363ccf816040518082815260200191505060405180910390a150565b61142d6116e9565b61149f576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260208152602001807f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657281525060200191505060405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff16600060019054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a360008060016101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550565b6000806000600654905060006007549050611578612756565b1561158e57611585612b53565b80925081935050505b84156115a15780829350935050506115aa565b81819350935050505b915091565b600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b6000809054906101000a900460ff1615611657576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601c8152602001807f636f6e747261637420616c726561647920696e697469616c697a65640000000081525060200191505060405180910390fd5b60016000806101000a81548160ff02191690831515021790555061167a33612bac565b611683866117ea565b61168c85611b15565b6116958461198e565b61169e836112d4565b6116a782611131565b6116b081611a5a565b6116b8611da9565b505050505050565b60008060019054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905090565b60008060019054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1661172b612cf2565b73ffffffffffffffffffffffffffffffffffffffff1614905090565b60008060006117558461155f565b809350819250505061176561347b565b61176e86612cfa565b905061177861347b565b61179361178484612115565b8361226c90919063ffffffff16565b905061179d61347b565b6117b8836117aa87612115565b612d5390919063ffffffff16565b90506117dd6117c6826126cb565b6117cf846126cb565b6126d990919063ffffffff16565b9550505050505092915050565b6117f26116e9565b611864576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260208152602001807f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657281525060200191505060405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff161415611907576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260208152602001807f43616e6e6f7420726567697374657220746865206e756c6c206164647265737381525060200191505060405180910390fd5b80600160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055508073ffffffffffffffffffffffffffffffffffffffff167f27fe5f0c1c3b1ed427cc63d0f05759ffdecf9aec9e18d31ef366fc8a6cb5dc3b60405160405180910390a250565b6119966116e9565b611a08576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260208152602001807f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657281525060200191505060405180910390fd5b611a1181612723565b6003600082015181600001559050507f8946f328efcc515b5cc3282f6cd95e87a6c0d3508421af0b52d4d3620b3e2db3816040518082815260200191505060405180910390a150565b611a626116e9565b611ad4576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260208152602001807f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657281525060200191505060405180910390fd5b80600a819055507f08523596abc266fb46d9c40ddf78fdfd3c08142252833ddce1a2b46f76521035816040518082815260200191505060405180910390a150565b611b1d6116e9565b611b8f576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260208152602001807f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657281525060200191505060405180910390fd5b80600560006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055508073ffffffffffffffffffffffffffffffffffffffff167f119a23392e161a0bc5f9d5f3e2a6040c45b40d43a36973e10ea1de916f3d8a8a60405160405180910390a250565b60048060000154905081565b60085481565b611c306116e9565b611ca2576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260208152602001807f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657281525060200191505060405180910390fd5b611cab81612bac565b50565b6000600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663dcf0aaed60405160200180807f467265657a6572000000000000000000000000000000000000000000000000008152506007019050604051602081830303815290604052805190602001206040518263ffffffff1660e01b81526004018082815260200191505060206040518083038186803b158015611d6957600080fd5b505afa158015611d7d573d6000803e3d6000fd5b505050506040513d6020811015611d9357600080fd5b8101908080519060200190929190505050905090565b611db1612756565b15611e1d5742600881905550611dc5612b53565b60066000600760008491905055839190505550507fa18ec663cb684011386aa866c4dacb32d2d2ad859a35d3440b6ce7200a76bad8600654600754604051808381526020018281526020019250505060405180910390a15b565b6000806000611e2d84612dfc565b8093508192505050611e3d61347b565b611e4686612cfa565b9050611e5061347b565b611e6b611e5c84612115565b8361226c90919063ffffffff16565b9050611e7561347b565b611e9083611e8287612115565b612d5390919063ffffffff16565b9050611eb5611e9e826126cb565b611ea7846126cb565b6126d990919063ffffffff16565b9550505050505092915050565b600080828401905083811015611f40576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601b8152602001807f536166654d6174683a206164646974696f6e206f766572666c6f77000000000081525060200191505060405180910390fd5b8091505092915050565b6000611f8c83836040518060400160405280601e81526020017f536166654d6174683a207375627472616374696f6e206f766572666c6f770000815250612e24565b905092915050565b6000600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663dcf0aaed60405160200180807f476f6c64546f6b656e00000000000000000000000000000000000000000000008152506009019050604051602081830303815290604052805190602001206040518263ffffffff1660e01b81526004018082815260200191505060206040518083038186803b15801561204f57600080fd5b505afa158015612063573d6000803e3d6000fd5b505050506040513d602081101561207957600080fd5b8101908080519060200190929190505050905090565b6000808314156120a2576000905061210f565b60008284029050828482816120b357fe5b041461210a576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260218152602001806135766021913960400191505060405180910390fd5b809150505b92915050565b61211d61347b565b612125612ee4565b82111561217d576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260368152602001806135106036913960400191505060405180910390fd5b604051806020016040528069d3c21bcecceda100000084028152509050919050565b6121a761347b565b604051806020016040528069d3c21bcecceda1000000815250905090565b6121cd61347b565b81600001518360000151101561224b576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601f8152602001807f737562737472616374696f6e20756e646572666c6f772064657465637465640081525060200191505060405180910390fd5b60405180602001604052808360000151856000015103815250905092915050565b61227461347b565b60008360000151148061228b575060008260000151145b156122a7576040518060200160405280600081525090506126c5565b69d3c21bcecceda1000000826000015114156122c5578290506126c5565b69d3c21bcecceda1000000836000015114156122e3578190506126c5565b600069d3c21bcecceda10000006122f985612f03565b600001518161230457fe5b049050600061231285612f3a565b600001519050600069d3c21bcecceda100000061232e86612f03565b600001518161233957fe5b049050600061234786612f3a565b60000151905060008285029050600085146123db578285828161236657fe5b04146123da576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260168152602001807f6f766572666c6f7720783179312064657465637465640000000000000000000081525060200191505060405180910390fd5b5b600069d3c21bcecceda1000000820290506000821461247d5769d3c21bcecceda100000082828161240857fe5b041461247c576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601f8152602001807f6f766572666c6f772078317931202a206669786564312064657465637465640081525060200191505060405180910390fd5b5b809150600084860290506000861461250e578486828161249957fe5b041461250d576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260168152602001807f6f766572666c6f7720783279312064657465637465640000000000000000000081525060200191505060405180910390fd5b5b600084880290506000881461259c578488828161252757fe5b041461259b576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260168152602001807f6f766572666c6f7720783179322064657465637465640000000000000000000081525060200191505060405180910390fd5b5b6125a4612f77565b87816125ac57fe5b0496506125b7612f77565b85816125bf57fe5b049450600085880290506000881461265057858882816125db57fe5b041461264f576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260168152602001807f6f766572666c6f7720783279322064657465637465640000000000000000000081525060200191505060405180910390fd5b5b61265861347b565b604051806020016040528087815250905061268181604051806020016040528087815250612d53565b905061269b81604051806020016040528086815250612d53565b90506126b581604051806020016040528085815250612d53565b9050809a50505050505050505050505b92915050565b600081600001519050919050565b600061271b83836040518060400160405280601a81526020017f536166654d6174683a206469766973696f6e206279207a65726f000000000000815250612f84565b905092915050565b61272b61347b565b6040518060200160405280838152509050919050565b60008160000151836000015110905092915050565b600080600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663dcf0aaed60405160200180807f536f727465644f7261636c657300000000000000000000000000000000000000815250600d019050604051602081830303815290604052805190602001206040518263ffffffff1660e01b81526004018082815260200191505060206040518083038186803b15801561281257600080fd5b505afa158015612826573d6000803e3d6000fd5b505050506040513d602081101561283c57600080fd5b8101908080519060200190929190505050905060008173ffffffffffffffffffffffffffffffffffffffff1663ffe736bf600560009054906101000a900473ffffffffffffffffffffffffffffffffffffffff166040518263ffffffff1660e01b8152600401808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001915050604080518083038186803b1580156128ef57600080fd5b505afa158015612903573d6000803e3d6000fd5b505050506040513d604081101561291957600080fd5b8101908080519060200190929190805190602001909291905050505090506000612950600954600854611ec290919063ffffffff16565b42101590506000600a548473ffffffffffffffffffffffffffffffffffffffff1663bbc66a94600560009054906101000a900473ffffffffffffffffffffffffffffffffffffffff166040518263ffffffff1660e01b8152600401808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060206040518083038186803b1580156129f957600080fd5b505afa158015612a0d573d6000803e3d6000fd5b505050506040513d6020811015612a2357600080fd5b8101908080519060200190929190505050101590506000612a4f60095442611f4a90919063ffffffff16565b8573ffffffffffffffffffffffffffffffffffffffff1663071b48fc600560009054906101000a900473ffffffffffffffffffffffffffffffffffffffff166040518263ffffffff1660e01b8152600401808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060206040518083038186803b158015612aee57600080fd5b505afa158015612b02573d6000803e3d6000fd5b505050506040513d6020811015612b1857600080fd5b8101908080519060200190929190505050119050828015612b365750815b8015612b3f5750805b8015612b49575083155b9550505050505090565b6000806000612b6061304a565b9050600080612b6d613116565b80925081935050506000612b9c82612b8e868661208f90919063ffffffff16565b6126d990919063ffffffff16565b9050838195509550505050509091565b600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff161415612c32576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252602681526020018061348f6026913960400191505060405180910390fd5b8073ffffffffffffffffffffffffffffffffffffffff16600060019054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a380600060016101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050565b600033905090565b612d0261347b565b612d4c612d0e83612115565b612d3e6003604051806020016040529081600082015481525050612d3061219f565b6121c590919063ffffffff16565b61226c90919063ffffffff16565b9050919050565b612d5b61347b565b6000826000015184600001510190508360000151811015612de4576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260158152602001807f616464206f766572666c6f77206465746563746564000000000000000000000081525060200191505060405180910390fd5b60405180602001604052808281525091505092915050565b6000808215612e145760075460065491509150612e1f565b600654600754915091505b915091565b6000838311158290612ed1576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825283818151815260200191508051906020019080838360005b83811015612e96578082015181840152602081019050612e7b565b50505050905090810190601f168015612ec35780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b5060008385039050809150509392505050565b60007601357c299a88ea76a58924d52ce4f26a85af186c2b9e74905090565b612f0b61347b565b604051806020016040528069d3c21bcecceda100000080856000015181612f2e57fe5b04028152509050919050565b612f4261347b565b604051806020016040528069d3c21bcecceda100000080856000015181612f6557fe5b04028460000151038152509050919050565b600064e8d4a51000905090565b60008083118290613030576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825283818151815260200191508051906020019080838360005b83811015612ff5578082015181840152602081019050612fda565b50505050905090810190601f1680156130225780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b50600083858161303c57fe5b049050809150509392505050565b60008061305561335f565b73ffffffffffffffffffffffffffffffffffffffff16638b7df8d46040518163ffffffff1660e01b815260040160206040518083038186803b15801561309a57600080fd5b505afa1580156130ae573d6000803e3d6000fd5b505050506040513d60208110156130c457600080fd5b8101908080519060200190929190505050905061311061310b6130e683612115565b600460405180602001604052908160008201548152505061226c90919063ffffffff16565b61345a565b91505090565b600080600080600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663dcf0aaed60405160200180807f536f727465644f7261636c657300000000000000000000000000000000000000815250600d019050604051602081830303815290604052805190602001206040518263ffffffff1660e01b81526004018082815260200191505060206040518083038186803b1580156131d557600080fd5b505afa1580156131e9573d6000803e3d6000fd5b505050506040513d60208110156131ff57600080fd5b810190808051906020019092919050505073ffffffffffffffffffffffffffffffffffffffff1663ef90e1b0600560009054906101000a900473ffffffffffffffffffffffffffffffffffffffff166040518263ffffffff1660e01b8152600401808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001915050604080518083038186803b1580156132ad57600080fd5b505afa1580156132c1573d6000803e3d6000fd5b505050506040513d60408110156132d757600080fd5b810190808051906020019092919080519060200190929190505050809250819350505060008111613353576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260308152602001806135466030913960400191505060405180910390fd5b81819350935050509091565b6000600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663dcf0aaed60405160200180807f52657365727665000000000000000000000000000000000000000000000000008152506007019050604051602081830303815290604052805190602001206040518263ffffffff1660e01b81526004018082815260200191505060206040518083038186803b15801561341a57600080fd5b505afa15801561342e573d6000803e3d6000fd5b505050506040513d602081101561344457600080fd5b8101908080519060200190929190505050905090565b600069d3c21bcecceda100000082600001518161347357fe5b049050919050565b604051806020016040528060008152509056fe4f776e61626c653a206e6577206f776e657220697320746865207a65726f206164647265737343616c63756c6174656420627579416d6f756e7420776173206c657373207468616e20737065636966696564206d696e427579416d6f756e7463616e27742063616c6c207768656e20636f6e74726163742069732066726f7a656e63616e277420637265617465206669786964697479206e756d626572206c6172676572207468616e206d61784e65774669786564282965786368616e676520726174652064656e6f6d696e61746f72206d7573742062652067726561746572207468616e2030536166654d6174683a206d756c7469706c69636174696f6e206f766572666c6f7772657365727665206672616374696f6e206d75737420626520736d616c6c6572207468616e2031a165627a7a723058206f2b53decc97249f3bb4ec81e509420cde8b273eef73f0deb8d4179ff96ad7990029