|
| 1 | +// SPDX-License-Identifier: UNLICENSED |
| 2 | +pragma solidity >=0.8.0; |
| 3 | + |
| 4 | +import { ERC20 } from "solmate/tokens/ERC20.sol"; |
| 5 | +import { TransparentUpgradeableProxy } from "@openzeppelin/contracts/proxy/transparent/TransparentUpgradeableProxy.sol"; |
| 6 | + |
| 7 | +import "./config/BaseTest.t.sol"; |
| 8 | +import { IonicComptroller } from "../compound/ComptrollerInterface.sol"; |
| 9 | +import { IComptroller } from "../external/compound/IComptroller.sol"; |
| 10 | +import { GlobalPauser } from "../GlobalPauser.sol"; |
| 11 | +import { PoolDirectory } from "../PoolDirectory.sol"; |
| 12 | +import { ICErc20 } from "../compound/CTokenInterfaces.sol"; |
| 13 | + |
| 14 | +import "forge-std/console.sol"; |
| 15 | + |
| 16 | +contract GlobalPauserTest is BaseTest { |
| 17 | + address public poolDirectory = 0x39C353Cf9041CcF467A04d0e78B63d961E81458a; |
| 18 | + address public pauseGuardian = 0xD9677b0eeafdCe6BF322d9774Bb65B1f42cF0404; |
| 19 | + address public multisig = 0x8Fba84867Ba458E7c6E2c024D2DE3d0b5C3ea1C2; |
| 20 | + GlobalPauser public pauser; // = GlobalPauser(0xe646D8Be18e545244C5E79F121202f75FA3880c8); |
| 21 | + |
| 22 | + function afterForkSetUp() internal override { |
| 23 | + super.afterForkSetUp(); |
| 24 | + pauser = new GlobalPauser(poolDirectory); |
| 25 | + pauser.setPauseGuardian(pauseGuardian, true); |
| 26 | + (, PoolDirectory.Pool[] memory pools) = PoolDirectory(poolDirectory).getActivePools(); |
| 27 | + for (uint256 i = 0; i < pools.length; i++) { |
| 28 | + vm.prank(IonicComptroller(pools[i].comptroller).admin()); |
| 29 | + IonicComptroller(pools[i].comptroller)._setPauseGuardian(address(pauser)); |
| 30 | + } |
| 31 | + } |
| 32 | + |
| 33 | + function testPauseNotGuardian(address sender) public debuggingOnly forkAtBlock(MODE_MAINNET, 9269895) { |
| 34 | + vm.assume(sender != pauseGuardian); |
| 35 | + vm.expectRevert(bytes("!guardian")); |
| 36 | + pauser.pauseAll(); |
| 37 | + } |
| 38 | + |
| 39 | + function testPauseAllMode() public debuggingOnly forkAtBlock(MODE_MAINNET, 9269895) { |
| 40 | + (, PoolDirectory.Pool[] memory pools) = PoolDirectory(poolDirectory).getActivePools(); |
| 41 | + for (uint256 i = 0; i < pools.length; i++) { |
| 42 | + ICErc20[] memory markets = IonicComptroller(pools[i].comptroller).getAllMarkets(); |
| 43 | + for (uint256 j = 0; j < markets.length; j++) { |
| 44 | + bool isPaused = IonicComptroller(pools[i].comptroller).borrowGuardianPaused(address(markets[j])); |
| 45 | + assertEq(isPaused, false); |
| 46 | + isPaused = IonicComptroller(pools[i].comptroller).mintGuardianPaused(address(markets[j])); |
| 47 | + assertEq(isPaused, false); |
| 48 | + } |
| 49 | + } |
| 50 | + vm.prank(pauseGuardian); |
| 51 | + pauser.pauseAll(); |
| 52 | + for (uint256 i = 0; i < pools.length; i++) { |
| 53 | + ICErc20[] memory markets = IonicComptroller(pools[i].comptroller).getAllMarkets(); |
| 54 | + for (uint256 j = 0; j < markets.length; j++) { |
| 55 | + bool isPaused = IonicComptroller(pools[i].comptroller).borrowGuardianPaused(address(markets[j])); |
| 56 | + assertEq(isPaused, true); |
| 57 | + isPaused = IonicComptroller(pools[i].comptroller).mintGuardianPaused(address(markets[j])); |
| 58 | + assertEq(isPaused, true); |
| 59 | + } |
| 60 | + } |
| 61 | + } |
| 62 | + |
| 63 | + function testPauseAllBase() public debuggingOnly forkAtBlock(BASE_MAINNET, 15970403) { |
| 64 | + address _poolDirectory = 0xE1A3006be645a80F206311d9f18C866c204bA02f; |
| 65 | + pauser = GlobalPauser(0x48F0F46F56C2Ca5def59fd673fF69495b7272Eb0); |
| 66 | + (, PoolDirectory.Pool[] memory pools) = PoolDirectory(_poolDirectory).getActivePools(); |
| 67 | + for (uint256 i = 0; i < pools.length; i++) { |
| 68 | + ICErc20[] memory markets = IonicComptroller(pools[i].comptroller).getAllMarkets(); |
| 69 | + for (uint256 j = 0; j < markets.length; j++) { |
| 70 | + bool isPaused = IonicComptroller(pools[i].comptroller).borrowGuardianPaused(address(markets[j])); |
| 71 | + assertEq(isPaused, false); |
| 72 | + isPaused = IonicComptroller(pools[i].comptroller).mintGuardianPaused(address(markets[j])); |
| 73 | + assertEq(isPaused, false); |
| 74 | + } |
| 75 | + } |
| 76 | + vm.prank(pauseGuardian); |
| 77 | + pauser.pauseAll(); |
| 78 | + for (uint256 i = 0; i < pools.length; i++) { |
| 79 | + ICErc20[] memory markets = IonicComptroller(pools[i].comptroller).getAllMarkets(); |
| 80 | + for (uint256 j = 0; j < markets.length; j++) { |
| 81 | + bool isPaused = IonicComptroller(pools[i].comptroller).borrowGuardianPaused(address(markets[j])); |
| 82 | + assertEq(isPaused, true); |
| 83 | + isPaused = IonicComptroller(pools[i].comptroller).mintGuardianPaused(address(markets[j])); |
| 84 | + assertEq(isPaused, true); |
| 85 | + } |
| 86 | + } |
| 87 | + } |
| 88 | +} |
0 commit comments