ETH Price: $3,715.99 (+3.46%)

Contract

0x332B8C9734b4097dE50f302F7D9F273FFdB45B84
 

Overview

ETH Balance

0 ETH

Eth Value

$0.00

Token Holdings

Multichain Info

No addresses found
Transaction Hash
Method
Block
From
To
Vote190544592024-01-21 9:51:59314 days ago1705830719IN
0x332B8C97...FFdB45B84
0 ETH0.002894614.44524067
Vote190425972024-01-19 18:07:35316 days ago1705687655IN
0x332B8C97...FFdB45B84
0 ETH0.0073824733.77393353
Vote185922672023-11-17 14:43:35379 days ago1700232215IN
0x332B8C97...FFdB45B84
0 ETH0.0081608941.1123923
Vote185921962023-11-17 14:29:23379 days ago1700231363IN
0x332B8C97...FFdB45B84
0 ETH0.0061668831.06709486
Vote185916612023-11-17 12:40:59379 days ago1700224859IN
0x332B8C97...FFdB45B84
0 ETH0.0067200330.4646212
Vote185908412023-11-17 9:55:47379 days ago1700214947IN
0x332B8C97...FFdB45B84
0 ETH0.0052566924.04876697
Stake174424862023-06-09 11:50:11540 days ago1686311411IN
0x332B8C97...FFdB45B84
0 ETH0.0038720921.56686602
Stake174424752023-06-09 11:47:59540 days ago1686311279IN
0x332B8C97...FFdB45B84
0 ETH0.0039738118.35267006
Stake174420202023-06-09 10:15:47540 days ago1686305747IN
0x332B8C97...FFdB45B84
0 ETH0.0066201621
Vote170104792023-04-09 11:34:47601 days ago1681040087IN
0x332B8C97...FFdB45B84
0 ETH0.0063014318.88193599
Vote170096282023-04-09 8:40:35601 days ago1681029635IN
0x332B8C97...FFdB45B84
0 ETH0.0031828819.98521387
Vote170096282023-04-09 8:40:35601 days ago1681029635IN
0x332B8C97...FFdB45B84
0 ETH0.0044707319.11822115
Vote170053662023-04-08 18:13:23602 days ago1680977603IN
0x332B8C97...FFdB45B84
0 ETH0.0095610940.8861223
Vote170046182023-04-08 15:39:59602 days ago1680968399IN
0x332B8C97...FFdB45B84
0 ETH0.0050018421.38372571
Vote170040552023-04-08 13:45:11602 days ago1680961511IN
0x332B8C97...FFdB45B84
0 ETH0.0050212721.47247319
Vote170021552023-04-08 7:16:47602 days ago1680938207IN
0x332B8C97...FFdB45B84
0 ETH0.0052133522.45178926
Vote170020542023-04-08 6:55:47602 days ago1680936947IN
0x332B8C97...FFdB45B84
0 ETH0.0049601121.35550815
Redeem Dao Bount...169997592023-04-07 23:09:11603 days ago1680908951IN
0x332B8C97...FFdB45B84
0 ETH0.0010491620.96901597
Vote169996032023-04-07 22:36:47603 days ago1680907007IN
0x332B8C97...FFdB45B84
0 ETH0.0049060521.12948157
Vote169989622023-04-07 20:27:35603 days ago1680899255IN
0x332B8C97...FFdB45B84
0 ETH0.0049773821.46840243
Vote169986012023-04-07 19:13:23603 days ago1680894803IN
0x332B8C97...FFdB45B84
0 ETH0.0056691324.45206798
Vote169985152023-04-07 18:54:59603 days ago1680893699IN
0x332B8C97...FFdB45B84
0 ETH0.0050959621.97398057
Vote169981582023-04-07 17:42:35603 days ago1680889355IN
0x332B8C97...FFdB45B84
0 ETH0.005685624.52307683
Vote169979862023-04-07 17:07:35603 days ago1680887255IN
0x332B8C97...FFdB45B84
0 ETH0.0073158931.54639189
Vote169978782023-04-07 16:45:47603 days ago1680885947IN
0x332B8C97...FFdB45B84
0 ETH0.0063310827.30718307
View all transactions

View more zero value Internal Transactions in Advanced View mode

Advanced mode:
Loading...
Loading

Contract Source Code Verified (Exact Match)

Contract Name:
GenesisProtocol

Compiler Version
v0.5.4+commit.9549d8ff

Optimization Enabled:
Yes with 200 runs

Other Settings:
default evmVersion

Contract Source Code (Solidity)

/**
 *Submitted for verification at Etherscan.io on 2019-05-27
*/

// File: openzeppelin-solidity/contracts/cryptography/ECDSA.sol

pragma solidity ^0.5.0;

/**
 * @title Elliptic curve signature operations
 * @dev Based on https://gist.github.com/axic/5b33912c6f61ae6fd96d6c4a47afde6d
 * TODO Remove this library once solidity supports passing a signature to ecrecover.
 * See https://github.com/ethereum/solidity/issues/864
 */

library ECDSA {
    /**
     * @dev Recover signer address from a message by using their signature
     * @param hash bytes32 message, the hash is the signed message. What is recovered is the signer address.
     * @param signature bytes signature, the signature is generated using web3.eth.sign()
     */
    function recover(bytes32 hash, bytes memory signature) internal pure returns (address) {
        bytes32 r;
        bytes32 s;
        uint8 v;

        // Check the signature length
        if (signature.length != 65) {
            return (address(0));
        }

        // Divide the signature in r, s and v variables
        // ecrecover takes the signature parameters, and the only way to get them
        // currently is to use assembly.
        // solhint-disable-next-line no-inline-assembly
        assembly {
            r := mload(add(signature, 0x20))
            s := mload(add(signature, 0x40))
            v := byte(0, mload(add(signature, 0x60)))
        }

        // Version of signature should be 27 or 28, but 0 and 1 are also possible versions
        if (v < 27) {
            v += 27;
        }

        // If the version is correct return the signer address
        if (v != 27 && v != 28) {
            return (address(0));
        } else {
            return ecrecover(hash, v, r, s);
        }
    }

    /**
     * toEthSignedMessageHash
     * @dev prefix a bytes32 value with "\x19Ethereum Signed Message:"
     * and hash the result
     */
    function toEthSignedMessageHash(bytes32 hash) internal pure returns (bytes32) {
        // 32 is the length in bytes of hash,
        // enforced by the type signature above
        return keccak256(abi.encodePacked("\x19Ethereum Signed Message:\n32", hash));
    }
}

// File: contracts/votingMachines/IntVoteInterface.sol

pragma solidity ^0.5.4;

interface IntVoteInterface {
    //When implementing this interface please do not only override function and modifier,
    //but also to keep the modifiers on the overridden functions.
    modifier onlyProposalOwner(bytes32 _proposalId) {revert(); _;}
    modifier votable(bytes32 _proposalId) {revert(); _;}

    event NewProposal(
        bytes32 indexed _proposalId,
        address indexed _organization,
        uint256 _numOfChoices,
        address _proposer,
        bytes32 _paramsHash
    );

    event ExecuteProposal(bytes32 indexed _proposalId,
        address indexed _organization,
        uint256 _decision,
        uint256 _totalReputation
    );

    event VoteProposal(
        bytes32 indexed _proposalId,
        address indexed _organization,
        address indexed _voter,
        uint256 _vote,
        uint256 _reputation
    );

    event CancelProposal(bytes32 indexed _proposalId, address indexed _organization );
    event CancelVoting(bytes32 indexed _proposalId, address indexed _organization, address indexed _voter);

    /**
     * @dev register a new proposal with the given parameters. Every proposal has a unique ID which is being
     * generated by calculating keccak256 of a incremented counter.
     * @param _numOfChoices number of voting choices
     * @param _proposalParameters defines the parameters of the voting machine used for this proposal
     * @param _proposer address
     * @param _organization address - if this address is zero the msg.sender will be used as the organization address.
     * @return proposal's id.
     */
    function propose(
        uint256 _numOfChoices,
        bytes32 _proposalParameters,
        address _proposer,
        address _organization
        ) external returns(bytes32);

    function vote(
        bytes32 _proposalId,
        uint256 _vote,
        uint256 _rep,
        address _voter
    )
    external
    returns(bool);

    function cancelVote(bytes32 _proposalId) external;

    function getNumberOfChoices(bytes32 _proposalId) external view returns(uint256);

    function isVotable(bytes32 _proposalId) external view returns(bool);

    /**
     * @dev voteStatus returns the reputation voted for a proposal for a specific voting choice.
     * @param _proposalId the ID of the proposal
     * @param _choice the index in the
     * @return voted reputation for the given choice
     */
    function voteStatus(bytes32 _proposalId, uint256 _choice) external view returns(uint256);

    /**
     * @dev isAbstainAllow returns if the voting machine allow abstain (0)
     * @return bool true or false
     */
    function isAbstainAllow() external pure returns(bool);

    /**
     * @dev getAllowedRangeOfChoices returns the allowed range of choices for a voting machine.
     * @return min - minimum number of choices
               max - maximum number of choices
     */
    function getAllowedRangeOfChoices() external pure returns(uint256 min, uint256 max);
}

// File: contracts/libs/RealMath.sol

pragma solidity ^0.5.4;

/**
 * RealMath: fixed-point math library, based on fractional and integer parts.
 * Using uint256 as real216x40, which isn't in Solidity yet.
 * Internally uses the wider uint256 for some math.
 *
 * Note that for addition, subtraction, and mod (%), you should just use the
 * built-in Solidity operators. Functions for these operations are not provided.
 *
 */


library RealMath {

    /**
     * How many total bits are there?
     */
    uint256 constant private REAL_BITS = 256;

    /**
     * How many fractional bits are there?
     */
    uint256 constant private REAL_FBITS = 40;

    /**
     * What's the first non-fractional bit
     */
    uint256 constant private REAL_ONE = uint256(1) << REAL_FBITS;

    /**
     * Raise a real number to any positive integer power
     */
    function pow(uint256 realBase, uint256 exponent) internal pure returns (uint256) {

        uint256 tempRealBase = realBase;
        uint256 tempExponent = exponent;

        // Start with the 0th power
        uint256 realResult = REAL_ONE;
        while (tempExponent != 0) {
            // While there are still bits set
            if ((tempExponent & 0x1) == 0x1) {
                // If the low bit is set, multiply in the (many-times-squared) base
                realResult = mul(realResult, tempRealBase);
            }
                // Shift off the low bit
            tempExponent = tempExponent >> 1;
            if (tempExponent != 0) {
                // Do the squaring
                tempRealBase = mul(tempRealBase, tempRealBase);
            }
        }

        // Return the final result.
        return realResult;
    }

    /**
     * Create a real from a rational fraction.
     */
    function fraction(uint216 numerator, uint216 denominator) internal pure returns (uint256) {
        return div(uint256(numerator) * REAL_ONE, uint256(denominator) * REAL_ONE);
    }

    /**
     * Multiply one real by another. Truncates overflows.
     */
    function mul(uint256 realA, uint256 realB) private pure returns (uint256) {
        // When multiplying fixed point in x.y and z.w formats we get (x+z).(y+w) format.
        // So we just have to clip off the extra REAL_FBITS fractional bits.
        uint256 res = realA * realB;
        require(res/realA == realB, "RealMath mul overflow");
        return (res >> REAL_FBITS);
    }

    /**
     * Divide one real by another real. Truncates overflows.
     */
    function div(uint256 realNumerator, uint256 realDenominator) private pure returns (uint256) {
        // We use the reverse of the multiplication trick: convert numerator from
        // x.y to (x+z).(y+w) fixed point, then divide by denom in z.w fixed point.
        return uint256((uint256(realNumerator) * REAL_ONE) / uint256(realDenominator));
    }

}

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

pragma solidity ^0.5.0;

/**
 * @title ERC20 interface
 * @dev see https://github.com/ethereum/EIPs/issues/20
 */
interface IERC20 {
    function transfer(address to, uint256 value) external returns (bool);

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

    function transferFrom(address from, address to, uint256 value) external returns (bool);

    function totalSupply() external view returns (uint256);

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

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

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

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

// File: contracts/votingMachines/VotingMachineCallbacksInterface.sol

pragma solidity ^0.5.4;


interface VotingMachineCallbacksInterface {
    function mintReputation(uint256 _amount, address _beneficiary, bytes32 _proposalId) external returns(bool);
    function burnReputation(uint256 _amount, address _owner, bytes32 _proposalId) external returns(bool);

    function stakingTokenTransfer(IERC20 _stakingToken, address _beneficiary, uint256 _amount, bytes32 _proposalId)
    external
    returns(bool);

    function getTotalReputationSupply(bytes32 _proposalId) external view returns(uint256);
    function reputationOf(address _owner, bytes32 _proposalId) external view returns(uint256);
    function balanceOfStakingToken(IERC20 _stakingToken, bytes32 _proposalId) external view returns(uint256);
}

// File: contracts/votingMachines/ProposalExecuteInterface.sol

pragma solidity ^0.5.4;

interface ProposalExecuteInterface {
    function executeProposal(bytes32 _proposalId, int _decision) external returns(bool);
}

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

pragma solidity ^0.5.0;

/**
 * @title SafeMath
 * @dev Unsigned math operations with safety checks that revert on error
 */
library SafeMath {
    /**
    * @dev Multiplies two unsigned integers, reverts on 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-solidity/pull/522
        if (a == 0) {
            return 0;
        }

        uint256 c = a * b;
        require(c / a == b);

        return c;
    }

    /**
    * @dev Integer division of two unsigned integers truncating the quotient, reverts on division by zero.
    */
    function div(uint256 a, uint256 b) internal pure returns (uint256) {
        // Solidity only automatically asserts when dividing by 0
        require(b > 0);
        uint256 c = a / b;
        // assert(a == b * c + a % b); // There is no case in which this doesn't hold

        return c;
    }

    /**
    * @dev Subtracts two unsigned integers, reverts on overflow (i.e. if subtrahend is greater than minuend).
    */
    function sub(uint256 a, uint256 b) internal pure returns (uint256) {
        require(b <= a);
        uint256 c = a - b;

        return c;
    }

    /**
    * @dev Adds two unsigned integers, reverts on overflow.
    */
    function add(uint256 a, uint256 b) internal pure returns (uint256) {
        uint256 c = a + b;
        require(c >= a);

        return c;
    }

    /**
    * @dev Divides two unsigned integers and returns the remainder (unsigned integer modulo),
    * reverts when dividing by zero.
    */
    function mod(uint256 a, uint256 b) internal pure returns (uint256) {
        require(b != 0);
        return a % b;
    }
}

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

pragma solidity ^0.5.0;

/**
 * @title Math
 * @dev Assorted math operations
 */
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 Calculates the average of two numbers. Since these are integers,
    * averages of an even and odd number cannot be represented, and will be
    * rounded down.
    */
    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);
    }
}

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

pragma solidity ^0.5.0;

/**
 * Utility library of inline functions on addresses
 */
library Address {
    /**
     * Returns whether the target address is a contract
     * @dev This function will return false if invoked during the constructor of a contract,
     * as the code is not actually created until after the constructor finishes.
     * @param account address of the account to check
     * @return whether the target address is a contract
     */
    function isContract(address account) internal view returns (bool) {
        uint256 size;
        // XXX Currently there is no better way to check if there is a contract in an address
        // than to check the size of the code at that address.
        // See https://ethereum.stackexchange.com/a/14016/36603
        // for more details about how this works.
        // TODO Check this again before the Serenity release, because all addresses will be
        // contracts then.
        // solhint-disable-next-line no-inline-assembly
        assembly { size := extcodesize(account) }
        return size > 0;
    }
}

// File: contracts/votingMachines/GenesisProtocolLogic.sol

pragma solidity ^0.5.4;











/**
 * @title GenesisProtocol implementation -an organization's voting machine scheme.
 */
