Comment on page
Schema & Entities
On a GraphQL endpoint, the data is available under the form of entities. These are the one currently available on our subgraphs.
inverse-subgraph
inverse-governance-subgraph
"""
The Comptroller type has protocol level variables stored
"""
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 stores all high level variables for a cToken market
"""
type Market @entity {
"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!
"CToken symbol"
symbol: String!
"CToken address"
id: ID!
"Borrows in the market"
totalBorrows: BigDecimal!
"CToken supply. CTokens have 8 decimals"
totalSupply: BigDecimal!
"Total reserves in the market"
totalReserves: BigDecimal!
"Underlying token address"
underlyingAddress: Bytes!
"Underlying token name"
underlyingName: String!
"Underlying token symbol"
underlyingSymbol: String!
"Underlying price of token in ETH"
underlyingPrice: BigDecimal!
# 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: BigDecimal!
# reserveFactorS: BigDecimal!
"Underlying token decimal length"
underlyingDecimals: Int!
"Decimals of the market"
decimals: Int!
"Yearly borrow rate. With 2102400 blocks per year"
borrowRate: BigDecimal!
compSpeed: BigDecimal!
"Yearly supply rate. With 2102400 blocks per year"
supplyRate: BigDecimal!
borrowRatePerBlock: BigDecimal!
supplyRatePerBlock: BigDecimal!
rewardPerBlock: BigDecimal!
# Added to follow interests generation (@Amxx)
"Total interest produced by borrowed assets"
totalInterestAccumulated: BigDecimal!
"Total interest produced by borrowed assets (non decimal value)"
totalInterestAccumulatedExact: BigInt!
}
"""
Account is an ETH address, with a list of all cToken markets the account has
participated in, along with liquidation information.
"""
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!
}
"""
AccountCToken is a single account within a single cToken market, with data such
as interest earned or paid
"""
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!
"Transactions data"
transactions: [AccountCTokenTransaction!]! @derivedFrom(field:"account")
"Block number this asset was updated at in the contract"
accrualBlockNumber: BigInt!
"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!
}
"""
Auxiliary entity for AccountCToken
"""
type AccountCTokenTransaction @entity {
id: ID!
account: AccountCToken!
tx_hash: Bytes!
timestamp: BigInt!
block: BigInt!
logIndex: BigInt!
underlyingPrice: BigDecimal!
exchangeRate: BigDecimal!
# borrower: UnderlyingTransfer
}
"""
An interface for a transfer of any cToken. TransferEvent, MintEvent,
RedeemEvent, and LiquidationEvent all use this interface
"""
interface CTokenTransfer {
"Transaction hash concatenated with log index"
id: ID!
"cTokens transferred"
amount: BigDecimal!
"Account that received tokens"
to: Bytes!
"Account that sent tokens"
from: Bytes!
"Block number"
blockNumber: Int!
"Block time"
blockTime: Int!
"Symbol of the cToken transferred"
cTokenSymbol: String!
}
"""
TransferEvent will be stored for every mint, redeem, liquidation, and any normal
transfer between two accounts.
"""
type TransferEvent implements CTokenTransfer @entity {
"Transaction hash concatenated with log index"
id: ID!
"cTokens transferred"
amount: BigDecimal!
"Account that received tokens"
to: Bytes!
"Account that sent tokens"
from: Bytes!
"Block number"
blockNumber: Int!
"Block time"
blockTime: Int!
"Symbol of the cToken transferred"
cTokenSymbol: String!
}
"""
MintEvent stores information for mints. From address will always be a cToken
market address
"""
type MintEvent @entity {
"Transaction hash concatenated with log index"
id: ID!
"cTokens transferred"
amount: BigDecimal!
"Account that received tokens"
minter: Bytes!
"cToken of the minted tokens"
cToken: Bytes!
"Block number"
blockNumber: Int!
"Block time"
blockTime: Int!
"Symbol of the cToken transferred"
cTokenSymbol: String!
"Underlying token amount transferred"
underlyingAmount: BigDecimal
}
"""
RedeemEvent stores information for redeems. To address will always be a
cToken market address
"""
type RedeemEvent @entity {
"Transaction hash concatenated with log index"
id: ID!
"cTokens transferred"
amount: BigDecimal!
"cToken of the redeemed tokens"
cToken: Bytes!
"Redeemer"
redeemer: Bytes!
"Block number"
blockNumber: Int!
"Block time"
blockTime: Int!
"Symbol of the cToken transferred"
cTokenSymbol: String!
"Underlying token amount transferred"
underlyingAmount: BigDecimal
}
"""
LiquidationEvent stores information for liquidations. The event is emitted from
the cToken market address.
"""
type LiquidationEvent @entity {
"Transaction hash concatenated with log index"
id: ID!
"Block number"
blockNumber: Int!
"Block time"
blockTime: Int!
"Liquidator"
liquidator: Bytes!
"Borrower"
borrower: Bytes!
"Seized amount of cToken"
seizeAmount: BigDecimal!
"cToken that was repaid by liquidator"
cToken: Bytes!
"cToken that was seized by liquidator"
seizeCToken: Bytes!
"Underlying cToken amount that was repaid by liquidator"
underlyingRepayAmount: BigDecimal!
"Underlying cToken amount that was seized by liquidator"
underlyingSeizeAmount: BigDecimal!
"Remaining Underlying collateral amount of borrower"
borrowerRemainingUnderlyingCollateral: BigDecimal!
"Remaining borrow balance of borrower"
borrowerRemainingBorrowBalance: BigDecimal!
}
"""
Underlying transfers are transfers of underlying collateral for both borrows
and repays
"""
interface UnderlyingTransfer {
"Transaction hash concatenated with log index"
id: ID!
"Amount of underlying borrowed"
amount: BigDecimal!
"Total borrows of this asset the account has"
accountBorrows: BigDecimal!
"Account that borrowed the tokens"
borrower: Bytes!
"Block number"
blockNumber: Int!
"Block time"
blockTime: Int!
"Symbol of the borrowed underlying asset"
underlyingSymbol: String!
underlyingPrice: BigDecimal!
exchangeRate: BigDecimal!
}
"""
BorrowEvent stores information for borrows
"""
type BorrowEvent implements UnderlyingTransfer @entity {
"Transaction hash concatenated with log index"
id: ID!
"Amount of underlying borrowed"
amount: BigDecimal!
"Total borrows of this asset the account has"
accountBorrows: BigDecimal!
"Account that borrowed the tokens"
borrower: Bytes!
"Block number"
blockNumber: Int!
"Block time"
blockTime: Int!
"Symbol of the borrowed underlying asset"
underlyingSymbol: String!
underlyingPrice: BigDecimal!
exchangeRate: BigDecimal!
"cToken of the borrowed tokens"
cToken: Bytes!
}
"""
RepayEvent stores information for repays. Payer is not always the same as
borrower, such as in the event of a Liquidation
"""
type RepayEvent implements UnderlyingTransfer @entity {
"Transaction hash concatenated with log index"
id: ID!
"Amount of underlying repaid"
amount: BigDecimal!
"Total borrows of this asset the account has"
accountBorrows: BigDecimal!
"Account that borrowed the tokens"
borrower: Bytes!
"Block number"
blockNumber: Int!
"Block time"
blockTime: Int!
"Symbol of the borrowed underlying asset"
underlyingSymbol: String!
"Payer of the borrow funds"
payer: Bytes!
underlyingPrice: BigDecimal!
exchangeRate: BigDecimal!
"cToken of the repaid tokens"
cToken: Bytes!
}
Query
Account
DelegateChanged
DelegateVotesChanged
ERC20Approval
ERC20Balance
ERC20Contract
ERC20Transfer
Event
Governor
Mint
Proposal
ProposalCall
ProposalCanceled
ProposalCreated
ProposalExecuted
ProposalQueued
ProposalSupport
ProposalThresholdUpdated
QuorumUpdated
Redeem
Timelock
TimelockNewDelay
TimelockTransaction
TimelockTransactionCanceled
TimelockTransactionExecuted
TimelockTransactionQueued
Transaction
VoteCast
VoteDelegation
VoteReceipt
VoteWeight
VotingContract
You can also use Hasura GraphQL API Explorer using the API link directly and then Click on the 'Voyager View' to see a visual representation the entities :
https://gateway.thegraph.com/api/93d61175f6871249995287b9e2033942/subgraphs/id/78kqSQgaXhtfypzCE1uoB6tTCdgynowp5574ADL6RQrS
Last modified 1yr ago