Entities

Overview

This sections briefs about all the available entities within Bunicorn Stable 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 relevant 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.

BuniCornFactory

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

Field Name

Value Type

Description

id

ID

factory address

pairCount

Int

Total no of token pairs existing in the Stable factory

poolCount

Int

amount of pools created by the Stable factory

totalVolumeUSD

BigDecimal

all time USD volume across all pools (USD is derived)

totalVolumeETH

BigDecimal

all time volume in ETH across all pools (ETH is derived)

totalfeeUSD

BigDecimal

Total fees collected across all pools

untrackedVolumeUSD

BigDecimal

all time untracked volume in USD across all pools

untrackedFeeUSD

BigDecimal

all time untracked fee in USD across all pools

totalLiquidityUSD

BigDecimal

total liquidity across all pools stored as a derived USD amount

totalLiquidityETH

BigDecimal

total liquidity across all pools stored as a derived ETH amount

txCount

BigInt

all time amount of transactions across all pools

Token

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

Field Name

Value Type

Description

id

ID

token address

symbol

String

token symbol

name

String

token name

decimals

BigInt

token decimals

totalSupply

BigInt

total supply of the token

tradeVolume

BigDecimal

amount of token traded all time across all pools

tradeVolumeUSD

BigDecimal

amount of token in USD traded all time across pools (only for tokens with liquidity above minimum threshold)

untrackedVolumeUSD

BigDecimal

amount of token in USD traded all time across pools (no minimum liquidity threshold)

txCount

BigInt

amount of transactions all time in pools including token

totalLiquidity

BigDecimal

total amount of token provided as liquidity across all pools

derivedETH

BigDecimal

ETH 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.

Field Name

Value Type

Description

id

ID

token addresses concatenated with a dash

token0

Token

reference to token0 as stored in pool contract

token1

Token

reference to token1 as stored in pool contract

reserve0

BigDecimal

aggregated balance of token0 across all pools

reserve1

BigDecimal

aggregated balance of token1 across all pools

totalSupply

BigDecimal

total supply of liquidity token distributed to LPs

pool

pool

reference to the pools liquidity is being provided on

reserveETH

BigDecimal

total liquidity of the pair across all pools stored as an amount of ETH

reserveUSD

BigDecimal

total liquidity of the pair across all pools stored as an amount of USD

trackedReserveETH

BigDecimal

total liquidity with only tracked amount (see tracked amounts)

token0Price

BigDecimal

token0 per token1

token1Price

BigDecimal

token1 per token0

volumeToken0

BigDecimal

amount of token0 swapped for this pair

volumeToken1

BigDecimal

amount of token1 swapped for this pair

volumeUSD

BigDecimal

total amount swapped all time for this pair stored in USD (only tracked if USD liquidity is above minimum threshold)

feeUSD

BigDecimal

total fee collected for the pair across all pools

untrackedVolumeUSD

BigDecimal

total amount swapped all time for this pair stored in USD, no minimum liquidity threshold

untrackedfeeUSD

BigDecimal

total amount of fee collected all time for this pair stored in USD, no min threshold

txCount

BigInt

all time amount of transactions for this pair

createdAtTimestamp

BigInt

timestamp contract was created

createdAtBlockNumber

BigInt

BSC block contract was created

liquidityProviderCount

BigInt

count 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 information 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 Name

Value Type

Description

id

ID

pool contract address

token0

Token

reference to token0 as stored in pool contract

token1

Token

reference to token1 as stored in pool contract

reserve0

BigDecimal

reserve of token0

reserve1

BigDecimal

reserve of token1

vreserve0

BigDecimal

virtual reserve of token0(based on amp factor)

vreserve1

BigDecimal

