forked from aave-dao/aave-v3-origin
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: use permissionless rescuable (aave-dao#20)
- Loading branch information
Showing
7 changed files
with
55 additions
and
29 deletions.
There are no files selected for viewing
Submodule solidity-utils
updated
29 files
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
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
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 |
---|---|---|
@@ -1,31 +1,37 @@ | ||
// SPDX-License-Identifier: BUSL-1.1 | ||
pragma solidity ^0.8.10; | ||
|
||
import {IRescuable} from 'solidity-utils/contracts/utils/Rescuable.sol'; | ||
import {IAToken} from '../../../src/periphery/contracts/static-a-token/StataTokenV2.sol'; | ||
import {BaseTest} from './TestBase.sol'; | ||
|
||
contract StataTokenV2RescuableTest is BaseTest { | ||
function test_whoCanRescue() external view { | ||
assertEq(IRescuable(address(stataTokenV2)).whoCanRescue(), poolAdmin); | ||
} | ||
event ERC20Rescued( | ||
address indexed caller, | ||
address indexed token, | ||
address indexed to, | ||
uint256 amount | ||
); | ||
|
||
function test_rescuable_shouldRevertForInvalidCaller() external { | ||
function test_rescuable_shouldTransferAssetsToCollector() external { | ||
deal(tokenList.usdx, address(stataTokenV2), 1 ether); | ||
vm.expectRevert('ONLY_RESCUE_GUARDIAN'); | ||
IRescuable(address(stataTokenV2)).emergencyTokenTransfer( | ||
tokenList.usdx, | ||
address(this), | ||
1 ether | ||
); | ||
stataTokenV2.emergencyTokenTransfer(tokenList.usdx, 1 ether); | ||
} | ||
|
||
function test_rescuable_shouldSuceedForOwner() external { | ||
deal(tokenList.usdx, address(stataTokenV2), 1 ether); | ||
vm.startPrank(poolAdmin); | ||
IRescuable(address(stataTokenV2)).emergencyTokenTransfer( | ||
tokenList.usdx, | ||
address(this), | ||
1 ether | ||
); | ||
function test_rescuable_shouldWorkForAToken() external { | ||
_fundAToken(1 ether, address(stataTokenV2)); | ||
stataTokenV2.emergencyTokenTransfer(aToken, 1 ether); | ||
} | ||
|
||
function test_rescuable_shouldNotCauseInsolvency(uint256 donation, uint256 stake) external { | ||
vm.assume(donation != 0 && donation <= type(uint96).max); | ||
vm.assume(stake != 0 && stake <= type(uint96).max); | ||
_fundAToken(donation, address(stataTokenV2)); | ||
_fund4626(stake, address(this)); | ||
|
||
address treasury = IAToken(aToken).RESERVE_TREASURY_ADDRESS(); | ||
|
||
vm.expectEmit(true, true, true, true); | ||
emit ERC20Rescued(address(this), aToken, treasury, donation); | ||
stataTokenV2.emergencyTokenTransfer(aToken, donation + stake); | ||
} | ||
} |
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