Skip to content
This repository was archived by the owner on Aug 26, 2024. It is now read-only.

Commit 6f2a60c

Browse files
committed
feat: global pauser
1 parent 0cec821 commit 6f2a60c

File tree

1 file changed

+43
-0
lines changed

1 file changed

+43
-0
lines changed

contracts/GlobalPauser.sol

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
// SPDX-License-Identifier: UNLICENSED
2+
pragma solidity ^0.8.0;
3+
4+
import { IonicComptroller } from "./compound/ComptrollerInterface.sol";
5+
import { ICErc20 } from "./compound/CTokenInterfaces.sol";
6+
7+
interface IPoolDirectory {
8+
struct Pool {
9+
string name;
10+
address creator;
11+
address comptroller;
12+
uint256 blockPosted;
13+
uint256 timestampPosted;
14+
}
15+
16+
function getActivePools() external view returns (uint256, Pool[] memory);
17+
}
18+
19+
contract GlobalPauser {
20+
IPoolDirectory public poolDirectory;
21+
22+
constructor(address _poolDirectory) {
23+
poolDirectory = IPoolDirectory(_poolDirectory);
24+
}
25+
26+
function pauseAll(bool paused) external {
27+
(, IPoolDirectory.Pool[] memory pools) = poolDirectory.getActivePools();
28+
for (uint256 i = 0; i < pools.length; i++) {
29+
ICErc20[] memory markets = IonicComptroller(pools[i].comptroller).getAllMarkets();
30+
for (uint256 j = 0; j < markets.length; j++) {
31+
bool isPaused = IonicComptroller(pools[i].comptroller).borrowGuardianPaused(address(markets[j]));
32+
if (paused != isPaused) {
33+
IonicComptroller(pools[i].comptroller)._setBorrowPaused(markets[j], paused);
34+
}
35+
36+
isPaused = IonicComptroller(pools[i].comptroller).mintGuardianPaused(address(markets[j]));
37+
if (paused != isPaused) {
38+
IonicComptroller(pools[i].comptroller)._setMintPaused(markets[j], paused);
39+
}
40+
}
41+
}
42+
}
43+
}

0 commit comments

Comments
 (0)