Celo Epoch Data is now available on Celo Explorer! READ MORE

Contract Address Details

0xe6F77e6c1Df6Aea40923659C0415d82119F34882

Contract Name
Governance
Creator
0xe1207b–0408ee at 0x2fe2b8–925d14
Balance
0 CELO ( )
Tokens
Fetching tokens...
Transactions
0 Transactions
Transfers
0 Transfers
Gas Used
Fetching gas used...
Last Balance Update
16593937
This contract has been partially verified via Sourcify. View contract in Sourcify repository
Contract name:
Governance




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




EVM Version
istanbul




Verified at
2022-03-23T14:45:53.920628Z

/home/eruiz/Projects/celo/celo-monorepo/packages/protocol/contracts/governance/Governance.sol

pragma solidity ^0.5.13;

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

import "./interfaces/IGovernance.sol";
import "./Proposals.sol";
import "../common/interfaces/IAccounts.sol";
import "../common/ExtractFunctionSignature.sol";
import "../common/Initializable.sol";
import "../common/FixidityLib.sol";
import "../common/linkedlists/IntegerSortedLinkedList.sol";
import "../common/UsingRegistry.sol";
import "../common/UsingPrecompiles.sol";
import "../common/interfaces/ICeloVersionedContract.sol";
import "../common/libraries/ReentrancyGuard.sol";

/**
 * @title A contract for making, passing, and executing on-chain governance proposals.
 */