virtual reserve of token1(based on amp factor

totalSupply

BigDecimal

total supply of liquidity token distributed to LPs

pair

pair

reference to the token pair liquidity is being provided

reserveETH

BigDecimal

total liquidity in pool stored as an amount of ETH

reserveUSD

BigDecimal

total liquidity amount in pool stored as an amount of USD

trackedReserveETH

BigDecimal

total liquidity with only tracked amount (see tracked amounts)

volumeUSD

BigDecimal

total amount swapped all time in this pool stored in USD (only tracked if USD liquidity is above minimum threshold)

feeUSD

BigDecimal

total fee collected for the pair

amp

BigDecimal

amplification factor for the pair

liquidityFactor

BigDecimal

is equal to x*y, where x,y are actual balances

token0PriceMin

BigDecimal

Minimum token0 per token1

token0PriceMax

BigDecimal

Maximum token0 per token1

token0Price

BigDecimal

token0 per token1

token1PriceMin

BigDecimal

Minimum token1 per token0

token1PriceMax

BigDecimal

Maximum token1 per token0

token1Price

BigDecimal

token1 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

createdAtTimestamp

BigInt

timestamp contract was created

createdAtBlockNumber

BigInt

BSC block contract was created

liquidityProviderCount

BigInt

count of LP's for the pair

txCount

BigInt

all time amount of transactions on this pool

volumeToken0

BigDecimal

amount of token0 swapped on this pool

volumeToken1

BigDecimal

amount of token1 swapped on this pool

untrackedVolumeUSD

BigDecimal

total amount swapped all time in this pool stored in USD, no minimum liquidity threshold

untrackedFeeUSD

BigDecimal

total amount of fee collected 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

[LiquidityPositionSnapshot]

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 one of the Bunicorn Stable Pools. This entity can be used to track open positions for users. LiquidityPosition entities can be referenced to get specific data about each position.

Field Name

Value Type

Description

id

ID

user address

liquidityPositions

[LiquidityPosition]

array of all liquidity positions user has open

usdSwapped

BigDecimal

total USD value swapped

LiquidityPosition

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 Name

Value Type

Description

id

ID

user address and pool address concatenated with a dash

user

User

reference to user

pair

pair

reference to the pair liquidity is being provided for

pool

pool

reference to the pool liquidity is being provided on

liquidityTokenBalance

BigDecimal

amount of LP tokens minted for this position

LiquidityPositionSnapshot

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

Field Name

Value Type

Description

id

ID

user address and pool address concatenated with a dash

liquidityPosition

[LiquidityPosition]

array of liquidity providers, used as a reference to LP entities

timestamp

Int

timestamp contract was created

block

Int

BSC block contract was created

user

User

reference to user

pair

pair

reference to the pair liquidity is being provided for

pool

pool

reference to the pool liquidity is being provided on

token0PriceUSD

BigDecimal

token0 price in USD

token1PriceUSD

BigDecimal

token1 price in USD

reserve0

BigDecimal

reserve of token0

reserve1

BigDecimal

reserve of token1

reserveUSD

BigDecimal

total liquidity amount in pool stored as an amount of USD

liquidityTokenTotalSupply

BigDecimal

total supply of the token liquidity is provided for

liquidityTokenBalance

BigDecimal

Balances of the token

Transaction

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

Field Name

Value Type

Description

id

ID

BSC transaction hash

blockNumber

BigInt

block transaction was mined in

timestamp

BigInt

timestamp 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 Stable 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 Name

Value Type

Description

id

ID

Transaction hash plus index in the transaction mint array

transaction

Transaction

reference to the transaction Mint was included in

timestamp

BigInt

timestamp of Mint, used to sort recent liquidity provisions

pair

pair

reference to token pair

pool

pool

reference to pool

to

Bytes

recipient of liquidity tokens

liquidity

BigDecimal

amount of liquidity tokens minted

sender

Bytes

address that initiated the liquidity provision

amount0

BigDecimal

amount of token0 provided

amount1

BigDecimal

amount of token1 provided

logIndex

BigInt

index in the transaction event was emitted

amountUSD

BigDecimal

derived USD value of token0 amount plus token1 amount

feeTo

Bytes

address of fee recipient (if fee is on)

feeLiquidity

BigDecimal

amount of liquidity sent to fee recipient (if fee is on)

Burn

Burn entities are created for every emitted Burn event on the Stable 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 Name

Value Type

Description

id

ID

Transaction hash plus index in the transaction burn array

transaction

Transaction

reference to the transaction Burn was included in

timestamp

BigInt

timestamp of Burn, used to sort recent liquidity removals

pair

pair

reference to token pair

pool

pool

reference to pool

liquidity

BigDecimal

amount of liquidity tokens burned

sender

Bytes

address that initiated the liquidity removal

amount0

BigDecimal

amount of token0 removed

amount1

BigDecimal

amount of token1 removed

to

Bytes

recipient of tokens

logIndex

BigInt

index in the transaction event was emitted

amountUSD

BigDecimal

derived USD value of token0 amount plus token1 amount

needsComplete

Boolean

Flag to check whether or not burn is triggered

feeTo

Bytes

address of fee recipient (if fee is on)

feeLiquidity

BigDecimal

amount 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 Name

Value Type

Description

id

ID

transaction hash plus index in Transaction swap array

transaction

Transaction

reference to transaction swap was included in

timestamp

BigInt

timestamp of swap, used for sorted lookups

pair

pair

reference to token pair

pool

pool

reference to pool

sender

Bytes

address that initiated the swap

from

Bytes

amount0In

BigDecimal

amount of token0 sold

amount1In

BigDecimal

amount of token1 sold

amount0Out

BigDecimal

amount of token0 received

amount1Out

BigDecimal

amount of token1 received

to

Bytes

recipient of output tokens

logIndex

BigInt

event index within transaction

origin

Bytes

origin of the swap

amountUSD

BigDecimal

derived amount of tokens sold in USD

feeUSD

BigDecimal

amount of fees for the swap in USD

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.

BuniCornDayData

Tracks data across all pools aggregated into a daily bucket.

Field Name

Value Type

Description

id

ID

unix timestamp for start of day / 86400 giving a unique day index

date

Int

unix timestamp for start of day

dailyVolumeETH

BigDecimal

total volume across all pools on this day, stored as a derived amount of ETH

dailyVolumeUSD

BigDecimal

total volume across all pools on this day, stored as a derived amount of USD

dailyVolumeUntracked

BigDecimal

untracked volume across all pools on this day

totalVolumeETH

BigDecimal

all time volume across all pools in ETH up to and including this day

totalLiquidityETH

BigDecimal

total liquidity across all pools in ETH up to and including this day

totalVolumeUSD

BigDecimal

all time volume across all pools in USD up to and including this day

totalLiquidityUSD

BigDecimal

total liquidity across all pools in USD up to and including this day

txCount

BigInt

number of transactions throughout this day

Pair Hour Data

Tracks pair data across each hour.

Field Name

Value Type

Description

id

ID

token address and hour id concatenated with a dash

hourStartUnix

Int

unix timestamp for start of hour

pair

pair

reference to token pair

reserve0

BigDecimal

reserve of token0 (updated during each transaction on pool)

reserve1

BigDecimal

reserve of token1 (updated during each transaction on pool)

reserveUSD

BigDecimal

reserve of token0 plus token1 stored as a derived USD amount

hourlyVolumeToken

BigDecimal

amount of token swapped per pair for an hour

hourlyVolumeETH

BigDecimal

amount of token swapped per pair for an hour stored as a derived amount of ETH

hourlyVolumeUSD

BigDecimal

amount of token swapped per pair for an hour stored as a derived amount of USD

hourlyTxns

BigInt

amount of transactions with this token across all pools

Pair Day Data

Tracks pair data across each Day.

Field Name

Value Type

Description

id

ID

token pair address and day id (day start timestamp in unix / 86400) concatenated with a dash

date

Int

unix timestamp for start of day

pairAddress

Bytes

addresses for token pair concatenated

token0

Token

reference to token0

token1

Token

reference to token1

reserve0

BigDecimal

reserve of token0 (updated during each transaction on pair)

reserve1

BigDecimal

reserve of token1 (updated during each transaction on pair)

totalSupply

BigDecimal

total supply of liquidity token distributed to LPs

reserveUSD

BigDecimal

reserve of token0 plus token1 stored as a derived USD amount

dailyVolumeToken0

BigDecimal

total amount of token0 swapped throughout day

dailyVolumeToken1

BigDecimal

total amount of token1 swapped throughout day

dailyVolumeUSD

BigDecimal

total volume for the pair throughout day

dailyTxns

BigInt

amount of transactions on pair throughout day

pool Hour Data

Tracks pool data across each Hour.

Field Name

Value Type

Description

id

ID

pool contract address and hour id concatenated with a dash

hourStartUnix

Int

unix timestamp for start of hour

pool

pool

reference to pool address

reserve0

BigDecimal

reserve of token0 (updated during each transaction on pool)

reserve1

BigDecimal

reserve of token1 (updated during each transaction on pool)

reserve0

BigDecimal

reserve of token0 (based on amp factor)

reserve1

BigDecimal

reserve of token1 (based on amp factor)

reserveUSD

BigDecimal

reserve of token0 plus token1 stored as a derived USD amount

hourlyVolumeToken

BigDecimal

amount of token swapped per pair for an hour

hourlyVolumeETH

BigDecimal

amount of token swapped per pair for an hour stored as a derived amount of ETH

hourlyVolumeUSD

BigDecimal

amount of token swapped per pair for an hour stored as a derived amount of USD

hourlyFeeUSD

BigDecimal

hourly fess for the pool

hourlyTxns

BigInt

amount of transactions with this token across all pools

pool Day Data

Tracks pool data across each day.

Field Name

Value Type

Description

id

ID

pool contract address and day id (day start timestamp in unix / 86400) concatenated with a dash

date

Int

unix timestamp for start of day

poolAddress

Bytes

address for pool contract

token0

Token

reference to token0

token1

Token

reference to token1

reserve0

BigDecimal

reserve of token0 (updated during each transaction on pool)

reserve1

BigDecimal

reserve of token1 (updated during each transaction on pool)

vreserve0

BigDecimal

virtual reserve of token0 (based on amp factor)

vreserve1

BigDecimal

virtual reserve of token1 (based on the amp factor)

totalSupply

BigDecimal

total supply of liquidity token distributed to LPs

reserveUSD

BigDecimal

reserve of token0 plus token1 stored as a derived USD amount

dailyVolumeToken0

BigDecimal

total amount of token0 swapped throughout day

dailyVolumeToken1

BigDecimal

total amount of token1 swapped throughout day

dailyVolumeUSD

BigDecimal

total volume within pool throughout day

dailyFeeUSD

BigDecimal

amount of fees on pool throughout day

dailyTxns

BigInt

amount of transactions on pool throughout day

Token Day Data

Tracks token data aggregated across all pools that include token.

Field Name

Value Type

Description

id

ID

token address and day id (day start timestamp in unix / 86400) concatenated with a dash

date

Int

unix timestamp for start of day

token

Token

reference to token entity

dailyVolumeToken

BigDecimal

amount of token swapped across all pools throughout day

dailyVolumeETH

BigDecimal

amount of token swapped across all pools throughout day stored as a derived amount of ETH

dailyVolumeUSD

BigDecimal

amount of token swapped across all pools throughout day stored as a derived amount of USD

dailyTxns

BigInt

amount of transactions with this token across all pools

totalLiquidityToken

BigDecimal

token amount of token deposited across all pools

totalLiquidityETH

BigDecimal

token amount of token deposited across all pools stored as amount of ETH

totalLiquidityUSD

BigDecimal

token amount of token deposited across all pools stored as amount of USD

priceUSD

BigDecimal

price of token in derived USD

Last updated