From ad86396e6959c04c7ef73256d39e0beb61f8f183 Mon Sep 17 00:00:00 2001 From: sandybradley Date: Sat, 17 Feb 2024 08:02:12 +0200 Subject: [PATCH] feat: added contract balance to queue processing --- script/ProcessQueueExitsandRewards.s.sol | 7 ++++++- test/ProcessQueueExitsandRewards.t.sol | 3 +++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/script/ProcessQueueExitsandRewards.s.sol b/script/ProcessQueueExitsandRewards.s.sol index c054e00..d760116 100644 --- a/script/ProcessQueueExitsandRewards.s.sol +++ b/script/ProcessQueueExitsandRewards.s.sol @@ -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(); @@ -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 diff --git a/test/ProcessQueueExitsandRewards.t.sol b/test/ProcessQueueExitsandRewards.t.sol index 18e1c07..2af9851 100644 --- a/test/ProcessQueueExitsandRewards.t.sol +++ b/test/ProcessQueueExitsandRewards.t.sol @@ -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); @@ -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); } }