contract Governance is
  IGovernance,
  ICeloVersionedContract,
  Ownable,
  Initializable,
  ReentrancyGuard,
  UsingRegistry,
  UsingPrecompiles
{
  using Proposals for Proposals.Proposal;
  using FixidityLib for FixidityLib.Fraction;
  using SafeMath for uint256;
  using IntegerSortedLinkedList for SortedLinkedList.List;
  using BytesLib for bytes;
  using Address for address payable; // prettier-ignore

  uint256 private constant FIXED_HALF = 500000000000000000000000;

  enum VoteValue { None, Abstain, No, Yes }

  struct UpvoteRecord {
    uint256 proposalId;
    uint256 weight;
  }

  struct VoteRecord {
    Proposals.VoteValue value;
    uint256 proposalId;
    uint256 weight;
  }

  struct Voter {
    // Key of the proposal voted for in the proposal queue
    UpvoteRecord upvote;
    uint256 mostRecentReferendumProposal;
    // Maps a `dequeued` index to a voter's vote record.
    mapping(uint256 => VoteRecord) referendumVotes;
  }

  struct ContractConstitution {
    FixidityLib.Fraction defaultThreshold;
    // Maps a function ID to a corresponding threshold, overriding the default.
    mapping(bytes4 => FixidityLib.Fraction) functionThresholds;
  }

  struct HotfixRecord {
    bool executed;
    bool approved;
    uint256 preparedEpoch;
    mapping(address => bool) whitelisted;
  }

  // The baseline is updated as
  // max{floor, (1 - baselineUpdateFactor) * baseline + baselineUpdateFactor * participation}
  struct ParticipationParameters {
    // The average network participation in governance, weighted toward recent proposals.
    FixidityLib.Fraction baseline;
    // The lower bound on the participation baseline.
    FixidityLib.Fraction baselineFloor;
    // The weight of the most recent proposal's participation on the baseline.
    FixidityLib.Fraction baselineUpdateFactor;
    // The proportion of the baseline that constitutes quorum.
    FixidityLib.Fraction baselineQuorumFactor;
  }

  Proposals.StageDurations public stageDurations;
  uint256 public queueExpiry;
  uint256 public dequeueFrequency;
  address public approver;
  uint256 public lastDequeue;
  uint256 public concurrentProposals;
  uint256 public proposalCount;
  uint256 public minDeposit;
  mapping(address => uint256) public refundedDeposits;
  mapping(address => ContractConstitution) private constitution;
  mapping(uint256 => Proposals.Proposal) private proposals;
  mapping(address => Voter) private voters;
  mapping(bytes32 => HotfixRecord) public hotfixes;
  SortedLinkedList.List private queue;
  uint256[] public dequeued;
  uint256[] public emptyIndices;
  ParticipationParameters private participationParameters;

  event ApproverSet(address indexed approver);

  event ConcurrentProposalsSet(uint256 concurrentProposals);

  event MinDepositSet(uint256 minDeposit);

  event QueueExpirySet(uint256 queueExpiry);

  event DequeueFrequencySet(uint256 dequeueFrequency);

  event ApprovalStageDurationSet(uint256 approvalStageDuration);

  event ReferendumStageDurationSet(uint256 referendumStageDuration);

  event ExecutionStageDurationSet(uint256 executionStageDuration);

  event ConstitutionSet(address indexed destination, bytes4 indexed functionId, uint256 threshold);

  event ProposalQueued(
    uint256 indexed proposalId,
    address indexed proposer,
    uint256 transactionCount,
    uint256 deposit,
    uint256 timestamp
  );

  event ProposalUpvoted(uint256 indexed proposalId, address indexed account, uint256 upvotes);

  event ProposalUpvoteRevoked(
    uint256 indexed proposalId,
    address indexed account,
    uint256 revokedUpvotes
  );

  event ProposalDequeued(uint256 indexed proposalId, uint256 timestamp);

  event ProposalApproved(uint256 indexed proposalId);

  event ProposalVoted(
    uint256 indexed proposalId,
    address indexed account,
    uint256 value,
    uint256 weight
  );

  event ProposalVoteRevoked(
    uint256 indexed proposalId,
    address indexed account,
    uint256 value,
    uint256 weight
  );

  event ProposalExecuted(uint256 indexed proposalId);

  event ProposalExpired(uint256 indexed proposalId);

  event ParticipationBaselineUpdated(uint256 participationBaseline);

  event ParticipationFloorSet(uint256 participationFloor);

  event ParticipationBaselineUpdateFactorSet(uint256 baselineUpdateFactor);

  event ParticipationBaselineQuorumFactorSet(uint256 baselineQuorumFactor);

  event HotfixWhitelisted(bytes32 indexed hash, address whitelister);

  event HotfixApproved(bytes32 indexed hash);

  event HotfixPrepared(bytes32 indexed hash, uint256 indexed epoch);

  event HotfixExecuted(bytes32 indexed hash);

  modifier hotfixNotExecuted(bytes32 hash) {
    require(!hotfixes[hash].executed, "hotfix already executed");
    _;
  }

  modifier onlyApprover() {
    require(msg.sender == approver, "msg.sender not approver");
    _;
  }

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

  function() external payable {
    require(msg.data.length == 0, "unknown method");
  }

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

  /**
   * @notice Used in place of the constructor to allow the contract to be upgradable via proxy.
   * @param registryAddress The address of the registry contract.
   * @param _approver The address that needs to approve proposals to move to the referendum stage.
   * @param _concurrentProposals The number of proposals to dequeue at once.
   * @param _minDeposit The minimum CELO deposit needed to make a proposal.
   * @param _queueExpiry The number of seconds a proposal can stay in the queue before expiring.
   * @param _dequeueFrequency The number of seconds before the next batch of proposals can be
   *   dequeued.
   * @param approvalStageDuration The number of seconds the approver has to approve a proposal
   *   after it is dequeued.
   * @param referendumStageDuration The number of seconds users have to vote on a dequeued proposal
   *   after the approval stage ends.
   * @param executionStageDuration The number of seconds users have to execute a passed proposal
   *   after the referendum stage ends.
   * @param participationBaseline The initial value of the participation baseline.
   * @param participationFloor The participation floor.
   * @param baselineUpdateFactor The weight of the new participation in the baseline update rule.
   * @param baselineQuorumFactor The proportion of the baseline that constitutes quorum.
   * @dev Should be called only once.
   */
  function initialize(
    address registryAddress,
    address _approver,
    uint256 _concurrentProposals,
    uint256 _minDeposit,
    uint256 _queueExpiry,
    uint256 _dequeueFrequency,
    uint256 approvalStageDuration,
    uint256 referendumStageDuration,
    uint256 executionStageDuration,
    uint256 participationBaseline,
    uint256 participationFloor,
    uint256 baselineUpdateFactor,
    uint256 baselineQuorumFactor
  ) external initializer {
    _transferOwnership(msg.sender);
    setRegistry(registryAddress);
    setApprover(_approver);
    setConcurrentProposals(_concurrentProposals);
    setMinDeposit(_minDeposit);
    setQueueExpiry(_queueExpiry);
    setDequeueFrequency(_dequeueFrequency);
    setApprovalStageDuration(approvalStageDuration);
    setReferendumStageDuration(referendumStageDuration);
    setExecutionStageDuration(executionStageDuration);
    setParticipationBaseline(participationBaseline);
    setParticipationFloor(participationFloor);
    setBaselineUpdateFactor(baselineUpdateFactor);
    setBaselineQuorumFactor(baselineQuorumFactor);
    // solhint-disable-next-line not-rely-on-time
    lastDequeue = now;
  }

  /**
   * @notice Updates the address that has permission to approve proposals in the approval stage.
   * @param _approver The address that has permission to approve proposals in the approval stage.
   */
  function setApprover(address _approver) public onlyOwner {
    require(_approver != address(0), "Approver cannot be 0");
    require(_approver != approver, "Approver unchanged");
    approver = _approver;
    emit ApproverSet(_approver);
  }

  /**
   * @notice Updates the number of proposals to dequeue at a time.
   * @param _concurrentProposals The number of proposals to dequeue at at a time.
   */
  function setConcurrentProposals(uint256 _concurrentProposals) public onlyOwner {
    require(_concurrentProposals > 0, "Number of proposals must be larger than zero");
    require(_concurrentProposals != concurrentProposals, "Number of proposals unchanged");
    concurrentProposals = _concurrentProposals;
    emit ConcurrentProposalsSet(_concurrentProposals);
  }

  /**
   * @notice Updates the minimum deposit needed to make a proposal.
   * @param _minDeposit The minimum CELO deposit needed to make a proposal.
   */
  function setMinDeposit(uint256 _minDeposit) public onlyOwner {
    require(_minDeposit > 0, "minDeposit must be larger than 0");
    require(_minDeposit != minDeposit, "Minimum deposit unchanged");
    minDeposit = _minDeposit;
    emit MinDepositSet(_minDeposit);
  }

  /**
   * @notice Updates the number of seconds before a queued proposal expires.
   * @param _queueExpiry The number of seconds a proposal can stay in the queue before expiring.
   */
  function setQueueExpiry(uint256 _queueExpiry) public onlyOwner {
    require(_queueExpiry > 0, "QueueExpiry must be larger than 0");
    require(_queueExpiry != queueExpiry, "QueueExpiry unchanged");
    queueExpiry = _queueExpiry;
    emit QueueExpirySet(_queueExpiry);
  }

  /**
   * @notice Updates the minimum number of seconds before the next batch of proposals can be
   *   dequeued.
   * @param _dequeueFrequency The number of seconds before the next batch of proposals can be
   *   dequeued.
   */
  function setDequeueFrequency(uint256 _dequeueFrequency) public onlyOwner {
    require(_dequeueFrequency > 0, "dequeueFrequency must be larger than 0");
    require(_dequeueFrequency != dequeueFrequency, "dequeueFrequency unchanged");
    dequeueFrequency = _dequeueFrequency;
    emit DequeueFrequencySet(_dequeueFrequency);
  }

  /**
   * @notice Updates the number of seconds proposals stay in the approval stage.
   * @param approvalStageDuration The number of seconds proposals stay in the approval stage.
   */
  function setApprovalStageDuration(uint256 approvalStageDuration) public onlyOwner {
    require(approvalStageDuration > 0, "Duration must be larger than 0");
    require(approvalStageDuration != stageDurations.approval, "Duration unchanged");
    stageDurations.approval = approvalStageDuration;
    emit ApprovalStageDurationSet(approvalStageDuration);
  }

  /**
   * @notice Updates the number of seconds proposals stay in the referendum stage.
   * @param referendumStageDuration The number of seconds proposals stay in the referendum stage.
   */
  function setReferendumStageDuration(uint256 referendumStageDuration) public onlyOwner {
    require(referendumStageDuration > 0, "Duration must be larger than 0");
    require(referendumStageDuration != stageDurations.referendum, "Duration unchanged");
    stageDurations.referendum = referendumStageDuration;
    emit ReferendumStageDurationSet(referendumStageDuration);
  }

  /**
   * @notice Updates the number of seconds proposals stay in the execution stage.
   * @param executionStageDuration The number of seconds proposals stay in the execution stage.
   */
  function setExecutionStageDuration(uint256 executionStageDuration) public onlyOwner {
    require(executionStageDuration > 0, "Duration must be larger than 0");
    require(executionStageDuration != stageDurations.execution, "Duration unchanged");
    stageDurations.execution = executionStageDuration;
    emit ExecutionStageDurationSet(executionStageDuration);
  }

  /**
   * @notice Updates the participation baseline.
   * @param participationBaseline The value of the baseline.
   */
  function setParticipationBaseline(uint256 participationBaseline) public onlyOwner {
    FixidityLib.Fraction memory participationBaselineFrac = FixidityLib.wrap(participationBaseline);
    require(
      FixidityLib.isProperFraction(participationBaselineFrac),
      "Participation baseline greater than one"
    );
    require(
      !participationBaselineFrac.equals(participationParameters.baseline),
      "Participation baseline unchanged"
    );
    participationParameters.baseline = participationBaselineFrac;
    emit ParticipationBaselineUpdated(participationBaseline);
  }

  /**
   * @notice Updates the floor of the participation baseline.
   * @param participationFloor The value at which the baseline is floored.
   */
  function setParticipationFloor(uint256 participationFloor) public onlyOwner {
    FixidityLib.Fraction memory participationFloorFrac = FixidityLib.wrap(participationFloor);
    require(
      FixidityLib.isProperFraction(participationFloorFrac),
      "Participation floor greater than one"
    );
    require(
      !participationFloorFrac.equals(participationParameters.baselineFloor),
      "Participation baseline floor unchanged"
    );
    participationParameters.baselineFloor = participationFloorFrac;
    emit ParticipationFloorSet(participationFloor);
  }

  /**
   * @notice Updates the weight of the new participation in the baseline update rule.
   * @param baselineUpdateFactor The new baseline update factor.
   */
  function setBaselineUpdateFactor(uint256 baselineUpdateFactor) public onlyOwner {
    FixidityLib.Fraction memory baselineUpdateFactorFrac = FixidityLib.wrap(baselineUpdateFactor);
    require(
      FixidityLib.isProperFraction(baselineUpdateFactorFrac),
      "Baseline update factor greater than one"
    );
    require(
      !baselineUpdateFactorFrac.equals(participationParameters.baselineUpdateFactor),
      "Baseline update factor unchanged"
    );
    participationParameters.baselineUpdateFactor = baselineUpdateFactorFrac;
    emit ParticipationBaselineUpdateFactorSet(baselineUpdateFactor);
  }

  /**
   * @notice Updates the proportion of the baseline that constitutes quorum.
   * @param baselineQuorumFactor The new baseline quorum factor.
   */
  function setBaselineQuorumFactor(uint256 baselineQuorumFactor) public onlyOwner {
    FixidityLib.Fraction memory baselineQuorumFactorFrac = FixidityLib.wrap(baselineQuorumFactor);
    require(
      FixidityLib.isProperFraction(baselineQuorumFactorFrac),
      "Baseline quorum factor greater than one"
    );
    require(
      !baselineQuorumFactorFrac.equals(participationParameters.baselineQuorumFactor),
      "Baseline quorum factor unchanged"
    );
    participationParameters.baselineQuorumFactor = baselineQuorumFactorFrac;
    emit ParticipationBaselineQuorumFactorSet(baselineQuorumFactor);
  }

  /**
   * @notice Updates the ratio of yes:yes+no votes needed for a specific class of proposals to pass.
   * @param destination The destination of proposals for which this threshold should apply.
   * @param functionId The function ID of proposals for which this threshold should apply. Zero
   *   will set the default.
   * @param threshold The threshold.
   * @dev If no constitution is explicitly set the default is a simple majority, i.e. 1:2.
   */
  function setConstitution(address destination, bytes4 functionId, uint256 threshold)
    external
    onlyOwner
  {
    require(destination != address(0), "Destination cannot be zero");
    require(
      threshold > FIXED_HALF && threshold <= FixidityLib.fixed1().unwrap(),
      "Threshold has to be greater than majority and not greater than unanimity"
    );
    if (functionId == 0) {
      constitution[destination].defaultThreshold = FixidityLib.wrap(threshold);
    } else {
      constitution[destination].functionThresholds[functionId] = FixidityLib.wrap(threshold);
    }
    emit ConstitutionSet(destination, functionId, threshold);
  }

  /**
   * @notice Creates a new proposal and adds it to end of the queue with no upvotes.
   * @param values The values of CELO to be sent in the proposed transactions.
   * @param destinations The destination addresses of the proposed transactions.
   * @param data The concatenated data to be included in the proposed transactions.
   * @param dataLengths The lengths of each transaction's data.
   * @return The ID of the newly proposed proposal.
   * @dev The minimum deposit must be included with the proposal, returned if/when the proposal is
   *   dequeued.
   */
  function propose(
    uint256[] calldata values,
    address[] calldata destinations,
    bytes calldata data,
    uint256[] calldata dataLengths,
    string calldata descriptionUrl
  ) external payable returns (uint256) {
    dequeueProposalsIfReady();
    require(msg.value >= minDeposit, "Too small deposit");

    proposalCount = proposalCount.add(1);
    Proposals.Proposal storage proposal = proposals[proposalCount];
    proposal.make(values, destinations, data, dataLengths, msg.sender, msg.value);
    proposal.setDescriptionUrl(descriptionUrl);
    queue.push(proposalCount);
    // solhint-disable-next-line not-rely-on-time
    emit ProposalQueued(proposalCount, msg.sender, proposal.transactions.length, msg.value, now);
    return proposalCount;
  }

  /**
   * @notice Removes a proposal if it is queued and expired.
   * @param proposalId The ID of the proposal to remove.
   * @return Whether the proposal was removed.
   */
  function removeIfQueuedAndExpired(uint256 proposalId) private returns (bool) {
    if (isQueued(proposalId) && isQueuedProposalExpired(proposalId)) {
      queue.remove(proposalId);
      emit ProposalExpired(proposalId);
      return true;
    }
    return false;
  }

  /**
   * @notice Requires a proposal is dequeued and removes it if expired.
   * @param proposalId The ID of the proposal.
   * @return The proposal storage struct and stage corresponding to `proposalId`.
   */
  function requireDequeuedAndDeleteExpired(uint256 proposalId, uint256 index)
    private
    returns (Proposals.Proposal storage, Proposals.Stage)
  {
    Proposals.Proposal storage proposal = proposals[proposalId];
    require(_isDequeuedProposal(proposal, proposalId, index), "Proposal not dequeued");
    Proposals.Stage stage = proposal.getDequeuedStage(stageDurations);
    if (_isDequeuedProposalExpired(proposal, stage)) {
      deleteDequeuedProposal(proposal, proposalId, index);
      return (proposal, Proposals.Stage.Expiration);
    }
    return (proposal, stage);
  }

  /**
   * @notice Upvotes a queued proposal.
   * @param proposalId The ID of the proposal to upvote.
   * @param lesser The ID of the proposal that will be just behind `proposalId` in the queue.
   * @param greater The ID of the proposal that will be just ahead `proposalId` in the queue.
   * @return Whether or not the upvote was made successfully.
   * @dev Provide 0 for `lesser`/`greater` when the proposal will be at the tail/head of the queue.
   * @dev Reverts if the account has already upvoted a proposal in the queue.
   */
  function upvote(uint256 proposalId, uint256 lesser, uint256 greater)
    external
    nonReentrant
    returns (bool)
  {
    dequeueProposalsIfReady();
    // If acting on an expired proposal, expire the proposal and take no action.
    if (removeIfQueuedAndExpired(proposalId)) {
      return false;
    }

    address account = getAccounts().voteSignerToAccount(msg.sender);
    Voter storage voter = voters[account];
    removeIfQueuedAndExpired(voter.upvote.proposalId);

    // We can upvote a proposal in the queue if we're not already upvoting a proposal in the queue.
    uint256 weight = getLockedGold().getAccountTotalLockedGold(account);
    require(weight > 0, "cannot upvote without locking gold");
    require(queue.contains(proposalId), "cannot upvote a proposal not in the queue");
    require(
      voter.upvote.proposalId == 0 || !queue.contains(voter.upvote.proposalId),
      "cannot upvote more than one queued proposal"
    );
    uint256 upvotes = queue.getValue(proposalId).add(weight);
    queue.update(proposalId, upvotes, lesser, greater);
    voter.upvote = UpvoteRecord(proposalId, weight);
    emit ProposalUpvoted(proposalId, account, weight);
    return true;
  }

  /**
   * @notice Returns stage of governance process given proposal is in
   * @param proposalId The ID of the proposal to query.
   * @return proposal stage
   */
  function getProposalStage(uint256 proposalId) external view returns (Proposals.Stage) {
    if (proposalId == 0 || proposalId > proposalCount) {
      return Proposals.Stage.None;
    }
    Proposals.Proposal storage proposal = proposals[proposalId];
    if (isQueued(proposalId)) {
      return
        _isQueuedProposalExpired(proposal) ? Proposals.Stage.Expiration : Proposals.Stage.Queued;
    } else {
      Proposals.Stage stage = proposal.getDequeuedStage(stageDurations);
      return _isDequeuedProposalExpired(proposal, stage) ? Proposals.Stage.Expiration : stage;
    }
  }

  /**
   * @notice Revokes an upvote on a queued proposal.
   * @param lesser The ID of the proposal that will be just behind the previously upvoted proposal
   *   in the queue.
   * @param greater The ID of the proposal that will be just ahead of the previously upvoted
   *   proposal in the queue.
   * @return Whether or not the upvote was revoked successfully.
   * @dev Provide 0 for `lesser`/`greater` when the proposal will be at the tail/head of the queue.
   */
  function revokeUpvote(uint256 lesser, uint256 greater) external nonReentrant returns (bool) {
    dequeueProposalsIfReady();
    address account = getAccounts().voteSignerToAccount(msg.sender);
    Voter storage voter = voters[account];
    uint256 proposalId = voter.upvote.proposalId;
    require(proposalId != 0, "Account has no historical upvote");
    removeIfQueuedAndExpired(proposalId);
    if (queue.contains(proposalId)) {
      queue.update(
        proposalId,
        queue.getValue(proposalId).sub(voter.upvote.weight),
        lesser,
        greater
      );
      emit ProposalUpvoteRevoked(proposalId, account, voter.upvote.weight);
    }
    voter.upvote = UpvoteRecord(0, 0);
    return true;
  }

  /**
   * @notice Approves a proposal in the approval stage.
   * @param proposalId The ID of the proposal to approve.
   * @param index The index of the proposal ID in `dequeued`.
   * @return Whether or not the approval was made successfully.
   */
  function approve(uint256 proposalId, uint256 index) external onlyApprover returns (bool) {
    dequeueProposalsIfReady();
    (Proposals.Proposal storage proposal, Proposals.Stage stage) = requireDequeuedAndDeleteExpired(
      proposalId,
      index
    );
    if (!proposal.exists()) {
      return false;
    }

    require(!proposal.isApproved(), "Proposal already approved");
    require(stage == Proposals.Stage.Approval, "Proposal not in approval stage");
    proposal.approved = true;
    // Ensures networkWeight is set by the end of the Referendum stage, even if 0 votes are cast.
    proposal.networkWeight = getLockedGold().getTotalLockedGold();
    emit ProposalApproved(proposalId);
    return true;
  }

  /**
   * @notice Votes on a proposal in the referendum stage.
   * @param proposalId The ID of the proposal to vote on.
   * @param index The index of the proposal ID in `dequeued`.
   * @param value Whether to vote yes, no, or abstain.
   * @return Whether or not the vote was cast successfully.
   */
  /* solhint-disable code-complexity */
  function vote(uint256 proposalId, uint256 index, Proposals.VoteValue value)
    external
    nonReentrant
    returns (bool)
  {
    dequeueProposalsIfReady();
    (Proposals.Proposal storage proposal, Proposals.Stage stage) = requireDequeuedAndDeleteExpired(
      proposalId,
      index
    );
    if (!proposal.exists()) {
      return false;
    }

    address account = getAccounts().voteSignerToAccount(msg.sender);
    Voter storage voter = voters[account];
    uint256 weight = getLockedGold().getAccountTotalLockedGold(account);
    require(proposal.isApproved(), "Proposal not approved");
    require(stage == Proposals.Stage.Referendum, "Incorrect proposal state");
    require(value != Proposals.VoteValue.None, "Vote value unset");
    require(weight > 0, "Voter weight zero");
    VoteRecord storage voteRecord = voter.referendumVotes[index];
    proposal.updateVote(
      voteRecord.weight,
      weight,
      (voteRecord.proposalId == proposalId) ? voteRecord.value : Proposals.VoteValue.None,
      value
    );
    proposal.networkWeight = getLockedGold().getTotalLockedGold();
    voter.referendumVotes[index] = VoteRecord(value, proposalId, weight);
    if (proposal.timestamp > proposals[voter.mostRecentReferendumProposal].timestamp) {
      voter.mostRecentReferendumProposal = proposalId;
    }
    emit ProposalVoted(proposalId, account, uint256(value), weight);
    return true;
  }

  /* solhint-enable code-complexity */

  /**
   * @notice Revoke votes on all proposals of sender in the referendum stage.
   * @return Whether or not all votes of an account were successfully revoked.
   */
  function revokeVotes() external nonReentrant returns (bool) {
    address account = getAccounts().voteSignerToAccount(msg.sender);
    Voter storage voter = voters[account];
    for (
      uint256 dequeueIndex = 0;
      dequeueIndex < dequeued.length;
      dequeueIndex = dequeueIndex.add(1)
    ) {
      VoteRecord storage voteRecord = voter.referendumVotes[dequeueIndex];

      // Skip proposals where there was no vote cast by the user AND
      // ensure vote record proposal matches identifier of dequeued index proposal.
      if (
        voteRecord.value != Proposals.VoteValue.None &&
        voteRecord.proposalId == dequeued[dequeueIndex]
      ) {
        (Proposals.Proposal storage proposal, Proposals.Stage stage) =
          requireDequeuedAndDeleteExpired(voteRecord.proposalId, dequeueIndex); // prettier-ignore

        // only revoke from proposals which are still in referendum
        if (stage == Proposals.Stage.Referendum) {
          proposal.updateVote(voteRecord.weight, 0, voteRecord.value, Proposals.VoteValue.None);
          proposal.networkWeight = getLockedGold().getTotalLockedGold();
          emit ProposalVoteRevoked(
            voteRecord.proposalId,
            account,
            uint256(voteRecord.value),
            voteRecord.weight
          );
        }

        // always delete dequeue vote records for gas refund as they must be expired or revoked
        delete voter.referendumVotes[dequeueIndex];
      }
    }

    // reset most recent referendum proposal ID to guarantee isVotingReferendum == false
    voter.mostRecentReferendumProposal = 0;
    return true;
  }

  /**
   * @notice Executes a proposal in the execution stage, removing it from `dequeued`.
   * @param proposalId The ID of the proposal to vote on.
   * @param index The index of the proposal ID in `dequeued`.
   * @return Whether or not the proposal was executed successfully.
   * @dev Does not remove the proposal if the execution fails.
   */
  function execute(uint256 proposalId, uint256 index) external nonReentrant returns (bool) {
    dequeueProposalsIfReady();
    (Proposals.Proposal storage proposal, Proposals.Stage stage) = requireDequeuedAndDeleteExpired(
      proposalId,
      index
    );
    bool notExpired = proposal.exists();
    if (notExpired) {
      require(
        stage == Proposals.Stage.Execution && _isProposalPassing(proposal),
        "Proposal not in execution stage or not passing"
      );
      proposal.execute();
      emit ProposalExecuted(proposalId);
      deleteDequeuedProposal(proposal, proposalId, index);
    }
    return notExpired;
  }

  /**
   * @notice Approves the hash of a hotfix transaction(s).
   * @param hash The abi encoded keccak256 hash of the hotfix transaction(s) to be approved.
   */
  function approveHotfix(bytes32 hash) external hotfixNotExecuted(hash) onlyApprover {
    hotfixes[hash].approved = true;
    emit HotfixApproved(hash);
  }

  /**
   * @notice Returns whether given hotfix hash has been whitelisted by given address.
   * @param hash The abi encoded keccak256 hash of the hotfix transaction(s) to be whitelisted.
   * @param whitelister Address to check whitelist status of.
   */
  function isHotfixWhitelistedBy(bytes32 hash, address whitelister) public view returns (bool) {
    return hotfixes[hash].whitelisted[whitelister];
  }

  /**
   * @notice Whitelists the hash of a hotfix transaction(s).
   * @param hash The abi encoded keccak256 hash of the hotfix transaction(s) to be whitelisted.
   */
  function whitelistHotfix(bytes32 hash) external hotfixNotExecuted(hash) {
    hotfixes[hash].whitelisted[msg.sender] = true;
    emit HotfixWhitelisted(hash, msg.sender);
  }

  /**
   * @notice Gives hotfix a prepared epoch for execution.
   * @param hash The hash of the hotfix to be prepared.
   */
  function prepareHotfix(bytes32 hash) external hotfixNotExecuted(hash) {
    require(isHotfixPassing(hash), "hotfix not whitelisted by 2f+1 validators");
    uint256 epoch = getEpochNumber();
    require(hotfixes[hash].preparedEpoch < epoch, "hotfix already prepared for this epoch");
    hotfixes[hash].preparedEpoch = epoch;
    emit HotfixPrepared(hash, epoch);
  }

  /**
   * @notice Executes a whitelisted proposal.
   * @param values The values of CELO to be sent in the proposed transactions.
   * @param destinations The destination addresses of the proposed transactions.
   * @param data The concatenated data to be included in the proposed transactions.
   * @param dataLengths The lengths of each transaction's data.
   * @param salt Arbitrary salt associated with hotfix which guarantees uniqueness of hash.
   * @dev Reverts if hotfix is already executed, not approved, or not prepared for current epoch.
   */
  function executeHotfix(
    uint256[] calldata values,
    address[] calldata destinations,
    bytes calldata data,
    uint256[] calldata dataLengths,
    bytes32 salt
  ) external {
    bytes32 hash = keccak256(abi.encode(values, destinations, data, dataLengths, salt));

    (bool approved, bool executed, uint256 preparedEpoch) = getHotfixRecord(hash);
    require(!executed, "hotfix already executed");
    require(approved, "hotfix not approved");
    require(preparedEpoch == getEpochNumber(), "hotfix must be prepared for this epoch");

    Proposals.makeMem(values, destinations, data, dataLengths, msg.sender, 0).executeMem();

    hotfixes[hash].executed = true;
    emit HotfixExecuted(hash);
  }

  /**
   * @notice Withdraws refunded CELO deposits.
   * @return Whether or not the withdraw was successful.
   */
  function withdraw() external nonReentrant returns (bool) {
    uint256 value = refundedDeposits[msg.sender];
    require(value > 0, "Nothing to withdraw");
    require(value <= address(this).balance, "Inconsistent balance");
    refundedDeposits[msg.sender] = 0;
    msg.sender.sendValue(value);
    return true;
  }

  /**
   * @notice Returns whether or not a particular account is voting on proposals.
   * @param account The address of the account.
   * @return Whether or not the account is voting on proposals.
   */
  function isVoting(address account) external view returns (bool) {
    Voter storage voter = voters[account];
    uint256 upvotedProposal = voter.upvote.proposalId;
    bool isVotingQueue = upvotedProposal != 0 &&
      isQueued(upvotedProposal) &&
      !isQueuedProposalExpired(upvotedProposal);
    Proposals.Proposal storage proposal = proposals[voter.mostRecentReferendumProposal];
    bool isVotingReferendum = (proposal.getDequeuedStage(stageDurations) ==
      Proposals.Stage.Referendum);
    return isVotingQueue || isVotingReferendum;
  }

  /**
   * @notice Returns the number of seconds proposals stay in approval stage.
   * @return The number of seconds proposals stay in approval stage.
   */
  function getApprovalStageDuration() external view returns (uint256) {
    return stageDurations.approval;
  }

  /**
   * @notice Returns the number of seconds proposals stay in the referendum stage.
   * @return The number of seconds proposals stay in the referendum stage.
   */
  function getReferendumStageDuration() external view returns (uint256) {
    return stageDurations.referendum;
  }

  /**
   * @notice Returns the number of seconds proposals stay in the execution stage.
   * @return The number of seconds proposals stay in the execution stage.
   */
  function getExecutionStageDuration() external view returns (uint256) {
    return stageDurations.execution;
  }

  /**
   * @notice Returns the participation parameters.
   * @return The participation parameters.
   */
  function getParticipationParameters() external view returns (uint256, uint256, uint256, uint256) {
    return (
      participationParameters.baseline.unwrap(),
      participationParameters.baselineFloor.unwrap(),
      participationParameters.baselineUpdateFactor.unwrap(),
      participationParameters.baselineQuorumFactor.unwrap()
    );
  }

  /**
   * @notice Returns whether or not a proposal exists.
   * @param proposalId The ID of the proposal.
   * @return Whether or not the proposal exists.
   */
  function proposalExists(uint256 proposalId) external view returns (bool) {
    return proposals[proposalId].exists();
  }

  /**
   * @notice Returns an unpacked proposal struct with its transaction count.
   * @param proposalId The ID of the proposal to unpack.
   * @return The unpacked proposal with its transaction count.
   */
  function getProposal(uint256 proposalId)
    external
    view
    returns (address, uint256, uint256, uint256, string memory)
  {
    return proposals[proposalId].unpack();
  }

  /**
   * @notice Returns a specified transaction in a proposal.
   * @param proposalId The ID of the proposal to query.
   * @param index The index of the specified transaction in the proposal's transaction list.
   * @return The specified transaction.
   */
  function getProposalTransaction(uint256 proposalId, uint256 index)
    external
    view
    returns (uint256, address, bytes memory)
  {
    return proposals[proposalId].getTransaction(index);
  }

  /**
   * @notice Returns whether or not a proposal has been approved.
   * @param proposalId The ID of the proposal.
   * @return Whether or not the proposal has been approved.
   */
  function isApproved(uint256 proposalId) external view returns (bool) {
    return proposals[proposalId].isApproved();
  }

  /**
   * @notice Returns the referendum vote totals for a proposal.
   * @param proposalId The ID of the proposal.
   * @return The yes, no, and abstain vote totals.
   */
  function getVoteTotals(uint256 proposalId) external view returns (uint256, uint256, uint256) {
    return proposals[proposalId].getVoteTotals();
  }

  /**
   * @notice Returns an accounts vote record on a particular index in `dequeued`.
   * @param account The address of the account to get the record for.
   * @param index The index in `dequeued`.
   * @return The corresponding proposal ID, vote value, and weight.
   */
  function getVoteRecord(address account, uint256 index)
    external
    view
    returns (uint256, uint256, uint256)
  {
    VoteRecord storage record = voters[account].referendumVotes[index];
    return (record.proposalId, uint256(record.value), record.weight);
  }

  /**
   * @notice Returns the number of proposals in the queue.
   * @return The number of proposals in the queue.
   */
  function getQueueLength() external view returns (uint256) {
    return queue.list.numElements;
  }

  /**
   * @notice Returns the number of upvotes the queued proposal has received.
   * @param proposalId The ID of the proposal.
   * @return The number of upvotes a queued proposal has received.
   */
  function getUpvotes(uint256 proposalId) external view returns (uint256) {
    require(isQueued(proposalId), "Proposal not queued");
    return queue.getValue(proposalId);
  }

  /**
   * @notice Returns the proposal ID and upvote total for all queued proposals.
   * @return The proposal ID and upvote total for all queued proposals.
   * @dev Note that this includes expired proposals that have yet to be removed from the queue.
   */
  function getQueue() external view returns (uint256[] memory, uint256[] memory) {
    return queue.getElements();
  }

  /**
   * @notice Returns the dequeued proposal IDs.
   * @return The dequeued proposal IDs.
   * @dev Note that this includes unused indices with proposalId == 0 from deleted proposals.
   */
  function getDequeue() external view returns (uint256[] memory) {
    return dequeued;
  }

  /**
   * @notice Returns the ID of the proposal upvoted by `account` and the weight of that upvote.
   * @param account The address of the account.
   * @return The ID of the proposal upvoted by `account` and the weight of that upvote.
   */
  function getUpvoteRecord(address account) external view returns (uint256, uint256) {
    UpvoteRecord memory upvoteRecord = voters[account].upvote;
    return (upvoteRecord.proposalId, upvoteRecord.weight);
  }

  /**
   * @notice Returns the ID of the most recently dequeued proposal voted on by `account`.
   * @param account The address of the account.
   * @return The ID of the most recently dequeued proposal voted on by `account`..
   */
  function getMostRecentReferendumProposal(address account) external view returns (uint256) {
    return voters[account].mostRecentReferendumProposal;
  }

  /**
   * @notice Returns number of validators from current set which have whitelisted the given hotfix.
   * @param hash The abi encoded keccak256 hash of the hotfix transaction.
   * @return Whitelist tally
   */
  function hotfixWhitelistValidatorTally(bytes32 hash) public view returns (uint256) {
    uint256 tally = 0;
    uint256 n = numberValidatorsInCurrentSet();
    IAccounts accounts = getAccounts();
    for (uint256 i = 0; i < n; i = i.add(1)) {
      address validatorSigner = validatorSignerAddressFromCurrentSet(i);
      address validatorAccount = accounts.signerToAccount(validatorSigner);
      if (
        isHotfixWhitelistedBy(hash, validatorSigner) ||
        isHotfixWhitelistedBy(hash, validatorAccount)
      ) {
        tally = tally.add(1);
      }
    }
    return tally;
  }

  /**
   * @notice Checks if a byzantine quorum of validators has whitelisted the given hotfix.
   * @param hash The abi encoded keccak256 hash of the hotfix transaction.
   * @return Whether validator whitelist tally >= validator byzantine quorum
   */
  function isHotfixPassing(bytes32 hash) public view returns (bool) {
    return hotfixWhitelistValidatorTally(hash) >= minQuorumSizeInCurrentSet();
  }

  /**
   * @notice Gets information about a hotfix.
   * @param hash The abi encoded keccak256 hash of the hotfix transaction.
   * @return Hotfix tuple of (approved, executed, preparedEpoch)
   */
  function getHotfixRecord(bytes32 hash) public view returns (bool, bool, uint256) {
    return (hotfixes[hash].approved, hotfixes[hash].executed, hotfixes[hash].preparedEpoch);
  }

  /**
   * @notice Removes the proposals with the most upvotes from the queue, moving them to the
   *   approval stage.
   * @dev If any of the top proposals have expired, they are deleted.
   */
  function dequeueProposalsIfReady() public {
    // solhint-disable-next-line not-rely-on-time
    if (now >= lastDequeue.add(dequeueFrequency)) {
      uint256 numProposalsToDequeue = Math.min(concurrentProposals, queue.list.numElements);
      uint256[] memory dequeuedIds = queue.popN(numProposalsToDequeue);
      for (uint256 i = 0; i < numProposalsToDequeue; i = i.add(1)) {
        uint256 proposalId = dequeuedIds[i];
        Proposals.Proposal storage proposal = proposals[proposalId];
        if (_isQueuedProposalExpired(proposal)) {
          emit ProposalExpired(proposalId);
          continue;
        }
        refundedDeposits[proposal.proposer] = refundedDeposits[proposal.proposer].add(
          proposal.deposit
        );
        // solhint-disable-next-line not-rely-on-time
        proposal.timestamp = now;
        if (emptyIndices.length > 0) {
          uint256 indexOfLastEmptyIndex = emptyIndices.length.sub(1);
          dequeued[emptyIndices[indexOfLastEmptyIndex]] = proposalId;
          delete emptyIndices[indexOfLastEmptyIndex];
          emptyIndices.length = indexOfLastEmptyIndex;
        } else {
          dequeued.push(proposalId);
        }
        // solhint-disable-next-line not-rely-on-time
        emit ProposalDequeued(proposalId, now);
      }
      // solhint-disable-next-line not-rely-on-time
      lastDequeue = now;
    }
  }

  /**
   * @notice Returns whether or not a proposal is in the queue.
   * @dev NOTE: proposal may be expired
   * @param proposalId The ID of the proposal.
   * @return Whether or not the proposal is in the queue.
   */
  function isQueued(uint256 proposalId) public view returns (bool) {
    return queue.contains(proposalId);
  }

  /**
   * @notice Returns whether or not a particular proposal is passing according to the constitution
   *   and the participation levels.
   * @param proposalId The ID of the proposal.
   * @return Whether or not the proposal is passing.
   */
  function isProposalPassing(uint256 proposalId) external view returns (bool) {
    return _isProposalPassing(proposals[proposalId]);
  }

  /**
   * @notice Returns whether or not a particular proposal is passing according to the constitution
   *   and the participation levels.
   * @param proposal The proposal struct.
   * @return Whether or not the proposal is passing.
   */
  function _isProposalPassing(Proposals.Proposal storage proposal) private view returns (bool) {
    FixidityLib.Fraction memory support = proposal.getSupportWithQuorumPadding(
      participationParameters.baseline.multiply(participationParameters.baselineQuorumFactor)
    );
    for (uint256 i = 0; i < proposal.transactions.length; i = i.add(1)) {
      bytes4 functionId = ExtractFunctionSignature.extractFunctionSignature(
        proposal.transactions[i].data
      );
      FixidityLib.Fraction memory threshold = _getConstitution(
        proposal.transactions[i].destination,
        functionId
      );
      if (support.lte(threshold)) {
        return false;
      }
    }
    return true;
  }

  /**
   * @notice Returns whether a proposal is dequeued at the given index.
   * @param proposalId The ID of the proposal.
   * @param index The index of the proposal ID in `dequeued`.
   * @return Whether the proposal is in `dequeued`.
   */
  function isDequeuedProposal(uint256 proposalId, uint256 index) external view returns (bool) {
    return _isDequeuedProposal(proposals[proposalId], proposalId, index);
  }

  /**
   * @notice Returns whether a proposal is dequeued at the given index.
   * @param proposal The proposal struct.
   * @param proposalId The ID of the proposal.
   * @param index The index of the proposal ID in `dequeued`.
   * @return Whether the proposal is in `dequeued` at index.
   */
  function _isDequeuedProposal(
    Proposals.Proposal storage proposal,
    uint256 proposalId,
    uint256 index
  ) private view returns (bool) {
    require(index < dequeued.length, "Provided index greater than dequeue length.");
    return proposal.exists() && dequeued[index] == proposalId;
  }

  /**
   * @notice Returns whether or not a dequeued proposal has expired.
   * @param proposalId The ID of the proposal.
   * @return Whether or not the dequeued proposal has expired.
   */
  function isDequeuedProposalExpired(uint256 proposalId) external view returns (bool) {
    Proposals.Proposal storage proposal = proposals[proposalId];
    return _isDequeuedProposalExpired(proposal, proposal.getDequeuedStage(stageDurations));
  }

  /**
   * @notice Returns whether or not a dequeued proposal has expired.
   * @param proposal The proposal struct.
   * @return Whether or not the dequeued proposal has expired.
   */
  function _isDequeuedProposalExpired(Proposals.Proposal storage proposal, Proposals.Stage stage)
    private
    view
    returns (bool)
  {
    // The proposal is considered expired under the following conditions:
    //   1. Past the approval stage and not approved.
    //   2. Past the referendum stage and not passing.
    //   3. Past the execution stage.
    return ((stage > Proposals.Stage.Execution) ||
      (stage > Proposals.Stage.Referendum && !_isProposalPassing(proposal)) ||
      (stage > Proposals.Stage.Approval && !proposal.isApproved()));
  }

  /**
   * @notice Returns whether or not a queued proposal has expired.
   * @param proposalId The ID of the proposal.
   * @return Whether or not the dequeued proposal has expired.
   */
  function isQueuedProposalExpired(uint256 proposalId) public view returns (bool) {
    return _isQueuedProposalExpired(proposals[proposalId]);
  }

  /**
   * @notice Returns whether or not a queued proposal has expired.
   * @param proposal The proposal struct.
   * @return Whether or not the dequeued proposal has expired.
   */
  function _isQueuedProposalExpired(Proposals.Proposal storage proposal)
    private
    view
    returns (bool)
  {
    // solhint-disable-next-line not-rely-on-time
    return now >= proposal.timestamp.add(queueExpiry);
  }

  /**
   * @notice Deletes a dequeued proposal.
   * @param proposal The proposal struct.
   * @param proposalId The ID of the proposal to delete.
   * @param index The index of the proposal ID in `dequeued`.
   * @dev Must always be preceded by `isDequeuedProposal`, which checks `index`.
   */
  function deleteDequeuedProposal(
    Proposals.Proposal storage proposal,
    uint256 proposalId,
    uint256 index
  ) private {
    if (proposal.isApproved() && proposal.networkWeight > 0) {
      updateParticipationBaseline(proposal);
    }
    dequeued[index] = 0;
    emptyIndices.push(index);
    delete proposals[proposalId];
  }

  /**
   * @notice Updates the participation baseline based on the proportion of BondedDeposit weight
   *   that participated in the proposal's Referendum stage.
   * @param proposal The proposal struct.
   */
  function updateParticipationBaseline(Proposals.Proposal storage proposal) private {
    FixidityLib.Fraction memory participation = proposal.getParticipation();
    FixidityLib.Fraction memory participationComponent = participation.multiply(
      participationParameters.baselineUpdateFactor
    );
    FixidityLib.Fraction memory baselineComponent = participationParameters.baseline.multiply(
      FixidityLib.fixed1().subtract(participationParameters.baselineUpdateFactor)
    );
    participationParameters.baseline = participationComponent.add(baselineComponent);
    if (participationParameters.baseline.lt(participationParameters.baselineFloor)) {
      participationParameters.baseline = participationParameters.baselineFloor;
    }
    emit ParticipationBaselineUpdated(participationParameters.baseline.unwrap());
  }

  /**
   * @notice Returns the constitution for a particular destination and function ID.
   * @param destination The destination address to get the constitution for.
   * @param functionId The function ID to get the constitution for, zero for the destination
   *   default.
   * @return The ratio of yes:no votes needed to exceed in order to pass the proposal.
   */
  function getConstitution(address destination, bytes4 functionId) external view returns (uint256) {
    return _getConstitution(destination, functionId).unwrap();
  }

  function _getConstitution(address destination, bytes4 functionId)
    internal
    view
    returns (FixidityLib.Fraction memory)
  {
    // Default to a simple majority.
    FixidityLib.Fraction memory threshold = FixidityLib.wrap(FIXED_HALF);
    if (constitution[destination].functionThresholds[functionId].unwrap() != 0) {
      threshold = constitution[destination].functionThresholds[functionId];
    } else if (constitution[destination].defaultThreshold.unwrap() != 0) {
      threshold = constitution[destination].defaultThreshold;
    }
    return threshold;
  }
}
        

/home/eruiz/Projects/celo/celo-monorepo/packages/protocol/contracts/common/ExtractFunctionSignature.sol

pragma solidity ^0.5.13;

library ExtractFunctionSignature {
  /**
   * @notice Extracts the first four bytes of a byte array.
   * @param input The byte array.
   * @return The first four bytes of `input`.
   */
  function extractFunctionSignature(bytes memory input) internal pure returns (bytes4) {
    return (bytes4(input[0]) |
      (bytes4(input[1]) >> 8) |
      (bytes4(input[2]) >> 16) |
      (bytes4(input[3]) >> 24));
  }
}
          

