generated from AngleProtocol/boilerplate
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
92e990d
commit dc4d2e3
Showing
1 changed file
with
61 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
// SPDX-License-Identifier: Unlicensed | ||
pragma solidity 0.8.26; | ||
|
||
import "../ERC4626StrategyTest.t.sol"; | ||
|
||
contract RecoverTokensTest is ERC4626StrategyTest { | ||
function test_recoverTokens_Success() public { | ||
deal(USDC, address(strategy), 10e18); | ||
|
||
address[] memory tokens = new address[](1); | ||
tokens[0] = USDC; | ||
|
||
vm.prank(keeper); | ||
strategy.recoverTokens(tokens, alice); | ||
|
||
assertEq(IERC20(USDC).balanceOf(alice), 10e18); | ||
} | ||
|
||
function test_recoverTokens_IgnoreAsset() public { | ||
deal(USDC, address(strategy), 10e18); | ||
deal(asset, address(strategy), 10e18); | ||
|
||
address[] memory tokens = new address[](2); | ||
tokens[0] = USDC; | ||
tokens[1] = asset; | ||
|
||
vm.prank(keeper); | ||
strategy.recoverTokens(tokens, alice); | ||
|
||
assertEq(IERC20(USDC).balanceOf(alice), 10e18); | ||
assertEq(IERC20(asset).balanceOf(alice), 0); | ||
assertEq(IERC20(asset).balanceOf(address(strategy)), 10e18); | ||
} | ||
|
||
function test_recoverTokens_IgnoreStrategyAsset() public { | ||
deal(USDC, address(strategy), 10e18); | ||
deal(strategyAsset, address(strategy), 10e18); | ||
|
||
address[] memory tokens = new address[](2); | ||
tokens[0] = USDC; | ||
tokens[1] = strategyAsset; | ||
|
||
vm.prank(keeper); | ||
strategy.recoverTokens(tokens, alice); | ||
|
||
assertEq(IERC20(USDC).balanceOf(alice), 10e18); | ||
assertEq(IERC20(strategyAsset).balanceOf(alice), 0); | ||
assertEq(IERC20(strategyAsset).balanceOf(address(strategy)), 10e18); | ||
} | ||
|
||
function test_recoverTokens_ZeroReceiver() public { | ||
deal(USDC, address(strategy), 10e18); | ||
|
||
address[] memory tokens = new address[](1); | ||
tokens[0] = USDC; | ||
|
||
vm.expectRevert(ZeroAddress.selector); | ||
vm.prank(keeper); | ||
strategy.recoverTokens(tokens, address(0)); | ||
} | ||
} |