From bc906e529812623187570f21646eaedd5a7d855c Mon Sep 17 00:00:00 2001 From: jaybuidl Date: Tue, 7 Oct 2025 17:50:04 +0100 Subject: [PATCH] fix: autostake the token rewards in the court where the stake originates from --- contracts/src/arbitration/KlerosCore.sol | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/contracts/src/arbitration/KlerosCore.sol b/contracts/src/arbitration/KlerosCore.sol index 7b1013a64..8030db65b 100644 --- a/contracts/src/arbitration/KlerosCore.sol +++ b/contracts/src/arbitration/KlerosCore.sol @@ -969,12 +969,13 @@ contract KlerosCore is IArbitratorV2, Initializable, UUPSProxiable { Dispute storage dispute = disputes[_params.disputeID]; Round storage round = dispute.rounds[_params.round]; IDisputeKit disputeKit = disputeKits[round.disputeKitID]; + uint256 repartition = _params.repartition % _params.numberOfVotesInRound; // [0, 1] value that determines how coherent the juror was in this round, in basis points. (uint256 pnkCoherence, uint256 feeCoherence) = disputeKit.getDegreeOfCoherenceReward( _params.disputeID, _params.round, - _params.repartition % _params.numberOfVotesInRound, + repartition, _params.feePerJurorInRound, _params.pnkAtStakePerJurorInRound ); @@ -987,7 +988,7 @@ contract KlerosCore is IArbitratorV2, Initializable, UUPSProxiable { feeCoherence = ONE_BASIS_POINT; } - address account = round.drawnJurors[_params.repartition % _params.numberOfVotesInRound]; + address account = round.drawnJurors[repartition]; uint256 pnkLocked = _applyCoherence(round.pnkAtStakePerJuror, pnkCoherence); // Release the rest of the PNKs of the juror for this round. @@ -1004,8 +1005,10 @@ contract KlerosCore is IArbitratorV2, Initializable, UUPSProxiable { _transferFeeToken(round.feeToken, payable(account), feeReward); } if (pnkReward != 0) { + uint96 rewardedInCourtID = round.drawnJurorFromCourtIDs[repartition]; + // Stake the PNK reward if possible, bypasses delayed stakes and other checks done by validateStake() - if (!sortitionModule.setStakeReward(account, dispute.courtID, pnkReward)) { + if (!sortitionModule.setStakeReward(account, rewardedInCourtID, pnkReward)) { pinakion.safeTransfer(account, pnkReward); } }