receiveApproval(address) :
This function is used to receive approval from a specified address (in this case, the address of the Pinakion contract). It requires that the Pinakion contract transfer a specified amount of tokens to the current contract, and then adds that amount to the balance of the specified address in the jurors mapping. (autogenerated documentation)
withdraw() :
This function allows a juror to withdraw a specified amount of Pinakion tokens from their balance. It first checks that the juror's balance is greater than their stake, that the amount they are trying to withdraw is less than their free balance, and that they have not already deposited in the current session. If all of these conditions are met, the function subtracts the specified amount from the juror's balance and attempts to transfer the tokens to the juror's address. If the transfer is successful, the function completes. (autogenerated documentation)
passPeriod() :
This function is used to transition between different periods in the contract. It requires that enough time has passed since the last period change, and then checks the current period. Depending on the current period, it will either request a random number from the RNG contract, set the random number, or increment the session. Finally, it updates the last period change timestamp and emits an event to signal the new period. (autogenerated documentation)
activateTokens() :
This function allows jurors to activate tokens in a given session. It requires that the value of the tokens being activated is greater than or equal to the minimum stake, and that the juror has enough balance to activate the tokens. The function then updates the juror's last session, segment start, segment end, and segment size variables. The segment start is set to the current segment size, and the segment size is increased by the value of the tokens being activated. The segment end is then set to the new segment size. (autogenerated documentation)
voteRuling() :
This function allows a juror to vote on a ruling for a dispute. The function takes in the dispute ID, the ruling, and an array of draws as parameters. It first checks that the juror has not already voted in this session, that the ruling is valid, and that the draws are valid. It then updates the vote count for the ruling, and if the vote count is higher than the winning count, it sets the winning count and choice to the current ruling. It then adds the vote to the dispute's votes array and updates the juror's at stake amount. Finally, it transfers the arbitration fee to the juror and emits an ArbitrationReward event. (autogenerated documentation)
penalizeInactiveJuror(address) :
This function penalizes an inactive juror for not voting in a dispute. It takes in the address of the inactive juror, the dispute ID, and an array of draws as parameters. It first checks that the period is after the voting period and that the juror did not vote in the dispute. It then checks that the draws are valid. It then calculates the penalty amount, which is equal to the number of draws multiplied by the minimum activated token multiplied by two multiplied by alpha divided by the alpha divisor. The penalty amount is then set to the lesser of the penalty amount or the inactive juror's balance. The inactive juror's balance is then reduced by the penalty amount, and half of the penalty amount is transferred (autogenerated documentation)
oneShotTokenRepartition() :
This function is used to redistribute tokens among jurors in a dispute. It is called when a dispute is closed and the winning choice has been determined. It takes the dispute ID as an argument. The function first checks that the dispute is open and that the dispute session and appeals are complete. It then calculates the amount of tokens to be redistributed (the stake per draw) and redistributes them among the jurors. If the winning choice is 0 (no consensus) then all tokens are redistributed to the governor. Otherwise, the tokens are redistributed to jurors who voted for the winning choice. Finally, the dispute state is set to executable. (autogenerated documentation)
multipleShotTokenRepartition() :
This function is used to redistribute tokens to jurors in a dispute. It is called after a dispute has been resolved and the winning choice has been determined. The function takes in two parameters: the dispute ID and the maximum number of iterations. It then sets the state of the dispute to Resolving and calculates the amount of tokens to be shifted. It then iterates through the votes in the dispute, redistributing tokens to jurors who voted for the winning choice and penalizing those who voted for the losing choice. Finally, it sets the state of the dispute to Executable. (autogenerated documentation)
amountJurors() :
This function calculates the total number of jurors for a given dispute. It takes the dispute ID as an input and returns the total number of jurors as an output. The total number of jurors is calculated by taking the initial number of jurors and adding 1, then multiplying that number by 2 to the power of the number of appeals. The result is then subtracted by 1. (autogenerated documentation)
validDraws(address) :
This function is used to validate a set of draws for a given dispute and juror. It takes in the address of the juror, the dispute ID, and an array of draws as parameters. It first checks that the juror has not already voted in the current session, that the dispute is still in the draw period, and that the draws are in ascending order. It then checks that each draw is within the range of the number of jurors for the dispute, and that the position of the draw is within the juror's segment. If all of these conditions are met, the function returns true. (autogenerated documentation)
createDispute() :
This function creates a new dispute and stores it in the disputes array. It takes two parameters, _choices and _extraData, and returns a disputeID. The function requires that the msg.value is greater than or equal to the arbitrationCost(_extraData) and calculates the number of jurors from the _extraData. It then sets the disputeID, arbitrated, session, choices, initialNumberJurors, arbitrationFeePerJuror, votes and voteCounter. Finally, it emits a DisputeCreation event and returns the disputeID. (autogenerated documentation)
appeal() :
This function allows a user to appeal a dispute. It requires that the user has enough ETH to pay the appeal fees, that the dispute is still active, and that the caller is the arbitrated contract. The function then increments the appeals counter, and increases the length of the votes and voteCounter arrays. (autogenerated documentation)
executeRuling() :
This function executes a ruling on a dispute with a given dispute ID. It first checks that the dispute is in an executable state, then sets the state of the dispute to executed and calls the rule function of the arbitrated contract, passing in the dispute ID and the winning choice from the vote counter. (autogenerated documentation)
arbitrationCost() :
This function calculates the cost of arbitration for a given dispute. It takes in the extra data associated with the dispute as an input, and uses the extraDataToNbJurors() function to calculate the number of jurors needed for the dispute. It then multiplies this number by the arbitrationFeePerJuror to calculate the total cost of arbitration. (autogenerated documentation)
appealCost() :
This function calculates the cost of appealing a dispute in the Kleros court system. It takes in a dispute ID and extra data as parameters and returns the fee associated with the appeal. The fee is calculated by multiplying the number of jurors assigned to the dispute (2 times the number of jurors plus 1) by the arbitration fee per juror. If the dispute has already reached the maximum number of appeals, the function returns a non-payable amount. (autogenerated documentation)
extraDataToNbJurors() :
This function takes in a byte array as an input and returns a uint16 number representing the number of jurors. It does this by checking the length of the byte array and if it is greater than 2, it shifts the first byte 8 bits to the left and adds it to the second byte. If the length is less than 2, it returns a default number of jurors. (autogenerated documentation)
getStakePerDraw() :
This function calculates the minimum amount of tokens that must be activated in order to participate in a draw. It does this by taking the alpha value (which is a multiplier that determines the minimum amount of tokens required to participate in a draw) and multiplying it by the minimum activated token value. The result is then divided by the ALPHA_DIVISOR, which is a constant used to ensure that the result is a whole number. (autogenerated documentation)
getVoteAccount() :
This function retrieves the account address associated with a particular vote in a dispute. It takes three parameters: the dispute ID, the appeals number, and the vote ID. It then returns the account address associated with the specified vote. (autogenerated documentation)
getVoteRuling() :
This function retrieves the ruling of a particular vote in a dispute. It takes three parameters: the dispute ID, the appeals number, and the vote ID. It then returns the ruling associated with the specified vote. (autogenerated documentation)
getWinningChoice() :
This function returns the winning choice of a dispute with a given dispute ID and appeals number. It works by accessing the disputes mapping and retrieving the voteCounter struct associated with the given dispute ID and appeals number. It then returns the winningChoice field of the struct. (autogenerated documentation)
getWinningCount() :
This function returns the number of winning votes for a particular dispute and appeal. It works by accessing the disputes mapping and retrieving the voteCounter mapping for the specified dispute and appeal. It then returns the winningCount value from the voteCounter mapping. (autogenerated documentation)
getVoteCount() :
This function returns the number of votes for a particular choice in a dispute. It takes in three parameters: the dispute ID, the appeals number, and the choice number. It then looks up the vote count for the specified dispute, appeals, and choice in the disputes mapping and returns it. (autogenerated documentation)
getLastSessionVote(address) :
This function retrieves the last session vote of a particular juror in a given dispute. It takes two parameters, the dispute ID and the address of the juror, and returns the last session vote of the juror as a uint. The function is viewable by anyone, meaning that the data can be accessed without changing the state of the blockchain. (autogenerated documentation)
isDrawn(address) :
This function checks if a particular juror has been drawn for a particular dispute. It takes in the dispute ID, the address of the juror, and the draw number as parameters. It first checks if the last session of the juror is the same as the current session, and if the dispute session plus the appeals is the same as the current session. It also checks if the period is in the draw period, if the draw number is greater than the amount of jurors for the dispute, if the draw number is 0, and if the segment size is 0. If all of these conditions are met, it calculates the position of the juror by taking the keccak256 hash of the random number, the dispute ID, and (autogenerated documentation)
currentRuling() :
This function returns the current ruling of a dispute with a given dispute ID. It works by accessing the storage of the dispute and returning the winningChoice value of the appeals counter. (autogenerated documentation)
disputeStatus() :
This function returns the status of a dispute based on the dispute ID provided. It checks the session and appeals associated with the dispute, as well as the current period, to determine the status of the dispute. If the dispute session and appeals are less than the current session, the dispute is considered solved. If the dispute session and appeals are equal to the current session, the dispute is either waiting or appealable depending on the current period. If the dispute session and appeals are greater than the current session, the dispute is waiting. (autogenerated documentation)
executeOrder(bytes32,address) :
This function is used to execute an order on the Ethereum blockchain. It takes three parameters: a bytes32 data, a uint value, and an address target. The function calls the target address with the given value and data. This allows the governor to execute orders on the blockchain, such as transferring funds or executing smart contracts. (autogenerated documentation)
setRng() :
This function sets the random number generator (RNG) for the contract. It is only accessible to the governor, meaning that only the governor can set the RNG. The RNG is used to generate random numbers for the contract, which can be used for various purposes such as determining the winner of a lottery. (autogenerated documentation)
setArbitrationFeePerJuror() :
This function allows the governor of the contract to set the arbitration fee per juror. This fee is used to determine the total arbitration fee for a dispute, which is calculated by multiplying the arbitration fee per juror by the number of jurors assigned to the dispute. (autogenerated documentation)
setDefaultNumberJuror(uint16) :
This function allows the Governor to set the default number of jurors for a dispute. It takes in a uint16 value as an argument and sets the defaultNumberJuror variable to this value. This value will be used as the default number of jurors for any new disputes created on the platform. (autogenerated documentation)
setMinActivatedToken() :
This function allows the governor to set the minimum amount of tokens that must be activated in order to participate in the token sale. It works by taking in a uint value as an argument and setting the minActivatedToken variable to that value. (autogenerated documentation)
setTimePerPeriod() :
This function allows the governor to set the amount of time for each period of the contract. The function takes an array of 5 unsigned integers as an argument, which represent the amount of time in seconds for each period. The function then sets the timePerPeriod variable to the array of times provided. (autogenerated documentation)
setAlpha() :
This function allows the governor of the contract to set the alpha value. Alpha is a parameter used to calculate the amount of tokens to be minted when a user deposits ETH into the contract. The function takes in a uint (unsigned integer) as an argument and sets the alpha value to that argument. (autogenerated documentation)
setMaxAppeals() :
This function allows the Governor to set the maximum number of appeals that can be made for a dispute. It works by taking in a uint (unsigned integer) value as an argument and setting the maxAppeals variable to that value. (autogenerated documentation)
setGovernor(address) :
This function sets the governor address of the contract. It can only be called by the current governor, and it takes an address as an argument. This address is then set as the new governor address. (autogenerated documentation)