DisputeKitClassic

Git Source

Inherits: BaseDisputeKit, IEvidence

State Variables

WINNER_STAKE_MULTIPLIER

uint256 public constant WINNER_STAKE_MULTIPLIER = 10000;

LOSER_STAKE_MULTIPLIER

uint256 public constant LOSER_STAKE_MULTIPLIER = 20000;

LOSER_APPEAL_PERIOD_MULTIPLIER

uint256 public constant LOSER_APPEAL_PERIOD_MULTIPLIER = 5000;

ONE_BASIS_POINT

uint256 public constant ONE_BASIS_POINT = 10000;

disputes

Dispute[] public disputes;

coreDisputeIDToLocal

mapping(uint256 => uint256) public coreDisputeIDToLocal;

Functions

notJumped

modifier notJumped(uint256 _coreDisputeID);

constructor

Constructor.

constructor(address _governor, KlerosCore _core) BaseDisputeKit(_governor, _core);

Parameters

NameTypeDescription
_governoraddressThe governor's address.
_coreKlerosCoreThe KlerosCore arbitrator.

changeGovernor

Changes the governor storage variable.

function changeGovernor(address payable _governor) external onlyByGovernor;

Parameters

NameTypeDescription
_governoraddress payableThe new value for the governor storage variable.

changeCore

Changes the core storage variable.

function changeCore(address _core) external onlyByGovernor;

Parameters

NameTypeDescription
_coreaddressThe new value for the core storage variable.

createDispute

Creates a local dispute and maps it to the dispute ID in the Core contract. Note: Access restricted to Kleros Core only.

function createDispute(uint256 _coreDisputeID, uint256 _numberOfChoices, bytes calldata _extraData, uint256 _nbVotes)
    external
    override
    onlyByCore;

Parameters

NameTypeDescription
_coreDisputeIDuint256The ID of the dispute in Kleros Core.
_numberOfChoicesuint256Number of choices of the dispute
_extraDatabytesAdditional info about the dispute, for possible use in future dispute kits.
_nbVotesuint256Number of votes for this dispute.

draw

Draws the juror from the sortition tree. The drawn address is picked up by Kleros Core. Note: Access restricted to Kleros Core only.

function draw(uint256 _coreDisputeID)
    external
    override
    onlyByCore
    notJumped(_coreDisputeID)
    returns (address drawnAddress);

Parameters

NameTypeDescription
_coreDisputeIDuint256The ID of the dispute in Kleros Core.

Returns

NameTypeDescription
drawnAddressaddressThe drawn address.

castCommit

Sets the caller's commit for the specified votes. It can be called multiple times during the commit period, each call overrides the commits of the previous one. O(n) where n is the number of votes.

function castCommit(uint256 _coreDisputeID, uint256[] calldata _voteIDs, bytes32 _commit)
    external
    notJumped(_coreDisputeID);

Parameters

NameTypeDescription
_coreDisputeIDuint256The ID of the dispute in Kleros Core.
_voteIDsuint256[]The IDs of the votes.
_commitbytes32The commit. Note that justification string is a part of the commit.

castVote

Sets the caller's choices for the specified votes. O(n) where n is the number of votes.

function castVote(
    uint256 _coreDisputeID,
    uint256[] calldata _voteIDs,
    uint256 _choice,
    uint256 _salt,
    string memory _justification
) external notJumped(_coreDisputeID);

Parameters

NameTypeDescription
_coreDisputeIDuint256The ID of the dispute in Kleros Core.
_voteIDsuint256[]The IDs of the votes.
_choiceuint256The choice.
_saltuint256The salt for the commit if the votes were hidden.
_justificationstringJustification of the choice.

fundAppeal

Manages contributions, and appeals a dispute if at least two choices are fully funded. Note that the surplus deposit will be reimbursed.

function fundAppeal(uint256 _coreDisputeID, uint256 _choice) external payable notJumped(_coreDisputeID);

Parameters

NameTypeDescription
_coreDisputeIDuint256Index of the dispute in Kleros Core.
_choiceuint256A choice that receives funding.

withdrawFeesAndRewards

Allows those contributors who attempted to fund an appeal round to withdraw any reimbursable fees or rewards after the dispute gets resolved.

function withdrawFeesAndRewards(
    uint256 _coreDisputeID,
    address payable _beneficiary,
    uint256 _coreRoundID,
    uint256 _choice
) external returns (uint256 amount);

Parameters

NameTypeDescription
_coreDisputeIDuint256Index of the dispute in Kleros Core contract.
_beneficiaryaddress payableThe address whose rewards to withdraw.
_coreRoundIDuint256The round in the Kleros Core contract the caller wants to withdraw from.
_choiceuint256The ruling option that the caller wants to withdraw from.

Returns

NameTypeDescription
amountuint256The withdrawn amount.

submitEvidence

Submits evidence.

function submitEvidence(uint256 _evidenceGroupID, string calldata _evidence) external;

Parameters

NameTypeDescription
_evidenceGroupIDuint256Unique identifier of the evidence group the evidence belongs to. It's the submitter responsability to submit the right evidence group ID.
_evidencestringIPFS path to evidence, example: '/ipfs/Qmarwkf7C9RuzDEJNnarT3WZ7kem5bk8DZAzx78acJjMFH/evidence.json'.

getFundedChoices

function getFundedChoices(uint256 _coreDisputeID) public view returns (uint256[] memory fundedChoices);

currentRuling

Gets the current ruling of a specified dispute.

