Marketis used to describe any smart contract that allows users to invest in it or borrow from it. For example
Uniswap V2is a protocol and all the pair contracts (liquidity pools) of
Marketsof 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.
Positionis 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
INVESTMENTin the DAI market of the Compound protocol. Similarly a user can borrow USDT from an Aave market thus creating a
DEBTin this market of the Aave protocol.
INVESTMENT. If it's borrowing funds then we create a new
DEBTposition if the user is borrowing for the first time from the market or update existing Positions with type
Accountentity 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)
Marketentity before every update to it. It has following properties:
AccountPositionentity when creating this position entity
Accountentity which is created for the user address who created this position
Marketentity in which the user's position is created
outputTokenBalanceback to the market. Because of limitations in how subgraph mapping code makes contract calls, the values of
inputTokenBalancesare 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 format
inputTokenBalances. Stored in TokenBalance format
Positioninstead of updating existing
closedposition. This way we keep track of historical positions as well.
gasPricein this entity, it can be used to calculate the cost of transaction when processing this data. It has the following properties:
MarketSnapshotentity created just before creating this transaction entity
gweiwhile executing this transaction
Positionentity before every update to it. It has following properties:
Positionentity when creating this snapshot