-
Notifications
You must be signed in to change notification settings - Fork 126
/
schema.graphql
144 lines (132 loc) · 5.19 KB
/
schema.graphql
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
# Comptroller global variables
type Comptroller @entity {
"ID is set to 1"
id: ID!
"Address of price oracle the comptroller uses"
priceOracle: Bytes
"Factor used to determine repayAmount for liquidating"
closeFactor: BigInt
"The percent bonus liquidators get for liquidating"
liquidationIncentive: BigInt
"Max assets a single user can enter"
maxAssets: BigInt
}
# Market inforamtion for a CToken
type Market @entity { # TODO rename to CToken, not market AND ALL OTHERS
#Fields that match compounds API
"Yearly borrow rate. With 2102400 blocks per year"
borrowRate: BigDecimal!
"The cToken contract balance of ERC20 or ETH"
cash: BigDecimal!
"Collateral factor determining how much one can borrow"
collateralFactor: BigDecimal!
"Exchange rate of tokens / cTokens"
exchangeRate: BigDecimal!
"Address of the interest rate model"
interestRateModelAddress: Bytes!
"Name of the cToken"
name: String!
"Number of borrowers active in the market"
numberOfBorrowers: Int!
"Number of suppliers active in the market"
numberOfSuppliers: Int!
"Reserves stored in the contract"
reserves: BigDecimal!
"Yearly supply rate. With 2104400 blocks per year"
supplyRate: BigDecimal!
"CToken symbol"
symbol: String!
"CToken address"
id: ID!
"Borrows in the market"
totalBorrows: BigDecimal!
"CToken supply. CTokens have 8 decimals"
totalSupply: BigDecimal!
"Underlying token address"
underlyingAddress: Bytes!
"Underlying token name"
underlyingName: String!
"Underlying price of token in ETH (ex. 0.007 DAI)"
underlyingPrice: BigDecimal!
"Underlying token symbol"
underlyingSymbol: String!
# Fields that are not in compounds api
"Block the market is updated to"
accrualBlockNumber: Int!
"Timestamp the market was most recently updated"
blockTimestamp: Int!
"The history of the markets borrow index return (Think S&P 500)"
borrowIndex: BigDecimal!
"The factor determining interest that goes to reserves"
reserveFactor: BigInt!
"Underlying token price in USD"
underlyingPriceUSD: BigDecimal!
"Underlying token decimal length"
underlyingDecimals: Int!
}
# Users within the protocol
type Account @entity {
"User ETH address"
id: ID!
"Array of CTokens user is in"
tokens: [AccountCToken!]! @derivedFrom(field: "account")
"Count user has been liquidated"
countLiquidated: Int!
"Count user has liquidated others"
countLiquidator: Int!
"True if user has ever borrowed"
hasBorrowed: Boolean!
# The following values are added by the JS Wrapper, and must be calculated with the most up
# to date values based on the block delta for market.exchangeRate and market.borrowIndex
# They do not need to be in the schema, but they will show up in the explorer playground
# "If less than 1, the account can be liquidated
# health: BigDecimal!
# "Total assets supplied by user"
# totalBorrowValueInEth: BigDecimal!
# "Total assets borrowed from user"
# totalCollateralValueInEth: BigDecimal!
}
# Stats for an accounts borrow and supply of an asset
type AccountCToken @entity {
"Concatenation of CToken address and user address"
id: ID!
"Relation to market"
market: Market!
"Symbol of the cToken"
symbol: String!
"Relation to user"
account: Account!
"Hashes of all user transactions"
transactionHashes: [Bytes!]!
"Times of all user transactions"
transactionTimes: [Int!]!
"Block number this asset was updated at in the contract"
accrualBlockNumber: Int!
"True if user is entered, false if they are exited"
enteredMarket: Boolean!
"CToken balance of the user"
cTokenBalance: BigDecimal!
"Total amount of underlying supplied"
totalUnderlyingSupplied: BigDecimal!
"Total amount of underling redeemed"
totalUnderlyingRedeemed: BigDecimal!
"The value of the borrow index upon users last interaction"
accountBorrowIndex: BigDecimal!
"Total amount underlying borrowed, exclusive of interest"
totalUnderlyingBorrowed: BigDecimal!
"Total amount underlying repaid"
totalUnderlyingRepaid: BigDecimal!
"Current borrow balance stored in contract (exclusive of interest since accrualBlockNumber)"
storedBorrowBalance: BigDecimal!
# The following values are added by the JS Wrapper, and must be calculated with the most up
# to date values based on the block delta for market.exchangeRate and market.borrowIndex
# They do not need to be in the schema, but they will show up in the explorer playground
# supplyBalanceUnderlying: BigDecimal!
# FORMULA: supplyBalanceUnderlying = cTokenBalance * market.exchangeRate
# lifetimeSupplyInterestAccrued: BigDecimal!
# FORMULA: lifetimeSupplyInterestAccrued = supplyBalanceUnderlying - totalUnderlyingSupplied + totalUnderlyingRedeemed
# borrowBalanceUnderlying: BigDecimal!
# FORMULA: borrowBalanceUnderlying = storedBorrowBalance * market.borrowIndex / accountBorrowIndex
# lifetimeBorrowInterestAccrued: BigDecimal!
# FORMULA: lifetimeBorrowInterestAccrued = borrowBalanceUnderlying - totalUnderlyingBorrowed + totalUnderlyingRepaid
}