Skip to main content

Entities

Overview#

This sections briefs about all the available entities within Kyber DMM Subgraph. Entities define the schema of the subgraph, and represent the data that can be queried. Each entity has a set of fields that store relavent information about the entity. To see an interactive sandbox of all entities see the Graph Explorer.

Each entity is defined with a value type, which will always be a base AssemblyScript type, or a custom type provided by The Graph's custom TypeScript library. For more information on value types see here.

DMM Factory#

The DMM Factory entity stores aggregate information across all DMM pools. It can be used to view stats about total liquidity, volume, amount of pools and more.

Field NameValue TypeDescription
idIDfactory address
pairCountIntTotal no of token pairs existing in the DMM factory
poolCountIntamount of pools created by the DMM factory
totalVolumeUSDBigDecimalall time USD volume across all pools (USD is derived)
totalVolumeETHBigDecimalall time volume in ETH across all pools (ETH is derived)
totalfeeUSDBigDecimalTotal fees collected accross all pools
untrackedVolumeUSDBigDecimalall time untracked volume in USD across all pools
untrackedFeeUSDBigDecimalall time untracked fee in USD across all pools
totalLiquidityUSDBigDecimaltotal liquidity across all pools stored as a derived USD amount
totalLiquidityETHBigDecimaltotal liquidity across all pools stored as a derived ETH amount
txCountBigIntall time amount of transactions across all pools

Token#

Stores aggregated information for a specific token across all pools that token is included in.

Field NameValue TypeDescription
idIDtoken address
symbolStringtoken symbol
nameStringtoken name
decimalsBigInttoken decimals
totalsupplyBigInttotal supply of the token
tradeVolumeBigDecimalamount of token traded all time across all pools
tradeVolumeUSDBigDecimalamount of token in USD traded all time across pools (only for tokens with liquidity above minimum threshold)
untrackedVolumeUSDBigDecimalamount of token in USD traded all time across pools (no minimum liquidity threshold)
txCountBigIntamount of transactions all time in pools including token
totalLiquidityBigDecimaltotal amount of token provided as liquidity across all pools
derivedETHBigDecimalETH per token
tokenDayData[tokenDayData]array of tokenDayData
pairDayDataBase[pairDayData]aray of pairDayData
pairDayDataQuote[pairDayData]aray of pairDayData
pairBase[pair]array of token pairs
pairquote[pair]array of token pairs

pair#

Includes information about token pairs, volume information, liquidity information, and more. As the kyber DMM has more/multiple pools for each token pair based on amplification factor, etc this entity also acts as a wrapper for all the pools of the token pair.

Field NameValue TypeDescription
idIDtoken addresses concatenated with a dash
token0Tokenreference to token0 as stored in pool contract
token1Tokenreference to token1 as stored in pool contract
reserve0BigDecimalaggregated balance of token0 across all pools
reserve1BigDecimalaggregated balance of token1 across all pools
totalSupplyBigDecimaltotal supply of liquidity token distributed to LPs
poolpoolreference to the pools liquidity is being provided on
reserveETHBigDecimaltotal liquidity of the pair across all pools stored as an amount of ETH
reserveUSDBigDecimaltotal liquidity of the pair across all pools stored as an amount of USD
trackedReserveETHBigDecimaltotal liquidity with only tracked amount (see tracked amounts)
token0PriceBigDecimaltoken0 per token1
token1PriceBigDecimaltoken1 per token0
volumeToken0BigDecimalamount of token0 swapped for this pair
volumeToken1BigDecimalamount of token1 swapped for this pair
volumeUSDBigDecimaltotal amount swapped all time for this pair stored in USD (only tracked if USD liquidity is above minimum threshold)
feeUSDBigDecimaltotal fee collected for the pair across all pools
untrackedVolumeUSDBigDecimaltotal amount swapped all time for this pair stored in USD, no minimum liquidity threshold
untrackedfeeUSDBigDecimaltotal amount of fee collected all time for this pair stored in USD, no min threshold
txCountBigIntall time amount of transactions for this pair
createdAtTimestampBigInttimestamp contract was created
createdAtBlockNumberBigIntEthereum block contract was created
liquidityProviderCountBigIntcount of LP's for the pair
pairHourData[pairHourData]Array of pairHourData
liquidityPositions[LiquidityPosition]array of liquidity providers, used as a reference to LP entities
liquidityPositionSnapshots[LiquidityPositionSnashot]array of liquidity providers, used as a reference to LP entities

pool#

Information about a pool. Includes infomation about to each token within the pool like minimum/maximum price per token, liquidity burn, mint and swaps, virtual reserves, amplification factor and more. The pool entity mirrors the pool smart contract, and also contains aggregated information about use.

