forked from compound-finance/compound-protocol
/
ComptrollerStorage.sol
147 lines (117 loc) · 4.32 KB
/
ComptrollerStorage.sol
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
pragma solidity ^0.5.16;
import "./IFuseFeeDistributor.sol";
import "./CToken.sol";
import "./PriceOracle.sol";
contract UnitrollerAdminStorage {
/**
* @notice Administrator for Fuse
*/
IFuseFeeDistributor internal constant fuseAdmin = IFuseFeeDistributor(0x2279B7A0a67DB372996a5FaB50D91eAA73d2eBe6);
/**
* @notice Administrator for this contract
*/
address public admin;
/**
* @notice Pending administrator for this contract
*/
address public pendingAdmin;
/**
* @notice Whether or not the Fuse admin has admin rights
*/
bool public fuseAdminHasRights = true;
/**
* @notice Whether or not the admin has admin rights
*/
bool public adminHasRights = true;
/**
* @notice Returns a boolean indicating if the sender has admin rights
*/
function hasAdminRights() internal view returns (bool) {
return (msg.sender == admin && adminHasRights) || (msg.sender == address(fuseAdmin) && fuseAdminHasRights);
}
/**
* @notice Active brains of Unitroller
*/
address public comptrollerImplementation;
/**
* @notice Pending brains of Unitroller
*/
address public pendingComptrollerImplementation;
}
contract ComptrollerV1Storage is UnitrollerAdminStorage {
/**
* @notice Oracle which gives the price of any given asset
*/
PriceOracle public oracle;
/**
* @notice Multiplier used to calculate the maximum repayAmount when liquidating a borrow
*/
uint public closeFactorMantissa;
/**
* @notice Multiplier representing the discount on collateral that a liquidator receives
*/
uint public liquidationIncentiveMantissa;
/**
* @notice Max number of assets a single account can participate in (borrow or use as collateral)
*/
uint public maxAssets;
/**
* @notice Per-account mapping of "assets you are in", capped by maxAssets
*/
mapping(address => CToken[]) public accountAssets;
}
contract ComptrollerV2Storage is ComptrollerV1Storage {
struct Market {
/**
* @notice Whether or not this market is listed
*/
bool isListed;
/**
* @notice Multiplier representing the most one can borrow against their collateral in this market.
* For instance, 0.9 to allow borrowing 90% of collateral value.
* Must be between 0 and 1, and stored as a mantissa.
*/
uint collateralFactorMantissa;
/**
* @notice Per-market mapping of "accounts in this asset"
*/
mapping(address => bool) accountMembership;
}
/**
* @notice Official mapping of cTokens -> Market metadata
* @dev Used e.g. to determine if a market is supported
*/
mapping(address => Market) public markets;
/// @notice A list of all markets
CToken[] public allMarkets;
/**
* @dev Maps borrowers to booleans indicating if they have entered any markets
*/
mapping(address => bool) internal borrowers;
/// @notice A list of all borrowers who have entered markets
address[] public allBorrowers;
/// @notice Indexes of borrower account addresses in the `borrowers` array
mapping(address => uint256) public borrowerIndexes;
/**
* @dev Maps suppliers to booleans indicating if they have ever supplied to any markets
*/
mapping(address => bool) public suppliers;
/// @notice All cTokens addresses mapped by their underlying token addresses
mapping(address => CToken) public cTokensByUnderlying;
/// @notice Whether or not the supplier whitelist is enforced
bool public enforceWhitelist;
/// @notice Maps addresses to booleans indicating if they are allowed to supply assets (i.e., mint cTokens)
mapping(address => bool) public whitelist;
/**
* @notice The Pause Guardian can pause certain actions as a safety mechanism.
* Actions which allow users to remove their own assets cannot be paused.
* Liquidation / seizing / transfer can only be paused globally, not by market.
*/
address public pauseGuardian;
bool public _mintGuardianPaused;
bool public _borrowGuardianPaused;
bool public transferGuardianPaused;
bool public seizeGuardianPaused;
mapping(address => bool) public mintGuardianPaused;
mapping(address => bool) public borrowGuardianPaused;
}