/home/eruiz/Projects/celo/celo-monorepo/packages/protocol/contracts/common/FixidityLib.sol

pragma solidity ^0.5.13;

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

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

  uint256 private constant FIXED1_UINT = 1000000000000000000000000;

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

/home/eruiz/Projects/celo/celo-monorepo/packages/protocol/contracts/common/Initializable.sol

pragma solidity ^0.5.13;

contract Initializable {
  bool public initialized;

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

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

/home/eruiz/Projects/celo/celo-monorepo/packages/protocol/contracts/common/UsingPrecompiles.sol

pragma solidity ^0.5.13;

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

contract UsingPrecompiles {
  using SafeMath for uint256;

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

}
          

/home/eruiz/Projects/celo/celo-monorepo/packages/protocol/contracts/common/UsingRegistry.sol

pragma solidity ^0.5.13;

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

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

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

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

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

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

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

  IRegistry public registry;

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

/home/eruiz/Projects/celo/celo-monorepo/packages/protocol/contracts/common/interfaces/IAccounts.sol

pragma solidity ^0.5.13;

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

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

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

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

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

/home/eruiz/Projects/celo/celo-monorepo/packages/protocol/contracts/common/interfaces/ICeloVersionedContract.sol

pragma solidity ^0.5.13;

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

/home/eruiz/Projects/celo/celo-monorepo/packages/protocol/contracts/common/interfaces/IFeeCurrencyWhitelist.sol

pragma solidity ^0.5.13;

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

/home/eruiz/Projects/celo/celo-monorepo/packages/protocol/contracts/common/interfaces/IFreezer.sol

pragma solidity ^0.5.13;

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

/home/eruiz/Projects/celo/celo-monorepo/packages/protocol/contracts/common/interfaces/IRegistry.sol

pragma solidity ^0.5.13;

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

/home/eruiz/Projects/celo/celo-monorepo/packages/protocol/contracts/common/libraries/ReentrancyGuard.sol

pragma solidity ^0.5.13;

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

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

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

/home/eruiz/Projects/celo/celo-monorepo/packages/protocol/contracts/common/linkedlists/IntegerSortedLinkedList.sol

pragma solidity ^0.5.13;

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

import "./SortedLinkedList.sol";

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

  /**
   * @notice Inserts an element into a doubly linked list.
   * @param list A storage pointer to the underlying list.
   * @param key The key of the element to insert.
   * @param value The element value.
   * @param lesserKey The key of the element less than the element to insert.
   * @param greaterKey The key of the element greater than the element to insert.
   */
  function insert(
    SortedLinkedList.List storage list,
    uint256 key,
    uint256 value,
    uint256 lesserKey,
    uint256 greaterKey
  ) public {
    list.insert(bytes32(key), value, bytes32(lesserKey), bytes32(greaterKey));
  }

  /**
   * @notice Removes an element from the doubly linked list.
   * @param list A storage pointer to the underlying list.
   * @param key The key of the element to remove.
   */
  function remove(SortedLinkedList.List storage list, uint256 key) public {
    list.remove(bytes32(key));
  }

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

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

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

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

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

  /**
   * @notice Gets all elements from the doubly linked list.
   * @param list A storage pointer to the underlying list.
   * @return An unpacked list of elements from largest to smallest.
   */
  function getElements(SortedLinkedList.List storage list)
    public
    view
    returns (uint256[] memory, uint256[] memory)
  {
    bytes32[] memory byteKeys = list.getKeys();
    uint256[] memory keys = new uint256[](byteKeys.length);
    uint256[] memory values = new uint256[](byteKeys.length);
    for (uint256 i = 0; i < byteKeys.length; i = i.add(1)) {
      keys[i] = uint256(byteKeys[i]);
      values[i] = list.values[byteKeys[i]];
    }
    return (keys, values);
  }
}
          

/home/eruiz/Projects/celo/celo-monorepo/packages/protocol/contracts/common/linkedlists/LinkedList.sol

pragma solidity ^0.5.13;

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

/home/eruiz/Projects/celo/celo-monorepo/packages/protocol/contracts/common/linkedlists/SortedLinkedList.sol

pragma solidity ^0.5.13;

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

/home/eruiz/Projects/celo/celo-monorepo/packages/protocol/contracts/governance/Proposals.sol

pragma solidity ^0.5.13;

import "openzeppelin-solidity/contracts/math/SafeMath.sol";
import "openzeppelin-solidity/contracts/utils/Address.sol";
import "solidity-bytes-utils/contracts/BytesLib.sol";

import "../common/FixidityLib.sol";

/**
 * @title A library operating on Celo Governance proposals.
 */
library Proposals {
  using FixidityLib for FixidityLib.Fraction;
  using SafeMath for uint256;
  using BytesLib for bytes;

  enum Stage { None, Queued, Approval, Referendum, Execution, Expiration }

  enum VoteValue { None, Abstain, No, Yes }

  struct StageDurations {
    uint256 approval;
    uint256 referendum;
    uint256 execution;
  }

  struct VoteTotals {
    uint256 yes;
    uint256 no;
    uint256 abstain;
  }

  struct Transaction {
    uint256 value;
    address destination;
    bytes data;
  }

  struct Proposal {
    address proposer;
    uint256 deposit;
    uint256 timestamp;
    VoteTotals votes;
    Transaction[] transactions;
    bool approved;
    uint256 networkWeight;
    string descriptionUrl;
  }

  /**
   * @notice Constructs a proposal.
   * @param proposal The proposal struct to be constructed.
   * @param values The values of CELO to be sent in the proposed transactions.
   * @param destinations The destination addresses of the proposed transactions.
   * @param data The concatenated data to be included in the proposed transactions.
   * @param dataLengths The lengths of each transaction's data.
   * @param proposer The proposer.
   * @param deposit The proposal deposit.
   */
  function make(
    Proposal storage proposal,
    uint256[] memory values,
    address[] memory destinations,
    bytes memory data,
    uint256[] memory dataLengths,
    address proposer,
    uint256 deposit
  ) public {
    require(
      values.length == destinations.length && destinations.length == dataLengths.length,
      "Array length mismatch"
    );
    uint256 transactionCount = values.length;

    proposal.proposer = proposer;
    proposal.deposit = deposit;
    // solhint-disable-next-line not-rely-on-time
    proposal.timestamp = now;

    uint256 dataPosition = 0;
    delete proposal.transactions;
    for (uint256 i = 0; i < transactionCount; i = i.add(1)) {
      proposal.transactions.push(
        Transaction(values[i], destinations[i], data.slice(dataPosition, dataLengths[i]))
      );
      dataPosition = dataPosition.add(dataLengths[i]);
    }
  }

  function setDescriptionUrl(Proposal storage proposal, string memory descriptionUrl) internal {
    require(bytes(descriptionUrl).length != 0, "Description url must have non-zero length");
    proposal.descriptionUrl = descriptionUrl;
  }

  /**
   * @notice Constructs a proposal for use in memory.
   * @param values The values of CELO to be sent in the proposed transactions.
   * @param destinations The destination addresses of the proposed transactions.
   * @param data The concatenated data to be included in the proposed transactions.
   * @param dataLengths The lengths of each transaction's data.
   * @param proposer The proposer.
   * @param deposit The proposal deposit.
   */
  function makeMem(
    uint256[] memory values,
    address[] memory destinations,
    bytes memory data,
    uint256[] memory dataLengths,
    address proposer,
    uint256 deposit
  ) internal view returns (Proposal memory) {
    require(
      values.length == destinations.length && destinations.length == dataLengths.length,
      "Array length mismatch"
    );
    uint256 transactionCount = values.length;

    Proposal memory proposal;
    proposal.proposer = proposer;
    proposal.deposit = deposit;
    // solhint-disable-next-line not-rely-on-time
    proposal.timestamp = now;

    uint256 dataPosition = 0;
    proposal.transactions = new Transaction[](transactionCount);
    for (uint256 i = 0; i < transactionCount; i = i.add(1)) {
      proposal.transactions[i] = Transaction(
        values[i],
        destinations[i],
        data.slice(dataPosition, dataLengths[i])
      );
      dataPosition = dataPosition.add(dataLengths[i]);
    }
    return proposal;
  }

  /**
   * @notice Adds or changes a vote on a proposal.
   * @param proposal The proposal struct.
   * @param previousWeight The previous weight of the vote.
   * @param currentWeight The current weight of the vote.
   * @param previousVote The vote to be removed, or None for a new vote.
   * @param currentVote The vote to be set.
   */
  function updateVote(
    Proposal storage proposal,
    uint256 previousWeight,
    uint256 currentWeight,
    VoteValue previousVote,
    VoteValue currentVote
  ) public {
    // Subtract previous vote.
    if (previousVote == VoteValue.Abstain) {
      proposal.votes.abstain = proposal.votes.abstain.sub(previousWeight);
    } else if (previousVote == VoteValue.Yes) {
      proposal.votes.yes = proposal.votes.yes.sub(previousWeight);
    } else if (previousVote == VoteValue.No) {
      proposal.votes.no = proposal.votes.no.sub(previousWeight);
    }

    // Add new vote.
    if (currentVote == VoteValue.Abstain) {
      proposal.votes.abstain = proposal.votes.abstain.add(currentWeight);
    } else if (currentVote == VoteValue.Yes) {
      proposal.votes.yes = proposal.votes.yes.add(currentWeight);
    } else if (currentVote == VoteValue.No) {
      proposal.votes.no = proposal.votes.no.add(currentWeight);
    }
  }

  /**
   * @notice Executes the proposal.
   * @param proposal The proposal struct.
   * @dev Reverts if any transaction fails.
   */
  function execute(Proposal storage proposal) public {
    executeTransactions(proposal.transactions);
  }

  /**
   * @notice Executes the proposal.
   * @param proposal The proposal struct.
   * @dev Reverts if any transaction fails.
   */
  function executeMem(Proposal memory proposal) internal {
    executeTransactions(proposal.transactions);
  }

  function executeTransactions(Transaction[] memory transactions) internal {
    for (uint256 i = 0; i < transactions.length; i = i.add(1)) {
      require(
        externalCall(
          transactions[i].destination,
          transactions[i].value,
          transactions[i].data.length,
          transactions[i].data
        ),
        "Proposal execution failed"
      );
    }
  }

  /**
   * @notice Computes the support ratio for a proposal with the quorum condition:
   *   If the total number of votes (yes + no + abstain) is less than the required number of votes,
   *   "no" votes are added to increase particiption to this level. The ratio of yes / (yes + no)
   *   votes is returned.
   * @param proposal The proposal struct.
   * @param quorum The minimum participation at which "no" votes are not added.
   * @return The support ratio with the quorum condition.
   */
  function getSupportWithQuorumPadding(
    Proposal storage proposal,
    FixidityLib.Fraction memory quorum
  ) internal view returns (FixidityLib.Fraction memory) {
    uint256 yesVotes = proposal.votes.yes;
    if (yesVotes == 0) {
      return FixidityLib.newFixed(0);
    }
    uint256 noVotes = proposal.votes.no;
    uint256 totalVotes = yesVotes.add(noVotes).add(proposal.votes.abstain);
    uint256 requiredVotes = quorum
      .multiply(FixidityLib.newFixed(proposal.networkWeight))
      .fromFixed();
    if (requiredVotes > totalVotes) {
      noVotes = noVotes.add(requiredVotes.sub(totalVotes));
    }
    return FixidityLib.newFixedFraction(yesVotes, yesVotes.add(noVotes));
  }

  /**
   * @notice Returns the stage of a dequeued proposal.
   * @param proposal The proposal struct.
   * @param stageDurations The durations of the dequeued proposal stages.
   * @return The stage of the dequeued proposal.
   * @dev Must be called on a dequeued proposal.
   */
  function getDequeuedStage(Proposal storage proposal, StageDurations storage stageDurations)
    internal
    view
    returns (Stage)
  {
    uint256 stageStartTime = proposal
      .timestamp
      .add(stageDurations.approval)
      .add(stageDurations.referendum)
      .add(stageDurations.execution);
    // solhint-disable-next-line not-rely-on-time
    if (now >= stageStartTime) {
      return Stage.Expiration;
    }
    stageStartTime = stageStartTime.sub(stageDurations.execution);
    // solhint-disable-next-line not-rely-on-time
    if (now >= stageStartTime) {
      return Stage.Execution;
    }
    stageStartTime = stageStartTime.sub(stageDurations.referendum);
    // solhint-disable-next-line not-rely-on-time
    if (now >= stageStartTime) {
      return Stage.Referendum;
    }
    return Stage.Approval;
  }

  /**
   * @notice Returns the number of votes cast on the proposal over the total number
   *   of votes in the network as a fraction.
   * @param proposal The proposal struct.
   * @return The participation of the proposal.
   */
  function getParticipation(Proposal storage proposal)
    internal
    view
    returns (FixidityLib.Fraction memory)
  {
    uint256 totalVotes = proposal.votes.yes.add(proposal.votes.no).add(proposal.votes.abstain);
    return FixidityLib.newFixedFraction(totalVotes, proposal.networkWeight);
  }

  /**
   * @notice Returns a specified transaction in a proposal.
   * @param proposal The proposal struct.
   * @param index The index of the specified transaction in the proposal's transaction list.
   * @return The specified transaction.
   */
  function getTransaction(Proposal storage proposal, uint256 index)
    public
    view
    returns (uint256, address, bytes memory)
  {
    require(index < proposal.transactions.length, "getTransaction: bad index");
    Transaction storage transaction = proposal.transactions[index];
    return (transaction.value, transaction.destination, transaction.data);
  }

  /**
   * @notice Returns an unpacked proposal struct with its transaction count.
   * @param proposal The proposal struct.
   * @return The unpacked proposal with its transaction count.
   */
  function unpack(Proposal storage proposal)
    internal
    view
    returns (address, uint256, uint256, uint256, string storage)
  {
    return (
      proposal.proposer,
      proposal.deposit,
      proposal.timestamp,
      proposal.transactions.length,
      proposal.descriptionUrl
    );
  }

  /**
   * @notice Returns the referendum vote totals for a proposal.
   * @param proposal The proposal struct.
   * @return The yes, no, and abstain vote totals.
   */
  function getVoteTotals(Proposal storage proposal)
    internal
    view
    returns (uint256, uint256, uint256)
  {
    return (proposal.votes.yes, proposal.votes.no, proposal.votes.abstain);
  }

  /**
   * @notice Returns whether or not a proposal has been approved.
   * @param proposal The proposal struct.
   * @return Whether or not the proposal has been approved.
   */
  function isApproved(Proposal storage proposal) internal view returns (bool) {
    return proposal.approved;
  }

  /**
   * @notice Returns whether or not a proposal exists.
   * @param proposal The proposal struct.
   * @return Whether or not the proposal exists.
   */
  function exists(Proposal storage proposal) internal view returns (bool) {
    return proposal.timestamp > 0;
  }

  // call has been separated into its own function in order to take advantage
  // of the Solidity's code generator to produce a loop that copies tx.data into memory.
  /**
   * @notice Executes a function call.
   * @param value The value of CELO to be sent with the function call.
   * @param destination The destination address of the function call.
   * @param dataLength The length of the data to be included in the function call.
   * @param data The data to be included in the function call.
   */
  function externalCall(address destination, uint256 value, uint256 dataLength, bytes memory data)
    private
    returns (bool)
  {
    bool result;

    if (dataLength > 0) require(Address.isContract(destination), "Invalid contract address");

    /* solhint-disable no-inline-assembly */
    assembly {
      /* solhint-disable max-line-length */
      let x := mload(0x40) // "Allocate" memory for output (0x40 is where "free memory" pointer is stored by convention)
      let d := add(data, 32) // First 32 bytes are the padded length of data, so exclude that
      result := call(
        sub(gas, 34710), // 34710 is the value that solidity is currently emitting
        // It includes callGas (700) + callVeryLow (3, to pay for SUB) + callValueTransferGas (9000) +
        // callNewAccountGas (25000, in case the destination address does not exist and needs creating)
        destination,
        value,
        d,
        dataLength, // Size of the input (in bytes) - this is what fixes the padding problem
        x,
        0 // Output is ignored, therefore the output size is zero
      )
      /* solhint-enable max-line-length */
    }
    /* solhint-enable no-inline-assembly */
    return result;
  }
}
          

/home/eruiz/Projects/celo/celo-monorepo/packages/protocol/contracts/governance/interfaces/IElection.sol

pragma solidity ^0.5.13;

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

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

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

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

/home/eruiz/Projects/celo/celo-monorepo/packages/protocol/contracts/governance/interfaces/IGovernance.sol

pragma solidity ^0.5.13;

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

/home/eruiz/Projects/celo/celo-monorepo/packages/protocol/contracts/governance/interfaces/ILockedGold.sol

pragma solidity ^0.5.13;

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

/home/eruiz/Projects/celo/celo-monorepo/packages/protocol/contracts/governance/interfaces/IValidators.sol

pragma solidity ^0.5.13;

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

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

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

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

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

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

}
          

/home/eruiz/Projects/celo/celo-monorepo/packages/protocol/contracts/identity/interfaces/IAttestations.sol

pragma solidity ^0.5.13;

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

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

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

/home/eruiz/Projects/celo/celo-monorepo/packages/protocol/contracts/identity/interfaces/IRandom.sol

pragma solidity ^0.5.13;

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

/home/eruiz/Projects/celo/celo-monorepo/packages/protocol/contracts/stability/interfaces/IExchange.sol

pragma solidity ^0.5.13;

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

/home/eruiz/Projects/celo/celo-monorepo/packages/protocol/contracts/stability/interfaces/IReserve.sol

pragma solidity ^0.5.13;

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

/home/eruiz/Projects/celo/celo-monorepo/packages/protocol/contracts/stability/interfaces/ISortedOracles.sol

pragma solidity ^0.5.13;

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

/home/eruiz/Projects/celo/celo-monorepo/packages/protocol/contracts/stability/interfaces/IStableToken.sol

pragma solidity ^0.5.13;

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

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

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

pragma solidity ^0.5.0;

/*
 * @dev Provides information about the current execution context, including the
 * sender of the transaction and its data. While these are generally available
 * via msg.sender and msg.data, they should not be accessed in such a direct
 * manner, since when dealing with GSN meta-transactions the account sending and
 * paying for execution may not be the actual sender (as far as an application
 * is concerned).
 *
 * This contract is only required for intermediate, library-like contracts.
 */
contract Context {
    // Empty internal constructor, to prevent people from mistakenly deploying
    // an instance of this contract, which should be used via inheritance.
    constructor () internal { }
    // solhint-disable-previous-line no-empty-blocks

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

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

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

pragma solidity ^0.5.0;

/**
 * @dev Standard math utilities missing in the Solidity language.
 */
library Math {
    /**
     * @dev Returns the largest of two numbers.
     */
    function max(uint256 a, uint256 b) internal pure returns (uint256) {
        return a >= b ? a : b;
    }

    /**
     * @dev Returns the smallest of two numbers.
     */
    function min(uint256 a, uint256 b) internal pure returns (uint256) {
        return a < b ? a : b;
    }

    /**
     * @dev Returns the average of two numbers. The result is rounded towards
     * zero.
     */
    function average(uint256 a, uint256 b) internal pure returns (uint256) {
        // (a + b) / 2 can overflow, so we distribute
        return (a / 2) + (b / 2) + ((a % 2 + b % 2) / 2);
    }
}
          

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

pragma solidity ^0.5.0;

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

        return c;
    }

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

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

        return c;
    }

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

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

        return c;
    }

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

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

        return c;
    }

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

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

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

pragma solidity ^0.5.0;

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

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

    /**
     * @dev Initializes the contract setting the deployer as the initial owner.
     */
    constructor () internal {
        address msgSender = _msgSender();
        _owner = msgSender;
        emit OwnershipTransferred(address(0), msgSender);
    }

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

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

    /**
     * @dev Returns true if the caller is the current owner.
     */
    function isOwner() public view returns (bool) {
        return _msgSender() == _owner;
    }

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

    /**
     * @dev Transfers ownership of the contract to a new account (`newOwner`).
     * Can only be called by the current owner.
     */
    function transferOwnership(address newOwner) public onlyOwner {
        _transferOwnership(newOwner);
    }

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

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

pragma solidity ^0.5.0;

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

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

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

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

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

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

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

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

/openzeppelin-solidity/contracts/utils/Address.sol

pragma solidity ^0.5.5;

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

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

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

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

/solidity-bytes-utils/contracts/BytesLib.sol

/*
 * @title Solidity Bytes Arrays Utils
 * @author Gonçalo Sá <[email protected]>
 *
 * @dev Bytes tightly packed arrays utility library for ethereum contracts written in Solidity.
 *      The library lets you concatenate, slice and type cast bytes arrays both in memory and storage.
 */

pragma solidity ^0.5.0;


