@@ -58,6 +58,8 @@ contract KlerosCore is IArbitrator {
5858 uint256 repartitions; // A counter of reward repartitions made in this round.
5959 uint256 penalties; // The amount of tokens collected from penalties in this round.
6060 address [] drawnJurors; // Addresses of the jurors that were drawn in this round.
61+ uint256 sumRewardPaid; // Total sum of arbitration fees paid to coherent jurors as a reward in this round.
62+ uint256 sumTokenRewardPaid; // Total sum of tokens paid to coherent jurors as a reward in this round.
6163 }
6264
6365 struct Juror {
@@ -718,7 +720,9 @@ contract KlerosCore is IArbitrator {
718720 }
719721
720722 uint256 tokenReward = ((penaltiesInRoundCache / coherentCount) * degreeOfCoherence) / ALPHA_DIVISOR;
723+ round.sumTokenRewardPaid += tokenReward;
721724 uint256 ethReward = ((round.totalFeesForJurors / coherentCount) * degreeOfCoherence) / ALPHA_DIVISOR;
725+ round.sumRewardPaid += ethReward;
722726 _safeTransfer (account, tokenReward);
723727 payable (account).send (ethReward);
724728 emit TokenAndETHShift (
@@ -729,6 +733,16 @@ contract KlerosCore is IArbitrator {
729733 int256 (tokenReward),
730734 int256 (ethReward)
731735 );
736+
737+ if (i == numberOfVotesInRound * 2 - 1 ) {
738+ // Due to partial coherence of the jurors there might still be a leftover reward. Send it to governor.
739+ if (round.totalFeesForJurors > round.sumRewardPaid) {
740+ payable (governor).send (round.totalFeesForJurors - round.sumRewardPaid);
741+ }
742+ if (penaltiesInRoundCache > round.sumTokenRewardPaid) {
743+ _safeTransfer (governor, penaltiesInRoundCache - round.sumTokenRewardPaid);
744+ }
745+ }
732746 }
733747 }
734748
@@ -824,7 +838,9 @@ contract KlerosCore is IArbitrator {
824838 uint256 repartitions ,
825839 uint256 penalties ,
826840 address [] memory drawnJurors ,
827- uint256 disputeKitID
841+ uint256 disputeKitID ,
842+ uint256 sumRewardPaid ,
843+ uint256 sumTokenRewardPaid
828844 )
829845 {
830846 Round storage round = disputes[_disputeID].rounds[_round];
@@ -834,7 +850,9 @@ contract KlerosCore is IArbitrator {
834850 round.repartitions,
835851 round.penalties,
836852 round.drawnJurors,
837- round.disputeKitID
853+ round.disputeKitID,
854+ round.sumRewardPaid,
855+ round.sumTokenRewardPaid
838856 );
839857 }
840858
0 commit comments