Skip to content

Commit cb492fd

Browse files
fix(KC): check safeTransfer for withdrawLeftover
1 parent 5799a3b commit cb492fd

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

contracts/src/arbitration/KlerosCore.sol

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -632,7 +632,7 @@ contract KlerosCore is IArbitratorV2, Initializable, UUPSProxiable {
632632
function transferBySortitionModule(address _account, uint256 _amount) external {
633633
if (msg.sender != address(sortitionModule)) revert SortitionModuleOnly();
634634
// Note eligibility is checked in SortitionModule.
635-
pinakion.safeTransfer(_account, _amount);
635+
if (!pinakion.safeTransfer(_account, _amount)) revert TransferFailed();
636636
}
637637

638638
/// @inheritdoc IArbitratorV2

contracts/test/foundry/KlerosCore_Execution.t.sol

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -487,6 +487,15 @@ contract KlerosCore_ExecutionTest is KlerosCore_TestBase {
487487
assertEq(pinakion.balanceOf(address(core)), 1000, "Wrong token balance of the core");
488488
assertEq(sortitionModule.totalStaked(), 1000, "Wrong totalStaked before withdrawal");
489489

490+
vm.prank(address(core));
491+
pinakion.transfer(staker2, 1000); // Manually send the balance to trigger the revert
492+
493+
vm.expectRevert(KlerosCore.TransferFailed.selector);
494+
sortitionModule.withdrawLeftoverPNK(staker1);
495+
496+
vm.prank(staker2);
497+
pinakion.transfer(address(core), 1000); // Transfer the tokens back to execute withdrawal
498+
490499
vm.expectEmit(true, true, true, true);
491500
emit SortitionModule.LeftoverPNKWithdrawn(staker1, 1000);
492501
sortitionModule.withdrawLeftoverPNK(staker1);

0 commit comments

Comments
 (0)