library BytesLib {
    function concat(
        bytes memory _preBytes,
        bytes memory _postBytes
    )
        internal
        pure
        returns (bytes memory)
    {
        bytes memory tempBytes;

        assembly {
            // Get a location of some free memory and store it in tempBytes as
            // Solidity does for memory variables.
            tempBytes := mload(0x40)

            // Store the length of the first bytes array at the beginning of
            // the memory for tempBytes.
            let length := mload(_preBytes)
            mstore(tempBytes, length)

            // Maintain a memory counter for the current write location in the
            // temp bytes array by adding the 32 bytes for the array length to
            // the starting location.
            let mc := add(tempBytes, 0x20)
            // Stop copying when the memory counter reaches the length of the
            // first bytes array.
            let end := add(mc, length)

            for {
                // Initialize a copy counter to the start of the _preBytes data,
                // 32 bytes into its memory.
                let cc := add(_preBytes, 0x20)
            } lt(mc, end) {
                // Increase both counters by 32 bytes each iteration.
                mc := add(mc, 0x20)
                cc := add(cc, 0x20)
            } {
                // Write the _preBytes data into the tempBytes memory 32 bytes
                // at a time.
                mstore(mc, mload(cc))
            }

            // Add the length of _postBytes to the current length of tempBytes
            // and store it as the new length in the first 32 bytes of the
            // tempBytes memory.
            length := mload(_postBytes)
            mstore(tempBytes, add(length, mload(tempBytes)))

            // Move the memory counter back from a multiple of 0x20 to the
            // actual end of the _preBytes data.
            mc := end
            // Stop copying when the memory counter reaches the new combined
            // length of the arrays.
            end := add(mc, length)

            for {
                let cc := add(_postBytes, 0x20)
            } lt(mc, end) {
                mc := add(mc, 0x20)
                cc := add(cc, 0x20)
            } {
                mstore(mc, mload(cc))
            }

            // Update the free-memory pointer by padding our last write location
            // to 32 bytes: add 31 bytes to the end of tempBytes to move to the
            // next 32 byte block, then round down to the nearest multiple of
            // 32. If the sum of the length of the two arrays is zero then add 
            // one before rounding down to leave a blank 32 bytes (the length block with 0).
            mstore(0x40, and(
              add(add(end, iszero(add(length, mload(_preBytes)))), 31),
              not(31) // Round down to the nearest 32 bytes.
            ))
        }

        return tempBytes;
    }

    function concatStorage(bytes storage _preBytes, bytes memory _postBytes) internal {
        assembly {
            // Read the first 32 bytes of _preBytes storage, which is the length
            // of the array. (We don't need to use the offset into the slot
            // because arrays use the entire slot.)
            let fslot := sload(_preBytes_slot)
            // Arrays of 31 bytes or less have an even value in their slot,
            // while longer arrays have an odd value. The actual length is
            // the slot divided by two for odd values, and the lowest order
            // byte divided by two for even values.
            // If the slot is even, bitwise and the slot with 255 and divide by
            // two to get the length. If the slot is odd, bitwise and the slot
            // with -1 and divide by two.
            let slength := div(and(fslot, sub(mul(0x100, iszero(and(fslot, 1))), 1)), 2)
            let mlength := mload(_postBytes)
            let newlength := add(slength, mlength)
            // slength can contain both the length and contents of the array
            // if length < 32 bytes so let's prepare for that
            // v. http://solidity.readthedocs.io/en/latest/miscellaneous.html#layout-of-state-variables-in-storage
            switch add(lt(slength, 32), lt(newlength, 32))
            case 2 {
                // Since the new array still fits in the slot, we just need to
                // update the contents of the slot.
                // uint256(bytes_storage) = uint256(bytes_storage) + uint256(bytes_memory) + new_length
                sstore(
                    _preBytes_slot,
                    // all the modifications to the slot are inside this
                    // next block
                    add(
                        // we can just add to the slot contents because the
                        // bytes we want to change are the LSBs
                        fslot,
                        add(
                            mul(
                                div(
                                    // load the bytes from memory
                                    mload(add(_postBytes, 0x20)),
                                    // zero all bytes to the right
                                    exp(0x100, sub(32, mlength))
                                ),
                                // and now shift left the number of bytes to
                                // leave space for the length in the slot
                                exp(0x100, sub(32, newlength))
                            ),
                            // increase length by the double of the memory
                            // bytes length
                            mul(mlength, 2)
                        )
                    )
                )
            }
            case 1 {
                // The stored value fits in the slot, but the combined value
                // will exceed it.
                // get the keccak hash to get the contents of the array
                mstore(0x0, _preBytes_slot)
                let sc := add(keccak256(0x0, 0x20), div(slength, 32))

                // save new length
                sstore(_preBytes_slot, add(mul(newlength, 2), 1))

                // The contents of the _postBytes array start 32 bytes into
                // the structure. Our first read should obtain the `submod`
                // bytes that can fit into the unused space in the last word
                // of the stored array. To get this, we read 32 bytes starting
                // from `submod`, so the data we read overlaps with the array
                // contents by `submod` bytes. Masking the lowest-order
                // `submod` bytes allows us to add that value directly to the
                // stored value.

                let submod := sub(32, slength)
                let mc := add(_postBytes, submod)
                let end := add(_postBytes, mlength)
                let mask := sub(exp(0x100, submod), 1)

                sstore(
                    sc,
                    add(
                        and(
                            fslot,
                            0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00
                        ),
                        and(mload(mc), mask)
                    )
                )

                for {
                    mc := add(mc, 0x20)
                    sc := add(sc, 1)
                } lt(mc, end) {
                    sc := add(sc, 1)
                    mc := add(mc, 0x20)
                } {
                    sstore(sc, mload(mc))
                }

                mask := exp(0x100, sub(mc, end))

                sstore(sc, mul(div(mload(mc), mask), mask))
            }
            default {
                // get the keccak hash to get the contents of the array
                mstore(0x0, _preBytes_slot)
                // Start copying to the last used word of the stored array.
                let sc := add(keccak256(0x0, 0x20), div(slength, 32))

                // save new length
                sstore(_preBytes_slot, add(mul(newlength, 2), 1))

                // Copy over the first `submod` bytes of the new data as in
                // case 1 above.
                let slengthmod := mod(slength, 32)
                let mlengthmod := mod(mlength, 32)
                let submod := sub(32, slengthmod)
                let mc := add(_postBytes, submod)
                let end := add(_postBytes, mlength)
                let mask := sub(exp(0x100, submod), 1)

                sstore(sc, add(sload(sc), and(mload(mc), mask)))
                
                for { 
                    sc := add(sc, 1)
                    mc := add(mc, 0x20)
                } lt(mc, end) {
                    sc := add(sc, 1)
                    mc := add(mc, 0x20)
                } {
                    sstore(sc, mload(mc))
                }

                mask := exp(0x100, sub(mc, end))

                sstore(sc, mul(div(mload(mc), mask), mask))
            }
        }
    }

    function slice(
        bytes memory _bytes,
        uint _start,
        uint _length
    )
        internal
        pure
        returns (bytes memory)
    {
        require(_bytes.length >= (_start + _length));

        bytes memory tempBytes;

        assembly {
            switch iszero(_length)
            case 0 {
                // Get a location of some free memory and store it in tempBytes as
                // Solidity does for memory variables.
                tempBytes := mload(0x40)

                // The first word of the slice result is potentially a partial
                // word read from the original array. To read it, we calculate
                // the length of that partial word and start copying that many
                // bytes into the array. The first word we copy will start with
                // data we don't care about, but the last `lengthmod` bytes will
                // land at the beginning of the contents of the new array. When
                // we're done copying, we overwrite the full first word with
                // the actual length of the slice.
                let lengthmod := and(_length, 31)

                // The multiplication in the next line is necessary
                // because when slicing multiples of 32 bytes (lengthmod == 0)
                // the following copy loop was copying the origin's length
                // and then ending prematurely not copying everything it should.
                let mc := add(add(tempBytes, lengthmod), mul(0x20, iszero(lengthmod)))
                let end := add(mc, _length)

                for {
                    // The multiplication in the next line has the same exact purpose
                    // as the one above.
                    let cc := add(add(add(_bytes, lengthmod), mul(0x20, iszero(lengthmod))), _start)
                } lt(mc, end) {
                    mc := add(mc, 0x20)
                    cc := add(cc, 0x20)
                } {
                    mstore(mc, mload(cc))
                }

                mstore(tempBytes, _length)

                //update free-memory pointer
                //allocating the array padded to 32 bytes like the compiler does now
                mstore(0x40, and(add(mc, 31), not(31)))
            }
            //if we want a zero-length slice let's just return a zero-length array
            default {
                tempBytes := mload(0x40)

                mstore(0x40, add(tempBytes, 0x20))
            }
        }

        return tempBytes;
    }

    function toAddress(bytes memory _bytes, uint _start) internal  pure returns (address) {
        require(_bytes.length >= (_start + 20));
        address tempAddress;

        assembly {
            tempAddress := div(mload(add(add(_bytes, 0x20), _start)), 0x1000000000000000000000000)
        }

        return tempAddress;
    }

    function toUint8(bytes memory _bytes, uint _start) internal  pure returns (uint8) {
        require(_bytes.length >= (_start + 1));
        uint8 tempUint;

        assembly {
            tempUint := mload(add(add(_bytes, 0x1), _start))
        }

        return tempUint;
    }

    function toUint16(bytes memory _bytes, uint _start) internal  pure returns (uint16) {
        require(_bytes.length >= (_start + 2));
        uint16 tempUint;

        assembly {
            tempUint := mload(add(add(_bytes, 0x2), _start))
        }

        return tempUint;
    }

    function toUint32(bytes memory _bytes, uint _start) internal  pure returns (uint32) {
        require(_bytes.length >= (_start + 4));
        uint32 tempUint;

        assembly {
            tempUint := mload(add(add(_bytes, 0x4), _start))
        }

        return tempUint;
    }

    function toUint(bytes memory _bytes, uint _start) internal  pure returns (uint256) {
        require(_bytes.length >= (_start + 32));
        uint256 tempUint;

        assembly {
            tempUint := mload(add(add(_bytes, 0x20), _start))
        }

        return tempUint;
    }

    function toBytes32(bytes memory _bytes, uint _start) internal  pure returns (bytes32) {
        require(_bytes.length >= (_start + 32));
        bytes32 tempBytes32;

        assembly {
            tempBytes32 := mload(add(add(_bytes, 0x20), _start))
        }

        return tempBytes32;
    }

    function equal(bytes memory _preBytes, bytes memory _postBytes) internal pure returns (bool) {
        bool success = true;

        assembly {
            let length := mload(_preBytes)

            // if lengths don't match the arrays are not equal
            switch eq(length, mload(_postBytes))
            case 1 {
                // cb is a circuit breaker in the for loop since there's
                //  no said feature for inline assembly loops
                // cb = 1 - don't breaker
                // cb = 0 - break
                let cb := 1

                let mc := add(_preBytes, 0x20)
                let end := add(mc, length)

                for {
                    let cc := add(_postBytes, 0x20)
                // the next line is the loop condition:
                // while(uint(mc < end) + cb == 2)
                } eq(add(lt(mc, end), cb), 2) {
                    mc := add(mc, 0x20)
                    cc := add(cc, 0x20)
                } {
                    // if any of these checks fails then arrays are not equal
                    if iszero(eq(mload(mc), mload(cc))) {
                        // unsuccess:
                        success := 0
                        cb := 0
                    }
                }
            }
            default {
                // unsuccess:
                success := 0
            }
        }

        return success;
    }

    function equalStorage(
        bytes storage _preBytes,
        bytes memory _postBytes
    )
        internal
        view
        returns (bool)
    {
        bool success = true;

        assembly {
            // we know _preBytes_offset is 0
            let fslot := sload(_preBytes_slot)
            // Decode the length of the stored array like in concatStorage().
            let slength := div(and(fslot, sub(mul(0x100, iszero(and(fslot, 1))), 1)), 2)
            let mlength := mload(_postBytes)

            // if lengths don't match the arrays are not equal
            switch eq(slength, mlength)
            case 1 {
                // slength can contain both the length and contents of the array
                // if length < 32 bytes so let's prepare for that
                // v. http://solidity.readthedocs.io/en/latest/miscellaneous.html#layout-of-state-variables-in-storage
                if iszero(iszero(slength)) {
                    switch lt(slength, 32)
                    case 1 {
                        // blank the last byte which is the length
                        fslot := mul(div(fslot, 0x100), 0x100)

                        if iszero(eq(fslot, mload(add(_postBytes, 0x20)))) {
                            // unsuccess:
                            success := 0
                        }
                    }
                    default {
                        // cb is a circuit breaker in the for loop since there's
                        //  no said feature for inline assembly loops
                        // cb = 1 - don't breaker
                        // cb = 0 - break
                        let cb := 1

                        // get the keccak hash to get the contents of the array
                        mstore(0x0, _preBytes_slot)
                        let sc := keccak256(0x0, 0x20)

                        let mc := add(_postBytes, 0x20)
                        let end := add(mc, mlength)

                        // the next line is the loop condition:
                        // while(uint(mc < end) + cb == 2)
                        for {} eq(add(lt(mc, end), cb), 2) {
                            sc := add(sc, 1)
                            mc := add(mc, 0x20)
                        } {
                            if iszero(eq(sload(sc), mload(mc))) {
                                // unsuccess:
                                success := 0
                                cb := 0
                            }
                        }
                    }
                }
            }
            default {
                // unsuccess:
                success := 0
            }
        }

        return success;
    }
}
          

Contract ABI