contract GenesisProtocolLogic is IntVoteInterface {
    using SafeMath for uint256;
    using Math for uint256;
    using RealMath for uint216;
    using RealMath for uint256;
    using Address for address;

    enum ProposalState { None, ExpiredInQueue, Executed, Queued, PreBoosted, Boosted, QuietEndingPeriod}
    enum ExecutionState { None, QueueBarCrossed, QueueTimeOut, PreBoostedBarCrossed, BoostedTimeOut, BoostedBarCrossed}

    //Organization's parameters
    struct Parameters {
        uint256 queuedVoteRequiredPercentage; // the absolute vote percentages bar.
        uint256 queuedVotePeriodLimit; //the time limit for a proposal to be in an absolute voting mode.
        uint256 boostedVotePeriodLimit; //the time limit for a proposal to be in boost mode.
        uint256 preBoostedVotePeriodLimit; //the time limit for a proposal
                                          //to be in an preparation state (stable) before boosted.
        uint256 thresholdConst; //constant  for threshold calculation .
                                //threshold =thresholdConst ** (numberOfBoostedProposals)
        uint256 limitExponentValue;// an upper limit for numberOfBoostedProposals
                                   //in the threshold calculation to prevent overflow
        uint256 quietEndingPeriod; //quite ending period
        uint256 proposingRepReward;//proposer reputation reward.
        uint256 votersReputationLossRatio;//Unsuccessful pre booster
                                          //voters lose votersReputationLossRatio% of their reputation.
        uint256 minimumDaoBounty;
        uint256 daoBountyConst;//The DAO downstake for each proposal is calculate according to the formula
                               //(daoBountyConst * averageBoostDownstakes)/100 .
        uint256 activationTime;//the point in time after which proposals can be created.
        //if this address is set so only this address is allowed to vote of behalf of someone else.
        address voteOnBehalf;
    }

    struct Voter {
        uint256 vote; // YES(1) ,NO(2)
        uint256 reputation; // amount of voter's reputation
        bool preBoosted;
    }

    struct Staker {
        uint256 vote; // YES(1) ,NO(2)
        uint256 amount; // amount of staker's stake
        uint256 amount4Bounty;// amount of staker's stake used for bounty reward calculation.
    }

    struct Proposal {
        bytes32 organizationId; // the organization unique identifier the proposal is target to.
        address callbacks;    // should fulfill voting callbacks interface.
        ProposalState state;
        uint256 winningVote; //the winning vote.
        address proposer;
        //the proposal boosted period limit . it is updated for the case of quiteWindow mode.
        uint256 currentBoostedVotePeriodLimit;
        bytes32 paramsHash;
        uint256 daoBountyRemain; //use for checking sum zero bounty claims.it is set at the proposing time.
        uint256 daoBounty;
        uint256 totalStakes;// Total number of tokens staked which can be redeemable by stakers.
        uint256 confidenceThreshold;
        uint256 secondsFromTimeOutTillExecuteBoosted;
        uint[3] times; //times[0] - submittedTime
                       //times[1] - boostedPhaseTime
                       //times[2] -preBoostedPhaseTime;
        bool daoRedeemItsWinnings;
        //      vote      reputation
        mapping(uint256   =>  uint256    ) votes;
        //      vote      reputation
        mapping(uint256   =>  uint256    ) preBoostedVotes;
        //      address     voter
        mapping(address =>  Voter    ) voters;
        //      vote        stakes
        mapping(uint256   =>  uint256    ) stakes;
        //      address  staker
        mapping(address  => Staker   ) stakers;
    }

    event Stake(bytes32 indexed _proposalId,
        address indexed _organization,
        address indexed _staker,
        uint256 _vote,
        uint256 _amount
    );

    event Redeem(bytes32 indexed _proposalId,
        address indexed _organization,
        address indexed _beneficiary,
        uint256 _amount
    );

    event RedeemDaoBounty(bytes32 indexed _proposalId,
        address indexed _organization,
        address indexed _beneficiary,
        uint256 _amount
    );

    event RedeemReputation(bytes32 indexed _proposalId,
        address indexed _organization,
        address indexed _beneficiary,
        uint256 _amount
    );

    event StateChange(bytes32 indexed _proposalId, ProposalState _proposalState);
    event GPExecuteProposal(bytes32 indexed _proposalId, ExecutionState _executionState);
    event ExpirationCallBounty(bytes32 indexed _proposalId, address indexed _beneficiary, uint256 _amount);
    event ConfidenceLevelChange(bytes32 indexed _proposalId, uint256 _confidenceThreshold);

    mapping(bytes32=>Parameters) public parameters;  // A mapping from hashes to parameters
    mapping(bytes32=>Proposal) public proposals; // Mapping from the ID of the proposal to the proposal itself.
    mapping(bytes32=>uint) public orgBoostedProposalsCnt;
           //organizationId => organization
    mapping(bytes32        => address     ) public organizations;
          //organizationId => averageBoostDownstakes
    mapping(bytes32           => uint256              ) public averagesDownstakesOfBoosted;
    uint256 constant public NUM_OF_CHOICES = 2;
    uint256 constant public NO = 2;
    uint256 constant public YES = 1;
    uint256 public proposalsCnt; // Total number of proposals
    IERC20 public stakingToken;
    address constant private GEN_TOKEN_ADDRESS = 0x543Ff227F64Aa17eA132Bf9886cAb5DB55DCAddf;
    uint256 constant private MAX_BOOSTED_PROPOSALS = 4096;

    /**
     * @dev Constructor
     */
    constructor(IERC20 _stakingToken) public {
      //The GEN token (staking token) address is hard coded in the contract by GEN_TOKEN_ADDRESS .
      //This will work for a network which already hosted the GEN token on this address (e.g mainnet).
      //If such contract address does not exist in the network (e.g ganache)
      //the contract will use the _stakingToken param as the
      //staking token address.
        if (address(GEN_TOKEN_ADDRESS).isContract()) {
            stakingToken = IERC20(GEN_TOKEN_ADDRESS);
        } else {
            stakingToken = _stakingToken;
        }
    }

  /**
   * @dev Check that the proposal is votable
   * a proposal is votable if it is in one of the following states:
   *  PreBoosted,Boosted,QuietEndingPeriod or Queued
   */
    modifier votable(bytes32 _proposalId) {
        require(_isVotable(_proposalId));
        _;
    }

    /**
     * @dev register a new proposal with the given parameters. Every proposal has a unique ID which is being
     * generated by calculating keccak256 of a incremented counter.
     * @param _paramsHash parameters hash
     * @param _proposer address
     * @param _organization address
     */
    function propose(uint256, bytes32 _paramsHash, address _proposer, address _organization)
        external
        returns(bytes32)
    {
      // solhint-disable-next-line not-rely-on-time
        require(now > parameters[_paramsHash].activationTime, "not active yet");
        //Check parameters existence.
        require(parameters[_paramsHash].queuedVoteRequiredPercentage >= 50);
        // Generate a unique ID:
        bytes32 proposalId = keccak256(abi.encodePacked(this, proposalsCnt));
        proposalsCnt = proposalsCnt.add(1);
         // Open proposal:
        Proposal memory proposal;
        proposal.callbacks = msg.sender;
        proposal.organizationId = keccak256(abi.encodePacked(msg.sender, _organization));

        proposal.state = ProposalState.Queued;
        // solhint-disable-next-line not-rely-on-time
        proposal.times[0] = now;//submitted time
        proposal.currentBoostedVotePeriodLimit = parameters[_paramsHash].boostedVotePeriodLimit;
        proposal.proposer = _proposer;
        proposal.winningVote = NO;
        proposal.paramsHash = _paramsHash;
        if (organizations[proposal.organizationId] == address(0)) {
            if (_organization == address(0)) {
                organizations[proposal.organizationId] = msg.sender;
            } else {
                organizations[proposal.organizationId] = _organization;
            }
        }
        //calc dao bounty
        uint256 daoBounty =
        parameters[_paramsHash].daoBountyConst.mul(averagesDownstakesOfBoosted[proposal.organizationId]).div(100);
        proposal.daoBountyRemain = daoBounty.max(parameters[_paramsHash].minimumDaoBounty);
        proposals[proposalId] = proposal;
        proposals[proposalId].stakes[NO] = proposal.daoBountyRemain;//dao downstake on the proposal

        emit NewProposal(proposalId, organizations[proposal.organizationId], NUM_OF_CHOICES, _proposer, _paramsHash);
        return proposalId;
    }

    /**
      * @dev executeBoosted try to execute a boosted or QuietEndingPeriod proposal if it is expired
      * it rewards the msg.sender with P % of the proposal's upstakes upon a successful call to this function.
      * P = t/150, where t is the number of seconds passed since the the proposal's timeout.
      * P is capped by 10%.
      * @param _proposalId the id of the proposal
      * @return uint256 expirationCallBounty the bounty amount for the expiration call
     */
    function executeBoosted(bytes32 _proposalId) external returns(uint256 expirationCallBounty) {
        Proposal storage proposal = proposals[_proposalId];
        require(proposal.state == ProposalState.Boosted || proposal.state == ProposalState.QuietEndingPeriod,
        "proposal state in not Boosted nor QuietEndingPeriod");
        require(_execute(_proposalId), "proposal need to expire");

        proposal.secondsFromTimeOutTillExecuteBoosted =
        // solhint-disable-next-line not-rely-on-time
        now.sub(proposal.currentBoostedVotePeriodLimit.add(proposal.times[1]));

        expirationCallBounty = calcExecuteCallBounty(_proposalId);
        proposal.totalStakes = proposal.totalStakes.sub(expirationCallBounty);
        require(stakingToken.transfer(msg.sender, expirationCallBounty), "transfer to msg.sender failed");
        emit ExpirationCallBounty(_proposalId, msg.sender, expirationCallBounty);
    }

    /**
     * @dev hash the parameters, save them if necessary, and return the hash value
     * @param _params a parameters array
     *    _params[0] - _queuedVoteRequiredPercentage,
     *    _params[1] - _queuedVotePeriodLimit, //the time limit for a proposal to be in an absolute voting mode.
     *    _params[2] - _boostedVotePeriodLimit, //the time limit for a proposal to be in an relative voting mode.
     *    _params[3] - _preBoostedVotePeriodLimit, //the time limit for a proposal to be in an preparation
     *                  state (stable) before boosted.
     *    _params[4] -_thresholdConst
     *    _params[5] -_quietEndingPeriod
     *    _params[6] -_proposingRepReward
     *    _params[7] -_votersReputationLossRatio
     *    _params[8] -_minimumDaoBounty
     *    _params[9] -_daoBountyConst
     *    _params[10] -_activationTime
     * @param _voteOnBehalf - authorized to vote on behalf of others.
    */
    function setParameters(
        uint[11] calldata _params, //use array here due to stack too deep issue.
        address _voteOnBehalf
    )
    external
    returns(bytes32)
    {
        require(_params[0] <= 100 && _params[0] >= 50, "50 <= queuedVoteRequiredPercentage <= 100");
        require(_params[4] <= 16000 && _params[4] > 1000, "1000 < thresholdConst <= 16000");
        require(_params[7] <= 100, "votersReputationLossRatio <= 100");
        require(_params[2] >= _params[5], "boostedVotePeriodLimit >= quietEndingPeriod");
        require(_params[8] > 0, "minimumDaoBounty should be > 0");
        require(_params[9] > 0, "daoBountyConst should be > 0");

        bytes32 paramsHash = getParametersHash(_params, _voteOnBehalf);
        //set a limit for power for a given alpha to prevent overflow
        uint256 limitExponent = 172;//for alpha less or equal 2
        uint256 j = 2;
        for (uint256 i = 2000; i < 16000; i = i*2) {
            if ((_params[4] > i) && (_params[4] <= i*2)) {
                limitExponent = limitExponent/j;
                break;
            }
            j++;
        }

        parameters[paramsHash] = Parameters({
            queuedVoteRequiredPercentage: _params[0],
            queuedVotePeriodLimit: _params[1],
            boostedVotePeriodLimit: _params[2],
            preBoostedVotePeriodLimit: _params[3],
            thresholdConst:uint216(_params[4]).fraction(uint216(1000)),
            limitExponentValue:limitExponent,
            quietEndingPeriod: _params[5],
            proposingRepReward: _params[6],
            votersReputationLossRatio:_params[7],
            minimumDaoBounty:_params[8],
            daoBountyConst:_params[9],
            activationTime:_params[10],
            voteOnBehalf:_voteOnBehalf
        });
        return paramsHash;
    }

    /**
     * @dev redeem a reward for a successful stake, vote or proposing.
     * The function use a beneficiary address as a parameter (and not msg.sender) to enable
     * users to redeem on behalf of someone else.
     * @param _proposalId the ID of the proposal
     * @param _beneficiary - the beneficiary address
     * @return rewards -
     *           [0] stakerTokenReward
     *           [1] voterReputationReward
     *           [2] proposerReputationReward
     */
     // solhint-disable-next-line function-max-lines,code-complexity
    function redeem(bytes32 _proposalId, address _beneficiary) public returns (uint[3] memory rewards) {
        Proposal storage proposal = proposals[_proposalId];
        require((proposal.state == ProposalState.Executed)||(proposal.state == ProposalState.ExpiredInQueue),
        "Proposal should be Executed or ExpiredInQueue");
        Parameters memory params = parameters[proposal.paramsHash];
        //as staker
        Staker storage staker = proposal.stakers[_beneficiary];
        uint256 totalWinningStakes = proposal.stakes[proposal.winningVote];
        uint256 totalStakesLeftAfterCallBounty =
        proposal.stakes[NO].add(proposal.stakes[YES]).sub(calcExecuteCallBounty(_proposalId));
        if (staker.amount > 0) {

            if (proposal.state == ProposalState.ExpiredInQueue) {
                //Stakes of a proposal that expires in Queue are sent back to stakers
                rewards[0] = staker.amount;
            } else if (staker.vote == proposal.winningVote) {
                if (staker.vote == YES) {
                    if (proposal.daoBounty < totalStakesLeftAfterCallBounty) {
                        uint256 _totalStakes = totalStakesLeftAfterCallBounty.sub(proposal.daoBounty);
                        rewards[0] = (staker.amount.mul(_totalStakes))/totalWinningStakes;
                    }
                } else {
                    rewards[0] = (staker.amount.mul(totalStakesLeftAfterCallBounty))/totalWinningStakes;
                }
            }
            staker.amount = 0;
        }
            //dao redeem its winnings
        if (proposal.daoRedeemItsWinnings == false &&
            _beneficiary == organizations[proposal.organizationId] &&
            proposal.state != ProposalState.ExpiredInQueue &&
            proposal.winningVote == NO) {
            rewards[0] =
            rewards[0]
            .add((proposal.daoBounty.mul(totalStakesLeftAfterCallBounty))/totalWinningStakes)
            .sub(proposal.daoBounty);
            proposal.daoRedeemItsWinnings = true;
        }

        //as voter
        Voter storage voter = proposal.voters[_beneficiary];
        if ((voter.reputation != 0) && (voter.preBoosted)) {
            if (proposal.state == ProposalState.ExpiredInQueue) {
              //give back reputation for the voter
                rewards[1] = ((voter.reputation.mul(params.votersReputationLossRatio))/100);
            } else if (proposal.winningVote == voter.vote) {
                uint256 lostReputation;
                if (proposal.winningVote == YES) {
                    lostReputation = proposal.preBoostedVotes[NO];
                } else {
                    lostReputation = proposal.preBoostedVotes[YES];
                }
                lostReputation = (lostReputation.mul(params.votersReputationLossRatio))/100;
                rewards[1] = ((voter.reputation.mul(params.votersReputationLossRatio))/100)
                .add((voter.reputation.mul(lostReputation))/proposal.preBoostedVotes[proposal.winningVote]);
            }
            voter.reputation = 0;
        }
        //as proposer
        if ((proposal.proposer == _beneficiary)&&(proposal.winningVote == YES)&&(proposal.proposer != address(0))) {
            rewards[2] = params.proposingRepReward;
            proposal.proposer = address(0);
        }
        if (rewards[0] != 0) {
            proposal.totalStakes = proposal.totalStakes.sub(rewards[0]);
            require(stakingToken.transfer(_beneficiary, rewards[0]), "transfer to beneficiary failed");
            emit Redeem(_proposalId, organizations[proposal.organizationId], _beneficiary, rewards[0]);
        }
        if (rewards[1].add(rewards[2]) != 0) {
            VotingMachineCallbacksInterface(proposal.callbacks)
            .mintReputation(rewards[1].add(rewards[2]), _beneficiary, _proposalId);
            emit RedeemReputation(
            _proposalId,
            organizations[proposal.organizationId],
            _beneficiary,
            rewards[1].add(rewards[2])
            );
        }
    }

    /**
     * @dev redeemDaoBounty a reward for a successful stake.
     * The function use a beneficiary address as a parameter (and not msg.sender) to enable
     * users to redeem on behalf of someone else.
     * @param _proposalId the ID of the proposal
     * @param _beneficiary - the beneficiary address
     * @return redeemedAmount - redeem token amount
     * @return potentialAmount - potential redeem token amount(if there is enough tokens bounty at the organization )
     */
    function redeemDaoBounty(bytes32 _proposalId, address _beneficiary)
    public
    returns(uint256 redeemedAmount, uint256 potentialAmount) {
        Proposal storage proposal = proposals[_proposalId];
        require(proposal.state == ProposalState.Executed);
        uint256 totalWinningStakes = proposal.stakes[proposal.winningVote];
        Staker storage staker = proposal.stakers[_beneficiary];
        if (
            (staker.amount4Bounty > 0)&&
            (staker.vote == proposal.winningVote)&&
            (proposal.winningVote == YES)&&
            (totalWinningStakes != 0)) {
            //as staker
                potentialAmount = (staker.amount4Bounty * proposal.daoBounty)/totalWinningStakes;
            }
        if ((potentialAmount != 0)&&
            (VotingMachineCallbacksInterface(proposal.callbacks)
            .balanceOfStakingToken(stakingToken, _proposalId) >= potentialAmount)) {
            staker.amount4Bounty = 0;
            proposal.daoBountyRemain = proposal.daoBountyRemain.sub(potentialAmount);
            require(
            VotingMachineCallbacksInterface(proposal.callbacks)
            .stakingTokenTransfer(stakingToken, _beneficiary, potentialAmount, _proposalId));
            redeemedAmount = potentialAmount;
            emit RedeemDaoBounty(_proposalId, organizations[proposal.organizationId], _beneficiary, redeemedAmount);
        }
    }

    /**
      * @dev calcExecuteCallBounty calculate the execute boosted call bounty
      * @param _proposalId the ID of the proposal
      * @return uint256 executeCallBounty
    */
    function calcExecuteCallBounty(bytes32 _proposalId) public view returns(uint256) {
        uint maxRewardSeconds = 1500;
        uint rewardSeconds =
        uint256(maxRewardSeconds).min(proposals[_proposalId].secondsFromTimeOutTillExecuteBoosted);
        return rewardSeconds.mul(proposals[_proposalId].stakes[YES]).div(maxRewardSeconds*10);
    }

    /**
     * @dev shouldBoost check if a proposal should be shifted to boosted phase.
     * @param _proposalId the ID of the proposal
     * @return bool true or false.
     */
    function shouldBoost(bytes32 _proposalId) public view returns(bool) {
        Proposal memory proposal = proposals[_proposalId];
        return (_score(_proposalId) > threshold(proposal.paramsHash, proposal.organizationId));
    }

    /**
     * @dev threshold return the organization's score threshold which required by
     * a proposal to shift to boosted state.
     * This threshold is dynamically set and it depend on the number of boosted proposal.
     * @param _organizationId the organization identifier
     * @param _paramsHash the organization parameters hash
     * @return uint256 organization's score threshold as real number.
     */
    function threshold(bytes32 _paramsHash, bytes32 _organizationId) public view returns(uint256) {
        uint256 power = orgBoostedProposalsCnt[_organizationId];
        Parameters storage params = parameters[_paramsHash];

        if (power > params.limitExponentValue) {
            power = params.limitExponentValue;
        }

        return params.thresholdConst.pow(power);
    }

  /**
   * @dev hashParameters returns a hash of the given parameters
   */
    function getParametersHash(
        uint[11] memory _params,//use array here due to stack too deep issue.
        address _voteOnBehalf
    )
        public
        pure
        returns(bytes32)
        {
        //double call to keccak256 to avoid deep stack issue when call with too many params.
        return keccak256(
            abi.encodePacked(
            keccak256(
            abi.encodePacked(
                _params[0],
                _params[1],
                _params[2],
                _params[3],
                _params[4],
                _params[5],
                _params[6],
                _params[7],
                _params[8],
                _params[9],
                _params[10])
            ),
            _voteOnBehalf
        ));
    }

    /**
      * @dev execute check if the proposal has been decided, and if so, execute the proposal
      * @param _proposalId the id of the proposal
      * @return bool true - the proposal has been executed
      *              false - otherwise.
     */
     // solhint-disable-next-line function-max-lines,code-complexity
    function _execute(bytes32 _proposalId) internal votable(_proposalId) returns(bool) {
        Proposal storage proposal = proposals[_proposalId];
        Parameters memory params = parameters[proposal.paramsHash];
        Proposal memory tmpProposal = proposal;
        uint256 totalReputation =
        VotingMachineCallbacksInterface(proposal.callbacks).getTotalReputationSupply(_proposalId);
        //first divide by 100 to prevent overflow
        uint256 executionBar = (totalReputation/100) * params.queuedVoteRequiredPercentage;
        ExecutionState executionState = ExecutionState.None;
        uint256 averageDownstakesOfBoosted;
        uint256 confidenceThreshold;

        if (proposal.votes[proposal.winningVote] > executionBar) {
         // someone crossed the absolute vote execution bar.
            if (proposal.state == ProposalState.Queued) {
                executionState = ExecutionState.QueueBarCrossed;
            } else if (proposal.state == ProposalState.PreBoosted) {
                executionState = ExecutionState.PreBoostedBarCrossed;
            } else {
                executionState = ExecutionState.BoostedBarCrossed;
            }
            proposal.state = ProposalState.Executed;
        } else {
            if (proposal.state == ProposalState.Queued) {
                // solhint-disable-next-line not-rely-on-time
                if ((now - proposal.times[0]) >= params.queuedVotePeriodLimit) {
                    proposal.state = ProposalState.ExpiredInQueue;
                    proposal.winningVote = NO;
                    executionState = ExecutionState.QueueTimeOut;
                } else {
                    confidenceThreshold = threshold(proposal.paramsHash, proposal.organizationId);
                    if (_score(_proposalId) > confidenceThreshold) {
                        //change proposal mode to PreBoosted mode.
                        proposal.state = ProposalState.PreBoosted;
                        // solhint-disable-next-line not-rely-on-time
                        proposal.times[2] = now;
                        proposal.confidenceThreshold = confidenceThreshold;
                    }
                }
            }

            if (proposal.state == ProposalState.PreBoosted) {
                confidenceThreshold = threshold(proposal.paramsHash, proposal.organizationId);
              // solhint-disable-next-line not-rely-on-time
                if ((now - proposal.times[2]) >= params.preBoostedVotePeriodLimit) {
                    if (_score(_proposalId) > confidenceThreshold) {
                        if (orgBoostedProposalsCnt[proposal.organizationId] < MAX_BOOSTED_PROPOSALS) {
                         //change proposal mode to Boosted mode.
                            proposal.state = ProposalState.Boosted;
                         // solhint-disable-next-line not-rely-on-time
                            proposal.times[1] = now;
                            orgBoostedProposalsCnt[proposal.organizationId]++;
                         //add a value to average -> average = average + ((value - average) / nbValues)
                            averageDownstakesOfBoosted = averagesDownstakesOfBoosted[proposal.organizationId];
                          // solium-disable-next-line indentation
                            averagesDownstakesOfBoosted[proposal.organizationId] =
                                uint256(int256(averageDownstakesOfBoosted) +
                                ((int256(proposal.stakes[NO])-int256(averageDownstakesOfBoosted))/
                                int256(orgBoostedProposalsCnt[proposal.organizationId])));
                        }
                    } else {
                        proposal.state = ProposalState.Queued;
                    }
                } else { //check the Confidence level is stable
                    uint256 proposalScore = _score(_proposalId);
                    if (proposalScore <= proposal.confidenceThreshold.min(confidenceThreshold)) {
                        proposal.state = ProposalState.Queued;
                    } else if (proposal.confidenceThreshold > proposalScore) {
                        proposal.confidenceThreshold = confidenceThreshold;
                        emit ConfidenceLevelChange(_proposalId, confidenceThreshold);
                    }
                }
            }
        }

        if ((proposal.state == ProposalState.Boosted) ||
            (proposal.state == ProposalState.QuietEndingPeriod)) {
            // solhint-disable-next-line not-rely-on-time
            if ((now - proposal.times[1]) >= proposal.currentBoostedVotePeriodLimit) {
                proposal.state = ProposalState.Executed;
                executionState = ExecutionState.BoostedTimeOut;
            }
        }

        if (executionState != ExecutionState.None) {
            if ((executionState == ExecutionState.BoostedTimeOut) ||
                (executionState == ExecutionState.BoostedBarCrossed)) {
                orgBoostedProposalsCnt[tmpProposal.organizationId] =
                orgBoostedProposalsCnt[tmpProposal.organizationId].sub(1);
                //remove a value from average = ((average * nbValues) - value) / (nbValues - 1);
                uint256 boostedProposals = orgBoostedProposalsCnt[tmpProposal.organizationId];
                if (boostedProposals == 0) {
                    averagesDownstakesOfBoosted[proposal.organizationId] = 0;
                } else {
                    averageDownstakesOfBoosted = averagesDownstakesOfBoosted[proposal.organizationId];
                    averagesDownstakesOfBoosted[proposal.organizationId] =
                    (averageDownstakesOfBoosted.mul(boostedProposals+1).sub(proposal.stakes[NO]))/boostedProposals;
                }
            }
            emit ExecuteProposal(
            _proposalId,
            organizations[proposal.organizationId],
            proposal.winningVote,
            totalReputation
            );
            emit GPExecuteProposal(_proposalId, executionState);
            ProposalExecuteInterface(proposal.callbacks).executeProposal(_proposalId, int(proposal.winningVote));
            proposal.daoBounty = proposal.daoBountyRemain;
        }
        if (tmpProposal.state != proposal.state) {
            emit StateChange(_proposalId, proposal.state);
        }
        return (executionState != ExecutionState.None);
    }

    /**
     * @dev staking function
     * @param _proposalId id of the proposal
     * @param _vote  NO(2) or YES(1).
     * @param _amount the betting amount
     * @return bool true - the proposal has been executed
     *              false - otherwise.
     */
    function _stake(bytes32 _proposalId, uint256 _vote, uint256 _amount, address _staker) internal returns(bool) {
        // 0 is not a valid vote.
        require(_vote <= NUM_OF_CHOICES && _vote > 0, "wrong vote value");
        require(_amount > 0, "staking amount should be >0");

        if (_execute(_proposalId)) {
            return true;
        }
        Proposal storage proposal = proposals[_proposalId];

        if ((proposal.state != ProposalState.PreBoosted) &&
            (proposal.state != ProposalState.Queued)) {
            return false;
        }

        // enable to increase stake only on the previous stake vote
        Staker storage staker = proposal.stakers[_staker];
        if ((staker.amount > 0) && (staker.vote != _vote)) {
            return false;
        }

        uint256 amount = _amount;
        require(stakingToken.transferFrom(_staker, address(this), amount), "fail transfer from staker");
        proposal.totalStakes = proposal.totalStakes.add(amount); //update totalRedeemableStakes
        staker.amount = staker.amount.add(amount);
        //This is to prevent average downstakes calculation overflow
        //Note that any how GEN cap is 100000000 ether.
        require(staker.amount <= 0x100000000000000000000000000000000, "staking amount is too high");
        require(proposal.totalStakes <= uint256(0x100000000000000000000000000000000).sub(proposal.daoBountyRemain),
                "total stakes is too high");

        if (_vote == YES) {
            staker.amount4Bounty = staker.amount4Bounty.add(amount);
        }
        staker.vote = _vote;

        proposal.stakes[_vote] = amount.add(proposal.stakes[_vote]);
        emit Stake(_proposalId, organizations[proposal.organizationId], _staker, _vote, _amount);
        return _execute(_proposalId);
    }

    /**
     * @dev Vote for a proposal, if the voter already voted, cancel the last vote and set a new one instead
     * @param _proposalId id of the proposal
     * @param _voter used in case the vote is cast for someone else
     * @param _vote a value between 0 to and the proposal's number of choices.
     * @param _rep how many reputation the voter would like to stake for this vote.
     *         if  _rep==0 so the voter full reputation will be use.
     * @return true in case of proposal execution otherwise false
     * throws if proposal is not open or if it has been executed
     * NB: executes the proposal if a decision has been reached
     */
     // solhint-disable-next-line function-max-lines,code-complexity
    function internalVote(bytes32 _proposalId, address _voter, uint256 _vote, uint256 _rep) internal returns(bool) {
        require(_vote <= NUM_OF_CHOICES && _vote > 0, "0 < _vote <= 2");
        if (_execute(_proposalId)) {
            return true;
        }

        Parameters memory params = parameters[proposals[_proposalId].paramsHash];
        Proposal storage proposal = proposals[_proposalId];

        // Check voter has enough reputation:
        uint256 reputation = VotingMachineCallbacksInterface(proposal.callbacks).reputationOf(_voter, _proposalId);
        require(reputation > 0, "_voter must have reputation");
        require(reputation >= _rep, "reputation >= _rep");
        uint256 rep = _rep;
        if (rep == 0) {
            rep = reputation;
        }
        // If this voter has already voted, return false.
        if (proposal.voters[_voter].reputation != 0) {
            return false;
        }
        // The voting itself:
        proposal.votes[_vote] = rep.add(proposal.votes[_vote]);
        //check if the current winningVote changed or there is a tie.
        //for the case there is a tie the current winningVote set to NO.
        if ((proposal.votes[_vote] > proposal.votes[proposal.winningVote]) ||
            ((proposal.votes[NO] == proposal.votes[proposal.winningVote]) &&
            proposal.winningVote == YES)) {
            if (proposal.state == ProposalState.Boosted &&
            // solhint-disable-next-line not-rely-on-time
                ((now - proposal.times[1]) >= (params.boostedVotePeriodLimit - params.quietEndingPeriod))||
                proposal.state == ProposalState.QuietEndingPeriod) {
                //quietEndingPeriod
                if (proposal.state != ProposalState.QuietEndingPeriod) {
                    proposal.currentBoostedVotePeriodLimit = params.quietEndingPeriod;
                    proposal.state = ProposalState.QuietEndingPeriod;
                    emit StateChange(_proposalId, proposal.state);
                }
                // solhint-disable-next-line not-rely-on-time
                proposal.times[1] = now;
            }
            proposal.winningVote = _vote;
        }
        proposal.voters[_voter] = Voter({
            reputation: rep,
            vote: _vote,
            preBoosted:((proposal.state == ProposalState.PreBoosted) || (proposal.state == ProposalState.Queued))
        });
        if ((proposal.state == ProposalState.PreBoosted) || (proposal.state == ProposalState.Queued)) {
            proposal.preBoostedVotes[_vote] = rep.add(proposal.preBoostedVotes[_vote]);
            uint256 reputationDeposit = (params.votersReputationLossRatio.mul(rep))/100;
            VotingMachineCallbacksInterface(proposal.callbacks).burnReputation(reputationDeposit, _voter, _proposalId);
        }
        emit VoteProposal(_proposalId, organizations[proposal.organizationId], _voter, _vote, rep);
        return _execute(_proposalId);
    }

    /**
     * @dev _score return the proposal score (Confidence level)
     * For dual choice proposal S = (S+)/(S-)
     * @param _proposalId the ID of the proposal
     * @return uint256 proposal score as real number.
     */
    function _score(bytes32 _proposalId) internal view returns(uint256) {
        Proposal storage proposal = proposals[_proposalId];
        //proposal.stakes[NO] cannot be zero as the dao downstake > 0 for each proposal.
        return uint216(proposal.stakes[YES]).fraction(uint216(proposal.stakes[NO]));
    }

    /**
      * @dev _isVotable check if the proposal is votable
      * @param _proposalId the ID of the proposal
      * @return bool true or false
    */
    function _isVotable(bytes32 _proposalId) internal view returns(bool) {
        ProposalState pState = proposals[_proposalId].state;
        return ((pState == ProposalState.PreBoosted)||
                (pState == ProposalState.Boosted)||
                (pState == ProposalState.QuietEndingPeriod)||
                (pState == ProposalState.Queued)
        );
    }
}

