# SILO V3 Entities

* [`Account`](#account)
* [`ActiveAccount`](#activeaccount)
* [`BalanceRebaseHelper`](#balancerebasehelper)
* [`Deposit`](#deposit)
* [`FinancialsDailySnapshot`](#financialsdailysnapshot)
* [`IncentiveProgram`](#incentiveprogram)
* [`InterestRate`](#interestrate)
* [`InterestRateDaily`](#interestratedaily)
* [`InterestRateHourly`](#interestratehourly)
* [`LendingProtocol`](#lendingprotocol)
* [`Liquidate`](#liquidate)
* [`LiquidationHelper`](#liquidationhelper)
* [`Market`](#market)
* [`Oracle`](#oracle)
* [`Position`](#position)
* [`PositionSnapshot`](#positionsnapshot)
* [`Protocol`](#protocol)
* [`RewardToken`](#rewardtoken)
* [`Silo`](#silo)
* [`SiloPosition`](#siloposition)
* [`Token`](#token)
* [`TokenOracle`](#tokenoracle)
* [`TowerCoordinate`](#towercoordinate)

## Account

Description: Represents an account entity with various attributes detailing positions, transactions, and events 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     |

## ActiveAccount

Description: Represents an active account entity, identifying various roles the account may have within the system.

| Field        | Type     | Description                                                                                      |
| ------------ | -------- | ------------------------------------------------------------------------------------------------ |
| id           | ID!      | Unique identifier: `{ daily/hourly }-{ Address of the account }-{ Days/hours since Unix epoch }` |
| isDepositor  | Boolean! | Indicates whether the account has made deposits                                                  |
| isBorrower   | Boolean! | Indicates whether the account has borrowed funds                                                 |
| isLiquidator | Boolean! | Indicates whether the account has acted as a liquidator                                          |
| isLiquidatee | Boolean! | Indicates whether the account has been liquidated                                                |

## BalanceRebaseHelper

Description: Represents an entity used to assist in rebalancing market balances, typically triggered under certain conditions.

| Field   | Type       | Description                                                   |
| ------- | ---------- | ------------------------------------------------------------- |
| id      | ID!        | Set to 'ID', uniquely identifying the entity                  |
| siloIds | \[String!] | Identifiers of silos where a balance loop should be triggered |

## Deposit

Description: Represents a deposit event in the system, detailing the transaction and the associated account, market, and position details.

| Field        | Type          | Description                                                                                     |
| ------------ | ------------- | ----------------------------------------------------------------------------------------------- |
| id           | ID!           | Unique identifier: `{ Transaction hash }-{ Log index }`                                         |
| hash         | String!       | Transaction hash of the transaction that emitted this event                                     |
| nonce        | BigInt!       | Nonce of the transaction that emitted this event                                                |
| logIndex     | Int!          | Event log index. For transactions that don't emit event, create arbitrary index starting from 0 |
| blockNumber  | BigInt!       | Block number of this event                                                                      |
| timestamp    | BigInt!       | Timestamp of this event                                                                         |
| account      | Account!      | Account that deposited tokens                                                                   |
| market       | Market!       | The market tokens are deposited to                                                              |
| silo         | Silo!         | The silo the event is for                                                                       |
| siloPosition | SiloPosition! | The users aggregated positions for a silo                                                       |
| position     | Position!     | The user position changed by this event                                                         |
| asset        | Token!        | Token deposited                                                                                 |
| amount       | BigInt!       | Amount of token deposited in native units                                                       |
| amountUSD    | BigDecimal!   | Amount of token deposited in USD                                                                |

## FinancialsDailySnapshot

Description: Represents a daily snapshot of financial metrics for 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). Only relevant for protocols with PCV.                           |
| mintedTokenSupplies              | \[BigInt!]       | Total supply of minted tokens in native amounts, with same ordering as mintedTokens. Only applies to CDP |
| dailySupplySideRevenueUSD        | BigDecimal!      | Revenue claimed by suppliers to the protocol (e.g., LPs on DEXs, depositors on lending protocols)        |
| cumulativeSupplySideRevenueUSD   | BigDecimal!      | Cumulative revenue claimed by suppliers to the protocol                                                  |
| dailyProtocolSideRevenueUSD      | BigDecimal!      | Gross revenue for the protocol (e.g., AMM protocol fee, OpenSea sell fee)                                |
| cumulativeProtocolSideRevenueUSD | BigDecimal!      | Cumulative gross revenue for the protocol                                                                |
| dailyTotalRevenueUSD             | BigDecimal!      | All revenue generated by the protocol on a given day                                                     |
| 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                                                               |

## IncentiveProgram

Description: Represents an incentive program entity, detailing the specifics of the program including the underlying asset and distribution details.

| Field                   | Type    | Description                                                 |
| ----------------------- | ------- | ----------------------------------------------------------- |
| id                      | ID!     | Unique identifier: `{ 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 amount allocated for distribution                     |

## InterestRate

Description: Represents an interest rate entity with detailed attributes including rate, duration, and associated market and asset information.

| Field              | Type                    | Description                                                                                 |
| ------------------ | ----------------------- | ------------------------------------------------------------------------------------------- |
| id                 | ID!                     | Unique identifier: `{ Interest rate side }-{ Interest rate type }-{ Market ID }-{Token ID}` |
| rate               | BigDecimal!             | Interest rate in percentage APY (e.g., 5.21% 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)                              |
| silo               | Silo                    | The Market that this interest rate is for                                                   |
| market             | Market                  | The Combination of the asset and market                                                     |
| token              | Token                   | The Asset that this interest rate is for                                                    |
| uopt               | BigInt                  | Optimal utilization (uopt ∈ (0, 1))                                                         |
| ucrit              | BigInt                  | Threshold of large utilization (ucrit ∈ (uopt, 1))                                          |
| ulow               | BigInt                  | Threshold of low utilization (ulow ∈ (0, uopt))                                             |
| ki                 | BigInt                  | Integrator gain (ki > 0)                                                                    |
| kcrit              | BigInt                  | Proportional gain for large utilization (kcrit > 0)                                         |
| klow               | BigInt                  | Proportional gain for low utilization (klow ≥ 0)                                            |
| klin               | BigInt                  | Coefficient of the lower linear bound (klin ≥ 0)                                            |
| beta               | BigInt                  | A scaling factor (beta ≥ 0)                                                                 |
| ri                 | BigInt                  | Initial value of the integrator (ri ≥ 0)                                                    |
| Tcrit              | BigInt                  | The time during which the utilization exceeds the critical value (Tcrit ≥ 0)                |
| 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 daily metrics for an interest rate, including utilization, rates, and related calculations.

| Field        | Type          | Description                                                                  |
| ------------ | ------------- | ---------------------------------------------------------------------------- |
| id           | ID!           | Unique identifier: `{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        | Initial value of the integrator (ri ≥ 0)                                     |
| Tcrit        | BigInt        | The time during which the utilization exceeds the critical value (Tcrit ≥ 0) |
| 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 hourly metrics for an interest rate, including utilization, rates, and related calculations.

| Field        | Type          | Description                                                                  |
| ------------ | ------------- | ---------------------------------------------------------------------------- |
| id           | ID!           | Unique identifier: `{InterestRate ID}-{# of days 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        | Initial value of the integrator (ri ≥ 0)                                     |
| Tcrit        | BigInt        | The time during which the utilization exceeds the critical value (Tcrit ≥ 0) |
| 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              |

## LendingProtocol

Description: Represents a lending protocol entity with comprehensive details including protocol characteristics, quantitative data, snapshots, markets, and credit information.

| Field                            | Type                            | Description                                                                                      |
| -------------------------------- | ------------------------------- | ------------------------------------------------------------------------------------------------ |
| id                               | ID!                             | Smart contract address of the protocol's main contract (Factory, Registry, etc)                  |
| name                             | String!                         | Name of the protocol, including version (e.g., Aave v2)                                          |
| slug                             | String!                         | Slug of protocol, including version (e.g., aave-v2)                                              |
| schemaVersion                    | String!                         | Version of the subgraph schema, in SemVer format (e.g., 1.0.0)                                   |
| subgraphVersion                  | String!                         | Version of the subgraph implementation, in SemVer format (e.g., 1.0.0)                           |
| methodologyVersion               | String!                         | Version of the methodology used to compute metrics, loosely based on SemVer format (e.g., 1.0.0) |
| network                          | Network!                        | The blockchain network this subgraph is indexing on                                              |
| type                             | ProtocolType!                   | The type of protocol (e.g., DEX, Lending, Yield, etc)                                            |
| lendingType                      | LendingType                     | The specific lending protocol type                                                               |
| riskType                         | RiskType                        | Risk type of the lending protocol                                                                |
| mintedTokens                     | \[Token!]                       | Tokens that can be minted. Only applies to CDP                                                   |
| cumulativeUniqueUsers            | Int!                            | Number of cumulative unique users                                                                |
| cumulativeUniqueDepositors       | Int!                            | Number of cumulative depositors                                                                  |
| cumulativeUniqueBorrowers        | Int!                            | Number of cumulative borrowers                                                                   |
| cumulativeUniqueLiquidators      | Int!                            | Number of cumulative liquidators (accounts that performed liquidation)                           |
| cumulativeUniqueLiquidatees      | Int!                            | Number of cumulative liquidatees (accounts that got liquidated)                                  |
| totalValueLockedUSD              | BigDecimal!                     | Current TVL (Total Value Locked) of the entire protocol                                          |
| protocolControlledValueUSD       | BigDecimal                      | Current PCV (Protocol Controlled Value). Only relevant for protocols with PCV.                   |
| cumulativeSupplySideRevenueUSD   | BigDecimal!                     | Revenue claimed by suppliers to the protocol                                                     |
| cumulativeProtocolSideRevenueUSD | BigDecimal!                     | Gross revenue for the protocol                                                                   |
| cumulativeTotalRevenueUSD        | BigDecimal!                     | All revenue generated by the protocol                                                            |
| totalDepositBalanceUSD           | BigDecimal!                     | Current balance of all deposited assets, in USD                                                  |
| cumulativeDepositUSD             | BigDecimal!                     | Sum of all historical deposits in USD                                                            |
| cumulativeWithdrawUSD            | BigDecimal!                     | Sum of all historical withdrawals 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                                                        |
| mintedTokenSupplies              | \[BigInt!]                      | Total supply of minted tokens in native amounts                                                  |
| totalPoolCount                   | Int!                            | Total number of pools                                                                            |
| openPositionCount                | Int!                            | Total number of open positions                                                                   |
| openLendingPositionCount         | Int!                            | Number of open lending positions for the protocol                                                |
| openBorrowingPositionCount       | Int!                            | Number of open borrowing positions for the protocol                                              |
| cumulativePositionCount          | Int!                            | Total number of positions (open and closed)                                                      |
| dailyUsageMetrics                | \[UsageMetricsDailySnapshot!]!  | Daily usage metrics for this protocol                                                            |
| hourlyUsageMetrics               | \[UsageMetricsHourlySnapshot!]! | Hourly usage metrics for this protocol                                                           |
| financialMetrics                 | \[FinancialsDailySnapshot!]!    | Daily financial metrics for this protocol                                                        |
| silos                            | \[Silo!]!                       | All markets that belong to this protocol                                                         |
| markets                          | \[Market!]!                     | All markets that belong to this protocol                                                         |
| oracles                          | \[Oracle!]!                     | All Oracles that belong to this protocol                                                         |
| creditSupply                     | BigInt!                         | Total credit supplied in XAI native Amount                                                       |
| creditUtilized                   | BigInt!                         | Total credit utilized in XAI native Amount                                                       |
| TVLBlockUpdated                  | BigInt!                         | Helper field for TVL Updates                                                                     |

## Liquidate

Description: Represents a liquidation event in the system, detailing the transaction, accounts involved, and the financial specifics of the liquidation.

| Field        | Type          | Description                                                                                     |
| ------------ | ------------- | ----------------------------------------------------------------------------------------------- |
| id           | ID!           | Unique identifier: `{ Transaction hash }-{ Log index }`                                         |
| hash         | String!       | Transaction hash of the transaction that emitted this event                                     |
| nonce        | BigInt!       | Nonce of the transaction that emitted this event                                                |
| logIndex     | Int!          | Event log index. For transactions that don't emit event, create arbitrary index starting from 0 |
| blockNumber  | BigInt!       | Block number of this event                                                                      |
| timestamp    | BigInt!       | Timestamp of this event                                                                         |
| liquidator   | Account!      | Account that carried out the liquidation                                                        |
| liquidatee   | Account!      | Account that got liquidated                                                                     |
| market       | Market!       | The market of the collateral being used                                                         |
| silo         | Silo!         | The silo the event is for                                                                       |
| siloPosition | SiloPosition! | The users aggregated positions for a silo                                                       |
| position     | Position!     | The user position changed by this event                                                         |
| asset        | Token!        | Asset repaid (borrowed)                                                                         |
| amount       | BigInt!       | Amount of collateral liquidated in native units                                                 |
| amountUSD    | BigDecimal!   | Amount of collateral liquidated in USD                                                          |
| profitUSD    | BigDecimal!   | Amount of profit from liquidation in USD                                                        |
| account      | Account!      | Liquidatee duplicated as account to implement Event                                             |

## LiquidationHelper

Description: Represents a helper entity for liquidation processes, detailing the account being liquidated and financial specifics of the liquidation.

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

## Market

Description: Represents a market entity within a lending protocol, detailing its characteristics, financial metrics, positions, and related events.

| Field                            | Type                      | Description                                                                                   |
| -------------------------------- | ------------------------- | --------------------------------------------------------------------------------------------- |
| id                               | ID!                       | Unique identifier: `{Silo ID} - {Asset ID}`                                                   |
| protocol                         | LendingProtocol!          | The protocol this pool belongs to                                                             |
| name                             | String                    | Name of market                                                                                |
| isPaused                         | Boolean!                  | Is this market paused for the silo                                                            |
| liquidationPenalty               | BigDecimal!               | Liquidation penalty as a percentage value                                                     |
| inputToken                       | Token!                    | Represents the asset for the market                                                           |
| outputToken                      | \[Token!]!                | Token that is minted to track ownership of position in protocol                               |
| 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                                                        |
| rewardTokens                     | \[RewardToken!]           | Additional tokens given as reward for position in a protocol                                  |
| 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                                          |
| rates                            | \[InterestRate!]!         | All interest rates / fees allowed in the market                                               |
| interestRateModel                | String                    | Interest Rate Model                                                                           |
| silo                             | Silo!                     | Sub Entity to the Market Assets                                                               |
| 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 as of the current block normalized to a day, in native amount |
| rewardTokenEmissionsUSD          | BigDecimal!               | Per-block reward token emission as of the current block normalized to a day, 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                                                       |
| openLendingPositionCount         | Int!                      | Number of open lending positions in this market                                               |
| openBorrowingPositionCount       | Int!                      | Number of open borrowing 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                                                          |

## Oracle

Description: Represents an oracle entity within a lending protocol, detailing its relationship with markets and the oracle provider.

| Field           | Type             | Description                                              |
| --------------- | ---------------- | -------------------------------------------------------- |
| id              | ID!              | Unique identifier: 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                             |

## Position

Description: Represents a position within a market, detailing the account, market, transaction hashes, and various attributes related to the position.

| Field             | Type          | Description                                                                               |
| ----------------- | ------------- | ----------------------------------------------------------------------------------------- |
| id                | ID!           | Unique identifier: `{ 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 (0 if still open)                            |
| timestampClosed   | BigInt        | Timestamp when the position was closed (0 if still open)                                  |
| side              | PositionSide! | Side of the position (either lender or borrower)                                          |
| isCollateral      | Boolean       | Whether this position has been enabled as a collateral                                    |
| sToken            | Token!        | Relation to the sToken                                                                    |
| sTokenBalance     | BigInt!       | Token balance of the sTokens for this asset position, in native WEI equivalence           |
| spToken           | Token!        | Relation to the spToken                                                                   |
| spTokenBalance    | BigInt!       | Token balance of the spTokens for this asset position, in native amounts                  |
| dToken            | Token!        | Relation to the dToken                                                                    |
| dTokenBalance     | BigInt!       | Token balance of the dTokens for this asset position, in native amounts                   |
| balance           | BigInt!       | Not used as we instead use sTokenBalance etc.                                             |
| avgEntry          | BigDecimal!   | Weighted avg of the s/dToken conversion as the account adds to this asset position        |

\| deposit

## PositionSnapshot

Description: Represents a snapshot of a position at a specific point in time, detailing the transaction and balances involved.

| Field         | Type        | Description                                                                                     |
| ------------- | ----------- | ----------------------------------------------------------------------------------------------- |
| id            | ID!         | Unique identifier: `{ Position ID }-{ Transaction hash }-{ Log index }`                         |
| hash          | String!     | Transaction hash of the transaction that triggered this snapshot                                |
| logIndex      | Int!        | Event log index. For transactions that don't emit event, create arbitrary index starting from 0 |
| nonce         | BigInt!     | Nonce of the transaction that triggered this snapshot                                           |
| position      | Position!   | Position of this snapshot                                                                       |
| balance       | BigInt!     | Token balance in this position, in native amounts                                               |
| balanceInput  | BigInt!     | Token balance in this position, in native amounts                                               |
| balanceOutput | \[BigInt!]! | Token balance of the output token(s) in this position, in native amounts                        |
| blockNumber   | BigInt!     | Block number of this snapshot                                                                   |
| timestamp     | BigInt!     | Timestamp of this snapshot                                                                      |

## Protocol

Description: Represents a lending protocol entity with comprehensive details including protocol characteristics, quantitative data, snapshots, markets, and credit information.

| Field                            | Type          | Description                                                                                      |
| -------------------------------- | ------------- | ------------------------------------------------------------------------------------------------ |
| id                               | ID!           | Smart contract address of the protocol's main contract (Factory, Registry, etc)                  |
| name                             | String!       | Name of the protocol, including version (e.g., Aave v2)                                          |
| slug                             | String!       | Slug of protocol, including version (e.g., aave-v2)                                              |
| schemaVersion                    | String!       | Version of the subgraph schema, in SemVer format (e.g., 1.0.0)                                   |
| subgraphVersion                  | String!       | Version of the subgraph implementation, in SemVer format (e.g., 1.0.0)                           |
| methodologyVersion               | String!       | Version of the methodology used to compute metrics, loosely based on SemVer format (e.g., 1.0.0) |
| network                          | Network!      | The blockchain network this subgraph is indexing on                                              |
| type                             | ProtocolType! | The type of protocol (e.g., DEX, Lending, Yield, etc)                                            |
| lendingType                      | LendingType   | The specific lending protocol type                                                               |
| riskType                         | RiskType      | Risk type of the lending protocol                                                                |
| mintedTokens                     | \[Token!]     | Tokens that can be minted. Only applies to CDP                                                   |
| cumulativeUniqueUsers            | Int!          | Number of cumulative unique users                                                                |
| cumulativeUniqueDepositors       | Int!          | Number of cumulative depositors                                                                  |
| cumulativeUniqueBorrowers        | Int!          | Number of cumulative borrowers                                                                   |
| cumulativeUniqueLiquidators      | Int!          | Number of cumulative liquidators (accounts that performed liquidation)                           |
| cumulativeUniqueLiquidatees      | Int!          | Number of cumulative liquidatees (accounts that got liquidated)                                  |
| totalValueLockedUSD              | BigDecimal!   | Current TVL (Total Value Locked) of the entire protocol                                          |
| protocolControlledValueUSD       | BigDecimal    | Current PCV (Protocol Controlled Value). Only relevant for protocols with PCV.                   |
| cumulativeSupplySideRevenueUSD   | BigDecimal!   | Revenue claimed by suppliers to the protocol                                                     |
| cumulativeProtocolSideRevenueUSD | BigDecimal!   | Gross revenue for the protocol                                                                   |
| cumulativeTotalRevenueUSD        | BigDecimal!   | All revenue generated by the protocol                                                            |
| totalDepositBalanceUSD           | BigDecimal!   | Current balance of all deposited assets, in USD                                                  |
| cumulativeDepositUSD             | BigDecimal!   | Sum of all historical deposits in USD                                                            |
| cumulativeWithdrawUSD            | BigDecimal!   | Sum of all historical withdrawals 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                                                        |
| mintedTokenSupplies              | \[BigInt!]    |                                                                                                  |

## RewardToken

Description: Represents a reward token entity, detailing its type and reference to the actual token.

| Field | Type             | Description                                                                               |
| ----- | ---------------- | ----------------------------------------------------------------------------------------- |
| id    | ID!              | Unique identifier: `{ 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                                                              |

## Silo

Description: Represents a silo entity within a lending protocol, detailing its characteristics, TVL, balances, and associated markets and rates.

| Field                  | Type              | Description                                                   |
| ---------------------- | ----------------- | ------------------------------------------------------------- |
| id                     | ID!               | Unique identifier: Smart contract address of the market       |
| name                   | String!           | Name of the silo (base asset symbol)                          |
| protocol               | LendingProtocol!  | Protocol that the silo belongs to                             |
| version                | BigInt!           | Silo Version Number                                           |
| baseAsset              | Token!            | Base Asset                                                    |
| bridgeAsset            | \[Token!]         | Bridge Assets                                                 |
| 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                               |
| totalValueLockedUSD    | BigDecimal!       | Current TVL (Total Value Locked) of this silo                 |
| totalDepositBalanceUSD | BigDecimal!       | Total Deposit Balance of this silo                            |
| totalBorrowBalanceUSD  | BigDecimal!       | Total Borrow Balance of this silo                             |
| market                 | \[Market!]!       | Market for the MarketAsset record                             |
| rates                  | \[InterestRate!]! | All interest rates / fees allowed for the asset in the market |
| siloPositions          | \[SiloPosition!]! | All silo positions                                            |
| activeSiloPositions    | \[String!]        | Silo Position ID's with > 0 collateral                        |
| createdTimestamp       | BigInt!           | Creation timestamp                                            |
| createdBlockNumber     | BigInt!           | Creation block number                                         |

## SiloPosition

Description: Represents a silo position within a lending protocol, detailing the account, positions, balances, and various metrics related to the position.

| Field                          | Type          | Description                                                                                |
| ------------------------------ | ------------- | ------------------------------------------------------------------------------------------ |
| id                             | ID!           | Unique identifier: `{ Silo ID } - {Account ID}`                                            |
| account                        | Account!      | Account that owns this position                                                            |
| positions                      | \[Position!]! | Account that owns this position                                                            |
| silo                           | Silo!         | The market in which this position was opened                                               |
| timestampOpened                | BigInt!       | Timestamp when the Position was most recently opened                                       |
| hashOpened                     | String!       | Transaction hash when the position was most recently opened                                |
| blockNumberOpened              | BigInt!       | Block number when the silo position was most recently opened                               |
| timestampClosed                | BigInt!       | Timestamp when the position was closed (0 if still open)                                   |
| isActive                       | Boolean!      | Does the silo position have active positions as children                                   |
| sTokenBalance                  | BigInt!       | Sum of balances across all lending positions for the silo (both sTokens & spTokens)        |
| dTokenBalance                  | BigInt!       | Sum of balances across all borrowing positions for the silo                                |
| totalCollateralValue           | BigDecimal!   | Total USD value of all lending positions                                                   |
| totalBorrowValue               | BigDecimal!   | Total USD value of all borrow positions                                                    |
| totalLiquidationThresholdValue | BigDecimal!   | Total USD value of all lending positions \* Liquidation Threshold for that asset           |
| riskFactor                     | BigDecimal!   | Percentage representing how close the user is to being insolvent (>= 100% means insolvent) |
| riskScore                      | BigDecimal!   | Derived, quantitative score that ranks borrow positions of interest                        |
| openPositions                  | Int!          | Open Positions for this silo                                                               |
| depositCount                   | Int!          | Number of deposits related to this Silo position                                           |
| withdrawCount                  | Int!          | Number of withdrawals related to this position                                             |
| borrowCount                    | Int!          | Number of borrows related to this position                                                 |
| repayCount                     | Int!          | Number of repays related to this position                                                  |
| liquidationCount               | Int!          | Number of liquidations related to this position                                            |

## Token

Description: Represents a token entity with various attributes like name, symbol, decimals, type, and associated market and silo information.

| 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                                            |
| silo                 | Silo                                          | The silo for the derivative                                                                                 |
| 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!]! @derivedFrom(field: "token") | The Oracle used to determine the price conversion of the tokens in a market                                 |

## TokenOracle

Description: Represents a token oracle entity within a market, detailing its creation, updates, and pricing information.

| Field            | Type       | Description                                                                 |
| ---------------- | ---------- | --------------------------------------------------------------------------- |
| id               | ID!        | Unique identifier: 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 (differs if a market has 2 non-USD based assets)     |
| oracle           | Oracle!    | The Protocol that is providing the oracle (nullable if non-standard source) |

## TowerCoordinate

Description: Represents a TowerCoordinate entity, typically used to map a specific coordinate or contract address within a system.

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


---

# 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-v3-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.
