/
ComptrollerStorage.sol
254 lines (202 loc) · 8.72 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
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
pragma solidity ^0.5.16;
import "../Tokens/VTokens/VToken.sol";
import "../Oracle/PriceOracle.sol";
import "../Tokens/VAI/VAIControllerInterface.sol";
import "./ComptrollerLensInterface.sol";
contract UnitrollerAdminStorage {
/**
* @notice Administrator for this contract
*/
address public admin;
/**
* @notice Pending administrator for this contract
*/
address public pendingAdmin;
/**
* @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 => VToken[]) public accountAssets;
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 Whether or not this market receives XVS
bool isVenus;
}
/**
* @notice Official mapping of vTokens -> Market metadata
* @dev Used e.g. to determine if a market is supported
*/
mapping(address => Market) public markets;
/**
* @notice The Pause Guardian can pause certain actions as a safety mechanism.
*/
address public pauseGuardian;
/// @notice Whether minting is paused (deprecated, superseded by actionPaused)
bool private _mintGuardianPaused;
/// @notice Whether borrowing is paused (deprecated, superseded by actionPaused)
bool private _borrowGuardianPaused;
/// @notice Whether borrowing is paused (deprecated, superseded by actionPaused)
bool internal transferGuardianPaused;
/// @notice Whether borrowing is paused (deprecated, superseded by actionPaused)
bool internal seizeGuardianPaused;
/// @notice Whether borrowing is paused (deprecated, superseded by actionPaused)
mapping(address => bool) internal mintGuardianPaused;
/// @notice Whether borrowing is paused (deprecated, superseded by actionPaused)
mapping(address => bool) internal borrowGuardianPaused;
struct VenusMarketState {
/// @notice The market's last updated venusBorrowIndex or venusSupplyIndex
uint224 index;
/// @notice The block number the index was last updated at
uint32 block;
}
/// @notice A list of all markets
VToken[] public allMarkets;
/// @notice The rate at which the flywheel distributes XVS, per block
uint public venusRate;
/// @notice The portion of venusRate that each market currently receives
mapping(address => uint) public venusSpeeds;
/// @notice The Venus market supply state for each market
mapping(address => VenusMarketState) public venusSupplyState;
/// @notice The Venus market borrow state for each market
mapping(address => VenusMarketState) public venusBorrowState;
/// @notice The Venus supply index for each market for each supplier as of the last time they accrued XVS
mapping(address => mapping(address => uint)) public venusSupplierIndex;
/// @notice The Venus borrow index for each market for each borrower as of the last time they accrued XVS
mapping(address => mapping(address => uint)) public venusBorrowerIndex;
/// @notice The XVS accrued but not yet transferred to each user
mapping(address => uint) public venusAccrued;
/// @notice The Address of VAIController
VAIControllerInterface public vaiController;
/// @notice The minted VAI amount to each user
mapping(address => uint) public mintedVAIs;
/// @notice VAI Mint Rate as a percentage
uint public vaiMintRate;
/**
* @notice The Pause Guardian can pause certain actions as a safety mechanism.
*/
bool public mintVAIGuardianPaused;
bool public repayVAIGuardianPaused;
/**
* @notice Pause/Unpause whole protocol actions
*/
bool public protocolPaused;
/// @notice The rate at which the flywheel distributes XVS to VAI Minters, per block (deprecated)
uint private venusVAIRate;
}
contract ComptrollerV2Storage is ComptrollerV1Storage {
/// @notice The rate at which the flywheel distributes XVS to VAI Vault, per block
uint public venusVAIVaultRate;
// address of VAI Vault
address public vaiVaultAddress;
// start block of release to VAI Vault
uint256 public releaseStartBlock;
// minimum release amount to VAI Vault
uint256 public minReleaseAmount;
}
contract ComptrollerV3Storage is ComptrollerV2Storage {
/// @notice The borrowCapGuardian can set borrowCaps to any number for any market. Lowering the borrow cap could disable borrowing on the given market.
address public borrowCapGuardian;
/// @notice Borrow caps enforced by borrowAllowed for each vToken address. Defaults to zero which corresponds to unlimited borrowing.
mapping(address => uint) public borrowCaps;
}
contract ComptrollerV4Storage is ComptrollerV3Storage {
/// @notice Treasury Guardian address
address public treasuryGuardian;
/// @notice Treasury address
address public treasuryAddress;
/// @notice Fee percent of accrued interest with decimal 18
uint256 public treasuryPercent;
}
contract ComptrollerV5Storage is ComptrollerV4Storage {
/// @notice The portion of XVS that each contributor receives per block (deprecated)
mapping(address => uint) private venusContributorSpeeds;
/// @notice Last block at which a contributor's XVS rewards have been allocated (deprecated)
mapping(address => uint) private lastContributorBlock;
}
contract ComptrollerV6Storage is ComptrollerV5Storage {
address public liquidatorContract;
}
contract ComptrollerV7Storage is ComptrollerV6Storage {
ComptrollerLensInterface public comptrollerLens;
}
contract ComptrollerV8Storage is ComptrollerV7Storage {
/// @notice Supply caps enforced by mintAllowed for each vToken address. Defaults to zero which corresponds to minting notAllowed
mapping(address => uint256) public supplyCaps;
}
contract ComptrollerV9Storage is ComptrollerV8Storage {
/// @notice AccessControlManager address
address internal accessControl;
enum Action {
MINT,
REDEEM,
BORROW,
REPAY,
SEIZE,
LIQUIDATE,
TRANSFER,
ENTER_MARKET,
EXIT_MARKET
}
/// @notice True if a certain action is paused on a certain market
mapping(address => mapping(uint => bool)) internal _actionPaused;
}
contract ComptrollerV10Storage is ComptrollerV9Storage {
/// @notice The rate at which venus is distributed to the corresponding borrow market (per block)
mapping(address => uint) public venusBorrowSpeeds;
/// @notice The rate at which venus is distributed to the corresponding supply market (per block)
mapping(address => uint) public venusSupplySpeeds;
}
contract ComptrollerV11Storage is ComptrollerV10Storage {
/// @notice Whether the delegate is allowed to borrow on behalf of the borrower
//mapping(address borrower => mapping (address delegate => bool approved)) public approvedDelegates;
mapping(address => mapping(address => bool)) public approvedDelegates;
}
contract ComptrollerV12Storage is ComptrollerV11Storage {
struct FacetAddressAndPosition {
address facetAddress;
uint96 functionSelectorPosition; // position in facetFunctionSelectors.functionSelectors array
}
struct FacetFunctionSelectors {
bytes4[] functionSelectors;
uint256 facetAddressPosition; // position of facetAddress in facetAddresses array
}
mapping(bytes4 => FacetAddressAndPosition) internal selectorToFacetAndPosition;
// maps facet addresses to function selectors
mapping(address => FacetFunctionSelectors) internal facetFunctionSelectors;
// facet addresses
address[] internal facetAddresses;
}