[{"type":"constructor","stateMutability":"nonpayable","payable":false,"inputs":[{"type":"bool","name":"test","internalType":"bool"}]},{"type":"event","name":"ApprovalStageDurationSet","inputs":[{"type":"uint256","name":"approvalStageDuration","internalType":"uint256","indexed":false}],"anonymous":false},{"type":"event","name":"ApproverSet","inputs":[{"type":"address","name":"approver","internalType":"address","indexed":true}],"anonymous":false},{"type":"event","name":"ConcurrentProposalsSet","inputs":[{"type":"uint256","name":"concurrentProposals","internalType":"uint256","indexed":false}],"anonymous":false},{"type":"event","name":"ConstitutionSet","inputs":[{"type":"address","name":"destination","internalType":"address","indexed":true},{"type":"bytes4","name":"functionId","internalType":"bytes4","indexed":true},{"type":"uint256","name":"threshold","internalType":"uint256","indexed":false}],"anonymous":false},{"type":"event","name":"DequeueFrequencySet","inputs":[{"type":"uint256","name":"dequeueFrequency","internalType":"uint256","indexed":false}],"anonymous":false},{"type":"event","name":"ExecutionStageDurationSet","inputs":[{"type":"uint256","name":"executionStageDuration","internalType":"uint256","indexed":false}],"anonymous":false},{"type":"event","name":"HotfixApproved","inputs":[{"type":"bytes32","name":"hash","internalType":"bytes32","indexed":true}],"anonymous":false},{"type":"event","name":"HotfixExecuted","inputs":[{"type":"bytes32","name":"hash","internalType":"bytes32","indexed":true}],"anonymous":false},{"type":"event","name":"HotfixPrepared","inputs":[{"type":"bytes32","name":"hash","internalType":"bytes32","indexed":true},{"type":"uint256","name":"epoch","internalType":"uint256","indexed":true}],"anonymous":false},{"type":"event","name":"HotfixWhitelisted","inputs":[{"type":"bytes32","name":"hash","internalType":"bytes32","indexed":true},{"type":"address","name":"whitelister","internalType":"address","indexed":false}],"anonymous":false},{"type":"event","name":"MinDepositSet","inputs":[{"type":"uint256","name":"minDeposit","internalType":"uint256","indexed":false}],"anonymous":false},{"type":"event","name":"OwnershipTransferred","inputs":[{"type":"address","name":"previousOwner","internalType":"address","indexed":true},{"type":"address","name":"newOwner","internalType":"address","indexed":true}],"anonymous":false},{"type":"event","name":"ParticipationBaselineQuorumFactorSet","inputs":[{"type":"uint256","name":"baselineQuorumFactor","internalType":"uint256","indexed":false}],"anonymous":false},{"type":"event","name":"ParticipationBaselineUpdateFactorSet","inputs":[{"type":"uint256","name":"baselineUpdateFactor","internalType":"uint256","indexed":false}],"anonymous":false},{"type":"event","name":"ParticipationBaselineUpdated","inputs":[{"type":"uint256","name":"participationBaseline","internalType":"uint256","indexed":false}],"anonymous":false},{"type":"event","name":"ParticipationFloorSet","inputs":[{"type":"uint256","name":"participationFloor","internalType":"uint256","indexed":false}],"anonymous":false},{"type":"event","name":"ProposalApproved","inputs":[{"type":"uint256","name":"proposalId","internalType":"uint256","indexed":true}],"anonymous":false},{"type":"event","name":"ProposalDequeued","inputs":[{"type":"uint256","name":"proposalId","internalType":"uint256","indexed":true},{"type":"uint256","name":"timestamp","internalType":"uint256","indexed":false}],"anonymous":false},{"type":"event","name":"ProposalExecuted","inputs":[{"type":"uint256","name":"proposalId","internalType":"uint256","indexed":true}],"anonymous":false},{"type":"event","name":"ProposalExpired","inputs":[{"type":"uint256","name":"proposalId","internalType":"uint256","indexed":true}],"anonymous":false},{"type":"event","name":"ProposalQueued","inputs":[{"type":"uint256","name":"proposalId","internalType":"uint256","indexed":true},{"type":"address","name":"proposer","internalType":"address","indexed":true},{"type":"uint256","name":"transactionCount","internalType":"uint256","indexed":false},{"type":"uint256","name":"deposit","internalType":"uint256","indexed":false},{"type":"uint256","name":"timestamp","internalType":"uint256","indexed":false}],"anonymous":false},{"type":"event","name":"ProposalUpvoteRevoked","inputs":[{"type":"uint256","name":"proposalId","internalType":"uint256","indexed":true},{"type":"address","name":"account","internalType":"address","indexed":true},{"type":"uint256","name":"revokedUpvotes","internalType":"uint256","indexed":false}],"anonymous":false},{"type":"event","name":"ProposalUpvoted","inputs":[{"type":"uint256","name":"proposalId","internalType":"uint256","indexed":true},{"type":"address","name":"account","internalType":"address","indexed":true},{"type":"uint256","name":"upvotes","internalType":"uint256","indexed":false}],"anonymous":false},{"type":"event","name":"ProposalVoteRevoked","inputs":[{"type":"uint256","name":"proposalId","internalType":"uint256","indexed":true},{"type":"address","name":"account","internalType":"address","indexed":true},{"type":"uint256","name":"value","internalType":"uint256","indexed":false},{"type":"uint256","name":"weight","internalType":"uint256","indexed":false}],"anonymous":false},{"type":"event","name":"ProposalVoted","inputs":[{"type":"uint256","name":"proposalId","internalType":"uint256","indexed":true},{"type":"address","name":"account","internalType":"address","indexed":true},{"type":"uint256","name":"value","internalType":"uint256","indexed":false},{"type":"uint256","name":"weight","internalType":"uint256","indexed":false}],"anonymous":false},{"type":"event","name":"QueueExpirySet","inputs":[{"type":"uint256","name":"queueExpiry","internalType":"uint256","indexed":false}],"anonymous":false},{"type":"event","name":"ReferendumStageDurationSet","inputs":[{"type":"uint256","name":"referendumStageDuration","internalType":"uint256","indexed":false}],"anonymous":false},{"type":"event","name":"RegistrySet","inputs":[{"type":"address","name":"registryAddress","internalType":"address","indexed":true}],"anonymous":false},{"type":"fallback","stateMutability":"payable","payable":true},{"type":"function","stateMutability":"nonpayable","payable":false,"outputs":[{"type":"bool","name":"","internalType":"bool"}],"name":"approve","inputs":[{"type":"uint256","name":"proposalId","internalType":"uint256"},{"type":"uint256","name":"index","internalType":"uint256"}],"constant":false},{"type":"function","stateMutability":"nonpayable","payable":false,"outputs":[],"name":"approveHotfix","inputs":[{"type":"bytes32","name":"hash","internalType":"bytes32"}],"constant":false},{"type":"function","stateMutability":"view","payable":false,"outputs":[{"type":"address","name":"","internalType":"address"}],"name":"approver","inputs":[],"constant":true},{"type":"function","stateMutability":"view","payable":false,"outputs":[{"type":"bool","name":"","internalType":"bool"}],"name":"checkProofOfPossession","inputs":[{"type":"address","name":"sender","internalType":"address"},{"type":"bytes","name":"blsKey","internalType":"bytes"},{"type":"bytes","name":"blsPop","internalType":"bytes"}],"constant":true},{"type":"function","stateMutability":"view","payable":false,"outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"concurrentProposals","inputs":[],"constant":true},{"type":"function","stateMutability":"view","payable":false,"outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"dequeueFrequency","inputs":[],"constant":true},{"type":"function","stateMutability":"nonpayable","payable":false,"outputs":[],"name":"dequeueProposalsIfReady","inputs":[],"constant":false},{"type":"function","stateMutability":"view","payable":false,"outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"dequeued","inputs":[{"type":"uint256","name":"","internalType":"uint256"}],"constant":true},{"type":"function","stateMutability":"view","payable":false,"outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"emptyIndices","inputs":[{"type":"uint256","name":"","internalType":"uint256"}],"constant":true},{"type":"function","stateMutability":"nonpayable","payable":false,"outputs":[{"type":"bool","name":"","internalType":"bool"}],"name":"execute","inputs":[{"type":"uint256","name":"proposalId","internalType":"uint256"},{"type":"uint256","name":"index","internalType":"uint256"}],"constant":false},{"type":"function","stateMutability":"nonpayable","payable":false,"outputs":[],"name":"executeHotfix","inputs":[{"type":"uint256[]","name":"values","internalType":"uint256[]"},{"type":"address[]","name":"destinations","internalType":"address[]"},{"type":"bytes","name":"data","internalType":"bytes"},{"type":"uint256[]","name":"dataLengths","internalType":"uint256[]"},{"type":"bytes32","name":"salt","internalType":"bytes32"}],"constant":false},{"type":"function","stateMutability":"view","payable":false,"outputs":[{"type":"uint256","name":"","internalType":"uint256"},{"type":"uint256","name":"","internalType":"uint256"}],"name":"fractionMulExp","inputs":[{"type":"uint256","name":"aNumerator","internalType":"uint256"},{"type":"uint256","name":"aDenominator","internalType":"uint256"},{"type":"uint256","name":"bNumerator","internalType":"uint256"},{"type":"uint256","name":"bDenominator","internalType":"uint256"},{"type":"uint256","name":"exponent","internalType":"uint256"},{"type":"uint256","name":"_decimals","internalType":"uint256"}],"constant":true},{"type":"function","stateMutability":"view","payable":false,"outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"getApprovalStageDuration","inputs":[],"constant":true},{"type":"function","stateMutability":"view","payable":false,"outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"getBlockNumberFromHeader","inputs":[{"type":"bytes","name":"header","internalType":"bytes"}],"constant":true},{"type":"function","stateMutability":"view","payable":false,"outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"getConstitution","inputs":[{"type":"address","name":"destination","internalType":"address"},{"type":"bytes4","name":"functionId","internalType":"bytes4"}],"constant":true},{"type":"function","stateMutability":"view","payable":false,"outputs":[{"type":"uint256[]","name":"","internalType":"uint256[]"}],"name":"getDequeue","inputs":[],"constant":true},{"type":"function","stateMutability":"view","payable":false,"outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"getEpochNumber","inputs":[],"constant":true},{"type":"function","stateMutability":"view","payable":false,"outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"getEpochNumberOfBlock","inputs":[{"type":"uint256","name":"blockNumber","internalType":"uint256"}],"constant":true},{"type":"function","stateMutability":"view","payable":false,"outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"getEpochSize","inputs":[],"constant":true},{"type":"function","stateMutability":"view","payable":false,"outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"getExecutionStageDuration","inputs":[],"constant":true},{"type":"function","stateMutability":"view","payable":false,"outputs":[{"type":"bool","name":"","internalType":"bool"},{"type":"bool","name":"","internalType":"bool"},{"type":"uint256","name":"","internalType":"uint256"}],"name":"getHotfixRecord","inputs":[{"type":"bytes32","name":"hash","internalType":"bytes32"}],"constant":true},{"type":"function","stateMutability":"view","payable":false,"outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"getMostRecentReferendumProposal","inputs":[{"type":"address","name":"account","internalType":"address"}],"constant":true},{"type":"function","stateMutability":"view","payable":false,"outputs":[{"type":"bytes32","name":"","internalType":"bytes32"}],"name":"getParentSealBitmap","inputs":[{"type":"uint256","name":"blockNumber","internalType":"uint256"}],"constant":true},{"type":"function","stateMutability":"view","payable":false,"outputs":[{"type":"uint256","name":"","internalType":"uint256"},{"type":"uint256","name":"","internalType":"uint256"},{"type":"uint256","name":"","internalType":"uint256"},{"type":"uint256","name":"","internalType":"uint256"}],"name":"getParticipationParameters","inputs":[],"constant":true},{"type":"function","stateMutability":"view","payable":false,"outputs":[{"type":"address","name":"","internalType":"address"},{"type":"uint256","name":"","internalType":"uint256"},{"type":"uint256","name":"","internalType":"uint256"},{"type":"uint256","name":"","internalType":"uint256"},{"type":"string","name":"","internalType":"string"}],"name":"getProposal","inputs":[{"type":"uint256","name":"proposalId","internalType":"uint256"}],"constant":true},{"type":"function","stateMutability":"view","payable":false,"outputs":[{"type":"uint8","name":"","internalType":"enum Proposals.Stage"}],"name":"getProposalStage","inputs":[{"type":"uint256","name":"proposalId","internalType":"uint256"}],"constant":true},{"type":"function","stateMutability":"view","payable":false,"outputs":[{"type":"uint256","name":"","internalType":"uint256"},{"type":"address","name":"","internalType":"address"},{"type":"bytes","name":"","internalType":"bytes"}],"name":"getProposalTransaction","inputs":[{"type":"uint256","name":"proposalId","internalType":"uint256"},{"type":"uint256","name":"index","internalType":"uint256"}],"constant":true},{"type":"function","stateMutability":"view","payable":false,"outputs":[{"type":"uint256[]","name":"","internalType":"uint256[]"},{"type":"uint256[]","name":"","internalType":"uint256[]"}],"name":"getQueue","inputs":[],"constant":true},{"type":"function","stateMutability":"view","payable":false,"outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"getQueueLength","inputs":[],"constant":true},{"type":"function","stateMutability":"view","payable":false,"outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"getReferendumStageDuration","inputs":[],"constant":true},{"type":"function","stateMutability":"view","payable":false,"outputs":[{"type":"uint256","name":"","internalType":"uint256"},{"type":"uint256","name":"","internalType":"uint256"}],"name":"getUpvoteRecord","inputs":[{"type":"address","name":"account","internalType":"address"}],"constant":true},{"type":"function","stateMutability":"view","payable":false,"outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"getUpvotes","inputs":[{"type":"uint256","name":"proposalId","internalType":"uint256"}],"constant":true},{"type":"function","stateMutability":"view","payable":false,"outputs":[{"type":"bytes32","name":"","internalType":"bytes32"}],"name":"getVerifiedSealBitmapFromHeader","inputs":[{"type":"bytes","name":"header","internalType":"bytes"}],"constant":true},{"type":"function","stateMutability":"pure","payable":false,"outputs":[{"type":"uint256","name":"","internalType":"uint256"},{"type":"uint256","name":"","internalType":"uint256"},{"type":"uint256","name":"","internalType":"uint256"},{"type":"uint256","name":"","internalType":"uint256"}],"name":"getVersionNumber","inputs":[],"constant":true},{"type":"function","stateMutability":"view","payable":false,"outputs":[{"type":"uint256","name":"","internalType":"uint256"},{"type":"uint256","name":"","internalType":"uint256"},{"type":"uint256","name":"","internalType":"uint256"}],"name":"getVoteRecord","inputs":[{"type":"address","name":"account","internalType":"address"},{"type":"uint256","name":"index","internalType":"uint256"}],"constant":true},{"type":"function","stateMutability":"view","payable":false,"outputs":[{"type":"uint256","name":"","internalType":"uint256"},{"type":"uint256","name":"","internalType":"uint256"},{"type":"uint256","name":"","internalType":"uint256"}],"name":"getVoteTotals","inputs":[{"type":"uint256","name":"proposalId","internalType":"uint256"}],"constant":true},{"type":"function","stateMutability":"view","payable":false,"outputs":[{"type":"bytes32","name":"","internalType":"bytes32"}],"name":"hashHeader","inputs":[{"type":"bytes","name":"header","internalType":"bytes"}],"constant":true},{"type":"function","stateMutability":"view","payable":false,"outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"hotfixWhitelistValidatorTally","inputs":[{"type":"bytes32","name":"hash","internalType":"bytes32"}],"constant":true},{"type":"function","stateMutability":"view","payable":false,"outputs":[{"type":"bool","name":"executed","internalType":"bool"},{"type":"bool","name":"approved","internalType":"bool"},{"type":"uint256","name":"preparedEpoch","internalType":"uint256"}],"name":"hotfixes","inputs":[{"type":"bytes32","name":"","internalType":"bytes32"}],"constant":true},{"type":"function","stateMutability":"nonpayable","payable":false,"outputs":[],"name":"initialize","inputs":[{"type":"address","name":"registryAddress","internalType":"address"},{"type":"address","name":"_approver","internalType":"address"},{"type":"uint256","name":"_concurrentProposals","internalType":"uint256"},{"type":"uint256","name":"_minDeposit","internalType":"uint256"},{"type":"uint256","name":"_queueExpiry","internalType":"uint256"},{"type":"uint256","name":"_dequeueFrequency","internalType":"uint256"},{"type":"uint256","name":"approvalStageDuration","internalType":"uint256"},{"type":"uint256","name":"referendumStageDuration","internalType":"uint256"},{"type":"uint256","name":"executionStageDuration","internalType":"uint256"},{"type":"uint256","name":"participationBaseline","internalType":"uint256"},{"type":"uint256","name":"participationFloor","internalType":"uint256"},{"type":"uint256","name":"baselineUpdateFactor","internalType":"uint256"},{"type":"uint256","name":"baselineQuorumFactor","internalType":"uint256"}],"constant":false},{"type":"function","stateMutability":"view","payable":false,"outputs":[{"type":"bool","name":"","internalType":"bool"}],"name":"initialized","inputs":[],"constant":true},{"type":"function","stateMutability":"view","payable":false,"outputs":[{"type":"bool","name":"","internalType":"bool"}],"name":"isApproved","inputs":[{"type":"uint256","name":"proposalId","internalType":"uint256"}],"constant":true},{"type":"function","stateMutability":"view","payable":false,"outputs":[{"type":"bool","name":"","internalType":"bool"}],"name":"isDequeuedProposal","inputs":[{"type":"uint256","name":"proposalId","internalType":"uint256"},{"type":"uint256","name":"index","internalType":"uint256"}],"constant":true},{"type":"function","stateMutability":"view","payable":false,"outputs":[{"type":"bool","name":"","internalType":"bool"}],"name":"isDequeuedProposalExpired","inputs":[{"type":"uint256","name":"proposalId","internalType":"uint256"}],"constant":true},{"type":"function","stateMutability":"view","payable":false,"outputs":[{"type":"bool","name":"","internalType":"bool"}],"name":"isHotfixPassing","inputs":[{"type":"bytes32","name":"hash","internalType":"bytes32"}],"constant":true},{"type":"function","stateMutability":"view","payable":false,"outputs":[{"type":"bool","name":"","internalType":"bool"}],"name":"isHotfixWhitelistedBy","inputs":[{"type":"bytes32","name":"hash","internalType":"bytes32"},{"type":"address","name":"whitelister","internalType":"address"}],"constant":true},{"type":"function","stateMutability":"view","payable":false,"outputs":[{"type":"bool","name":"","internalType":"bool"}],"name":"isOwner","inputs":[],"constant":true},{"type":"function","stateMutability":"view","payable":false,"outputs":[{"type":"bool","name":"","internalType":"bool"}],"name":"isProposalPassing","inputs":[{"type":"uint256","name":"proposalId","internalType":"uint256"}],"constant":true},{"type":"function","stateMutability":"view","payable":false,"outputs":[{"type":"bool","name":"","internalType":"bool"}],"name":"isQueued","inputs":[{"type":"uint256","name":"proposalId","internalType":"uint256"}],"constant":true},{"type":"function","stateMutability":"view","payable":false,"outputs":[{"type":"bool","name":"","internalType":"bool"}],"name":"isQueuedProposalExpired","inputs":[{"type":"uint256","name":"proposalId","internalType":"uint256"}],"constant":true},{"type":"function","stateMutability":"view","payable":false,"outputs":[{"type":"bool","name":"","internalType":"bool"}],"name":"isVoting","inputs":[{"type":"address","name":"account","internalType":"address"}],"constant":true},{"type":"function","stateMutability":"view","payable":false,"outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"lastDequeue","inputs":[],"constant":true},{"type":"function","stateMutability":"view","payable":false,"outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"minDeposit","inputs":[],"constant":true},{"type":"function","stateMutability":"view","payable":false,"outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"minQuorumSize","inputs":[{"type":"uint256","name":"blockNumber","internalType":"uint256"}],"constant":true},{"type":"function","stateMutability":"view","payable":false,"outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"minQuorumSizeInCurrentSet","inputs":[],"constant":true},{"type":"function","stateMutability":"view","payable":false,"outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"numberValidatorsInCurrentSet","inputs":[],"constant":true},{"type":"function","stateMutability":"view","payable":false,"outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"numberValidatorsInSet","inputs":[{"type":"uint256","name":"blockNumber","internalType":"uint256"}],"constant":true},{"type":"function","stateMutability":"view","payable":false,"outputs":[{"type":"address","name":"","internalType":"address"}],"name":"owner","inputs":[],"constant":true},{"type":"function","stateMutability":"nonpayable","payable":false,"outputs":[],"name":"prepareHotfix","inputs":[{"type":"bytes32","name":"hash","internalType":"bytes32"}],"constant":false},{"type":"function","stateMutability":"view","payable":false,"outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"proposalCount","inputs":[],"constant":true},{"type":"function","stateMutability":"view","payable":false,"outputs":[{"type":"bool","name":"","internalType":"bool"}],"name":"proposalExists","inputs":[{"type":"uint256","name":"proposalId","internalType":"uint256"}],"constant":true},{"type":"function","stateMutability":"payable","payable":true,"outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"propose","inputs":[{"type":"uint256[]","name":"values","internalType":"uint256[]"},{"type":"address[]","name":"destinations","internalType":"address[]"},{"type":"bytes","name":"data","internalType":"bytes"},{"type":"uint256[]","name":"dataLengths","internalType":"uint256[]"},{"type":"string","name":"descriptionUrl","internalType":"string"}],"constant":false},{"type":"function","stateMutability":"view","payable":false,"outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"queueExpiry","inputs":[],"constant":true},{"type":"function","stateMutability":"view","payable":false,"outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"refundedDeposits","inputs":[{"type":"address","name":"","internalType":"address"}],"constant":true},{"type":"function","stateMutability":"view","payable":false,"outputs":[{"type":"address","name":"","internalType":"contract IRegistry"}],"name":"registry","inputs":[],"constant":true},{"type":"function","stateMutability":"nonpayable","payable":false,"outputs":[],"name":"renounceOwnership","inputs":[],"constant":false},{"type":"function","stateMutability":"nonpayable","payable":false,"outputs":[{"type":"bool","name":"","internalType":"bool"}],"name":"revokeUpvote","inputs":[{"type":"uint256","name":"lesser","internalType":"uint256"},{"type":"uint256","name":"greater","internalType":"uint256"}],"constant":false},{"type":"function","stateMutability":"nonpayable","payable":false,"outputs":[{"type":"bool","name":"","internalType":"bool"}],"name":"revokeVotes","inputs":[],"constant":false},{"type":"function","stateMutability":"nonpayable","payable":false,"outputs":[],"name":"setApprovalStageDuration","inputs":[{"type":"uint256","name":"approvalStageDuration","internalType":"uint256"}],"constant":false},{"type":"function","stateMutability":"nonpayable","payable":false,"outputs":[],"name":"setApprover","inputs":[{"type":"address","name":"_approver","internalType":"address"}],"constant":false},{"type":"function","stateMutability":"nonpayable","payable":false,"outputs":[],"name":"setBaselineQuorumFactor","inputs":[{"type":"uint256","name":"baselineQuorumFactor","internalType":"uint256"}],"constant":false},{"type":"function","stateMutability":"nonpayable","payable":false,"outputs":[],"name":"setBaselineUpdateFactor","inputs":[{"type":"uint256","name":"baselineUpdateFactor","internalType":"uint256"}],"constant":false},{"type":"function","stateMutability":"nonpayable","payable":false,"outputs":[],"name":"setConcurrentProposals","inputs":[{"type":"uint256","name":"_concurrentProposals","internalType":"uint256"}],"constant":false},{"type":"function","stateMutability":"nonpayable","payable":false,"outputs":[],"name":"setConstitution","inputs":[{"type":"address","name":"destination","internalType":"address"},{"type":"bytes4","name":"functionId","internalType":"bytes4"},{"type":"uint256","name":"threshold","internalType":"uint256"}],"constant":false},{"type":"function","stateMutability":"nonpayable","payable":false,"outputs":[],"name":"setDequeueFrequency","inputs":[{"type":"uint256","name":"_dequeueFrequency","internalType":"uint256"}],"constant":false},{"type":"function","stateMutability":"nonpayable","payable":false,"outputs":[],"name":"setExecutionStageDuration","inputs":[{"type":"uint256","name":"executionStageDuration","internalType":"uint256"}],"constant":false},{"type":"function","stateMutability":"nonpayable","payable":false,"outputs":[],"name":"setMinDeposit","inputs":[{"type":"uint256","name":"_minDeposit","internalType":"uint256"}],"constant":false},{"type":"function","stateMutability":"nonpayable","payable":false,"outputs":[],"name":"setParticipationBaseline","inputs":[{"type":"uint256","name":"participationBaseline","internalType":"uint256"}],"constant":false},{"type":"function","stateMutability":"nonpayable","payable":false,"outputs":[],"name":"setParticipationFloor","inputs":[{"type":"uint256","name":"participationFloor","internalType":"uint256"}],"constant":false},{"type":"function","stateMutability":"nonpayable","payable":false,"outputs":[],"name":"setQueueExpiry","inputs":[{"type":"uint256","name":"_queueExpiry","internalType":"uint256"}],"constant":false},{"type":"function","stateMutability":"nonpayable","payable":false,"outputs":[],"name":"setReferendumStageDuration","inputs":[{"type":"uint256","name":"referendumStageDuration","internalType":"uint256"}],"constant":false},{"type":"function","stateMutability":"nonpayable","payable":false,"outputs":[],"name":"setRegistry","inputs":[{"type":"address","name":"registryAddress","internalType":"address"}],"constant":false},{"type":"function","stateMutability":"view","payable":false,"outputs":[{"type":"uint256","name":"approval","internalType":"uint256"},{"type":"uint256","name":"referendum","internalType":"uint256"},{"type":"uint256","name":"execution","internalType":"uint256"}],"name":"stageDurations","inputs":[],"constant":true},{"type":"function","stateMutability":"nonpayable","payable":false,"outputs":[],"name":"transferOwnership","inputs":[{"type":"address","name":"newOwner","internalType":"address"}],"constant":false},{"type":"function","stateMutability":"nonpayable","payable":false,"outputs":[{"type":"bool","name":"","internalType":"bool"}],"name":"upvote","inputs":[{"type":"uint256","name":"proposalId","internalType":"uint256"},{"type":"uint256","name":"lesser","internalType":"uint256"},{"type":"uint256","name":"greater","internalType":"uint256"}],"constant":false},{"type":"function","stateMutability":"view","payable":false,"outputs":[{"type":"address","name":"","internalType":"address"}],"name":"validatorSignerAddressFromCurrentSet","inputs":[{"type":"uint256","name":"index","internalType":"uint256"}],"constant":true},{"type":"function","stateMutability":"view","payable":false,"outputs":[{"type":"address","name":"","internalType":"address"}],"name":"validatorSignerAddressFromSet","inputs":[{"type":"uint256","name":"index","internalType":"uint256"},{"type":"uint256","name":"blockNumber","internalType":"uint256"}],"constant":true},{"type":"function","stateMutability":"nonpayable","payable":false,"outputs":[{"type":"bool","name":"","internalType":"bool"}],"name":"vote","inputs":[{"type":"uint256","name":"proposalId","internalType":"uint256"},{"type":"uint256","name":"index","internalType":"uint256"},{"type":"uint8","name":"value","internalType":"enum Proposals.VoteValue"}],"constant":false},{"type":"function","stateMutability":"nonpayable","payable":false,"outputs":[],"name":"whitelistHotfix","inputs":[{"type":"bytes32","name":"hash","internalType":"bytes32"}],"constant":false},{"type":"function","stateMutability":"nonpayable","payable":false,"outputs":[{"type":"bool","name":"","internalType":"bool"}],"name":"withdraw","inputs":[],"constant":false}]
            

Deployed ByteCode

