|
2 | 2 | The Comptroller type has protocol level variables stored |
3 | 3 | """ |
4 | 4 | type Comptroller @entity { |
5 | | - "ID is set to comptroller address" |
6 | | - id: Bytes! |
7 | | - "Comptroller Address" |
8 | | - address: Bytes! |
9 | | - "Address of price oracle the comptroller uses" |
10 | | - priceOracle: Bytes! |
11 | | - "Factor used to determine repayAmount for liquidating" |
12 | | - closeFactorMantissa: BigInt! |
13 | | - "The percent bonus liquidators get for liquidating" |
14 | | - liquidationIncentive: BigInt! |
| 5 | + "ID is set to comptroller address" |
| 6 | + id: Bytes! |
| 7 | + "Comptroller Address" |
| 8 | + address: Bytes! |
| 9 | + "Address of price oracle the comptroller uses" |
| 10 | + priceOracle: Bytes! |
| 11 | + "Factor used to determine repayAmount for liquidating" |
| 12 | + closeFactorMantissa: BigInt! |
| 13 | + "The percent bonus liquidators get for liquidating" |
| 14 | + liquidationIncentive: BigInt! |
15 | 15 | } |
16 | 16 |
|
17 | 17 | """ |
18 | 18 | ERC20 Token |
19 | 19 | """ |
20 | 20 | type Token @entity(immutable: true) { |
21 | | - "Address of the asset" |
22 | | - id: Bytes! |
23 | | - "Address of the asset" |
24 | | - address: Bytes! |
25 | | - "Name of the asset" |
26 | | - name: String! |
27 | | - "Symbol of the asset" |
28 | | - symbol: String |
29 | | - "Decimals of the asset" |
30 | | - decimals: Int! |
| 21 | + "Address of the asset" |
| 22 | + id: Bytes! |
| 23 | + "Address of the asset" |
| 24 | + address: Bytes! |
| 25 | + "Name of the asset" |
| 26 | + name: String! |
| 27 | + "Symbol of the asset" |
| 28 | + symbol: String |
| 29 | + "Decimals of the asset" |
| 30 | + decimals: Int! |
31 | 31 | } |
32 | 32 |
|
33 | 33 | """ |
34 | 34 | Market stores all high level variables for a vToken market |
35 | 35 | """ |
36 | 36 | type Market @entity { |
37 | | - "VToken address" |
38 | | - id: Bytes! |
39 | | - "Vtoken Address" |
40 | | - address: Bytes! |
41 | | - "vToken decimal length" |
42 | | - vTokenDecimals: Int! |
43 | | - "Name of the vToken" |
44 | | - name: String! |
45 | | - "VToken symbol" |
46 | | - symbol: String! |
47 | | - "Flag indicating if the market is listed" |
48 | | - isListed: Boolean! |
49 | | - "Borrow rate per block" |
50 | | - borrowRateMantissa: BigInt! |
51 | | - "The vToken contract balance of BEP20 or BNB" |
52 | | - cashMantissa: BigInt! |
53 | | - "Collateral factor determining how much one can borrow" |
54 | | - collateralFactorMantissa: BigInt! |
55 | | - "Exchange rate of tokens / vTokens" |
56 | | - exchangeRateMantissa: BigInt! |
57 | | - "Address of the interest rate model" |
58 | | - interestRateModelAddress: Bytes! |
59 | | - "Reserves stored in the contract" |
60 | | - reservesMantissa: BigInt! |
61 | | - "Supply rate per block" |
62 | | - supplyRateMantissa: BigInt! |
63 | | - "Borrows in the market" |
64 | | - totalBorrowsMantissa: BigInt! |
65 | | - "Total vToken supplied" |
66 | | - totalSupplyVTokenMantissa: BigInt! |
67 | | - "Underlying Token" |
68 | | - underlyingToken: Token! |
69 | | - "XVS Supply Distribution Block" |
70 | | - xvsSupplyStateBlock: BigInt! |
71 | | - "XVS Supply Distribution Index" |
72 | | - xvsSupplyStateIndex: BigInt! |
73 | | - "XVS Reward Distribution Block" |
74 | | - xvsBorrowStateBlock: BigInt! |
75 | | - "XVS Reward Distribution Index" |
76 | | - xvsBorrowStateIndex: BigInt! |
77 | | - "The rate at which XVS is distributed to the corresponding supply market (per block)" |
78 | | - xvsSupplySpeed: BigInt! |
79 | | - "The rate at which XVS is distributed to the corresponding borrow market (per block)" |
80 | | - xvsBorrowSpeed: BigInt! |
| 37 | + "VToken address" |
| 38 | + id: Bytes! |
| 39 | + "Vtoken Address" |
| 40 | + address: Bytes! |
| 41 | + "vToken decimal length" |
| 42 | + vTokenDecimals: Int! |
| 43 | + "Name of the vToken" |
| 44 | + name: String! |
| 45 | + "VToken symbol" |
| 46 | + symbol: String! |
| 47 | + "Flag indicating if the market is listed" |
| 48 | + isListed: Boolean! |
| 49 | + "Borrow rate per block" |
| 50 | + borrowRateMantissa: BigInt! |
| 51 | + "The vToken contract balance of BEP20 or BNB" |
| 52 | + cashMantissa: BigInt! |
| 53 | + "Collateral factor determining how much one can borrow" |
| 54 | + collateralFactorMantissa: BigInt! |
| 55 | + "Exchange rate of tokens / vTokens" |
| 56 | + exchangeRateMantissa: BigInt! |
| 57 | + "Address of the interest rate model" |
| 58 | + interestRateModelAddress: Bytes! |
| 59 | + "Reserves stored in the contract" |
| 60 | + reservesMantissa: BigInt! |
| 61 | + "Supply rate per block" |
| 62 | + supplyRateMantissa: BigInt! |
| 63 | + "Borrows in the market" |
| 64 | + totalBorrowsMantissa: BigInt! |
| 65 | + "Total vToken supplied" |
| 66 | + totalSupplyVTokenMantissa: BigInt! |
| 67 | + "Underlying Token" |
| 68 | + underlyingToken: Token! |
| 69 | + "XVS Supply Distribution Block" |
| 70 | + xvsSupplyStateBlock: BigInt! |
| 71 | + "XVS Supply Distribution Index" |
| 72 | + xvsSupplyStateIndex: BigInt! |
| 73 | + "XVS Reward Distribution Block" |
| 74 | + xvsBorrowStateBlock: BigInt! |
| 75 | + "XVS Reward Distribution Index" |
| 76 | + xvsBorrowStateIndex: BigInt! |
| 77 | + "The rate at which XVS is distributed to the corresponding supply market (per block)" |
| 78 | + xvsSupplySpeed: BigInt! |
| 79 | + "The rate at which XVS is distributed to the corresponding borrow market (per block)" |
| 80 | + xvsBorrowSpeed: BigInt! |
81 | 81 |
|
82 | | - "Block the market is updated to" |
83 | | - accrualBlockNumber: BigInt! |
84 | | - "The history of the markets borrow index return (Think S&P 500)" |
85 | | - borrowIndex: BigInt! |
86 | | - "The factor determining interest that goes to reserves" |
87 | | - reserveFactorMantissa: BigInt! |
88 | | - "Last recorded Underlying token price in USD cents" |
89 | | - lastUnderlyingPriceCents: BigInt! |
90 | | - "Block price was last updated" |
91 | | - lastUnderlyingPriceBlockNumber: BigInt! |
92 | | - "Total XVS Distributed for this market" |
93 | | - totalXvsDistributedMantissa: BigInt! |
| 82 | + "Block the market is updated to" |
| 83 | + accrualBlockNumber: BigInt! |
| 84 | + "The history of the markets borrow index return (Think S&P 500)" |
| 85 | + borrowIndex: BigInt! |
| 86 | + "The factor determining interest that goes to reserves" |
| 87 | + reserveFactorMantissa: BigInt! |
| 88 | + "Last recorded Underlying token price in USD cents" |
| 89 | + lastUnderlyingPriceCents: BigInt! |
| 90 | + "Block price was last updated" |
| 91 | + lastUnderlyingPriceBlockNumber: BigInt! |
| 92 | + "Total XVS Distributed for this market" |
| 93 | + totalXvsDistributedMantissa: BigInt! |
94 | 94 |
|
95 | | - "Number of accounts currently supplying to this market" |
96 | | - supplierCount: BigInt! |
| 95 | + "Number of accounts currently supplying to this market" |
| 96 | + supplierCount: BigInt! |
97 | 97 |
|
98 | | - "Number of accounts currently borrowing from this market" |
99 | | - borrowerCount: BigInt! |
| 98 | + "Number of accounts currently borrowing from this market" |
| 99 | + borrowerCount: BigInt! |
100 | 100 |
|
101 | | - "Accounts who participate in this market" |
102 | | - accounts: [MarketPosition!]! @derivedFrom(field:"market") |
| 101 | + "Accounts who participate in this market" |
| 102 | + accounts: [MarketPosition!]! @derivedFrom(field: "market") |
| 103 | +} |
| 104 | + |
| 105 | +""" |
| 106 | +MarketRatesData records the state of a given market rates in a block number/timestamp |
| 107 | +""" |
| 108 | +type MarketRatesData @entity(timeseries: true) { |
| 109 | + "Incremental ID" |
| 110 | + id: Int8! |
| 111 | + "Timestamp in microseconds" |
| 112 | + timestamp: Timestamp! |
| 113 | + "Corresponding block number" |
| 114 | + blockNumber: BigInt! |
| 115 | + "Corresponding market" |
| 116 | + market: Market! |
| 117 | + "vToken exchange rate in the given block number/timestamp" |
| 118 | + exchangeRateMantissa: BigInt! |
| 119 | + "Supply rate in the given block number/timestamp" |
| 120 | + supplyRateMantissa: BigInt! |
| 121 | + "Borrow rate in the given block number/timestamp" |
| 122 | + borrowRateMantissa: BigInt! |
| 123 | + "Underlying token price in cents" |
| 124 | + underlyingPriceCents: BigInt! |
| 125 | +} |
| 126 | + |
| 127 | +""" |
| 128 | +MarketRatesDaily is an aggregation for the MarketRatesData time series |
| 129 | +Useful to calculate daily averages for the market rates |
| 130 | +""" |
| 131 | +type MarketRatesDaily @aggregation(intervals: ["day"], source: "MarketRatesData") { |
| 132 | + "Incremental ID" |
| 133 | + id: Int8! |
| 134 | + "Timestamp in microseconds" |
| 135 | + timestamp: Timestamp! |
| 136 | + "Corresponding market" |
| 137 | + market: Market! |
| 138 | + "Count of data points the given interval" |
| 139 | + count: Int8! @aggregate(fn: "count", cumulative: true) |
| 140 | + "Sum of the supply rates in the given interval" |
| 141 | + supplyRateMantissaSum: BigInt! @aggregate(fn: "sum", arg: "supplyRateMantissa") |
| 142 | + "Sum of the borrow rates in the given interval" |
| 143 | + borrowRateMantissaSum: BigInt! @aggregate(fn: "sum", arg: "borrowRateMantissa") |
| 144 | + "Sum of the exchange rates in the given interval" |
| 145 | + exchangeRateMantissaSum: BigInt! @aggregate(fn: "sum", arg: "exchangeRateMantissa") |
103 | 146 | } |
104 | 147 |
|
105 | 148 | """ |
106 | 149 | Account is an BNB address, with a list of all vToken markets the account has |
107 | 150 | participated in, along with liquidation information. |
108 | 151 | """ |
109 | 152 | type Account @entity { |
110 | | - "Account address" |
111 | | - id: Bytes! |
112 | | - "Account address" |
113 | | - address: Bytes! |
114 | | - "Array of VTokens user is in" |
115 | | - tokens: [MarketPosition!]! @derivedFrom(field: "account") |
116 | | - "Count user has been liquidated" |
117 | | - countLiquidated: Int! |
118 | | - "Count user has liquidated others" |
119 | | - countLiquidator: Int! |
120 | | - "True if user has ever borrowed" |
121 | | - hasBorrowed: Boolean! |
| 153 | + "Account address" |
| 154 | + id: Bytes! |
| 155 | + "Account address" |
| 156 | + address: Bytes! |
| 157 | + "Array of VTokens user is in" |
| 158 | + tokens: [MarketPosition!]! @derivedFrom(field: "account") |
| 159 | + "Count user has been liquidated" |
| 160 | + countLiquidated: Int! |
| 161 | + "Count user has liquidated others" |
| 162 | + countLiquidator: Int! |
| 163 | + "True if user has ever borrowed" |
| 164 | + hasBorrowed: Boolean! |
122 | 165 | } |
123 | 166 |
|
124 | 167 | """ |
125 | 168 | MarketPosition is a single account within a single vToken market |
126 | 169 | """ |
127 | 170 | type MarketPosition @entity { |
128 | | - "Concatenation of VToken address and user address" |
129 | | - id: Bytes! |
130 | | - "Relation to market" |
131 | | - market: Market! |
132 | | - "Relation to user" |
133 | | - account: Account! |
134 | | - "Block the position is updated to" |
135 | | - accrualBlockNumber: BigInt! |
136 | | - "Borrow Index this position last accrued interest" |
137 | | - borrowIndex: BigInt! |
138 | | - "True if user is entered, false if they are exited" |
139 | | - enteredMarket: Boolean! |
140 | | - "VToken balance of the user" |
141 | | - vTokenBalanceMantissa: BigInt! |
142 | | - "Total amount of underlying redeemed" |
143 | | - totalUnderlyingRedeemedMantissa: BigInt! |
144 | | - "Total amount underlying repaid" |
145 | | - totalUnderlyingRepaidMantissa: BigInt! |
146 | | - "Stored borrow balance stored in contract (exclusive of interest since accrualBlockNumber)" |
147 | | - storedBorrowBalanceMantissa: BigInt! |
| 171 | + "Concatenation of VToken address and user address" |
| 172 | + id: Bytes! |
| 173 | + "Relation to market" |
| 174 | + market: Market! |
| 175 | + "Relation to user" |
| 176 | + account: Account! |
| 177 | + "Block the position is updated to" |
| 178 | + accrualBlockNumber: BigInt! |
| 179 | + "Borrow Index this position last accrued interest" |
| 180 | + borrowIndex: BigInt! |
| 181 | + "True if user is entered, false if they are exited" |
| 182 | + enteredMarket: Boolean! |
| 183 | + "VToken balance of the user" |
| 184 | + vTokenBalanceMantissa: BigInt! |
| 185 | + "Total amount of underlying redeemed" |
| 186 | + totalUnderlyingRedeemedMantissa: BigInt! |
| 187 | + "Total amount underlying repaid" |
| 188 | + totalUnderlyingRepaidMantissa: BigInt! |
| 189 | + "Stored borrow balance stored in contract (exclusive of interest since accrualBlockNumber)" |
| 190 | + storedBorrowBalanceMantissa: BigInt! |
| 191 | +} |
| 192 | + |
| 193 | +""" |
| 194 | +MarketSupplyPositionData records the state of an account's supply position in a block number/timestamp |
| 195 | +""" |
| 196 | +type MarketSupplyPositionData @entity(timeseries: true) { |
| 197 | + "Incremental ID" |
| 198 | + id: Int8! |
| 199 | + "Timestamp in microseconds" |
| 200 | + timestamp: Timestamp! |
| 201 | + "Corresponding block number" |
| 202 | + blockNumber: BigInt! |
| 203 | + "Supplier account" |
| 204 | + account: Account! |
| 205 | + "Supplied market" |
| 206 | + market: Market! |
| 207 | + "vToken balance at the given block number/timestamp" |
| 208 | + vTokenBalanceMantissa: BigInt! |
| 209 | +} |
| 210 | + |
| 211 | +""" |
| 212 | +MarketBorrowPositionData records the state of an account's borrow position in a block number/timestamp |
| 213 | +""" |
| 214 | +type MarketBorrowPositionData @entity(timeseries: true) { |
| 215 | + "Incremental ID" |
| 216 | + id: Int8! |
| 217 | + "Timestamp in microseconds" |
| 218 | + timestamp: Timestamp! |
| 219 | + "Corresponding block number" |
| 220 | + blockNumber: BigInt! |
| 221 | + "Borrower account" |
| 222 | + account: Account! |
| 223 | + "Borrowed from this market" |
| 224 | + market: Market! |
| 225 | + "Borrowed underlying balance at the given block number/timestamp" |
| 226 | + borrowBalanceMantissa: BigInt! |
148 | 227 | } |
149 | 228 |
|
150 | 229 | enum EventType { |
151 | | - MINT |
152 | | - MINT_BEHALF |
153 | | - REDEEM |
154 | | - BORROW |
155 | | - TRANSFER |
156 | | - LIQUIDATE |
157 | | - REPAY |
| 230 | + MINT |
| 231 | + MINT_BEHALF |
| 232 | + REDEEM |
| 233 | + BORROW |
| 234 | + TRANSFER |
| 235 | + LIQUIDATE |
| 236 | + REPAY |
158 | 237 | } |
159 | 238 |
|
160 | 239 | """ |
161 | 240 | An interface for a transfer of any vToken. TransferEvent, MintEvent, |
162 | 241 | RedeemEvent, and LiquidationEvent all use this interface |
163 | 242 | """ |
164 | 243 | type Transaction @entity { |
165 | | - "Transaction hash concatenated with log index" |
166 | | - id: Bytes! |
167 | | - "enum of event type" |
168 | | - type: EventType! |
169 | | - "The account that sent the tokens, usually vToken" |
170 | | - from: Bytes! |
171 | | - "count of vTokens transferred" |
172 | | - amountMantissa: BigInt! |
173 | | - "Account that received tokens" |
174 | | - to: Bytes! |
175 | | - "Block number" |
176 | | - blockNumber: Int! |
177 | | - "Block time" |
178 | | - blockTime: Int! |
| 244 | + "Transaction hash concatenated with log index" |
| 245 | + id: Bytes! |
| 246 | + "enum of event type" |
| 247 | + type: EventType! |
| 248 | + "The account that sent the tokens, usually vToken" |
| 249 | + from: Bytes! |
| 250 | + "count of vTokens transferred" |
| 251 | + amountMantissa: BigInt! |
| 252 | + "Account that received tokens" |
| 253 | + to: Bytes! |
| 254 | + "Block number" |
| 255 | + blockNumber: Int! |
| 256 | + "Block time" |
| 257 | + blockTime: Int! |
179 | 258 | } |
0 commit comments