// File: contracts/votingMachines/GenesisProtocol.sol

pragma solidity ^0.5.4;




/**
 * @title GenesisProtocol implementation -an organization's voting machine scheme.
 */
contract GenesisProtocol is IntVoteInterface, GenesisProtocolLogic {
    using ECDSA for bytes32;

    // Digest describing the data the user signs according EIP 712.
    // Needs to match what is passed to Metamask.
    bytes32 public constant DELEGATION_HASH_EIP712 =
    keccak256(abi.encodePacked(
    "address GenesisProtocolAddress",
    "bytes32 ProposalId",
    "uint256 Vote",
    "uint256 AmountToStake",
    "uint256 Nonce"
    ));

    mapping(address=>uint256) public stakesNonce; //stakes Nonce

    /**
     * @dev Constructor
     */
    constructor(IERC20 _stakingToken)
    public
    // solhint-disable-next-line no-empty-blocks
    GenesisProtocolLogic(_stakingToken) {
    }

    /**
     * @dev staking function
     * @param _proposalId id of the proposal
     * @param _vote  NO(2) or YES(1).
     * @param _amount the betting amount
     * @return bool true - the proposal has been executed
     *              false - otherwise.
     */
    function stake(bytes32 _proposalId, uint256 _vote, uint256 _amount) external returns(bool) {
        return _stake(_proposalId, _vote, _amount, msg.sender);
    }

    /**
     * @dev stakeWithSignature function
     * @param _proposalId id of the proposal
     * @param _vote  NO(2) or YES(1).
     * @param _amount the betting amount
     * @param _nonce nonce value ,it is part of the signature to ensure that
              a signature can be received only once.
     * @param _signatureType signature type
              1 - for web3.eth.sign
              2 - for eth_signTypedData according to EIP #712.
     * @param _signature  - signed data by the staker
     * @return bool true - the proposal has been executed
     *              false - otherwise.
     */
    function stakeWithSignature(
        bytes32 _proposalId,
        uint256 _vote,
        uint256 _amount,
        uint256 _nonce,
        uint256 _signatureType,
        bytes calldata _signature
        )
        external
        returns(bool)
        {
        // Recreate the digest the user signed
        bytes32 delegationDigest;
        if (_signatureType == 2) {
            delegationDigest = keccak256(
                abi.encodePacked(
                    DELEGATION_HASH_EIP712, keccak256(
                        abi.encodePacked(
                        address(this),
                        _proposalId,
                        _vote,
                        _amount,
                        _nonce)
                    )
                )
            );
        } else {
            delegationDigest = keccak256(
                        abi.encodePacked(
                        address(this),
                        _proposalId,
                        _vote,
                        _amount,
                        _nonce)
                    ).toEthSignedMessageHash();
        }
        address staker = delegationDigest.recover(_signature);
        //a garbage staker address due to wrong signature will revert due to lack of approval and funds.
        require(staker != address(0), "staker address cannot be 0");
        require(stakesNonce[staker] == _nonce);
        stakesNonce[staker] = stakesNonce[staker].add(1);
        return _stake(_proposalId, _vote, _amount, staker);
    }

    /**
     * @dev voting function
     * @param _proposalId id of the proposal
     * @param _vote NO(2) or YES(1).
     * @param _amount the reputation amount to vote with . if _amount == 0 it will use all voter reputation.
     * @param _voter voter address
     * @return bool true - the proposal has been executed
     *              false - otherwise.
     */
    function vote(bytes32 _proposalId, uint256 _vote, uint256 _amount, address _voter)
    external
    votable(_proposalId)
    returns(bool) {
        Proposal storage proposal = proposals[_proposalId];
        Parameters memory params = parameters[proposal.paramsHash];
        address voter;
        if (params.voteOnBehalf != address(0)) {
            require(msg.sender == params.voteOnBehalf);
            voter = _voter;
        } else {
            voter = msg.sender;
        }
        return internalVote(_proposalId, voter, _vote, _amount);
    }

  /**
   * @dev Cancel the vote of the msg.sender.
   * cancel vote is not allow in genesisProtocol so this function doing nothing.
   * This function is here in order to comply to the IntVoteInterface .
   */
    function cancelVote(bytes32 _proposalId) external votable(_proposalId) {
       //this is not allowed
        return;
    }

    /**
      * @dev execute check if the proposal has been decided, and if so, execute the proposal
      * @param _proposalId the id of the proposal
      * @return bool true - the proposal has been executed
      *              false - otherwise.
     */
    function execute(bytes32 _proposalId) external votable(_proposalId) returns(bool) {
        return _execute(_proposalId);
    }

  /**
    * @dev getNumberOfChoices returns the number of choices possible in this proposal
    * @return uint256 that contains number of choices
    */
    function getNumberOfChoices(bytes32) external view returns(uint256) {
        return NUM_OF_CHOICES;
    }

    /**
      * @dev getProposalTimes returns proposals times variables.
      * @param _proposalId id of the proposal
      * @return proposals times array
      */
    function getProposalTimes(bytes32 _proposalId) external view returns(uint[3] memory times) {
        return proposals[_proposalId].times;
    }

    /**
     * @dev voteInfo returns the vote and the amount of reputation of the user committed to this proposal
     * @param _proposalId the ID of the proposal
     * @param _voter the address of the voter
     * @return uint256 vote - the voters vote
     *        uint256 reputation - amount of reputation committed by _voter to _proposalId
     */
    function voteInfo(bytes32 _proposalId, address _voter) external view returns(uint, uint) {
        Voter memory voter = proposals[_proposalId].voters[_voter];
        return (voter.vote, voter.reputation);
    }

    /**
    * @dev voteStatus returns the reputation voted for a proposal for a specific voting choice.
    * @param _proposalId the ID of the proposal
    * @param _choice the index in the
    * @return voted reputation for the given choice
    */
    function voteStatus(bytes32 _proposalId, uint256 _choice) external view returns(uint256) {
        return proposals[_proposalId].votes[_choice];
    }

    /**
    * @dev isVotable check if the proposal is votable
    * @param _proposalId the ID of the proposal
    * @return bool true or false
    */
    function isVotable(bytes32 _proposalId) external view returns(bool) {
        return _isVotable(_proposalId);
    }

    /**
    * @dev proposalStatus return the total votes and stakes for a given proposal
    * @param _proposalId the ID of the proposal
    * @return uint256 preBoostedVotes YES
    * @return uint256 preBoostedVotes NO
    * @return uint256 total stakes YES
    * @return uint256 total stakes NO
    */
    function proposalStatus(bytes32 _proposalId) external view returns(uint256, uint256, uint256, uint256) {
        return (
                proposals[_proposalId].preBoostedVotes[YES],
                proposals[_proposalId].preBoostedVotes[NO],
                proposals[_proposalId].stakes[YES],
                proposals[_proposalId].stakes[NO]
        );
    }

  /**
    * @dev getProposalOrganization return the organizationId for a given proposal
    * @param _proposalId the ID of the proposal
    * @return bytes32 organization identifier
    */
    function getProposalOrganization(bytes32 _proposalId) external view returns(bytes32) {
        return (proposals[_proposalId].organizationId);
    }

    /**
      * @dev getStaker return the vote and stake amount for a given proposal and staker
      * @param _proposalId the ID of the proposal
      * @param _staker staker address
      * @return uint256 vote
      * @return uint256 amount
    */
    function getStaker(bytes32 _proposalId, address _staker) external view returns(uint256, uint256) {
        return (proposals[_proposalId].stakers[_staker].vote, proposals[_proposalId].stakers[_staker].amount);
    }

    /**
      * @dev voteStake return the amount stakes for a given proposal and vote
      * @param _proposalId the ID of the proposal
      * @param _vote vote number
      * @return uint256 stake amount
    */
    function voteStake(bytes32 _proposalId, uint256 _vote) external view returns(uint256) {
        return proposals[_proposalId].stakes[_vote];
    }

  /**
    * @dev voteStake return the winningVote for a given proposal
    * @param _proposalId the ID of the proposal
    * @return uint256 winningVote
    */
    function winningVote(bytes32 _proposalId) external view returns(uint256) {
        return proposals[_proposalId].winningVote;
    }

    /**
      * @dev voteStake return the state for a given proposal
      * @param _proposalId the ID of the proposal
      * @return ProposalState proposal state
    */
    function state(bytes32 _proposalId) external view returns(ProposalState) {
        return proposals[_proposalId].state;
    }

   /**
    * @dev isAbstainAllow returns if the voting machine allow abstain (0)
    * @return bool true or false
    */
    function isAbstainAllow() external pure returns(bool) {
        return false;
    }

    /**
     * @dev getAllowedRangeOfChoices returns the allowed range of choices for a voting machine.
     * @return min - minimum number of choices
               max - maximum number of choices
     */
    function getAllowedRangeOfChoices() external pure returns(uint256 min, uint256 max) {
        return (YES, NO);
    }

    /**
     * @dev score return the proposal score
     * @param _proposalId the ID of the proposal
     * @return uint256 proposal score.
     */
    function score(bytes32 _proposalId) public view returns(uint256) {
        return  _score(_proposalId);
    }
}

