Skip to main content

Entities

Entities define the schema of the subgraph, and represent the data that can be queried. Within each entity are sets of fields that store useful information related to the entity. Below is a list of the available entities within the Pegasys Subgraph, and descriptions for the available fields.

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.

Pegasys Factory#

The Pegasys Factory entity is responsible for storing aggregate information across all Pegasys pairs. It can be used to view stats about total liquidity, volume, amount of pairs and more. There is only one PegasysFactory entity in the subgraph.

Field NameValue TypeDescription
idIDfactory address
pairCountIntamount of pairs created by the Pegasys factory
totalVolumeUSDBigDecimalall time USD volume across all pairs (USD is derived)
totalVolumeSYSBigDecimalall time volume in SYS across all pairs (SYS is derived)
totalLiquidityUSDBigDecimaltotal liquidity across all pairs stored as a derived USD amount
totalLiquiditySYSBigDecimaltotal liquidity across all pairs stored as a derived SYS amount
txCountBigIntall time amount of transactions across all pairs

Token#

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

Field NameValue TypeDescription
idIDtoken address
symbolStringtoken symbol
nameStringtoken name
decimalsBigInttoken decimals
tradeVolumeBigDecimalamount of token traded all time across all pairs
tradeVolumeUSDBigDecimalamount of token in USD traded all time across pairs (only for tokens with liquidity above minimum threshold)
untrackedVolumeUSDBigDecimalamount of token in USD traded all time across pairs (no minimum liquidity threshold)
txCountBigIntamount of transactions all time in pairs including token
totalLiquidityBigDecimaltotal amount of token provided as liquidity across all pairs
derivedSYSBigDecimalSYS per token

Pair#

Information about a pair. Includes references to each token within the pair, volume information, liquidity information, and more. The pair entity mirrors the pair smart contract, and also contains aggregated information about use.

Field NameValue TypeDescription
idIDpair contract address
factoryPegasysFactoryreference to Pegasys factory entity
token0Tokenreference to token0 as stored in pair contract
token1Tokenreference to token1 as stored in pair contract
reserve0BigDecimalreserve of token0
reserve1BigDecimalreserve of token1
totalSupplyBigDecimaltotal supply of liquidity token distributed to LPs
reserveSYSBigDecimaltotal liquidity in pair stored as an amount of SYS
reserveUSDBigDecimaltotal liquidity amount in pair stored as an amount of USD
trackedReserveSYSBigDecimaltotal liquidity with only tracked amount (see tracked amounts)
token0PriceBigDecimaltoken0 per token1
token1PriceBigDecimaltoken1 per token0
volumeToken0BigDecimalamount of token0 swapped on this pair
volumeToken1BigDecimalamount of token1 swapped on this pair
volumeUSDBigDecimaltotal amount swapped all time in this pair stored in USD (only tracked if USD liquidity is above minimum threshold)
untrackedVolumeUSDBigDecimaltotal amount swapped all time in this pair stored in USD, no minimum liquidity threshold
txCountBigIntall time amount of transactions on this pair
createdAtTimestampBigInttimestamp contract was created
createdAtBlockNumberBigIntSyscoin block contract was created
liquidityPositions[LiquidityPosition]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 Pegasys. This entity can be used to track open positions for users. LiquidyPosition 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 pair itself can be used to provide position sizes, token deposits, and more.

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

Transaction#

Transaction entities are created for each Syscoin transaction that contains an interaction within Pegasys contracts. This subgraph tracks Mint, Burn, and Swap events on the Pegasys core contracts. Each transaction contains 3 arrays, and at least one of these arrays has a length of 1.

Field NameValue TypeDescription
idIDSyscoin 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 Pegasys 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 pairs.

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 pair
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 Pegasys 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 pairs.

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 pair
toBytesrecipient of tokens
liquidityBigDecimalamount of liquidity tokens burned
senderBytesaddress that initiated the liquidity removal
amount0BigDecimalamount of token0 removed
amount1BigDecimalamount of token1 removed
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 tokens sent to fee recipient (if fee is on)

Swap#

Swap entities are created for each token swap within a pair. 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 pair
senderBytesaddress that initiated the swap
amount0InBigDecimalamount of token0 sold
amount1InBigDecimalamount of token1 sold
amount0OutBigDecimalamount of token0 received
amount1OutBigDecimalamount of token1 received
toBytesrecipient of output tokens
logIndexBigIntevent index within transaction
amountUSDBigDecimalderived amount of tokens sold in USD

Bundle#

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

Field NameValue TypeDescription
idIDconstant 1
sysPriceBigDecimalderived price of SYS in USD based on stablecoin pairs

Historical Entities#

The subgraph tracks aggregated information grouped by days to provide insights to daily activity on Pegasys. While time travel queries can be used for direct comparison against values in the past, it is much more expensive to query grouped data. For this reason 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.

PegasysDayData#

Tracks data across all pairs 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
dailyVolumeSYSBigDecimaltotal volume across all pairs on this day, stored as a derived amount of SYS
dailyVolumeUSDBigDecimaltotal volume across all pairs on this day, stored as a derived amount of USD
totalVolumeSYSBigDecimalall time volume across all pairs in SYS up to and including this day
totalLiquiditySYSBigDecimaltotal liquidity across all pairs in SYS up to and including this day
totalVolumeUSDBigDecimalall time volume across all pairs in USD up to and including this day
totalLiquidityUSDBigDecimaltotal liquidity across all pairs in USD up to and including this day
maxStoredIntreference used to store most liquid tokens, used for historical liquidity charts
mostLiquidTokens[TokenDayData!]tokens with most liquidity in Pegasys
txCountBigIntnumber of transactions throughout this day

Pair Day Data#

Tracks pair data across each day.

Field NameValue TypeDescription
idIDpair contract address and day id (day start timestamp in unix / 86400) concatenated with a dash
dateIntunix timestamp for start of day
pairAddressBytesaddress for pair contract
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 within pair throughout day
dailyTxnsBigIntamount of transactions on pair throughout day

TokenDayData#

Tracks token data aggregated across all pairs 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 pairs throughout day
dailyVolumeSYSBigDecimalamount of token swapped across all pairs throughout day stored as a derived amount of SYS
dailyVolumeUSDBigDecimalamount of token swapped across all pairs throughout day stored as a derived amount of USD
dailyTxnsBigIntamount of transactions with this token across all pairs
totalLiquidityTokenBigDecimaltoken amount of token deposited across all pairs
totalLiquiditySYSBigDecimaltoken amount of token deposited across all pairs stored as amount of SYS
totalLiquidityUSDBigDecimaltoken amount of token deposited across all pairs stored as amount of USD
priceUSDBigDecimalprice of token in derived USD
maxStoredIntamount of token deposited in pair with highest token liquidity - used only as a reference for storing most liquid pairs for this token
mostLiquidPairs[PairDayData]pairs with most liquidity for this token