Verify & Publish
0x6080604052600436106104e15760003560e01c80637b10399911610281578063b15f0f581161015a578063cea69e74116100cc578063e50e652d11610085578063e50e652d146125a3578063ec683072146125f2578063ed3852741461267a578063f2fde38b146126fe578063fae8db0a1461274f578063ffea74c01461279e576104e1565b8063cea69e741461222e578063cf48eb9414612269578063d704f0c5146123f8578063da35c664146124f0578063df4da4611461251b578063e41db45514612546576104e1565b8063c1939b201161011e578063c1939b2014611f18578063c73a6d7814611ff8578063c7f758a81461204b578063c805956d14612147578063c8d8d2b514612187578063cd845a76146121c2576104e1565b8063b15f0f5814611dca578063b8f7700514611e05578063bbb2eab914611e30578063c0aee5f414611e9a578063c134b2fc14611ec5576104e1565b806398f42702116101f3578063a91ee0dc116101b7578063a91ee0dc14611c18578063aa2feb8314611c69578063ad78c10914611cb8578063add004df14611ce3578063af108a0e14611d32578063b0f9984214611d8f576104e1565b806398f4270214611ad95780639a6c3d8314611b285780639a7b3be714611b635780639b2b592f14611b8e5780639cb02dfc14611bdd576104e1565b80638da5cb5b116102455780638da5cb5b146119305780638e905ed6146119875780638f32d59b146119b25780638fcc9cfb146119e15780639381ab2514611a1c57806397b9eba614611a4b576104e1565b80637b103999146117485780638018556e1461179f57806381d4728d146117da57806387ee8a0f146118295780638a88362614611854576104e1565b80633fa5fed0116103be5780635f115a85116103305780636de8a63b116102e95780636de8a63b146115c95780636f2ab69314611635578063715018a6146116885780637385e5da1461169f57806377d26a2a146116ca5780637910867b146116f5576104e1565b80635f115a85146111865780635f8dd6491461120357806360b4d34d1461126c57806365bbdaa0146112d15780636643ac58146114b257806367960e91146114ed576104e1565b80635601eaea116103825780635601eaea14610f485780635733397814610fa5578063582ae53b1461100c5780635c759394146110695780635d180adb146110a45780635d35a3d914611129576104e1565b80633fa5fed014610d2957806341b3d18514610d9c57806345a7849914610dc75780634b2c2f4414610e2c57806354255be014610f08576104e1565b806323f0ab65116104575780633156560e1161041b5780633156560e14610bb5578063344944cf14610c065780633b1eb4bf14610c595780633bb0ed2b14610ca85780633ccfd60b14610cbf5780633db9dd9a14610cee576104e1565b806323f0ab65146109005780632762132114610a97578063283aaefb14610aea5780632c05235514610b4f57806330a095d014610b8a576104e1565b8063123633ea116104a9578063123633ea146107145780631374b22d1461078f578063141a8dd8146107e2578063152b483414610839578063158ef93e146108965780631c65bc61146108c5576104e1565b806301fce27e1461055c57806304acaec9146106105780630e0b78ae1461064b5780630f717e42146106b05780631201a0fb146106e9575b6000803690501461055a576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252600e8152602001807f756e6b6e6f776e206d6574686f6400000000000000000000000000000000000081525060200191505060405180910390fd5b005b34801561056857600080fd5b506105716127c9565b604051808060200180602001838103835285818151815260200191508051906020019060200280838360005b838110156105b857808201518184015260208101905061059d565b50505050905001838103825284818151815260200191508051906020019060200280838360005b838110156105fa5780820151818401526020810190506105df565b5050505090500194505050505060405180910390f35b34801561061c57600080fd5b506106496004803603602081101561063357600080fd5b810190808035906020019092919050505061298e565b005b34801561065757600080fd5b506106846004803603602081101561066e57600080fd5b8101908080359060200190929190505050612b66565b604051808415151515815260200183151515158152602001828152602001935050505060405180910390f35b3480156106bc57600080fd5b506106c5612bd7565b60405180848152602001838152602001828152602001935050505060405180910390f35b3480156106f557600080fd5b506106fe612bef565b6040518082815260200191505060405180910390f35b34801561072057600080fd5b5061074d6004803603602081101561073757600080fd5b8101908080359060200190929190505050612bf5565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b34801561079b57600080fd5b506107c8600480360360208110156107b257600080fd5b8101908080359060200190929190505050612d46565b604051808215151515815260200191505060405180910390f35b3480156107ee57600080fd5b506107f7612d6a565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b34801561084557600080fd5b5061087c6004803603604081101561085c57600080fd5b810190808035906020019092919080359060200190929190505050612d90565b604051808215151515815260200191505060405180910390f35b3480156108a257600080fd5b506108ab612db7565b604051808215151515815260200191505060405180910390f35b3480156108d157600080fd5b506108fe600480360360208110156108e857600080fd5b8101908080359060200190929190505050612dca565b005b34801561090c57600080fd5b50610a7d6004803603606081101561092357600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff1690602001909291908035906020019064010000000081111561096057600080fd5b82018360208201111561097257600080fd5b8035906020019184600183028401116401000000008311171561099457600080fd5b91908080601f016020809104026020016040519081016040528093929190818152602001838380828437600081840152601f19601f820116905080830192505050505050509192919290803590602001906401000000008111156109f757600080fd5b820183602082011115610a0957600080fd5b80359060200191846001830284011164010000000083111715610a2b57600080fd5b91908080601f016020809104026020016040519081016040528093929190818152602001838380828437600081840152601f19601f820116905080830192505050505050509192919290505050612f85565b604051808215151515815260200191505060405180910390f35b348015610aa357600080fd5b50610ad060048036036020811015610aba57600080fd5b810190808035906020019092919050505061313e565b604051808215151515815260200191505060405180910390f35b348015610af657600080fd5b50610b3960048036036020811015610b0d57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050613162565b6040518082815260200191505060405180910390f35b348015610b5b57600080fd5b50610b8860048036036020811015610b7257600080fd5b81019080803590602001909291905050506131ae565b005b348015610b9657600080fd5b50610b9f61333a565b6040518082815260200191505060405180910390f35b348015610bc157600080fd5b50610c0460048036036020811015610bd857600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050613347565b005b348015610c1257600080fd5b50610c3f60048036036020811015610c2957600080fd5b81019080803590602001909291905050506135af565b604051808215151515815260200191505060405180910390f35b348015610c6557600080fd5b50610c9260048036036020811015610c7c57600080fd5b81019080803590602001909291905050506135cb565b6040518082815260200191505060405180910390f35b348015610cb457600080fd5b50610cbd6135e5565b005b348015610ccb57600080fd5b50610cd46139d4565b604051808215151515815260200191505060405180910390f35b348015610cfa57600080fd5b50610d2760048036036020811015610d1157600080fd5b8101908080359060200190929190505050613c0b565b005b348015610d3557600080fd5b50610d8260048036036040811015610d4c57600080fd5b8101908080359060200190929190803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050613de3565b604051808215151515815260200191505060405180910390f35b348015610da857600080fd5b50610db1613e4e565b6040518082815260200191505060405180910390f35b348015610dd357600080fd5b50610e0060048036036020811015610dea57600080fd5b8101908080359060200190929190505050613e54565b604051808415151515815260200183151515158152602001828152602001935050505060405180910390f35b348015610e3857600080fd5b50610ef260048036036020811015610e4f57600080fd5b8101908080359060200190640100000000811115610e6c57600080fd5b820183602082011115610e7e57600080fd5b80359060200191846001830284011164010000000083111715610ea057600080fd5b91908080601f016020809104026020016040519081016040528093929190818152602001838380828437600081840152601f19601f820116905080830192505050505050509192919290505050613e98565b6040518082815260200191505060405180910390f35b348015610f1457600080fd5b50610f1d61402c565b6040518085815260200184815260200183815260200182815260200194505050505060405180910390f35b348015610f5457600080fd5b50610f8b60048036036040811015610f6b57600080fd5b810190808035906020019092919080359060200190929190505050614053565b604051808215151515815260200191505060405180910390f35b348015610fb157600080fd5b50610ff260048036036060811015610fc857600080fd5b8101908080359060200190929190803590602001909291908035906020019092919050505061423e565b604051808215151515815260200191505060405180910390f35b34801561101857600080fd5b506110456004803603602081101561102f57600080fd5b81019080803590602001909291905050506148d3565b6040518082600581111561105557fe5b60ff16815260200191505060405180910390f35b34801561107557600080fd5b506110a26004803603602081101561108c57600080fd5b810190808035906020019092919050505061496f565b005b3480156110b057600080fd5b506110e7600480360360408110156110c757600080fd5b810190808035906020019092919080359060200190929190505050614b47565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b34801561113557600080fd5b5061116c6004803603604081101561114c57600080fd5b810190808035906020019092919080359060200190929190505050614c99565b604051808215151515815260200191505060405180910390f35b34801561119257600080fd5b506111df600480360360408110156111a957600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050614f7e565b60405180848152602001838152602001828152602001935050505060405180910390f35b34801561120f57600080fd5b506112526004803603602081101561122657600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919050505061500e565b604051808215151515815260200191505060405180910390f35b34801561127857600080fd5b506112bb6004803603602081101561128f57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff1690602001909291905050506150ea565b6040518082815260200191505060405180910390f35b61149c600480360360a08110156112e757600080fd5b810190808035906020019064010000000081111561130457600080fd5b82018360208201111561131657600080fd5b8035906020019184602083028401116401000000008311171561133857600080fd5b90919293919293908035906020019064010000000081111561135957600080fd5b82018360208201111561136b57600080fd5b8035906020019184602083028401116401000000008311171561138d57600080fd5b9091929391929390803590602001906401000000008111156113ae57600080fd5b8201836020820111156113c057600080fd5b803590602001918460018302840111640100000000831117156113e257600080fd5b90919293919293908035906020019064010000000081111561140357600080fd5b82018360208201111561141557600080fd5b8035906020019184602083028401116401000000008311171561143757600080fd5b90919293919293908035906020019064010000000081111561145857600080fd5b82018360208201111561146a57600080fd5b8035906020019184600183028401116401000000008311171561148c57600080fd5b9091929391929390505050615102565b6040518082815260200191505060405180910390f35b3480156114be57600080fd5b506114eb600480360360208110156114d557600080fd5b810190808035906020019092919050505061547e565b005b3480156114f957600080fd5b506115b36004803603602081101561151057600080fd5b810190808035906020019064010000000081111561152d57600080fd5b82018360208201111561153f57600080fd5b8035906020019184600183028401116401000000008311171561156157600080fd5b91908080601f016020809104026020016040519081016040528093929190818152602001838380828437600081840152601f19601f82011690508083019250505050505050919291929050505061562d565b6040518082815260200191505060405180910390f35b3480156115d557600080fd5b506115de6157c1565b6040518080602001828103825283818151815260200191508051906020019060200280838360005b83811015611621578082015181840152602081019050611606565b505050509050019250505060405180910390f35b34801561164157600080fd5b5061166e6004803603602081101561165857600080fd5b8101908080359060200190929190505050615819565b604051808215151515815260200191505060405180910390f35b34801561169457600080fd5b5061169d615856565b005b3480156116ab57600080fd5b506116b461598f565b6040518082815260200191505060405180910390f35b3480156116d657600080fd5b506116df61599f565b6040518082815260200191505060405180910390f35b34801561170157600080fd5b5061172e6004803603602081101561171857600080fd5b81019080803590602001909291905050506159a5565b604051808215151515815260200191505060405180910390f35b34801561175457600080fd5b5061175d6159c9565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b3480156117ab57600080fd5b506117d8600480360360208110156117c257600080fd5b81019080803590602001909291905050506159ef565b005b3480156117e657600080fd5b50611813600480360360208110156117fd57600080fd5b8101908080359060200190929190505050615b7b565b6040518082815260200191505060405180910390f35b34801561183557600080fd5b5061183e615cd1565b6040518082815260200191505060405180910390f35b34801561186057600080fd5b5061191a6004803603602081101561187757600080fd5b810190808035906020019064010000000081111561189457600080fd5b8201836020820111156118a657600080fd5b803590602001918460018302840111640100000000831117156118c857600080fd5b91908080601f016020809104026020016040519081016040528093929190818152602001838380828437600081840152601f19601f820116905080830192505050505050509192919290505050615e18565b6040518082815260200191505060405180910390f35b34801561193c57600080fd5b50611945615fac565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b34801561199357600080fd5b5061199c615fd5565b6040518082815260200191505060405180910390f35b3480156119be57600080fd5b506119c7615fdb565b604051808215151515815260200191505060405180910390f35b3480156119ed57600080fd5b50611a1a60048036036020811015611a0457600080fd5b8101908080359060200190929190505050616039565b005b348015611a2857600080fd5b50611a316161e2565b604051808215151515815260200191505060405180910390f35b348015611a5757600080fd5b50611ac360048036036040811015611a6e57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080357bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19169060200190929190505050616667565b6040518082815260200191505060405180910390f35b348015611ae557600080fd5b50611b1260048036036020811015611afc57600080fd5b8101908080359060200190929190505050616683565b6040518082815260200191505060405180910390f35b348015611b3457600080fd5b50611b6160048036036020811015611b4b57600080fd5b810190808035906020019092919050505061679c565b005b348015611b6f57600080fd5b50611b7861694b565b6040518082815260200191505060405180910390f35b348015611b9a57600080fd5b50611bc760048036036020811015611bb157600080fd5b810190808035906020019092919050505061695b565b6040518082815260200191505060405180910390f35b348015611be957600080fd5b50611c1660048036036020811015611c0057600080fd5b8101908080359060200190929190505050616aa4565b005b348015611c2457600080fd5b50611c6760048036036020811015611c3b57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050616c62565b005b348015611c7557600080fd5b50611ca260048036036020811015611c8c57600080fd5b8101908080359060200190929190505050616e06565b6040518082815260200191505060405180910390f35b348015611cc457600080fd5b50611ccd616e27565b6040518082815260200191505060405180910390f35b348015611cef57600080fd5b50611d1c60048036036020811015611d0657600080fd5b8101908080359060200190929190505050616e34565b6040518082815260200191505060405180910390f35b348015611d3e57600080fd5b50611d7560048036036040811015611d5557600080fd5b810190808035906020019092919080359060200190929190505050616e55565b604051808215151515815260200191505060405180910390f35b348015611d9b57600080fd5b50611dc860048036036020811015611db257600080fd5b81019080803590602001909291905050506172e8565b005b348015611dd657600080fd5b50611e0360048036036020811015611ded57600080fd5b81019080803590602001909291905050506174a3565b005b348015611e1157600080fd5b50611e1a61760f565b6040518082815260200191505060405180910390f35b348015611e3c57600080fd5b50611e8060048036036060811015611e5357600080fd5b810190808035906020019092919080359060200190929190803560ff16906020019092919050505061761f565b604051808215151515815260200191505060405180910390f35b348015611ea657600080fd5b50611eaf617d49565b6040518082815260200191505060405180910390f35b348015611ed157600080fd5b50611efe60048036036020811015611ee857600080fd5b8101908080359060200190929190505050617d4f565b604051808215151515815260200191505060405180910390f35b348015611f2457600080fd5b50611ff660048036036101a0811015611f3c57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff1690602001909291908035906020019092919080359060200190929190803590602001909291908035906020019092919080359060200190929190803590602001909291908035906020019092919080359060200190929190803590602001909291908035906020019092919080359060200190929190505050617d73565b005b34801561200457600080fd5b506120316004803603602081101561201b57600080fd5b8101908080359060200190929190505050617ea5565b604051808215151515815260200191505060405180910390f35b34801561205757600080fd5b506120846004803603602081101561206e57600080fd5b8101908080359060200190929190505050617f43565b604051808673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200185815260200184815260200183815260200180602001828103825283818151815260200191508051906020019080838360005b838110156121085780820151818401526020810190506120ed565b50505050905090810190601f1680156121355780820380516001836020036101000a031916815260200191505b50965050505050505060405180910390f35b34801561215357600080fd5b5061215c618015565b6040518085815260200184815260200183815260200182815260200194505050505060405180910390f35b34801561219357600080fd5b506121c0600480360360208110156121aa57600080fd5b81019080803590602001909291905050506180b1565b005b3480156121ce57600080fd5b50612211600480360360208110156121e557600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919050505061823d565b604051808381526020018281526020019250505060405180910390f35b34801561223a57600080fd5b506122676004803603602081101561225157600080fd5b81019080803590602001909291905050506182bf565b005b34801561227557600080fd5b506123f6600480360360a081101561228c57600080fd5b81019080803590602001906401000000008111156122a957600080fd5b8201836020820111156122bb57600080fd5b803590602001918460208302840111640100000000831117156122dd57600080fd5b9091929391929390803590602001906401000000008111156122fe57600080fd5b82018360208201111561231057600080fd5b8035906020019184602083028401116401000000008311171561233257600080fd5b90919293919293908035906020019064010000000081111561235357600080fd5b82018360208201111561236557600080fd5b8035906020019184600183028401116401000000008311171561238757600080fd5b9091929391929390803590602001906401000000008111156123a857600080fd5b8201836020820111156123ba57600080fd5b803590602001918460208302840111640100000000831117156123dc57600080fd5b90919293919293908035906020019092919050505061846e565b005b34801561240457600080fd5b5061243b6004803603604081101561241b57600080fd5b810190808035906020019092919080359060200190929190505050618855565b604051808481526020018373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200180602001828103825283818151815260200191508051906020019080838360005b838110156124b3578082015181840152602081019050612498565b50505050905090810190601f1680156124e05780820380516001836020036101000a031916815260200191505b5094505050505060405180910390f35b3480156124fc57600080fd5b506125056189df565b6040518082815260200191505060405180910390f35b34801561252757600080fd5b506125306189e5565b6040518082815260200191505060405180910390f35b34801561255257600080fd5b5061257f6004803603602081101561256957600080fd5b8101908080359060200190929190505050618b21565b60405180848152602001838152602001828152602001935050505060405180910390f35b3480156125af57600080fd5b506125dc600480360360208110156125c657600080fd5b8101908080359060200190929190505050618b4e565b6040518082815260200191505060405180910390f35b3480156125fe57600080fd5b5061265d600480360360c081101561261557600080fd5b81019080803590602001909291908035906020019092919080359060200190929190803590602001909291908035906020019092919080359060200190929190505050618b99565b604051808381526020018281526020019250505060405180910390f35b34801561268657600080fd5b506126fc6004803603606081101561269d57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080357bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916906020019092919080359060200190929190505050618dad565b005b34801561270a57600080fd5b5061274d6004803603602081101561272157600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff1690602001909291905050506190ea565b005b34801561275b57600080fd5b506127886004803603602081101561277257600080fd5b8101908080359060200190929190505050619170565b6040518082815260200191505060405180910390f35b3480156127aa57600080fd5b506127b36192b9565b6040518082815260200191505060405180910390f35b606080601273411b40a81a07fcd3542ce5b3d7e215178c4ca2ef6369b317e390916040518263ffffffff1660e01b81526004018082815260200191505060006040518083038186803b15801561281e57600080fd5b505af4158015612832573d6000803e3d6000fd5b505050506040513d6000823e3d601f19601f82011682018060405250604081101561285c57600080fd5b810190808051604051939291908464010000000082111561287c57600080fd5b8382019150602082018581111561289257600080fd5b82518660208202830111640100000000821117156128af57600080fd5b8083526020830192505050908051906020019060200280838360005b838110156128e65780820151818401526020810190506128cb565b505050509050016040526020018051604051939291908464010000000082111561290f57600080fd5b8382019150602082018581111561292557600080fd5b825186602082028301116401000000008211171561294257600080fd5b8083526020830192505050908051906020019060200280838360005b8381101561297957808201518184015260208101905061295e565b50505050905001604052505050915091509091565b612996615fdb565b612a08576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260208152602001807f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657281525060200191505060405180910390fd5b612a1061b7e5565b612a19826192c6565b9050612a24816192e4565b612a79576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252602781526020018061bbc86027913960400191505060405180910390fd5b612aa56019600301604051806020016040529081600082015481525050826192fe90919063ffffffff16565b15612b18576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260208152602001807f426173656c696e652071756f72756d20666163746f7220756e6368616e67656481525060200191505060405180910390fd5b806019600301600082015181600001559050507fddfdbe55eaaa70fe2b8bc82a9b0734c25cabe7cb6f1457f9644019f0b5ff91fc826040518082815260200191505060405180910390a15050565b60008060006011600085815260200190815260200160002060000160019054906101000a900460ff166011600086815260200190815260200160002060000160009054906101000a900460ff1660116000878152602001908152602001600020600101549250925092509193909250565b60038060000154908060010154908060020154905083565b600a5481565b60006060600060fa73ffffffffffffffffffffffffffffffffffffffff16844360405160200180838152602001828152602001925050506040516020818303038152906040526040518082805190602001908083835b60208310612c6e5780518252602082019150602081019050602083039250612c4b565b6001836020036101000a038019825116818451168082178552505050505050905001915050600060405180830381855afa9150503d8060008114612cce576040519150601f19603f3d011682016040523d82523d6000602084013e612cd3565b606091505b50809350819250505080612d32576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252603d81526020018061bd55603d913960400191505060405180910390fd5b612d3d826000619313565b92505050919050565b6000612d63600f600084815260200190815260200160002061932a565b9050919050565b600860009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b6000612daf600f6000858152602001908152602001600020848461933a565b905092915050565b600060149054906101000a900460ff1681565b612dd2615fdb565b612e44576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260208152602001807f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657281525060200191505060405180910390fd5b612e4c61b7e5565b612e55826192c6565b9050612e60816192e4565b612eb5576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252602481526020018061bf2f6024913960400191505060405180910390fd5b612ee16019600101604051806020016040529081600082015481525050826192fe90919063ffffffff16565b15612f37576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252602681526020018061bc376026913960400191505060405180910390fd5b806019600101600082015181600001559050507f122a37b609e0f758b6a23c43506cb567017a4d18b21fa91312fb42b44975a5b5826040518082815260200191505060405180910390a15050565b60008060fb73ffffffffffffffffffffffffffffffffffffffff16858585604051602001808473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1660601b815260140183805190602001908083835b6020831061300e5780518252602082019150602081019050602083039250612feb565b6001836020036101000a03801982511681845116808217855250505050505090500182805190602001908083835b6020831061305f578051825260208201915060208101905060208303925061303c565b6001836020036101000a03801982511681845116808217855250505050505090500193505050506040516020818303038152906040526040518082805190602001908083835b602083106130c857805182526020820191506020810190506020830392506130a5565b6001836020036101000a038019825116818451168082178552505050505050905001915050600060405180830381855afa9150503d8060008114613128576040519150601f19603f3d011682016040523d82523d6000602084013e61312d565b606091505b505080915050809150509392505050565b600061315b600f60008481526020019081526020016000206193cd565b9050919050565b6000601060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600201549050919050565b6131b6615fdb565b613228576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260208152602001807f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657281525060200191505060405180910390fd5b60008111613281576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252602181526020018061bad76021913960400191505060405180910390fd5b6006548114156132f9576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260158152602001807f517565756545787069727920756e6368616e676564000000000000000000000081525060200191505060405180910390fd5b806006819055507f4ecbf0bb0701615e2d6f9b0a0996056c959fe359ce76aa7ce06c5f1d57dae4d7816040518082815260200191505060405180910390a150565b6000600360020154905090565b61334f615fdb565b6133c1576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260208152602001807f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657281525060200191505060405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff161415613464576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260148152602001807f417070726f7665722063616e6e6f74206265203000000000000000000000000081525060200191505060405180910390fd5b600860009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff161415613528576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260128152602001807f417070726f76657220756e6368616e676564000000000000000000000000000081525060200191505060405180910390fd5b80600860006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055508073ffffffffffffffffffffffffffffffffffffffff167fa03757d836cb0b61c0fbba2147f5d51d6071ff3dd5bf6963beb55563d64878e160405160405180910390a250565b60006135b961598f565b6135c283615b7b565b10159050919050565b60006135de826135d96189e5565b6195ac565b9050919050565b6135fc6007546009546195f490919063ffffffff16565b42106139d2576000613618600a5460126000016002015461967c565b90506060601273411b40a81a07fcd3542ce5b3d7e215178c4ca2ef6377b024799091846040518363ffffffff1660e01b8152600401808381526020018281526020019250505060006040518083038186803b15801561367657600080fd5b505af415801561368a573d6000803e3d6000fd5b505050506040513d6000823e3d601f19601f8201168201806040525060208110156136b457600080fd5b81019080805160405193929190846401000000008211156136d457600080fd5b838201915060208201858111156136ea57600080fd5b825186602082028301116401000000008211171561370757600080fd5b8083526020830192505050908051906020019060200280838360005b8381101561373e578082015181840152602081019050613723565b50505050905001604052505050905060008090505b828110156139c757600082828151811061376957fe5b602002602001015190506000600f6000838152602001908152602001600020905061379381619695565b156137cc57817f88e53c486703527139dfc8d97a1e559d9bd93d3f9d52cda4e06564111e7a264360405160405180910390a250506139ac565b6138468160010154600d60008460000160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546195f490919063ffffffff16565b600d60008360000160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550428160020181905550600060188054905011156139445760006138df60016018805490506196ba90919063ffffffff16565b9050826017601883815481106138f157fe5b90600052602060002001548154811061390657fe5b90600052602060002001819055506018818154811061392157fe5b90600052602060002001600090558060188161393d919061b7f8565b5050613971565b60178290806001815401808255809150509060018203906000526020600020016000909192909190915055505b817f3e069fb74dcf5fbc07740b0d40d7f7fc48e9c0ca5dc3d19eb34d2e05d74c5543426040518082815260200191505060405180910390a250505b6139c06001826195f490919063ffffffff16565b9050613753565b504260098190555050505b565b600060018060008282540192505081905550600060015490506000600d60003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905060008111613aa7576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260138152602001807f4e6f7468696e6720746f2077697468647261770000000000000000000000000081525060200191505060405180910390fd5b47811115613b1d576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260148152602001807f496e636f6e73697374656e742062616c616e636500000000000000000000000081525060200191505060405180910390fd5b6000600d60003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550613b8b813373ffffffffffffffffffffffffffffffffffffffff1661970490919063ffffffff16565b60019250506001548114613c07576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252600e8152602001807f7265656e7472616e742063616c6c00000000000000000000000000000000000081525060200191505060405180910390fd5b5090565b613c13615fdb565b613c85576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260208152602001807f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657281525060200191505060405180910390fd5b613c8d61b7e5565b613c96826192c6565b9050613ca1816192e4565b613cf6576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252602781526020018061bb266027913960400191505060405180910390fd5b613d226019600001604051806020016040529081600082015481525050826192fe90919063ffffffff16565b15613d95576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260208152602001807f50617274696369706174696f6e20626173656c696e6520756e6368616e67656481525060200191505060405180910390fd5b806019600001600082015181600001559050507f51131d2820f04a6b6edd20e22a07d5bf847e265a3906e85256fca7d6043417c5826040518082815260200191505060405180910390a15050565b60006011600084815260200190815260200160002060020160008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff16905092915050565b600c5481565b60116020528060005260406000206000915090508060000160009054906101000a900460ff16908060000160019054906101000a900460ff16908060010154905083565b60006060600060f473ffffffffffffffffffffffffffffffffffffffff16846040516020018082805190602001908083835b60208310613eed5780518252602082019150602081019050602083039250613eca565b6001836020036101000a0380198251168184511680821785525050505050509050019150506040516020818303038152906040526040518082805190602001908083835b60208310613f545780518252602082019150602081019050602083039250613f31565b6001836020036101000a038019825116818451168082178552505050505050905001915050600060405180830381855afa9150503d8060008114613fb4576040519150601f19603f3d011682016040523d82523d6000602084013e613fb9565b606091505b50809350819250505080614018576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252603881526020018061bcbe6038913960400191505060405180910390fd5b61402382600061983e565b92505050919050565b60008060008060016002600180839350829250819150809050935093509350935090919293565b600060018060008282540192505081905550600060015490506140746135e5565b60008061408186866198df565b9150915060006140908361932a565b905080156141ba57600460058111156140a557fe5b8260058111156140b157fe5b1480156140c357506140c2836193cd565b5b614118576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252602e81526020018061bdfd602e913960400191505060405180910390fd5b8273239dd6e82d77d5ed0600e42f1427c3fc53eaf9cb63c67e7b4b90916040518263ffffffff1660e01b81526004018082815260200191505060006040518083038186803b15801561416957600080fd5b505af415801561417d573d6000803e3d6000fd5b50505050867f712ae1383f79ac853f8d882153778e0260ef8f03b504e2866e0593e04d2b291f60405160405180910390a26141b98388886199c6565b5b8094505050506001548114614237576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252600e8152602001807f7265656e7472616e742063616c6c00000000000000000000000000000000000081525060200191505060405180910390fd5b5092915050565b6000600180600082825401925050819055506000600154905061425f6135e5565b61426885619ae4565b156142765760009150614854565b6000614280619bb7565b73ffffffffffffffffffffffffffffffffffffffff16636642d594336040518263ffffffff1660e01b8152600401808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060206040518083038186803b1580156142fc57600080fd5b505afa158015614310573d6000803e3d6000fd5b505050506040513d602081101561432657600080fd5b810190808051906020019092919050505090506000601060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020905061438c8160000160000154619ae4565b506000614397619cb2565b73ffffffffffffffffffffffffffffffffffffffff166330ec70f5846040518263ffffffff1660e01b8152600401808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060206040518083038186803b15801561441357600080fd5b505afa158015614427573d6000803e3d6000fd5b505050506040513d602081101561443d57600080fd5b81019080805190602001909291905050509050600081116144a9576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252602281526020018061be9b6022913960400191505060405180910390fd5b601273411b40a81a07fcd3542ce5b3d7e215178c4ca2ef63bfc5163890918a6040518363ffffffff1660e01b8152600401808381526020018281526020019250505060206040518083038186803b15801561450357600080fd5b505af4158015614517573d6000803e3d6000fd5b505050506040513d602081101561452d57600080fd5b8101908080519060200190929190505050614593576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252602981526020018061bd2c6029913960400191505060405180910390fd5b6000826000016000015414806146425750601273411b40a81a07fcd3542ce5b3d7e215178c4ca2ef63bfc51638909184600001600001546040518363ffffffff1660e01b8152600401808381526020018281526020019250505060206040518083038186803b15801561460557600080fd5b505af4158015614619573d6000803e3d6000fd5b505050506040513d602081101561462f57600080fd5b8101908080519060200190929190505050155b614697576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252602b81526020018061bfb0602b913960400191505060405180910390fd5b600061474082601273411b40a81a07fcd3542ce5b3d7e215178c4ca2ef637577759990918d6040518363ffffffff1660e01b8152600401808381526020018281526020019250505060206040518083038186803b1580156146f757600080fd5b505af415801561470b573d6000803e3d6000fd5b505050506040513d602081101561472157600080fd5b81019080805190602001909291905050506195f490919063ffffffff16565b9050601273411b40a81a07fcd3542ce5b3d7e215178c4ca2ef63239491ba90918b848c8c6040518663ffffffff1660e01b8152600401808681526020018581526020018481526020018381526020018281526020019550505050505060006040518083038186803b1580156147b457600080fd5b505af41580156147c8573d6000803e3d6000fd5b5050505060405180604001604052808a8152602001838152508360000160008201518160000155602082015181600101559050508373ffffffffffffffffffffffffffffffffffffffff16897fd19965d25ef670a1e322fbf05475924b7b12d81fd6b96ab718b261782efb3d62846040518082815260200191505060405180910390a360019550505050505b60015481146148cb576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252600e8152602001807f7265656e7472616e742063616c6c00000000000000000000000000000000000081525060200191505060405180910390fd5b509392505050565b6000808214806148e45750600b5482115b156148f2576000905061496a565b6000600f6000848152602001908152602001600020905061491283617ea5565b156149365761492081619695565b61492b57600161492e565b60055b91505061496a565b600061494c600383619dad90919063ffffffff16565b90506149588282619e6a565b6149625780614965565b60055b925050505b919050565b614977615fdb565b6149e9576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260208152602001807f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657281525060200191505060405180910390fd5b6149f161b7e5565b6149fa826192c6565b9050614a05816192e4565b614a5a576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252602781526020018061bc976027913960400191505060405180910390fd5b614a866019600201604051806020016040529081600082015481525050826192fe90919063ffffffff16565b15614af9576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260208152602001807f426173656c696e652075706461746520666163746f7220756e6368616e67656481525060200191505060405180910390fd5b806019600201600082015181600001559050507f8dedb4d995dd500718c7c5f6a077fba6153a7ee063da961d9fcab90ff528ac1f826040518082815260200191505060405180910390a15050565b60006060600060fa73ffffffffffffffffffffffffffffffffffffffff16858560405160200180838152602001828152602001925050506040516020818303038152906040526040518082805190602001908083835b60208310614bc05780518252602082019150602081019050602083039250614b9d565b6001836020036101000a038019825116818451168082178552505050505050905001915050600060405180830381855afa9150503d8060008114614c20576040519150601f19603f3d011682016040523d82523d6000602084013e614c25565b606091505b50809350819250505080614c84576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252603681526020018061bdc76036913960400191505060405180910390fd5b614c8f826000619313565b9250505092915050565b6000600860009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614614d5e576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260178152602001807f6d73672e73656e646572206e6f7420617070726f76657200000000000000000081525060200191505060405180910390fd5b614d666135e5565b600080614d7385856198df565b91509150614d808261932a565b614d8f57600092505050614f78565b614d9882619ef4565b15614e0b576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260198152602001807f50726f706f73616c20616c726561647920617070726f7665640000000000000081525060200191505060405180910390fd5b60026005811115614e1857fe5b816005811115614e2457fe5b14614e97576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601e8152602001807f50726f706f73616c206e6f7420696e20617070726f76616c207374616765000081525060200191505060405180910390fd5b60018260070160006101000a81548160ff021916908315150217905550614ebc619cb2565b73ffffffffffffffffffffffffffffffffffffffff166330a61d596040518163ffffffff1660e01b815260040160206040518083038186803b158015614f0157600080fd5b505afa158015614f15573d6000803e3d6000fd5b505050506040513d6020811015614f2b57600080fd5b81019080805190602001909291905050508260080181905550847f28ec9e38ba73636ceb2f6c1574136f83bd46284a3c74734b711bf45e12f8d92960405160405180910390a26001925050505b92915050565b600080600080601060008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206003016000868152602001908152602001600020905080600101548160000160009054906101000a900460ff166003811115614ffb57fe5b8260020154935093509350509250925092565b600080601060008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002090506000816000016000015490506000808214158015615075575061507482617ea5565b5b8015615087575061508582617d4f565b155b90506000600f60008560020154815260200190815260200160002090506000600360058111156150b357fe5b6150c7600384619dad90919063ffffffff16565b60058111156150d257fe5b14905082806150de5750805b95505050505050919050565b600d6020528060005260406000206000915090505481565b600061510c6135e5565b600c54341015615184576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260118152602001807f546f6f20736d616c6c206465706f73697400000000000000000000000000000081525060200191505060405180910390fd5b61519a6001600b546195f490919063ffffffff16565b600b819055506000600f6000600b54815260200190815260200160002090508073239dd6e82d77d5ed0600e42f1427c3fc53eaf9cb633053123f90918e8e8e8e8e8e8e8e33346040518c63ffffffff1660e01b8152600401808c8152602001806020018060200180602001806020018773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200186815260200185810385528f8f82818152602001925060200280828437600081840152601f19601f82011690508083019250505085810384528d8d82818152602001925060200280828437600081840152601f19601f82011690508083019250505085810383528b8b82818152602001925080828437600081840152601f19601f8201169050808301925050508581038252898982818152602001925060200280828437600081840152601f19601f8201169050808301925050509f5050505050505050505050505050505060006040518083038186803b15801561531f57600080fd5b505af4158015615333573d6000803e3d6000fd5b5050505061538e84848080601f016020809104026020016040519081016040528093929190818152602001838380828437600081840152601f19601f8201169050808301925050505050505082619f0f90919063ffffffff16565b601273411b40a81a07fcd3542ce5b3d7e215178c4ca2ef63d7a8acc19091600b546040518363ffffffff1660e01b8152600401808381526020018281526020019250505060006040518083038186803b1580156153ea57600080fd5b505af41580156153fe573d6000803e3d6000fd5b505050503373ffffffffffffffffffffffffffffffffffffffff16600b547f1bfe527f3548d9258c2512b6689f0acfccdd0557d80a53845db25fc57e93d8fe8360060180549050344260405180848152602001838152602001828152602001935050505060405180910390a3600b549150509a9950505050505050505050565b615486615fdb565b6154f8576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260208152602001807f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657281525060200191505060405180910390fd5b6000811161556e576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601e8152602001807f4475726174696f6e206d757374206265206c6172676572207468616e2030000081525060200191505060405180910390fd5b6003600201548114156155e9576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260128152602001807f4475726174696f6e20756e6368616e676564000000000000000000000000000081525060200191505060405180910390fd5b806003600201819055507f7819c8059302d1d66abc7fe228ecc02214e0bc5c529956c13717aabefce937d8816040518082815260200191505060405180910390a150565b60006060600060f673ffffffffffffffffffffffffffffffffffffffff16846040516020018082805190602001908083835b60208310615682578051825260208201915060208101905060208303925061565f565b6001836020036101000a0380198251168184511680821785525050505050509050019150506040516020818303038152906040526040518082805190602001908083835b602083106156e957805182526020820191506020810190506020830392506156c6565b6001836020036101000a038019825116818451168082178552505050505050905001915050600060405180830381855afa9150503d8060008114615749576040519150601f19603f3d011682016040523d82523d6000602084013e61574e565b606091505b508093508192505050806157ad576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252602381526020018061bfdb6023913960400191505060405180910390fd5b6157b882600061983e565b92505050919050565b6060601780548060200260200160405190810160405280929190818152602001828054801561580f57602002820191906000526020600020905b8154815260200190600101908083116157fb575b5050505050905090565b600080600f6000848152602001908152602001600020905061584e81615849600384619dad90919063ffffffff16565b619e6a565b915050919050565b61585e615fdb565b6158d0576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260208152602001807f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657281525060200191505060405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff166000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a360008060006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550565b600061599a43618b4e565b905090565b60075481565b60006159c2600f6000848152602001908152602001600020619ef4565b9050919050565b600260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b6159f7615fdb565b615a69576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260208152602001807f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657281525060200191505060405180910390fd5b60008111615ac2576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252602681526020018061be2b6026913960400191505060405180910390fd5b600754811415615b3a576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601a8152602001807f646571756575654672657175656e637920756e6368616e67656400000000000081525060200191505060405180910390fd5b806007819055507f391e82aae76c653cd640ad1b6028e2ee39ca4f29b30152e3d0a9ddd7e1169c34816040518082815260200191505060405180910390a150565b600080600090506000615b8c615cd1565b90506000615b98619bb7565b905060008090505b82811015615cc5576000615bb382612bf5565b905060008373ffffffffffffffffffffffffffffffffffffffff166393c5c487836040518263ffffffff1660e01b8152600401808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060206040518083038186803b158015615c3457600080fd5b505afa158015615c48573d6000803e3d6000fd5b505050506040513d6020811015615c5e57600080fd5b81019080805190602001909291905050509050615c7b8883613de3565b80615c8c5750615c8b8882613de3565b5b15615ca857615ca56001876195f490919063ffffffff16565b95505b5050615cbe6001826195f490919063ffffffff16565b9050615ba0565b50829350505050919050565b60006060600060f973ffffffffffffffffffffffffffffffffffffffff1643604051602001808281526020019150506040516020818303038152906040526040518082805190602001908083835b60208310615d425780518252602082019150602081019050602083039250615d1f565b6001836020036101000a038019825116818451168082178552505050505050905001915050600060405180830381855afa9150503d8060008114615da2576040519150601f19603f3d011682016040523d82523d6000602084013e615da7565b606091505b50809350819250505080615e06576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252603581526020018061bd926035913960400191505060405180910390fd5b615e11826000619313565b9250505090565b60006060600060f773ffffffffffffffffffffffffffffffffffffffff16846040516020018082805190602001908083835b60208310615e6d5780518252602082019150602081019050602083039250615e4a565b6001836020036101000a0380198251168184511680821785525050505050509050019150506040516020818303038152906040526040518082805190602001908083835b60208310615ed45780518252602082019150602081019050602083039250615eb1565b6001836020036101000a038019825116818451168082178552505050505050905001915050600060405180830381855afa9150503d8060008114615f34576040519150601f19603f3d011682016040523d82523d6000602084013e615f39565b606091505b50809350819250505080615f98576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252603181526020018061bf7f6031913960400191505060405180910390fd5b615fa3826000619313565b92505050919050565b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905090565b60065481565b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1661601d619f87565b73ffffffffffffffffffffffffffffffffffffffff1614905090565b616041615fdb565b6160b3576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260208152602001807f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657281525060200191505060405180910390fd5b60008111616129576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260208152602001807f6d696e4465706f736974206d757374206265206c6172676572207468616e203081525060200191505060405180910390fd5b600c548114156161a1576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260198152602001807f4d696e696d756d206465706f73697420756e6368616e6765640000000000000081525060200191505060405180910390fd5b80600c819055507fc50a7f0bdf88c216b2541b0bdea26f22305460e39ffc672ec1a7501732c5ba81816040518082815260200191505060405180910390a150565b600060018060008282540192505081905550600060015490506000616205619bb7565b73ffffffffffffffffffffffffffffffffffffffff16636642d594336040518263ffffffff1660e01b8152600401808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060206040518083038186803b15801561628157600080fd5b505afa158015616295573d6000803e3d6000fd5b505050506040513d60208110156162ab57600080fd5b810190808051906020019092919050505090506000601060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020905060008090505b6017805490508110156165db57600082600301600083815260200190815260200160002090506000600381111561633a57fe5b8160000160009054906101000a900460ff16600381111561635757fe5b1415801561637f57506017828154811061636d57fe5b90600052602060002001548160010154145b156165bf576000806163958360010154856198df565b91509150600360058111156163a657fe5b8160058111156163b257fe5b1415616580578173239dd6e82d77d5ed0600e42f1427c3fc53eaf9cb63b05cd27f9091856002015460008760000160009054906101000a900460ff1660006040518663ffffffff1660e01b81526004018086815260200185815260200184815260200183600381111561642157fe5b60ff16815260200182600381111561643557fe5b60ff1681526020019550505050505060006040518083038186803b15801561645c57600080fd5b505af4158015616470573d6000803e3d6000fd5b5050505061647c619cb2565b73ffffffffffffffffffffffffffffffffffffffff166330a61d596040518163ffffffff1660e01b815260040160206040518083038186803b1580156164c157600080fd5b505afa1580156164d5573d6000803e3d6000fd5b505050506040513d60208110156164eb57600080fd5b810190808051906020019092919050505082600801819055508573ffffffffffffffffffffffffffffffffffffffff1683600101547fb59283e3d5436f05576bddef72ddbfb6344c216ed6ea6d7ced2e9bbb94c661ab8560000160009054906101000a900460ff16600381111561655e57fe5b8660020154604051808381526020018281526020019250505060405180910390a35b846003016000858152602001908152602001600020600080820160006101000a81549060ff021916905560018201600090556002820160009055505050505b506165d46001826195f490919063ffffffff16565b9050616307565b50600081600201819055506001935050506001548114616663576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252600e8152602001807f7265656e7472616e742063616c6c00000000000000000000000000000000000081525060200191505060405180910390fd5b5090565b600061667b6166768484619f8f565b61a1e1565b905092915050565b600061668e82617ea5565b616700576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260138152602001807f50726f706f73616c206e6f74207175657565640000000000000000000000000081525060200191505060405180910390fd5b601273411b40a81a07fcd3542ce5b3d7e215178c4ca2ef63757775999091846040518363ffffffff1660e01b8152600401808381526020018281526020019250505060206040518083038186803b15801561675a57600080fd5b505af415801561676e573d6000803e3d6000fd5b505050506040513d602081101561678457600080fd5b81019080805190602001909291905050509050919050565b6167a4615fdb565b616816576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260208152602001807f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657281525060200191505060405180910390fd5b6000811161688c576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601e8152602001807f4475726174696f6e206d757374206265206c6172676572207468616e2030000081525060200191505060405180910390fd5b600360000154811415616907576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260128152602001807f4475726174696f6e20756e6368616e676564000000000000000000000000000081525060200191505060405180910390fd5b806003600001819055507fbc44c003a66b841b48c220869efb738b265af305649ac8bafe8efe0c8130e313816040518082815260200191505060405180910390a150565b6000616956436135cb565b905090565b60006060600060f973ffffffffffffffffffffffffffffffffffffffff1684604051602001808281526020019150506040516020818303038152906040526040518082805190602001908083835b602083106169cc57805182526020820191506020810190506020830392506169a9565b6001836020036101000a038019825116818451168082178552505050505050905001915050600060405180830381855afa9150503d8060008114616a2c576040519150601f19603f3d011682016040523d82523d6000602084013e616a31565b606091505b50809350819250505080616a90576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252602e81526020018061baf8602e913960400191505060405180910390fd5b616a9b826000619313565b92505050919050565b806011600082815260200190815260200160002060000160009054906101000a900460ff1615616b3c576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260178152602001807f686f7466697820616c726561647920657865637574656400000000000000000081525060200191505060405180910390fd5b616b45826135af565b616b9a576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252602981526020018061be726029913960400191505060405180910390fd5b6000616ba461694b565b905080601160008581526020019081526020016000206001015410616c14576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252602681526020018061bee46026913960400191505060405180910390fd5b80601160008581526020019081526020016000206001018190555080837f6f184ec313435b3307a4fe59e2293381f08419a87214464c875a2a247e8af5e060405160405180910390a3505050565b616c6a615fdb565b616cdc576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260208152602001807f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657281525060200191505060405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff161415616d7f576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260208152602001807f43616e6e6f7420726567697374657220746865206e756c6c206164647265737381525060200191505060405180910390fd5b80600260006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055508073ffffffffffffffffffffffffffffffffffffffff167f27fe5f0c1c3b1ed427cc63d0f05759ffdecf9aec9e18d31ef366fc8a6cb5dc3b60405160405180910390a250565b60188181548110616e1357fe5b906000526020600020016000915090505481565b6000600360010154905090565b60178181548110616e4157fe5b906000526020600020016000915090505481565b60006001806000828254019250508190555060006001549050616e766135e5565b6000616e80619bb7565b73ffffffffffffffffffffffffffffffffffffffff16636642d594336040518263ffffffff1660e01b8152600401808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060206040518083038186803b158015616efc57600080fd5b505afa158015616f10573d6000803e3d6000fd5b505050506040513d6020811015616f2657600080fd5b810190808051906020019092919050505090506000601060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002090506000816000016000015490506000811415616fff576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260208152602001807f4163636f756e7420686173206e6f20686973746f726963616c207570766f746581525060200191505060405180910390fd5b61700881619ae4565b50601273411b40a81a07fcd3542ce5b3d7e215178c4ca2ef63bfc516389091836040518363ffffffff1660e01b8152600401808381526020018281526020019250505060206040518083038186803b15801561706357600080fd5b505af4158015617077573d6000803e3d6000fd5b505050506040513d602081101561708d57600080fd5b81019080805190602001909291905050501561723157601273411b40a81a07fcd3542ce5b3d7e215178c4ca2ef63239491ba9091836171708660000160010154601273411b40a81a07fcd3542ce5b3d7e215178c4ca2ef63757775999091896040518363ffffffff1660e01b8152600401808381526020018281526020019250505060206040518083038186803b15801561712757600080fd5b505af415801561713b573d6000803e3d6000fd5b505050506040513d602081101561715157600080fd5b81019080805190602001909291905050506196ba90919063ffffffff16565b8b8b6040518663ffffffff1660e01b8152600401808681526020018581526020018481526020018381526020018281526020019550505050505060006040518083038186803b1580156171c257600080fd5b505af41580156171d6573d6000803e3d6000fd5b505050508273ffffffffffffffffffffffffffffffffffffffff16817f7dc46237a819c9171a9c037ec98928e563892905c4d23373ca0f3f500f4ed11484600001600101546040518082815260200191505060405180910390a35b60405180604001604052806000815260200160008152508260000160008201518160000155602082015181600101559050506001945050505060015481146172e1576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252600e8152602001807f7265656e7472616e742063616c6c00000000000000000000000000000000000081525060200191505060405180910390fd5b5092915050565b806011600082815260200190815260200160002060000160009054906101000a900460ff1615617380576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260178152602001807f686f7466697820616c726561647920657865637574656400000000000000000081525060200191505060405180910390fd5b600860009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614617443576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260178152602001807f6d73672e73656e646572206e6f7420617070726f76657200000000000000000081525060200191505060405180910390fd5b60016011600084815260200190815260200160002060000160016101000a81548160ff021916908315150217905550817f36bc158cba244a94dc9b8c08d327e8f7e3c2ab5f1925454c577527466f04851f60405160405180910390a25050565b806011600082815260200190815260200160002060000160009054906101000a900460ff161561753b576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260178152602001807f686f7466697820616c726561647920657865637574656400000000000000000081525060200191505060405180910390fd5b60016011600084815260200190815260200160002060020160003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff021916908315150217905550817ff6d22d0b43a6753880b8f9511b82b86cd0fe349cd580bbe6a25b6dc063ef496f33604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390a25050565b6000601260000160020154905090565b600060018060008282540192505081905550600060015490506176406135e5565b60008061764d87876198df565b9150915061765a8261932a565b61766957600093505050617cca565b6000617673619bb7565b73ffffffffffffffffffffffffffffffffffffffff16636642d594336040518263ffffffff1660e01b8152600401808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060206040518083038186803b1580156176ef57600080fd5b505afa158015617703573d6000803e3d6000fd5b505050506040513d602081101561771957600080fd5b810190808051906020019092919050505090506000601060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002090506000617779619cb2565b73ffffffffffffffffffffffffffffffffffffffff166330ec70f5846040518263ffffffff1660e01b8152600401808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060206040518083038186803b1580156177f557600080fd5b505afa158015617809573d6000803e3d6000fd5b505050506040513d602081101561781f57600080fd5b8101908080519060200190929190505050905061783b85619ef4565b6178ad576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260158152602001807f50726f706f73616c206e6f7420617070726f766564000000000000000000000081525060200191505060405180910390fd5b600360058111156178ba57fe5b8460058111156178c657fe5b14617939576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260188152602001807f496e636f72726563742070726f706f73616c207374617465000000000000000081525060200191505060405180910390fd5b6000600381111561794657fe5b88600381111561795257fe5b14156179c6576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260108152602001807f566f74652076616c756520756e7365740000000000000000000000000000000081525060200191505060405180910390fd5b60008111617a3c576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260118152602001807f566f74657220776569676874207a65726f00000000000000000000000000000081525060200191505060405180910390fd5b60008260030160008b815260200190815260200160002090508573239dd6e82d77d5ed0600e42f1427c3fc53eaf9cb63b05cd27f90918360020154858f866001015414617a8a576000617a9d565b8560000160009054906101000a900460ff165b8e6040518663ffffffff1660e01b815260040180868152602001858152602001848152602001836003811115617acf57fe5b60ff168152602001826003811115617ae357fe5b60ff1681526020019550505050505060006040518083038186803b158015617b0a57600080fd5b505af4158015617b1e573d6000803e3d6000fd5b50505050617b2a619cb2565b73ffffffffffffffffffffffffffffffffffffffff166330a61d596040518163ffffffff1660e01b815260040160206040518083038186803b158015617b6f57600080fd5b505afa158015617b83573d6000803e3d6000fd5b505050506040513d6020811015617b9957600080fd5b8101908080519060200190929190505050866008018190555060405180606001604052808a6003811115617bc957fe5b81526020018c8152602001838152508360030160008c815260200190815260200160002060008201518160000160006101000a81548160ff02191690836003811115617c1157fe5b02179055506020820151816001015560408201518160020155905050600f6000846002015481526020019081526020016000206002015486600201541115617c5d578a83600201819055505b8373ffffffffffffffffffffffffffffffffffffffff168b7ff3709dc32cf1356da6b8a12a5be1401aeb00989556be7b16ae566e65fef7a9df8b6003811115617ca257fe5b85604051808381526020018281526020019250505060405180910390a3600197505050505050505b6001548114617d41576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252600e8152602001807f7265656e7472616e742063616c6c00000000000000000000000000000000000081525060200191505060405180910390fd5b509392505050565b60095481565b6000617d6c600f6000848152602001908152602001600020619695565b9050919050565b600060149054906101000a900460ff1615617df6576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601c8152602001807f636f6e747261637420616c726561647920696e697469616c697a65640000000081525060200191505060405180910390fd5b6001600060146101000a81548160ff021916908315150217905550617e1a3361a1ef565b617e238d616c62565b617e2c8c613347565b617e358b6180b1565b617e3e8a616039565b617e47896131ae565b617e50886159ef565b617e598761679c565b617e62866182bf565b617e6b8561547e565b617e7484613c0b565b617e7d83612dca565b617e868261496f565b617e8f8161298e565b4260098190555050505050505050505050505050565b6000601273411b40a81a07fcd3542ce5b3d7e215178c4ca2ef63bfc516389091846040518363ffffffff1660e01b8152600401808381526020018281526020019250505060206040518083038186803b158015617f0157600080fd5b505af4158015617f15573d6000803e3d6000fd5b505050506040513d6020811015617f2b57600080fd5b81019080805190602001909291905050509050919050565b6000806000806060617f66600f600088815260200190815260200160002061a333565b808054600181600116156101000203166002900480601f016020809104026020016040519081016040528092919081815260200182805460018160011615610100020316600290048015617ffb5780601f10617fd057610100808354040283529160200191617ffb565b820191906000526020600020905b815481529060010190602001808311617fde57829003601f168201915b505050505090509450945094509450945091939590929450565b60008060008061803d601960000160405180602001604052908160008201548152505061a1e1565b61805f601960010160405180602001604052908160008201548152505061a1e1565b618081601960020160405180602001604052908160008201548152505061a1e1565b6180a3601960030160405180602001604052908160008201548152505061a1e1565b935093509350935090919293565b6180b9615fdb565b61812b576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260208152602001807f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657281525060200191505060405180910390fd5b60008111618184576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252602c81526020018061bb4d602c913960400191505060405180910390fd5b600a548114156181fc576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601d8152602001807f4e756d626572206f662070726f706f73616c7320756e6368616e67656400000081525060200191505060405180910390fd5b80600a819055507f85399b9b2595eb13c392e1638ca77730156cd8d48d4733df4db068e4aa6b93a6816040518082815260200191505060405180910390a150565b60008061824861b824565b601060008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600001604051806040016040529081600082015481526020016001820154815250509050806000015181602001519250925050915091565b6182c7615fdb565b618339576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260208152602001807f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657281525060200191505060405180910390fd5b600081116183af576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601e8152602001807f4475726174696f6e206d757374206265206c6172676572207468616e2030000081525060200191505060405180910390fd5b60036001015481141561842a576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260128152602001807f4475726174696f6e20756e6368616e676564000000000000000000000000000081525060200191505060405180910390fd5b806003600101819055507f90290eb9b27055e686a69fb810bada5381e544d07b8270021da2d355a6c96ed6816040518082815260200191505060405180910390a150565b6000898989898989898989604051602001808060200180602001806020018060200186815260200185810385528e8e82818152602001925060200280828437600081840152601f19601f82011690508083019250505085810384528c8c82818152602001925060200280828437600081840152601f19601f82011690508083019250505085810383528a8a82818152602001925080828437600081840152601f19601f8201169050808301925050508581038252888882818152602001925060200280828437600081840152601f19601f8201169050808301925050509d5050505050505050505050505050604051602081830303815290604052805190602001209050600080600061858084612b66565b92509250925081156185fa576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260178152602001807f686f7466697820616c726561647920657865637574656400000000000000000081525060200191505060405180910390fd5b8261866d576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260138152602001807f686f74666978206e6f7420617070726f7665640000000000000000000000000081525060200191505060405180910390fd5b61867561694b565b81146186cc576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252602681526020018061bab16026913960400191505060405180910390fd5b6187ea6187e58e8e80806020026020016040519081016040528093929190818152602001838360200280828437600081840152601f19601f820116905080830192505050505050508d8d80806020026020016040519081016040528093929190818152602001838360200280828437600081840152601f19601f820116905080830192505050505050508c8c8080601f016020809104026020016040519081016040528093929190818152602001838380828437600081840152601f19601f820116905080830192505050505050508b8b80806020026020016040519081016040528093929190818152602001838360200280828437600081840152601f19601f8201169050808301925050505050505033600061a38c565b61a5b5565b60016011600086815260200190815260200160002060000160006101000a81548160ff021916908315150217905550837f708a7934acb657a77a617b1fcd5f6d7d9ad592b72934841bff01acefd10f9b6360405160405180910390a250505050505050505050505050565b6000806060600f600086815260200190815260200160002073239dd6e82d77d5ed0600e42f1427c3fc53eaf9cb63e6a5192f9091866040518363ffffffff1660e01b8152600401808381526020018281526020019250505060006040518083038186803b1580156188c557600080fd5b505af41580156188d9573d6000803e3d6000fd5b505050506040513d6000823e3d601f19601f82011682018060405250606081101561890357600080fd5b8101908080519060200190929190805190602001909291908051604051939291908464010000000082111561893757600080fd5b8382019150602082018581111561894d57600080fd5b825186600182028301116401000000008211171561896a57600080fd5b8083526020830192505050908051906020019080838360005b8381101561899e578082015181840152602081019050618983565b50505050905090810190601f1680156189cb5780820380516001836020036101000a031916815260200191505b506040525050509250925092509250925092565b600b5481565b60006060600060f873ffffffffffffffffffffffffffffffffffffffff166040516020016040516020818303038152906040526040518082805190602001908083835b60208310618a4b5780518252602082019150602081019050602083039250618a28565b6001836020036101000a038019825116818451168082178552505050505050905001915050600060405180830381855afa9150503d8060008114618aab576040519150601f19603f3d011682016040523d82523d6000602084013e618ab0565b606091505b50809350819250505080618b0f576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252602581526020018061bf0a6025913960400191505060405180910390fd5b618b1a826000619313565b9250505090565b6000806000618b41600f600086815260200190815260200160002061a5c5565b9250925092509193909250565b6000618b926003618b846002618b766002618b688861695b565b61a5ef90919063ffffffff16565b6195f490919063ffffffff16565b61a67590919063ffffffff16565b9050919050565b60008060008714158015618bae575060008514155b618c20576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260158152602001807f612064656e6f6d696e61746f72206973207a65726f000000000000000000000081525060200191505060405180910390fd5b6000806000606060fc73ffffffffffffffffffffffffffffffffffffffff168c8c8c8c8c8c6040516020018087815260200186815260200185815260200184815260200183815260200182815260200196505050505050506040516020818303038152906040526040518082805190602001908083835b60208310618cba5780518252602082019150602081019050602083039250618c97565b6001836020036101000a038019825116818451168082178552505050505050905001915050600060405180830381855afa9150503d8060008114618d1a576040519150601f19603f3d011682016040523d82523d6000602084013e618d1f565b606091505b50809250819350505081618d7e576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252602781526020018061bebd6027913960400191505060405180910390fd5b618d89816000619313565b9350618d96816020619313565b925083839550955050505050965096945050505050565b618db5615fdb565b618e27576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260208152602001807f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657281525060200191505060405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff161415618eca576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601a8152602001807f44657374696e6174696f6e2063616e6e6f74206265207a65726f00000000000081525060200191505060405180910390fd5b6969e10de76676d080000081118015618ef25750618eee618ee961a6bf565b61a1e1565b8111155b618f47576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252604881526020018061bbef6048913960600191505060405180910390fd5b600060e01b827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19161415618fcf57618f7b816192c6565b600e60008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060000160008201518160000155905050619077565b618fd8816192c6565b600e60008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206001016000847bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19167bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19168152602001908152602001600020600082015181600001559050505b817bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19168373ffffffffffffffffffffffffffffffffffffffff167f60c5b4756af49d7b071b00dbf0f87af605cce11896ecd3b760d19f0f9d3fbcef836040518082815260200191505060405180910390a3505050565b6190f2615fdb565b619164576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260208152602001807f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657281525060200191505060405180910390fd5b61916d8161a1ef565b50565b60006060600060f573ffffffffffffffffffffffffffffffffffffffff1684604051602001808281526020019150506040516020818303038152906040526040518082805190602001908083835b602083106191e157805182526020820191506020810190506020830392506191be565b6001836020036101000a038019825116818451168082178552505050505050905001915050600060405180830381855afa9150503d8060008114619241576040519150601f19603f3d011682016040523d82523d6000602084013e619246565b606091505b508093508192505050806192a5576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252602c81526020018061bf53602c913960400191505060405180910390fd5b6192b082600061983e565b92505050919050565b6000600360000154905090565b6192ce61b7e5565b6040518060200160405280838152509050919050565b60006192f7826192f261a6bf565b61a6e5565b9050919050565b60008160000151836000015114905092915050565b600061931f838361983e565b60001c905092915050565b6000808260020154119050919050565b60006017805490508210619399576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252602b81526020018061bffe602b913960400191505060405180910390fd5b6193a28461932a565b80156193c4575082601783815481106193b757fe5b9060005260206000200154145b90509392505050565b60006193d761b7e5565b61942e61941f6019600301604051806020016040529081600082015481525050601960000160405180602001604052908160008201548152505061a6fb90919063ffffffff16565b8461ab5a90919063ffffffff16565b905060008090505b83600601805490508110156195a057600061950885600601838154811061945957fe5b90600052602060002090600302016002018054600181600116156101000203166002900480601f0160208091040260200160405190810160405280929190818152602001828054600181600116156101000203166002900480156194fe5780601f106194d3576101008083540402835291602001916194fe565b820191906000526020600020905b8154815290600101906020018083116194e157829003601f168201915b505050505061ac49565b905061951261b7e5565b61955c86600601848154811061952457fe5b906000526020600020906003020160010160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1683619f8f565b9050619571818561a6e590919063ffffffff16565b156195835760009450505050506195a7565b50506195996001826195f490919063ffffffff16565b9050619436565b5060019150505b919050565b6000808284816195b857fe5b04905060008385816195c657fe5b0614156195d657809150506195ee565b6195ea6001826195f490919063ffffffff16565b9150505b92915050565b600080828401905083811015619672576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601b8152602001807f536166654d6174683a206164646974696f6e206f766572666c6f77000000000081525060200191505060405180910390fd5b8091505092915050565b600081831061968b578161968d565b825b905092915050565b60006196b060065483600201546195f490919063ffffffff16565b4210159050919050565b60006196fc83836040518060400160405280601e81526020017f536166654d6174683a207375627472616374696f6e206f766572666c6f77000081525061ada6565b905092915050565b8047101561977a576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601d8152602001807f416464726573733a20696e73756666696369656e742062616c616e636500000081525060200191505060405180910390fd5b60008273ffffffffffffffffffffffffffffffffffffffff168260405180600001905060006040518083038185875af1925050503d80600081146197da576040519150601f19603f3d011682016040523d82523d6000602084013e6197df565b606091505b5050905080619839576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252603a81526020018061bc5d603a913960400191505060405180910390fd5b505050565b60006198546020836195f490919063ffffffff16565b835110156198ca576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260148152602001807f736c6963696e67206f7574206f662072616e676500000000000000000000000081525060200191505060405180910390fd5b60006020830184015190508091505092915050565b6000806000600f6000868152602001908152602001600020905061990481868661933a565b619976576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260158152602001807f50726f706f73616c206e6f74206465717565756564000000000000000000000081525060200191505060405180910390fd5b600061998c600383619dad90919063ffffffff16565b90506199988282619e6a565b156199b6576199a88287876199c6565b8160059350935050506199bf565b81819350935050505b9250929050565b6199cf83619ef4565b80156199df575060008360080154115b156199ee576199ed8361ae66565b5b6000601782815481106199fd57fe5b90600052602060002001819055506018819080600181540180825580915050906001820390600052602060002001600090919290919091505550600f6000838152602001908152602001600020600080820160006101000a81549073ffffffffffffffffffffffffffffffffffffffff02191690556001820160009055600282016000905560038201600080820160009055600182016000905560028201600090555050600682016000619ab1919061b83e565b6007820160006101000a81549060ff02191690556008820160009055600982016000619add919061b862565b5050505050565b6000619aef82617ea5565b8015619b005750619aff82617d4f565b5b15619bad57601273411b40a81a07fcd3542ce5b3d7e215178c4ca2ef63eed5f7be9091846040518363ffffffff1660e01b8152600401808381526020018281526020019250505060006040518083038186803b158015619b5f57600080fd5b505af4158015619b73573d6000803e3d6000fd5b50505050817f88e53c486703527139dfc8d97a1e559d9bd93d3f9d52cda4e06564111e7a264360405160405180910390a260019050619bb2565b600090505b919050565b6000600260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663dcf0aaed60405160200180807f4163636f756e74730000000000000000000000000000000000000000000000008152506008019050604051602081830303815290604052805190602001206040518263ffffffff1660e01b81526004018082815260200191505060206040518083038186803b158015619c7257600080fd5b505afa158015619c86573d6000803e3d6000fd5b505050506040513d6020811015619c9c57600080fd5b8101908080519060200190929190505050905090565b6000600260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663dcf0aaed60405160200180807f4c6f636b6564476f6c6400000000000000000000000000000000000000000000815250600a019050604051602081830303815290604052805190602001206040518263ffffffff1660e01b81526004018082815260200191505060206040518083038186803b158015619d6d57600080fd5b505afa158015619d81573d6000803e3d6000fd5b505050506040513d6020811015619d9757600080fd5b8101908080519060200190929190505050905090565b600080619df78360020154619de98560010154619ddb876000015489600201546195f490919063ffffffff16565b6195f490919063ffffffff16565b6195f490919063ffffffff16565b9050804210619e0a576005915050619e64565b619e218360020154826196ba90919063ffffffff16565b9050804210619e34576004915050619e64565b619e4b8360010154826196ba90919063ffffffff16565b9050804210619e5e576003915050619e64565b60029150505b92915050565b600060046005811115619e7957fe5b826005811115619e8557fe5b1180619eb9575060036005811115619e9957fe5b826005811115619ea557fe5b118015619eb85750619eb6836193cd565b155b5b80619eec575060026005811115619ecc57fe5b826005811115619ed857fe5b118015619eeb5750619ee983619ef4565b155b5b905092915050565b60008160070160009054906101000a900460ff169050919050565b600081511415619f6a576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252602981526020018061bb9f6029913960400191505060405180910390fd5b80826009019080519060200190619f8292919061b8aa565b505050565b600033905090565b619f9761b7e5565b619f9f61b7e5565b619fb26969e10de76676d08000006192c6565b9050600061a064600e60008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206001016000867bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19167bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916815260200190815260200160002060405180602001604052908160008201548152505061a1e1565b1461a11657600e60008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206001016000847bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19167bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19168152602001908152602001600020604051806020016040529081600082015481525050905061a1d7565b600061a177600e60008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060000160405180602001604052908160008201548152505061a1e1565b1461a1d657600e60008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060000160405180602001604052908160008201548152505090505b5b8091505092915050565b600081600001519050919050565b600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff16141561a275576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252602681526020018061bb796026913960400191505060405180910390fd5b8073ffffffffffffffffffffffffffffffffffffffff166000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a3806000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050565b60008060008060008560000160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16866001015487600201548860060180549050896009018090509450945094509450945091939590929450565b61a39461b92a565b8551875114801561a3a6575083518651145b61a418576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260158152602001807f4172726179206c656e677468206d69736d61746368000000000000000000000081525060200191505060405180910390fd5b60008751905061a42661b92a565b84816000019073ffffffffffffffffffffffffffffffffffffffff16908173ffffffffffffffffffffffffffffffffffffffff1681525050838160200181815250504281604001818152505060008090508260405190808252806020026020018201604052801561a4b157816020015b61a49e61b98d565b81526020019060019003908161a4965790505b50826080018190525060008090505b8381101561a5a45760405180606001604052808c838151811061a4df57fe5b602002602001015181526020018b838151811061a4f857fe5b602002602001015173ffffffffffffffffffffffffffffffffffffffff16815260200161a543848b858151811061a52b57fe5b60200260200101518d61affc9092919063ffffffff16565b8152508360800151828151811061a55657fe5b602002602001018190525061a58788828151811061a57057fe5b6020026020010151836195f490919063ffffffff16565b915061a59d6001826195f490919063ffffffff16565b905061a4c0565b508193505050509695505050505050565b61a5c2816080015161b088565b50565b60008060008360030160000154846003016001015485600301600201549250925092509193909250565b60008083141561a602576000905061a66f565b600082840290508284828161a61357fe5b041461a66a576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252602181526020018061be516021913960400191505060405180910390fd5b809150505b92915050565b600061a6b783836040518060400160405280601a81526020017f536166654d6174683a206469766973696f6e206279207a65726f00000000000081525061b191565b905092915050565b61a6c761b7e5565b604051806020016040528069d3c21bcecceda1000000815250905090565b6000816000015183600001511115905092915050565b61a70361b7e5565b60008360000151148061a71a575060008260000151145b1561a7365760405180602001604052806000815250905061ab54565b69d3c21bcecceda10000008260000151141561a7545782905061ab54565b69d3c21bcecceda10000008360000151141561a7725781905061ab54565b600069d3c21bcecceda100000061a7888561b257565b600001518161a79357fe5b049050600061a7a18561b28e565b600001519050600069d3c21bcecceda100000061a7bd8661b257565b600001518161a7c857fe5b049050600061a7d68661b28e565b600001519050600082850290506000851461a86a578285828161a7f557fe5b041461a869576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260168152602001807f6f766572666c6f7720783179312064657465637465640000000000000000000081525060200191505060405180910390fd5b5b600069d3c21bcecceda1000000820290506000821461a90c5769d3c21bcecceda100000082828161a89757fe5b041461a90b576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601f8152602001807f6f766572666c6f772078317931202a206669786564312064657465637465640081525060200191505060405180910390fd5b5b809150600084860290506000861461a99d578486828161a92857fe5b041461a99c576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260168152602001807f6f766572666c6f7720783279312064657465637465640000000000000000000081525060200191505060405180910390fd5b5b600084880290506000881461aa2b578488828161a9b657fe5b041461aa2a576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260168152602001807f6f766572666c6f7720783179322064657465637465640000000000000000000081525060200191505060405180910390fd5b5b61aa3361b2cb565b878161aa3b57fe5b04965061aa4661b2cb565b858161aa4e57fe5b049450600085880290506000881461aadf578588828161aa6a57fe5b041461aade576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260168152602001807f6f766572666c6f7720783279322064657465637465640000000000000000000081525060200191505060405180910390fd5b5b61aae761b7e5565b604051806020016040528087815250905061ab108160405180602001604052808781525061b2d8565b905061ab2a8160405180602001604052808681525061b2d8565b905061ab448160405180602001604052808581525061b2d8565b9050809a50505050505050505050505b92915050565b61ab6261b7e5565b600083600301600001549050600081141561ab895761ab81600061b381565b91505061ac43565b600084600301600101549050600061abc3866003016002015461abb584866195f490919063ffffffff16565b6195f490919063ffffffff16565b9050600061abee61abe961abda896008015461b381565b8861a6fb90919063ffffffff16565b61b40b565b90508181111561ac205761ac1d61ac0e83836196ba90919063ffffffff16565b846195f490919063ffffffff16565b92505b61ac3c8461ac3785876195f490919063ffffffff16565b61b42c565b9450505050505b92915050565b600060188260038151811061ac5a57fe5b602001015160f81c60f81b7effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff19167bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916901c60108360028151811061acb757fe5b602001015160f81c60f81b7effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff19167bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916901c60088460018151811061ad1457fe5b602001015160f81c60f81b7effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff19167bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916901c8460008151811061ad6f57fe5b602001015160f81c60f81b7effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff19161717179050919050565b600083831115829061ae53576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825283818151815260200191508051906020019080838360005b8381101561ae1857808201518184015260208101905061adfd565b50505050905090810190601f16801561ae455780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b5060008385039050809150509392505050565b61ae6e61b7e5565b61ae778261b46e565b905061ae8161b7e5565b61aead60196002016040518060200160405290816000820154815250508361a6fb90919063ffffffff16565b905061aeb761b7e5565b61af1561aeed601960020160405180602001604052908160008201548152505061aedf61a6bf565b61b4ca90919063ffffffff16565b601960000160405180602001604052908160008201548152505061a6fb90919063ffffffff16565b905061af2a818361b2d890919063ffffffff16565b60196000016000820151816000015590505061af816019600101604051806020016040529081600082015481525050601960000160405180602001604052908160008201548152505061b57190919063ffffffff16565b1561af9e5760196001016019600001600082015481600001559050505b7f51131d2820f04a6b6edd20e22a07d5bf847e265a3906e85256fca7d6043417c561afe1601960000160405180602001604052908160008201548152505061a1e1565b6040518082815260200191505060405180910390a150505050565b60608183018451101561b00e57600080fd5b606082156000811461b02b5760405191506020820160405261b07c565b6040519150601f8416801560200281840101858101878315602002848b0101015b8183101561b069578051835260208301925060208101905061b04c565b50868552601f19601f8301166040525050505b50809150509392505050565b60008090505b815181101561b18d5761b10082828151811061b0a657fe5b60200260200101516020015183838151811061b0be57fe5b60200260200101516000015184848151811061b0d657fe5b6020026020010151604001515185858151811061b0ef57fe5b60200260200101516040015161b586565b61b172576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260198152602001807f50726f706f73616c20657865637574696f6e206661696c65640000000000000081525060200191505060405180910390fd5b61b1866001826195f490919063ffffffff16565b905061b08e565b5050565b6000808311829061b23d576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825283818151815260200191508051906020019080838360005b8381101561b20257808201518184015260208101905061b1e7565b50505050905090810190601f16801561b22f5780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b50600083858161b24957fe5b049050809150509392505050565b61b25f61b7e5565b604051806020016040528069d3c21bcecceda10000008085600001518161b28257fe5b04028152509050919050565b61b29661b7e5565b604051806020016040528069d3c21bcecceda10000008085600001518161b2b957fe5b04028460000151038152509050919050565b600064e8d4a51000905090565b61b2e061b7e5565b600082600001518460000151019050836000015181101561b369576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260158152602001807f616464206f766572666c6f77206465746563746564000000000000000000000081525060200191505060405180910390fd5b60405180602001604052808281525091505092915050565b61b38961b7e5565b61b39161b632565b82111561b3e9576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252603681526020018061bcf66036913960400191505060405180910390fd5b604051806020016040528069d3c21bcecceda100000084028152509050919050565b600069d3c21bcecceda100000082600001518161b42457fe5b049050919050565b61b43461b7e5565b61b43c61b7e5565b61b4458461b381565b905061b44f61b7e5565b61b4588461b381565b905061b464828261b651565b9250505092915050565b61b47661b7e5565b600061b4b2836003016002015461b4a4856003016001015486600301600001546195f490919063ffffffff16565b6195f490919063ffffffff16565b905061b4c281846008015461b42c565b915050919050565b61b4d261b7e5565b81600001518360000151101561b550576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601f8152602001807f737562737472616374696f6e20756e646572666c6f772064657465637465640081525060200191505060405180910390fd5b60405180602001604052808360000151856000015103815250905092915050565b60008160000151836000015110905092915050565b600080600084111561b60e5761b59b8661b79a565b61b60d576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260188152602001807f496e76616c696420636f6e74726163742061646472657373000000000000000081525060200191505060405180910390fd5b5b6040516020840160008287838a8c6187965a03f19250505080915050949350505050565b60007601357c299a88ea76a58924d52ce4f26a85af186c2b9e74905090565b61b65961b7e5565b60008260000151141561b6d4576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260118152602001807f63616e277420646976696465206279203000000000000000000000000000000081525060200191505060405180910390fd5b600069d3c21bcecceda10000008460000151029050836000015169d3c21bcecceda1000000828161b70157fe5b041461b775576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260128152602001807f6f766572666c6f7720617420646976696465000000000000000000000000000081525060200191505060405180910390fd5b60405180602001604052808460000151838161b78d57fe5b0481525091505092915050565b60008060007fc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a47060001b9050833f915080821415801561b7dc57506000801b8214155b92505050919050565b6040518060200160405280600081525090565b81548183558181111561b81f5781836000526020600020918201910161b81e919061b9c4565b5b505050565b604051806040016040528060008152602001600081525090565b508054600082556003029060005260206000209081019061b85f919061b9e9565b50565b50805460018160011615610100020316600290046000825580601f1061b888575061b8a7565b601f01602090049060005260206000209081019061b8a6919061b9c4565b5b50565b828054600181600116156101000203166002900490600052602060002090601f016020900481019282601f1061b8eb57805160ff191683800117855561b919565b8280016001018555821561b919579182015b8281111561b91857825182559160200191906001019061b8fd565b5b50905061b926919061b9c4565b5090565b604051806101000160405280600073ffffffffffffffffffffffffffffffffffffffff168152602001600081526020016000815260200161b96961ba47565b81526020016060815260200160001515815260200160008152602001606081525090565b604051806060016040528060008152602001600073ffffffffffffffffffffffffffffffffffffffff168152602001606081525090565b61b9e691905b8082111561b9e257600081600090555060010161b9ca565b5090565b90565b61ba4491905b8082111561ba40576000808201600090556001820160006101000a81549073ffffffffffffffffffffffffffffffffffffffff021916905560028201600061ba37919061ba68565b5060030161b9ef565b5090565b90565b60405180606001604052806000815260200160008152602001600081525090565b50805460018160011615610100020316600290046000825580601f1061ba8e575061baad565b601f01602090049060005260206000209081019061baac919061b9c4565b5b5056fe686f74666978206d75737420626520707265706172656420666f7220746869732065706f63685175657565457870697279206d757374206265206c6172676572207468616e20306572726f722063616c6c696e67206e756d62657256616c696461746f7273496e53657420707265636f6d70696c6550617274696369706174696f6e20626173656c696e652067726561746572207468616e206f6e654e756d626572206f662070726f706f73616c73206d757374206265206c6172676572207468616e207a65726f4f776e61626c653a206e6577206f776e657220697320746865207a65726f20616464726573734465736372697074696f6e2075726c206d7573742068617665206e6f6e2d7a65726f206c656e677468426173656c696e652071756f72756d20666163746f722067726561746572207468616e206f6e655468726573686f6c642068617320746f2062652067726561746572207468616e206d616a6f7269747920616e64206e6f742067726561746572207468616e20756e616e696d69747950617274696369706174696f6e20626173656c696e6520666c6f6f7220756e6368616e676564416464726573733a20756e61626c6520746f2073656e642076616c75652c20726563697069656e74206d61792068617665207265766572746564426173656c696e652075706461746520666163746f722067726561746572207468616e206f6e656572726f722063616c6c696e672067657456657269666965645365616c4269746d617046726f6d48656164657220707265636f6d70696c6563616e277420637265617465206669786964697479206e756d626572206c6172676572207468616e206d61784e65774669786564282963616e6e6f74207570766f746520612070726f706f73616c206e6f7420696e207468652071756575656572726f722063616c6c696e672076616c696461746f725369676e65724164647265737346726f6d43757272656e7453657420707265636f6d70696c656572726f722063616c6c696e67206e756d62657256616c696461746f7273496e43757272656e7453657420707265636f6d70696c656572726f722063616c6c696e672076616c696461746f725369676e65724164647265737346726f6d53657420707265636f6d70696c6550726f706f73616c206e6f7420696e20657865637574696f6e207374616765206f72206e6f742070617373696e67646571756575654672657175656e6379206d757374206265206c6172676572207468616e2030536166654d6174683a206d756c7469706c69636174696f6e206f766572666c6f77686f74666978206e6f742077686974656c69737465642062792032662b312076616c696461746f727363616e6e6f74207570766f746520776974686f7574206c6f636b696e6720676f6c646572726f722063616c6c696e67206672616374696f6e4d756c45787020707265636f6d70696c65686f7466697820616c726561647920707265706172656420666f7220746869732065706f63686572726f722063616c6c696e672067657445706f636853697a6520707265636f6d70696c6550617274696369706174696f6e20666c6f6f722067726561746572207468616e206f6e656572726f722063616c6c696e6720676574506172656e745365616c4269746d617020707265636f6d70696c656572726f722063616c6c696e6720676574426c6f636b4e756d62657246726f6d48656164657220707265636f6d70696c6563616e6e6f74207570766f7465206d6f7265207468616e206f6e65207175657565642070726f706f73616c6572726f722063616c6c696e67206861736848656164657220707265636f6d70696c6550726f766964656420696e6465782067726561746572207468616e2064657175657565206c656e6774682ea265627a7a72315820db2274ff44a6d4be94b439bc918a01c5ca533731619e6ecdbff9b12ce42750bd64736f6c634300050d0032