11/**
22 * https://contributing.kleros.io/smart-contract-workflow
33 * @authors: [@fnanni-0]
4- * @reviewers: [@shalzz*, @unknownunknown1*, @MerlinEgalite*, @hbarcelos* ]
4+ * @reviewers: [@shalzz*, @unknownunknown1*, @MerlinEgalite*, @hbarcelos]
55 * @auditors: []
66 * @bounties: []
77 * @deployments: []
@@ -21,7 +21,8 @@ import { SortitionSumTreeFactory } from "@kleros/kleros/contracts/data-structure
2121/**
2222 * @title xKlerosLiquid
2323 * @dev This contract is an adaption of Mainnet's KlerosLiquid (https://github.com/kleros/kleros/blob/69cfbfb2128c29f1625b3a99a3183540772fda08/contracts/kleros/KlerosLiquid.sol)
24- * for xDai chain.
24+ * for xDai chain. Notice that variables referring to ETH values in this contract, will hold the native token values of the chain on which xKlerosLiquid is deployed.
25+ * When this contract gets deployed on xDai chain, ETH variables will hold xDai values.
2526 */
2627contract xKlerosLiquid is Initializable , TokenController , Arbitrator {
2728 /* Enums */
@@ -133,21 +134,20 @@ contract xKlerosLiquid is Initializable, TokenController, Arbitrator {
133134 */
134135 event Draw (address indexed _address , uint indexed _disputeID , uint _appeal , uint _voteID );
135136
136- /** @dev Emitted when a juror wins or loses tokens and xDai from a dispute.
137- * The original name from KlerosLiquid is kept in this event to match its ABI.
137+ /** @dev Emitted when a juror wins or loses tokens and ETH from a dispute.
138138 * @param _address The juror affected.
139139 * @param _disputeID The ID of the dispute.
140140 * @param _tokenAmount The amount of tokens won or lost.
141- * @param _xDaiAmount The amount of xDai won or lost.
141+ * @param _ETHAmount The amount of ETH won or lost.
142142 */
143- event TokenAndETHShift (address indexed _address , uint indexed _disputeID , int _tokenAmount , int _xDaiAmount );
143+ event TokenAndETHShift (address indexed _address , uint indexed _disputeID , int _tokenAmount , int _ETHAmount );
144144
145145 /* Storage */
146146
147147 // General Constants
148148 uint public constant MAX_STAKE_PATHS = 4 ; // The maximum number of stake paths a juror can have.
149149 uint public constant MIN_JURORS = 3 ; // The global default minimum number of jurors in a dispute.
150- uint public constant NON_PAYABLE_AMOUNT = (2 ** 256 - 2 ) / 2 ; // An amount higher than the supply of xDai .
150+ uint public constant NON_PAYABLE_AMOUNT = (2 ** 256 - 2 ) / 2 ; // An amount higher than the supply of ETH .
151151 uint public constant ALPHA_DIVISOR = 1e4 ; // The number to divide `Court.alpha` by.
152152 // General Contracts
153153 address public governor; // The governor of the contract.
@@ -164,7 +164,6 @@ contract xKlerosLiquid is Initializable, TokenController, Arbitrator {
164164 uint public maxDrawingTime; // The maximum drawing time.
165165 // True if insolvent (`balance < stakedTokens || balance < lockedTokens`) token transfers should be blocked. Used to avoid blocking penalties.
166166 bool public lockInsolventTransfers;
167- uint public totalStake;
168167 // General Storage
169168 Court[] public courts; // The subcourts.
170169 using SortitionSumTreeFactory for SortitionSumTreeFactory.SortitionSumTrees; // Use library functions for sortition sum trees.
@@ -572,14 +571,13 @@ contract xKlerosLiquid is Initializable, TokenController, Arbitrator {
572571 }
573572 }
574573
575- /** @dev Computes the token and xDai rewards for a specified appeal in a specified dispute.
576- * The original name from KlerosLiquid is kept in this function to match its ABI.
574+ /** @dev Computes the token and ETH rewards for a specified appeal in a specified dispute.
577575 * @param _disputeID The ID of the dispute.
578576 * @param _appeal The appeal.
579577 * @return tokenReward The token reward.
580- * @return xDaiReward The xDai reward.
578+ * @return ETHReward The ETH reward.
581579 */
582- function computeTokenAndETHRewards (uint _disputeID , uint _appeal ) private view returns (uint tokenReward , uint xDaiReward ) {
580+ function computeTokenAndETHRewards (uint _disputeID , uint _appeal ) private view returns (uint tokenReward , uint ETHReward ) {
583581 Dispute storage dispute = disputes[_disputeID];
584582
585583 // Distribute penalties and arbitration fees.
@@ -588,21 +586,21 @@ contract xKlerosLiquid is Initializable, TokenController, Arbitrator {
588586 uint activeCount = dispute.votesInEachRound[_appeal];
589587 if (activeCount > 0 ) {
590588 tokenReward = dispute.penaltiesInEachRound[_appeal] / activeCount;
591- xDaiReward = dispute.totalFeesForJurors[_appeal] / activeCount;
589+ ETHReward = dispute.totalFeesForJurors[_appeal] / activeCount;
592590 } else {
593591 tokenReward = 0 ;
594- xDaiReward = 0 ;
592+ ETHReward = 0 ;
595593 }
596594 } else {
597595 // Distribute penalties and fees evenly between coherent jurors.
598596 uint winningChoice = dispute.voteCounters[dispute.voteCounters.length - 1 ].winningChoice;
599597 uint coherentCount = dispute.voteCounters[_appeal].counts[winningChoice];
600598 tokenReward = dispute.penaltiesInEachRound[_appeal] / coherentCount;
601- xDaiReward = dispute.totalFeesForJurors[_appeal] / coherentCount;
599+ ETHReward = dispute.totalFeesForJurors[_appeal] / coherentCount;
602600 }
603601 }
604602
605- /** @dev Repartitions tokens and xDai for a specified appeal in a specified dispute. Can be called in parts.
603+ /** @dev Repartitions tokens and ETH for a specified appeal in a specified dispute. Can be called in parts.
606604 * `O(i + u * n * (n + p * log_k(j)))` where
607605 * `i` is the number of iterations to run,
608606 * `u` is the number of jurors that need to be unstaked,
@@ -620,7 +618,7 @@ contract xKlerosLiquid is Initializable, TokenController, Arbitrator {
620618 uint end = dispute.repartitionsInEachRound[_appeal] + _iterations;
621619 require (end >= dispute.repartitionsInEachRound[_appeal]);
622620 uint penaltiesInRoundCache = dispute.penaltiesInEachRound[_appeal]; // For saving gas.
623- (uint tokenReward , uint xDaiReward ) = (0 , 0 );
621+ (uint tokenReward , uint ETHReward ) = (0 , 0 );
624622
625623 // Avoid going out of range.
626624 if (
@@ -631,7 +629,7 @@ contract xKlerosLiquid is Initializable, TokenController, Arbitrator {
631629 if (end > dispute.votes[_appeal].length ) end = dispute.votes[_appeal].length ;
632630 } else {
633631 // We loop over the votes twice, first to collect penalties, and second to distribute them as rewards along with arbitration fees.
634- (tokenReward, xDaiReward ) = dispute.repartitionsInEachRound[_appeal] >= dispute.votes[_appeal].length ? computeTokenAndETHRewards (_disputeID, _appeal) : (0 , 0 ); // Compute rewards if rewarding.
632+ (tokenReward, ETHReward ) = dispute.repartitionsInEachRound[_appeal] >= dispute.votes[_appeal].length ? computeTokenAndETHRewards (_disputeID, _appeal) : (0 , 0 ); // Compute rewards if rewarding.
635633 if (end > dispute.votes[_appeal].length * 2 ) end = dispute.votes[_appeal].length * 2 ;
636634 }
637635 for (uint i = dispute.repartitionsInEachRound[_appeal]; i < end; i++ ) {
@@ -645,8 +643,8 @@ contract xKlerosLiquid is Initializable, TokenController, Arbitrator {
645643 // Reward.
646644 pinakion.transfer (vote.account, tokenReward);
647645 // Intentional use to avoid blocking.
648- vote.account.send (xDaiReward ); // solium-disable-line security/no-send
649- emit TokenAndETHShift (vote.account, _disputeID, int (tokenReward), int (xDaiReward ));
646+ vote.account.send (ETHReward ); // solium-disable-line security/no-send
647+ emit TokenAndETHShift (vote.account, _disputeID, int (tokenReward), int (ETHReward ));
650648 jurors[vote.account].lockedTokens -= dispute.tokensAtStakePerJuror[_appeal];
651649 }
652650 } else { // Juror was inactive, or voted incoherently and it was not a tie.
@@ -675,7 +673,7 @@ contract xKlerosLiquid is Initializable, TokenController, Arbitrator {
675673 } else if (i + 1 < end) {
676674 // Compute rewards because we are going into rewarding.
677675 dispute.penaltiesInEachRound[_appeal] = penaltiesInRoundCache;
678- (tokenReward, xDaiReward ) = computeTokenAndETHRewards (_disputeID, _appeal);
676+ (tokenReward, ETHReward ) = computeTokenAndETHRewards (_disputeID, _appeal);
679677 }
680678 }
681679 }
@@ -761,8 +759,8 @@ contract xKlerosLiquid is Initializable, TokenController, Arbitrator {
761759 emit NewPeriod (_disputeID, Period.evidence);
762760 }
763761
764- /** @dev DEPRECATED. Called when `_owner` sends xDai to the Wrapped Token contract.
765- * @param _owner The address that sent the xDai to create tokens.
762+ /** @dev DEPRECATED. Called when `_owner` sends ETH to the Wrapped Token contract.
763+ * @param _owner The address that sent the ETH to create tokens.
766764 * @return allowed Whether the operation should be allowed or not.
767765 */
768766 function proxyPayment (address _owner ) public payable returns (bool allowed ) { allowed = false ; }
0 commit comments