Skip to content

Commit 4a70abd

Browse files
committed
prevent any type of ETH donation
1 parent 7b6b0bd commit 4a70abd

4 files changed

Lines changed: 22 additions & 16 deletions

File tree

src/contracts/adapters/EtherFiAssetAdapter.sol

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -166,11 +166,11 @@ contract EtherFiAssetAdapter is Initializable, IAssetAdapter, IERC721Receiver {
166166
return pendingRequestIds[index];
167167
}
168168

169-
/// @notice Accepts ETH donations and authorized Ether.fi claim proceeds.
170-
/// @dev A permissionless Ether.fi claim is rejected unless it was initiated by this adapter.
171-
/// Ether.fi reverts the entire claim, including the NFT burn, when this transfer fails.
169+
/// @notice Accepts ETH only while this adapter is claiming Ether.fi withdrawals.
170+
/// @dev ETH arriving outside an adapter-initiated claim (e.g. a permissionless Ether.fi claim) is
171+
/// rejected. Ether.fi reverts the entire claim, including the NFT burn, when this transfer fails.
172172
receive() external payable {
173-
if (msg.sender == address(etherfiWithdrawalNFT) && !claimingEtherFi) {
173+
if (!claimingEtherFi) {
174174
revert UnauthorizedEtherFiClaim();
175175
}
176176
}

src/contracts/adapters/WeETHAssetAdapter.sol

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -176,11 +176,11 @@ contract WeETHAssetAdapter is Initializable, IAssetAdapter, IERC721Receiver {
176176
return pendingRequestIds[index];
177177
}
178178

179-
/// @notice Accepts ETH donations and authorized Ether.fi claim proceeds.
180-
/// @dev A permissionless Ether.fi claim is rejected unless it was initiated by this adapter.
181-
/// Ether.fi reverts the entire claim, including the NFT burn, when this transfer fails.
179+
/// @notice Accepts ETH only while this adapter is claiming Ether.fi withdrawals.
180+
/// @dev ETH arriving outside an adapter-initiated claim (e.g. a permissionless Ether.fi claim) is
181+
/// rejected. Ether.fi reverts the entire claim, including the NFT burn, when this transfer fails.
182182
receive() external payable {
183-
if (msg.sender == address(etherfiWithdrawalNFT) && !claimingEtherFi) {
183+
if (!claimingEtherFi) {
184184
revert UnauthorizedEtherFiClaim();
185185
}
186186
}

test/unit/adapters/concrete/EtherFiAssetAdapter.t.sol

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -280,11 +280,14 @@ contract Unit_EtherFiAssetAdapter_Test is Test {
280280
);
281281
}
282282

283-
function test_Receive_AcceptsEth() public {
283+
function test_Receive_RevertWhen_EthArrivesOutsideClaim() public {
284+
// Any ETH — not just NFT-forwarded claim proceeds — is refused outside an adapter-initiated claim.
284285
vm.deal(address(this), 1 ether);
285-
(bool ok,) = address(adapter).call{value: 1 ether}("");
286-
assertTrue(ok, "adapter accepts ETH");
287-
assertEq(address(adapter).balance, 1 ether, "adapter eth balance");
286+
(bool ok, bytes memory ret) = address(adapter).call{value: 1 ether}("");
287+
288+
assertFalse(ok, "adapter rejects ETH outside a claim");
289+
assertEq(bytes4(ret), EtherFiAssetAdapter.UnauthorizedEtherFiClaim.selector, "revert selector");
290+
assertEq(address(adapter).balance, 0, "no ETH retained");
288291
}
289292

290293
//////////////////////////////////////////////////////

test/unit/adapters/concrete/WeETHAssetAdapter.t.sol

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -264,11 +264,14 @@ contract Unit_WeETHAssetAdapter_Test is Test {
264264
);
265265
}
266266

267-
function test_Receive_AcceptsEth() public {
267+
function test_Receive_RevertWhen_EthArrivesOutsideClaim() public {
268+
// Any ETH — not just NFT-forwarded claim proceeds — is refused outside an adapter-initiated claim.
268269
vm.deal(address(this), 1 ether);
269-
(bool ok,) = address(adapter).call{value: 1 ether}("");
270-
assertTrue(ok, "adapter accepts ETH");
271-
assertEq(address(adapter).balance, 1 ether, "adapter eth balance");
270+
(bool ok, bytes memory ret) = address(adapter).call{value: 1 ether}("");
271+
272+
assertFalse(ok, "adapter rejects ETH outside a claim");
273+
assertEq(bytes4(ret), WeETHAssetAdapter.UnauthorizedEtherFiClaim.selector, "revert selector");
274+
assertEq(address(adapter).balance, 0, "no ETH retained");
272275
}
273276

274277
//////////////////////////////////////////////////////

0 commit comments

Comments
 (0)