Skip to content

Commit 67b3a76

Browse files
unknownunknown1jaybuidl
authored andcommitted
feat(KlerosCore): send leftover to governor
1 parent 35352ed commit 67b3a76

File tree

3 files changed

+22
-4
lines changed

3 files changed

+22
-4
lines changed

contracts/src/arbitration/KlerosCore.sol

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -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

contracts/src/arbitration/dispute-kits/DisputeKitClassic.sol

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -538,7 +538,7 @@ contract DisputeKitClassic is BaseDisputeKit, IEvidence {
538538
/// @return Whether the address can be drawn or not.
539539
function _postDrawCheck(uint256 _coreDisputeID, address _juror) internal view override returns (bool) {
540540
(uint96 courtID, , , , ) = core.disputes(_coreDisputeID);
541-
(uint256 lockedAmountPerJuror, , , , , ) = core.getRoundInfo(
541+
(uint256 lockedAmountPerJuror, , , , , , , ) = core.getRoundInfo(
542542
_coreDisputeID,
543543
core.getNumberOfRounds(_coreDisputeID) - 1
544544
);

contracts/src/arbitration/dispute-kits/DisputeKitSybilResistant.sol

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -558,7 +558,7 @@ contract DisputeKitSybilResistant is BaseDisputeKit, IEvidence {
558558
/// @return Whether the address can be drawn or not.
559559
function _postDrawCheck(uint256 _coreDisputeID, address _juror) internal view override returns (bool) {
560560
(uint96 courtID, , , , ) = core.disputes(_coreDisputeID);
561-
(uint256 lockedAmountPerJuror, , , , , ) = core.getRoundInfo(
561+
(uint256 lockedAmountPerJuror, , , , , , , ) = core.getRoundInfo(
562562
_coreDisputeID,
563563
core.getNumberOfRounds(_coreDisputeID) - 1
564564
);

0 commit comments

Comments
 (0)