Field NameValue TypeDescription
idIDpool contract address
token0Tokenreference to token0 as stored in pool contract
token1Tokenreference to token1 as stored in pool contract
reserve0BigDecimalreserve of token0
reserve1BigDecimalreserve of token1
vreserve0BigDecimalvirtual reserve of token0(based on amp factor)
vreserve1BigDecimalvirtual reserve of token1(based on amp factor
totalSupplyBigDecimaltotal supply of liquidity token distributed to LPs
pairpairreference to the token pair liquidity is being provided
reserveETHBigDecimaltotal liquidity in pool stored as an amount of ETH
reserveUSDBigDecimaltotal liquidity amount in pool stored as an amount of USD
trackedReserveETHBigDecimaltotal liquidity with only tracked amount (see tracked amounts)
volumeUSDBigDecimaltotal amount swapped all time in this pool stored in USD (only tracked if USD liquidity is above minimum threshold)
feeUSDBigDecimaltotal fee collected for the pair
ampBigDecimalamplification factor for the pair
liquidityFactorBigDecimalis equal to x*y, where x,y are actual balances
token0PriceMinBigDecimalMinimum token0 per token1
token0PriceMaxBigDecimalMaximum token0 per token1
token0PriceBigDecimaltoken0 per token1
token1PriceMinBigDecimalMinimum token1 per token0
token1PriceMaxBigDecimalMaximum token1 per token0
token1PriceBigDecimaltoken1 per token0
mints[mint]array of mints, to track latest mint on the pool
burns[burn]array of burns, to track burn activity on the pool
swaps[swap]array of swap, to track ltoken swaps on the pool
createdAtTimestampBigInttimestamp contract was created
createdAtBlockNumberBigIntEthereum block contract was created
liquidityProviderCountBigIntcount of LP's for the pair
txCountBigIntall time amount of transactions on this pool
volumeToken0BigDecimalamount of token0 swapped on this pool
volumeToken1BigDecimalamount of token1 swapped on this pool
untrackedVolumeUSDBigDecimaltotal amount swapped all time in this pool stored in USD, no minimum liquidity threshold
untrackedfeeUSDBigDecimaltotal amount of fee colected all time in this pool stored in USD
poolHourData[poolHourData]Array of poolHourData
liquidityPositions[LiquidityPosition]array of liquidity providers, used as a reference to LP entities
liquidityPositionSnapshots[LiquidityPositionSnashot]array of liquidity providers, used as a reference to LP entities

User#

A user entity is created for any address that provides liquidity to a pool on the kyber DMM platform. This entity can be used to track open positions for users. LiquidityPosition entities can be referenced to get specific data about each position.

Field NameValue TypeDescription
idIDuser address
liquidityPositions[LiquidityPosition]array of all liquidity positions user has open
usdSwappedBigDecimaltotal USD value swapped

LiquidityPositiion#

This entity is used to store data about a user's liquidity position. This information, along with information from the pool itself can be used to provide position sizes, token deposits, and more.

Field NameValue TypeDescription
idIDuser address and pool address concatenated with a dash
userUserreference to user
pairpairreference to the pair liquidity is being provided for
poolpoolreference to the pool liquidity is being provided on
liquidityTokenBalanceBigDecimalamount of LP tokens minted for this position

LiquidityPositiionSnapshot#

This entity provides snapshot or a gist of the users liquidity position, like token price, total supply, etc.

Field NameValue TypeDescription
idIDuser address and pool address concatenated with a dash
liquidityPosition[LiquidityPosition]array of liquidity providers, used as a reference to LP entities
timestampInttimestamp contract was created
blockIntEthereum block contract was created
userUserreference to user
pairpairreference to the pair liquidity is being provided for
poolpoolreference to the pool liquidity is being provided on
token0PriceUSDBigDecimaltoken0 price in USD
token1PriceUSDBigDecimaltoken1 price in USD
reserve0BigDecimalreserve of token0
reserve1BigDecimalreserve of token1
reserveUSDBigDecimaltotal liquidity amount in pool stored as an amount of USD
liquidityTokenTotalSupplyBigDecimaltotal supply of the token liquidity is provided for
liquidityTokenBalanceBigDecimalBalances of the token

Transaction#

Transaction entities are created for each Ethereum transaction done through the DMM contracts. This subgraph tracks Mint, Burn, and Swap events on the DMM core contracts. Each transaction contains 3 arrays, and at least one of these arrays has a length = 1.

Field NameValue TypeDescription
idIDEthereum transaction hash
blockNumberBigIntblock transaction was mined in
timestampBigInttimestamp for transaction
mints[Mint]array of Mint events within the transaction, 0 or greater
burns[Burn]array of Burn events within transaction, 0 or greater
swaps[Swap]array of Swap events within transaction, 0 or greater

Mint#

Mint entities are created for every emitted Mint event on the DMM core contracts. The Mint entity stores key data about the event like token amounts, who sent the transaction, who received the liquidity, and more. This entity can be used to track liquidity provisions on pools.

Field NameValue TypeDescription
idIDTransaction hash plus index in the transaction mint array
transactionTransactionreference to the transaction Mint was included in
timestampBigInttimestamp of Mint, used to sort recent liquidity provisions
pairpairreference to token pair
poolpoolreference to pool
toBytesrecipient of liquidity tokens
liquidityBigDecimalamount of liquidity tokens minted
senderBytesaddress that initiated the liquidity provision
amount0BigDecimalamount of token0 provided
amount1BigDecimalamount of token1 provided
logIndexBigIntindex in the transaction event was emitted
amountUSDBigDecimalderived USD value of token0 amount plus token1 amount
feeToBytesaddress of fee recipient (if fee is on)
feeLiquidityBigDecimalamount of liquidity sent to fee recipient (if fee is on)

Burn#

Burn entities are created for every emitted Burn event on the DMM core contracts. The Burn entity stores key data about the event like token amounts, who burned LP tokens, who received tokens, and more. This entity can be used to track liquidity removals on pools.

Field NameValue TypeDescription
idIDTransaction hash plus index in the transaction burn array
transactionTransactionreference to the transaction Burn was included in
timestampBigInttimestamp of Burn, used to sort recent liquidity removals
pairpairreference to token pair
poolpoolreference to pool
liquidityBigDecimalamount of liquidity tokens burned
senderBytesaddress that initiated the liquidity removal
amount0BigDecimalamount of token0 removed
amount1BigDecimalamount of token1 removed
toBytesrecipient of tokens
logIndexBigIntindex in the transaction event was emitted
amountUSDBigDecimalderived USD value of token0 amount plus token1 amount
needsCompleteBooleanFlag to check whether or not burn is triggered
feeToBytesaddress of fee recipient (if fee is on)
feeLiquidityBigDecimalamount of tokens sent to fee recipient (if fee is on)

Swap#

Swap entities are created for each token swap within a pool. The Swap entity can be used to get things like swap size (in tokens and USD), sender, recipient and more. See the Swap overview page for more information on amounts.

Field NameValue TypeDescription
idIDtransaction hash plus index in Transaction swap array
transactionTransactionreference to transaction swap was included in
timestampBigInttimestamp of swap, used for sorted lookups
pairpairreference to token pair
poolpoolreference to pool
senderBytesaddress that initiated the swap
fromBytes
amount0InBigDecimalamount of token0 sold
amount1InBigDecimalamount of token1 sold
amount0OutBigDecimalamount of token0 received
amount1OutBigDecimalamount of token1 received
toBytesrecipient of output tokens
logIndexBigIntevent index within transaction
originBytesorigin of the swap
amountUSDBigDecimalderived amount of tokens sold in USD
feeUSDBigDecimalamount of fees for the swap in USD

Bundle#

The Bundle is used as a global store of derived ETH price in USD. Because there is no guaranteed common base token across pools, a global reference of USD price is useful for deriving other USD values. The Bundle entity stores an updated weighted average of ETH<->Stablecoin pool prices. This provides a strong estimate for the USD price of ETH that can be used in other places in the subgraph.

Field NameValue TypeDescription
idIDconstant 1
ethPriceBigDecimalderived price of ETH in USD based on stablecoin pools

Historical Entities#

Since, tracking historic data on-chain is a tiresome job, and is expensive for grouped data, the subgraph tracks information grouped in daily buckets, using timestamps provided by contract events. These entities can be used to query things like total volume on a given day, price of a token on a given day, etc. For each DayData type, a new entity is created each day.

DMMDayData#

Tracks data across all pools aggregated into a daily bucket.

Field NameValue TypeDescription
idIDunix timestamp for start of day / 86400 giving a unique day index
dateIntunix timestamp for start of day
dailyVolumeETHBigDecimaltotal volume across all pools on this day, stored as a derived amount of ETH
dailyVolumeUSDBigDecimaltotal volume across all pools on this day, stored as a derived amount of USD
dailyVolumeUntrackedBigDecimaluntracked volume across all pools on this day
totalVolumeETHBigDecimalall time volume across all pools in ETH up to and including this day
totalLiquidityETHBigDecimaltotal liquidity across all pools in ETH up to and including this day
totalVolumeUSDBigDecimalall time volume across all pools in USD up to and including this day
totalLiquidityUSDBigDecimaltotal liquidity across all pools in USD up to and including this day
txCountBigIntnumber of transactions throughout this day

Pair Hour Data#

Tracks pair data across each hour.

Field NameValue TypeDescription
idIDtoken address and hour id concatenated with a dash
hourStartUnixIntunix timestamp for start of hour
pairpairreference to token pair
reserve0BigDecimalreserve of token0 (updated during each transaction on pool)
reserve1BigDecimalreserve of token1 (updated during each transaction on pool)
reserveUSDBigDecimalreserve of token0 plus token1 stored as a derived USD amount
hourlyVolumeTokenBigDecimalamount of token swapped per pair for an hour
hourlyVolumeETHBigDecimalamount of token swapped per pair for an hour stored as a derived amount of ETH
hourlyVolumeUSDBigDecimalamount of token swapped per pair for an hour stored as a derived amount of USD
hourlyTxnsBigIntamount of transactions with this token across all pools

Pair Day Data#

Tracks pair data across each Day.

Field NameValue TypeDescription
idIDtoken pair address and day id (day start timestamp in unix / 86400) concatenated with a dash
dateIntunix timestamp for start of day
pairAddressBytesaddresses for token pair concatenated
token0Tokenreference to token0
token1Tokenreference to token1
reserve0BigDecimalreserve of token0 (updated during each transaction on pair)
reserve1BigDecimalreserve of token1 (updated during each transaction on pair)
totalSupplyBigDecimaltotal supply of liquidity token distributed to LPs
reserveUSDBigDecimalreserve of token0 plus token1 stored as a derived USD amount
dailyVolumeToken0BigDecimaltotal amount of token0 swapped throughout day
dailyVolumeToken1BigDecimaltotal amount of token1 swapped throughout day
dailyVolumeUSDBigDecimaltotal volume for the pair throughout day
dailyTxnsBigIntamount of transactions on pair throughout day

pool Hour Data#

Tracks pool data across each Hour.

Field NameValue TypeDescription
idIDpool contract address and hour id concatenated with a dash
hourStartUnixIntunix timestamp for start of hour
poolpoolreference to pool address
reserve0BigDecimalreserve of token0 (updated during each transaction on pool)
reserve1BigDecimalreserve of token1 (updated during each transaction on pool)
reserve0BigDecimalreserve of token0 (based on amp factor)
reserve1BigDecimalreserve of token1 (based on amp factor)
reserveUSDBigDecimalreserve of token0 plus token1 stored as a derived USD amount
hourlyVolumeTokenBigDecimalamount of token swapped per pair for an hour
hourlyVolumeETHBigDecimalamount of token swapped per pair for an hour stored as a derived amount of ETH
hourlyVolumeUSDBigDecimalamount of token swapped per pair for an hour stored as a derived amount of USD
hourlyFeeUSDBigDecimalhourly fess for the pool
hourlyTxnsBigIntamount of transactions with this token across all pools

pool Day Data#

Tracks pool data across each day.

Field NameValue TypeDescription
idIDpool contract address and day id (day start timestamp in unix / 86400) concatenated with a dash
dateIntunix timestamp for start of day
poolAddressBytesaddress for pool contract
token0Tokenreference to token0
token1Tokenreference to token1
reserve0BigDecimalreserve of token0 (updated during each transaction on pool)
reserve1BigDecimalreserve of token1 (updated during each transaction on pool)
vreserve0BigDecimalvirtual reserve of token0 (based on amp factor)
vreserve1BigDecimalvirtual reserve of token1 (based on the amp factor)
totalSupplyBigDecimaltotal supply of liquidity token distributed to LPs
reserveUSDBigDecimalreserve of token0 plus token1 stored as a derived USD amount
dailyVolumeToken0BigDecimaltotal amount of token0 swapped throughout day
dailyVolumeToken1BigDecimaltotal amount of token1 swapped throughout day
dailyVolumeUSDBigDecimaltotal volume within pool throughout day
dailyFeeUSDBigDecimalamount of fees on pool throughout day
dailyTxnsBigIntamount of transactions on pool throughout day

Token Day Data#

Tracks token data aggregated across all pools that include token.

Field NameValue TypeDescription
idIDtoken address and day id (day start timestamp in unix / 86400) concatenated with a dash
dateIntunix timestamp for start of day
tokenTokenreference to token entity
dailyVolumeTokenBigDecimalamount of token swapped across all pools throughout day
dailyVolumeETHBigDecimalamount of token swapped across all pools throughout day stored as a derived amount of ETH
dailyVolumeUSDBigDecimalamount of token swapped across all pools throughout day stored as a derived amount of USD
dailyTxnsBigIntamount of transactions with this token across all pools
totalLiquidityTokenBigDecimaltoken amount of token deposited across all pools
totalLiquidityETHBigDecimaltoken amount of token deposited across all pools stored as amount of ETH
totalLiquidityUSDBigDecimaltoken amount of token deposited across all pools stored as amount of USD
priceUSDBigDecimalprice of token in derived USD