# SILO V2 Entities

* [`Token`](#token)
* [`RewardToken`](#rewardtoken)
* [`InterestRate`](#interestrate)
* [`InterestRateDaily`](#interestratedaily)
* [`InterestRateHourly`](#interestratehourly)
* [`UsageMetricsDailySnapshot`](#usagemetricsdailysnapshot)
* [`UsageMetricsHourlySnapshot`](#usagemetricshourlysnapshot)
* [`FinancialsDailySnapshot`](#financialsdailysnapshot)
* [`Market`](#market)
* [`MarketAsset`](#marketasset)
* [`MarketDailySnapshot`](#marketdailysnapshot)
* [`MarketHourlySnapshot`](#markethourlysnapshot)
* [`Account`](#account)
* [`Position`](#position)
* [`AssetPosition`](#assetposition)
* [`PositionSnapshot`](#positionsnapshot)
* [`Oracle`](#oracle)
* [`TokenOracle`](#tokenoracle)
* [`ActiveAccount`](#activeaccount)
* [`LiquidationHelper`](#liquidationhelper)
* [`LiquidationContract`](#liquidationcontract)
* [`TowerCoordinate`](#towercoordinate)
* [`IncentiveProgram`](#incentiveprogram)

## Token

Description: Represents a token entity with various attributes detailing its characteristics and associations.

| Field                | Type             | Description                                                                                                 |
| -------------------- | ---------------- | ----------------------------------------------------------------------------------------------------------- |
| id                   | ID!              | Smart contract address of the token                                                                         |
| name                 | String!          | Name of the token, mirrored from the smart contract                                                         |
| symbol               | String!          | Symbol of the token, mirrored from the smart contract                                                       |
| decimals             | Int!             | The number of decimal places this token uses, default to 18                                                 |
| type                 | String!          | 'Asset' 'Share' 'Protected Share' 'Debt'                                                                    |
| lastPriceUSD         | BigDecimal       | Optional field to track the price of a token, mostly for caching purposes                                   |
| lastPriceBlockNumber | BigInt!          | Optional field to track the block number of the last token price                                            |
| market               | Market           | The market for the derivative                                                                               |
| asset                | Token            | The base asset for the derivative (USDC for sUSDC)                                                          |
| derivativeConversion | BigDecimal!      | Optional field to track the conversion rate of an \[s/d]Token to the deposited Asset. 0 for non derivatives |
| totalSupply          | BigInt!          | Supply tracking for derivative tokens                                                                       |
| activeOracle         | TokenOracle      | The Oracle actively used for the market calculations                                                        |
| oracles              | \[TokenOracle!]! | The Oracle used to determine the price conversion of the tokens in a market                                 |

## RewardToken

Description: Represents a RewardToken entity with various attributes detailing its characteristics.

| Field | Type             | Description                                                          |
| ----- | ---------------- | -------------------------------------------------------------------- |
| id    | ID!              | { Reward token type }-{ Smart contract address of the reward token } |
| token | Token!           | Reference to the actual token                                        |
| type  | RewardTokenType! | The type of the reward token                                         |

## InterestRate

Description: Represents an InterestRate entity, detailing various aspects of interest rates in financial contexts.

| Field              | Type                    | Description                                                                  |
| ------------------ | ----------------------- | ---------------------------------------------------------------------------- |
| id                 | ID!                     | { Interest rate side }-{ Interest rate type }-{ Market ID }-{Token ID }      |
| rate               | BigDecimal!             | Interest rate in percentage APY. E.g. 5.21% should be stored as 5.21         |
| duration           | Int                     | Duration of the loan in days. Only applies to fixed term lending             |
| maturityBlock      | BigInt                  | Maturity of the loan in block height. Only applies to fixed term lending     |
| side               | InterestRateSide!       | The party the interest is paid to / received from                            |
| type               | InterestRateType!       | The type of interest rate (e.g. stable, fixed, variable, etc)                |
| market             | Market                  | The Market that this interest rate is for                                    |
| marketAsset        | MarketAsset             | The Combination of the asset and market                                      |
| token              | Token                   | The Asset that this interest rate is for                                     |
| uopt               | BigInt                  | uopt ∈ (0, 1) – optimal utilization                                          |
| ucrit              | BigInt                  | ucrit ∈ (uopt, 1) – threshold of large utilization                           |
| ulow               | BigInt                  | ulow ∈ (0, uopt) – threshold of low utilization                              |
| ki                 | BigInt                  | ki > 0 – integrator gain                                                     |
| kcrit              | BigInt                  | kcrit > 0 – proportional gain for large utilization                          |
| klow               | BigInt                  | klow ≥ 0 – proportional gain for low utilization                             |
| klin               | BigInt                  | klin ≥ 0 – coefficient of the lower linear bound                             |
| beta               | BigInt                  | beta ≥ 0 - a scaling factor                                                  |
| ri                 | BigInt                  | ri ≥ 0 – initial value of the integrator                                     |
| Tcrit              | BigInt                  | Tcrit ≥ 0 - the time during which the utilization exceeds the critical value |
| utilization        | BigDecimal              | Utilization of the asset as a percent                                        |
| interestRateDaily  | \[InterestRateDaily!]!  | Daily metrics for the rates                                                  |
| interestRateHourly | \[InterestRateHourly!]! | Hourly metrics for the rates                                                 |

## InterestRateDaily

Description: Represents a daily snapshot of interest rates, including various metrics and associated data.

| Field        | Type          | Description                                                                  |
| ------------ | ------------- | ---------------------------------------------------------------------------- |
| id           | ID!           | ID is the {InterestRate ID}-{# of days since Unix epoch time}                |
| day          | Int!          | # of days since Unix epoch time                                              |
| timestamp    | Int!          | Timestamp of the start of the day                                            |
| interestRate | InterestRate! | Entity to connect to the interest rate                                       |
| ri           | BigInt        | ri ≥ 0 – initial value of the integrator                                     |
| Tcrit        | BigInt        | Tcrit ≥ 0 - the time during which the utilization exceeds the critical value |
| utilization  | BigDecimal    | Utilization of the asset as a percent                                        |
| rateLast     | BigDecimal!   | The most recent rate recorded or last for the day                            |
| rateHigh     | BigDecimal!   | Highest the rate was for the day                                             |
| rateLow      | BigDecimal!   | Lowest the rate was for the day                                              |
| rateAvg      | BigDecimal!   | Average of the recorded rates for the day                                    |
| rateSum      | BigDecimal!   | Sum of rates recorded for the day - used for calculating avg                 |
| rateCount    | Int!          | Count of rates recorded for the day - used for calculating avg               |

## InterestRateHourly

Description: Represents an hourly snapshot of interest rates, encompassing various metrics and associated data.

| Field        | Type          | Description                                                                  |
| ------------ | ------------- | ---------------------------------------------------------------------------- |
| id           | ID!           | ID is the {InterestRate ID}-{# of hours since Unix epoch time}               |
| hour         | Int!          | # of hours since Unix epoch time                                             |
| timestamp    | Int!          | Timestamp of the start of the hour                                           |
| interestRate | InterestRate! | Entity to connect to the interest rate                                       |
| ri           | BigInt        | ri ≥ 0 – initial value of the integrator                                     |
| Tcrit        | BigInt        | Tcrit ≥ 0 - the time during which the utilization exceeds the critical value |
| utilization  | BigDecimal    | Utilization of the asset as a percent                                        |
| rateLast     | BigDecimal!   | The most recent rate recorded or last for the hour                           |
| rateHigh     | BigDecimal!   | Highest the rate was for the hour                                            |
| rateLow      | BigDecimal!   | Lowest the rate was for the hour                                             |
| rateAvg      | BigDecimal!   | Average of the recorded rates for the hour                                   |
| rateSum      | BigDecimal!   | Sum of rates recorded for the hour - used for calculating avg                |
| rateCount    | Int!          | Count of rates recorded for the hour - used for calculating avg              |

## UsageMetricsDailySnapshot

Description: Represents daily usage metrics for a lending protocol, including user activities and transaction counts.

| Field                       | Type             | Description                                                              |
| --------------------------- | ---------------- | ------------------------------------------------------------------------ |
| id                          | ID!              | ID is # of days since Unix epoch time                                    |
| protocol                    | LendingProtocol! | Protocol this snapshot is associated with                                |
| dailyActiveUsers            | Int!             | Number of unique daily active users                                      |
| cumulativeUniqueUsers       | Int!             | Number of cumulative unique users                                        |
| dailyActiveDepositors       | Int!             | Number of unique daily depositors                                        |
| cumulativeUniqueDepositors  | Int!             | Number of cumulative depositors                                          |
| dailyActiveBorrowers        | Int!             | Number of unique daily borrowers                                         |
| cumulativeUniqueBorrowers   | Int!             | Number of cumulative borrowers                                           |
| dailyActiveLiquidators      | Int!             | Number of unique daily liquidators (accounts that performed liquidation) |
| cumulativeUniqueLiquidators | Int!             | Number of cumulative liquidators (accounts that performed liquidation)   |
| dailyActiveLiquidatees      | Int!             | Number of unique daily liquidatees (accounts that got liquidated)        |
| cumulativeUniqueLiquidatees | Int!             | Number of cumulative liquidatees (accounts that got liquidated)          |
| dailyTransactionCount       | Int!             | Total number of transactions occurred in a day                           |
| dailyDepositCount           | Int!             | Total number of deposits in a day                                        |
| dailyWithdrawCount          | Int!             | Total number of withdrawals in a day                                     |
| dailyBorrowCount            | Int!             | Total number of borrows/mints in a day                                   |
| dailyRepayCount             | Int!             | Total number of repayments/burns in a day                                |
| dailyLiquidateCount         | Int!             | Total number of liquidations in a day                                    |
| totalPoolCount              | Int!             | Total number of pools                                                    |
| blockNumber                 | BigInt!          | Block number of this snapshot                                            |
| timestamp                   | BigInt!          | Timestamp of this snapshot                                               |

## UsageMetricsHourlySnapshot

Description: Represents hourly usage metrics for a lending protocol, including user activities and transaction counts.

| Field                  | Type             | Description                                      |
| ---------------------- | ---------------- | ------------------------------------------------ |
| id                     | ID!              | { # of hours since Unix epoch time }             |
| protocol               | LendingProtocol! | Protocol this snapshot is associated with        |
| hourlyActiveUsers      | Int!             | Number of unique hourly active users             |
| cumulativeUniqueUsers  | Int!             | Number of cumulative unique users                |
| hourlyTransactionCount | Int!             | Total number of transactions occurred in an hour |
| hourlyDepositCount     | Int!             | Total number of deposits in an hour              |
| hourlyWithdrawCount    | Int!             | Total number of withdrawals in an hour           |
| hourlyBorrowCount      | Int!             | Total number of borrows/mints in an hour         |
| hourlyRepayCount       | Int!             | Total number of repayments/burns in an hour      |
| hourlyLiquidateCount   | Int!             | Total number of liquidations in an hour          |
| blockNumber            | BigInt!          | Block number of this snapshot                    |
| timestamp              | BigInt!          | Timestamp of this snapshot                       |

## FinancialsDailySnapshot

Description: Represents a daily financial snapshot of a lending protocol, including TVL, revenue, and lending activities.

| Field                            | Type             | Description                                             |
| -------------------------------- | ---------------- | ------------------------------------------------------- |
| id                               | ID!              | ID is # of days since Unix epoch time                   |
| protocol                         | LendingProtocol! | Protocol this snapshot is associated with               |
| blockNumber                      | BigInt!          | Block number of this snapshot                           |
| timestamp                        | BigInt!          | Timestamp of this snapshot                              |
| totalValueLockedUSD              | BigDecimal!      | Current TVL (Total Value Locked) of the entire protocol |
| protocolControlledValueUSD       | BigDecimal       | Current PCV (Protocol Controlled Value)                 |
| mintedTokenSupplies              | \[BigInt!]       | Total supply of minted tokens in native amounts         |
| dailySupplySideRevenueUSD        | BigDecimal!      | Revenue claimed by suppliers to the protocol            |
| cumulativeSupplySideRevenueUSD   | BigDecimal!      | Cumulative revenue claimed by suppliers                 |
| dailyProtocolSideRevenueUSD      | BigDecimal!      | Gross revenue for the protocol                          |
| cumulativeProtocolSideRevenueUSD | BigDecimal!      | Cumulative gross revenue for the protocol               |
| dailyTotalRevenueUSD             | BigDecimal!      | All revenue generated by the protocol                   |
| cumulativeTotalRevenueUSD        | BigDecimal!      | Cumulative total revenue generated by the protocol      |
| totalDepositBalanceUSD           | BigDecimal!      | Current balance of all deposited assets, in USD         |
| dailyDepositUSD                  | BigDecimal!      | Total assets deposited on a given day, in USD           |
| cumulativeDepositUSD             | BigDecimal!      | Sum of all historical deposits in USD                   |
| totalBorrowBalanceUSD            | BigDecimal!      | Current balance of all borrowed/minted assets, in USD   |
| dailyBorrowUSD                   | BigDecimal!      | Total assets borrowed/minted on a given day, in USD     |
| cumulativeBorrowUSD              | BigDecimal!      | Sum of all historical borrows/mints in USD              |
| dailyLiquidateUSD                | BigDecimal!      | Total assets liquidated on a given day, in USD          |
| cumulativeLiquidateUSD           | BigDecimal!      | Sum of all historical liquidations in USD               |
| dailyWithdrawUSD                 | BigDecimal!      | Total assets withdrawn on a given day, in USD           |
| dailyRepayUSD                    | BigDecimal!      | Total assets repaid on a given day, in USD              |

## Market

Description: Represents the Market entity, detailing various aspects of a market in a lending protocol.

| Field                            | Type                      | Description                                                     |
| -------------------------------- | ------------------------- | --------------------------------------------------------------- |
| id                               | ID!                       | Smart contract address of the market                            |
| protocol                         | LendingProtocol!          | The protocol this pool belongs to                               |
| name                             | String                    | Name of market                                                  |
| isActive                         | Boolean!                  | Is this market active or is it frozen                           |
| archived                         | Boolean!                  | If the market has been archived due to being replaced           |
| canUseAsCollateral               | Boolean!                  | Can you use the output token as collateral                      |
| canBorrowFrom                    | Boolean!                  | Can you borrow from this market                                 |
| liquidationPenalty               | BigDecimal!               | Liquidation penalty as a percentage value                       |
| inputToken                       | Token!                    | Token that needs to be deposited to take a position in protocol |
| outputToken                      | \[Token!]!                | Token that is minted to track ownership of position in protocol |
| rewardTokens                     | \[RewardToken!]           | Additional tokens given as reward for position in protocol      |
| rates                            | \[InterestRate!]!         | All interest rates/fees allowed in the market                   |
| marketAssets                     | \[MarketAsset!]!          | Sub Entity to the Market Assets                                 |
| marketAssetIds                   | \[String!]                | Id's for the sub entity                                         |
| totalValueLockedUSD              | BigDecimal!               | Current TVL (Total Value Locked) of this market                 |
| cumulativeSupplySideRevenueUSD   | BigDecimal!               | All revenue generated by the market, accrued to the supply side |
| cumulativeProtocolSideRevenueUSD | BigDecimal!               | All revenue generated by the market, accrued to the protocol    |
| cumulativeTotalRevenueUSD        | BigDecimal!               | All revenue generated by the market                             |
| totalDepositBalanceUSD           | BigDecimal!               | Current balance of all deposited assets, in USD                 |
| cumulativeDepositUSD             | BigDecimal!               | Sum of all historical deposits in USD                           |
| totalBorrowBalanceUSD            | BigDecimal!               | Current balance of all borrowed/minted assets, in USD           |
| cumulativeBorrowUSD              | BigDecimal!               | Sum of all historical borrows/mints in USD                      |
| cumulativeLiquidateUSD           | BigDecimal!               | Sum of all historical liquidations in USD                       |
| rewardTokenEmissionsAmount       | BigInt!                   | Per-block reward token emission in native amount                |
| rewardTokenEmissionsUSD          | BigDecimal!               | Per-block reward token emission in USD value                    |
| createdTimestamp                 | BigInt!                   | Creation timestamp                                              |
| createdBlockNumber               | BigInt!                   | Creation block number                                           |
| positions                        | \[Position!]!             | All positions in this market                                    |
| positionCount                    | Int!                      | Number of positions in this market                              |
| openPositionCount                | Int!                      | Number of open positions in this market                         |
| closedPositionCount              | Int!                      | Number of closed positions in this market                       |
| lendingPositionCount             | Int!                      | Number of lending positions in this market                      |
| borrowingPositionCount           | Int!                      | Number of borrowing positions in this market                    |
| creditSupply                     | BigInt!                   | Total credit supplied in XAI native Amount                      |
| creditUtilized                   | BigInt!                   | Total credit utilized in XAI native Amount                      |
| dailySnapshots                   | \[MarketDailySnapshot!]!  | Market daily snapshots                                          |
| hourlySnapshots                  | \[MarketHourlySnapshot!]! | Market hourly snapshots                                         |
| deposits                         | \[Deposit!]!              | All deposits made to this market                                |
| withdraws                        | \[Withdraw!]!             | All withdrawals made from this market                           |
| borrows                          | \[Borrow!]!               | All borrows from this market                                    |
| repays                           | \[Repay!]!                | All repayments to this market                                   |
| liquidates                       | \[Liquidate!]!            | All liquidations made to this market                            |

## MarketAsset

Description: Represents the MarketAsset entity, detailing the characteristics and financial aspects of an asset within a market.

| Field                | Type              | Description                                                     |
| -------------------- | ----------------- | --------------------------------------------------------------- |
| id                   | ID!               | {Smart contract address of the market}-{Asset Contract Address} |
| market               | Market!           | Market for the MarketAsset record                               |
| asset                | Token!            | Asset for the MarketAsset record                                |
| maximumLTV           | BigDecimal!       | Maximum loan-to-value ratio as a percentage value               |
| liquidationThreshold | BigDecimal!       | Liquidation threshold as a percentage value                     |
| type                 | String            | Bridge or Non-Bridge asset                                      |
| supply               | BigInt!           | Total supply of sToken and spToken                              |
| protectedSupply      | BigInt!           | Total supply of spToken                                         |
| balance              | BigInt!           | Available Balance of sToken                                     |
| borrowed             | BigInt!           | Total amount of output token borrowed in native amounts         |
| tokenPriceUSD        | BigDecimal!       | Price per share of output token in USD                          |
| exchangeRate         | BigDecimal        | Amount of input token per full share of output token            |
| sToken               | Token!            | The Share Token for the asset in a silo                         |
| spToken              | Token!            | The Protected Share Token for the asset in a silo               |
| dToken               | Token!            | The Debt Token for the asset in a silo                          |
| rates                | \[InterestRate!]! | All interest rates/fees allowed for the asset in the market     |
| interestRateModel    | String            |                                                                 |

## MarketDailySnapshot

Description: Represents a daily snapshot of a market, detailing quantitative data, revenues, and token balances.

| Field                            | Type             | Description                                                                 |
| -------------------------------- | ---------------- | --------------------------------------------------------------------------- |
| id                               | ID!              | { Smart contract address of the market}-{ # of days since Unix epoch time } |
| protocol                         | LendingProtocol! | The protocol this snapshot belongs to                                       |
| market                           | Market!          | The pool this snapshot belongs to                                           |
| blockNumber                      | BigInt!          | Block number of this snapshot                                               |
| timestamp                        | BigInt!          | Timestamp of this snapshot                                                  |
| rates                            | \[InterestRate!] | All interest rates/fees allowed in the market                               |
| totalValueLockedUSD              | BigDecimal!      | Current TVL (Total Value Locked) of this market                             |
| cumulativeSupplySideRevenueUSD   | BigDecimal!      | All revenue generated by the market, accrued to the supply side             |
| dailySupplySideRevenueUSD        | BigDecimal!      | Daily revenue generated by the market, accrued to the supply side           |
| cumulativeProtocolSideRevenueUSD | BigDecimal!      | All revenue generated by the market, accrued to the protocol                |
| dailyProtocolSideRevenueUSD      | BigDecimal!      | Daily revenue generated by the market, accrued to the protocol              |
| cumulativeTotalRevenueUSD        | BigDecimal!      | All revenue generated by the market                                         |
| dailyTotalRevenueUSD             | BigDecimal!      | Daily revenue generated by the market                                       |
| totalDepositBalanceUSD           | BigDecimal!      | Current balance of all deposited assets, in USD                             |
| dailyDepositUSD                  | BigDecimal!      | Sum of all deposits made on a given day, in USD                             |
| cumulativeDepositUSD             | BigDecimal!      | Sum of all historical deposits in USD                                       |
| totalBorrowBalanceUSD            | BigDecimal!      | Current balance of all borrowed/minted assets, in USD                       |
| dailyBorrowUSD                   | BigDecimal!      | Sum of all borrows/mints made on a given day, in USD                        |
| cumulativeBorrowUSD              | BigDecimal!      | Sum of all historical borrows/mints in USD                                  |
| dailyLiquidateUSD                | BigDecimal!      | Total assets liquidated on a given day, in USD                              |
| cumulativeLiquidateUSD           | BigDecimal!      | Sum of all historical liquidations in USD                                   |
| dailyWithdrawUSD                 | BigDecimal!      | Total assets withdrawn on a given day, in USD                               |
| dailyRepayUSD                    | BigDecimal!      | Total assets repaid on a given day, in USD                                  |
| inputTokenBalance                | BigInt           | Amount of input token in the market                                         |
| inputTokenPriceUSD               | BigDecimal       | Price per share of input token in USD                                       |
| outputTokenSupply                | \[BigInt!]       | Total supply of output token                                                |
| outputTokenPriceUSD              | \[BigDecimal!]   | Price per share of output token in USD                                      |
| exchangeRate                     | BigDecimal       | Amount of input token per full share of output token                        |
| rewardTokenEmissionsAmount       | \[BigInt!]       | Per-block reward token emission in native amount                            |
| rewardTokenEmissionsUSD          | \[BigDecimal!]   | Per-block reward token emission in USD value                                |

## MarketHourlySnapshot

Description: Represents an hourly snapshot of a market, detailing quantitative data, revenues, and token balances.

| Field                            | Type             | Description                                                                  |
| -------------------------------- | ---------------- | ---------------------------------------------------------------------------- |
| id                               | ID!              | { Smart contract address of the market}-{ # of hours since Unix epoch time } |
| protocol                         | LendingProtocol! | The protocol this snapshot belongs to                                        |
| market                           | Market!          | The pool this snapshot belongs to                                            |
| blockNumber                      | BigInt!          | Block number of this snapshot                                                |
| timestamp                        | BigInt!          | Timestamp of this snapshot                                                   |
| rates                            | \[InterestRate!] | All interest rates/fees allowed in the market                                |
| totalValueLockedUSD              | BigDecimal!      | Current TVL (Total Value Locked) of this market                              |
| cumulativeSupplySideRevenueUSD   | BigDecimal!      | All revenue generated by the market, accrued to the supply side              |
| hourlySupplySideRevenueUSD       | BigDecimal!      | Hourly revenue generated by the market, accrued to the supply side           |
| cumulativeProtocolSideRevenueUSD | BigDecimal!      | All revenue generated by the market, accrued to the protocol                 |
| hourlyProtocolSideRevenueUSD     | BigDecimal!      | Hourly revenue generated by the market, accrued to the protocol              |
| cumulativeTotalRevenueUSD        | BigDecimal!      | All revenue generated by the market                                          |
| hourlyTotalRevenueUSD            | BigDecimal!      | Hourly revenue generated by the market                                       |
| totalDepositBalanceUSD           | BigDecimal!      | Current balance of all deposited assets, in USD                              |
| hourlyDepositUSD                 | BigDecimal!      | Sum of all deposits made in a given hour, in USD                             |
| cumulativeDepositUSD             | BigDecimal!      | Sum of all historical deposits in USD                                        |
| totalBorrowBalanceUSD            | BigDecimal!      | Current balance of all borrowed/minted assets, in USD                        |
| hourlyBorrowUSD                  | BigDecimal!      | Sum of all borrows/mints made in a given hour, in USD                        |
| cumulativeBorrowUSD              | BigDecimal!      | Sum of all historical borrows/mints in USD                                   |
| hourlyLiquidateUSD               | BigDecimal!      | Total assets liquidated in a given hour, in USD                              |
| cumulativeLiquidateUSD           | BigDecimal!      | Sum of all historical liquidations in USD                                    |
| hourlyWithdrawUSD                | BigDecimal!      | Total assets withdrawn on a given hour, in USD                               |
| hourlyRepayUSD                   | BigDecimal!      | Total assets repaid on a given hour, in USD                                  |
| inputTokenBalance                | BigInt           | Amount of input token in the market                                          |
| inputTokenPriceUSD               | BigDecimal       | Price per share of input token in USD                                        |
| outputTokenSupply                | \[BigInt!]       | Total supply of output token                                                 |
| outputTokenPriceUSD              | \[BigDecimal!]   | Price per share of output token in USD                                       |
| exchangeRate                     | BigDecimal       | Amount of input token per full share of output token                         |
| rewardTokenEmissionsAmount       | \[BigInt!]       | Per-block reward token emission in native amount                             |
| rewardTokenEmissionsUSD          | \[BigDecimal!]   | Per-block reward token emission in USD value                                 |

## Account

Description: Represents an account entity, detailing the positions, transactions, and activities associated with the account.

| Field               | Type           | Description                                                  |
| ------------------- | -------------- | ------------------------------------------------------------ |
| id                  | ID!            | { Account address }                                          |
| positionCount       | Int!           | Number of positions this account has                         |
| positions           | \[Position!]!  | All positions that belong to this account                    |
| openPositionCount   | Int!           | Number of open positions this account has                    |
| closedPositionCount | Int!           | Number of closed positions this account has                  |
| depositCount        | Int!           | Number of deposits this account made                         |
| deposits            | \[Deposit!]!   | All deposit events of this account                           |
| withdrawCount       | Int!           | Number of withdrawals this account made                      |
| withdraws           | \[Withdraw!]!  | All withdraw events of this account                          |
| borrowCount         | Int!           | Number of borrows this account made                          |
| borrows             | \[Borrow!]!    | All borrow events of this account                            |
| repayCount          | Int!           | Number of repays this account made                           |
| repays              | \[Repay!]!     | All repay events of this account                             |
| liquidateCount      | Int!           | Number of times this account liquidated a position           |
| liquidates          | \[Liquidate!]! | All liquidation events where this account was the liquidator |
| liquidationCount    | Int!           | Number of times this account has been liquidated             |
| liquidations        | \[Liquidate!]! | All liquidation events where this account got liquidated     |

## Position

Description: Represents a specific position held by an account in a market, detailing its characteristics and associated events.

| Field             | Type                  | Description                                                          |
| ----------------- | --------------------- | -------------------------------------------------------------------- |
| id                | ID!                   | { Account address }-{ Market address }-{ Position Side }-{ Counter } |
| account           | Account!              | Account that owns this position                                      |
| market            | Market!               | The market in which this position was opened                         |
| hashOpened        | String!               | The hash of the transaction that opened this position                |
| hashClosed        | String                | The hash of the transaction that closed this position                |
| blockNumberOpened | BigInt!               | Block number of when the position was opened                         |
| timestampOpened   | BigInt!               | Timestamp when the position was opened                               |
| blockNumberClosed | BigInt                | Block number of when the position was closed                         |
| timestampClosed   | BigInt                | Timestamp when the position was closed                               |
| side              | PositionSide!         | Side of the position (either lender or borrower)                     |
| isCollateral      | Boolean               | Whether this position has been enabled as collateral                 |
| balance           | BigInt!               | Balance of the position                                              |
| depositCount      | Int!                  | Number of deposits related to this position                          |
| deposits          | \[Deposit!]!          | All deposit events of this position                                  |
| withdrawCount     | Int!                  | Number of withdrawals related to this position                       |
| withdraws         | \[Withdraw!]!         | All withdraw events of this position                                 |
| borrowCount       | Int!                  | Number of borrows related to this position                           |
| borrows           | \[Borrow!]!           | All borrow events of this position                                   |
| repayCount        | Int!                  | Number of repays related to this position                            |
| repays            | \[Repay!]!            | All repay events of this position                                    |
| liquidationCount  | Int!                  | Number of liquidations related to this position                      |
| liquidations      | \[Liquidate!]!        | Liquidation event related to this position                           |
| snapshots         | \[PositionSnapshot!]! | Position daily snapshots for open positions                          |
| assetPositions    | \[AssetPosition!]!    | Position daily snapshots for open positions                          |

## AssetPosition

Description: Details an asset position within a market, linked to an account and position.

| Field            | Type          | Description                                           |
| ---------------- | ------------- | ----------------------------------------------------- |
| id               | ID!           | { Position ID } - { MarketAsset ID }                  |
| account          | Account!      | Account that owns this position                       |
| position         | Position!     | Account that owns this position                       |
| marketAsset      | MarketAsset!  | The market in which this position was opened          |
| side             | PositionSide! | Side of the position (either lender or borrower)      |
| sToken           | Token!        | Relation to the sToken                                |
| sTokenBalance    | BigInt!       | Token balance of the sTokens for this asset position  |
| spToken          | Token!        | Relation to the spToken                               |
| spTokenBalance   | BigInt!       | Token balance of the spTokens for this asset position |
| dToken           | Token!        | Relation to the dToken                                |
| dTokenBalance    | BigInt!       | Token balance of the dTokens for this asset position  |
| avgEntry         | BigDecimal!   | Weighted avg of the s/dToken conversion               |
| timestampOpened  | BigInt!       | Timestamp when the Asset Position was opened          |
| timestampClosed  | BigInt!       | Timestamp when the asset position was closed          |
| depositCount     | Int!          | Number of deposits related to this asset position     |
| withdrawCount    | Int!          | Number of withdrawals related to this asset position  |
| borrowCount      | Int!          | Number of borrows related to this asset position      |
| repayCount       | Int!          | Number of repays related to this asset position       |
| liquidationCount | Int!          | Number of liquidations related to this asset position |

## PositionSnapshot

Description: Records snapshots for open positions after every significant event, including opening and closing.

| Field         | Type        | Description                                                      |
| ------------- | ----------- | ---------------------------------------------------------------- |
| id            | ID!         | { Position ID }-{ Transaction hash }-{ Log index }               |
| hash          | String!     | Transaction hash of the transaction that triggered this snapshot |
| logIndex      | Int!        | Event log index                                                  |
| nonce         | BigInt!     | Nonce of the transaction that triggered this snapshot            |
| position      | Position!   | Position of this snapshot                                        |
| balance       | BigInt!     | Token balance in this position                                   |
| balanceInput  | BigInt!     | Token balance in this position (input)                           |
| balanceOutput | \[BigInt!]! | Token balance of the output token(s) in this position            |
| blockNumber   | BigInt!     | Block number of this snapshot                                    |
| timestamp     | BigInt!     | Timestamp of this snapshot                                       |

## Oracle

Description: Represents the oracle entity, detailing the oracle used in a lending protocol.

| Field           | Type             | Description                                |
| --------------- | ---------------- | ------------------------------------------ |
| id              | ID!              | { smart contract address for the oracle }  |
| lendingProtocol | LendingProtocol! | The Protocol Address                       |
| tokenOracles    | \[TokenOracle!]! | The relationship of this Oracle to Markets |
| oracleProvider  | String!          | The Oracle Governor contract               |

## TokenOracle

Description: Details the oracle used for pricing tokens in a specific market.

| Field            | Type       | Description                                                      |
| ---------------- | ---------- | ---------------------------------------------------------------- |
| id               | ID!        | { Smart contract address of the market }                         |
| token            | Token!     | The marketId that the Oracle is used for                         |
| blockCreated     | BigInt!    | The block this oracle was adopted for a market                   |
| blockLU          | BigInt!    | The most recent block that the oracle was updated                |
| timestampCreated | BigInt!    | The timestamp this oracle was adopted for a market               |
| timestampLU      | BigInt!    | The most recent timestamp that the oracle was updated            |
| isActive         | Boolean    | Is the Oracle currently used as the source of truth for a market |
| tokenPrice       | BigInt     | The price of the token in WEI                                    |
| tokenPriceUSD    | BigDecimal | Conversion Rate in USD                                           |
| oracle           | Oracle!    | The Protocol that is providing the oracle                        |

## ActiveAccount

Description: Represents an active account in the protocol, detailing its roles.

| Field        | Type     | Description                                                                 |
| ------------ | -------- | --------------------------------------------------------------------------- |
| id           | ID!      | { daily/hourly }-{ Address of the account }-{ Days/hours since Unix epoch } |
| isDepositor  | Boolean! | Indicates if the account is a depositor                                     |
| isBorrower   | Boolean! | Indicates if the account is a borrower                                      |
| isLiquidator | Boolean! | Indicates if the account is a liquidator                                    |
| isLiquidatee | Boolean! | Indicates if the account has been liquidated                                |

## LiquidationHelper

Description: Details the liquidation helper entity used in liquidation transactions.

| Field                      | Type     | Description                                           |
| -------------------------- | -------- | ----------------------------------------------------- |
| id                         | ID!      | Transaction Hash                                      |
| liquidatee                 | Account! | The wallet address that is being liquidated           |
| quoteAmountFromCollaterals | BigInt!  | The total amount received after collateral is swapped |
| quoteLeftAfterRepay        | BigInt!  | The profit for the liquidation                        |

## LiquidationContract

Description: Represents the contract used for liquidation processes.

| Field | Type | Description                                          |
| ----- | ---- | ---------------------------------------------------- |
| id    | ID!  | Contract Address for the liquidation helper contract |

## TowerCoordinate

Description: Represents a coordinate in the system, often associated with a contract.

| Field    | Type   | Description                        |
| -------- | ------ | ---------------------------------- |
| id       | ID!    | Unique identifier                  |
| key      | String | The coordinate, a contract address |
| contract | Bytes  | The associated contract            |

## IncentiveProgram

Description: Details an incentive program related to an asset in the protocol.

| Field                   | Type    | Description                                                 |
| ----------------------- | ------- | ----------------------------------------------------------- |
| id                      | ID!     | { Transaction hash }-{ Log index }                          |
| hash                    | String! | Transaction hash of the transaction that emitted this event |
| blockNumber             | BigInt! | Block number of this event                                  |
| timestamp               | BigInt! | Timestamp of this event                                     |
| asset                   | Token!  | Underlying Asset for the program                            |
| emmissionsPerSecond     | BigInt! | Amount of collateral liquidated in native units             |
| distributionEnd         | BigInt! | Distribution end                                            |
| totalDistributionAmount | BigInt! | Total distribution amount                                   |


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://devdocs.silo.finance/silo-subgraphs/silo-v2-entities.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