Contract Security Audit

Contract ABI

[{"constant":true,"inputs":[{"name":"","type":"bytes32"}],"name":"parameters","outputs":[{"name":"queuedVoteRequiredPercentage","type":"uint256"},{"name":"queuedVotePeriodLimit","type":"uint256"},{"name":"boostedVotePeriodLimit","type":"uint256"},{"name":"preBoostedVotePeriodLimit","type":"uint256"},{"name":"thresholdConst","type":"uint256"},{"name":"limitExponentValue","type":"uint256"},{"name":"quietEndingPeriod","type":"uint256"},{"name":"proposingRepReward","type":"uint256"},{"name":"votersReputationLossRatio","type":"uint256"},{"name":"minimumDaoBounty","type":"uint256"},{"name":"daoBountyConst","type":"uint256"},{"name":"activationTime","type":"uint256"},{"name":"voteOnBehalf","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"name":"_params","type":"uint256[11]"},{"name":"_voteOnBehalf","type":"address"}],"name":"getParametersHash","outputs":[{"name":"","type":"bytes32"}],"payable":false,"stateMutability":"pure","type":"function"},{"constant":true,"inputs":[],"name":"NO","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"name":"_proposalId","type":"bytes32"},{"name":"_voter","type":"address"}],"name":"voteInfo","outputs":[{"name":"","type":"uint256"},{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"name":"_proposalId","type":"bytes32"},{"name":"_staker","type":"address"}],"name":"getStaker","outputs":[{"name":"","type":"uint256"},{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"name":"_proposalId","type":"bytes32"}],"name":"getProposalOrganization","outputs":[{"name":"","type":"bytes32"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"proposalsCnt","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"name":"_paramsHash","type":"bytes32"},{"name":"_organizationId","type":"bytes32"}],"name":"threshold","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"_proposalId","type":"bytes32"},{"name":"_vote","type":"uint256"},{"name":"_amount","type":"uint256"}],"name":"stake","outputs":[{"name":"","type":"bool"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"DELEGATION_HASH_EIP712","outputs":[{"name":"","type":"bytes32"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"name":"","type":"bytes32"}],"name":"proposals","outputs":[{"name":"organizationId","type":"bytes32"},{"name":"callbacks","type":"address"},{"name":"state","type":"uint8"},{"name":"winningVote","type":"uint256"},{"name":"proposer","type":"address"},{"name":"currentBoostedVotePeriodLimit","type":"uint256"},{"name":"paramsHash","type":"bytes32"},{"name":"daoBountyRemain","type":"uint256"},{"name":"daoBounty","type":"uint256"},{"name":"totalStakes","type":"uint256"},{"name":"confidenceThreshold","type":"uint256"},{"name":"secondsFromTimeOutTillExecuteBoosted","type":"uint256"},{"name":"daoRedeemItsWinnings","type":"bool"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"_proposalId","type":"bytes32"},{"name":"_vote","type":"uint256"},{"name":"_amount","type":"uint256"},{"name":"_voter","type":"address"}],"name":"vote","outputs":[{"name":"","type":"bool"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[{"name":"_proposalId","type":"bytes32"}],"name":"winningVote","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"name":"_proposalId","type":"bytes32"}],"name":"calcExecuteCallBounty","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"_proposalId","type":"bytes32"},{"name":"_vote","type":"uint256"},{"name":"_amount","type":"uint256"},{"name":"_nonce","type":"uint256"},{"name":"_signatureType","type":"uint256"},{"name":"_signature","type":"bytes"}],"name":"stakeWithSignature","outputs":[{"name":"","type":"bool"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"getAllowedRangeOfChoices","outputs":[{"name":"min","type":"uint256"},{"name":"max","type":"uint256"}],"payable":false,"stateMutability":"pure","type":"function"},{"constant":true,"inputs":[],"name":"isAbstainAllow","outputs":[{"name":"","type":"bool"}],"payable":false,"stateMutability":"pure","type":"function"},{"constant":true,"inputs":[{"name":"_proposalId","type":"bytes32"}],"name":"state","outputs":[{"name":"","type":"uint8"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"_proposalId","type":"bytes32"},{"name":"_beneficiary","type":"address"}],"name":"redeemDaoBounty","outputs":[{"name":"redeemedAmount","type":"uint256"},{"name":"potentialAmount","type":"uint256"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[{"name":"_proposalId","type":"bytes32"},{"name":"_vote","type":"uint256"}],"name":"voteStake","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"stakingToken","outputs":[{"name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"name":"_proposalId","type":"bytes32"}],"name":"proposalStatus","outputs":[{"name":"","type":"uint256"},{"name":"","type":"uint256"},{"name":"","type":"uint256"},{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"name":"_proposalId","type":"bytes32"}],"name":"shouldBoost","outputs":[{"name":"","type":"bool"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"","type":"uint256"},{"name":"_paramsHash","type":"bytes32"},{"name":"_proposer","type":"address"},{"name":"_organization","type":"address"}],"name":"propose","outputs":[{"name":"","type":"bytes32"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"name":"_params","type":"uint256[11]"},{"name":"_voteOnBehalf","type":"address"}],"name":"setParameters","outputs":[{"name":"","type":"bytes32"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"name":"_proposalId","type":"bytes32"}],"name":"cancelVote","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"NUM_OF_CHOICES","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"name":"","type":"bytes32"}],"name":"getNumberOfChoices","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"name":"","type":"address"}],"name":"stakesNonce","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"YES","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"name":"_proposalId","type":"bytes32"},{"name":"_choice","type":"uint256"}],"name":"voteStatus","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"name":"","type":"bytes32"}],"name":"organizations","outputs":[{"name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"name":"","type":"bytes32"}],"name":"averagesDownstakesOfBoosted","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"_proposalId","type":"bytes32"}],"name":"executeBoosted","outputs":[{"name":"expirationCallBounty","type":"uint256"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[{"name":"_proposalId","type":"bytes32"}],"name":"isVotable","outputs":[{"name":"","type":"bool"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"name":"_proposalId","type":"bytes32"}],"name":"getProposalTimes","outputs":[{"name":"times","type":"uint256[3]"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"_proposalId","type":"bytes32"},{"name":"_beneficiary","type":"address"}],"name":"redeem","outputs":[{"name":"rewards","type":"uint256[3]"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[{"name":"_proposalId","type":"bytes32"}],"name":"score","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"_proposalId","type":"bytes32"}],"name":"execute","outputs":[{"name":"","type":"bool"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[{"name":"","type":"bytes32"}],"name":"orgBoostedProposalsCnt","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"inputs":[{"name":"_stakingToken","type":"address"}],"payable":false,"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"name":"_proposalId","type":"bytes32"},{"indexed":true,"name":"_organization","type":"address"},{"indexed":true,"name":"_staker","type":"address"},{"indexed":false,"name":"_vote","type":"uint256"},{"indexed":false,"name":"_amount","type":"uint256"}],"name":"Stake","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"name":"_proposalId","type":"bytes32"},{"indexed":true,"name":"_organization","type":"address"},{"indexed":true,"name":"_beneficiary","type":"address"},{"indexed":false,"name":"_amount","type":"uint256"}],"name":"Redeem","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"name":"_proposalId","type":"bytes32"},{"indexed":true,"name":"_organization","type":"address"},{"indexed":true,"name":"_beneficiary","type":"address"},{"indexed":false,"name":"_amount","type":"uint256"}],"name":"RedeemDaoBounty","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"name":"_proposalId","type":"bytes32"},{"indexed":true,"name":"_organization","type":"address"},{"indexed":true,"name":"_beneficiary","type":"address"},{"indexed":false,"name":"_amount","type":"uint256"}],"name":"RedeemReputation","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"name":"_proposalId","type":"bytes32"},{"indexed":false,"name":"_proposalState","type":"uint8"}],"name":"StateChange","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"name":"_proposalId","type":"bytes32"},{"indexed":false,"name":"_executionState","type":"uint8"}],"name":"GPExecuteProposal","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"name":"_proposalId","type":"bytes32"},{"indexed":true,"name":"_beneficiary","type":"address"},{"indexed":false,"name":"_amount","type":"uint256"}],"name":"ExpirationCallBounty","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"name":"_proposalId","type":"bytes32"},{"indexed":false,"name":"_confidenceThreshold","type":"uint256"}],"name":"ConfidenceLevelChange","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"name":"_proposalId","type":"bytes32"},{"indexed":true,"name":"_organization","type":"address"},{"indexed":false,"name":"_numOfChoices","type":"uint256"},{"indexed":false,"name":"_proposer","type":"address"},{"indexed":false,"name":"_paramsHash","type":"bytes32"}],"name":"NewProposal","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"name":"_proposalId","type":"bytes32"},{"indexed":true,"name":"_organization","type":"address"},{"indexed":false,"name":"_decision","type":"uint256"},{"indexed":false,"name":"_totalReputation","type":"uint256"}],"name":"ExecuteProposal","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"name":"_proposalId","type":"bytes32"},{"indexed":true,"name":"_organization","type":"address"},{"indexed":true,"name":"_voter","type":"address"},{"indexed":false,"name":"_vote","type":"uint256"},{"indexed":false,"name":"_reputation","type":"uint256"}],"name":"VoteProposal","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"name":"_proposalId","type":"bytes32"},{"indexed":true,"name":"_organization","type":"address"}],"name":"CancelProposal","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"name":"_proposalId","type":"bytes32"},{"indexed":true,"name":"_organization","type":"address"},{"indexed":true,"name":"_voter","type":"address"}],"name":"CancelVoting","type":"event"}]

