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.
* feat: recover tokens from strategy * feat: check for receiver * tests: add RecoverTokens tests
- Loading branch information
1 parent
7c79b1a
commit 476608f
Showing
2 changed files
with
82 additions
and
1 deletion.
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
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)); | ||
} | ||
} |