Skip to content
Draft
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
1 change: 1 addition & 0 deletions src/tenderizer/Tenderizer.sol
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@ contract Tenderizer is TenderizerImmutableArgs, TenderizerEvents, TToken, Multic

// withdraw assets to send to `receiver`
amount = _withdraw(validator(), unlockID);
if (amount == 0) revert InsufficientAssets();

// transfer assets to `receiver`
ERC20(asset()).safeTransfer(receiver, amount);
Expand Down
11 changes: 11 additions & 0 deletions test/tenderizer/Tenderizer.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import { StdCheats } from "forge-std/StdCheats.sol";
import { IERC20, IERC20Metadata } from "core/interfaces/IERC20.sol";
import { Adapter, TenderizerHarness } from "test/tenderizer/Tenderizer.harness.sol";
import { AdapterDelegateCall } from "core/adapters/Adapter.sol";
import { Tenderizer as TenderizerContract } from "core/tenderizer/Tenderizer.sol";
import { TenderizerEvents } from "core/tenderizer/TenderizerBase.sol";
import { StaticCallFailed } from "core/utils/StaticCall.sol";
import { TToken } from "core/tendertoken/TToken.sol";
Expand Down Expand Up @@ -298,6 +299,16 @@ contract TenderizerTest is TenderizerSetup, TenderizerEvents {
tenderizer.withdraw(account1, unlockID);
}

function test_Withdraw_RevertIfAdapterReturnsZeroAssets() public {
uint256 unlockID = 1;
vm.mockCall(unlocks, abi.encodeCall(Unlocks.useUnlock, (account1, unlockID)), "");
vm.mockCall(adapter, abi.encodeCall(Adapter.withdraw, (validator, unlockID)), abi.encode(0));

vm.prank(account1);
vm.expectRevert(TenderizerContract.InsufficientAssets.selector);
tenderizer.withdraw(account2, unlockID);
}

function test_Withdraw_RevertIfUseUnlockFails() public {
uint256 unlockID = 1;
// Calls to mocked addresses may revert if there is no code on the address.
Expand Down