Skip to content

Commit d8ca70d

Browse files
committed
added integration test for AaveETHBackend and related logic fix
1 parent 1e49964 commit d8ca70d

File tree

5 files changed

+440
-8
lines changed

5 files changed

+440
-8
lines changed

packages/ethereum-contracts/contracts/superfluid/AaveETHYieldBackend.sol

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ contract AaveETHYieldBackend is AaveYieldBackend {
8282
// fallback function of the SuperToken contract.
8383
uint256 withdrawnAmount = AAVE_POOL.withdraw(address(ASSET_TOKEN), amount, address(_SELF));
8484
// unwrap to ETH and transfer it to the calling SuperToken contract
85-
_SELF.unwrapWETHAndForwardETH(withdrawnAmount);
85+
_SELF.unwrapWETHAndForwardETH(withdrawnAmount, address(this));
8686
}
8787

8888
// ============ functions operating on this contract itself (NOT in delegatecall context) ============
@@ -92,11 +92,11 @@ contract AaveETHYieldBackend is AaveYieldBackend {
9292

9393
// To be invoked by `withdraw` which is executed via delegatecall in a SuperToken context.
9494
// WETH deposited or withdrawn by the SuperToken never stays in this contract beyond the lifetime of the tx.
95-
// Thus it is not necessary to check msg.sender.
95+
// Thus it is not necessary to restrict msg.sender.
9696
// We accept that an alien caller may withdraw WETH deposited to this contract (for whatever reason).
97-
function unwrapWETHAndForwardETH(uint256 amount) external {
97+
function unwrapWETHAndForwardETH(uint256 amount, address recipient) external {
9898
IWETH(address(ASSET_TOKEN)).withdraw(amount);
99-
(bool success,) = address(msg.sender).call{ value: amount }("");
99+
(bool success,) = recipient.call{ value: amount }("");
100100
require(success, "call failed");
101101
}
102102
}

packages/ethereum-contracts/contracts/superfluid/SuperToken.sol

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,12 @@ contract SuperToken is
219219
function disableYieldBackend() external onlyAdmin {
220220
require(address(_yieldBackend) != address(0), "yield backend not set");
221221
address oldYieldBackend = address(_yieldBackend);
222+
223+
// This guard is needed for the native token wrapper
224+
_skipSelfMint = true;
222225
delegateCallChecked(address(_yieldBackend), abi.encodeCall(IYieldBackend.withdrawMax, ()));
226+
_skipSelfMint = false;
227+
223228
delegateCallChecked(address(_yieldBackend), abi.encodeCall(IYieldBackend.disable, ()));
224229
_yieldBackend = IYieldBackend(address(0));
225230
emit YieldBackendDisabled(oldYieldBackend);

0 commit comments

Comments
 (0)