function currentRuling(uint256 _coreDisputeID)
    external
    view
    override
    returns (uint256 ruling, bool tied, bool overridden);

Parameters

NameTypeDescription
_coreDisputeIDuint256The ID of the dispute in Kleros Core.

Returns

NameTypeDescription
rulinguint256The current ruling.
tiedboolWhether it's a tie or not.
overriddenboolWhether the ruling was overridden by appeal funding or not.

getDegreeOfCoherence

Gets the degree of coherence of a particular voter. This function is called by Kleros Core in order to determine the amount of the reward.

function getDegreeOfCoherence(uint256 _coreDisputeID, uint256 _coreRoundID, uint256 _voteID)
    external
    view
    override
    returns (uint256);

Parameters

NameTypeDescription
_coreDisputeIDuint256The ID of the dispute in Kleros Core, not in the Dispute Kit.
_coreRoundIDuint256The ID of the round in Kleros Core, not in the Dispute Kit.
_voteIDuint256The ID of the vote.

Returns

NameTypeDescription
<none>uint256The degree of coherence in basis points.

getCoherentCount

Gets the number of jurors who are eligible to a reward in this round.

function getCoherentCount(uint256 _coreDisputeID, uint256 _coreRoundID) external view override returns (uint256);

Parameters

NameTypeDescription
_coreDisputeIDuint256The ID of the dispute in Kleros Core, not in the Dispute Kit.
_coreRoundIDuint256The ID of the round in Kleros Core, not in the Dispute Kit.

Returns

NameTypeDescription
<none>uint256The number of coherent jurors.

areCommitsAllCast

Returns true if all of the jurors have cast their commits for the last round.

function areCommitsAllCast(uint256 _coreDisputeID) external view override returns (bool);

Parameters

NameTypeDescription
_coreDisputeIDuint256The ID of the dispute in Kleros Core.

Returns

NameTypeDescription
<none>boolWhether all of the jurors have cast their commits for the last round.

areVotesAllCast

Returns true if all of the jurors have cast their votes for the last round.

function areVotesAllCast(uint256 _coreDisputeID) external view override returns (bool);

Parameters

NameTypeDescription
_coreDisputeIDuint256The ID of the dispute in Kleros Core.

Returns

NameTypeDescription
<none>boolWhether all of the jurors have cast their votes for the last round.

isVoteActive

Returns true if the specified voter was active in this round.

function isVoteActive(uint256 _coreDisputeID, uint256 _coreRoundID, uint256 _voteID)
    external
    view
    override
    returns (bool);

Parameters

NameTypeDescription
_coreDisputeIDuint256The ID of the dispute in Kleros Core, not in the Dispute Kit.
_coreRoundIDuint256The ID of the round in Kleros Core, not in the Dispute Kit.
_voteIDuint256The ID of the voter.

Returns

NameTypeDescription
<none>boolWhether the voter was active or not.

getRoundInfo

function getRoundInfo(uint256 _coreDisputeID, uint256 _coreRoundID, uint256 _choice)
    external
    view
    override
    returns (
        uint256 winningChoice,
        bool tied,
        uint256 totalVoted,
        uint256 totalCommited,
        uint256 nbVoters,
        uint256 choiceCount
    );

getVoteInfo

function getVoteInfo(uint256 _coreDisputeID, uint256 _coreRoundID, uint256 _voteID)
    external
    view
    override
    returns (address account, bytes32 commit, uint256 choice, bool voted);

_postDrawCheck

Checks that the chosen address satisfies certain conditions for being drawn.

function _postDrawCheck(uint256 _coreDisputeID, address _juror) internal view override returns (bool);

Parameters

NameTypeDescription
_coreDisputeIDuint256ID of the dispute in the core contract.
_juroraddressChosen address.

Returns

NameTypeDescription
<none>boolWhether the address can be drawn or not.

Events

DisputeCreation

event DisputeCreation(uint256 indexed _coreDisputeID, uint256 _numberOfChoices, bytes _extraData);

CommitCast

event CommitCast(uint256 indexed _coreDisputeID, uint256[] _voteIDs, bytes32 _commit);

Contribution

event Contribution(
    uint256 indexed _coreDisputeID,
    uint256 indexed _coreRoundID,
    uint256 _choice,
    address indexed _contributor,
    uint256 _amount
);

Withdrawal

event Withdrawal(
    uint256 indexed _coreDisputeID,
    uint256 indexed _coreRoundID,
    uint256 _choice,
    address indexed _contributor,
    uint256 _amount
);

ChoiceFunded

event ChoiceFunded(uint256 indexed _coreDisputeID, uint256 indexed _coreRoundID, uint256 indexed _choice);

Structs

Dispute

struct Dispute {
    Round[] rounds;
    uint256 numberOfChoices;
    bool jumped;
    mapping(uint256 => uint256) coreRoundIDToLocal;
    bytes extraData;
}

Round

struct Round {
    Vote[] votes;
    uint256 winningChoice;
    mapping(uint256 => uint256) counts;
    bool tied;
    uint256 totalVoted;
    uint256 totalCommitted;
    mapping(uint256 => uint256) paidFees;
    mapping(uint256 => bool) hasPaid;
    mapping(address => mapping(uint256 => uint256)) contributions;
    uint256 feeRewards;
    uint256[] fundedChoices;
    uint256 nbVotes;
}

Vote

struct Vote {
    address account;
    bytes32 commit;
    uint256 choice;
    bool voted;
}