Market
is used to describe any smart contract that allows users to invest in it or borrow from it. For example Uniswap V2
is a protocol and all the pair contracts (liquidity pools) of Uniswap V2
are Markets
of this protocol. Every pair contract is an individual market. For example a DAI-ETH pair is a market where users can provide liquidity by depositing DAI and ETH thus investing in this market.Position
is used to describe any investment made, or debt taken, by a user in a market. For example a user can deposit DAI in a Compound DAI market thus creating a Position
of type INVESTMENT
in the DAI market of the Compound protocol. Similarly a user can borrow USDT from an Aave market thus creating a Position
of type DEBT
in this market of the Aave protocol.INVESTMENT
. If it's borrowing funds then we create a new DEBT
position if the user is borrowing for the first time from the market or update existing Positions with type DEBT
TokenStandard
enumtokenAddress|accountAddress|tokenAmountBigInt
Account
entity for this smart contract. This can be used to fetch positions of this market in other markets (for example, the position that a yield farm holds in a Uniswap liquidity pool)ProtocolName
enumProtocolType
enumMarket
entity before every update to it. It has following properties:inputTokenBalances
of Market
entitypositionCounter
property of AccountPosition
entity when creating this position entityAccountPosition
entityAccount
entity which is created for the user address who created this positionMarket
entity in which the user's position is createdPositionType
enumoutputToken
outputTokenBalance
back to the market. Because of limitations in how subgraph mapping code makes contract calls, the values of inputTokenBalances
are based on the market's state recorded by the relevant smart contract at the block level (after all the transaction in the block have been executed to update the smart contract address). This can cause an inaccurate value of inputTokenBalances for specific transactions which are followed by other transactions that affect the market's balances in the same block. We are working with The Graph to address this limitation and increase accuracy. Stored in TokenBalance formatinputTokenBalances
. Stored in TokenBalance formatPositionSnapshot
idclosed
when:INVESTMENT
DEBT
Position
instead of updating existing closed
position. This way we keep track of historical positions as well.Position
entitygasUsed
and gasPrice
in this entity, it can be used to calculate the cost of transaction when processing this data. It has the following properties:MarketSnapshot
entity created just before creating this transaction entityTransactionType
enumgwei
while executing this transactionPosition
entity before every update to it. It has following properties:outputTokenBalance
of Position
entity when creating this snapshot