60806040523480156200001157600080fd5b506040516020806200454b833981018060405260208110156200003357600080fd5b5051806200006373543ff227f64aa17ea132bf9886cab5db55dcaddf64010000000062004392620000b982021704565b15620000955760068054600160a060020a03191673543ff227f64aa17ea132bf9886cab5db55dcaddf179055620000b1565b60068054600160a060020a031916600160a060020a0383161790555b5050620000c1565b6000903b1190565b61447a80620000d16000396000f3fe608060405234801561001057600080fd5b5060043610610265576000357c01000000000000000000000000000000000000000000000000000000009004806372f702f311610158578063b4512913116100d5578063c8f526e811610099578063c8f526e8146108a4578063cc3bf9e9146108f9578063e5af18c514610925578063e751f27114610942578063fb6c0cbb1461095f57610265565b8063b45129131461080d578063ba51b14e14610830578063bb5a05ed1461084d578063beda80151461086a578063c08351061461088757610265565b80639525c0cc1161011c5780639525c0cc146107a35780639bc5689d14610364578063a003651d146107c2578063a05ea6e4146107df578063b2449d651461080557610265565b806372f702f3146106b957806379a1c1f6146106dd57806380f5e0a11461072057806388737b5e1461073d5780638894c41b1461077757610265565b806332ed5b12116101e65780635142bc1e116101aa5780635142bc1e1461061957806351d997b21461062157806361d585da146106295780636359036b1461066a578063707437681461069657610265565b806332ed5b121461046a578063359afa49146105185780633c13381814610550578063404748731461056d578063488c65fc1461058a57610265565b80631702ef0c1161022d5780631702ef0c146103dd57806321b4b3dc146103fa5780632d598e58146104025780632daedd521461042557806330ca0a531461046257610265565b8063025068041461026a57806307b4e1e3146102f55780630d48344214610364578063119ce91b1461036c57806316db5172146103b1575b600080fd5b6102876004803603602081101561028057600080fd5b503561097c565b604080519d8e5260208e019c909c528c8c019a909a5260608c019890985260808b019690965260a08a019490945260c089019290925260e0880152610100870152610120860152610140850152610160840152600160a060020a031661018083015251908190036101a00190f35b610352600480360361018081101561030c57600080fd5b81019080806101600190600b806020026040519081016040528092919082600b60200280828437600092019190915250919450505035600160a060020a031690506109ec565b60408051918252519081900360200190f35b610352610b09565b6103986004803603604081101561038257600080fd5b5080359060200135600160a060020a0316610b0e565b6040805192835260208301919091528051918290030190f35b610398600480360360408110156103c757600080fd5b5080359060200135600160a060020a0316610b71565b610352600480360360208110156103f357600080fd5b5035610ba2565b610352610bb4565b6103526004803603604081101561041857600080fd5b5080359060200135610bba565b61044e6004803603606081101561043b57600080fd5b5080359060208101359060400135610c07565b604080519115158252519081900360200190f35b610352610c1d565b6104876004803603602081101561048057600080fd5b5035610cfd565b604080518e8152600160a060020a038e1660208201529081018c60068111156104ac57fe5b60ff168152602081019b909b5250600160a060020a039098166040808b019190915260608a0197909752608089019590955260a088019390935260c087019190915260e08601526101008501526101208401529015156101408301525190819003610160019350915050f35b61044e6004803603608081101561052e57600080fd5b5080359060208101359060408101359060600135600160a060020a0316610d6b565b6103526004803603602081101561056657600080fd5b5035610e89565b6103526004803603602081101561058357600080fd5b5035610e9e565b61044e600480360360c08110156105a057600080fd5b8135916020810135916040820135916060810135916080820135919081019060c0810160a08201356401000000008111156105da57600080fd5b8201836020820111156105ec57600080fd5b8035906020019184600183028401116401000000008311171561060e57600080fd5b509092509050610f0e565b6103986111fb565b61044e611203565b6106466004803603602081101561063f57600080fd5b5035611209565b6040518082600681111561065657fe5b60ff16815260200191505060405180910390f35b6103986004803603604081101561068057600080fd5b5080359060200135600160a060020a0316611229565b610352600480360360408110156106ac57600080fd5b50803590602001356114d8565b6106c16114f9565b60408051600160a060020a039092168252519081900360200190f35b6106fa600480360360208110156106f357600080fd5b5035611508565b604080519485526020850193909352838301919091526060830152519081900360800190f35b61044e6004803603602081101561073657600080fd5b503561154b565b6103526004803603608081101561075357600080fd5b50803590602081013590600160a060020a0360408201358116916060013516611688565b610352600480360361018081101561078e57600080fd5b50600160a060020a0361016082013516611a9a565b6107c0600480360360208110156107b957600080fd5b5035611ee0565b005b610352600480360360208110156107d857600080fd5b5035611ef9565b610352600480360360208110156107f557600080fd5b5035600160a060020a0316611eff565b610352611f11565b6103526004803603604081101561082357600080fd5b5080359060200135611f16565b6106c16004803603602081101561084657600080fd5b5035611f37565b6103526004803603602081101561086357600080fd5b5035611f52565b6103526004803603602081101561088057600080fd5b5035611f64565b61044e6004803603602081101561089d57600080fd5b50356121d5565b6108c1600480360360208110156108ba57600080fd5b50356121e0565b6040518082606080838360005b838110156108e65781810151838201526020016108ce565b5050505090500191505060405180910390f35b6108c16004803603604081101561090f57600080fd5b5080359060200135600160a060020a031661222f565b6103526004803603602081101561093b57600080fd5b50356129fc565b61044e6004803603602081101561095857600080fd5b5035612a07565b6103526004803603602081101561097557600080fd5b5035612a2e565b600060208190529081526040902080546001820154600283015460038401546004850154600586015460068701546007880154600889015460098a0154600a8b0154600b8c0154600c909c01549a9b999a98999798969795969495939492939192909190600160a060020a03168d565b60008281602002015183600160200201518460026020020151856003602002015186600460200201518760056020020151886006602002015189600760200201518a600860200201518b600960200201518c600a6020020151604051602001808c81526020018b81526020018a81526020018981526020018881526020018781526020018681526020018581526020018481526020018381526020018281526020019b50505050505050505050505060405160208183030381529060405280519060200120826040516020018083815260200182600160a060020a0316600160a060020a03166c01000000000000000000000000028152601401925050506040516020818303038152906040528051906020012090505b92915050565b600281565b600080610b19614204565b5050506000918252600160208181526040808520600160a060020a039490941685526011909301815292829020825160608101845281548082529282015494810185905260029091015460ff16151592019190915291565b6000918252600160208181526040808520600160a060020a0394909416855260139093019052912080549101549091565b60009081526001602052604090205490565b60055481565b6000818152600260209081526040808320548584529183905282206005810154821115610be957806005015491505b6004810154610bfe908363ffffffff612a4016565b95945050505050565b6000610c1584848433612a89565b949350505050565b604080517f616464726573732047656e6573697350726f746f636f6c4164647265737300006020808301919091527f627974657333322050726f706f73616c49640000000000000000000000000000603e8301527f75696e7432353620566f7465000000000000000000000000000000000000000060508301527f75696e7432353620416d6f756e74546f5374616b650000000000000000000000605c8301527f75696e74323536204e6f6e63650000000000000000000000000000000000000060718301528251605e818403018152607e909201909252805191012081565b600160208190526000918252604090912080549181015460028201546003830154600484015460058501546006860154600787015460088801546009890154600a8a0154600e909a0154600160a060020a03808b169b60ff60a060020a909c048c169b99909116989091168d565b600084610d7781612ee3565b1515610d8257600080fd5b6000868152600160205260409020610d98614228565b5060058082015460009081526020818152604080832081516101a0810183528154815260018201549381019390935260028101549183019190915260038101546060830152600481015460808301529283015460a0820152600683015460c0820152600783015460e082015260088301546101008201526009830154610120820152600a830154610140820152600b830154610160820152600c90920154600160a060020a0316610180830181905215610e6d57610180820151600160a060020a03163314610e6657600080fd5b5084610e70565b50335b610e7c89828a8a612f56565b9998505050505050505050565b60009081526001602052604090206002015490565b6000818152600160205260408120600a01546105dc908290610ec790839063ffffffff6135ff16565b600085815260016020818152604080842092845260129092019052902054909150610c1590600a840290610f0290849063ffffffff61361516565b9063ffffffff61364016565b60008084600214156110715750604080517f616464726573732047656e6573697350726f746f636f6c4164647265737300006020808301919091527f627974657333322050726f706f73616c49640000000000000000000000000000603e8301527f75696e7432353620566f7465000000000000000000000000000000000000000060508301527f75696e7432353620416d6f756e74546f5374616b650000000000000000000000605c8301527f75696e74323536204e6f6e63650000000000000000000000000000000000000060718301528251605e818403018152607e830184528051908201206c010000000000000000000000003002609e84015260b283018c905260d283018b905260f283018a90526101128084018a90528451808503909101815261013284018552805190830120610152840191909152610172808401919091528351808403909101815261019290920190925280519101206110ce565b604080516c010000000000000000000000003002602080830191909152603482018c9052605482018b9052607482018a905260948083018a90528351808403909101815260b490920190925280519101206110cb90613664565b90505b600061111885858080601f016020809104026020016040519081016040528093929190818152602001838380828437600092019190915250869392505063ffffffff6136b5169050565b9050600160a060020a038116151561117a576040805160e560020a62461bcd02815260206004820152601a60248201527f7374616b657220616464726573732063616e6e6f742062652030000000000000604482015290519081900360640190fd5b600160a060020a038116600090815260076020526040902054871461119e57600080fd5b600160a060020a0381166000908152600760205260409020546111c890600163ffffffff61378b16565b600160a060020a0382166000908152600760205260409020556111ed8a8a8a84612a89565b9a9950505050505050505050565b600160029091565b60005b90565b6000908152600160208190526040909120015460a060020a900460ff1690565b600082815260016020526040812081906002600182015460a060020a900460ff16600681111561125557fe5b1461125f57600080fd5b6002808201546000908152601283016020908152604080832054600160a060020a0389168452601386019092528220928301549092911080156112a6575060028301548154145b80156112b6575060018360020154145b80156112c157508115155b156112df578183600701548260020154028115156112db57fe5b0493505b831580159061138d57506001830154600654604080517f6b8eb403000000000000000000000000000000000000000000000000000000008152600160a060020a039283166004820152602481018b9052905187939290921691636b8eb40391604480820192602092909190829003018186803b15801561135e57600080fd5b505afa158015611372573d6000803e3d6000fd5b505050506040513d602081101561138857600080fd5b505110155b156114ce576000600282015560068301546113ae908563ffffffff61379d16565b60068085019190915560018401549054604080517fbea75f28000000000000000000000000000000000000000000000000000000008152600160a060020a039283166004820152898316602482015260448101889052606481018b90529051919092169163bea75f289160848083019260209291908290030181600087803b15801561143957600080fd5b505af115801561144d573d6000803e3d6000fd5b505050506040513d602081101561146357600080fd5b5051151561147057600080fd5b825460009081526003602090815260409182902054825187815292519697508796600160a060020a03808b16949216928b927fb4a37163ec93e05e09b62e52f7f2ea8cfde431802edede7dfebe53d2ad969dbb929081900390910190a45b5050509250929050565b60009182526001602090815260408084209284526012909201905290205490565b600654600160a060020a031681565b6000908152600160208181526040808420838552601081018352818520546002808752838720549587526012909201909352818520549085529320549093919291565b600061155561429a565b60008381526001602081815260409283902083516101c0810185528154815292810154600160a060020a03811692840192909252919283019060a060020a900460ff1660068111156115a357fe5b60068111156115ae57fe5b815260028201546020820152600380830154600160a060020a0316604080840191909152600484015460608085019190915260058501546080850152600685015460a0850152600785015460c0850152600885015460e08501526009850154610100850152600a8501546101208501528151908101918290526101409093019291600b85019182845b815481526020019060010190808311611637575050509183525050600e919091015460ff16151560209091015260c0810151815191925061167791610bba565b611680846137b2565b119392505050565b6000838152602081905260408120600b015442116116f0576040805160e560020a62461bcd02815260206004820152600e60248201527f6e6f742061637469766520796574000000000000000000000000000000000000604482015290519081900360640190fd5b6000848152602081905260409020546032111561170c57600080fd5b600554604080516c010000000000000000000000003002602080830191909152603480830185905283518084039091018152605490920190925280519101209061175d90600163ffffffff61378b16565b60055561176861429a565b336020828101829052604080516c0100000000000000000000000093840281840152600160a060020a03888116909402603482015281516028818303018152604890910182528051908301208452600381850181905261018085015142905260008a815280845282812060029081015460a08801528a86166080880152606087015260c086018b905285518152925290205416151561187a57600160a060020a03841615156118435780516000908152600360205260409020805473ffffffffffffffffffffffffffffffffffffffff19163317905561187a565b80516000908152600360205260409020805473ffffffffffffffffffffffffffffffffffffffff1916600160a060020a0386161790555b8051600090815260046020908152604080832054898452918390528220600a01546118b191606491610f029163ffffffff61361516565b6000888152602081905260409020600901549091506118d790829063ffffffff61380716565b60e08301526000838152600160208181526040928390208551815590850151918101805473ffffffffffffffffffffffffffffffffffffffff1916600160a060020a03909316929092178083559285015185939192909160a060020a60ff02191660a060020a83600681111561194957fe5b02179055506060820151600282015560808201516003808301805473ffffffffffffffffffffffffffffffffffffffff1916600160a060020a039093169290921790915560a0830151600483015560c0830151600583015560e08301516006830155610100830151600783015561012083015160088301556101408301516009830155610160830151600a8301556101808301516119ec91600b8401919061431b565b506101a09190910151600e909101805460ff191691151591909117905560e0820151600084815260016020908152604080832060028085526012909101835281842094909455855183526003825291829020548251938452600160a060020a038a8116928501929092528383018b9052915191169185917f75b4ff136cc5de5957574c797de3334eb1c141271922b825eb071e0487ba2c5c916060908290030190a350909695505050505050565b60006064833511801590611ab057506032833510155b1515611af05760405160e560020a62461bcd0281526004018080602001828103825260298152602001806143f36029913960400191505060405180910390fd5b613e80608084013511801590611b0b57506103e86080840135115b1515611b61576040805160e560020a62461bcd02815260206004820152601e60248201527f31303030203c207468726573686f6c64436f6e7374203c3d2031363030300000604482015290519081900360640190fd5b606460e08401351115611bbe576040805160e560020a62461bcd02815260206004820181905260248201527f766f7465727352657075746174696f6e4c6f7373526174696f203c3d20313030604482015290519081900360640190fd5b60a083013560408401351015611c085760405160e560020a62461bcd02815260040180806020018281038252602b8152602001806143c8602b913960400191505060405180910390fd5b600061010084013511611c65576040805160e560020a62461bcd02815260206004820152601e60248201527f6d696e696d756d44616f426f756e74792073686f756c64206265203e20300000604482015290519081900360640190fd5b600061012084013511611cc2576040805160e560020a62461bcd02815260206004820152601c60248201527f64616f426f756e7479436f6e73742073686f756c64206265203e203000000000604482015290519081900360640190fd5b6000611cf884600b806020026040519081016040528092919082600b602002808284376000920191909152508691506109ec9050565b905060ac60026107d05b613e80811015611d4c57608087013581108015611d26575060028102608088013511155b15611d3e578183811515611d3657fe5b049250611d4c565b600190910190600202611d02565b50604080516101a0810182528735815260208089013590820152878201359181019190915260608088013590820152608080820190611dad908901357affffffffffffffffffffffffffffffffffffffffffffffffffffff166103e8613817565b815260208101849052604001876005602090810291909101358252018760066020908102919091013582520187600760209081029190910135825201876008602090810291909101358252018760096020908102919091013582520187600a602090810291909101358252600160a060020a03978816918101919091526000858152808252604090819020835181559183015160018301558201516002820155606082015160038201556080820151600482015560a0820151600582015560c0820151600682015560e0820151600782015561010082015160088201556101208201516009820155610140820151600a820155610160820151600b82015561018090910151600c909101805473ffffffffffffffffffffffffffffffffffffffff19169190961617909455509392505050565b80611eea81612ee3565b1515611ef557600080fd5b5050565b50600290565b60076020526000908152604090205481565b600181565b6000918252600160209081526040808420928452600f909201905290205490565b600360205260009081526040902054600160a060020a031681565b60046020526000908152604090205481565b60008181526001602052604081206005600182015460a060020a900460ff166006811115611f8e57fe5b1480611fb357506006600182015460a060020a900460ff166006811115611fb157fe5b145b1515611ff35760405160e560020a62461bcd02815260040180806020018281038252603381526020018061441c6033913960400191505060405180910390fd5b611ffc8361384e565b1515612052576040805160e560020a62461bcd02815260206004820152601760248201527f70726f706f73616c206e65656420746f20657870697265000000000000000000604482015290519081900360640190fd5b61207e612071600b83016001015460048401549063ffffffff61378b16565b429063ffffffff61379d16565b600a82015561208c83610e9e565b60088201549092506120a4908363ffffffff61379d16565b6008820155600654604080517fa9059cbb000000000000000000000000000000000000000000000000000000008152336004820152602481018590529051600160a060020a039092169163a9059cbb916044808201926020929091908290030181600087803b15801561211657600080fd5b505af115801561212a573d6000803e3d6000fd5b505050506040513d602081101561214057600080fd5b50511515612198576040805160e560020a62461bcd02815260206004820152601d60248201527f7472616e7366657220746f206d73672e73656e646572206661696c6564000000604482015290519081900360640190fd5b604080518381529051339185917f7468017f6ff596af88244327e88fe691ac48cc1db88b033d11c335f2c7ccdd039181900360200190a350919050565b6000610b0382612ee3565b6121e8614359565b60008281526001602052604090819020815160608101909252600b0160038282826020028201915b8154815260200190600101908083116122105750505050509050919050565b612237614359565b60008381526001602052604090206002600182015460a060020a900460ff16600681111561226157fe5b1480612285575060018082015460a060020a900460ff16600681111561228357fe5b145b15156122c55760405160e560020a62461bcd02815260040180806020018281038252602d81526020018061439b602d913960400191505060405180910390fd5b6122cd614228565b5060058082015460009081526020818152604080832081516101a081018352815481526001820154818501526002808301548285015260038301546060830152600483015460808301529582015460a0820152600682015460c0820152600782015460e082015260088201546101008201526009820154610120820152600a820154610140820152600b820154610160820152600c90910154600160a060020a0390811661018083015288168452601386018352818420948601548452601286019092528220549092916123d96123a389610e9e565b6001600090815260128801602052604080822054600283529120546123cd9163ffffffff61378b16565b9063ffffffff61379d16565b90506000836001015411156124aa5760018086015460a060020a900460ff16600681111561240357fe5b141561241557600183015486526124a2565b6002850154835414156124a25782546001141561247e57808560070154101561247957600061245186600701548361379d90919063ffffffff16565b90508261246b82866001015461361590919063ffffffff16565b81151561247457fe5b048752505b6124a2565b60018301548290612495908363ffffffff61361516565b81151561249e57fe5b0486525b600060018401555b600e85015460ff161580156124da57508454600090815260036020526040902054600160a060020a038881169116145b80156124ff575060018086015460a060020a900460ff1660068111156124fc57fe5b14155b801561250f575060028560020154145b15612562576007850154612550906123cd84612531838663ffffffff61361516565b81151561253a57fe5b048960005b60200201519063ffffffff61378b16565b8652600e8501805460ff191660011790555b600160a060020a038716600090815260118601602052604090206001810154158015906125935750600281015460ff165b156126da5760018087015460a060020a900460ff1660068111156125b357fe5b14156125eb5760646125d7866101000151836001015461361590919063ffffffff16565b8115156125e057fe5b0460208801526126d2565b8054600287015414156126d2576000600187600201541415612620575060026000908152601087016020526040902054612635565b50600160009081526010870160205260409020545b606461264f8761010001518361361590919063ffffffff16565b81151561265857fe5b6002890154600090815260108a01602052604090205460018501549290910492506126cb9161268d908463ffffffff61361516565b81151561269657fe5b0460646126b5896101000151866001015461361590919063ffffffff16565b8115156126be57fe5b049063ffffffff61378b16565b6020890152505b600060018201555b6003860154600160a060020a0389811691161480156126fd575060018660020154145b801561271557506003860154600160a060020a031615155b156127445760e0850151604088015260038601805473ffffffffffffffffffffffffffffffffffffffff191690555b8651156128af578651600887015461275b9161379d565b60088701556006548751604080517fa9059cbb000000000000000000000000000000000000000000000000000000008152600160a060020a038c8116600483015260248201939093529051919092169163a9059cbb9160448083019260209291908290030181600087803b1580156127d257600080fd5b505af11580156127e6573d6000803e3d6000fd5b505050506040513d60208110156127fc57600080fd5b50511515612854576040805160e560020a62461bcd02815260206004820152601e60248201527f7472616e7366657220746f2062656e6566696369617279206661696c65640000604482015290519081900360640190fd5b855460009081526003602090815260409182902054895183519081529251600160a060020a038c8116949216928d927f6d26871c9f457d104b2122485f659f126f7a0cf6938cf20482c03f49794a2fbf929081900390910190a45b60408701516128c09088600161253f565b156129f0576001860154600160a060020a031663d29b5d2f6128eb89600260200201518a600161253f565b8a8c6040518463ffffffff167c01000000000000000000000000000000000000000000000000000000000281526004018084815260200183600160a060020a0316600160a060020a031681526020018281526020019350505050602060405180830381600087803b15801561295f57600080fd5b505af1158015612973573d6000803e3d6000fd5b505050506040513d602081101561298957600080fd5b50508554600090815260036020526040902054600160a060020a03808a1691168a7f7419b736daacf66d5c1645948c956fca2b83be1e2e02d486d65713f289d683b86129de8b600260200201518c600161253f565b60408051918252519081900360200190a45b50505050505092915050565b6000610b03826137b2565b600081612a1381612ee3565b1515612a1e57600080fd5b612a278361384e565b9392505050565b60026020526000908152604090205481565b60008282650100000000005b8115610bfe578160011660011415612a6b57612a688184614170565b90505b6002909104908115612a8457612a818384614170565b92505b612a4c565b600060028411158015612a9c5750600084115b1515612af2576040805160e560020a62461bcd02815260206004820152601060248201527f77726f6e6720766f74652076616c756500000000000000000000000000000000604482015290519081900360640190fd5b60008311612b4a576040805160e560020a62461bcd02815260206004820152601b60248201527f7374616b696e6720616d6f756e742073686f756c64206265203e300000000000604482015290519081900360640190fd5b612b538561384e565b15612b6057506001610c15565b60008581526001602052604090206004600182015460a060020a900460ff166006811115612b8a57fe5b14158015612bb257506003600182015460a060020a900460ff166006811115612baf57fe5b14155b15612bc1576000915050610c15565b600160a060020a0383166000908152601382016020526040812060018101549091108015612bf0575080548614155b15612c0057600092505050610c15565b600654604080517f23b872dd000000000000000000000000000000000000000000000000000000008152600160a060020a038781166004830152306024830152604482018990529151889392909216916323b872dd916064808201926020929091908290030181600087803b158015612c7857600080fd5b505af1158015612c8c573d6000803e3d6000fd5b505050506040513d6020811015612ca257600080fd5b50511515612cfa576040805160e560020a62461bcd02815260206004820152601960248201527f6661696c207472616e736665722066726f6d207374616b657200000000000000604482015290519081900360640190fd5b6008830154612d0f908263ffffffff61378b16565b60088401556001820154612d29908263ffffffff61378b16565b600183018190557001000000000000000000000000000000001015612d98576040805160e560020a62461bcd02815260206004820152601a60248201527f7374616b696e6720616d6f756e7420697320746f6f2068696768000000000000604482015290519081900360640190fd5b6006830154612dbf907001000000000000000000000000000000009063ffffffff61379d16565b60088401541115612e1a576040805160e560020a62461bcd02815260206004820152601860248201527f746f74616c207374616b657320697320746f6f20686967680000000000000000604482015290519081900360640190fd5b6001871415612e3e576002820154612e38908263ffffffff61378b16565b60028301555b8682556000878152601284016020526040902054612e6390829063ffffffff61378b16565b60008881526012850160209081526040808320939093558554825260038152908290205482518a81529182018990528251600160a060020a03808a16949216928c927fd0239d7d4acf51def4507fa173be466927de5d75d8b10d840cd6994d6e10231092918290030190a4612ed78861384e565b98975050505050505050565b60008181526001602081905260408220015460a060020a900460ff166004816006811115612f0d57fe5b1480612f2457506005816006811115612f2257fe5b145b80612f3a57506006816006811115612f3857fe5b145b80612a2757506003816006811115612f4e57fe5b149392505050565b600060028311158015612f695750600083115b1515612fbf576040805160e560020a62461bcd02815260206004820152600e60248201527f30203c205f766f7465203c3d2032000000000000000000000000000000000000604482015290519081900360640190fd5b612fc88561384e565b15612fd557506001610c15565b612fdd614228565b506000858152600160208181526040808420600580820154865285845282862083516101a0810185528154815281870154818701526002820154818601526003820154606082015260048083015460808301529282015460a0820152600682015460c0820152600782015460e082015260088201546101008201526009820154610120820152600a820154610140820152600b820154610160820152600c90910154600160a060020a039081166101808301528c88528686529583015484517f9588378e0000000000000000000000000000000000000000000000000000000081528c881693810193909352602483018d905293519096929592949390921692639588378e92604480840193829003018186803b1580156130fd57600080fd5b505afa158015613111573d6000803e3d6000fd5b505050506040513d602081101561312757600080fd5b5051905060008111613183576040805160e560020a62461bcd02815260206004820152601b60248201527f5f766f746572206d75737420686176652072657075746174696f6e0000000000604482015290519081900360640190fd5b848110156131db576040805160e560020a62461bcd02815260206004820152601260248201527f72657075746174696f6e203e3d205f7265700000000000000000000000000000604482015290519081900360640190fd5b848015156131e65750805b600160a060020a038816600090815260118401602052604090206001015415613216576000945050505050610c15565b6000878152600f8401602052604090205461323890829063ffffffff61378b16565b6000888152600f850160205260408082208390556002860154825281205490899052108061329057506002808401546000908152600f8501602052604080822054928252902054148015613290575060018360020154145b156133b3576005600184015460a060020a900460ff1660068111156132b157fe5b1480156132d1575060c0840151604085015103600b840160010154420310155b806132f557506006600184015460a060020a900460ff1660068111156132f357fe5b145b156133ab576006600184015460a060020a900460ff16600681111561331657fe5b146133a45760c0840151600484015560018301805460a060020a60ff0219167406000000000000000000000000000000000000000017908190556040518a917f21aca7f0285ccddeca2935074d3e36b5ab8fea0327f84cbbf12cf1b6d1a749f99160a060020a90910460ff16908082600681111561339057fe5b60ff16815260200191505060405180910390a25b42600c8401555b600283018790555b60408051606081018252888152602081018390529081016004600186015460a060020a900460ff1660068111156133e657fe5b148061340b57506003600186015460a060020a900460ff16600681111561340957fe5b145b15159052600160a060020a0389166000908152601185016020908152604091829020835181559083015160018201559101516002909101805460ff19169115159190911790556004600184015460a060020a900460ff16600681111561346d57fe5b148061349257506003600184015460a060020a900460ff16600681111561349057fe5b145b1561359a5760008781526010840160205260409020546134b990829063ffffffff61378b16565b60008881526010850160205260408120919091556101008501516064906134e6908463ffffffff61361516565b8115156134ef57fe5b6001860154604080517ff81f8bf60000000000000000000000000000000000000000000000000000000081529390920460048401819052600160a060020a038d81166024860152604485018f9052925190945091169163f81f8bf69160648083019260209291908290030181600087803b15801561356c57600080fd5b505af1158015613580573d6000803e3d6000fd5b505050506040513d602081101561359657600080fd5b5050505b82546000908152600360209081526040918290205482518a81529182018490528251600160a060020a03808d16949216928d927f066c061a3792cb3eb64a441a928655fcbafb4a54b49725fe9cd2951df5e7189e92918290030190a4610e7c8961384e565b600081831061360e5781612a27565b5090919050565b600082151561362657506000610b03565b82820282848281151561363557fe5b0414612a2757600080fd5b600080821161364e57600080fd5b6000828481151561365b57fe5b04949350505050565b604080517f19457468657265756d205369676e6564204d6573736167653a0a333200000000602080830191909152603c8083019490945282518083039094018452605c909101909152815191012090565b600080600080845160411415156136d25760009350505050610b03565b50505060208201516040830151606084015160001a601b60ff821610156136f757601b015b8060ff16601b1415801561370f57508060ff16601c14155b156137205760009350505050610b03565b6040805160008152602080820180845289905260ff8416828401526060820186905260808201859052915160019260a0808401939192601f1981019281900390910190855afa158015613777573d6000803e3d6000fd5b505050602060405103519350505050610b03565b600082820183811015612a2757600080fd5b6000828211156137ac57600080fd5b50900390565b60008181526001602081815260408084206002855260128101909252808420549284528320549091612a27917affffffffffffffffffffffffffffffffffffffffffffffffffffff169063ffffffff61381716565b60008183101561360e5781612a27565b6000612a277affffffffffffffffffffffffffffffffffffffffffffffffffffff80851665010000000000908102918516026141e7565b60008161385a81612ee3565b151561386557600080fd5b600083815260016020526040902061387b614228565b506005808201546000908152602081815260409182902082516101a0810184528154815260018201549281019290925260028101549282019290925260038201546060820152600482015460808201529181015460a0830152600681015460c0830152600781015460e083015260088101546101008301526009810154610120830152600a810154610140830152600b810154610160830152600c0154600160a060020a031661018082015261392f61429a565b604080516101c081018252845481526001850154600160a060020a0381166020830152909185919083019060a060020a900460ff16600681111561396f57fe5b600681111561397a57fe5b815260028201546020820152600380830154600160a060020a0316604080840191909152600484015460608085019190915260058501546080850152600685015460a0850152600785015460c0850152600885015460e08501526009850154610100850152600a8501546101208501528151908101918290526101409093019291600b85019182845b815481526020019060010190808311613a03575050509183525050600e919091015460ff1615156020918201526001850154604080517fb551c373000000000000000000000000000000000000000000000000000000008152600481018b90529051939450600093600160a060020a039092169263b551c37392602480840193829003018186803b158015613a9757600080fd5b505afa158015613aab573d6000803e3d6000fd5b505050506040513d6020811015613ac157600080fd5b5051835160028601546000908152600f87016020526040812054929350606484049091029181908190841015613b71576003600189015460a060020a900460ff166006811115613b0d57fe5b1415613b1c5760019250613b4c565b6004600189015460a060020a900460ff166006811115613b3857fe5b1415613b475760039250613b4c565b600592505b6001880180546002919060a060020a60ff02191660a060020a835b0217905550613dfc565b6003600189015460a060020a900460ff166006811115613b8d57fe5b1415613c26576020870151600b890154420310613bcb5760018801805460a060020a60ff02191660a060020a17905560028089018190559250613c26565b613bdd88600501548960000154610bba565b905080613be98c6137b2565b1115613c265760018801805460a060020a60ff0219167404000000000000000000000000000000000000000017905542600d890155600988018190555b6004600189015460a060020a900460ff166006811115613c4257fe5b1415613dfc57613c5a88600501548960000154610bba565b6060880151909150600b890160020154420310613d595780613c7b8c6137b2565b1115613d355787546000908152600260205260409020546110001115613d30576001888101805460a060020a60ff0219167405000000000000000000000000000000000000000017905542600c8a01558854600090815260026020818152604080842080549095019094558b54835260048152838320548282528484205492845260128d01909152929091205491935090839003811515613d1857fe5b89546000908152600460205260409020919005830190555b613d54565b6001880180546003919060a060020a60ff02191660a060020a83613b67565b613dfc565b6000613d648c6137b2565b60098a0154909150613d7c908363ffffffff6135ff16565b8111613db05760018901805460a060020a60ff02191674030000000000000000000000000000000000000000179055613dfa565b8089600901541115613dfa57600989018290556040805183815290518d917fad767d61af51c7895fa3cc0497dde01afb610c74e55ee4d8a71fa5e3ee136d54919081900360200190a25b505b6005600189015460a060020a900460ff166006811115613e1857fe5b1480613e3d57506006600189015460a060020a900460ff166006811115613e3b57fe5b145b15613e81576004880154600c890154420310613e815760018801805460a060020a60ff02191674020000000000000000000000000000000000000000179055600492505b6000836005811115613e8f57fe5b146140ca576004836005811115613ea257fe5b1480613eb957506005836005811115613eb757fe5b145b15613f78578551600090815260026020526040902054613ee090600163ffffffff61379d16565b865160009081526002602052604080822092909255875181522054801515613f18578854600090815260046020526040812055613f76565b88546000908152600460209081526040808320546002845260128d01909252909120549093508190613f57906123cd866001850163ffffffff61361516565b811515613f6057fe5b8a54600090815260046020526040902091900490555b505b87546000908152600360209081526040918290205460028b015483519081529182018890528251600160a060020a03909116928e927f37471b9c9d295ffb1309ad070b8964700bfb7b555e8e8292d0b6cbc7dba35d10929081900390910190a38a7f46a713b994c752c68fbefa9048bec9a0010cc7d933ad95a3c3dbb25931a167e7846040518082600581111561400b57fe5b60ff16815260200191505060405180910390a260018801546002890154604080517f9d4c162d000000000000000000000000000000000000000000000000000000008152600481018f9052602481019290925251600160a060020a0390921691639d4c162d916044808201926020929091908290030181600087803b15801561409357600080fd5b505af11580156140a7573d6000803e3d6000fd5b505050506040513d60208110156140bd57600080fd5b5050600688015460078901555b600188015460a060020a900460ff1660068111156140e457fe5b866040015160068111156140f457fe5b14614151578a7f21aca7f0285ccddeca2935074d3e36b5ab8fea0327f84cbbf12cf1b6d1a749f98960010160149054906101000a900460ff166040518082600681111561413d57fe5b60ff16815260200191505060405180910390a25b600083600581111561415f57fe5b14159b9a5050505050505050505050565b600082820282848281151561418157fe5b04146141d7576040805160e560020a62461bcd02815260206004820152601560248201527f5265616c4d617468206d756c206f766572666c6f770000000000000000000000604482015290519081900360640190fd5b6501000000000090049392505050565b6000816501000000000084028115156141fc57fe5b049392505050565b60606040519081016040528060008152602001600081526020016000151581525090565b6101a0604051908101604052806000815260200160008152602001600081526020016000815260200160008152602001600081526020016000815260200160008152602001600081526020016000815260200160008152602001600081526020016000600160a060020a031681525090565b604080516102008101825260008082526020820181905290918201908152602001600081526020016000600160a060020a031681526020016000815260200160008019168152602001600081526020016000815260200160008152602001600081526020016000815260200161430e614359565b8152600060209091015290565b8260038101928215614349579160200282015b8281111561434957825182559160200191906001019061432e565b50614355929150614378565b5090565b6060604051908101604052806003906020820280388339509192915050565b61120691905b80821115614355576000815560010161437e565b6000903b119056fe50726f706f73616c2073686f756c64206265204578656375746564206f722045787069726564496e5175657565626f6f73746564566f7465506572696f644c696d6974203e3d207175696574456e64696e67506572696f643530203c3d20717565756564566f7465526571756972656450657263656e74616765203c3d2031303070726f706f73616c20737461746520696e206e6f7420426f6f73746564206e6f72205175696574456e64696e67506572696f64a165627a7a72305820b245ca9a6f2d7b8aabb67d17c023f7cb514e1c60360315fc0729c044b776d3be0029000000000000000000000000543ff227f64aa17ea132bf9886cab5db55dcaddf

