Entities

Overview

This section briefs about all the available entities within Bunicorn Flexible 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 Subgraph 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.

Buni

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

Field Name

Value

Description

id

ID

Always be 1

poolCount

Int

Number of pools

finalizedPoolCount

Int

Number of finalized pools

crpCount

Int

Number of CRP (Smart Pools)

pools

[Pool]

Array of all flexible pools has open

txCount

BigInt

Number of transactions

totalLiquidity

BigDecimal

All the pools liquidity value in USD

totalSwapVolume

BigDecimal

All the swap volume in USD

totalSwapFee

BigDecimal

All the swap fee in USD

Pool

Information about a pool. Includes information about each token within the pool like balance per token or denorm weight. The pool entity mirrors the pool smart contract, and also contains aggregated information about use such as total liquidity, volume, amount and more.

Field Name

Value

Description

id

ID

Pool address

controller

Bytes

Address of the pool’s controller

publicSwap

Boolean

Open for public users to swap

finalized

Boolean

Is Finalized

crp

Boolean

Is configurable rights pool (Smart pool)

crpController

Bytes

CRP controller address

rights

[String]

List of rights (for CRP)

active

Boolean

Is Active

swapFee

BigDecimal

Swap fee setting

totalWeight

BigDecimal

Total of all weights in the pool

totalShares

BigDecimal

Total pool token shares

totalSwapVolume

BigDecimal

Total swap volume in USD

totalSwapFee

BigDecimal

Total swap fee in USD

liquidity

BigDecimal

Pool liquidity value in USD

tokensList

[Bytes]

Temp workaround until graph supports filtering on derived field

tokens

[PoolToken]

Array of pool tokens. Used as a reference to PoolToken entity

shares

[PoolShare]

Array of liquidity shares. Used as a reference to PoolShare entity

createTime

Int

Block time pool was created

tokensCount

BigInt

Number of tokens in the pool

holdersCount

BigInt

Number of addresses holding pool tokens

joinsCount

BigInt

All time liquidity has been added

exitsCount

BigInt

All time liquidity has been added

swapsCount

BigInt

All time amount of transactions on this pool

factoryID

Buni

Reference to factory record (Buni entity)

tx

Bytes

Pool creation transaction id

swaps

[Swap]

Array of swaps has been made. Used as a reference to Swap entity

PoolToken

The PoolToken stores information for a specific token in a pool that token is included in, along with the information of the pool itself.

Field Name

Value

Description

id

ID

Pool address and token address concatenated with a dash

poolId

Pool

Reference to the Pool entity that token is included in

symbol

String

Token symbol

name

String

Token name

decimals

Int

Token decimal

address

String

Token address

balance

BigDecimal

Balance (reserve) of this token in the pool

denormWeight

BigDecimal

Weight of this token in the pool

PoolShare

This entity is used to store data about a user's liquidity shares.

Field Name

Value

Description

id

ID

Pool address and shareholder address concatenated with a dash

userAddress

User

Shareholder address

poolId

Pool

Reference to the Pool entity that shares belong to

balance

BigDecimal

Amount of the pool token that user is holding

User

A user entity is created for any address that provides liquidity to a flexible pool or swaps tokens on the platform. This entity can be used to track users' shares or exchange history.

Field Name

Value

Description

id

ID

User address

sharesOwned

[PoolShare]

Reference to an array of PoolShare entity to mirror all shares across pools that user is holding

txs

[Transaction]

Reference to an array of Transaction entity to mirror all blockchain transactions that use has been made related to the system

swaps

[Swap]

Reference to an array of Swap entity to mirror all swaps across pools that user has been made

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), caller, recipient and more.

Field Name

Value

Description

id

ID

Blockchain transaction hash that includes this swap, and the event’s index in this transaction concatenated with a dash

caller

Bytes

The address who executed this swap. Normally it is the exchange proxy.

tokenIn

Bytes

Address of the token user pushed to the pool

tokenInSym

String

Symbol of the token user pushed to the pool

tokenOut

Bytes

Address of the token user pull of the pool

tokenOutSym

String

Symbol of the token user pull of the pool

tokenAmountIn

BigDecimal

Amount of the token user pushed to the pool

tokenAmountOut

BigDecimal

Amount of the token user pull of the pool

poolAddress

Pool

The pool that swap happened on. Used as reference to Pool entity

userAddress

User

User that initiates the swap. Used as reference to User entity

value

BigDecimal

Swap value in USD

feeValue

BigDecimal

Swap fee value in USD

poolTotalSwapVolume

BigDecimal

Total pool swap volume in USD

poolTotalSwapFee

BigDecimal

Total pool swap fee in USD

poolLiquidity

BigDecimal

Pool liquidity value in USD

timestamp

Int

Timestamp when the swap was made

TokenPrice

To store the spot price of a token which is included in any flexible pool. The price is calculated by on-chain reserves and weights in the highest liquidity pool that includes this token.

Field Name

Value

Description

id

ID

Token address

symbol

String

Token symbol

name

String

Token name

decimals

Int

Token decimal

price

BigDecimal

Token price

poolLiquidity

BigDecimal

Liquidity of the pool was used to calculate token price

poolTokenId

String

Reference to a PoolToken entity which was used to calculate token price

Transaction

Transaction entities actually represent an event created in each blockchain transaction done through Buni flexible pools. This tracks the transaction information such as block, timestamp, gas used, event type and more. For more information about event types, see smart contracts document.

Field Name

Value

Description

id

ID

Blockchain transaction hash and the event’s index in this transaction concatenated with a dash

tx

Bytes

Transaction hash

event

String

Event name. Can be setSwapFee, setController, setCrpController, setPublicSwap, finalize, rebind, unbind, join, exit, or swap

block

Int

Block number

timestamp

Int

Timestamp

gasUsed

BigDecimal

Gas used

gasPrice

BigDecimal

Gas price

poolAddress

Pool

Reference to a Pool entity that this event done through

userAddress

User

Reference to a User entity who trigger this event

Last updated