Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 9 additions & 3 deletions src/contracts/LidoARM.sol
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,12 @@ contract LidoARM is Initializable, AbstractARM {
* @param hintIds The hint IDs of the withdrawal requests.
* Call `findCheckpointHints` on the Lido withdrawal queue contract to get the hint IDs.
*/
function claimLidoWithdrawals(uint256[] calldata requestIds, uint256[] calldata hintIds) external {
function claimLidoWithdrawals(uint256[] calldata requestIds, uint256[] calldata hintIds)
external
onlyOperatorOrOwner
{
Comment on lines +144 to +147
uint256 ethBalanceBefore = address(this).balance;

// Claim the NFTs for ETH.
lidoWithdrawalQueue.claimWithdrawals(requestIds, hintIds);

Expand All @@ -165,8 +170,9 @@ contract LidoARM is Initializable, AbstractARM {
// this subtraction should never underflow.
lidoWithdrawalQueueAmount -= totalAmountRequested;

// Wrap all the received ETH to WETH. This can be less than the requested amount in the event of slashing.
weth.deposit{value: address(this).balance}();
// Wrap only the ETH received from this claim. This can be less than the requested amount in the event of slashing.
uint256 ethReceived = address(this).balance - ethBalanceBefore;
if (ethReceived > 0) weth.deposit{value: ethReceived}();
Comment on lines +174 to +175

emit ClaimLidoWithdrawals(requestIds);
}
Expand Down
37 changes: 37 additions & 0 deletions test/fork/LidoARM/ClaimStETHWithdrawalForWETH.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,16 @@ contract Fork_Concrete_LidoARM_ClaimLidoWithdrawals_Test_ is Fork_Shared_Test_ {
amounts2[1] = DEFAULT_AMOUNT;
}

//////////////////////////////////////////////////////
/// --- REVERTING TESTS
//////////////////////////////////////////////////////
function test_RevertWhen_ClaimLidoWithdrawals_NotOperatorOrOwner() public asRandomAddress {
uint256[] memory emptyList = new uint256[](0);

vm.expectRevert("ARM: Only operator or owner can call this function.");
lidoARM.claimLidoWithdrawals(emptyList, emptyList);
}

//////////////////////////////////////////////////////
/// --- PASSING TESTS
//////////////////////////////////////////////////////
Expand Down Expand Up @@ -83,6 +93,33 @@ contract Fork_Concrete_LidoARM_ClaimLidoWithdrawals_Test_ is Fork_Shared_Test_ {
assertEq(weth.balanceOf(address(lidoARM)), balanceBefore + DEFAULT_AMOUNT);
}

function test_ClaimLidoWithdrawals_OnlyWrapsClaimedETH()
public
asOperator
requestLidoWithdrawalsOnLidoARM(amounts1)
mockFunctionClaimWithdrawOnLidoARM(DEFAULT_AMOUNT)
{
uint256 donatedETH = 0.5 ether;
vm.deal(address(lidoARM), donatedETH);

uint256 balanceBefore = weth.balanceOf(address(lidoARM));
assertEq(address(lidoARM).balance, donatedETH);
assertEq(lidoARM.lidoWithdrawalQueueAmount(), DEFAULT_AMOUNT);

stETHWithdrawal.getLastRequestId();
uint256[] memory requests = new uint256[](1);
requests[0] = stETHWithdrawal.getLastRequestId();

uint256 lastIndex = stETHWithdrawal.getLastCheckpointIndex();
uint256[] memory hintIds = stETHWithdrawal.findCheckpointHints(requests, 1, lastIndex);

lidoARM.claimLidoWithdrawals(requests, hintIds);

assertEq(address(lidoARM).balance, donatedETH);
assertEq(lidoARM.lidoWithdrawalQueueAmount(), 0);
assertEq(weth.balanceOf(address(lidoARM)), balanceBefore + DEFAULT_AMOUNT);
}

function test_ClaimLidoWithdrawals_MultiRequest()
public
asOperator
Expand Down
2 changes: 1 addition & 1 deletion test/fork/utils/MockCall.sol
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,6 @@ contract ETHSender {
Vm private constant vm = Vm(address(uint160(uint256(keccak256("hevm cheat code")))));

function sendETH(address target) external {
vm.deal(target, address(this).balance);
vm.deal(target, target.balance + address(this).balance);
}
}