Deployed Bytecode

0x608060405234801561001057600080fd5b5060043610610265576000357c01000000000000000000000000000000000000000000000000000000009004806372f702f311610158578063b4512913116100d5578063c8f526e811610099578063c8f526e8146108a4578063cc3bf9e9146108f9578063e5af18c514610925578063e751f27114610942578063fb6c0cbb1461095f57610265565b8063b45129131461080d578063ba51b14e14610830578063bb5a05ed1461084d578063beda80151461086a578063c08351061461088757610265565b80639525c0cc1161011c5780639525c0cc146107a35780639bc5689d14610364578063a003651d146107c2578063a05ea6e4146107df578063b2449d651461080557610265565b806372f702f3146106b957806379a1c1f6146106dd57806380f5e0a11461072057806388737b5e1461073d5780638894c41b1461077757610265565b806332ed5b12116101e65780635142bc1e116101aa5780635142bc1e1461061957806351d997b21461062157806361d585da146106295780636359036b1461066a578063707437681461069657610265565b806332ed5b121461046a578063359afa49146105185780633c13381814610550578063404748731461056d578063488c65fc1461058a57610265565b80631702ef0c1161022d5780631702ef0c146103dd57806321b4b3dc146103fa5780632d598e58146104025780632daedd521461042557806330ca0a531461046257610265565b8063025068041461026a57806307b4e1e3146102f55780630d48344214610364578063119ce91b1461036c57806316db5172146103b1575b600080fd5b6102876004803603602081101561028057600080fd5b503561097c565b604080519d8e5260208e019c909c528c8c019a909a5260608c019890985260808b019690965260a08a019490945260c089019290925260e0880152610100870152610120860152610140850152610160840152600160a060020a031661018083015251908190036101a00190f35b610352600480360361018081101561030c57600080fd5b81019080806101600190600b806020026040519081016040528092919082600b60200280828437600092019190915250919450505035600160a060020a031690506109ec565b60408051918252519081900360200190f35b610352610b09565b6103986004803603604081101561038257600080fd5b5080359060200135600160a060020a0316610b0e565b6040805192835260208301919091528051918290030190f35b610398600480360360408110156103c757600080fd5b5080359060200135600160a060020a0316610b71565b610352600480360360208110156103f357600080fd5b5035610ba2565b610352610bb4565b6103526004803603604081101561041857600080fd5b5080359060200135610bba565b61044e6004803603606081101561043b57600080fd5b5080359060208101359060400135610c07565b604080519115158252519081900360200190f35b610352610c1d565b6104876004803603602081101561048057600080fd5b5035610cfd565b604080518e8152600160a060020a038e1660208201529081018c60068111156104ac57fe5b60ff168152602081019b909b5250600160a060020a039098166040808b019190915260608a0197909752608089019590955260a088019390935260c087019190915260e08601526101008501526101208401529015156101408301525190819003610160019350915050f35b61044e6004803603608081101561052e57600080fd5b5080359060208101359060408101359060600135600160a060020a0316610d6b565b6103526004803603602081101561056657600080fd5b5035610e89565b6103526004803603602081101561058357600080fd5b5035610e9e565b61044e600480360360c08110156105a057600080fd5b8135916020810135916040820135916060810135916080820135919081019060c0810160a08201356401000000008111156105da57600080fd5b8201836020820111156105ec57600080fd5b8035906020019184600183028401116401000000008311171561060e57600080fd5b509092509050610f0e565b6103986111fb565b61044e611203565b6106466004803603602081101561063f57600080fd5b5035611209565b6040518082600681111561065657fe5b60ff16815260200191505060405180910390f35b6103986004803603604081101561068057600080fd5b5080359060200135600160a060020a0316611229565b610352600480360360408110156106ac57600080fd5b50803590602001356114d8565b6106c16114f9565b60408051600160a060020a039092168252519081900360200190f35b6106fa600480360360208110156106f357600080fd5b5035611508565b604080519485526020850193909352838301919091526060830152519081900360800190f35b61044e6004803603602081101561073657600080fd5b503561154b565b6103526004803603608081101561075357600080fd5b50803590602081013590600160a060020a0360408201358116916060013516611688565b610352600480360361018081101561078e57600080fd5b50600160a060020a0361016082013516611a9a565b6107c0600480360360208110156107b957600080fd5b5035611ee0565b005b610352600480360360208110156107d857600080fd5b5035611ef9565b610352600480360360208110156107f557600080fd5b5035600160a060020a0316611eff565b610352611f11565b6103526004803603604081101561082357600080fd5b5080359060200135611f16565b6106c16004803603602081101561084657600080fd5b5035611f37565b6103526004803603602081101561086357600080fd5b5035611f52565b6103526004803603602081101561088057600080fd5b5035611f64565b61044e6004803603602081101561089d57600080fd5b50356121d5565b6108c1600480360360208110156108ba57600080fd5b50356121e0565b6040518082606080838360005b838110156108e65781810151838201526020016108ce565b5050505090500191505060405180910390f35b6108c16004803603604081101561090f57600080fd5b5080359060200135600160a060020a031661222f565b6103526004803603602081101561093b57600080fd5b50356129fc565b61044e6004803603602081101561095857600080fd5b5035612a07565b6103526004803603602081101561097557600080fd5b5035612a2e565b600060208190529081526040902080546001820154600283015460038401546004850154600586015460068701546007880154600889015460098a0154600a8b0154600b8c0154600c909c01549a9b999a98999798969795969495939492939192909190600160a060020a03168d565b60008281602002015183600160200201518460026020020151856003602002015186600460200201518760056020020151886006602002015189600760200201518a600860200201518b600960200201518c600a6020020151604051602001808c81526020018b81526020018a81526020018981526020018881526020018781526020018681526020018581526020018481526020018381526020018281526020019b50505050505050505050505060405160208183030381529060405280519060200120826040516020018083815260200182600160a060020a0316600160a060020a03166c01000000000000000000000000028152601401925050506040516020818303038152906040528051906020012090505b92915050565b600281565b600080610b19614204565b5050506000918252600160208181526040808520600160a060020a039490941685526011909301815292829020825160608101845281548082529282015494810185905260029091015460ff16151592019190915291565b6000918252600160208181526040808520600160a060020a0394909416855260139093019052912080549101549091565b60009081526001602052604090205490565b60055481565b6000818152600260209081526040808320548584529183905282206005810154821115610be957806005015491505b6004810154610bfe908363ffffffff612a4016565b95945050505050565b6000610c1584848433612a89565b949350505050565b604080517f616464726573732047656e6573697350726f746f636f6c4164647265737300006020808301919091527f627974657333322050726f706f73616c49640000000000000000000000000000603e8301527f75696e7432353620566f7465000000000000000000000000000000000000000060508301527f75696e7432353620416d6f756e74546f5374616b650000000000000000000000605c8301527f75696e74323536204e6f6e63650000000000000000000000000000000000000060718301528251605e818403018152607e909201909252805191012081565b600160208190526000918252604090912080549181015460028201546003830154600484015460058501546006860154600787015460088801546009890154600a8a0154600e909a0154600160a060020a03808b169b60ff60a060020a909c048c169b99909116989091168d565b600084610d7781612ee3565b1515610d8257600080fd5b6000868152600160205260409020610d98614228565b5060058082015460009081526020818152604080832081516101a0810183528154815260018201549381019390935260028101549183019190915260038101546060830152600481015460808301529283015460a0820152600683015460c0820152600783015460e082015260088301546101008201526009830154610120820152600a830154610140820152600b830154610160820152600c90920154600160a060020a0316610180830181905215610e6d57610180820151600160a060020a03163314610e6657600080fd5b5084610e70565b50335b610e7c89828a8a612f56565b9998505050505050505050565b60009081526001602052604090206002015490565b6000818152600160205260408120600a01546105dc908290610ec790839063ffffffff6135ff16565b600085815260016020818152604080842092845260129092019052902054909150610c1590600a840290610f0290849063ffffffff61361516565b9063ffffffff61364016565b60008084600214156110715750604080517f616464726573732047656e6573697350726f746f636f6c4164647265737300006020808301919091527f627974657333322050726f706f73616c49640000000000000000000000000000603e8301527f75696e7432353620566f7465000000000000000000000000000000000000000060508301527f75696e7432353620416d6f756e74546f5374616b650000000000000000000000605c8301527f75696e74323536204e6f6e63650000000000000000000000000000000000000060718301528251605e818403018152607e830184528051908201206c010000000000000000000000003002609e84015260b283018c905260d283018b905260f283018a90526101128084018a90528451808503909101815261013284018552805190830120610152840191909152610172808401919091528351808403909101815261019290920190925280519101206110ce565b604080516c010000000000000000000000003002602080830191909152603482018c9052605482018b9052607482018a905260948083018a90528351808403909101815260b490920190925280519101206110cb90613664565b90505b600061111885858080601f016020809104026020016040519081016040528093929190818152602001838380828437600092019190915250869392505063ffffffff6136b5169050565b9050600160a060020a038116151561117a576040805160e560020a62461bcd02815260206004820152601a60248201527f7374616b657220616464726573732063616e6e6f742062652030000000000000604482015290519081900360640190fd5b600160a060020a038116600090815260076020526040902054871461119e57600080fd5b600160a060020a0381166000908152600760205260409020546111c890600163ffffffff61378b16565b600160a060020a0382166000908152600760205260409020556111ed8a8a8a84612a89565b9a9950505050505050505050565b600160029091565b60005b90565b6000908152600160208190526040909120015460a060020a900460ff1690565b600082815260016020526040812081906002600182015460a060020a900460ff16600681111561125557fe5b1461125f57600080fd5b6002808201546000908152601283016020908152604080832054600160a060020a0389168452601386019092528220928301549092911080156112a6575060028301548154145b80156112b6575060018360020154145b80156112c157508115155b156112df578183600701548260020154028115156112db57fe5b0493505b831580159061138d57506001830154600654604080517f6b8eb403000000000000000000000000000000000000000000000000000000008152600160a060020a039283166004820152602481018b9052905187939290921691636b8eb40391604480820192602092909190829003018186803b15801561135e57600080fd5b505afa158015611372573d6000803e3d6000fd5b505050506040513d602081101561138857600080fd5b505110155b156114ce576000600282015560068301546113ae908563ffffffff61379d16565b60068085019190915560018401549054604080517fbea75f28000000000000000000000000000000000000000000000000000000008152600160a060020a039283166004820152898316602482015260448101889052606481018b90529051919092169163bea75f289160848083019260209291908290030181600087803b15801561143957600080fd5b505af115801561144d573d6000803e3d6000fd5b505050506040513d602081101561146357600080fd5b5051151561147057600080fd5b825460009081526003602090815260409182902054825187815292519697508796600160a060020a03808b16949216928b927fb4a37163ec93e05e09b62e52f7f2ea8cfde431802edede7dfebe53d2ad969dbb929081900390910190a45b5050509250929050565b60009182526001602090815260408084209284526012909201905290205490565b600654600160a060020a031681565b6000908152600160208181526040808420838552601081018352818520546002808752838720549587526012909201909352818520549085529320549093919291565b600061155561429a565b60008381526001602081815260409283902083516101c0810185528154815292810154600160a060020a03811692840192909252919283019060a060020a900460ff1660068111156115a357fe5b60068111156115ae57fe5b815260028201546020820152600380830154600160a060020a0316604080840191909152600484015460608085019190915260058501546080850152600685015460a0850152600785015460c0850152600885015460e08501526009850154610100850152600a8501546101208501528151908101918290526101409093019291600b85019182845b815481526020019060010190808311611637575050509183525050600e919091015460ff16151560209091015260c0810151815191925061167791610bba565b611680846137b2565b119392505050565b6000838152602081905260408120600b015442116116f0576040805160e560020a62461bcd02815260206004820152600e60248201527f6e6f742061637469766520796574000000000000000000000000000000000000604482015290519081900360640190fd5b6000848152602081905260409020546032111561170c57600080fd5b600554604080516c010000000000000000000000003002602080830191909152603480830185905283518084039091018152605490920190925280519101209061175d90600163ffffffff61378b16565b60055561176861429a565b336020828101829052604080516c0100000000000000000000000093840281840152600160a060020a03888116909402603482015281516028818303018152604890910182528051908301208452600381850181905261018085015142905260008a815280845282812060029081015460a08801528a86166080880152606087015260c086018b905285518152925290205416151561187a57600160a060020a03841615156118435780516000908152600360205260409020805473ffffffffffffffffffffffffffffffffffffffff19163317905561187a565b80516000908152600360205260409020805473ffffffffffffffffffffffffffffffffffffffff1916600160a060020a0386161790555b8051600090815260046020908152604080832054898452918390528220600a01546118b191606491610f029163ffffffff61361516565b6000888152602081905260409020600901549091506118d790829063ffffffff61380716565b60e08301526000838152600160208181526040928390208551815590850151918101805473ffffffffffffffffffffffffffffffffffffffff1916600160a060020a03909316929092178083559285015185939192909160a060020a60ff02191660a060020a83600681111561194957fe5b02179055506060820151600282015560808201516003808301805473ffffffffffffffffffffffffffffffffffffffff1916600160a060020a039093169290921790915560a0830151600483015560c0830151600583015560e08301516006830155610100830151600783015561012083015160088301556101408301516009830155610160830151600a8301556101808301516119ec91600b8401919061431b565b506101a09190910151600e909101805460ff191691151591909117905560e0820151600084815260016020908152604080832060028085526012909101835281842094909455855183526003825291829020548251938452600160a060020a038a8116928501929092528383018b9052915191169185917f75b4ff136cc5de5957574c797de3334eb1c141271922b825eb071e0487ba2c5c916060908290030190a350909695505050505050565b60006064833511801590611ab057506032833510155b1515611af05760405160e560020a62461bcd0281526004018080602001828103825260298152602001806143f36029913960400191505060405180910390fd5b613e80608084013511801590611b0b57506103e86080840135115b1515611b61576040805160e560020a62461bcd02815260206004820152601e60248201527f31303030203c207468726573686f6c64436f6e7374203c3d2031363030300000604482015290519081900360640190fd5b606460e08401351115611bbe576040805160e560020a62461bcd02815260206004820181905260248201527f766f7465727352657075746174696f6e4c6f7373526174696f203c3d20313030604482015290519081900360640190fd5b60a083013560408401351015611c085760405160e560020a62461bcd02815260040180806020018281038252602b8152602001806143c8602b913960400191505060405180910390fd5b600061010084013511611c65576040805160e560020a62461bcd02815260206004820152601e60248201527f6d696e696d756d44616f426f756e74792073686f756c64206265203e20300000604482015290519081900360640190fd5b600061012084013511611cc2576040805160e560020a62461bcd02815260206004820152601c60248201527f64616f426f756e7479436f6e73742073686f756c64206265203e203000000000604482015290519081900360640190fd5b6000611cf884600b806020026040519081016040528092919082600b602002808284376000920191909152508691506109ec9050565b905060ac60026107d05b613e80811015611d4c57608087013581108015611d26575060028102608088013511155b15611d3e578183811515611d3657fe5b049250611d4c565b600190910190600202611d02565b50604080516101a0810182528735815260208089013590820152878201359181019190915260608088013590820152608080820190611dad908901357affffffffffffffffffffffffffffffffffffffffffffffffffffff166103e8613817565b815260208101849052604001876005602090810291909101358252018760066020908102919091013582520187600760209081029190910135825201876008602090810291909101358252018760096020908102919091013582520187600a602090810291909101358252600160a060020a03978816918101919091526000858152808252604090819020835181559183015160018301558201516002820155606082015160038201556080820151600482015560a0820151600582015560c0820151600682015560e0820151600782015561010082015160088201556101208201516009820155610140820151600a820155610160820151600b82015561018090910151600c909101805473ffffffffffffffffffffffffffffffffffffffff19169190961617909455509392505050565b80611eea81612ee3565b1515611ef557600080fd5b5050565b50600290565b60076020526000908152604090205481565b600181565b6000918252600160209081526040808420928452600f909201905290205490565b600360205260009081526040902054600160a060020a031681565b60046020526000908152604090205481565b60008181526001602052604081206005600182015460a060020a900460ff166006811115611f8e57fe5b1480611fb357506006600182015460a060020a900460ff166006811115611fb157fe5b145b1515611ff35760405160e560020a62461bcd02815260040180806020018281038252603381526020018061441c6033913960400191505060405180910390fd5b611ffc8361384e565b1515612052576040805160e560020a62461bcd02815260206004820152601760248201527f70726f706f73616c206e65656420746f20657870697265000000000000000000604482015290519081900360640190fd5b61207e612071600b83016001015460048401549063ffffffff61378b16565b429063ffffffff61379d16565b600a82015561208c83610e9e565b60088201549092506120a4908363ffffffff61379d16565b6008820155600654604080517fa9059cbb000000000000000000000000000000000000000000000000000000008152336004820152602481018590529051600160a060020a039092169163a9059cbb916044808201926020929091908290030181600087803b15801561211657600080fd5b505af115801561212a573d6000803e3d6000fd5b505050506040513d602081101561214057600080fd5b50511515612198576040805160e560020a62461bcd02815260206004820152601d60248201527f7472616e7366657220746f206d73672e73656e646572206661696c6564000000604482015290519081900360640190fd5b604080518381529051339185917f7468017f6ff596af88244327e88fe691ac48cc1db88b033d11c335f2c7ccdd039181900360200190a350919050565b6000610b0382612ee3565b6121e8614359565b60008281526001602052604090819020815160608101909252600b0160038282826020028201915b8154815260200190600101908083116122105750505050509050919050565b612237614359565b60008381526001602052604090206002600182015460a060020a900460ff16600681111561226157fe5b1480612285575060018082015460a060020a900460ff16600681111561228357fe5b145b15156122c55760405160e560020a62461bcd02815260040180806020018281038252602d81526020018061439b602d913960400191505060405180910390fd5b6122cd614228565b5060058082015460009081526020818152604080832081516101a081018352815481526001820154818501526002808301548285015260038301546060830152600483015460808301529582015460a0820152600682015460c0820152600782015460e082015260088201546101008201526009820154610120820152600a820154610140820152600b820154610160820152600c90910154600160a060020a0390811661018083015288168452601386018352818420948601548452601286019092528220549092916123d96123a389610e9e565b6001600090815260128801602052604080822054600283529120546123cd9163ffffffff61378b16565b9063ffffffff61379d16565b90506000836001015411156124aa5760018086015460a060020a900460ff16600681111561240357fe5b141561241557600183015486526124a2565b6002850154835414156124a25782546001141561247e57808560070154101561247957600061245186600701548361379d90919063ffffffff16565b90508261246b82866001015461361590919063ffffffff16565b81151561247457fe5b048752505b6124a2565b60018301548290612495908363ffffffff61361516565b81151561249e57fe5b0486525b600060018401555b600e85015460ff161580156124da57508454600090815260036020526040902054600160a060020a038881169116145b80156124ff575060018086015460a060020a900460ff1660068111156124fc57fe5b14155b801561250f575060028560020154145b15612562576007850154612550906123cd84612531838663ffffffff61361516565b81151561253a57fe5b048960005b60200201519063ffffffff61378b16565b8652600e8501805460ff191660011790555b600160a060020a038716600090815260118601602052604090206001810154158015906125935750600281015460ff165b156126da5760018087015460a060020a900460ff1660068111156125b357fe5b14156125eb5760646125d7866101000151836001015461361590919063ffffffff16565b8115156125e057fe5b0460208801526126d2565b8054600287015414156126d2576000600187600201541415612620575060026000908152601087016020526040902054612635565b50600160009081526010870160205260409020545b606461264f8761010001518361361590919063ffffffff16565b81151561265857fe5b6002890154600090815260108a01602052604090205460018501549290910492506126cb9161268d908463ffffffff61361516565b81151561269657fe5b0460646126b5896101000151866001015461361590919063ffffffff16565b8115156126be57fe5b049063ffffffff61378b16565b6020890152505b600060018201555b6003860154600160a060020a0389811691161480156126fd575060018660020154145b801561271557506003860154600160a060020a031615155b156127445760e0850151604088015260038601805473ffffffffffffffffffffffffffffffffffffffff191690555b8651156128af578651600887015461275b9161379d565b60088701556006548751604080517fa9059cbb000000000000000000000000000000000000000000000000000000008152600160a060020a038c8116600483015260248201939093529051919092169163a9059cbb9160448083019260209291908290030181600087803b1580156127d257600080fd5b505af11580156127e6573d6000803e3d6000fd5b505050506040513d60208110156127fc57600080fd5b50511515612854576040805160e560020a62461bcd02815260206004820152601e60248201527f7472616e7366657220746f2062656e6566696369617279206661696c65640000604482015290519081900360640190fd5b855460009081526003602090815260409182902054895183519081529251600160a060020a038c8116949216928d927f6d26871c9f457d104b2122485f659f126f7a0cf6938cf20482c03f49794a2fbf929081900390910190a45b60408701516128c09088600161253f565b156129f0576001860154600160a060020a031663d29b5d2f6128eb89600260200201518a600161253f565b8a8c6040518463ffffffff167c01000000000000000000000000000000000000000000000000000000000281526004018084815260200183600160a060020a0316600160a060020a031681526020018281526020019350505050602060405180830381600087803b15801561295f57600080fd5b505af1158015612973573d6000803e3d6000fd5b505050506040513d602081101561298957600080fd5b50508554600090815260036020526040902054600160a060020a03808a1691168a7f7419b736daacf66d5c1645948c956fca2b83be1e2e02d486d65713f289d683b86129de8b600260200201518c600161253f565b60408051918252519081900360200190a45b50505050505092915050565b6000610b03826137b2565b600081612a1381612ee3565b1515612a1e57600080fd5b612a278361384e565b9392505050565b60026020526000908152604090205481565b60008282650100000000005b8115610bfe578160011660011415612a6b57612a688184614170565b90505b6002909104908115612a8457612a818384614170565b92505b612a4c565b600060028411158015612a9c5750600084115b1515612af2576040805160e560020a62461bcd02815260206004820152601060248201527f77726f6e6720766f74652076616c756500000000000000000000000000000000604482015290519081900360640190fd5b60008311612b4a576040805160e560020a62461bcd02815260206004820152601b60248201527f7374616b696e6720616d6f756e742073686f756c64206265203e300000000000604482015290519081900360640190fd5b612b538561384e565b15612b6057506001610c15565b60008581526001602052604090206004600182015460a060020a900460ff166006811115612b8a57fe5b14158015612bb257506003600182015460a060020a900460ff166006811115612baf57fe5b14155b15612bc1576000915050610c15565b600160a060020a0383166000908152601382016020526040812060018101549091108015612bf0575080548614155b15612c0057600092505050610c15565b600654604080517f23b872dd000000000000000000000000000000000000000000000000000000008152600160a060020a038781166004830152306024830152604482018990529151889392909216916323b872dd916064808201926020929091908290030181600087803b158015612c7857600080fd5b505af1158015612c8c573d6000803e3d6000fd5b505050506040513d6020811015612ca257600080fd5b50511515612cfa576040805160e560020a62461bcd02815260206004820152601960248201527f6661696c207472616e736665722066726f6d207374616b657200000000000000604482015290519081900360640190fd5b6008830154612d0f908263ffffffff61378b16565b60088401556001820154612d29908263ffffffff61378b16565b600183018190557001000000000000000000000000000000001015612d98576040805160e560020a62461bcd02815260206004820152601a60248201527f7374616b696e6720616d6f756e7420697320746f6f2068696768000000000000604482015290519081900360640190fd5b6006830154612dbf907001000000000000000000000000000000009063ffffffff61379d16565b60088401541115612e1a576040805160e560020a62461bcd02815260206004820152601860248201527f746f74616c207374616b657320697320746f6f20686967680000000000000000604482015290519081900360640190fd5b6001871415612e3e576002820154612e38908263ffffffff61378b16565b60028301555b8682556000878152601284016020526040902054612e6390829063ffffffff61378b16565b60008881526012850160209081526040808320939093558554825260038152908290205482518a81529182018990528251600160a060020a03808a16949216928c927fd0239d7d4acf51def4507fa173be466927de5d75d8b10d840cd6994d6e10231092918290030190a4612ed78861384e565b98975050505050505050565b60008181526001602081905260408220015460a060020a900460ff166004816006811115612f0d57fe5b1480612f2457506005816006811115612f2257fe5b145b80612f3a57506006816006811115612f3857fe5b145b80612a2757506003816006811115612f4e57fe5b149392505050565b600060028311158015612f695750600083115b1515612fbf576040805160e560020a62461bcd02815260206004820152600e60248201527f30203c205f766f7465203c3d2032000000000000000000000000000000000000604482015290519081900360640190fd5b612fc88561384e565b15612fd557506001610c15565b612fdd614228565b506000858152600160208181526040808420600580820154865285845282862083516101a0810185528154815281870154818701526002820154818601526003820154606082015260048083015460808301529282015460a0820152600682015460c0820152600782015460e082015260088201546101008201526009820154610120820152600a820154610140820152600b820154610160820152600c90910154600160a060020a039081166101808301528c88528686529583015484517f9588378e0000000000000000000000000000000000000000000000000000000081528c881693810193909352602483018d905293519096929592949390921692639588378e92604480840193829003018186803b1580156130fd57600080fd5b505afa158015613111573d6000803e3d6000fd5b505050506040513d602081101561312757600080fd5b5051905060008111613183576040805160e560020a62461bcd02815260206004820152601b60248201527f5f766f746572206d75737420686176652072657075746174696f6e0000000000604482015290519081900360640190fd5b848110156131db576040805160e560020a62461bcd02815260206004820152601260248201527f72657075746174696f6e203e3d205f7265700000000000000000000000000000604482015290519081900360640190fd5b848015156131e65750805b600160a060020a038816600090815260118401602052604090206001015415613216576000945050505050610c15565b6000878152600f8401602052604090205461323890829063ffffffff61378b16565b6000888152600f850160205260408082208390556002860154825281205490899052108061329057506002808401546000908152600f8501602052604080822054928252902054148015613290575060018360020154145b156133b3576005600184015460a060020a900460ff1660068111156132b157fe5b1480156132d1575060c0840151604085015103600b840160010154420310155b806132f557506006600184015460a060020a900460ff1660068111156132f357fe5b145b156133ab576006600184015460a060020a900460ff16600681111561331657fe5b146133a45760c0840151600484015560018301805460a060020a60ff0219167406000000000000000000000000000000000000000017908190556040518a917f21aca7f0285ccddeca2935074d3e36b5ab8fea0327f84cbbf12cf1b6d1a749f99160a060020a90910460ff16908082600681111561339057fe5b60ff16815260200191505060405180910390a25b42600c8401555b600283018790555b60408051606081018252888152602081018390529081016004600186015460a060020a900460ff1660068111156133e657fe5b148061340b57506003600186015460a060020a900460ff16600681111561340957fe5b145b15159052600160a060020a0389166000908152601185016020908152604091829020835181559083015160018201559101516002909101805460ff19169115159190911790556004600184015460a060020a900460ff16600681111561346d57fe5b148061349257506003600184015460a060020a900460ff16600681111561349057fe5b145b1561359a5760008781526010840160205260409020546134b990829063ffffffff61378b16565b60008881526010850160205260408120919091556101008501516064906134e6908463ffffffff61361516565b8115156134ef57fe5b6001860154604080517ff81f8bf60000000000000000000000000000000000000000000000000000000081529390920460048401819052600160a060020a038d81166024860152604485018f9052925190945091169163f81f8bf69160648083019260209291908290030181600087803b15801561356c57600080fd5b505af1158015613580573d6000803e3d6000fd5b505050506040513d602081101561359657600080fd5b5050505b82546000908152600360209081526040918290205482518a81529182018490528251600160a060020a03808d16949216928d927f066c061a3792cb3eb64a441a928655fcbafb4a54b49725fe9cd2951df5e7189e92918290030190a4610e7c8961384e565b600081831061360e5781612a27565b5090919050565b600082151561362657506000610b03565b82820282848281151561363557fe5b0414612a2757600080fd5b600080821161364e57600080fd5b6000828481151561365b57fe5b04949350505050565b604080517f19457468657265756d205369676e6564204d6573736167653a0a333200000000602080830191909152603c8083019490945282518083039094018452605c909101909152815191012090565b600080600080845160411415156136d25760009350505050610b03565b50505060208201516040830151606084015160001a601b60ff821610156136f757601b015b8060ff16601b1415801561370f57508060ff16601c14155b156137205760009350505050610b03565b6040805160008152602080820180845289905260ff8416828401526060820186905260808201859052915160019260a0808401939192601f1981019281900390910190855afa158015613777573d6000803e3d6000fd5b505050602060405103519350505050610b03565b600082820183811015612a2757600080fd5b6000828211156137ac57600080fd5b50900390565b60008181526001602081815260408084206002855260128101909252808420549284528320549091612a27917affffffffffffffffffffffffffffffffffffffffffffffffffffff169063ffffffff61381716565b60008183101561360e5781612a27565b6000612a277affffffffffffffffffffffffffffffffffffffffffffffffffffff80851665010000000000908102918516026141e7565b60008161385a81612ee3565b151561386557600080fd5b600083815260016020526040902061387b614228565b506005808201546000908152602081815260409182902082516101a0810184528154815260018201549281019290925260028101549282019290925260038201546060820152600482015460808201529181015460a0830152600681015460c0830152600781015460e083015260088101546101008301526009810154610120830152600a810154610140830152600b810154610160830152600c0154600160a060020a031661018082015261392f61429a565b604080516101c081018252845481526001850154600160a060020a0381166020830152909185919083019060a060020a900460ff16600681111561396f57fe5b600681111561397a57fe5b815260028201546020820152600380830154600160a060020a0316604080840191909152600484015460608085019190915260058501546080850152600685015460a0850152600785015460c0850152600885015460e08501526009850154610100850152600a8501546101208501528151908101918290526101409093019291600b85019182845b815481526020019060010190808311613a03575050509183525050600e919091015460ff1615156020918201526001850154604080517fb551c373000000000000000000000000000000000000000000000000000000008152600481018b90529051939450600093600160a060020a039092169263b551c37392602480840193829003018186803b158015613a9757600080fd5b505afa158015613aab573d6000803e3d6000fd5b505050506040513d6020811015613ac157600080fd5b5051835160028601546000908152600f87016020526040812054929350606484049091029181908190841015613b71576003600189015460a060020a900460ff166006811115613b0d57fe5b1415613b1c5760019250613b4c565b6004600189015460a060020a900460ff166006811115613b3857fe5b1415613b475760039250613b4c565b600592505b6001880180546002919060a060020a60ff02191660a060020a835b0217905550613dfc565b6003600189015460a060020a900460ff166006811115613b8d57fe5b1415613c26576020870151600b890154420310613bcb5760018801805460a060020a60ff02191660a060020a17905560028089018190559250613c26565b613bdd88600501548960000154610bba565b905080613be98c6137b2565b1115613c265760018801805460a060020a60ff0219167404000000000000000000000000000000000000000017905542600d890155600988018190555b6004600189015460a060020a900460ff166006811115613c4257fe5b1415613dfc57613c5a88600501548960000154610bba565b6060880151909150600b890160020154420310613d595780613c7b8c6137b2565b1115613d355787546000908152600260205260409020546110001115613d30576001888101805460a060020a60ff0219167405000000000000000000000000000000000000000017905542600c8a01558854600090815260026020818152604080842080549095019094558b54835260048152838320548282528484205492845260128d01909152929091205491935090839003811515613d1857fe5b89546000908152600460205260409020919005830190555b613d54565b6001880180546003919060a060020a60ff02191660a060020a83613b67565b613dfc565b6000613d648c6137b2565b60098a0154909150613d7c908363ffffffff6135ff16565b8111613db05760018901805460a060020a60ff02191674030000000000000000000000000000000000000000179055613dfa565b8089600901541115613dfa57600989018290556040805183815290518d917fad767d61af51c7895fa3cc0497dde01afb610c74e55ee4d8a71fa5e3ee136d54919081900360200190a25b505b6005600189015460a060020a900460ff166006811115613e1857fe5b1480613e3d57506006600189015460a060020a900460ff166006811115613e3b57fe5b145b15613e81576004880154600c890154420310613e815760018801805460a060020a60ff02191674020000000000000000000000000000000000000000179055600492505b6000836005811115613e8f57fe5b146140ca576004836005811115613ea257fe5b1480613eb957506005836005811115613eb757fe5b145b15613f78578551600090815260026020526040902054613ee090600163ffffffff61379d16565b865160009081526002602052604080822092909255875181522054801515613f18578854600090815260046020526040812055613f76565b88546000908152600460209081526040808320546002845260128d01909252909120549093508190613f57906123cd866001850163ffffffff61361516565b811515613f6057fe5b8a54600090815260046020526040902091900490555b505b87546000908152600360209081526040918290205460028b015483519081529182018890528251600160a060020a03909116928e927f37471b9c9d295ffb1309ad070b8964700bfb7b555e8e8292d0b6cbc7dba35d10929081900390910190a38a7f46a713b994c752c68fbefa9048bec9a0010cc7d933ad95a3c3dbb25931a167e7846040518082600581111561400b57fe5b60ff16815260200191505060405180910390a260018801546002890154604080517f9d4c162d000000000000000000000000000000000000000000000000000000008152600481018f9052602481019290925251600160a060020a0390921691639d4c162d916044808201926020929091908290030181600087803b15801561409357600080fd5b505af11580156140a7573d6000803e3d6000fd5b505050506040513d60208110156140bd57600080fd5b5050600688015460078901555b600188015460a060020a900460ff1660068111156140e457fe5b866040015160068111156140f457fe5b14614151578a7f21aca7f0285ccddeca2935074d3e36b5ab8fea0327f84cbbf12cf1b6d1a749f98960010160149054906101000a900460ff166040518082600681111561413d57fe5b60ff16815260200191505060405180910390a25b600083600581111561415f57fe5b14159b9a5050505050505050505050565b600082820282848281151561418157fe5b04146141d7576040805160e560020a62461bcd02815260206004820152601560248201527f5265616c4d617468206d756c206f766572666c6f770000000000000000000000604482015290519081900360640190fd5b6501000000000090049392505050565b6000816501000000000084028115156141fc57fe5b049392505050565b60606040519081016040528060008152602001600081526020016000151581525090565b6101a0604051908101604052806000815260200160008152602001600081526020016000815260200160008152602001600081526020016000815260200160008152602001600081526020016000815260200160008152602001600081526020016000600160a060020a031681525090565b604080516102008101825260008082526020820181905290918201908152602001600081526020016000600160a060020a031681526020016000815260200160008019168152602001600081526020016000815260200160008152602001600081526020016000815260200161430e614359565b8152600060209091015290565b8260038101928215614349579160200282015b8281111561434957825182559160200191906001019061432e565b50614355929150614378565b5090565b6060604051908101604052806003906020820280388339509192915050565b61120691905b80821115614355576000815560010161437e565b6000903b119056fe50726f706f73616c2073686f756c64206265204578656375746564206f722045787069726564496e5175657565626f6f73746564566f7465506572696f644c696d6974203e3d207175696574456e64696e67506572696f643530203c3d20717565756564566f7465526571756972656450657263656e74616765203c3d2031303070726f706f73616c20737461746520696e206e6f7420426f6f73746564206e6f72205175696574456e64696e67506572696f64a165627a7a72305820b245ca9a6f2d7b8aabb67d17c023f7cb514e1c60360315fc0729c044b776d3be0029

Constructor Arguments (ABI-Encoded and is the last bytes of the Contract Creation Code above)

000000000000000000000000543ff227f64aa17ea132bf9886cab5db55dcaddf

-----Decoded View---------------
Arg [0] : _stakingToken (address): 0x543Ff227F64Aa17eA132Bf9886cAb5DB55DCAddf

-----Encoded View---------------
1 Constructor Arguments found :
Arg [0] : 000000000000000000000000543ff227f64aa17ea132bf9886cab5db55dcaddf


Swarm Source

bzzr://b245ca9a6f2d7b8aabb67d17c023f7cb514e1c60360315fc0729c044b776d3be

Block Transaction Difficulty Gas Used Reward
View All Blocks Produced

Block Uncle Number Difficulty Gas Used Reward
View All Uncles
Loading...
Loading
Loading...
Loading

Validator Index Block Amount
View All Withdrawals

Transaction Hash Block Value Eth2 PubKey Valid
View All Deposits
Loading...
Loading
[ Download: CSV Export  ]

A contract address hosts a smart contract, which is a set of code stored on the blockchain that runs when predetermined conditions are met. Learn more about addresses in our Knowledge Base.