-
Notifications
You must be signed in to change notification settings - Fork 148
/
CometStorage.sol
76 lines (64 loc) · 2.26 KB
/
CometStorage.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
// SPDX-License-Identifier: BUSL-1.1
pragma solidity 0.8.15;
/**
* @title Compound's Comet Storage Interface
* @dev Versions can enforce append-only storage slots via inheritance.
* @author Compound
*/
contract CometStorage {
// 512 bits total = 2 slots
struct TotalsBasic {
// 1st slot
uint64 baseSupplyIndex;
uint64 baseBorrowIndex;
uint64 trackingSupplyIndex;
uint64 trackingBorrowIndex;
// 2nd slot
uint104 totalSupplyBase;
uint104 totalBorrowBase;
uint40 lastAccrualTime;
uint8 pauseFlags;
}
struct TotalsCollateral {
uint128 totalSupplyAsset;
uint128 _reserved;
}
struct UserBasic {
int104 principal;
uint64 baseTrackingIndex;
uint64 baseTrackingAccrued;
uint16 assetsIn;
uint8 _reserved;
}
struct UserCollateral {
uint128 balance;
uint128 _reserved;
}
struct LiquidatorPoints {
uint32 numAbsorbs;
uint64 numAbsorbed;
uint128 approxSpend;
uint32 _reserved;
}
/// @dev Aggregate variables tracked for the entire market
uint64 internal baseSupplyIndex;
uint64 internal baseBorrowIndex;
uint64 internal trackingSupplyIndex;
uint64 internal trackingBorrowIndex;
uint104 internal totalSupplyBase;
uint104 internal totalBorrowBase;
uint40 internal lastAccrualTime;
uint8 internal pauseFlags;
/// @notice Aggregate variables tracked for each collateral asset
mapping(address => TotalsCollateral) public totalsCollateral;
/// @notice Mapping of users to accounts which may be permitted to manage the user account
mapping(address => mapping(address => bool)) public isAllowed;
/// @notice The next expected nonce for an address, for validating authorizations via signature
mapping(address => uint) public userNonce;
/// @notice Mapping of users to base principal and other basic data
mapping(address => UserBasic) public userBasic;
/// @notice Mapping of users to collateral data per collateral asset
mapping(address => mapping(address => UserCollateral)) public userCollateral;
/// @notice Mapping of magic liquidator points
mapping(address => LiquidatorPoints) public liquidatorPoints;
}