Skip to content

Commit

Permalink
feat: added contract balance to queue processing
Browse files Browse the repository at this point in the history
  • Loading branch information
sandybradley committed Feb 17, 2024
1 parent cc6d6c6 commit ad86396
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
7 changes: 6 additions & 1 deletion script/ProcessQueueExitsandRewards.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ contract ProcessQueueExitsandRewardsScript is BatchScript {
// assuming rewards balance = remaing multisig balance - 10%
uint256 rewardsBalance = (safe.balance - exitsBalance) * 90 / 100;

uint256 payout = exitsBalance + rewardsBalance;
uint256 payout = exitsBalance + rewardsBalance + address(mevEth).balance;

if (numExits == 0 && rewardsBalance == 0) {
revert NothingToProcess();
Expand Down Expand Up @@ -61,6 +61,11 @@ contract ProcessQueueExitsandRewardsScript is BatchScript {
} else {
// numExits stays the max as original
rewardsToProcess = amountToProcess - exitsBalance;
if (address(mevEth).balance >= rewardsToProcess) {
rewardsToProcess = 0;
} else {
rewardsToProcess = rewardsToProcess - address(mevEth).balance;
}
}

// build tx
Expand Down
3 changes: 3 additions & 0 deletions test/ProcessQueueExitsandRewards.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ contract ProcessQueueExitsandRewardsTest is Test {
string RPC_ETH_MAINNET = vm.envString("RPC_MAINNET");
uint256 FORK_ID;
ProcessQueueExitsandRewardsScript process;
IMevEthQueue mevEth = IMevEthQueue(0x24Ae2dA0f361AA4BE46b48EB19C91e02c5e4f27E);

function setUp() public virtual {
FORK_ID = vm.createSelectFork(RPC_ETH_MAINNET, 18_977_178);
Expand All @@ -19,6 +20,8 @@ contract ProcessQueueExitsandRewardsTest is Test {
function testProcessQueueExitsandRewards() public virtual {
vm.selectFork(FORK_ID);
vm.deal(0x617c8dE5BdE54ffbb8d92716CC947858cA38f582, 4 * 32 ether + 49 ether);
vm.deal(address(mevEth), 0.51327282151044822 ether);
process.run(5);
assertEq(mevEth.requestsFinalisedUntil(), 150);
}
}

0 comments on commit ad86396

Please sign in to comment.