# Protocol Overview

![](https://files.gitbook.com/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FXkTAUVVLYPoxSHOs8SSD%2Fuploads%2F4AgQTduEErOvVH1XCbp8%2FProject-overview-architecture.jpg?alt=media\&token=d3f85e89-e8d5-4180-a9a8-209cb21b0baf)

### PriceProvidersRepository <a href="#priceprovidersrepository" id="priceprovidersrepository"></a>

The role of an oracle is to provide Silo with the correct price of an asset. SiloOracleRepository is the entry point of token prices for a Silo and manages oracle modules and price request routing. It can support many protocols and sources.

#### BalancerV2PriceProvider <a href="#balancerv2priceprovider" id="balancerv2priceprovider"></a>

BalancerV2Oracle is an oracle module that is responsible for pulling the correct prices of a given asset from BalanecerV2 pools. It performs security checks and returns TWAP prices when requested.

#### UniswapV3PriceProvider <a href="#uniswapv3priceprovider" id="uniswapv3priceprovider"></a>

UniswapV3Oracle is an oracle module that is responsible for pulling the correct prices of a given asset from UniswapV3 pools. It performs security checks and returns TWAP prices when requested.

#### ChainlinkPriceProvider <a href="#balancerv2priceprovider" id="balancerv2priceprovider"></a>

ChainlinkV2 Oracle is an oracle module that is responsible for pulling the correct prices of a given asset from Chainlink Price Feeds.

### Silo <a href="#silo" id="silo"></a>

Silo is the main component of the protocol. It implements lending logic, manages and isolates risk, acts as a vault for assets, and performs liquidations. Each Silo is composed of the unique asset for which it was created (ie. UNI) and bridge assets (ie. ETH and SiloDollar). There may be multiple bridge assets at any given time.

### SiloRepository <a href="#silorepository" id="silorepository"></a>

Repository handles the creation and configuration of Silos.

* **Stores configuration for each asset in each Silo:** Each asset in each Silo starts with a default config that later on can be changed by the contract owner
* **Stores registry of Factory contracts that deploy different versions of Silos:** It is possible to have multiple versions/implementations of Silo and use different versions for different tokens. For example, one version can be used for UNI (ERC20) and the other can be used for UniV3LP tokens (ERC721)
* **Manages bridge assets:** Each Silo can have 1 or more bridge assets. New Silos are created with all currently active bridge assets. Silos that are already developed must synchronize bridge assets. Sync can be done by anyone since the function has public access.
* Is a single source of truth for other contract addresses

#### SiloFactory <a href="#silofactory" id="silofactory"></a>

Factory contract performs deployment of each Silo. Many Factory contracts can be registered with the Repository contract.

### Interest Rate Model <a href="#interest-rate-model" id="interest-rate-model"></a>

Interest Rate Model calculates the dynamic interest rate for each asset in each Silo at any given time. It calculates two values:

1. 1.**Current Interest Rate:** Used to display the current interest rate for the user in UI.
2. 2.**Compound Interest Rate:** Returns the interest rate for a given time range compounded every second.

### Silo Router <a href="#silo-router" id="silo-router"></a>

Silo Router is a utility contract that aims to improve UX. It can batch any number or combination of actions (Deposit, Withdraw, Borrow, Repay) and execute them in a single transaction.


# Upgradability

The platform is designed by a set of registries where the component itself can't be updated but can be replaced by a new version. Clients of these components will automatically switch to the latest version of it. The core part of the platform ("Silo") does not store any information regarding the version of such components as price providers or tokens factory. It fetches the latest version from the Silo repository before any request to these components. The only component in the system that can't be updated is Silo Repository.

![](/files/PZAbL0RwLk6hpsm5nyTH)


# Asset Configuration

Each asset configuration in the protocol is stored in the Silo Repository. An authorized party can determine a default configuration for assets by the protocol design. This configuration will apply to any new asset added to the system and can be updated later.\
\
Configuration for any asset configured through the Silo Repository will apply to all Silos that use this asset.

![Silo Repository as a single source of the asset configuration](/files/AV9cmFjLw6s6cj4W4a43)

Silo Repository allows for authorized parties to configure:\
\- **maxLoanToValue** (uint64) Loan-to-Value ratio represents the maximum borrowing power of a specific collateral.\
\- **liquidationThreshold** (uint64) The liquidation threshold represents the threshold at which a borrow position will be considered undercollateralized and subject to liquidation for each collateral.\
\- **interestRateModel** (address) The interest rate model address

![Example of the asset configurations for the user solvency calculation](/files/BrCKFftTSEO3Z6AFyJuF)

![Silo's interaction with the Interest model](/files/muWmgECodnCED8C2sgcU)


# Silo Assets

For each asset in a Silo, there are three ERC-20 tokens deployed via Tokens Factory:

* shares token that will represent a collateral
* shares token that will represent protected collateral (cannot be borrowed)
* debt token that will be minted to represent a debt

When the user deposits into a Silo they can decide where their deposit can be borrowed by other users to earn interest. Protected deposits are also called "collateral only" and other users cannot borrow them.\
\
Silo uses the mint and burn functions to operate these underlying tokens. Meanwhile, the transfer is still available and can be used by any third-party application (MetaMask, DEX, etc...). Underlying tokens support hooks and can notify about the basic tokens operations (mint, burn, transfer) third party smart contract if those will be configured in the Silo Repository as a notification receiver for the Silo where operation occurs.\
\
For better understanding, see basic Silo operations with assets state visualization

![Underlying Silo assets state visualization](/files/f9NCRFKds37MgfaJaErJ)


# Bridge Assets & Bridge Pool

On the Silo protocol, assets are divided into two classes: silo and bridge assets. From the technical perspective, there is no difference. All assets are the same ERC-20 compatible tokens. The difference is in how these assets are used in the protocol. When creating a silo, we need to specify for which asset it is created for. This asset will be a "silo asset". But technically, we can't create a silo with a single asset. In that scenario, it loses any practical value for the protocol - a bridge asset is required for a silo to function.\
\
Let's take a look at an example for a better understanding. SiloRepository has one bridge asset registered: WETH. We create two silos: LINK and DAI.

![Bridge asset in the silo](/files/MWm6S90t0Xm8Tg2ir2MP)

Each silo can have only one "silo asset" and multiple bridge assets. Management of the bridge assets happens in the Silo Repository where an authorized party (governance) can add/remove bridge assets. After adding/removing bridge asset, each Silo must be synchronized.

Synchronization occurs automatically during silo creation and manually after that. The method for the bridge assets synchronization is public and open to anyone which means that at any point in time, any user can synchronize bridge assets into the silo.

The synchronization process can affect a silo in two ways: adding or removing the bridge assets. When the bridge asset is added to the silo, users will be able to deposit it and borrow any other asset in the silo using it as collateral.

\
On the other hand, if existing in the silo, the bridge asset will be removed its functionality will be limited. Such features as "deposit" and "borrow" will be disabled. While "withdraw" and "repay" will still work. It can happen that the removed bridge asset will be added again. In that case, it should work as any other asset.\
\
If there are two or more bridge assets in the protocol, it opens a possibility to create a "bridge pool". This pool is similar to any other silo in the protocol and behaves in the same way. The only difference is that we can create only one "bridge pool" in the protocol, and it contains only the bridge assets. The bridge asset for which this silo was created will become a "silo asset" in that silo.

![Bridge pool](/files/GpNlyHk0cFnSW8mZMEcw)

To better understand, see application state visualization while bridge assets are added/removed, and bridge pool is created.

![Application state](/files/CEyyQmGdjnm5BLnXIsAv)

![Actions notes](/files/8CA5a6UuhPxznGXRLDXC)


# System Roles

### InterestRateModel

* Owner: [Team-managed Safe 3/5](https://etherscan.io/address/0xE8e8041cB5E3158A0829A19E014CA1cf91098554)

| **Role** | **Methods** | **Describtion**                     |
| -------- | ----------- | ----------------------------------- |
| Owner    | setConfig   | Sets model configuration for assets |

### SiloRepository

Owner: [Team-managed Safe 3/5](https://etherscan.io/address/0xE8e8041cB5E3158A0829A19E014CA1cf91098554)

| **Role** | **Methods**                    | **Describtion**                                       |
| -------- | ------------------------------ | ----------------------------------------------------- |
| Owner    | setTokensFactory               | Sets contract that deploys tokens                     |
| Owner    | setFees                        | Sets protocol fees                                    |
| Owner    | setAssetConfig                 | Sets asset config                                     |
| Owner    | setDefaultInterestRateModel    | Sets default interest rate model                      |
| Owner    | setDefaultMaximumLTV           | Sets default maximum LTV                              |
| Owner    | setDefaultLiquidationThreshold | Sets default liquidation threshold                    |
| Owner    | setPriceProvidersRepository    | Sets PriceProvidersRepository contract                |
| Owner    | setRouter                      | Sets Router contract                                  |
| Owner    | setNotificationReceiver        | Sets notification receiver (rewards/farming) contract |
| Owner    | addBridgeAsset                 | Adds bridge asset                                     |
| Owner    | removeBridgeAsset              | Removes bridge asset                                  |
| Owner    | replaceSilo                    | Replaces already deployed Silo within the system      |
| Owner    | registerSiloVersion            | Adds new Silo contract version                        |
| Owner    | unregisterSiloVersion          | Removes Silo contract version                         |
| Owner    | setDefaultSiloVersion          | Sets default Silo contract version                    |
| Manager  | toggleLimitedMaxLiquidity      | on/off deposits limit                                 |
| Manager  | setDefaultSiloMaxDepositsLimit | default deposits limit                                |
| Manager  | setSiloMaxDepositsLimit        | deposits limit for Silo                               |
| Manager  | setGlobalPause                 | pause all Silos                                       |
| Manager  | setSiloPause                   | pause specific Silo                                   |

### PriceProvidersRepository

Owner: [Team-managed Safe 3/5](https://etherscan.io/address/0xE8e8041cB5E3158A0829A19E014CA1cf91098554)

| **Role** | **Methods**              | **Description**                     |
| -------- | ------------------------ | ----------------------------------- |
| Owner    | addPriceProvider         | Registers new price provider module |
| Owner    | removePriceProvider      | Unregisters price provider module   |
| Manager  | setPriceProviderForAsset | Assigns price provider for an asset |

### UniswapV3PriceProvider

Manager: [Team-managed Safe 3/5](https://etherscan.io/address/0xE8e8041cB5E3158A0829A19E014CA1cf91098554)

(inherited from PriceProvidersRepository)

| **Role** | **Methods**             | **Description**                                                                        |
| -------- | ----------------------- | -------------------------------------------------------------------------------------- |
| Manager  | setupAsset              | Configures price feed for asset                                                        |
| Manager  | changePeriodForAvgPrice | Change period for which to calculated TWAP prices                                      |
| Manager  | changeBlockTime         | Change block time which is used to adjust oracle cardinality fot providing TWAP prices |

BalancerV2PriceProvider

Manager: [Team-managed Safe 3/5](https://etherscan.io/address/0xE8e8041cB5E3158A0829A19E014CA1cf91098554)

(inherited from PriceProvidersRepository)

| **Role** | **Methods**             | **Description**                                                                             |
| -------- | ----------------------- | ------------------------------------------------------------------------------------------- |
| Manager  | setupAsset              | Configures price feed for asset                                                             |
| Manager  | changePeriodForAvgPrice | Change period for which to calculated TWAP prices                                           |
| Manager  | changeSecondsAgo        | Change number of seconds in the past where calculations starts for average price            |
| Manager  | changeSettings          | Change period for average price and number of seconds in the past where calculations starts |


# Core Protocol

### [SiloRepository](/smart-contracts-overview/core-protocol/silorepository)

### [Silo](/smart-contracts-overview/core-protocol/silo)


# SiloRepository

> SiloRepository

SiloRepository handles the creation and configuration of Silos.

*Stores configuration for each asset in each silo. Each asset in each Silo starts with a default config can later be changed by the contract owner. Stores registry of Factory contracts that deploy different versions of Silos. It is possible to have multiple versions/implementations of Silo and use different versions for different tokens. For example, one version can be used for UNI (ERC20) and the other can be used for UniV3LP tokens (ERC721). Manages bridge assets. Each Silo can have 1 or more bridge assets. New Silos are created with all currently active bridge assets. Silos that are already developed must synchronize bridge assets. Sync can be done by anyone, function has public access. Is a single source of truth for other contract addresses.*

## Methods

### acceptOwnership

```solidity
function acceptOwnership() external nonpayable
```

*Transfers ownership of the contract to a pending owner Can only be called by the pending owner.*

### addBridgeAsset

```solidity
function addBridgeAsset(address _newBridgeAsset) external nonpayable
```

Adds new bridge asset

*New bridge asset must be unique. Duplicates in bridge assets are not allowed. It's possible to add bridge asset that has been removed in the past. Note that all Silos must be synced manually. Callable only by owner.*

#### Parameters

| Name             | Type    | Description          |
| ---------------- | ------- | -------------------- |
| \_newBridgeAsset | address | bridge asset address |

### assetConfigs

```solidity
function assetConfigs(address, address) external view returns (uint64 maxLoanToValue, uint64 liquidationThreshold, contract IInterestRateModel interestRateModel)
```

*maps silo => asset => config*

#### Parameters

| Name | Type    | Description |
| ---- | ------- | ----------- |
| \_0  | address | undefined   |
| \_1  | address | undefined   |

#### Returns

| Name                 | Type                        | Description |
| -------------------- | --------------------------- | ----------- |
| maxLoanToValue       | uint64                      | undefined   |
| liquidationThreshold | uint64                      | undefined   |
| interestRateModel    | contract IInterestRateModel | undefined   |

### bridgePool

```solidity
function bridgePool() external view returns (address)
```

*Silo for bridge asset. We can have only one bridge pool*

#### Returns

| Name | Type    | Description |
| ---- | ------- | ----------- |
| \_0  | address | undefined   |

### defaultAssetConfig

```solidity
function defaultAssetConfig() external view returns (uint64 maxLoanToValue, uint64 liquidationThreshold, contract IInterestRateModel interestRateModel)
```

*Default values for AssetConfig. Used if values are not configured manually.*

#### Returns

| Name                 | Type                        | Description |
| -------------------- | --------------------------- | ----------- |
| maxLoanToValue       | uint64                      | undefined   |
| liquidationThreshold | uint64                      | undefined   |
| interestRateModel    | contract IInterestRateModel | undefined   |

### ensureCanCreateSiloFor

```solidity
function ensureCanCreateSiloFor(address _asset, bool _assetIsABridge) external view
```

*checks all conditions for new silo creation and throws when not possible to create*

#### Parameters

| Name             | Type    | Description                                                   |
| ---------------- | ------- | ------------------------------------------------------------- |
| \_asset          | address | address of asset for which you want to create silo            |
| \_assetIsABridge | bool    | bool TRUE when `_asset` is bridge asset, FALSE when it is not |

### entryFee

```solidity
function entryFee() external view returns (uint256)
```

*Get protocol fee for opening a borrow position*

#### Returns

| Name | Type    | Description                                                      |
| ---- | ------- | ---------------------------------------------------------------- |
| \_0  | uint256 | fee in precision points (BaseSilo.PRECISION\_DECIMALS() == 100%) |

### fees

```solidity
function fees() external view returns (uint64 entryFee, uint64 protocolShareFee, uint64 protocolLiquidationFee)
```

#### Returns

| Name                   | Type   | Description |
| ---------------------- | ------ | ----------- |
| entryFee               | uint64 | undefined   |
| protocolShareFee       | uint64 | undefined   |
| protocolLiquidationFee | uint64 | undefined   |

### getBridgeAssets

```solidity
function getBridgeAssets() external view returns (address[])
```

Get current bridge assets

*Keep in mind that not all Silos may be synced with current bridge assets so it's possbile that some assets in that list are not part of given Silo.*

#### Returns

| Name | Type       | Description                    |
| ---- | ---------- | ------------------------------ |
| \_0  | address\[] | address array of bridge assets |

### getInterestRateModel

```solidity
function getInterestRateModel(address _silo, address _asset) external view returns (contract IInterestRateModel model)
```

Get Interest Rate Model address for asset in given Silo

*If dedicated config is not set, method returns default config*

#### Parameters

| Name    | Type    | Description         |
| ------- | ------- | ------------------- |
| \_silo  | address | address of Silo     |
| \_asset | address | address of an asset |

#### Returns

| Name  | Type                        | Description                    |
| ----- | --------------------------- | ------------------------------ |
| model | contract IInterestRateModel | address of interest rate model |

### getLiquidationThreshold

```solidity
function getLiquidationThreshold(address _silo, address _asset) external view returns (uint256)
```

Get liquidation threshold for asset in given Silo

*If dedicated config is not set, method returns default config*

#### Parameters

| Name    | Type    | Description         |
| ------- | ------- | ------------------- |
| \_silo  | address | address of Silo     |
| \_asset | address | address of an asset |

#### Returns

| Name | Type    | Description                                                                |
| ---- | ------- | -------------------------------------------------------------------------- |
| \_0  | uint256 | liquidation threshold in precision points (BaseSilo.PRECISION\_DECIMALS()) |

### getMaxSiloDeposits

```solidity
function getMaxSiloDeposits(address _silo, address _asset) external view returns (uint256)
```

Gets deposit limit for Silo

#### Parameters

| Name    | Type    | Description                         |
| ------- | ------- | ----------------------------------- |
| \_silo  | address | Silo address for which to set limit |
| \_asset | address | Silo asset for which to set limit   |

#### Returns

| Name | Type    | Description            |
| ---- | ------- | ---------------------- |
| \_0  | uint256 | deposit limit for Silo |

### getMaximumLTV

```solidity
function getMaximumLTV(address _silo, address _asset) external view returns (uint256)
```

Get maximum LTV for asset in given Silo

*If dedicated config is not set, method returns default config*

#### Parameters

| Name    | Type    | Description         |
| ------- | ------- | ------------------- |
| \_silo  | address | address of Silo     |
| \_asset | address | address of an asset |

#### Returns

| Name | Type    | Description                                                      |
| ---- | ------- | ---------------------------------------------------------------- |
| \_0  | uint256 | maximum LTV in precision points (BaseSilo.PRECISION\_DECIMALS()) |

### getNotificationReceiver

```solidity
function getNotificationReceiver(address) external view returns (contract INotificationReceiver)
```

*Maps Silo address to incentive contract that will distribute rewards for that Silo*

#### Parameters

| Name | Type    | Description |
| ---- | ------- | ----------- |
| \_0  | address | undefined   |

#### Returns

| Name | Type                           | Description |
| ---- | ------------------------------ | ----------- |
| \_0  | contract INotificationReceiver | undefined   |

### getRemovedBridgeAssets

```solidity
function getRemovedBridgeAssets() external view returns (address[])
```

Get removed bridge assets

*Keep in mind that not all Silos may be synced with bridge assets so it's possbile that some assets in that list are still part of given Silo.*

#### Returns

| Name | Type       | Description                    |
| ---- | ---------- | ------------------------------ |
| \_0  | address\[] | address array of bridge assets |

### getSilo

```solidity
function getSilo(address) external view returns (address)
```

*maps token address to silo address, asset => silo*

#### Parameters

| Name | Type    | Description |
| ---- | ------- | ----------- |
| \_0  | address | undefined   |

#### Returns

| Name | Type    | Description |
| ---- | ------- | ----------- |
| \_0  | address | undefined   |

### isPaused

```solidity
function isPaused() external view returns (bool globalPause)
```

#### Returns

| Name        | Type | Description |
| ----------- | ---- | ----------- |
| globalPause | bool | undefined   |

### isSilo

```solidity
function isSilo(address _silo) external view returns (bool)
```

Check if contract address is a Silo deployment

#### Parameters

| Name   | Type    | Description              |
| ------ | ------- | ------------------------ |
| \_silo | address | address of expected Silo |

#### Returns

| Name | Type | Description                                         |
| ---- | ---- | --------------------------------------------------- |
| \_0  | bool | true if address is Silo deployment, otherwise false |

### isSiloPaused

```solidity
function isSiloPaused(address _silo, address _asset) external view returns (bool)
```

Check given asset in a Silo is paused

#### Parameters

| Name    | Type    | Description         |
| ------- | ------- | ------------------- |
| \_silo  | address | address of Silo     |
| \_asset | address | address of an asset |

#### Returns

| Name | Type | Description                                              |
| ---- | ---- | -------------------------------------------------------- |
| \_0  | bool | true if given asset in a Silo is paused, otherwise false |

### maxLiquidity

```solidity
function maxLiquidity() external view returns (bool globalToggle, uint256 defaultMaxLiquidity)
```

#### Returns

| Name                | Type    | Description |
| ------------------- | ------- | ----------- |
| globalToggle        | bool    | undefined   |
| defaultMaxLiquidity | uint256 | undefined   |

### newSilo

```solidity
function newSilo(address _siloAsset, uint128 _siloVersion, bytes _siloData) external nonpayable
```

use this method only when off-chain verification is OFF

*Silo does NOT support rebase and deflationary tokens*

#### Parameters

| Name          | Type    | Description                                             |
| ------------- | ------- | ------------------------------------------------------- |
| \_siloAsset   | address | silo asset                                              |
| \_siloVersion | uint128 | version of silo implementation                          |
| \_siloData    | bytes   | (optional) data that may be needed during silo creation |

### owner

```solidity
function owner() external view returns (address)
```

Get owner role address of Repository

#### Returns

| Name | Type    | Description        |
| ---- | ------- | ------------------ |
| \_0  | address | owner role address |

### pendingOwner

```solidity
function pendingOwner() external view returns (address)
```

*Returns the address of the pending owner.*

#### Returns

| Name | Type    | Description |
| ---- | ------- | ----------- |
| \_0  | address | undefined   |

### priceProvidersRepository

```solidity
function priceProvidersRepository() external view returns (contract IPriceProvidersRepository)
```

*PriceProvidersRepository contract that manages ProceProviders implementations and is an entry point for reading prices for Silos.*

#### Returns

| Name | Type                               | Description |
| ---- | ---------------------------------- | ----------- |
| \_0  | contract IPriceProvidersRepository | undefined   |

### protocolLiquidationFee

```solidity
function protocolLiquidationFee() external view returns (uint256)
```

*Get protocol liquidation fee*

#### Returns

| Name | Type    | Description                                                                           |
| ---- | ------- | ------------------------------------------------------------------------------------- |
| \_0  | uint256 | protocol liquidation fee in precision points (BaseSilo.PRECISION\_DECIMALS() == 100%) |

### protocolShareFee

```solidity
function protocolShareFee() external view returns (uint256)
```

*Get protocol share fee*

#### Returns

| Name | Type    | Description                                                                     |
| ---- | ------- | ------------------------------------------------------------------------------- |
| \_0  | uint256 | protocol share fee in precision points (BaseSilo.PRECISION\_DECIMALS() == 100%) |

### registerSiloVersion

```solidity
function registerSiloVersion(contract ISiloFactory _factory, bool _isDefault) external nonpayable
```

Registers new Silo version

*User can choose which Silo version he wants to deploy. It's possible to have multiple versions of Silo. Callable only by owner.*

#### Parameters

| Name        | Type                  | Description                                       |
| ----------- | --------------------- | ------------------------------------------------- |
| \_factory   | contract ISiloFactory | factory contract that deploys new version of Silo |
| \_isDefault | bool                  | true if this version should be used as default    |

### removeBridgeAsset

```solidity
function removeBridgeAsset(address _bridgeAssetToRemove) external nonpayable
```

Removes bridge asset

*Note that all Silos must be synced manually. Callable only by owner.*

#### Parameters

| Name                  | Type    | Description                        |
| --------------------- | ------- | ---------------------------------- |
| \_bridgeAssetToRemove | address | bridge asset address to be removed |

### renounceOwnership

```solidity
function renounceOwnership() external nonpayable
```

*Leaves the contract without owner. It will not be possible to call `onlyOwner` functions anymore. Can only be called by the current owner. NOTE: Renouncing ownership will leave the contract without an owner, thereby removing any functionality that is only available to the owner.*

### replaceSilo

```solidity
function replaceSilo(address _siloAsset, uint128 _siloVersion, bytes _siloData) external nonpayable
```

use this method to deploy new version of Silo for an asset that already has Silo deployed. Only owner (DAO) can replace.

*Silo does NOT support rebase and deflationary tokens*

#### Parameters

| Name          | Type    | Description                                                                               |
| ------------- | ------- | ----------------------------------------------------------------------------------------- |
| \_siloAsset   | address | silo asset                                                                                |
| \_siloVersion | uint128 | version of silo implementation. Use 0 for default version which is fine for 99% of cases. |
| \_siloData    | bytes   | (optional) data that may be needed during silo creation                                   |

### router

```solidity
function router() external view returns (address)
```

*SiloRouter utility contract that combines number of actions (Deposit, Withdraw, Borrow, Repay) for batch execution in single transaction.*

#### Returns

| Name | Type    | Description |
| ---- | ------- | ----------- |
| \_0  | address | undefined   |

### setAssetConfig

```solidity
function setAssetConfig(address _silo, address _asset, ISiloRepository.AssetConfig _assetConfig) external nonpayable
```

Set configuration for given asset in given Silo

*Callable only by owner*

#### Parameters

| Name          | Type                        | Description                                                                                                                                                                                                                                                                                                                  |
| ------------- | --------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| \_silo        | address                     | Silo address for which config applies                                                                                                                                                                                                                                                                                        |
| \_asset       | address                     | asset address for which config applies                                                                                                                                                                                                                                                                                       |
| \_assetConfig | ISiloRepository.AssetConfig | : - \_maxLoanToValue maximum Loan-to-Value, for detailes see `Repository.AssetConfig.maxLoanToValue` - \_liquidationThreshold liquidation threshold, for detailes see `Repository.AssetConfig.maxLoanToValue` - \_interestRateModel interest rate model address, for detailes see `Repository.AssetConfig.interestRateModel` |

### setDefaultInterestRateModel

```solidity
function setDefaultInterestRateModel(contract IInterestRateModel _defaultInterestRateModel) external nonpayable
```

Set default interest rate model

*Callable only by owner*

#### Parameters

| Name                       | Type                        | Description                 |
| -------------------------- | --------------------------- | --------------------------- |
| \_defaultInterestRateModel | contract IInterestRateModel | default interest rate model |

### setDefaultLiquidationThreshold

```solidity
function setDefaultLiquidationThreshold(uint64 _defaultLiquidationThreshold) external nonpayable
```

Set default liquidation threshold

*Callable only by owner*

#### Parameters

| Name                          | Type   | Description                                                                        |
| ----------------------------- | ------ | ---------------------------------------------------------------------------------- |
| \_defaultLiquidationThreshold | uint64 | default liquidation threshold in precision points (BaseSilo.PRECISION\_DECIMALS()) |

### setDefaultMaximumLTV

```solidity
function setDefaultMaximumLTV(uint64 _defaultMaxLTV) external nonpayable
```

Set default maximum LTV

*Callable only by owner*

#### Parameters

| Name            | Type   | Description                                                              |
| --------------- | ------ | ------------------------------------------------------------------------ |
| \_defaultMaxLTV | uint64 | default maximum LTV in precision points (BaseSilo.PRECISION\_DECIMALS()) |

### setDefaultSiloMaxDepositsLimit

```solidity
function setDefaultSiloMaxDepositsLimit(uint256 _maxDeposits) external nonpayable
```

Sets default deposit limit for all Silos

#### Parameters

| Name          | Type    | Description                 |
| ------------- | ------- | --------------------------- |
| \_maxDeposits | uint256 | deposit limit amount in ETH |

### setDefaultSiloVersion

```solidity
function setDefaultSiloVersion(uint128 _defaultVersion) external nonpayable
```

Set default Silo version

*Callable only by owner.*

#### Parameters

| Name             | Type    | Description                       |
| ---------------- | ------- | --------------------------------- |
| \_defaultVersion | uint128 | Silo version to be set as default |

### setFees

```solidity
function setFees(ISiloRepository.Fees _fees) external nonpayable
```

Set default fees

*Callable only by owner*

#### Parameters

| Name   | Type                 | Description                                                                                                                                                                                                                                                                                                                                                                                                                                   |
| ------ | -------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| \_fees | ISiloRepository.Fees | : - \_entryFee one time protocol fee for opening a borrow position in precision points (BaseSilo.PRECISION\_DECIMALS()) - \_protocolShareFee protocol revenue share in interest paid in precision points (BaseSilo.PRECISION\_DECIMALS()) - \_protocolLiquidationFee protocol share in liquidation profit in precision points (BaseSilo.PRECISION\_DECIMALS()). It's calculated from total collateral amount to be transferred to liquidator. |

### setGlobalPause

```solidity
function setGlobalPause(bool _globalPause) external nonpayable
```

Pause all Silos

*Callable only by owner.*

#### Parameters

| Name          | Type | Description                              |
| ------------- | ---- | ---------------------------------------- |
| \_globalPause | bool | true to pause all Silos, otherwise false |

### setNotificationReceiver

```solidity
function setNotificationReceiver(address _silo, contract INotificationReceiver _newNotificationReceiver) external nonpayable
```

Set NotificationReceiver contract

*Callable only by owner*

#### Parameters

| Name                      | Type                           | Description                                           |
| ------------------------- | ------------------------------ | ----------------------------------------------------- |
| \_silo                    | address                        | silo address for which to set `_notificationReceiver` |
| \_newNotificationReceiver | contract INotificationReceiver | undefined                                             |

### setPriceProvidersRepository

```solidity
function setPriceProvidersRepository(address _repository) external nonpayable
```

Set price provider repository

*Callable only by owner*

#### Parameters

| Name         | Type    | Description                       |
| ------------ | ------- | --------------------------------- |
| \_repository | address | price provider repository address |

### setRouter

```solidity
function setRouter(address _router) external nonpayable
```

Set router contract

*Callable only by owner*

#### Parameters

| Name     | Type    | Description    |
| -------- | ------- | -------------- |
| \_router | address | router address |

### setSiloMaxDepositsLimit

```solidity
function setSiloMaxDepositsLimit(address _silo, address _asset, uint256 _maxDeposits) external nonpayable
```

Sets deposit limit for Silo

#### Parameters

| Name          | Type    | Description                         |
| ------------- | ------- | ----------------------------------- |
| \_silo        | address | Silo address for which to set limit |
| \_asset       | address | Silo asset for which to set limit   |
| \_maxDeposits | uint256 | deposit limit amount in ETH         |

### setSiloPause

```solidity
function setSiloPause(address _silo, address _asset, bool _pauseValue) external nonpayable
```

Pause single asset in a single Silo

*Callable only by owner.*

#### Parameters

| Name         | Type    | Description                                       |
| ------------ | ------- | ------------------------------------------------- |
| \_silo       | address | address of Silo in which `_asset` is being paused |
| \_asset      | address | address of an asset that is being paused          |
| \_pauseValue | bool    | true to pause, false to unpause                   |

### setTokensFactory

```solidity
function setTokensFactory(address _tokensFactory) external nonpayable
```

Set factory contract for debt and collateral tokens for each Silo asset

*Callable only by owner*

#### Parameters

| Name            | Type    | Description                                                               |
| --------------- | ------- | ------------------------------------------------------------------------- |
| \_tokensFactory | address | address of TokensFactory contract that deploys debt and collateral tokens |

### siloFactory

```solidity
function siloFactory(uint256) external view returns (contract ISiloFactory)
```

*Maps version => ISiloFactory. Versions start at 1 and are incremented by 1.*

#### Parameters

| Name | Type    | Description |
| ---- | ------- | ----------- |
| \_0  | uint256 | undefined   |

#### Returns

| Name | Type                  | Description |
| ---- | --------------------- | ----------- |
| \_0  | contract ISiloFactory | undefined   |

### siloRepositoryPing

```solidity
function siloRepositoryPing() external pure returns (bool)
```

#### Returns

| Name | Type | Description |
| ---- | ---- | ----------- |
| \_0  | bool | undefined   |

### siloReverse

```solidity
function siloReverse(address) external view returns (address)
```

*maps silo address to token address, silo => asset*

#### Parameters

| Name | Type    | Description |
| ---- | ------- | ----------- |
| \_0  | address | undefined   |

#### Returns

| Name | Type    | Description |
| ---- | ------- | ----------- |
| \_0  | address | undefined   |

### siloVersion

```solidity
function siloVersion() external view returns (uint128 byDefault, uint128 latest)
```

#### Returns

| Name      | Type    | Description |
| --------- | ------- | ----------- |
| byDefault | uint128 | undefined   |
| latest    | uint128 | undefined   |

### toggleLimitedMaxLiquidity

```solidity
function toggleLimitedMaxLiquidity() external nonpayable
```

Switch to turn on and off limited liquidity

### tokensFactory

```solidity
function tokensFactory() external view returns (contract ITokensFactory)
```

*Factory contracts that deploys debt and collateral tokens for each asset in Silo*

#### Returns

| Name | Type                    | Description |
| ---- | ----------------------- | ----------- |
| \_0  | contract ITokensFactory | undefined   |

### transferOwnership

```solidity
function transferOwnership(address newOwner) external nonpayable
```

*Transfers ownership of the contract to a new account (`newOwner`). Can only be called by the current owner.*

#### Parameters

| Name     | Type    | Description |
| -------- | ------- | ----------- |
| newOwner | address | undefined   |

### transferPendingOwnership

```solidity
function transferPendingOwnership(address newPendingOwner) external nonpayable
```

*Transfers pending ownership of the contract to a new account (`newPendingOwner`). Can only be called by the current owner.*

#### Parameters

| Name            | Type    | Description |
| --------------- | ------- | ----------- |
| newPendingOwner | address | undefined   |

### unregisterSiloVersion

```solidity
function unregisterSiloVersion(uint128 _siloVersion) external nonpayable
```

Unregisters Silo version

*Callable only by owner.*

#### Parameters

| Name          | Type    | Description                     |
| ------------- | ------- | ------------------------------- |
| \_siloVersion | uint128 | Silo version to be unregistered |

## Events

### BridgeAssetAdded

```solidity
event BridgeAssetAdded(address newBridgeAsset)
```

Emitted on new bridge asset

#### Parameters

| Name           | Type    | Description |
| -------------- | ------- | ----------- |
| newBridgeAsset | address | undefined   |

### BridgeAssetRemoved

```solidity
event BridgeAssetRemoved(address bridgeAssetRemoved)
```

Emitted on removed bridge asset

#### Parameters

| Name               | Type    | Description |
| ------------------ | ------- | ----------- |
| bridgeAssetRemoved | address | undefined   |

### BridgePool

```solidity
event BridgePool(address indexed pool)
```

Emitted when new Silo (or existing one) becomes a bridge pool (pool with only bridge tokens).

#### Parameters

| Name           | Type    | Description |
| -------------- | ------- | ----------- |
| pool `indexed` | address | undefined   |

### DefaultSiloMaxDepositsLimitUpdate

```solidity
event DefaultSiloMaxDepositsLimitUpdate(uint256 newMaxDeposits)
```

Emitted when default max liquidity limit is changed

#### Parameters

| Name           | Type    | Description |
| -------------- | ------- | ----------- |
| newMaxDeposits | uint256 | undefined   |

### FeeUpdate

```solidity
event FeeUpdate(uint64 newEntryFee, uint64 newProtocolShareFee, uint64 newProtocolLiquidationFee)
```

Emitted when default fee is updated

#### Parameters

| Name                      | Type   | Description |
| ------------------------- | ------ | ----------- |
| newEntryFee               | uint64 | undefined   |
| newProtocolShareFee       | uint64 | undefined   |
| newProtocolLiquidationFee | uint64 | undefined   |

### GlobalPause

```solidity
event GlobalPause(bool globalPause)
```

Emitted when all Silos are paused or unpaused

#### Parameters

| Name        | Type | Description |
| ----------- | ---- | ----------- |
| globalPause | bool | undefined   |

### InterestRateModel

```solidity
event InterestRateModel(contract IInterestRateModel newModel)
```

Emitted when default interest rate model is changed

#### Parameters

| Name     | Type                        | Description |
| -------- | --------------------------- | ----------- |
| newModel | contract IInterestRateModel | undefined   |

### LimitedMaxLiquidityToggled

```solidity
event LimitedMaxLiquidityToggled(bool newLimitedMaxLiquidityState)
```

Emitted when max liquidity toggle is switched

#### Parameters

| Name                        | Type | Description |
| --------------------------- | ---- | ----------- |
| newLimitedMaxLiquidityState | bool | undefined   |

### NewDefaultLiquidationThreshold

```solidity
event NewDefaultLiquidationThreshold(uint64 defaultLiquidationThreshold)
```

#### Parameters

| Name                        | Type   | Description |
| --------------------------- | ------ | ----------- |
| defaultLiquidationThreshold | uint64 | undefined   |

### NewDefaultMaximumLTV

```solidity
event NewDefaultMaximumLTV(uint64 defaultMaximumLTV)
```

#### Parameters

| Name              | Type   | Description |
| ----------------- | ------ | ----------- |
| defaultMaximumLTV | uint64 | undefined   |

### NewSilo

```solidity
event NewSilo(address indexed silo, address indexed asset, uint128 siloVersion)
```

Emitted on new Silo creation

#### Parameters

| Name            | Type    | Description |
| --------------- | ------- | ----------- |
| silo `indexed`  | address | undefined   |
| asset `indexed` | address | undefined   |
| siloVersion     | uint128 | undefined   |

### NotificationReceiverUpdate

```solidity
event NotificationReceiverUpdate(contract INotificationReceiver newIncentiveContract)
```

Emitted on INotificationReceiver address update

#### Parameters

| Name                 | Type                           | Description |
| -------------------- | ------------------------------ | ----------- |
| newIncentiveContract | contract INotificationReceiver | undefined   |

### OwnershipPending

```solidity
event OwnershipPending(address indexed previousOwner, address indexed newOwner)
```

Emitted when ownership transfer is proposed, aka pending owner is set

#### Parameters

| Name                    | Type    | Description |
| ----------------------- | ------- | ----------- |
| previousOwner `indexed` | address | undefined   |
| newOwner `indexed`      | address | undefined   |

### OwnershipTransferred

```solidity
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner)
```

Emitted when ownership is transferred on `transferOwnership` and `acceptOwnership`

#### Parameters

| Name                    | Type    | Description |
| ----------------------- | ------- | ----------- |
| previousOwner `indexed` | address | undefined   |
| newOwner `indexed`      | address | undefined   |

### PriceProvidersRepositoryUpdate

```solidity
event PriceProvidersRepositoryUpdate(contract IPriceProvidersRepository oldProvider, contract IPriceProvidersRepository newProvider)
```

Emitted on price provider repository address update

#### Parameters

| Name        | Type                               | Description |
| ----------- | ---------------------------------- | ----------- |
| oldProvider | contract IPriceProvidersRepository | undefined   |
| newProvider | contract IPriceProvidersRepository | undefined   |

### RegisterSiloVersion

```solidity
event RegisterSiloVersion(address factory, uint128 siloLatestVersion, uint128 siloDefaultVersion)
```

Emitted when new Silo version is registered

#### Parameters

| Name               | Type    | Description |
| ------------------ | ------- | ----------- |
| factory            | address | undefined   |
| siloLatestVersion  | uint128 | undefined   |
| siloDefaultVersion | uint128 | undefined   |

### RouterUpdate

```solidity
event RouterUpdate(address oldRouter, address newRouter)
```

Emitted on router address update

#### Parameters

| Name      | Type    | Description |
| --------- | ------- | ----------- |
| oldRouter | address | undefined   |
| newRouter | address | undefined   |

### SiloDefaultVersion

```solidity
event SiloDefaultVersion(uint128 oldDefaultVersion, uint128 newDefaultVersion)
```

Emitted when default Silo version is updated

#### Parameters

| Name              | Type    | Description |
| ----------------- | ------- | ----------- |
| oldDefaultVersion | uint128 | undefined   |
| newDefaultVersion | uint128 | undefined   |

### SiloMaxDepositsLimitsUpdate

```solidity
event SiloMaxDepositsLimitsUpdate(address indexed silo, address indexed asset, uint256 newMaxDeposits)
```

Emitted when deposit liquidity limit is changed for Silo and asset

#### Parameters

| Name            | Type    | Description |
| --------------- | ------- | ----------- |
| silo `indexed`  | address | undefined   |
| asset `indexed` | address | undefined   |
| newMaxDeposits  | uint256 | undefined   |

### SiloPause

```solidity
event SiloPause(address silo, address asset, bool pauseValue)
```

Emitted when asingle Silo or single asset in a Silo is paused or unpaused

#### Parameters

| Name       | Type    | Description |
| ---------- | ------- | ----------- |
| silo       | address | undefined   |
| asset      | address | undefined   |
| pauseValue | bool    | undefined   |

### TokensFactoryUpdate

```solidity
event TokensFactoryUpdate(address oldTokensFactory, address newTokensFactory)
```

Emitted on token factory address update

#### Parameters

| Name             | Type    | Description |
| ---------------- | ------- | ----------- |
| oldTokensFactory | address | undefined   |
| newTokensFactory | address | undefined   |

### UnregisterSiloVersion

```solidity
event UnregisterSiloVersion(address factory, uint128 siloVersion)
```

Emitted when Silo version is unregistered

#### Parameters

| Name        | Type    | Description |
| ----------- | ------- | ----------- |
| factory     | address | undefined   |
| siloVersion | uint128 | undefined   |

## Errors

### AddressZeroAsInput

```solidity
error AddressZeroAsInput()
```

### AssetIsNotABridge

```solidity
error AssetIsNotABridge()
```

### CanNotRemoveLastBridgeAssets

```solidity
error CanNotRemoveLastBridgeAssets()
```

### InvalidTokenAddress

```solidity
error InvalidTokenAddress()
```

### NoPriceProviderForAsset

```solidity
error NoPriceProviderForAsset()
```

### SiloAlreadyExistsForAsset

```solidity
error SiloAlreadyExistsForAsset()
```

### SiloForBridgeAssetsAlreadyExists

```solidity
error SiloForBridgeAssetsAlreadyExists()
```

### SiloNotAllowedForBridgeAsset

```solidity
error SiloNotAllowedForBridgeAsset()
```

### SiloNotExists

```solidity
error SiloNotExists()
```


# Silo

> ISilo

Silo is the main component of the protocol. It implements lending logic, manages and isolates risk, acts as a vault for assets, and performs liquidations. Each Silo is composed of the unique asset for which it was created (ie. UNI) and bridge assets (ie. ETH and SiloDollar). There may be multiple bridge assets at any given time.

*Main Silo contact that inherits from Base contract. It implements all user/UI facing methods.*

## Methods

### ASSET\_DECIMAL\_POINTS

```solidity
function ASSET_DECIMAL_POINTS() external view returns (uint256)
```

#### Returns

| Name | Type    | Description |
| ---- | ------- | ----------- |
| \_0  | uint256 | undefined   |

### VERSION

```solidity
function VERSION() external view returns (uint256)
```

It tells us which `SiloRepository.siloFactory(version)` created this Silo

#### Returns

| Name | Type    | Description |
| ---- | ------- | ----------- |
| \_0  | uint256 | undefined   |

### accrueInterest

```solidity
function accrueInterest(address _asset) external nonpayable
```

Function to update interests for `_asset` token since the last saved state

#### Parameters

| Name    | Type    | Description                            |
| ------- | ------- | -------------------------------------- |
| \_asset | address | The address of the token to be updated |

### allSiloAssets

```solidity
function allSiloAssets(uint256) external view returns (address)
```

#### Parameters

| Name | Type    | Description |
| ---- | ------- | ----------- |
| \_0  | uint256 | undefined   |

#### Returns

| Name | Type    | Description |
| ---- | ------- | ----------- |
| \_0  | address | undefined   |

### assetInterestData

```solidity
function assetInterestData(address) external view returns (uint256 harvestedProtocolFees, uint256 protocolFees, uint64 interestRateTimestamp, enum IBaseSilo.AssetStatus status)
```

#### Parameters

| Name | Type    | Description |
| ---- | ------- | ----------- |
| \_0  | address | undefined   |

#### Returns

| Name                  | Type                       | Description |
| --------------------- | -------------------------- | ----------- |
| harvestedProtocolFees | uint256                    | undefined   |
| protocolFees          | uint256                    | undefined   |
| interestRateTimestamp | uint64                     | undefined   |
| status                | enum IBaseSilo.AssetStatus | undefined   |

### assetStorage

```solidity
function assetStorage(address _asset) external view returns (struct IBaseSilo.AssetStorage)
```

Get asset storage data

#### Parameters

| Name    | Type    | Description   |
| ------- | ------- | ------------- |
| \_asset | address | asset address |

#### Returns

| Name | Type                   | Description         |
| ---- | ---------------------- | ------------------- |
| \_0  | IBaseSilo.AssetStorage | AssetStorage struct |

### borrow

```solidity
function borrow(address _asset, uint256 _amount) external nonpayable
```

Borrow `_amount` of `_asset` tokens from the Silo to `msg.sender`

#### Parameters

| Name     | Type    | Description                        |
| -------- | ------- | ---------------------------------- |
| \_asset  | address | The address of the token to borrow |
| \_amount | uint256 | The amount of the token to borrow  |

### borrowFor

```solidity
function borrowFor(address _asset, address _borrower, address _receiver, uint256 _amount) external nonpayable
```

Router function to borrow `_amount` of `_asset` tokens from the Silo for the `_receiver`

#### Parameters

| Name       | Type    | Description                             |
| ---------- | ------- | --------------------------------------- |
| \_asset    | address | The address of the token to borrow      |
| \_borrower | address | The address of the debt tokens receiver |
| \_receiver | address | The address of the asset receiver       |
| \_amount   | uint256 | The amount of the token to borrow       |

### borrowPossible

```solidity
function borrowPossible(address _asset, address _borrower) external view returns (bool)
```

Check if borrowing an asset for given account is possible

*Borrowing an asset that has been already deposited (and vice versa) is disallowed*

#### Parameters

| Name       | Type    | Description              |
| ---------- | ------- | ------------------------ |
| \_asset    | address | asset we want to deposit |
| \_borrower | address | borrower address         |

#### Returns

| Name | Type | Description                               |
| ---- | ---- | ----------------------------------------- |
| \_0  | bool | true if asset can be borrowed by borrower |

### deposit

```solidity
function deposit(address _asset, uint256 _amount, bool _collateralOnly) external nonpayable
```

Deposit `_amount` of `_asset` tokens from `msg.sender` to the Silo

#### Parameters

| Name             | Type    | Description                         |
| ---------------- | ------- | ----------------------------------- |
| \_asset          | address | The address of the token to deposit |
| \_amount         | uint256 | The amount of the token to deposit  |
| \_collateralOnly | bool    | True if depositing collateral only  |

### depositFor

```solidity
function depositFor(address _asset, address _depositor, uint256 _amount, bool _collateralOnly) external nonpayable
```

Router function to deposit `_amount` of `_asset` tokens to the Silo for the `_depositor`

#### Parameters

| Name             | Type    | Description                                       |
| ---------------- | ------- | ------------------------------------------------- |
| \_asset          | address | The address of the token to deposit               |
| \_depositor      | address | The address of the recipient of collateral tokens |
| \_amount         | uint256 | The amount of the token to deposit                |
| \_collateralOnly | bool    | True if depositing collateral only                |

### depositPossible

```solidity
function depositPossible(address _asset, address _depositor) external view returns (bool)
```

Check if depositing an asset for given account is possible

*Depositing an asset that has been already borrowed (and vice versa) is disallowed*

#### Parameters

| Name        | Type    | Description              |
| ----------- | ------- | ------------------------ |
| \_asset     | address | asset we want to deposit |
| \_depositor | address | depositor address        |

#### Returns

| Name | Type | Description                                 |
| ---- | ---- | ------------------------------------------- |
| \_0  | bool | true if asset can be deposited by depositor |

### flashLiquidate

```solidity
function flashLiquidate(address[] _users, bytes _flashReceiverData) external nonpayable returns (address[] assets, uint256[][] receivedCollaterals, uint256[][] shareAmountsToRepay)
```

this methods does not requires to have tokens in order to liquidate user

*during liquidation process, msg.sender will be notified once all collateral will be send to him msg.sender needs to be `IFlashLiquidationReceiver`*

#### Parameters

| Name                | Type       | Description                                             |
| ------------------- | ---------- | ------------------------------------------------------- |
| \_users             | address\[] | array of users to liquidate                             |
| \_flashReceiverData | bytes      | this data will be forward to msg.sender on notification |

#### Returns

| Name                | Type          | Description                                                                                    |
| ------------------- | ------------- | ---------------------------------------------------------------------------------------------- |
| assets              | address\[]    | array of all processed assets (collateral + debt, including removed)                           |
| receivedCollaterals | uint256\[]\[] | seizedCollaterals\[userId]\[assetId] => amount amounts of collaterals send to `_flashReceiver` |
| shareAmountsToRepay | uint256\[]\[] | shareAmountsToRepaid\[userId]\[assetId] => amount required amounts of debt to be repaid        |

### getAssets

```solidity
function getAssets() external view returns (address[] assets)
```

Returns all initialized (synced) assets of Silo including current and removed bridge assets

#### Returns

| Name   | Type       | Description                         |
| ------ | ---------- | ----------------------------------- |
| assets | address\[] | array of initialized assets of Silo |

### getAssetsWithState

```solidity
function getAssetsWithState() external view returns (address[] assets, struct IBaseSilo.AssetStorage[] assetsStorage)
```

Returns all initialized (synced) assets of Silo including current and removed bridge assets with corresponding state

#### Returns

| Name          | Type                      | Description                                           |
| ------------- | ------------------------- | ----------------------------------------------------- |
| assets        | address\[]                | array of initialized assets of Silo                   |
| assetsStorage | IBaseSilo.AssetStorage\[] | array of assets state corresponding to `assets` array |

### harvestProtocolFees

```solidity
function harvestProtocolFees(address[] _assets) external nonpayable
```

*harvest protocol fees from an array of assets*

#### Parameters

| Name     | Type       | Description                                  |
| -------- | ---------- | -------------------------------------------- |
| \_assets | address\[] | array of assets we want to harvest fees from |

### initAssetsTokens

```solidity
function initAssetsTokens() external nonpayable
```

*this is exposed only for test purposes, but it is safe to leave it like that*

### interestData

```solidity
function interestData(address _asset) external view returns (struct IBaseSilo.AssetInterestData)
```

Get asset interest data

#### Parameters

| Name    | Type    | Description   |
| ------- | ------- | ------------- |
| \_asset | address | asset address |

#### Returns

| Name | Type                        | Description              |
| ---- | --------------------------- | ------------------------ |
| \_0  | IBaseSilo.AssetInterestData | AssetInterestData struct |

### isSolvent

```solidity
function isSolvent(address _user) external view returns (bool)
```

Calculates solvency of an account

#### Parameters

| Name   | Type    | Description                                     |
| ------ | ------- | ----------------------------------------------- |
| \_user | address | wallet address for which solvency is calculated |

#### Returns

| Name | Type | Description                      |
| ---- | ---- | -------------------------------- |
| \_0  | bool | true if solvent, false otherwise |

### repay

```solidity
function repay(address _asset, uint256 _amount) external nonpayable
```

Repay `_amount` of `_asset` tokens from `msg.sender` to the Silo

#### Parameters

| Name     | Type    | Description                                  |
| -------- | ------- | -------------------------------------------- |
| \_asset  | address | The address of the token to repay            |
| \_amount | uint256 | amount of asset to repay, includes interests |

### repayFor

```solidity
function repayFor(address _asset, address _borrower, uint256 _amount) external nonpayable
```

Allows to repay in behalf of borrower to execute liquidation

#### Parameters

| Name       | Type    | Description                                        |
| ---------- | ------- | -------------------------------------------------- |
| \_asset    | address | The address of the token to repay                  |
| \_borrower | address | The address of the user to have debt tokens burned |
| \_amount   | uint256 | amount of asset to repay, includes interests       |

### siloAsset

```solidity
function siloAsset() external view returns (address)
```

#### Returns

| Name | Type    | Description |
| ---- | ------- | ----------- |
| \_0  | address | undefined   |

### siloRepository

```solidity
function siloRepository() external view returns (contract ISiloRepository)
```

Get Silo Repository contract address

#### Returns

| Name | Type                     | Description |
| ---- | ------------------------ | ----------- |
| \_0  | contract ISiloRepository | undefined   |

### state

```solidity
function state(address) external view returns (contract IShareToken collateralToken, contract IShareToken collateralOnlyToken, contract IShareToken debtToken, uint256 totalDeposits, uint256 collateralOnlyDeposits, uint256 totalBorrowAmount)
```

#### Parameters

| Name | Type    | Description |
| ---- | ------- | ----------- |
| \_0  | address | undefined   |

#### Returns

| Name                   | Type                 | Description |
| ---------------------- | -------------------- | ----------- |
| collateralToken        | contract IShareToken | undefined   |
| collateralOnlyToken    | contract IShareToken | undefined   |
| debtToken              | contract IShareToken | undefined   |
| totalDeposits          | uint256              | undefined   |
| collateralOnlyDeposits | uint256              | undefined   |
| totalBorrowAmount      | uint256              | undefined   |

### syncBridgeAssets

```solidity
function syncBridgeAssets() external nonpayable
```

Synchronize current bridge assets with Silo

*This function needs to be called on Silo deployment to setup all assets for Silo. It needs to be called every time a bridged asset is added or removed. When bridge asset is removed, depositing and borrowing should be disabled during asset sync.*

### utilizationData

```solidity
function utilizationData(address _asset) external view returns (struct IBaseSilo.UtilizationData data)
```

*helper method for InterestRateModel calculations*

#### Parameters

| Name    | Type    | Description |
| ------- | ------- | ----------- |
| \_asset | address | undefined   |

#### Returns

| Name | Type                      | Description |
| ---- | ------------------------- | ----------- |
| data | IBaseSilo.UtilizationData | undefined   |

### withdraw

```solidity
function withdraw(address _asset, uint256 _amount, bool _collateralOnly) external nonpayable
```

Withdraw `_amount` of `_asset` tokens from the Silo to `msg.sender`

#### Parameters

| Name             | Type    | Description                                 |
| ---------------- | ------- | ------------------------------------------- |
| \_asset          | address | The address of the token to withdraw        |
| \_amount         | uint256 | The amount of the token to withdraw         |
| \_collateralOnly | bool    | True if withdrawing collateral only deposit |

### withdrawFor

```solidity
function withdrawFor(address _asset, address _depositor, address _receiver, uint256 _amount, bool _collateralOnly) external nonpayable
```

Router function to withdraw `_amount` of `_asset` tokens from the Silo for the `_depositor`

#### Parameters

| Name             | Type    | Description                                         |
| ---------------- | ------- | --------------------------------------------------- |
| \_asset          | address | The address of the token to withdraw                |
| \_depositor      | address | The address of the collateral tokens source account |
| \_receiver       | address | The address of the asset receiver                   |
| \_amount         | uint256 | The amount of the token to withdraw                 |
| \_collateralOnly | bool    | True if withdrawing collateral only deposit         |

## Events

### Borrow

```solidity
event Borrow(address indexed asset, address indexed user, uint256 amount)
```

Emitted on asset borrow

#### Parameters

| Name            | Type    | Description |
| --------------- | ------- | ----------- |
| asset `indexed` | address | undefined   |
| user `indexed`  | address | undefined   |
| amount          | uint256 | undefined   |

### Deposit

```solidity
event Deposit(address indexed asset, address indexed depositor, uint256 amount, bool collateralOnly)
```

Emitted when deposit is made

#### Parameters

| Name                | Type    | Description |
| ------------------- | ------- | ----------- |
| asset `indexed`     | address | undefined   |
| depositor `indexed` | address | undefined   |
| amount              | uint256 | undefined   |
| collateralOnly      | bool    | undefined   |

### Liquidate

```solidity
event Liquidate(address indexed asset, address indexed user, uint256 shareAmountRepaid, uint256 seizedCollateral)
```

Emitted on user liquidation

#### Parameters

| Name              | Type    | Description |
| ----------------- | ------- | ----------- |
| asset `indexed`   | address | undefined   |
| user `indexed`    | address | undefined   |
| shareAmountRepaid | uint256 | undefined   |
| seizedCollateral  | uint256 | undefined   |

### Repay

```solidity
event Repay(address indexed asset, address indexed user, uint256 amount)
```

Emitted on asset repay

#### Parameters

| Name            | Type    | Description |
| --------------- | ------- | ----------- |
| asset `indexed` | address | undefined   |
| user `indexed`  | address | undefined   |
| amount          | uint256 | undefined   |

### Withdraw

```solidity
event Withdraw(address indexed asset, address indexed depositor, address indexed receiver, uint256 amount, bool collateralOnly)
```

Emitted when withdraw is made

#### Parameters

| Name                | Type    | Description |
| ------------------- | ------- | ----------- |
| asset `indexed`     | address | undefined   |
| depositor `indexed` | address | undefined   |
| receiver `indexed`  | address | undefined   |
| amount              | uint256 | undefined   |
| collateralOnly      | bool    | undefined   |

## Errors

### IncorrectDataLength

```solidity
error IncorrectDataLength()
```


# Oracle

### [PriceProvidersRepository](/smart-contracts-overview/oracle/priceprovidersrepository)

### [BalancerV2PriceProvider](/smart-contracts-overview/oracle/balancerv2priceprovider)

### [UniswapV3PriceProvider](/smart-contracts-overview/oracle/uniswapv3priceprovider)


# PriceProvidersRepository

> PriceProvidersRepository

A repository of price providers. It manages price providers as well as maps assets to their price provider. It acts as a entry point for Silo for token prices.

## Methods

### acceptOwnership

```solidity
function acceptOwnership() external nonpayable
```

*Transfers ownership of the contract to a pending owner Can only be called by the pending owner.*

### addPriceProvider

```solidity
function addPriceProvider(contract IPriceProvider _provider) external nonpayable
```

Register new price provider

#### Parameters

| Name       | Type                    | Description |
| ---------- | ----------------------- | ----------- |
| \_provider | contract IPriceProvider | undefined   |

### changeManager

```solidity
function changeManager(address _manager) external nonpayable
```

Change manager address

*Callable by manager or external owner role*

#### Parameters

| Name      | Type    | Description         |
| --------- | ------- | ------------------- |
| \_manager | address | new manager address |

### getPrice

```solidity
function getPrice(address _asset) external view returns (uint256)
```

Returns "Time-Weighted Average Price" for an asset

#### Parameters

| Name    | Type    | Description                                 |
| ------- | ------- | ------------------------------------------- |
| \_asset | address | address of an asset for which to read price |

#### Returns

| Name | Type    | Description                            |
| ---- | ------- | -------------------------------------- |
| \_0  | uint256 | TWAP price of a token with 18 decimals |

### isPriceProvider

```solidity
function isPriceProvider(contract IPriceProvider _provider) external view returns (bool)
```

Returns true if address is a registered price provider

#### Parameters

| Name       | Type                    | Description                             |
| ---------- | ----------------------- | --------------------------------------- |
| \_provider | contract IPriceProvider | address of price provider to be removed |

#### Returns

| Name | Type | Description                                                     |
| ---- | ---- | --------------------------------------------------------------- |
| \_0  | bool | true if address is a registered price provider, otherwise false |

### manager

```solidity
function manager() external view returns (address)
```

Gets manager role address

#### Returns

| Name | Type    | Description          |
| ---- | ------- | -------------------- |
| \_0  | address | manager role address |

### owner

```solidity
function owner() external view returns (address)
```

*Returns the address of the current owner.*

#### Returns

| Name | Type    | Description |
| ---- | ------- | ----------- |
| \_0  | address | undefined   |

### pendingOwner

```solidity
function pendingOwner() external view returns (address)
```

*Returns the address of the pending owner.*

#### Returns

| Name | Type    | Description |
| ---- | ------- | ----------- |
| \_0  | address | undefined   |

### priceProviders

```solidity
function priceProviders(address) external view returns (contract IPriceProvider)
```

Maps asset address to its price provider

*Each asset must have a price provider contract assigned, otherwise it's not supported*

#### Parameters

| Name | Type    | Description |
| ---- | ------- | ----------- |
| \_0  | address | undefined   |

#### Returns

| Name | Type                    | Description |
| ---- | ----------------------- | ----------- |
| \_0  | contract IPriceProvider | undefined   |

### priceProvidersRepositoryPing

```solidity
function priceProvidersRepositoryPing() external pure returns (bool)
```

Sanity check funciton

#### Returns

| Name | Type | Description         |
| ---- | ---- | ------------------- |
| \_0  | bool | returns always TRUE |

### providerList

```solidity
function providerList() external view returns (address[])
```

Gets an array of price providers

#### Returns

| Name | Type       | Description              |
| ---- | ---------- | ------------------------ |
| \_0  | address\[] | array of price providers |

### providersCount

```solidity
function providersCount() external view returns (uint256)
```

Gets number of pice providers registerd

#### Returns

| Name | Type    | Description                        |
| ---- | ------- | ---------------------------------- |
| \_0  | uint256 | number of pice providers registerd |

### providersReadyForAsset

```solidity
function providersReadyForAsset(address _asset) external view returns (bool)
```

Check if prices are available for an asset

#### Parameters

| Name    | Type    | Description            |
| ------- | ------- | ---------------------- |
| \_asset | address | asset address to check |

#### Returns

| Name | Type | Description                                          |
| ---- | ---- | ---------------------------------------------------- |
| \_0  | bool | returns TRUE if price feed is ready, otherwise false |

### quoteToken

```solidity
function quoteToken() external view returns (address)
```

Token in which prices are quoted. It's most likely WETH, however it could vary from deployment to deployment. For example 1 SILO costs X amount of quoteToken.

#### Returns

| Name | Type    | Description |
| ---- | ------- | ----------- |
| \_0  | address | undefined   |

### removePriceProvider

```solidity
function removePriceProvider(contract IPriceProvider _provider) external nonpayable
```

Unregister price provider

#### Parameters

| Name       | Type                    | Description |
| ---------- | ----------------------- | ----------- |
| \_provider | contract IPriceProvider | undefined   |

### renounceOwnership

```solidity
function renounceOwnership() external nonpayable
```

*Leaves the contract without owner. It will not be possible to call `onlyOwner` functions anymore. Can only be called by the current owner. NOTE: Renouncing ownership will leave the contract without an owner, thereby removing any functionality that is only available to the owner.*

### setPriceProviderForAsset

```solidity
function setPriceProviderForAsset(address _asset, contract IPriceProvider _provider) external nonpayable
```

Sets price provider for asset

*Request for asset price is forwarded to the price provider assigned to that asset*

#### Parameters

| Name       | Type                    | Description                                               |
| ---------- | ----------------------- | --------------------------------------------------------- |
| \_asset    | address                 | address of an asset for which price provider will be used |
| \_provider | contract IPriceProvider | undefined                                                 |

### siloRepository

```solidity
function siloRepository() external view returns (address)
```

SiloRepository contract address

#### Returns

| Name | Type    | Description |
| ---- | ------- | ----------- |
| \_0  | address | undefined   |

### transferOwnership

```solidity
function transferOwnership(address newOwner) external nonpayable
```

*Transfers ownership of the contract to a new account (`newOwner`). Can only be called by the current owner.*

#### Parameters

| Name     | Type    | Description |
| -------- | ------- | ----------- |
| newOwner | address | undefined   |

### transferPendingOwnership

```solidity
function transferPendingOwnership(address newPendingOwner) external nonpayable
```

*Transfers pending ownership of the contract to a new account (`newPendingOwner`). Can only be called by the current owner.*

#### Parameters

| Name            | Type    | Description |
| --------------- | ------- | ----------- |
| newPendingOwner | address | undefined   |

## Events

### ManagerChanged

```solidity
event ManagerChanged(address manager)
```

Emitted when manager is changed

#### Parameters

| Name    | Type    | Description |
| ------- | ------- | ----------- |
| manager | address | undefined   |

### NewPriceProvider

```solidity
event NewPriceProvider(contract IPriceProvider newPriceProvider)
```

Emitted when price provider is added

#### Parameters

| Name             | Type                    | Description |
| ---------------- | ----------------------- | ----------- |
| newPriceProvider | contract IPriceProvider | undefined   |

### OwnershipPending

```solidity
event OwnershipPending(address indexed previousOwner, address indexed newOwner)
```

Emitted when ownership transfer is proposed, aka pending owner is set

#### Parameters

| Name                    | Type    | Description |
| ----------------------- | ------- | ----------- |
| previousOwner `indexed` | address | undefined   |
| newOwner `indexed`      | address | undefined   |

### OwnershipTransferred

```solidity
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner)
```

Emitted when ownership is transferred on `transferOwnership` and `acceptOwnership`

#### Parameters

| Name                    | Type    | Description |
| ----------------------- | ------- | ----------- |
| previousOwner `indexed` | address | undefined   |
| newOwner `indexed`      | address | undefined   |

### PriceProviderForAsset

```solidity
event PriceProviderForAsset(address indexed asset, contract IPriceProvider priceProvider)
```

Emitted when asset is assigned to price provider

#### Parameters

| Name            | Type                    | Description |
| --------------- | ----------------------- | ----------- |
| asset `indexed` | address                 | undefined   |
| priceProvider   | contract IPriceProvider | undefined   |

### PriceProviderRemoved

```solidity
event PriceProviderRemoved(contract IPriceProvider priceProvider)
```

Emitted when price provider is removed

#### Parameters

| Name          | Type                    | Description |
| ------------- | ----------------------- | ----------- |
| priceProvider | contract IPriceProvider | undefined   |


# BalancerV2PriceProvider

> BalancerV2PriceProvider

Price provider contract that reads prices from BalancerV2

## Methods

### acceptOwnership

```solidity
function acceptOwnership() external nonpayable
```

*Transfers ownership of the contract to a pending owner Can only be called by the pending owner.*

### assetSupported

```solidity
function assetSupported(address _asset) external view returns (bool)
```

*Informs if PriceProvider is setup for asset. It does not means PriceProvider can provide price right away. Some providers implementations need time to "build" buffor for TWAP price, so price may not be available yet but this method will return true.*

#### Parameters

| Name    | Type    | Description       |
| ------- | ------- | ----------------- |
| \_asset | address | asset in question |

#### Returns

| Name | Type | Description                                   |
| ---- | ---- | --------------------------------------------- |
| \_0  | bool | TRUE if asset has been setup, otherwise false |

### assetsPools

```solidity
function assetsPools(address) external view returns (bytes32 poolId, address priceOracle, bool token0isAsset)
```

Maps asset address to BalancerPool struct

#### Parameters

| Name | Type    | Description |
| ---- | ------- | ----------- |
| \_0  | address | undefined   |

#### Returns

| Name          | Type    | Description |
| ------------- | ------- | ----------- |
| poolId        | bytes32 | undefined   |
| priceOracle   | address | undefined   |
| token0isAsset | bool    | undefined   |

### changePeriodForAvgPrice

```solidity
function changePeriodForAvgPrice(uint32 _period) external nonpayable
```

Change period for average price

#### Parameters

| Name     | Type   | Description                                             |
| -------- | ------ | ------------------------------------------------------- |
| \_period | uint32 | period in seconds for TWAP price, ie. 1800 means 30 min |

### changeSecondsAgo

```solidity
function changeSecondsAgo(uint32 _ago) external nonpayable
```

Change number of seconds in the past where calcualtions starts for average price

#### Parameters

| Name  | Type   | Description                                             |
| ----- | ------ | ------------------------------------------------------- |
| \_ago | uint32 | new seconds ago value in seconds, ie. 1800 means 30 min |

### changeSettings

```solidity
function changeSettings(uint32 _period, uint32 _ago) external nonpayable
```

Change period for average price and number of seconds in the past where calcualtions starts for average price

#### Parameters

| Name     | Type   | Description                                             |
| -------- | ------ | ------------------------------------------------------- |
| \_period | uint32 | period in seconds for TWAP price, ie. 1800 means 30 min |
| \_ago    | uint32 | new seconds ago value in seconds, ie. 1800 means 30 min |

### getPoolQuoteLiquidity

```solidity
function getPoolQuoteLiquidity(bytes32 _poolId) external view returns (uint256)
```

Gets amount of quote token deposited in the pool

#### Parameters

| Name     | Type    | Description                                                           |
| -------- | ------- | --------------------------------------------------------------------- |
| \_poolId | bytes32 | must be valid pool for asset, balancer will throw BAL#500 if it's not |

#### Returns

| Name | Type    | Description                       |
| ---- | ------- | --------------------------------- |
| \_0  | uint256 | amount of quote token in the pool |

### getPrice

```solidity
function getPrice(address _asset) external view returns (uint256 price)
```

Returns price for a given asset

*Balancer docs: | Some pools (WeightedPool2Tokens and MetaStable Pools) have optional Oracle functionality. | This means that they can be used as sources of on-chain price data. | Note from balancer docs: that you can only call getWeightedTimeAverage after the buffer is full, | or it will revert with ORACLE\_NOT\_INITIALIZED. If you call getSample(1023) and it returns 0's, | that means the buffer's not full yet. We are using Resilient way (recommended by balancer for lending protocols), Less up-to-date but more resilient to manipulation*

#### Parameters

| Name    | Type    | Description   |
| ------- | ------- | ------------- |
| \_asset | address | asset address |

#### Returns

| Name  | Type    | Description             |
| ----- | ------- | ----------------------- |
| price | uint256 | of asset in 18 decimals |

### owner

```solidity
function owner() external view returns (address)
```

*Returns the address of the current owner.*

#### Returns

| Name | Type    | Description |
| ---- | ------- | ----------- |
| \_0  | address | undefined   |

### pendingOwner

```solidity
function pendingOwner() external view returns (address)
```

*Returns the address of the pending owner.*

#### Returns

| Name | Type    | Description |
| ---- | ------- | ----------- |
| \_0  | address | undefined   |

### periodForAvgPrice

```solidity
function periodForAvgPrice() external view returns (uint256)
```

Information for a Time Weighted Average query.

*Each query computes the average over a window of duration `secs` seconds that ended `ago` seconds ago. For example, the average over the past 30 minutes is computed by settings secs to 1800 and ago to 0. If secs is 1800 and ago is 1800 as well, the average between 60 and 30 minutes ago is computed instead.*

#### Returns

| Name | Type    | Description |
| ---- | ------- | ----------- |
| \_0  | uint256 | undefined   |

### priceBufferReady

```solidity
function priceBufferReady(address _asset) external view returns (bool)
```

Checks if price buffer is ready for a BalancerV2 pool assigned to an asset

#### Parameters

| Name    | Type    | Description   |
| ------- | ------- | ------------- |
| \_asset | address | asset address |

#### Returns

| Name | Type | Description                           |
| ---- | ---- | ------------------------------------- |
| \_0  | bool | true if buffer ready, otherwise false |

### priceProviderPing

```solidity
function priceProviderPing() external pure returns (bool)
```

Helper method that allows easily detects, if contract is PriceProvider

*this can save us from simple human errors, in case we use invalid address but this should NOT be treated as security check*

#### Returns

| Name | Type | Description |
| ---- | ---- | ----------- |
| \_0  | bool | always true |

### priceProvidersRepository

```solidity
function priceProvidersRepository() external view returns (contract IPriceProvidersRepository)
```

PriceProvidersRepository address

#### Returns

| Name | Type                               | Description |
| ---- | ---------------------------------- | ----------- |
| \_0  | contract IPriceProvidersRepository | undefined   |

### quoteToken

```solidity
function quoteToken() external view returns (address)
```

Token address which prices are quoted in. Must be the same as PriceProvidersRepository.quoteToken

#### Returns

| Name | Type    | Description |
| ---- | ------- | ----------- |
| \_0  | address | undefined   |

### renounceOwnership

```solidity
function renounceOwnership() external nonpayable
```

*Leaves the contract without owner. It will not be possible to call `onlyOwner` functions anymore. Can only be called by the current owner. NOTE: Renouncing ownership will leave the contract without an owner, thereby removing any functionality that is only available to the owner.*

### resolvePoolAddress

```solidity
function resolvePoolAddress(bytes32 _poolId) external pure returns (address)
```

Returns the address of a Pool's contract.

*Due to how Pool IDs are created, this is done with no storage accesses and costs little gas.*

#### Parameters

| Name     | Type    | Description          |
| -------- | ------- | -------------------- |
| \_poolId | bytes32 | valid pool for asset |

#### Returns

| Name | Type    | Description  |
| ---- | ------- | ------------ |
| \_0  | address | pool address |

### secondsAgo

```solidity
function secondsAgo() external view returns (uint256)
```

Information for a Time Weighted Average query

*Each query computes the average over a window of duration `secs` seconds that ended `ago` seconds ago.*

#### Returns

| Name | Type    | Description |
| ---- | ------- | ----------- |
| \_0  | uint256 | undefined   |

### setupAsset

```solidity
function setupAsset(address _asset, bytes32 _poolId) external nonpayable
```

*Setup pool for asset. Use it also for update.*

#### Parameters

| Name     | Type    | Description        |
| -------- | ------- | ------------------ |
| \_asset  | address | asset address      |
| \_poolId | bytes32 | BalancerV2 pool ID |

### transferOwnership

```solidity
function transferOwnership(address newOwner) external nonpayable
```

*Transfers ownership of the contract to a new account (`newOwner`). Can only be called by the current owner.*

#### Parameters

| Name     | Type    | Description |
| -------- | ------- | ----------- |
| newOwner | address | undefined   |

### transferPendingOwnership

```solidity
function transferPendingOwnership(address newPendingOwner) external nonpayable
```

*Transfers pending ownership of the contract to a new account (`newPendingOwner`). Can only be called by the current owner.*

#### Parameters

| Name            | Type    | Description |
| --------------- | ------- | ----------- |
| newPendingOwner | address | undefined   |

### vault

```solidity
function vault() external view returns (contract IVault)
```

*main BalancerV2 contract, something like router for Uniswap but much more*

#### Returns

| Name | Type            | Description |
| ---- | --------------- | ----------- |
| \_0  | contract IVault | undefined   |

### verifyPool

```solidity
function verifyPool(bytes32 _poolId, address _asset) external view returns (contract IERC20[] tokens)
```

Checks if provided `_poolId` is valid pool for `_asset`

*NOTICE: keep in ming anyone can register pool in balancer Vault <https://github.com/balancer-labs/balancer-v2-monorepo> /blob/09c69ed5dc4715a0076c1dc87a81c0b6c2669b5a/pkg/vault/contracts/PoolRegistry.sol#L67 Only some pools (WeightedPool2Tokens and MetaStable Pools) provides oracle functionality. To be 100% sure, if pool has build-in oracle, we need to do call for getLargestSafeQueryWindow() and see if it fails or not.*

#### Parameters

| Name     | Type    | Description                                       |
| -------- | ------- | ------------------------------------------------- |
| \_poolId | bytes32 | balancer poolId                                   |
| \_asset  | address | token address for which we want to check the pool |

#### Returns

| Name   | Type               | Description                                                          |
| ------ | ------------------ | -------------------------------------------------------------------- |
| tokens | contract IERC20\[] | IERC20\[] pool tokens in original order, throws when pool is invalid |

## Events

### NewPeriod

```solidity
event NewPeriod(uint32 period)
```

Emitted when TWAP period changes

#### Parameters

| Name   | Type   | Description                                  |
| ------ | ------ | -------------------------------------------- |
| period | uint32 | new period in seconds, ie. 1800 means 30 min |

### NewSecondsAgo

```solidity
event NewSecondsAgo(uint32 ago)
```

Emitted when seconds ago changes

#### Parameters

| Name | Type   | Description                                             |
| ---- | ------ | ------------------------------------------------------- |
| ago  | uint32 | new seconds ago value in seconds, ie. 1800 means 30 min |

### OwnershipPending

```solidity
event OwnershipPending(address indexed previousOwner, address indexed newOwner)
```

#### Parameters

| Name                    | Type    | Description |
| ----------------------- | ------- | ----------- |
| previousOwner `indexed` | address | undefined   |
| newOwner `indexed`      | address | undefined   |

### OwnershipTransferred

```solidity
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner)
```

#### Parameters

| Name                    | Type    | Description |
| ----------------------- | ------- | ----------- |
| previousOwner `indexed` | address | undefined   |
| newOwner `indexed`      | address | undefined   |

### PoolForAsset

```solidity
event PoolForAsset(address asset, bytes32 poolId)
```

Emitted when BalancerV2 pool is set for asset

#### Parameters

| Name   | Type    | Description        |
| ------ | ------- | ------------------ |
| asset  | address | asset address      |
| poolId | bytes32 | BalancerV2 pool ID |


# UniswapV3PriceProvider

> UniswapV3PriceProvider

Price provider contract that reads prices from UniswapV3

## Methods

### acceptOwnership

```solidity
function acceptOwnership() external nonpayable
```

*Transfers ownership of the contract to a pending owner Can only be called by the pending owner.*

### adjustOracleCardinality

```solidity
function adjustOracleCardinality(address _asset) external nonpayable
```

Adjust UniV3 pool cardinality to Silo's requirements

*This could be used manually to setup pool, so it will be ready to use in the future. There is only one case, when it could be needed: if we have more than one pool for `_asset` and you want to use UniswapV3 but the pool does not have enough observations (liquidity == 1). You can run this method manually and it will set valid number of observations, so the pool can be used once price data is ready.*

#### Parameters

| Name    | Type    | Description                                                           |
| ------- | ------- | --------------------------------------------------------------------- |
| \_asset | address | asset used to lookup the pool address to increase the cardinality for |

### assetSupported

```solidity
function assetSupported(address _asset) external view returns (bool supported)
```

*Informs if PriceProvider is setup for asset. It does not means PriceProvider can provide price right away. Some providers implementations need time to "build" buffor for TWAP price, so price may not be available yet but this method will return true.*

#### Parameters

| Name    | Type    | Description       |
| ------- | ------- | ----------------- |
| \_asset | address | asset in question |

#### Returns

| Name      | Type | Description                                   |
| --------- | ---- | --------------------------------------------- |
| supported | bool | TRUE if asset has been setup, otherwise false |

### changeBlockTime

```solidity
function changeBlockTime(uint8 _blockTime) external nonpayable
```

Change block time which is used to adjust oracle cardinality fot providing TWAP prices

#### Parameters

| Name        | Type  | Description                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    |
| ----------- | ----- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| \_blockTime | uint8 | it is better to set it bit lower than higher that avg block time eg. if ETH block time is 13\~13.5s, you can set it to 11-12s based on `priceCalculationData.periodForAvgPrice` and `priceCalculationData.blockTime` price provider calculates number of blocks for (cardinality) requires for TWAP price. Unfortunately block time can change and this can lead to issues with getting price. Edge case will be when we set `_blockTime` to 1, then we have 100% guarantee, that no matter how real block time changes, we always can get price. Downside will be cost of initialization. That's why it is better to set a bit lower and adjust (decrease) in case of issues. |

### changePeriodForAvgPrice

```solidity
function changePeriodForAvgPrice(uint32 _period) external nonpayable
```

Change period for which to calcualted TWAP prices

*WARNING: There is a possibility that when we change this period, UniV3 pool that is already initialized and set as oracle for asset, can throw. This can happen when it will not be able calculate TWAP for new period and it can potentially lock the Silo until we have necessary observations. If UniV3 is NOT only available oracle for asset, we can change the oracle and Silo will be unlocked.*

#### Parameters

| Name     | Type   | Description                                  |
| -------- | ------ | -------------------------------------------- |
| \_period | uint32 | new period in seconds, ie. 1800 means 30 min |

### getPrice

```solidity
function getPrice(address _asset) external view returns (uint256 price)
```

Returns "Time-Weighted Average Price" for an asset. Calculates TWAP price for quote/asset. It unifies all tokens decimal to 18, examples: - if asses == quote it returns 1e18 - if asset is USDC and quote is ETH and ETH costs \~$3300 then it returns \~0.0003e18 WETH per 1 USDC

*UniV3 saves price only on: mint, burn and swap. Mint and burn will write observation only when "current tick is inside the passed range" of ticks. I think that means, that if we minting/burning outside ticks range (so outside current price) it will not modify observation. So we left with swap. Swap will write observation under this condition: // update tick and write an oracle entry if the tick change if (state.tick != slot0Start.tick) { that means, it is possible that price will be up to date (in a range of same tick) but observation timestamp will be old. Every pool by default comes with just one slot for observation (cardinality == 1). We can increase number of slots so TWAP price will be "better". When we increase, we have to wait until new tx will write new observation. Based on all above, we can tell how old is observation, but this does not mean the price is wrong. UniV3 recommends to use `observe` and `OracleLibrary.consult` uses it. `observe` reverts if `secondsAgos` > oldest observation, means, if there is any price observation in selected time frame, it will revert. Otherwise it will return either exact TWAP price or by interpolation. Conclusion: we can choose how many observation pool will be storing, but we need to remember, not all of them might be used to provide our price. Final question is: how many observations we need? How UniV3 calculates TWAP we ask for TWAP on time range ago:now using `OracleLibrary.consult`, it is all about find the right tick - we call `IUniswapV3Pool(pool).observe(secondAgos)` that returns two accumulator values (for ago and now) - each observation is resolved by `observeSingle` - for now we just using latest observation, and if it does not match timestamp, we interpolate (!) and this is how we got the tickCumulative, so in extreme situation, if last observation was made day ago, UniV3 will interpolate to reflect tickCumulative at current time - for ago we search for observation using `getSurroundingObservations` that give us before and after observation, base on which we calculate "avg" and we have target tickCumulative - getSurroundingObservations: it's job is to find 2 observations based on which we calculate tickCumulative here is where all calculations can revert, if ago < oldest observation, otherwise it will be calculated either by interpolation or we will have exact match - now with both \_tickCumulative\_s we calculating TWAP recommended observations are = 30 min / blockTime*

#### Parameters

| Name    | Type    | Description                                 |
| ------- | ------- | ------------------------------------------- |
| \_asset | address | address of an asset for which to read price |

#### Returns

| Name  | Type    | Description                                                                   |
| ----- | ------- | ----------------------------------------------------------------------------- |
| price | uint256 | of asses with 18 decimals, throws when pool is not ready yet to provide price |

### hasEnoughObservations

```solidity
function hasEnoughObservations(address _pool) external view returns (bool, uint32 oldestObservationTimestamp)
```

Check if UniV3 pool has enough cardinality to meet Silo's requirements

#### Parameters

| Name   | Type    | Description        |
| ------ | ------- | ------------------ |
| \_pool | address | UniV3 pool address |

#### Returns

| Name                       | Type   | Description                         |
| -------------------------- | ------ | ----------------------------------- |
| \_0                        | bool   | TURE if has enough observations     |
| oldestObservationTimestamp | uint32 | timestamp of the oldest observation |

### owner

```solidity
function owner() external view returns (address)
```

*Returns the address of the current owner.*

#### Returns

| Name | Type    | Description |
| ---- | ------- | ----------- |
| \_0  | address | undefined   |

### pendingOwner

```solidity
function pendingOwner() external view returns (address)
```

*Returns the address of the pending owner.*

#### Returns

| Name | Type    | Description |
| ---- | ------- | ----------- |
| \_0  | address | undefined   |

### pools

```solidity
function pools(address) external view returns (contract IUniswapV3Pool)
```

Maps asset address to UniV3 pool

#### Parameters

| Name | Type    | Description |
| ---- | ------- | ----------- |
| \_0  | address | undefined   |

#### Returns

| Name | Type                    | Description |
| ---- | ----------------------- | ----------- |
| \_0  | contract IUniswapV3Pool | undefined   |

### priceCalculationData

```solidity
function priceCalculationData() external view returns (uint32 periodForAvgPrice, uint8 blockTime)
```

*priceCalculationData: - periodForAvgPrice: Number of seconds for which time-weighted average should be calculated, ie. 1800 is 30 min - blockTime: Estimated blockchain block time*

#### Returns

| Name              | Type   | Description |
| ----------------- | ------ | ----------- |
| periodForAvgPrice | uint32 | undefined   |
| blockTime         | uint8  | undefined   |

### priceProviderPing

```solidity
function priceProviderPing() external pure returns (bool)
```

Helper method that allows easily detects, if contract is PriceProvider

*this can save us from simple human errors, in case we use invalid address but this should NOT be treated as security check*

#### Returns

| Name | Type | Description |
| ---- | ---- | ----------- |
| \_0  | bool | always true |

### priceProvidersRepository

```solidity
function priceProvidersRepository() external view returns (contract IPriceProvidersRepository)
```

PriceProvidersRepository address

#### Returns

| Name | Type                               | Description |
| ---- | ---------------------------------- | ----------- |
| \_0  | contract IPriceProvidersRepository | undefined   |

### quoteToken

```solidity
function quoteToken() external view returns (address)
```

Token address which prices are quoted in. Must be the same as PriceProvidersRepository.quoteToken

#### Returns

| Name | Type    | Description |
| ---- | ------- | ----------- |
| \_0  | address | undefined   |

### renounceOwnership

```solidity
function renounceOwnership() external nonpayable
```

*Leaves the contract without owner. It will not be possible to call `onlyOwner` functions anymore. Can only be called by the current owner. NOTE: Renouncing ownership will leave the contract without an owner, thereby removing any functionality that is only available to the owner.*

### setupAsset

```solidity
function setupAsset(address _asset, contract IUniswapV3Pool _pool) external nonpayable
```

*Setup pool for asset. Use it also for update.*

#### Parameters

| Name    | Type                    | Description        |
| ------- | ----------------------- | ------------------ |
| \_asset | address                 | asset address      |
| \_pool  | contract IUniswapV3Pool | UniV3 pool address |

### transferOwnership

```solidity
function transferOwnership(address newOwner) external nonpayable
```

*Transfers ownership of the contract to a new account (`newOwner`). Can only be called by the current owner.*

#### Parameters

| Name     | Type    | Description |
| -------- | ------- | ----------- |
| newOwner | address | undefined   |

### transferPendingOwnership

```solidity
function transferPendingOwnership(address newPendingOwner) external nonpayable
```

*Transfers pending ownership of the contract to a new account (`newPendingOwner`). Can only be called by the current owner.*

#### Parameters

| Name            | Type    | Description |
| --------------- | ------- | ----------- |
| newPendingOwner | address | undefined   |

### uniswapV3Factory

```solidity
function uniswapV3Factory() external view returns (contract IUniswapV3Factory)
```

*UniswapV3 factory contract*

#### Returns

| Name | Type                       | Description |
| ---- | -------------------------- | ----------- |
| \_0  | contract IUniswapV3Factory | undefined   |

### verifyPool

```solidity
function verifyPool(address _asset, contract IUniswapV3Pool _pool) external view returns (bool)
```

*It verifies if provider pool for asset (and quote token) is valid. Throws when there is no pool or pool is empty (zero liquidity).*

#### Parameters

| Name    | Type                    | Description                                       |
| ------- | ----------------------- | ------------------------------------------------- |
| \_asset | address                 | asset for which prices are going to be calcualted |
| \_pool  | contract IUniswapV3Pool | UniV3 pool address                                |

#### Returns

| Name | Type | Description                                       |
| ---- | ---- | ------------------------------------------------- |
| \_0  | bool | true if verification successful, otherwise throws |

## Events

### NewBlockTime

```solidity
event NewBlockTime(uint8 blockTime)
```

Emitted when blockTime changes

#### Parameters

| Name      | Type  | Description           |
| --------- | ----- | --------------------- |
| blockTime | uint8 | block time in seconds |

### NewPeriod

```solidity
event NewPeriod(uint32 period)
```

Emitted when TWAP period changes

#### Parameters

| Name   | Type   | Description                                  |
| ------ | ------ | -------------------------------------------- |
| period | uint32 | new period in seconds, ie. 1800 means 30 min |

### OwnershipPending

```solidity
event OwnershipPending(address indexed previousOwner, address indexed newOwner)
```

#### Parameters

| Name                    | Type    | Description |
| ----------------------- | ------- | ----------- |
| previousOwner `indexed` | address | undefined   |
| newOwner `indexed`      | address | undefined   |

### OwnershipTransferred

```solidity
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner)
```

#### Parameters

| Name                    | Type    | Description |
| ----------------------- | ------- | ----------- |
| previousOwner `indexed` | address | undefined   |
| newOwner `indexed`      | address | undefined   |

### PoolForAsset

```solidity
event PoolForAsset(address indexed asset, contract IUniswapV3Pool indexed pool)
```

Emitted when UniV3 pool is set for asset

#### Parameters

| Name            | Type                    | Description        |
| --------------- | ----------------------- | ------------------ |
| asset `indexed` | address                 | asset address      |
| pool `indexed`  | contract IUniswapV3Pool | UniV3 pool address |


# Ownership Tokens

### [ShareCollateralToken](/smart-contracts-overview/ownership-tokens/sharecollateraltoken)

### [ShareDebtToken](/smart-contracts-overview/ownership-tokens/sharedebttoken)


# ShareCollateralToken

> ShareCollateralToken

ERC20 compatible token represennting collateral position in Silo

## Methods

### allowance

```solidity
function allowance(address owner, address spender) external view returns (uint256)
```

*See {IERC20-allowance}.*

#### Parameters

| Name    | Type    | Description |
| ------- | ------- | ----------- |
| owner   | address | undefined   |
| spender | address | undefined   |

#### Returns

| Name | Type    | Description |
| ---- | ------- | ----------- |
| \_0  | uint256 | undefined   |

### approve

```solidity
function approve(address spender, uint256 amount) external nonpayable returns (bool)
```

*See {IERC20-approve}. Requirements: - `spender` cannot be the zero address.*

#### Parameters

| Name    | Type    | Description |
| ------- | ------- | ----------- |
| spender | address | undefined   |
| amount  | uint256 | undefined   |

#### Returns

| Name | Type | Description |
| ---- | ---- | ----------- |
| \_0  | bool | undefined   |

### asset

```solidity
function asset() external view returns (address)
```

asset for which this tokens was deployed

#### Returns

| Name | Type    | Description |
| ---- | ------- | ----------- |
| \_0  | address | undefined   |

### balanceOf

```solidity
function balanceOf(address account) external view returns (uint256)
```

*See {IERC20-balanceOf}.*

#### Parameters

| Name    | Type    | Description |
| ------- | ------- | ----------- |
| account | address | undefined   |

#### Returns

| Name | Type    | Description |
| ---- | ------- | ----------- |
| \_0  | uint256 | undefined   |

### burn

```solidity
function burn(address _account, uint256 _amount) external nonpayable
```

Burn method for Silo to close debt positon

#### Parameters

| Name      | Type    | Description                    |
| --------- | ------- | ------------------------------ |
| \_account | address | wallet for which to burn token |
| \_amount  | uint256 | amount of token to be burned   |

### decimals

```solidity
function decimals() external view returns (uint8)
```

*Returns the number of decimals used to get its user representation. For example, if `decimals` equals `2`, a balance of `505` tokens should be displayed to a user as `5.05` (`505 / 10 ** 2`). Tokens usually opt for a value of 18, imitating the relationship between Ether and Wei. This is the value {ERC20} uses, unless this function is overridden; NOTE: This information is only used for display purposes: it in no way affects any of the arithmetic of the contract, including {IERC20-balanceOf} and {IERC20-transfer}.*

#### Returns

| Name | Type  | Description |
| ---- | ----- | ----------- |
| \_0  | uint8 | undefined   |

### decreaseAllowance

```solidity
function decreaseAllowance(address spender, uint256 subtractedValue) external nonpayable returns (bool)
```

*Atomically decreases the allowance granted to `spender` by the caller. This is an alternative to {approve} that can be used as a mitigation for problems described in {IERC20-approve}. Emits an {Approval} event indicating the updated allowance. Requirements: - `spender` cannot be the zero address. - `spender` must have allowance for the caller of at least `subtractedValue`.*

#### Parameters

| Name            | Type    | Description |
| --------------- | ------- | ----------- |
| spender         | address | undefined   |
| subtractedValue | uint256 | undefined   |

#### Returns

| Name | Type | Description |
| ---- | ---- | ----------- |
| \_0  | bool | undefined   |

### increaseAllowance

```solidity
function increaseAllowance(address spender, uint256 addedValue) external nonpayable returns (bool)
```

*Atomically increases the allowance granted to `spender` by the caller. This is an alternative to {approve} that can be used as a mitigation for problems described in {IERC20-approve}. Emits an {Approval} event indicating the updated allowance. Requirements: - `spender` cannot be the zero address.*

#### Parameters

| Name       | Type    | Description |
| ---------- | ------- | ----------- |
| spender    | address | undefined   |
| addedValue | uint256 | undefined   |

#### Returns

| Name | Type | Description |
| ---- | ---- | ----------- |
| \_0  | bool | undefined   |

### mint

```solidity
function mint(address _account, uint256 _amount) external nonpayable
```

Mint method for Silo to create debt positon

#### Parameters

| Name      | Type    | Description                    |
| --------- | ------- | ------------------------------ |
| \_account | address | wallet for which to mint token |
| \_amount  | uint256 | amount of token to be minted   |

### name

```solidity
function name() external view returns (string)
```

*Returns the name of the token.*

#### Returns

| Name | Type   | Description |
| ---- | ------ | ----------- |
| \_0  | string | undefined   |

### silo

```solidity
function silo() external view returns (contract ISilo)
```

Silo address for which tokens was deployed

#### Returns

| Name | Type           | Description |
| ---- | -------------- | ----------- |
| \_0  | contract ISilo | undefined   |

### symbol

```solidity
function symbol() external view returns (string)
```

Returns token symbol

#### Returns

| Name | Type   | Description  |
| ---- | ------ | ------------ |
| \_0  | string | token symbol |

### totalSupply

```solidity
function totalSupply() external view returns (uint256)
```

*See {IERC20-totalSupply}.*

#### Returns

| Name | Type    | Description |
| ---- | ------- | ----------- |
| \_0  | uint256 | undefined   |

### transfer

```solidity
function transfer(address recipient, uint256 amount) external nonpayable returns (bool)
```

*See {IERC20-transfer}. Requirements: - `recipient` cannot be the zero address. - the caller must have a balance of at least `amount`.*

#### Parameters

| Name      | Type    | Description |
| --------- | ------- | ----------- |
| recipient | address | undefined   |
| amount    | uint256 | undefined   |

#### Returns

| Name | Type | Description |
| ---- | ---- | ----------- |
| \_0  | bool | undefined   |

### transferFrom

```solidity
function transferFrom(address sender, address recipient, uint256 amount) external nonpayable returns (bool)
```

*See {IERC20-transferFrom}. Emits an {Approval} event indicating the updated allowance. This is not required by the EIP. See the note at the beginning of {ERC20}. Requirements: - `sender` and `recipient` cannot be the zero address. - `sender` must have a balance of at least `amount`. - the caller must have allowance for `sender`'s tokens of at least `amount`.*

#### Parameters

| Name      | Type    | Description |
| --------- | ------- | ----------- |
| sender    | address | undefined   |
| recipient | address | undefined   |
| amount    | uint256 | undefined   |

#### Returns

| Name | Type | Description |
| ---- | ---- | ----------- |
| \_0  | bool | undefined   |

## Events

### Approval

```solidity
event Approval(address indexed owner, address indexed spender, uint256 value)
```

#### Parameters

| Name              | Type    | Description |
| ----------------- | ------- | ----------- |
| owner `indexed`   | address | undefined   |
| spender `indexed` | address | undefined   |
| value             | uint256 | undefined   |

### NotificationSent

```solidity
event NotificationSent(contract INotificationReceiver notificationReceiver, bool success)
```

Emitted every time receiver is notified about token transfer

#### Parameters

| Name                 | Type                           | Description |
| -------------------- | ------------------------------ | ----------- |
| notificationReceiver | contract INotificationReceiver | undefined   |
| success              | bool                           | undefined   |

### Transfer

```solidity
event Transfer(address indexed from, address indexed to, uint256 value)
```

#### Parameters

| Name           | Type    | Description |
| -------------- | ------- | ----------- |
| from `indexed` | address | undefined   |
| to `indexed`   | address | undefined   |
| value          | uint256 | undefined   |


# ShareDebtToken

> ShareDebtToken

ERC20 compatible token represennting debt position in Silo

*It implements reversed approvals (ERC20R) and checks solvency of receiver on transfer. It is assumed that there is no vector attack on taking somone else's debt becasue we don't see economical reason why one would do such thing. For that reason anyone can transfer owner's token to any receiver as long as receiving wallet approves the transfer. In other words, anyone can take someone else's debt without asking.*

## Methods

### allowance

```solidity
function allowance(address owner, address spender) external view returns (uint256)
```

*See {IERC20-allowance}.*

#### Parameters

| Name    | Type    | Description |
| ------- | ------- | ----------- |
| owner   | address | undefined   |
| spender | address | undefined   |

#### Returns

| Name | Type    | Description |
| ---- | ------- | ----------- |
| \_0  | uint256 | undefined   |

### approve

```solidity
function approve(address spender, uint256 amount) external nonpayable returns (bool)
```

*See {IERC20-approve}. Requirements: - `spender` cannot be the zero address.*

#### Parameters

| Name    | Type    | Description |
| ------- | ------- | ----------- |
| spender | address | undefined   |
| amount  | uint256 | undefined   |

#### Returns

| Name | Type | Description |
| ---- | ---- | ----------- |
| \_0  | bool | undefined   |

### asset

```solidity
function asset() external view returns (address)
```

asset for which this tokens was deployed

#### Returns

| Name | Type    | Description |
| ---- | ------- | ----------- |
| \_0  | address | undefined   |

### balanceOf

```solidity
function balanceOf(address account) external view returns (uint256)
```

*See {IERC20-balanceOf}.*

#### Parameters

| Name    | Type    | Description |
| ------- | ------- | ----------- |
| account | address | undefined   |

#### Returns

| Name | Type    | Description |
| ---- | ------- | ----------- |
| \_0  | uint256 | undefined   |

### burn

```solidity
function burn(address _account, uint256 _amount) external nonpayable
```

Burn method for Silo to close debt positon

#### Parameters

| Name      | Type    | Description                    |
| --------- | ------- | ------------------------------ |
| \_account | address | wallet for which to burn token |
| \_amount  | uint256 | amount of token to be burned   |

### decimals

```solidity
function decimals() external view returns (uint8)
```

*Returns the number of decimals used to get its user representation. For example, if `decimals` equals `2`, a balance of `505` tokens should be displayed to a user as `5.05` (`505 / 10 ** 2`). Tokens usually opt for a value of 18, imitating the relationship between Ether and Wei. This is the value {ERC20} uses, unless this function is overridden; NOTE: This information is only used for display purposes: it in no way affects any of the arithmetic of the contract, including {IERC20-balanceOf} and {IERC20-transfer}.*

#### Returns

| Name | Type  | Description |
| ---- | ----- | ----------- |
| \_0  | uint8 | undefined   |

### decreaseAllowance

```solidity
function decreaseAllowance(address spender, uint256 subtractedValue) external nonpayable returns (bool)
```

*Atomically decreases the allowance granted to `spender` by the caller. This is an alternative to {approve} that can be used as a mitigation for problems described in {IERC20-approve}. Emits an {Approval} event indicating the updated allowance. Requirements: - `spender` cannot be the zero address. - `spender` must have allowance for the caller of at least `subtractedValue`.*

#### Parameters

| Name            | Type    | Description |
| --------------- | ------- | ----------- |
| spender         | address | undefined   |
| subtractedValue | uint256 | undefined   |

#### Returns

| Name | Type | Description |
| ---- | ---- | ----------- |
| \_0  | bool | undefined   |

### decreaseReceiveAllowance

```solidity
function decreaseReceiveAllowance(address _owner, uint256 _subtractedValue) external nonpayable returns (bool)
```

*Atomically decreases the receive allowance granted to `owner` by the caller. This is an alternative to {receive approve} that can be used as a mitigation for problems described in {IERC20-approve}. Emits an {ReceiveApproval} event indicating the updated receive allowance.*

#### Parameters

| Name              | Type    | Description                                                        |
| ----------------- | ------- | ------------------------------------------------------------------ |
| \_owner           | address | owner of debt token that is being allowed sending it to the caller |
| \_subtractedValue | uint256 | amount of token to decrease allowance                              |

#### Returns

| Name | Type | Description       |
| ---- | ---- | ----------------- |
| \_0  | bool | true if succeeded |

### increaseAllowance

```solidity
function increaseAllowance(address spender, uint256 addedValue) external nonpayable returns (bool)
```

*Atomically increases the allowance granted to `spender` by the caller. This is an alternative to {approve} that can be used as a mitigation for problems described in {IERC20-approve}. Emits an {Approval} event indicating the updated allowance. Requirements: - `spender` cannot be the zero address.*

#### Parameters

| Name       | Type    | Description |
| ---------- | ------- | ----------- |
| spender    | address | undefined   |
| addedValue | uint256 | undefined   |

#### Returns

| Name | Type | Description |
| ---- | ---- | ----------- |
| \_0  | bool | undefined   |

### increaseReceiveAllowance

```solidity
function increaseReceiveAllowance(address _owner, uint256 _addedValue) external nonpayable returns (bool)
```

*Atomically increases the receive allowance granted to `owner` by the caller. This is an alternative to {receive approve} that can be used as a mitigation for problems described in {IERC20-approve}. Emits an {ReceiveApproval} event indicating the updated receive allowance.*

#### Parameters

| Name         | Type    | Description                                                        |
| ------------ | ------- | ------------------------------------------------------------------ |
| \_owner      | address | owner of debt token that is being allowed sending it to the caller |
| \_addedValue | uint256 | amount of token to increase allowance                              |

#### Returns

| Name | Type | Description       |
| ---- | ---- | ----------------- |
| \_0  | bool | true if succeeded |

### mint

```solidity
function mint(address _account, uint256 _amount) external nonpayable
```

Mint method for Silo to create debt positon

#### Parameters

| Name      | Type    | Description                    |
| --------- | ------- | ------------------------------ |
| \_account | address | wallet for which to mint token |
| \_amount  | uint256 | amount of token to be minted   |

### name

```solidity
function name() external view returns (string)
```

*Returns the name of the token.*

#### Returns

| Name | Type   | Description |
| ---- | ------ | ----------- |
| \_0  | string | undefined   |

### receiveAllowance

```solidity
function receiveAllowance(address _owner, address _receiver) external view returns (uint256)
```

*Returns the remaining number of tokens that `_owner` is allowed to send to `_receiver` through {transferFrom}. This is zero by default.*

#### Parameters

| Name       | Type    | Description                          |
| ---------- | ------- | ------------------------------------ |
| \_owner    | address | owner of debt token                  |
| \_receiver | address | wallet that is receiving debt tokens |

#### Returns

| Name | Type    | Description             |
| ---- | ------- | ----------------------- |
| \_0  | uint256 | current token allowance |

### setReceiveApproval

```solidity
function setReceiveApproval(address owner, uint256 _amount) external nonpayable returns (bool)
```

*Sets `_amount` as the allowance of `spender` over the caller's tokens. Returns a boolean value indicating whether the operation succeeded. IMPORTANT: Beware that changing an allowance with this method brings the risk that someone may use both the old and the new allowance by unfortunate transaction ordering. One possible solution to mitigate this race condition is to first reduce the spender's allowance to 0 and set the desired value afterwards: <https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729> OR use increase/decrease approval method instead. Emits an {ReceiveApproval} event.*

#### Parameters

| Name     | Type    | Description               |
| -------- | ------- | ------------------------- |
| owner    | address | undefined                 |
| \_amount | uint256 | amount of token allowance |

#### Returns

| Name | Type | Description       |
| ---- | ---- | ----------------- |
| \_0  | bool | true if succeeded |

### silo

```solidity
function silo() external view returns (contract ISilo)
```

Silo address for which tokens was deployed

#### Returns

| Name | Type           | Description |
| ---- | -------------- | ----------- |
| \_0  | contract ISilo | undefined   |

### symbol

```solidity
function symbol() external view returns (string)
```

Returns token symbol

#### Returns

| Name | Type   | Description  |
| ---- | ------ | ------------ |
| \_0  | string | token symbol |

### totalSupply

```solidity
function totalSupply() external view returns (uint256)
```

*See {IERC20-totalSupply}.*

#### Returns

| Name | Type    | Description |
| ---- | ------- | ----------- |
| \_0  | uint256 | undefined   |

### transfer

```solidity
function transfer(address recipient, uint256 amount) external nonpayable returns (bool)
```

*See {IERC20-transfer}. Requirements: - `recipient` cannot be the zero address. - the caller must have a balance of at least `amount`.*

#### Parameters

| Name      | Type    | Description |
| --------- | ------- | ----------- |
| recipient | address | undefined   |
| amount    | uint256 | undefined   |

#### Returns

| Name | Type | Description |
| ---- | ---- | ----------- |
| \_0  | bool | undefined   |

### transferFrom

```solidity
function transferFrom(address sender, address recipient, uint256 amount) external nonpayable returns (bool)
```

*See {IERC20-transferFrom}. Emits an {Approval} event indicating the updated allowance. This is not required by the EIP. See the note at the beginning of {ERC20}. Requirements: - `sender` and `recipient` cannot be the zero address. - `sender` must have a balance of at least `amount`. - the caller must have allowance for `sender`'s tokens of at least `amount`.*

#### Parameters

| Name      | Type    | Description |
| --------- | ------- | ----------- |
| sender    | address | undefined   |
| recipient | address | undefined   |
| amount    | uint256 | undefined   |

#### Returns

| Name | Type | Description |
| ---- | ---- | ----------- |
| \_0  | bool | undefined   |

## Events

### Approval

```solidity
event Approval(address indexed owner, address indexed spender, uint256 value)
```

#### Parameters

| Name              | Type    | Description |
| ----------------- | ------- | ----------- |
| owner `indexed`   | address | undefined   |
| spender `indexed` | address | undefined   |
| value             | uint256 | undefined   |

### NotificationSent

```solidity
event NotificationSent(contract INotificationReceiver notificationReceiver, bool success)
```

Emitted every time receiver is notified about token transfer

#### Parameters

| Name                 | Type                           | Description |
| -------------------- | ------------------------------ | ----------- |
| notificationReceiver | contract INotificationReceiver | undefined   |
| success              | bool                           | undefined   |

### ReceiveApproval

```solidity
event ReceiveApproval(address indexed _owner, address indexed _receiver, uint256 _value)
```

#### Parameters

| Name                 | Type    | Description |
| -------------------- | ------- | ----------- |
| \_owner `indexed`    | address | undefined   |
| \_receiver `indexed` | address | undefined   |
| \_value              | uint256 | undefined   |

### Transfer

```solidity
event Transfer(address indexed from, address indexed to, uint256 value)
```

#### Parameters

| Name           | Type    | Description |
| -------------- | ------- | ----------- |
| from `indexed` | address | undefined   |
| to `indexed`   | address | undefined   |
| value          | uint256 | undefined   |


# InterestRateModel

> InterestRateModel

Dynamic interest rate model implementation

*Model stores some Silo specific data. If model is replaced, it needs to set proper config after redeployment for seamless service. Please refer to separte litepaper about model for design details.*

## Methods

### DP

```solidity
function DP() external view returns (int256)
```

*DP is 18 decimal points used for integer calculations*

#### Returns

| Name | Type   | Description |
| ---- | ------ | ----------- |
| \_0  | int256 | undefined   |

### RCOMP\_MAX

```solidity
function RCOMP_MAX() external view returns (uint256)
```

*maximum value of compound interest the model will return*

#### Returns

| Name | Type    | Description |
| ---- | ------- | ----------- |
| \_0  | uint256 | undefined   |

### X\_MAX

```solidity
function X_MAX() external view returns (int256)
```

*maximum value of X for which, RCOMP\_MAX should be returned*

#### Returns

| Name | Type   | Description |
| ---- | ------ | ----------- |
| \_0  | int256 | undefined   |

### acceptOwnership

```solidity
function acceptOwnership() external nonpayable
```

*Transfers ownership of the contract to a pending owner Can only be called by the pending owner.*

### calculateCompoundInterestRate

```solidity
function calculateCompoundInterestRate(IInterestRateModel.Config _c, int256 _u, uint256 _interestRateTimestamp, uint256 _blockTimestamp) external pure returns (uint256 rcomp, int256 ri, int256 Tcrit)
```

*pure function that calculates interest rate based on raw input data*

#### Parameters

| Name                    | Type                      | Description                                    |
| ----------------------- | ------------------------- | ---------------------------------------------- |
| \_c                     | IInterestRateModel.Config | configuration object, InterestRateModel.Config |
| \_u                     | int256                    | asset untilization                             |
| \_interestRateTimestamp | uint256                   | timestamp of last interest rate update         |
| \_blockTimestamp        | uint256                   | current block timestamp                        |

#### Returns

| Name  | Type    | Description                                                  |
| ----- | ------- | ------------------------------------------------------------ |
| rcomp | uint256 | compounded interest rate from last update until now          |
| ri    | int256  | current integral part of the rate                            |
| Tcrit | int256  | time during which the utilization exceeds the critical value |

### calculateCurrentInterestRate

```solidity
function calculateCurrentInterestRate(IInterestRateModel.Config _c, int256 _u, uint256 _interestRateTimestamp, uint256 _blockTimestamp) external pure returns (uint256 rcur)
```

*pure function that calculates current annual interest rate*

#### Parameters

| Name                    | Type                      | Description                                    |
| ----------------------- | ------------------------- | ---------------------------------------------- |
| \_c                     | IInterestRateModel.Config | configuration object, InterestRateModel.Config |
| \_u                     | int256                    | asset untilization                             |
| \_interestRateTimestamp | uint256                   | timestamp of last interest rate update         |
| \_blockTimestamp        | uint256                   | current block timestamp                        |

#### Returns

| Name | Type    | Description                  |
| ---- | ------- | ---------------------------- |
| rcur | uint256 | current annual interest rate |

### config

```solidity
function config(address, address) external view returns (int256 uopt, int256 ucrit, int256 ulow, int256 ki, int256 kcrit, int256 klow, int256 klin, int256 beta, int256 ri, int256 Tcrit)
```

#### Parameters

| Name | Type    | Description |
| ---- | ------- | ----------- |
| \_0  | address | undefined   |
| \_1  | address | undefined   |

#### Returns

| Name  | Type   | Description |
| ----- | ------ | ----------- |
| uopt  | int256 | undefined   |
| ucrit | int256 | undefined   |
| ulow  | int256 | undefined   |
| ki    | int256 | undefined   |
| kcrit | int256 | undefined   |
| klow  | int256 | undefined   |
| klin  | int256 | undefined   |
| beta  | int256 | undefined   |
| ri    | int256 | undefined   |
| Tcrit | int256 | undefined   |

### getCompoundInterestRate

```solidity
function getCompoundInterestRate(address _silo, address _asset, uint256 _blockTimestamp) external view returns (uint256 rcomp)
```

*get compound interest rate*

#### Parameters

| Name             | Type    | Description                                                              |
| ---------------- | ------- | ------------------------------------------------------------------------ |
| \_silo           | address | address of Silo                                                          |
| \_asset          | address | address of an asset in Silo for which interest rate should be calculated |
| \_blockTimestamp | uint256 | current block timestamp                                                  |

#### Returns

| Name  | Type    | Description                                         |
| ----- | ------- | --------------------------------------------------- |
| rcomp | uint256 | compounded interest rate from last update until now |

### getCompoundInterestRateAndUpdate

```solidity
function getCompoundInterestRateAndUpdate(address _asset, uint256 _blockTimestamp) external nonpayable returns (uint256 rcomp)
```

*get compound interest rate and update model storage*

#### Parameters

| Name             | Type    | Description                                                              |
| ---------------- | ------- | ------------------------------------------------------------------------ |
| \_asset          | address | address of an asset in Silo for which interest rate should be calculated |
| \_blockTimestamp | uint256 | current block timestamp                                                  |

#### Returns

| Name  | Type    | Description                                         |
| ----- | ------- | --------------------------------------------------- |
| rcomp | uint256 | compounded interest rate from last update until now |

### getConfig

```solidity
function getConfig(address _silo, address _asset) external view returns (struct IInterestRateModel.Config)
```

*Get config for giver asset in a Silo. If dedicated config is not set, default one will be returned.*

#### Parameters

| Name    | Type    | Description                                  |
| ------- | ------- | -------------------------------------------- |
| \_silo  | address | Silo address for which config should be set  |
| \_asset | address | asset address for which config should be set |

#### Returns

| Name | Type                      | Description                     |
| ---- | ------------------------- | ------------------------------- |
| \_0  | IInterestRateModel.Config | Config sturct for asset in Silo |

### getCurrentInterestRate

```solidity
function getCurrentInterestRate(address _silo, address _asset, uint256 _blockTimestamp) external view returns (uint256 rcur)
```

*get current annual interest rate*

#### Parameters

| Name             | Type    | Description                                                              |
| ---------------- | ------- | ------------------------------------------------------------------------ |
| \_silo           | address | address of Silo                                                          |
| \_asset          | address | address of an asset in Silo for which interest rate should be calculated |
| \_blockTimestamp | uint256 | current block timestamp                                                  |

#### Returns

| Name | Type    | Description                  |
| ---- | ------- | ---------------------------- |
| rcur | uint256 | current annual interest rate |

### interestRateModelPing

```solidity
function interestRateModelPing() external pure returns (bool)
```

*just a helper method to see if address is a InterestRateModel*

#### Returns

| Name | Type | Description |
| ---- | ---- | ----------- |
| \_0  | bool | always true |

### owner

```solidity
function owner() external view returns (address)
```

*Returns the address of the current owner.*

#### Returns

| Name | Type    | Description |
| ---- | ------- | ----------- |
| \_0  | address | undefined   |

### pendingOwner

```solidity
function pendingOwner() external view returns (address)
```

*Returns the address of the pending owner.*

#### Returns

| Name | Type    | Description |
| ---- | ------- | ----------- |
| \_0  | address | undefined   |

### renounceOwnership

```solidity
function renounceOwnership() external nonpayable
```

*Leaves the contract without owner. It will not be possible to call `onlyOwner` functions anymore. Can only be called by the current owner. NOTE: Renouncing ownership will leave the contract without an owner, thereby removing any functionality that is only available to the owner.*

### setConfig

```solidity
function setConfig(address _silo, address _asset, IInterestRateModel.Config _config) external nonpayable
```

*Set dedicated config for giver asset in a Silo. Config is per asset per Silo so different assets in different Silo can have different configs.*

#### Parameters

| Name     | Type                      | Description                                  |
| -------- | ------------------------- | -------------------------------------------- |
| \_silo   | address                   | Silo address for which config should be set  |
| \_asset  | address                   | asset address for which config should be set |
| \_config | IInterestRateModel.Config | undefined                                    |

### transferOwnership

```solidity
function transferOwnership(address newOwner) external nonpayable
```

*Transfers ownership of the contract to a new account (`newOwner`). Can only be called by the current owner.*

#### Parameters

| Name     | Type    | Description |
| -------- | ------- | ----------- |
| newOwner | address | undefined   |

### transferPendingOwnership

```solidity
function transferPendingOwnership(address newPendingOwner) external nonpayable
```

*Transfers pending ownership of the contract to a new account (`newPendingOwner`). Can only be called by the current owner.*

#### Parameters

| Name            | Type    | Description |
| --------------- | ------- | ----------- |
| newPendingOwner | address | undefined   |

## Events

### ConfigUpdate

```solidity
event ConfigUpdate(address indexed silo, address indexed asset, IInterestRateModel.Config config)
```

Emitted on config change

#### Parameters

| Name            | Type                      | Description                                  |
| --------------- | ------------------------- | -------------------------------------------- |
| silo `indexed`  | address                   | Silo address for which config should be set  |
| asset `indexed` | address                   | asset address for which config should be set |
| config          | IInterestRateModel.Config | config sturct for asset in Silo              |

### OwnershipPending

```solidity
event OwnershipPending(address indexed previousOwner, address indexed newOwner)
```

Emitted when ownership transfer is proposed, aka pending owner is set

#### Parameters

| Name                    | Type    | Description |
| ----------------------- | ------- | ----------- |
| previousOwner `indexed` | address | undefined   |
| newOwner `indexed`      | address | undefined   |

### OwnershipTransferred

```solidity
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner)
```

Emitted when ownership is transferred on `transferOwnership` and `acceptOwnership`

#### Parameters

| Name                    | Type    | Description |
| ----------------------- | ------- | ----------- |
| previousOwner `indexed` | address | undefined   |
| newOwner `indexed`      | address | undefined   |


# SiloRouter

> SiloRouter

Silo Router is a utility contract that aims to improve UX. It can batch any number or combination of actions (Deposit, Withdraw, Borrow, Repay) and execute them in a single transaction.

*SiloRouter requires only first action asset to be approved*

## Methods

### execute

```solidity
function execute(SiloRouter.Action[] _actions) external payable
```

Execute actions

*User can bundle any combination and number of actions. It's possible to do multiple deposits, withdraws etc. For that reason router may need to send multiple tokens back to the user.*

#### Parameters

| Name      | Type                 | Description                 |
| --------- | -------------------- | --------------------------- |
| \_actions | SiloRouter.Action\[] | array of actions to execute |

### siloRouterPing

```solidity
function siloRouterPing() external pure returns (bool)
```

#### Returns

| Name | Type | Description |
| ---- | ---- | ----------- |
| \_0  | bool | undefined   |

### wrappedNativeToken

```solidity
function wrappedNativeToken() external view returns (contract IWrappedNativeToken)
```

#### Returns

| Name | Type                         | Description |
| ---- | ---------------------------- | ----------- |
| \_0  | contract IWrappedNativeToken | undefined   |


# SiloLens

> SiloLens

Utility contract that simplifies reading data from Silo protocol contracts

## Methods

### balanceOfUnderlying

```solidity
function balanceOfUnderlying(uint256 _assetTotalDeposits, contract IShareToken _shareToken, address _user) external view returns (uint256)
```

Get underlying balance of collateral or debt token

*You can think about debt and collateral tokens as cToken in compound. They represent ownership of debt or collateral in given Silo. This method converts that ownership to exact amount of underlying token.*

#### Parameters

| Name                 | Type                 | Description                                                                                                                                                                                                                |
| -------------------- | -------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| \_assetTotalDeposits | uint256              | Total amount of assets that has been deposited or borrowed. For collateral token, use `totalDeposits` to get this value. For debt token, use `totalBorrowAmount` to get this value.                                        |
| \_shareToken         | contract IShareToken | share token address. It's the collateral and debt share token address. You can find these addresses in: - `ISilo.AssetStorage.collateralToken` - `ISilo.AssetStorage.collateralOnlyToken` - `ISilo.AssetStorage.debtToken` |
| \_user               | address              | wallet address for which to read data                                                                                                                                                                                      |

#### Returns

| Name | Type    | Description                                                     |
| ---- | ------- | --------------------------------------------------------------- |
| \_0  | uint256 | balance of underlying token deposited or borrowed of given user |

### borrowAPY

```solidity
function borrowAPY(contract ISilo _silo, address _asset) external view returns (uint256)
```

Yearly interest rate for borrowing asset token, dynamically calculated for current block timestamp

#### Parameters

| Name    | Type           | Description                          |
| ------- | -------------- | ------------------------------------ |
| \_silo  | contract ISilo | Silo address from which to read data |
| \_asset | address        | asset address                        |

#### Returns

| Name | Type    | Description          |
| ---- | ------- | -------------------- |
| \_0  | uint256 | APY with 18 decimals |

### borrowShare

```solidity
function borrowShare(contract ISilo _silo, address _asset, address _user) external view returns (uint256)
```

Get debt token balance of a user

*Debt token represents a share in total debt of given asset. This method calls balanceOf(\_user) on that token.*

#### Parameters

| Name    | Type           | Description                           |
| ------- | -------------- | ------------------------------------- |
| \_silo  | contract ISilo | Silo address from which to read data  |
| \_asset | address        | asset address for which to read data  |
| \_user  | address        | wallet address for which to read data |

#### Returns

| Name | Type    | Description                         |
| ---- | ------- | ----------------------------------- |
| \_0  | uint256 | balance of debt token of given user |

### calcFee

```solidity
function calcFee(uint256 _amount) external view returns (uint256)
```

Calculate amount of entry fee for given amount

#### Parameters

| Name     | Type    | Description                       |
| -------- | ------- | --------------------------------- |
| \_amount | uint256 | amount for which to calculate fee |

#### Returns

| Name | Type    | Description                    |
| ---- | ------- | ------------------------------ |
| \_0  | uint256 | Amount of token fee to be paid |

### calculateBorrowValue

```solidity
function calculateBorrowValue(contract ISilo _silo, address _user, address _asset, uint256, uint256) external view returns (uint256)
```

Calculate value of borrowed asset by user

*It dynamically adds interest earned to borrowed amount*

#### Parameters

| Name    | Type           | Description                                  |
| ------- | -------------- | -------------------------------------------- |
| \_silo  | contract ISilo | Silo address from which to read data         |
| \_user  | address        | account for which calculation are done       |
| \_asset | address        | token address for which calculation are done |
| \_3     | uint256        | undefined                                    |
| \_4     | uint256        | undefined                                    |

#### Returns

| Name | Type    | Description                                      |
| ---- | ------- | ------------------------------------------------ |
| \_0  | uint256 | value of debt denominated in ETH with 18 decimal |

### calculateCollateralValue

```solidity
function calculateCollateralValue(contract ISilo _silo, address _user, address _asset) external view returns (uint256)
```

Calculate value of collateral asset for user

*It dynamically adds interest earned. Takes for account collateral only deposits as well.*

#### Parameters

| Name    | Type           | Description                                  |
| ------- | -------------- | -------------------------------------------- |
| \_silo  | contract ISilo | Silo address from which to read data         |
| \_user  | address        | account for which calculation are done       |
| \_asset | address        | token address for which calculation are done |

#### Returns

| Name | Type    | Description                                            |
| ---- | ------- | ------------------------------------------------------ |
| \_0  | uint256 | value of collateral denominated in ETH with 18 decimal |

### collateralBalanceOfUnderlying

```solidity
function collateralBalanceOfUnderlying(contract ISilo _silo, address _asset, address _user) external view returns (uint256)
```

Get underlying balance of all deposits of given token of given user including "collateralOnly" deposits

*It reads directly from storage so interest generated between last update and now is not taken for account*

#### Parameters

| Name    | Type           | Description                           |
| ------- | -------------- | ------------------------------------- |
| \_silo  | contract ISilo | Silo address from which to read data  |
| \_asset | address        | asset address for which to read data  |
| \_user  | address        | wallet address for which to read data |

#### Returns

| Name | Type    | Description                         |
| ---- | ------- | ----------------------------------- |
| \_0  | uint256 | balance of debt token of given user |

### collateralOnlyDeposits

```solidity
function collateralOnlyDeposits(contract ISilo _silo, address _asset) external view returns (uint256)
```

Get amount of asset token that has been deposited to Silo with option "collateralOnly"

*It reads directly from storage so interest generated between last update and now is not taken for account*

#### Parameters

| Name    | Type           | Description                          |
| ------- | -------------- | ------------------------------------ |
| \_silo  | contract ISilo | Silo address from which to read data |
| \_asset | address        | asset address for which to read data |

#### Returns

| Name | Type    | Description                                                  |
| ---- | ------- | ------------------------------------------------------------ |
| \_0  | uint256 | amount of all "collateralOnly" deposits made for given asset |

### debtBalanceOfUnderlying

```solidity
function debtBalanceOfUnderlying(contract ISilo _silo, address _asset, address _user) external view returns (uint256)
```

Get amount of debt of underlying token for given user

*It reads directly from storage so interest generated between last update and now is not taken for account*

#### Parameters

| Name    | Type           | Description                           |
| ------- | -------------- | ------------------------------------- |
| \_silo  | contract ISilo | Silo address from which to read data  |
| \_asset | address        | asset address for which to read data  |
| \_user  | address        | wallet address for which to read data |

#### Returns

| Name | Type    | Description                      |
| ---- | ------- | -------------------------------- |
| \_0  | uint256 | balance of underlying token owed |

### depositAPY

```solidity
function depositAPY(contract ISilo _silo, address _asset) external view returns (uint256)
```

Yearly interest rate for depositing asset token, dynamically calculated for current block timestamp

#### Parameters

| Name    | Type           | Description                          |
| ------- | -------------- | ------------------------------------ |
| \_silo  | contract ISilo | Silo address from which to read data |
| \_asset | address        | asset address                        |

#### Returns

| Name | Type    | Description          |
| ---- | ------- | -------------------- |
| \_0  | uint256 | APY with 18 decimals |

### getBorrowAmount

```solidity
function getBorrowAmount(contract ISilo _silo, address _asset, address _user, uint256 _timestamp) external view returns (uint256)
```

Calculates current borrow amount for user with interest

*Interest is calculated based on the provided timestamp with is expected to be current time.*

#### Parameters

| Name        | Type           | Description                                  |
| ----------- | -------------- | -------------------------------------------- |
| \_silo      | contract ISilo | Silo address from which to read data         |
| \_asset     | address        | token address for which calculation are done |
| \_user      | address        | account for which calculation are done       |
| \_timestamp | uint256        | timestamp used for interest calculations     |

#### Returns

| Name | Type    | Description                                                     |
| ---- | ------- | --------------------------------------------------------------- |
| \_0  | uint256 | total amount of asset user needs to repay at provided timestamp |

### getModel

```solidity
function getModel(contract ISilo _silo, address _asset) external view returns (contract IInterestRateModel)
```

*gets interest rates model object*

#### Parameters

| Name    | Type           | Description                                |
| ------- | -------------- | ------------------------------------------ |
| \_silo  | contract ISilo | Silo address from which to read data       |
| \_asset | address        | asset for which to calculate interest rate |

#### Returns

| Name | Type                        | Description                                    |
| ---- | --------------------------- | ---------------------------------------------- |
| \_0  | contract IInterestRateModel | IInterestRateModel interest rates model object |

### getUserLTV

```solidity
function getUserLTV(contract ISilo _silo, address _user) external view returns (uint256 userLTV)
```

Returns Loan-To-Value for an account

*Each Silo has multiple asset markets (bridge assets + unique asset). This function calculates a sum of all deposits and all borrows denominated in ETH. Returns fraction between borrow value and deposit value with 18 decimals.*

#### Parameters

| Name   | Type           | Description                                |
| ------ | -------------- | ------------------------------------------ |
| \_silo | contract ISilo | Silo address from which to read data       |
| \_user | address        | wallet address for which LTV is calculated |

#### Returns

| Name    | Type    | Description                       |
| ------- | ------- | --------------------------------- |
| userLTV | uint256 | user current LTV with 18 decimals |

### getUserLiquidationThreshold

```solidity
function getUserLiquidationThreshold(contract ISilo _silo, address _user) external view returns (uint256 liquidationThreshold)
```

Get combined liquidation threshold for a user

*Methodology for calculating liquidation threshold is as follows. Each Silo is combined form multiple assets (bridge assets + unique asset). Each of these assets may have different liquidation threshold. That means effective liquidation threshold must be calculated per asset based on current deposits and borrows of given account.*

#### Parameters

| Name   | Type           | Description                           |
| ------ | -------------- | ------------------------------------- |
| \_silo | contract ISilo | Silo address from which to read data  |
| \_user | address        | wallet address for which to read data |

#### Returns

| Name                 | Type    | Description                         |
| -------------------- | ------- | ----------------------------------- |
| liquidationThreshold | uint256 | liquidation threshold of given user |

### getUserMaximumLTV

```solidity
function getUserMaximumLTV(contract ISilo _silo, address _user) external view returns (uint256 maximumLTV)
```

Get combined maximum Loan-To-Value for a user

*Methodology for calculating maximum LTV is as follows. Each Silo is combined form multiple assets (bridge assets + unique asset). Each of these assets may have different maximum Loan-To-Value for opening borrow position. That means effective maximum LTV must be calculated per asset based on current deposits and borrows of given account.*

#### Parameters

| Name   | Type           | Description                           |
| ------ | -------------- | ------------------------------------- |
| \_silo | contract ISilo | Silo address from which to read data  |
| \_user | address        | wallet address for which to read data |

#### Returns

| Name       | Type    | Description                         |
| ---------- | ------- | ----------------------------------- |
| maximumLTV | uint256 | Maximum Loan-To-Value of given user |

### getUtilization

```solidity
function getUtilization(contract ISilo _silo, address _asset) external view returns (uint256)
```

Calculates fraction between borrowed and deposited amount of tokens for given asset denominated in percentage

*Utilization is calculated current values in storage so it does not take for account earned interest and ever-increasing total borrow amount. It assumes 1e18 = 100%.*

#### Parameters

| Name    | Type           | Description                          |
| ------- | -------------- | ------------------------------------ |
| \_silo  | contract ISilo | Silo address from which to read data |
| \_asset | address        | asset address                        |

#### Returns

| Name | Type    | Description       |
| ---- | ------- | ----------------- |
| \_0  | uint256 | utilization value |

### inDebt

```solidity
function inDebt(contract ISilo _silo, address _user) external view returns (bool)
```

Check if user is in debt

#### Parameters

| Name   | Type           | Description                           |
| ------ | -------------- | ------------------------------------- |
| \_silo | contract ISilo | Silo address from which to read data  |
| \_user | address        | wallet address for which to read data |

#### Returns

| Name | Type | Description                                                    |
| ---- | ---- | -------------------------------------------------------------- |
| \_0  | bool | TRUE if user borrowed any amount of any asset, otherwise FALSE |

### lensPing

```solidity
function lensPing() external pure returns (bool)
```

*Method for sanity check*

#### Returns

| Name | Type | Description |
| ---- | ---- | ----------- |
| \_0  | bool | always true |

### liquidity

```solidity
function liquidity(contract ISilo _silo, address _asset) external view returns (uint256)
```

*Amount of token that is available for borrowing.*

#### Parameters

| Name    | Type           | Description                          |
| ------- | -------------- | ------------------------------------ |
| \_silo  | contract ISilo | Silo address from which to read data |
| \_asset | address        | asset address for which to read data |

#### Returns

| Name | Type    | Description    |
| ---- | ------- | -------------- |
| \_0  | uint256 | Silo liquidity |

### protocolFees

```solidity
function protocolFees(contract ISilo _silo, address _asset) external view returns (uint256)
```

Get amount of fees earned by protocol to date

*It reads directly from storage so interest generated between last update and now is not taken for account*

#### Parameters

| Name    | Type           | Description                          |
| ------- | -------------- | ------------------------------------ |
| \_silo  | contract ISilo | Silo address from which to read data |
| \_asset | address        | asset address for which to read data |

#### Returns

| Name | Type    | Description                               |
| ---- | ------- | ----------------------------------------- |
| \_0  | uint256 | amount of fees earned by protocol to date |

### siloRepository

```solidity
function siloRepository() external view returns (contract ISiloRepository)
```

#### Returns

| Name | Type                     | Description |
| ---- | ------------------------ | ----------- |
| \_0  | contract ISiloRepository | undefined   |

### totalBorrowAmount

```solidity
function totalBorrowAmount(contract ISilo _silo, address _asset) external view returns (uint256)
```

Get amount of asset that has been borrowed

*It reads directly from storage so interest generated between last update and now is not taken for account*

#### Parameters

| Name    | Type           | Description                          |
| ------- | -------------- | ------------------------------------ |
| \_silo  | contract ISilo | Silo address from which to read data |
| \_asset | address        | asset address for which to read data |

#### Returns

| Name | Type    | Description                            |
| ---- | ------- | -------------------------------------- |
| \_0  | uint256 | amount of asset that has been borrowed |

### totalBorrowAmountWithInterest

```solidity
function totalBorrowAmountWithInterest(contract ISilo _silo, address _asset) external view returns (uint256 _totalBorrowAmount)
```

returns total borrow amount with interest dynamically calculated at current block timestamp

#### Parameters

| Name    | Type           | Description   |
| ------- | -------------- | ------------- |
| \_silo  | contract ISilo | undefined     |
| \_asset | address        | asset address |

#### Returns

| Name                | Type    | Description                         |
| ------------------- | ------- | ----------------------------------- |
| \_totalBorrowAmount | uint256 | total deposits amount with interest |

### totalBorrowShare

```solidity
function totalBorrowShare(contract ISilo _silo, address _asset) external view returns (uint256)
```

Get totalSupply of debt token

*Debt token represents a share in total debt of given asset*

#### Parameters

| Name    | Type           | Description                          |
| ------- | -------------- | ------------------------------------ |
| \_silo  | contract ISilo | Silo address from which to read data |
| \_asset | address        | asset address for which to read data |

#### Returns

| Name | Type    | Description               |
| ---- | ------- | ------------------------- |
| \_0  | uint256 | totalSupply of debt token |

### totalDeposits

```solidity
function totalDeposits(contract ISilo _silo, address _asset) external view returns (uint256)
```

Get amount of asset token that has been deposited to Silo

*It reads directly from storage so interest generated between last update and now is not taken for account*

#### Parameters

| Name    | Type           | Description                          |
| ------- | -------------- | ------------------------------------ |
| \_silo  | contract ISilo | Silo address from which to read data |
| \_asset | address        | asset address for which to read data |

#### Returns

| Name | Type    | Description                                 |
| ---- | ------- | ------------------------------------------- |
| \_0  | uint256 | amount of all deposits made for given asset |

### totalDepositsWithInterest

```solidity
function totalDepositsWithInterest(contract ISilo _silo, address _asset) external view returns (uint256 _totalDeposits)
```

returns total deposits with interest dynamically calculated at current block timestamp

#### Parameters

| Name    | Type           | Description   |
| ------- | -------------- | ------------- |
| \_silo  | contract ISilo | undefined     |
| \_asset | address        | asset address |

#### Returns

| Name            | Type    | Description                         |
| --------------- | ------- | ----------------------------------- |
| \_totalDeposits | uint256 | total deposits amount with interest |

## Errors

### IncorrectDataLength

```solidity
error IncorrectDataLength()
```


# Audits & Formal Verification

### Security Reports

* [ChainSecurity Curve & Convex Audit Report](https://drive.google.com/file/d/1h-vjVceL2k03jXAN_mBcEmeUbATcrrEt/view?usp=sharing)
* [Certora Formal Verification Report of Silo Protocol](https://drive.google.com/file/d/1D2EIOb0XaRov5Ph2AE0DTfIsMISd7UXG/view?usp=sharing)
* [Certora Formal Verification Report of Chainlink Price Provider](https://prover.certora.com/output/74264/b233863cce92448566db?anonymousKey=2a3af53f3a3da84fa1a7763b6122b1d9c32caf32)
* [ABDK Audit Report](https://drive.google.com/file/d/1WXaB3ICLv4rSEX86POK3-NaOIxXwyq9l/view?usp=sharing)
* [Quantstamp Audit Report](https://drive.google.com/file/d/10GyfA-nBJ5jqLWW9LEYJQeFem8qSgNH6/view?usp=sharing)

### Important Information About Audits

{% hint style="warning" %}
Silo v1.1.1 was fully audited by QS and ABDK. Deployed version differs from the audited version. All Silo versions are formally verified. Read on.&#x20;
{% endhint %}

The core contributors team followed rigid processes to develop and secure the Silo protocol, including:&#x20;

* Writing comprehensive unit tests&#x20;
* Verifying contracts against written rules (a process known as Formal Verification)
* Conducting extensive internal code reviews&#x20;
* Hiring two reputable auditors to audit contracts&#x20;
* Running a [security bounty program](/security/bug-bounty-program) through Immunefi

Silo v1.1.1 refers to core smart contracts that implement permissionless isolated lending markets governed by the Silo DAO. Version v1.1.1 was fully audited by Quantstamp and ABDK. Upon the conclusion of the audits, the core team tested audited contracts against various formal verification rules using the Certora Prover (the process is known as Formal Verification).

The [Formal Verification revealed](https://drive.google.com/file/d/1D2EIOb0XaRov5Ph2AE0DTfIsMISd7UXG/view?usp=sharing) a few critical vulnerabilities that went undiscovered in both the ABDK and Quantstamp formal audits. The team fixed those vulnerabilities and released a new version of smart contracts. Rather than repeating the full audit again, the team extensively reviewed the code and tested it against formal verification rules. Smart contracts pass all Formal Verification specifications. Please see the Formal Verification report

While we believe the audited version Silo v1.1.1 and deployed version do not vary materially, we cannot guarantee the security of any shipped deployments including the currently deployed version.

Going forward, the core team will only audit new versions of the protocol–that is, when there are major upgrades to the architecture of the protocol. The core team has already retained Trail of Bits to audit Silo V2.

Silo beta imposes deposit caps in launched markets (Silos) to limit users’ exposure. During the first 4 weeks of beta, the core team will work with the white hats community through Silo’s bounty program to further improve the protocol’s security.


# Smart Contracts

### Silo Ethereum <a href="#silo-legacy-ethereum" id="silo-legacy-ethereum"></a>

* SiloRepository: [0xbACBBefda6fD1FbF5a2d6A79916F4B6124eD2D49 ](https://etherscan.io/address/0xbACBBefda6fD1FbF5a2d6A79916F4B6124eD2D49)
* PriceProvidersRepository: [0xE93CD89E29B5D22bED68dAe8448E241D5ed6d7C3 ](https://etherscan.io/address/0xE93CD89E29B5D22bED68dAe8448E241D5ed6d7C3)
* SiloFactory: [0xB7d391192080674281bAAB8B3083154a5f64cd0a](https://etherscan.io/address/0xB7d391192080674281bAAB8B3083154a5f64cd0a)&#x20;
* InterestRateModelV2: [0x03FF53ee6B0c8221E5cf3829Db1A1B2d5D26C821](https://etherscan.io/address/0x03FF53ee6B0c8221E5cf3829Db1A1B2d5D26C821)&#x20;
* TokensFactory: [0x7Ed1160719AB280760FAa0Ba26CF13139904CbA5 ](https://etherscan.io/address/0x7Ed1160719AB280760FAa0Ba26CF13139904CbA5)
* UniswapV3PriceProviderV2: [0x23755639583e92Db7bf1702E721DBc18fB99ba90](https://etherscan.io/address/0x23755639583e92Db7bf1702E721DBc18fB99ba90)&#x20;
* ChainlinkV3PriceProvider: [0xa3580D7a163616eb66B85C6FcAdB08dB02da6BEd](https://etherscan.io/address/0xa3580D7a163616eb66B85C6FcAdB08dB02da6BEd)&#x20;
* InterestRateDataResolver: [0xCb6CcBd979aa167b81411e672050c01826d715EC](https://etherscan.io/address/0xCb6CcBd979aa167b81411e672050c01826d715EC)
* PriceProvidersRepository: [0xE93CD89E29B5D22bED68dAe8448E241D5ed6d7C3](https://etherscan.io/address/0xE93CD89E29B5D22bED68dAe8448E241D5ed6d7C3)
* SiloIncentivesControllerV2ForSilo: [0xB14F20982F2d1E5933362f5A796736D9ffa220E4](https://etherscan.io/address/0xB14F20982F2d1E5933362f5A796736D9ffa220E4)&#x20;
* SiloLens: [0x331243a425F7EE2468f0FddCe5cD83f58733Cc1C](https://etherscan.io/address/0x331243a425F7EE2468f0FddCe5cD83f58733Cc1C)&#x20;
* SiloLiquidationLens: [0xA5B7Fa178151B29cb87b6c196D88249d94151A3B](https://etherscan.io/address/0xA5B7Fa178151B29cb87b6c196D88249d94151A3B)&#x20;
* SiloRouter: [0x871Ea4c95F204AC944Cdd91cf5FAafD166fbD887](https://etherscan.io/address/0x871Ea4c95F204AC944Cdd91cf5FAafD166fbD887)
* LiquidationHelper: [0x77c5abdfaE4534A5d89FEDE8ecbFcEa839bDc4c4](https://etherscan.io/address/0x77c5abdfaE4534A5d89FEDE8ecbFcEa839bDc4c4)&#x20;
* ManualLiquidation: [0xC99519F2a25c7Ed868D928a50dd1Fe603df14d6A](https://etherscan.io/address/0xC99519F2a25c7Ed868D928a50dd1Fe603df14d6A)&#x20;

### Silo legacy <a href="#silo-legacy-ethereum" id="silo-legacy-ethereum"></a>

* SiloRepository: [0xd998C35B7900b344bbBe6555cc11576942Cf309d](https://etherscan.io/address/0xd998C35B7900b344bbBe6555cc11576942Cf309d#code)
* PriceProvidersRepository:[ 0x7C2ca9D502f2409BeceAfa68E97a176Ff805029F](https://etherscan.io/address/0x7C2ca9D502f2409BeceAfa68E97a176Ff805029F#code)
* SiloFactory: [0x4D919CEcfD4793c0D47866C8d0a02a0950737589](https://etherscan.io/address/0x4D919CEcfD4793c0D47866C8d0a02a0950737589#code)
* InterestRateModelV2: [0x76074C0b66A480F7bc6AbDaA9643a7dc99e18314](https://etherscan.io/address/0x76074C0b66A480F7bc6AbDaA9643a7dc99e18314)
* TokensFactory: [0x0e37Df413f97fC198a84A21BC463C41b516AD622](https://etherscan.io/address/0x0e37Df413f97fC198a84A21BC463C41b516AD622#code)
* UniswapV3PriceProvider: [0x9D46F86516d6083ACA3F9850D060CB62CD0F6924](https://etherscan.io/address/0x9D46F86516d6083ACA3F9850D060CB62CD0F6924#code)
* BalancerV2PriceProvider: [0x2F1aA93249bcc0DF7d89739F86308c7a270F5EEd](https://etherscan.io/address/0x2F1aA93249bcc0DF7d89739F86308c7a270F5EEd#code)
* gOHMPriceProvider: [0x9315FEb6b8e68ff66B2b47E1aD9d6FC68b4dfa2B](https://etherscan.io/address/0x9315FEb6b8e68ff66B2b47E1aD9d6FC68b4dfa2B#code)
* ChainlinkPriceProvider:[ 0xe37B8c83138caF12E57632D19c06Eb561D47e423](https://etherscan.io/address/0xe37B8c83138caF12E57632D19c06Eb561D47e423#code)
* SiloGovernanceToken:[ 0x6f80310CA7F2C654691D1383149Fa1A57d8AB1f8](https://etherscan.io/address/0x6f80310CA7F2C654691D1383149Fa1A57d8AB1f8#code)
* SiloGovernor: [0xA89163F7B2D68A8fbA6Ca36BEEd32Bd4f3EeAf61](https://etherscan.io/address/0xA89163F7B2D68A8fbA6Ca36BEEd32Bd4f3EeAf61#code)
* SiloIncentivesController: [0x6c1603aB6CecF89DD60C24530DdE23F97DA3C229](https://etherscan.io/address/0x6c1603aB6CecF89DD60C24530DdE23F97DA3C229)
* SiloLens (Outdated): [0xf12C3758c1eC393704f0Db8537ef7F57368D92Ea](https://etherscan.io/address/0xf12C3758c1eC393704f0Db8537ef7F57368D92Ea#code)
* SiloLensV2: [0x0e466FC22386997daC23D1f89A43ecb2CB1e76E9](https://etherscan.io/address/0x0e466FC22386997daC23D1f89A43ecb2CB1e76E9)
* SiloRouterV2: [0x8658047e48cc09161f4152c79155dac1d710ff0a](https://etherscan.io/address/0x8658047e48cc09161f4152c79155dac1d710ff0a#code)
* SiloRouter (Deprecated): [0xb2374f84b3cEeFF6492943Df613C9BcF45322a0c](https://etherscan.io/address/0xb2374f84b3cEeFF6492943Df613C9BcF45322a0c#code)
* ManualLiquidationContract: [0x669229276F5625046D6A1017C3258315Ba69c72E](https://etherscan.io/address/0x669229276F5625046D6A1017C3258315Ba69c72E)

### Silo Llama - Ethereum <a href="#silo-llama-ethereum" id="silo-llama-ethereum"></a>

* SiloRepository: [0xbcd67f35c7a2f212db0ad7f68fc773b5ac15377c](https://etherscan.io/address/0xbcd67f35c7a2f212db0ad7f68fc773b5ac15377c#code)
* PriceProvidersRepository: [0xa40111994F44C8add82eF495269e19109c9A982A](https://etherscan.io/address/0xa40111994F44C8add82eF495269e19109c9A982A#code)
* SiloFactory: [0x2c0fA05281730EFd3ef71172d8992500B36b56eA](https://etherscan.io/address/0x2c0fA05281730EFd3ef71172d8992500B36b56eA#code)
* InterestRateModelV2: [0x408822E4E8682413666809b0655161093cd36f2b](https://etherscan.io/address/0x408822E4E8682413666809b0655161093cd36f2b#code)
* ChainlinkPriceProvider: [0xb05F478d93C7063194f37535aD148242B8d1F1B8](https://etherscan.io/address/0xb05F478d93C7063194f37535aD148242B8d1F1B8#code)
* crvUSDPriceProider: [0xa1c2837b7A899d6f89282e9bE9f1496D12e86bBa](https://etherscan.io/address/0xa1c2837b7A899d6f89282e9bE9f1496D12e86bBa#code)
* SiloLens: [0x32a4Bcd8DEa5E18a12a50584682f8E4B77fFF2DF](https://etherscan.io/address/0x32a4Bcd8DEa5E18a12a50584682f8E4B77fFF2DF#code)
* Liquidation helper: [0x205E95fCCFa7A0684BF7E41A4d11b4BF41E88516](https://etherscan.io/address/0x205E95fCCFa7A0684BF7E41A4d11b4BF41E88516#code)
* SiloRouter: [0xF380F025675A868eD5614a1Dd77c6b05f4147004](https://etherscan.io/address/0xF380F025675A868eD5614a1Dd77c6b05f4147004#code)
* IncentiveController: [0x361384A0d755f972E5Eea26e4F4efBAf976B6461](https://etherscan.io/address/0x361384A0d755f972E5Eea26e4F4efBAf976B6461)
* ManualLiquidationContract: [0x8431Adf6637c37d5F41c94ec954e206908C06B70](<https://etherscan.io/address/0x8431Adf6637c37d5F41c94ec954e206908C06B70#readContract >)

### Silo - Arbitrum <a href="#silo-arbitrum" id="silo-arbitrum"></a>

* SiloRepository: [0x8658047e48CC09161f4152c79155Dac1d710Ff0a](https://arbiscan.io/address/0x8658047e48CC09161f4152c79155Dac1d710Ff0a#code)
* PriceProvidersRepository: [0x5bf4E67127263D951FC515E23B323d0e3b4485fd](https://arbiscan.io/address/0x5bf4E67127263D951FC515E23B323d0e3b4485fd#code)
* SiloFactory: [0x4166487056A922D784b073d4d928a516B074b719](https://arbiscan.io/address/0x4166487056A922D784b073d4d928a516B074b719#code)
* InterestRateModelV2: [0x374D79ef2A75d5D25A4Ce163D85AB0b579171d6c](https://arbiscan.io/address/0x374D79ef2A75d5D25A4Ce163D85AB0b579171d6c)
* TokensFactory: [0xE067b967A36A136084Eb9DF0149Dde64F01ea7d1](https://arbiscan.io/address/0xE067b967A36A136084Eb9DF0149Dde64F01ea7d1#code)
* SiloLens: [0xBDb843c7a7e48Dc543424474d7Aa63b61B5D9536](https://arbiscan.io/address/0xBDb843c7a7e48Dc543424474d7Aa63b61B5D9536#code)
* SiloRouter: [0x9992f660137979C1ca7f8b119Cd16361594E3681](https://arbiscan.io/address/0x9992f660137979C1ca7f8b119Cd16361594E3681#code)
* ChainlinkV3PriceProvider: [0x9d0DDE842801448534263FF23C629EDC6B6B31ee](https://arbiscan.io/address/0x9d0DDE842801448534263FF23C629EDC6B6B31ee#code)
* UniswapV3PriceProvider: [0xa44030057A005995851ae36553caeF7551d36BDd](https://arbiscan.io/address/0xa44030057A005995851ae36553caeF7551d36BDd#code)
* UniswapV3PriceProviderV2: [0x124230c23ab32E22c69aCB48b38B4Dbaaaf74a40](https://arbiscan.io/address/0x124230c23ab32E22c69aCB48b38B4Dbaaaf74a40#code)
* BalancerV2PriceProvider: [0x7aAe7D92fbDd1De868c3398E1fade684c000f88d](https://arbiscan.io/address/0x7aAe7D92fbDd1De868c3398E1fade684c000f88d#code)
* Bridged SiloGovernanceToken: [0x0341c0c0ec423328621788d4854119b97f44e391](https://arbiscan.io/address/0x0341c0c0ec423328621788d4854119b97f44e391)
* SiloLens: [0xBDb843c7a7e48Dc543424474d7Aa63b61B5D9536](https://arbiscan.io/address/0xBDb843c7a7e48Dc543424474d7Aa63b61B5D9536#code)
* SiloLens (Outdated): [0x07b94eB6AaD663c4eaf083fBb52928ff9A15BE47](https://arbiscan.io/address/0x07b94eB6AaD663c4eaf083fBb52928ff9A15BE47#code)
* ManualLiquidationContract: [0xEbF50C87a41Cfcc740202464919c1f5988022453](<https://arbiscan.io/address/0xEbF50C87a41Cfcc740202464919c1f5988022453#code >)
* SiloIncentiveController: [0xbDBBf747402653A5aD6F6B8c49F2e8dCeC37fAcF](https://arbiscan.io/address/0xbDBBf747402653A5aD6F6B8c49F2e8dCeC37fAcF)

## Silo - Optimism

* SiloLens: [0xd3De080436b9d38DC315944c16d89C050C414Fed](https://optimistic.etherscan.io/address/0xd3De080436b9d38DC315944c16d89C050C414Fed)
* SiloRouter: [0xC66D2a90c37c873872281a05445EC0e9e82c76a9](https://optimistic.etherscan.io/address/0xC66D2a90c37c873872281a05445EC0e9e82c76a9)
* SiloRepository: [0xD2767dAdED5910bbc205811FdbD2eEFd460AcBe9](https://optimistic.etherscan.io/address/0xD2767dAdED5910bbc205811FdbD2eEFd460AcBe9)
* SiloFactory: [0x6B14c4450a29Dd9562c20259eBFF67a577b540b9](https://optimistic.etherscan.io/address/0x6B14c4450a29Dd9562c20259eBFF67a577b540b9)
* OPIncentivesController: [0x847D9420643e117798e803d9C5F0e406277CB622](https://optimistic.etherscan.io/address/0x847D9420643e117798e803d9C5F0e406277CB622)
* ChainlinkV3PriceProvider: [0xE89D07da1438177eaa0AE7277D7D9A4dDdc16C0F](https://optimistic.etherscan.io/address/0xE89D07da1438177eaa0AE7277D7D9A4dDdc16C0F)
* InterestRateDataResolver: [0xb59605f42A1c564aacc9387132Ad712295b21E55](https://optimistic.etherscan.io/address/0xb59605f42A1c564aacc9387132Ad712295b21E55)
* InterestRateModelV2: [0xb562b6CdEEE3ec10E4803B8dcfef81a32074e6B5](https://optimistic.etherscan.io/address/0xb562b6CdEEE3ec10E4803B8dcfef81a32074e6B5)
* LiquidationHelper: [0xc3f01B8c6B0338c952a5456e30a9FC26468C052A](https://optimistic.etherscan.io/address/0xc3f01B8c6B0338c952a5456e30a9FC26468C052A)
* ManualLiquidation: [0x662c3aFD2a1B5912C8c798AF84f5ABe25D33e5fC](https://optimistic.etherscan.io/address/0x662c3aFD2a1B5912C8c798AF84f5ABe25D33e5fC)
* PriceProvidersRepository: [0x1E915d8950f0C6bf9d01C603D33c50b6110beDA3](https://optimistic.etherscan.io/address/0x1E915d8950f0C6bf9d01C603D33c50b6110beDA3)
* SiloLiquidationLens: [0x5825E982Dec576B6e7743be493fd8807A610860B](https://optimistic.etherscan.io/address/0x5825E982Dec576B6e7743be493fd8807A610860B)
* TokensFactory: [0x8A3C8F33b36B935f5E68108E664FB139B54eC0E8](https://optimistic.etherscan.io/address/0x8A3C8F33b36B935f5E68108E664FB139B54eC0E8)
* Tower: [0x413e64c7407D292D3EAcCc7FB878F3bC3522BB93](https://optimistic.etherscan.io/address/0x413e64c7407D292D3EAcCc7FB878F3bC3522BB93)
* UniswapV3PriceProviderV2: [0xB19C46e6Ca1BAbf5f0d60080A697511e73151bF1](https://optimistic.etherscan.io/address/0xB19C46e6Ca1BAbf5f0d60080A697511e73151bF1)

## Silo - Base

* ChainlinkV3PriceProvider: [0x44E9C695624dAd0bB3690A40C90e6D7964B32D3D](https://basescan.org/address/0x44E9C695624dAd0bB3690A40C90e6D7964B32D3D)
* InterestRateModelV2: [0xf1268Fd0F285fCDcA2bC130E1B44229079487DD1](https://basescan.org/address/0xf1268Fd0F285fCDcA2bC130E1B44229079487DD1)
* LiquidationHelper: [0xF89E18019A0bDC92dE8cc75633cC45014De732c8](https://basescan.org/address/0xF89E18019A0bDC92dE8cc75633cC45014De732c8)
* ManualLiquidationContract: [0x92cECB67Ed267FF98026F814D813fDF3054C6Ff9](https://basescan.org/address/0x92cECB67Ed267FF98026F814D813fDF3054C6Ff9)&#x20;
* PriceProvidersRepository: [0xF380F025675A868eD5614a1Dd77c6b05f4147004](https://basescan.org/address/0xF380F025675A868eD5614a1Dd77c6b05f4147004)
* SiloFactory: [0x408822E4E8682413666809b0655161093cd36f2b](https://basescan.org/address/0x408822E4E8682413666809b0655161093cd36f2b)
* SiloLens: [0x196D312fd81412B6443620Ca81B41103b4E123FD](https://basescan.org/address/0x196D312fd81412B6443620Ca81B41103b4E123FD)
* SiloLiquidationLens: [0xf363C6d369888F5367e9f1aD7b6a7dAe133e8740](https://basescan.org/address/0xf363C6d369888F5367e9f1aD7b6a7dAe133e8740)
* SiloRepository: [0xa42001D6d2237d2c74108FE360403C4b796B7170](https://basescan.org/address/0xa42001D6d2237d2c74108FE360403C4b796B7170)
* SiloRouter: [0x757748e1A208f23bfeb08b925Fac64971eF0584E](https://basescan.org/address/0x757748e1A208f23bfeb08b925Fac64971eF0584E)
* TokensFactory: [0x0f9d4fa99A0ca3c3c0DEdd287531c04E054c5f39](https://basescan.org/address/0x0f9d4fa99A0ca3c3c0DEdd287531c04E054c5f39)
* Tower: [0x22AacdEc57b13911dE9f188CF69633cC537BdB76](https://basescan.org/address/0x22AacdEc57b13911dE9f188CF69633cC537BdB76)
* UniswapV3PriceProviderV2: [0xA95aa71AEce270C7f2c777B1020A97503F7bd0a5](https://basescan.org/address/0xA95aa71AEce270C7f2c777B1020A97503F7bd0a5)
* SiloIncentivesController: [0x626e6A8D4EB33D77A8b631ABfE2E98dA69E3100e<br>](<https://basescan.org/address/0x626e6A8D4EB33D77A8b631ABfE2E98dA69E3100e&#xA;>)


# Bug Bounty Program

Silo finance runs a bug bounty program on Immunefi. You can find the program details and submit a bug report at the following link:&#x20;

<https://immunefi.com/bounty/silofinance/>


# Subgraph Introduction

Silo has a GraphQL API Endpoint hosted by [The Graph](https://thegraph.com/docs/about/introduction#what-the-graph-is) called a subgraph for indexing and organizing data from the SILO smart contracts.

Subgraph information is serviced by a decentralized group of server operators called Indexers.

{% hint style="info" %}
*Silo maintains **two versions** of it's subgraph, a **v2*** ***version** and a **v3 version.** The v2 version is recommended for most users, it is faster and works more reliably. The v3 version does contain more feature rich data, but since it uses large iterations, your code needs to be prepared to deal with errors. \*\***There are major schema differences from V2 to V3.***
{% endhint %}

![](https://static.wixstatic.com/media/fd5034_828547682b1b4ddfbe555444366669ea~mv2.png/v1/fill/w_1200,h_600,al_c/fd5034_828547682b1b4ddfbe555444366669ea~mv2.png)

## SILO Finance Ethereum Mainnet

* **Explorer Page:** [View on The Graph](https://thegraph.com/explorer/subgraphs/81ER342viJd3oRvPf28M7GwsnToa1RVWDNLnTr1eBciC?view=Overview\&chain=arbitrum-one)
* **Graphql Endpoint:** `https://gateway-arbitrum.network.thegraph.com/api/[api-key]/subgraphs/id/81ER342viJd3oRvPf28M7GwsnToa1RVWDNLnTr1eBciC`

## SILO Finance Llama Edition

* **Explorer Page:** [View on The Graph](https://thegraph.com/explorer/subgraphs/5cNT22xQJVEWBBigBMBicv4UZAnGxH2CeHpenTJ8Q8kA?view=Overview\&chain=arbitrum-one)
* **Graphql Endpoint:** `https://gateway-arbitrum.network.thegraph.com/api/[api-key]/subgraphs/id/5cNT22xQJVEWBBigBMBicv4UZAnGxH2CeHpenTJ8Q8kA`

## SILO Finance Arbitrum

* **Explorer Page:** [View on The Graph](https://thegraph.com/explorer/subgraphs/2ufoztRpybsgogPVW6j9NTn1JmBWFYPKbP7pAabizADU?view=Overview\&chain=arbitrum-one)
* **Graphql Endpoint:** `https://gateway-arbitrum.network.thegraph.com/api/[api-key]/subgraphs/id/2ufoztRpybsgogPVW6j9NTn1JmBWFYPKbP7pAabizADU`

## Helpful Resources

* [Video Tutorial on creating an API Key](https://www.youtube.com/watch?v=UrfIpm-Vlgs)
* [Managing your API Key & setting your indexer preferences](https://thegraph.com/docs/en/studio/managing-api-keys/)
* [Querying from an application](https://thegraph.com/docs/en/developer/querying-from-your-app/)
* [How to use the explorer and playground to query on-chain data](https://medium.com/@chidubem_/how-to-query-on-chain-data-with-the-graph-f8507488215)
* [Deploy your own subgraph](https://thegraph.com/docs/en/developing/creating-a-subgraph/)
* [New to GraphQL? - Read Here](https://graphql.org/learn/)


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


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


# Querying SILO

You can build your own queries using a [GraphQL Explorer](https://graphiql-online.com/graphiql) and enter your endpoint to limit the data to exactly what you need.

Each entity has a plural version and a singular version. When querying for a single record response (e.g. account), you will need to supply the id for the entity. When querying for a list of responses (e.g. accounts), you may add filters using the 'where' clause.

**Below are some sample queries you can use to gather information from the SILO contracts.**

## Main Market&#x20;

{% tabs %}
{% tab title="Request" %}

```graphql
fragment rates on Market {
  rates {
    side
    rate
    token {
      id
    }
  }
}

query Markets {
  lendingProtocols(block: { number: 18642057 }) {
    totalValueLockedUSD
  }
  markets(
    first: 5
    orderBy: totalValueLockedUSD
    orderDirection: desc
    where: { inputToken_: { activeOracle_not: "null" } }
    block: { number: 18642057 }
  ) {
    id
    name
    isActive
    archived
    marketAssets {
      asset {
        id
        symbol
        name
        decimals
        lastPriceUSD
      }
      balance
    }
    inputToken {
      id
    }
    outputToken {
      id
    }
    ...rates
  }
}
```

{% endtab %}

{% tab title="Response" %}

```javascript

{
  "data": {
    "lendingProtocols": [
      {
        "totalValueLockedUSD": "31654756.19623516090541036987741325"
      }
    ],
    "markets": [
      {
        "id": "0xfccc27aabd0ab7a0b2ad2b7760037b1eab61616b",
        "name": "USDC",
        "isActive": true,
        "archived": false,
        "marketAssets": [
          {
            "asset": {
              "id": "0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48",
              "symbol": "USDC",
              "name": "USD Coin",
              "decimals": 6,
              "lastPriceUSD": "1"
            },
            "balance": "364078400145"
          },
          {
            "asset": {
              "id": "0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2",
              "symbol": "WETH",
              "name": "Wrapped Ether",
              "decimals": 18,
              "lastPriceUSD": "2100.250075022509051901332528399629"
            },
            "balance": "744793426127992093125"
          },
          {
            "asset": {
              "id": "0xd7c9f0e536dc865ae858b0c0453fe76d13c3beac",
              "symbol": "XAI",
              "name": "XAI Stablecoin",
              "decimals": 18,
              "lastPriceUSD": "1"
            },
            "balance": "3664902613587539313319456"
          }
        ],
        "inputToken": {
          "id": "0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48"
        },
        "outputToken": [
          {
            "id": "0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2"
          },
          {
            "id": "0xd7c9f0e536dc865ae858b0c0453fe76d13c3beac"
          }
        ],
        "rates": [
          {
            "side": "BORROWER",
            "rate": "3.434378284656",
            "token": {
              "id": "0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48"
            }
          },
          {
            "side": "BORROWER",
            "rate": "0.0007085319264",
            "token": {
              "id": "0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2"
            }
          },
          {
            "side": "BORROWER",
            "rate": "1.344572112672",
            "token": {
              "id": "0xd7c9f0e536dc865ae858b0c0453fe76d13c3beac"
            }
          },
          {
            "side": "LENDER",
            "rate": "2.3590011102390599",
            "token": {
              "id": "0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48"
            }
          },
          {
            "side": "LENDER",
            "rate": "0.0000000611154161",
            "token": {
              "id": "0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2"
            }
          },
          {
            "side": "LENDER",
            "rate": "0.3615863356405243",
            "token": {
              "id": "0xd7c9f0e536dc865ae858b0c0453fe76d13c3beac"
            }
          }
        ]
      },
      {
        "id": "0x4f5717f1efdec78a960f08871903b394e7ea95ed",
        "name": "wstETH",
        "isActive": true,
        "archived": false,
        "marketAssets": [
          {
            "asset": {
              "id": "0x7f39c581f595b53c5cb19bd0b3f8da6c935e2ca0",
              "symbol": "wstETH",
              "name": "Wrapped liquid staked Ether 2.0",
              "decimals": 18,
              "lastPriceUSD": "2408.294929866506817127363832612126"
            },
            "balance": "601658380485446574568"
          },
          {
            "asset": {
              "id": "0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2",
              "symbol": "WETH",
              "name": "Wrapped Ether",
              "decimals": 18,
              "lastPriceUSD": "2100.250075022509051901332528399629"
            },
            "balance": "623319763908688439623"
          },
          {
            "asset": {
              "id": "0xd7c9f0e536dc865ae858b0c0453fe76d13c3beac",
              "symbol": "XAI",
              "name": "XAI Stablecoin",
              "decimals": 18,
              "lastPriceUSD": "1"
            },
            "balance": "771217449793349753242731"
          }
        ],
        "inputToken": {
          "id": "0x7f39c581f595b53c5cb19bd0b3f8da6c935e2ca0"
        },
        "outputToken": [
          {
            "id": "0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2"
          },
          {
            "id": "0xd7c9f0e536dc865ae858b0c0453fe76d13c3beac"
          }
        ],
        "rates": [
          {
            "side": "BORROWER",
            "rate": "0.137159083296",
            "token": {
              "id": "0x7f39c581f595b53c5cb19bd0b3f8da6c935e2ca0"
            }
          },
          {
            "side": "BORROWER",
            "rate": "0.0535833789408",
            "token": {
              "id": "0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2"
            }
          },
          {
            "side": "BORROWER",
            "rate": "2.436831753408",
            "token": {
              "id": "0xd7c9f0e536dc865ae858b0c0453fe76d13c3beac"
            }
          },
          {
            "side": "LENDER",
            "rate": "0.001343759355935",
            "token": {
              "id": "0x7f39c581f595b53c5cb19bd0b3f8da6c935e2ca0"
            }
          },
          {
            "side": "LENDER",
            "rate": "0.0003495347911237",
            "token": {
              "id": "0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2"
            }
          },
          {
            "side": "LENDER",
            "rate": "1.187656316557936",
            "token": {
              "id": "0xd7c9f0e536dc865ae858b0c0453fe76d13c3beac"
            }
          }
        ]
      },
      {
        "id": "0x2eaf84b425822edf450fc5fdeec085f2e5ada98b",
        "name": "cbETH",
        "isActive": true,
        "archived": false,
        "marketAssets": [
          {
            "asset": {
              "id": "0xbe9895146f7af43049ca1c1ae358b0541ea49704",
              "symbol": "cbETH",
              "name": "Coinbase Wrapped Staked ETH",
              "decimals": 18,
              "lastPriceUSD": "2214.509986723636758691980260177686"
            },
            "balance": "1045283373304657555837"
          },
          {
            "asset": {
              "id": "0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2",
              "symbol": "WETH",
              "name": "Wrapped Ether",
              "decimals": 18,
              "lastPriceUSD": "2100.250075022509051901332528399629"
            },
            "balance": "250155143931829327052"
          },
          {
            "asset": {
              "id": "0xd7c9f0e536dc865ae858b0c0453fe76d13c3beac",
              "symbol": "XAI",
              "name": "XAI Stablecoin",
              "decimals": 18,
              "lastPriceUSD": "1"
            },
            "balance": "936713155752097208926071"
          }
        ],
        "inputToken": {
          "id": "0xbe9895146f7af43049ca1c1ae358b0541ea49704"
        },
        "outputToken": [
          {
            "id": "0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2"
          },
          {
            "id": "0xd7c9f0e536dc865ae858b0c0453fe76d13c3beac"
          }
        ],
        "rates": [
          {
            "side": "BORROWER",
            "rate": "0.000035225712",
            "token": {
              "id": "0xbe9895146f7af43049ca1c1ae358b0541ea49704"
            }
          },
          {
            "side": "BORROWER",
            "rate": "0.0234909361872",
            "token": {
              "id": "0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2"
            }
          },
          {
            "side": "BORROWER",
            "rate": "0.322337229624",
            "token": {
              "id": "0xd7c9f0e536dc865ae858b0c0453fe76d13c3beac"
            }
          },
          {
            "side": "LENDER",
            "rate": "0.0000000006204765",
            "token": {
              "id": "0xbe9895146f7af43049ca1c1ae358b0541ea49704"
            }
          },
          {
            "side": "LENDER",
            "rate": "0.0000671786091185",
            "token": {
              "id": "0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2"
            }
          },
          {
            "side": "LENDER",
            "rate": "0.0207803524198505",
            "token": {
              "id": "0xd7c9f0e536dc865ae858b0c0453fe76d13c3beac"
            }
          }
        ]
      },
      {
        "id": "0xb1590d554dc7d66f710369983b46a5905ad34c8c",
        "name": "rETH",
        "isActive": true,
        "archived": false,
        "marketAssets": [
          {
            "asset": {
              "id": "0xae78736cd615f374d3085123a210448e74fc6393",
              "symbol": "rETH",
              "name": "Rocket Pool ETH",
              "decimals": 18,
              "lastPriceUSD": "2292.625183628069381072962910193171"
            },
            "balance": "15101222667947455404"
          },
          {
            "asset": {
              "id": "0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2",
              "symbol": "WETH",
              "name": "Wrapped Ether",
              "decimals": 18,
              "lastPriceUSD": "2100.250075022509051901332528399629"
            },
            "balance": "180269965101087073548"
          },
          {
            "asset": {
              "id": "0xd7c9f0e536dc865ae858b0c0453fe76d13c3beac",
              "symbol": "XAI",
              "name": "XAI Stablecoin",
              "decimals": 18,
              "lastPriceUSD": "1"
            },
            "balance": "1550356627288000922924929"
          }
        ],
        "inputToken": {
          "id": "0xae78736cd615f374d3085123a210448e74fc6393"
        },
        "outputToken": [
          {
            "id": "0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2"
          },
          {
            "id": "0xd7c9f0e536dc865ae858b0c0453fe76d13c3beac"
          }
        ],
        "rates": [
          {
            "side": "BORROWER",
            "rate": "1.426541382648",
            "token": {
              "id": "0xae78736cd615f374d3085123a210448e74fc6393"
            }
          },
          {
            "side": "BORROWER",
            "rate": "1.5563409821568",
            "token": {
              "id": "0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2"
            }
          },
          {
            "side": "BORROWER",
            "rate": "0.1280269262592",
            "token": {
              "id": "0xd7c9f0e536dc865ae858b0c0453fe76d13c3beac"
            }
          },
          {
            "side": "LENDER",
            "rate": "0.1453600202675915",
            "token": {
              "id": "0xae78736cd615f374d3085123a210448e74fc6393"
            }
          },
          {
            "side": "LENDER",
            "rate": "0.2948868793977595",
            "token": {
              "id": "0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2"
            }
          },
          {
            "side": "LENDER",
            "rate": "0.003278181697007",
            "token": {
              "id": "0xd7c9f0e536dc865ae858b0c0453fe76d13c3beac"
            }
          }
        ]
      },
      {
        "id": "0xbc6594df90ddeada7cdd70dbc08e221a77512deb",
        "name": "LUSD",
        "isActive": true,
        "archived": false,
        "marketAssets": [
          {
            "asset": {
              "id": "0x5f98805a4e8be255a32880fdec7f6728c6568ba0",
              "symbol": "LUSD",
              "name": "LUSD Stablecoin",
              "decimals": 18,
              "lastPriceUSD": "0.9924404904383092540606718941941649"
            },
            "balance": "0"
          },
          {
            "asset": {
              "id": "0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2",
              "symbol": "WETH",
              "name": "Wrapped Ether",
              "decimals": 18,
              "lastPriceUSD": "2100.250075022509051901332528399629"
            },
            "balance": "1000000000000000"
          },
          {
            "asset": {
              "id": "0xd7c9f0e536dc865ae858b0c0453fe76d13c3beac",
              "symbol": "XAI",
              "name": "XAI Stablecoin",
              "decimals": 18,
              "lastPriceUSD": "1"
            },
            "balance": "1389926560519749010983303"
          }
        ],
        "inputToken": {
          "id": "0x5f98805a4e8be255a32880fdec7f6728c6568ba0"
        },
        "outputToken": [
          {
            "id": "0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2"
          },
          {
            "id": "0xd7c9f0e536dc865ae858b0c0453fe76d13c3beac"
          }
        ],
        "rates": [
          {
            "side": "BORROWER",
            "rate": "0",
            "token": {
              "id": "0x5f98805a4e8be255a32880fdec7f6728c6568ba0"
            }
          },
          {
            "side": "BORROWER",
            "rate": "0",
            "token": {
              "id": "0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2"
            }
          },
          {
            "side": "BORROWER",
            "rate": "0.3671964895248",
            "token": {
              "id": "0xd7c9f0e536dc865ae858b0c0453fe76d13c3beac"
            }
          },
          {
            "side": "LENDER",
            "rate": "0",
            "token": {
              "id": "0x5f98805a4e8be255a32880fdec7f6728c6568ba0"
            }
          },
          {
            "side": "LENDER",
            "rate": "0",
            "token": {
              "id": "0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2"
            }
          },
          {
            "side": "LENDER",
            "rate": "0.0269706815118324",
            "token": {
              "id": "0xd7c9f0e536dc865ae858b0c0453fe76d13c3beac"
            }
          }
        ]
      }
    ]
  }
```

{% endtab %}
{% endtabs %}

## Basic Market&#x20;

{% tabs %}
{% tab title="Request" %}

```graphql
query BasicMarkets {
  silos(first: 5) {
    id
    archived
    baseAsset {
      id
    }
    bridgeAsset {
      id
    }
    market {
      inputToken {
        id
        name
        symbol
        decimals
      }
      sToken {
        id
      }
      spToken {
        id
      }
      dToken {
        id
      }
    }
  }
}
```

{% endtab %}

{% tab title="Response" %}

```javascript

{
  "data": {
    "silos": [
      {
        "id": "0x00c64ae39df498b8e77355d2085b8f968f0e3954",
        "archived": false,
        "baseAsset": {
          "id": "0xf4d2888d29d722226fafa5d9b24f9164c092421e"
        },
        "bridgeAsset": [
          {
            "id": "0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2"
          },
          {
            "id": "0xd7c9f0e536dc865ae858b0c0453fe76d13c3beac"
          }
        ],
        "market": [
          {
            "inputToken": {
              "id": "0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2",
              "name": "Wrapped Ether",
              "symbol": "WETH",
              "decimals": 18
            },
            "sToken": {
              "id": "0xb212bc5279369c2b04c4f33ea25ca602de07abfd"
            },
            "spToken": {
              "id": "0x3f382b6f8deb8dd8a496307eceb4de83d67352da"
            },
            "dToken": {
              "id": "0x4ded151c215758cea2661f9dcf3ec45605570466"
            }
          },
          {
            "inputToken": {
              "id": "0xd7c9f0e536dc865ae858b0c0453fe76d13c3beac",
              "name": "XAI Stablecoin",
              "symbol": "XAI",
              "decimals": 18
            },
            "sToken": {
              "id": "0xbae6f752ddc8e349eadae72559db483625be22f7"
            },
            "spToken": {
              "id": "0x248f6ab12802598f367e57d0f83fa612a19fe492"
            },
            "dToken": {
              "id": "0x2c9c886ad590c05888848209d75ec66cd6139801"
            }
          },
          {
            "inputToken": {
              "id": "0xf4d2888d29d722226fafa5d9b24f9164c092421e",
              "name": "LooksRare Token",
              "symbol": "LOOKS",
              "decimals": 18
            },
            "sToken": {
              "id": "0x7fff1d70d5a48ac888ef453b01e50ae53384113d"
            },
            "spToken": {
              "id": "0xb74bb1d717476e0392739b178395ef3435747ee1"
            },
            "dToken": {
              "id": "0x62373f9cacdefb22bcac230e529a1ae25ec05a00"
            }
          }
        ]
      },
      {
        "id": "0x03ff864f65a69e6c025f68f5695fa243f8d2d61b",
        "archived": false,
        "baseAsset": {
          "id": "0x041dfd7e8497b3b47b2260fc0ced9443c67c9ed2"
        },
        "bridgeAsset": [
          {
            "id": "0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2"
          },
          {
            "id": "0xd7c9f0e536dc865ae858b0c0453fe76d13c3beac"
          }
        ],
        "market": [
          {
            "inputToken": {
              "id": "0x041dfd7e8497b3b47b2260fc0ced9443c67c9ed2",
              "name": "Staked Curve.fi ETH/stETH Convex Deposit Silo",
              "symbol": "stkcvxsteCRV-silo",
              "decimals": 18
            },
            "sToken": {
              "id": "0x1d6f0e3e549396a23a4101e64bfe2fd79ed1dce8"
            },
            "spToken": {
              "id": "0xb99f4530fd0ffe3e259d682acd20ed8e2657e605"
            },
            "dToken": {
              "id": "0xa41a28aa25d5de522d7d67bb4a3f443e732bbb0b"
            }
          },
          {
            "inputToken": {
              "id": "0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2",
              "name": "Wrapped Ether",
              "symbol": "WETH",
              "decimals": 18
            },
            "sToken": {
              "id": "0xf98b72b02969001b0093349ec39ce4f2d5c5592c"
            },
            "spToken": {
              "id": "0x0bd0de6570af90ed61c855350018c09f91de8b7c"
            },
            "dToken": {
              "id": "0x5a86245d6c5ad9f349ae3f853b836b60acb0122b"
            }
          },
          {
            "inputToken": {
              "id": "0xd7c9f0e536dc865ae858b0c0453fe76d13c3beac",
              "name": "XAI Stablecoin",
              "symbol": "XAI",
              "decimals": 18
            },
            "sToken": {
              "id": "0xccbb566fd1a30523e63099d0b0cd317a3b085059"
            },
            "spToken": {
              "id": "0xfb26d5bf228617412e7a5df6ca579ebb916be683"
            },
            "dToken": {
              "id": "0xb611f1336ad67bcecdb3b6fa4ff0b14853a6d851"
            }
          }
        ]
      },
      {
        "id": "0x0a898eba24e6d1213f1e494d49e757640628aeec",
        "archived": false,
        "baseAsset": {
          "id": "0xfcdeee2bfeae88e749e88a628e2c3401ec5eda3c"
        },
        "bridgeAsset": [
          {
            "id": "0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2"
          },
          {
            "id": "0xd7c9f0e536dc865ae858b0c0453fe76d13c3beac"
          }
        ],
        "market": [
          {
            "inputToken": {
              "id": "0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2",
              "name": "Wrapped Ether",
              "symbol": "WETH",
              "decimals": 18
            },
            "sToken": {
              "id": "0x54cb4edecdc08f0470798eb6a979288132128535"
            },
            "spToken": {
              "id": "0x2e3e4951a108e0e7467107653ed9e30898535f3d"
            },
            "dToken": {
              "id": "0x57a4681f1b4a32ffa8bde55dc6feeb54941e10a4"
            }
          },
          {
            "inputToken": {
              "id": "0xd7c9f0e536dc865ae858b0c0453fe76d13c3beac",
              "name": "XAI Stablecoin",
              "symbol": "XAI",
              "decimals": 18
            },
            "sToken": {
              "id": "0x868eb1922b792b427a353524107d8d39d01b0b80"
            },
            "spToken": {
              "id": "0x90c10c01f49009609c44eb78f3764b3d11d792e5"
            },
            "dToken": {
              "id": "0x667615208bae460629ee36c7f4bbdbbf4af61854"
            }
          },
          {
            "inputToken": {
              "id": "0xfcdeee2bfeae88e749e88a628e2c3401ec5eda3c",
              "name": "Staked Curve.fi FRAX/USDC Convex Deposit Silo",
              "symbol": "stkcvxcrvFRAX-silo",
              "decimals": 18
            },
            "sToken": {
              "id": "0x25a857a7db90d417d438f7de03b2c325c254576f"
            },
            "spToken": {
              "id": "0x2860b3c313554966760a05ec438e5d86c82e8fad"
            },
            "dToken": {
              "id": "0xab7b57450da82d0674625e641775318ec14cb934"
            }
          }
        ]
      },
      {
        "id": "0x0bce613ef6a197e8c56be525cf173c27b49ac47d",
        "archived": false,
        "baseAsset": {
          "id": "0x9f8f72aa9304c8b593d555f12ef6589cc3a579a2"
        },
        "bridgeAsset": [
          {
            "id": "0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2"
          },
          {
            "id": "0xd7c9f0e536dc865ae858b0c0453fe76d13c3beac"
          }
        ],
        "market": [
          {
            "inputToken": {
              "id": "0x9f8f72aa9304c8b593d555f12ef6589cc3a579a2",
              "name": "Maker",
              "symbol": "MKR",
              "decimals": 18
            },
            "sToken": {
              "id": "0xbc5983599e890443bf7cbc56bf2b6933dbc80f02"
            },
            "spToken": {
              "id": "0xa08ffcedecbb0df7c4e4f3548a8da9e17ee0283b"
            },
            "dToken": {
              "id": "0x8a0af25a58d506efb93c4fe1ce803754360ca538"
            }
          },
          {
            "inputToken": {
              "id": "0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2",
              "name": "Wrapped Ether",
              "symbol": "WETH",
              "decimals": 18
            },
            "sToken": {
              "id": "0x5693e813b39cf2768b0ce103c9d8088e9cb45fbf"
            },
            "spToken": {
              "id": "0x02cf19e0bd0533c36dbb74ec6075584fc295b81a"
            },
            "dToken": {
              "id": "0x1bcd41506c35d9174db5851a64594544ecdf37b0"
            }
          },
          {
            "inputToken": {
              "id": "0xd7c9f0e536dc865ae858b0c0453fe76d13c3beac",
              "name": "XAI Stablecoin",
              "symbol": "XAI",
              "decimals": 18
            },
            "sToken": {
              "id": "0xe8c5a2eca2cde8c7b03f260412d8bbb71b21e283"
            },
            "spToken": {
              "id": "0xb914dc4e7ed2ed3e43154f8f6ae305ec039619d6"
            },
            "dToken": {
              "id": "0x003d5ca37c7657f9cb511f8eb5bd4efe0ca23f7a"
            }
          }
        ]
      },
      {
        "id": "0x0cb6c16798f2639a96e144b0524243f5fc1780b6",
        "archived": false,
        "baseAsset": {
          "id": "0x5283d291dbcf85356a21ba090e6db59121208b44"
        },
        "bridgeAsset": [
          {
            "id": "0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2"
          },
          {
            "id": "0xd7c9f0e536dc865ae858b0c0453fe76d13c3beac"
          }
        ],
        "market": [
          {
            "inputToken": {
              "id": "0x5283d291dbcf85356a21ba090e6db59121208b44",
              "name": "Blur",
              "symbol": "BLUR",
              "decimals": 18
            },
            "sToken": {
              "id": "0xe485befd6aa753cffcbc1177a8f261eb8f2f6f82"
            },
            "spToken": {
              "id": "0xc82a6ffab56eed8d78d3b8562176161770299a48"
            },
            "dToken": {
              "id": "0x32fe7494dcf02ef7b0d0b1ea956bf13f273c9e92"
            }
          },
          {
            "inputToken": {
              "id": "0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2",
              "name": "Wrapped Ether",
              "symbol": "WETH",
              "decimals": 18
            },
            "sToken": {
              "id": "0x2247e52857ac7808992893e108a71d6a219db54d"
            },
            "spToken": {
              "id": "0x142811e0b09bb95b4db8878890599527c2c2a0ad"
            },
            "dToken": {
              "id": "0x4ec5c69dd214d8681ac802372a23b75cb5ee82d2"
            }
          },
          {
            "inputToken": {
              "id": "0xd7c9f0e536dc865ae858b0c0453fe76d13c3beac",
              "name": "XAI Stablecoin",
              "symbol": "XAI",
              "decimals": 18
            },
            "sToken": {
              "id": "0x9913638f9b12e77687aff57690ee7da3f8971cfc"
            },
            "spToken": {
              "id": "0xe6ea54975d0c4195d7f3e44527f542af5819c453"
            },
            "dToken": {
              "id": "0x607385fd3e2de43f434ba5e774170df23d97a74b"
            }
          }
        ]
      }
    ]
  }
}
```

{% endtab %}
{% endtabs %}

## Most at risk of liquidation - V3 ONLY

{% tabs %}
{% tab title="Request" %}

```graphql
fragment positionFields on Position {
  marketAsset: market {
    inputToken {
      id
    }
  }
  snapshots(first: 1, orderBy: blockNumber, orderDirection: desc) {
    blockNumber
    hash
  }
}

query QueryPositions {
  siloPositions(
    first: 5
    skip: 0
    where: { dTokenBalance_gt: 0, silo_: { id_not_in: [""] } }
    orderBy: riskFactor
    orderDirection: desc
    block: { number_gte: 19112526 }
  ) {
    id
    account {
      id
    }
    silo {
      id
      baseAsset {
        id
      }
      bridgeAsset {
        id
      }
      marketAssets: market {
        inputToken {
          id
          symbol
          decimals
          lastPriceUSD
        }
        liquidationThreshold
      }
    }
    totalCollateralValue
    totalBorrowValue
    riskFactor
    riskScore
    collateralPositions: positions(where: { sTokenBalance_gt: 0 }) {
      sTokenBalance
      sToken {
        derivativeConversion
      }
      ...positionFields
    }
    collateralOnlyPositions: positions(where: { spTokenBalance_gt: 0 }) {
      spTokenBalance
      ...positionFields
    }
    debtPositions: positions(where: { dTokenBalance_gt: 0 }) {
      dTokenBalance
      dToken {
        derivativeConversion
      }
      ...positionFields
    }
  }
}
```

{% endtab %}

{% tab title="Response" %}

```javascript

{
  "data": {
    "siloPositions": [
      {
        "id": "0x31f3b3b86a074e2ffc4fd75d8eb9721a75ee04dc-0xef1f82df5e1416fc8fc203420d8e3451e1c7d687",
        "account": {
          "id": "0xef1f82df5e1416fc8fc203420d8e3451e1c7d687"
        },
        "silo": {
          "id": "0x31f3b3b86a074e2ffc4fd75d8eb9721a75ee04dc",
          "baseAsset": {
            "id": "0x2260fac5e5542a773aa44fbcfedf7c193bc2c599"
          },
          "bridgeAsset": [
            {
              "id": "0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2"
            },
            {
              "id": "0xd7c9f0e536dc865ae858b0c0453fe76d13c3beac"
            }
          ],
          "marketAssets": [
            {
              "inputToken": {
                "id": "0x2260fac5e5542a773aa44fbcfedf7c193bc2c599",
                "symbol": "WBTC",
                "decimals": 8,
                "lastPriceUSD": "43081.13070585360735183995069250443"
              },
              "liquidationThreshold": "85"
            },
            {
              "inputToken": {
                "id": "0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2",
                "symbol": "WETH",
                "decimals": 18,
                "lastPriceUSD": "2305.352727896261500078058211416915"
              },
              "liquidationThreshold": "85"
            },
            {
              "inputToken": {
                "id": "0xd7c9f0e536dc865ae858b0c0453fe76d13c3beac",
                "symbol": "XAI",
                "decimals": 18,
                "lastPriceUSD": "1"
              },
              "liquidationThreshold": "0.0000000010000001"
            }
          ]
        },
        "totalCollateralValue": "26.40718071374015943438822681197585",
        "totalBorrowValue": "21.7618512648009563519588448452707",
        "riskFactor": "0.9695157630086599610452807568527247",
        "riskScore": "21.09845783347447102492544605531852",
        "collateralPositions": [
          {
            "sTokenBalance": "9999883999346598",
            "sToken": {
              "derivativeConversion": "1.145485752473693930683708730069486"
            },
            "marketAsset": {
              "inputToken": {
                "id": "0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2"
              }
            },
            "snapshots": [
              {
                "blockNumber": "15581184",
                "hash": "0x45faa8dcf44468b534a6b0b5521e34e9cfb1259f869df52ba522bae6925d33ff"
              }
            ]
          }
        ],
        "collateralOnlyPositions": [],
        "debtPositions": [
          {
            "dTokenBalance": "49890",
            "dToken": {
              "derivativeConversion": "1.012500486400249036927506906883536"
            },
            "marketAsset": {
              "inputToken": {
                "id": "0x2260fac5e5542a773aa44fbcfedf7c193bc2c599"
              }
            },
            "snapshots": [
              {
                "blockNumber": "16195567",
                "hash": "0x38f676655f314a6621add9087df44b0249acec50e51b2b0a9df6bf4fddf4bb0c"
              }
            ]
          }
        ]
      },
      {
        "id": "0xb1590d554dc7d66f710369983b46a5905ad34c8c-0xf2f6709f1917b3ecb2e97fadfec206cd56da76ed",
        "account": {
          "id": "0xf2f6709f1917b3ecb2e97fadfec206cd56da76ed"
        },
        "silo": {
          "id": "0xb1590d554dc7d66f710369983b46a5905ad34c8c",
          "baseAsset": {
            "id": "0xae78736cd615f374d3085123a210448e74fc6393"
          },
          "bridgeAsset": [
            {
              "id": "0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2"
            },
            {
              "id": "0xd7c9f0e536dc865ae858b0c0453fe76d13c3beac"
            }
          ],
          "marketAssets": [
            {
              "inputToken": {
                "id": "0xae78736cd615f374d3085123a210448e74fc6393",
                "symbol": "rETH",
                "decimals": 18,
                "lastPriceUSD": "2528.003245037548002523965051889023"
              },
              "liquidationThreshold": "85"
            },
            {
              "inputToken": {
                "id": "0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2",
                "symbol": "WETH",
                "decimals": 18,
                "lastPriceUSD": "2305.352727896261500078058211416915"
              },
              "liquidationThreshold": "85"
            },
            {
              "inputToken": {
                "id": "0xd7c9f0e536dc865ae858b0c0453fe76d13c3beac",
                "symbol": "XAI",
                "decimals": 18,
                "lastPriceUSD": "1"
              },
              "liquidationThreshold": "90"
            }
          ]
        },
        "totalCollateralValue": "75.8276802636028734567222807490901",
        "totalBorrowValue": "60.60850544289398489236958341940444",
        "riskFactor": "0.9403442621821749272603240204475126",
        "riskScore": "56.99286033266247743827058952848295",
        "collateralPositions": [
          {
            "sTokenBalance": "32368899245681332",
            "sToken": {
              "derivativeConversion": "1.016160843305877923883982401708182"
            },
            "marketAsset": {
              "inputToken": {
                "id": "0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2"
              }
            },
            "snapshots": [
              {
                "blockNumber": "18523199",
                "hash": "0x104b9788ab03783d9c3bab0761add4d95929ae73de4fab9990d60d067002054b"
              }
            ]
          }
        ],
        "collateralOnlyPositions": [],
        "debtPositions": [
          {
            "dTokenBalance": "23904840870537614",
            "dToken": {
              "derivativeConversion": "1.002928772333625496007291710727422"
            },
            "marketAsset": {
              "inputToken": {
                "id": "0xae78736cd615f374d3085123a210448e74fc6393"
              }
            },
            "snapshots": [
              {
                "blockNumber": "18523172",
                "hash": "0x7e86f0feae07b6aaf4492cf4ca01988e737d741a219e82e4e0452da1f7866c61"
              }
            ]
          }
        ]
      },
      {
        "id": "0xcd7ae3373f7e76a817238261b8303fa17d2af585-0x128efd501c665b14ff2408f0fe8c727f13e5e49a",
        "account": {
          "id": "0x128efd501c665b14ff2408f0fe8c727f13e5e49a"
        },
        "silo": {
          "id": "0xcd7ae3373f7e76a817238261b8303fa17d2af585",
          "baseAsset": {
            "id": "0xcd5fe23c85820f7b72d0926fc9b05b43e359b7ee"
          },
          "bridgeAsset": [
            {
              "id": "0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2"
            },
            {
              "id": "0xd7c9f0e536dc865ae858b0c0453fe76d13c3beac"
            }
          ],
          "marketAssets": [
            {
              "inputToken": {
                "id": "0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2",
                "symbol": "WETH",
                "decimals": 18,
                "lastPriceUSD": "2305.352727896261500078058211416915"
              },
              "liquidationThreshold": "85"
            },
            {
              "inputToken": {
                "id": "0xcd5fe23c85820f7b72d0926fc9b05b43e359b7ee",
                "symbol": "weETH",
                "decimals": 18,
                "lastPriceUSD": "2371.291671510023435484500874531296"
              },
              "liquidationThreshold": "85"
            },
            {
              "inputToken": {
                "id": "0xd7c9f0e536dc865ae858b0c0453fe76d13c3beac",
                "symbol": "XAI",
                "decimals": 18,
                "lastPriceUSD": "1"
              },
              "liquidationThreshold": "0.0000000010000001"
            }
          ]
        },
        "totalCollateralValue": "276.3996600955495876243550356049394",
        "totalBorrowValue": "220.7462963468598670525100275578585",
        "riskFactor": "0.9395869916199449564488059963322557",
        "riskScore": "207.4103484957909078575171982770573",
        "collateralPositions": [
          {
            "sTokenBalance": "116560529707562535",
            "sToken": {
              "derivativeConversion": "1.000002339998258700690484205200131"
            },
            "marketAsset": {
              "inputToken": {
                "id": "0xcd5fe23c85820f7b72d0926fc9b05b43e359b7ee"
              }
            },
            "snapshots": [
              {
                "blockNumber": "19095098",
                "hash": "0x86bf07d6f985feb7aaa125ad4eb8840a49a3baf1dc23215617ea29e00c321ab4"
              }
            ]
          }
        ],
        "collateralOnlyPositions": [],
        "debtPositions": [
          {
            "dTokenBalance": "95720979924718579",
            "dToken": {
              "derivativeConversion": "1.000342928115019775577072674203063"
            },
            "marketAsset": {
              "inputToken": {
                "id": "0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2"
              }
            },
            "snapshots": [
              {
                "blockNumber": "19095103",
                "hash": "0x704123344e39d2f9a71291ceae16f5f441567b157f72c93ff21b0f67c691f7df"
              }
            ]
          }
        ]
      },
      {
        "id": "0xfccc27aabd0ab7a0b2ad2b7760037b1eab61616b-0x46c0a3baa03cb86ef3dc30dca6a2e9a5427e0488",
        "account": {
          "id": "0x46c0a3baa03cb86ef3dc30dca6a2e9a5427e0488"
        },
        "silo": {
          "id": "0xfccc27aabd0ab7a0b2ad2b7760037b1eab61616b",
          "baseAsset": {
            "id": "0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48"
          },
          "bridgeAsset": [
            {
              "id": "0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2"
            },
            {
              "id": "0xd7c9f0e536dc865ae858b0c0453fe76d13c3beac"
            }
          ],
          "marketAssets": [
            {
              "inputToken": {
                "id": "0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48",
                "symbol": "USDC",
                "decimals": 6,
                "lastPriceUSD": "1"
              },
              "liquidationThreshold": "95"
            },
            {
              "inputToken": {
                "id": "0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2",
                "symbol": "WETH",
                "decimals": 18,
                "lastPriceUSD": "2305.352727896261500078058211416915"
              },
              "liquidationThreshold": "85"
            },
            {
              "inputToken": {
                "id": "0xd7c9f0e536dc865ae858b0c0453fe76d13c3beac",
                "symbol": "XAI",
                "decimals": 18,
                "lastPriceUSD": "1"
              },
              "liquidationThreshold": "0.0000000010000001"
            }
          ]
        },
        "totalCollateralValue": "1.566198517392905748554136812741513",
        "totalBorrowValue": "1.383886075078367030058811365786744",
        "riskFactor": "0.9301006022645697940054184730355017",
        "riskScore": "1.287153271895940825645103195103763",
        "collateralPositions": [
          {
            "sTokenBalance": "1553879",
            "sToken": {
              "derivativeConversion": "1.007928234690671376956723665575964"
            },
            "marketAsset": {
              "inputToken": {
                "id": "0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48"
              }
            },
            "snapshots": [
              {
                "blockNumber": "17070774",
                "hash": "0xdfef5f4fa8adaf7a9ea368f9a2277e8c68a3dd8dd5143d874db3fe25b6e6e1ef"
              }
            ]
          }
        ],
        "collateralOnlyPositions": [],
        "debtPositions": [
          {
            "dTokenBalance": "1353165622720189675",
            "dToken": {
              "derivativeConversion": "1.022702655050031368072024642431499"
            },
            "marketAsset": {
              "inputToken": {
                "id": "0xd7c9f0e536dc865ae858b0c0453fe76d13c3beac"
              }
            },
            "snapshots": [
              {
                "blockNumber": "17070769",
                "hash": "0xeb87fec36cbee9e2db74ee239af72ab7cf3af6abbd00606e987f35f5944d905e"
              }
            ]
          }
        ]
      },
      {
        "id": "0xf5ffabab8f9a6f4f6de1f0dd6e0820f68657d7db-0xa896969811e0b3a5fd8e86de238e68122b603c61",
        "account": {
          "id": "0xa896969811e0b3a5fd8e86de238e68122b603c61"
        },
        "silo": {
          "id": "0xf5ffabab8f9a6f4f6de1f0dd6e0820f68657d7db",
          "baseAsset": {
            "id": "0x64aa3364f17a4d01c6f1751fd97c2bd3d7e7f1d5"
          },
          "bridgeAsset": [
            {
              "id": "0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2"
            },
            {
              "id": "0xd7c9f0e536dc865ae858b0c0453fe76d13c3beac"
            }
          ],
          "marketAssets": [
            {
              "inputToken": {
                "id": "0x64aa3364f17a4d01c6f1751fd97c2bd3d7e7f1d5",
                "symbol": "OHM",
                "decimals": 9,
                "lastPriceUSD": "13.52469934274851891265588117004675"
              },
              "liquidationThreshold": "85"
            },
            {
              "inputToken": {
                "id": "0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2",
                "symbol": "WETH",
                "decimals": 18,
                "lastPriceUSD": "2305.352727896261500078058211416915"
              },
              "liquidationThreshold": "90"
            },
            {
              "inputToken": {
                "id": "0xd7c9f0e536dc865ae858b0c0453fe76d13c3beac",
                "symbol": "XAI",
                "decimals": 18,
                "lastPriceUSD": "1"
              },
              "liquidationThreshold": "90"
            }
          ]
        },
        "totalCollateralValue": "2.942820387334544315674251472843072",
        "totalBorrowValue": "2.443595771605127424549345226178442",
        "riskFactor": "0.9226204985462228904845042411876295",
        "riskScore": "2.254511549043764869333039473897119",
        "collateralPositions": [
          {
            "sTokenBalance": "1276516322957659",
            "sToken": {
              "derivativeConversion": "1"
            },
            "marketAsset": {
              "inputToken": {
                "id": "0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2"
              }
            },
            "snapshots": [
              {
                "blockNumber": "17698968",
                "hash": "0x9f50fb25c0a20c47535c482ed732136675a9776951fda62c5e723e0d0750eaee"
              }
            ]
          }
        ],
        "collateralOnlyPositions": [],
        "debtPositions": [
          {
            "dTokenBalance": "147316360",
            "dToken": {
              "derivativeConversion": "1.226452593949547014247518707673039"
            },
            "marketAsset": {
              "inputToken": {
                "id": "0x64aa3364f17a4d01c6f1751fd97c2bd3d7e7f1d5"
              }
            },
            "snapshots": [
              {
                "blockNumber": "17698964",
                "hash": "0x04172338503514e781b16de4f8b0e3c76542808daf5fa9e8e7ee1dd03935f158"
              }
            ]
          }
        ]
      }
    ]
  }
```

{% endtab %}
{% endtabs %}

## Interest rate example, can also be applied to InterestRateHourly

{% tabs %}
{% tab title="Request" %}

```graphql
{
  market(id: "0xa8897b4552c075e884bdb8e7b704eb10db29bf0d") {
    id
    name
    rates {
      side
      token {
        id
        symbol
      }
      interestRateDaily(first: 10, orderBy: day, orderDirection: desc) {
        day
        timestamp
        rateHigh
        rateLow
        rateAvg
        rateLast
      }
    }
  }
}
```

{% endtab %}

{% tab title="Response" %}

```javascript

{
  "data": {
    "market": {
      "id": "0xa8897b4552c075e884bdb8e7b704eb10db29bf0d",
      "name": "wstETH",
      "rates": [
        {
          "side": "BORROWER",
          "token": {
            "id": "0x5979d7b546e38e414f7e9822514be443a4800529",
            "symbol": "wstETH"
          },
          "interestRateDaily": [
            {
              "day": 19752,
              "timestamp": 1706572800,
              "rateHigh": "0.636866571384",
              "rateLow": "0.636866571384",
              "rateAvg": "0.636866571384",
              "rateLast": "0.636866571384"
            },
            {
              "day": 19751,
              "timestamp": 1706486400,
              "rateHigh": "0.6423874748352",
              "rateLow": "0.636866571384",
              "rateAvg": "0.6396450494629710376282782212086659",
              "rateLast": "0.636866571384"
            }
          ]
        },
        {
          "side": "BORROWER",
          "token": {
            "id": "0x82af49447d8a07e3bd95bd0d56f35241523fbab1",
            "symbol": "WETH"
          },
          "interestRateDaily": [
            {
              "day": 19752,
              "timestamp": 1706572800,
              "rateHigh": "2.7131967893088",
              "rateLow": "2.7038396512944",
              "rateAvg": "2.706718770683446153846153846153846",
              "rateLast": "2.7038396512944"
            },
            {
              "day": 19751,
              "timestamp": 1706486400,
              "rateHigh": "2.716033301136",
              "rateLow": "2.6671331411856",
              "rateAvg": "2.695745529019210946408209806157355",
              "rateLast": "2.7131967893088"
            }
          ]
        },
        {
          "side": "BORROWER",
          "token": {
            "id": "0xff970a61a04b1ca14834a43f5de4533ebddb5cc8",
            "symbol": "USDC"
          },
          "interestRateDaily": [
            {
              "day": 19752,
              "timestamp": 1706572800,
              "rateHigh": "6.7900824234432",
              "rateLow": "6.7679353812816",
              "rateAvg": "6.780472421452061538461538461538462",
              "rateLast": "6.7900824234432"
            },
            {
              "day": 19751,
              "timestamp": 1706486400,
              "rateHigh": "6.978896317368",
              "rateLow": "6.7211762918256",
              "rateAvg": "6.78817676165180387685290763968073",
              "rateLast": "6.7679353812816"
            }
          ]
        },
        {
          "side": "LENDER",
          "token": {
            "id": "0x5979d7b546e38e414f7e9822514be443a4800529",
            "symbol": "wstETH"
          },
          "interestRateDaily": [
            {
              "day": 19752,
              "timestamp": 1706572800,
              "rateHigh": "0.0493773650385694",
              "rateLow": "0.0493773512951291",
              "rateAvg": "0.04937735782541639230769230769230769",
              "rateLast": "0.0493773650385694"
            },
            {
              "day": 19751,
              "timestamp": 1706486400,
              "rateHigh": "0.050237072675083",
              "rateLow": "0.0493772732717314",
              "rateAvg": "0.04980976297993667924743443557582668",
              "rateLast": "0.0493773508713335"
            }
          ]
        },
        {
          "side": "LENDER",
          "token": {
            "id": "0x82af49447d8a07e3bd95bd0d56f35241523fbab1",
            "symbol": "WETH"
          },
          "interestRateDaily": [
            {
              "day": 19752,
              "timestamp": 1706572800,
              "rateHigh": "0.8961760473953493",
              "rateLow": "0.89000420911402",
              "rateAvg": "0.8919033774836127333333333333333333",
              "rateLast": "0.8900048865320267"
            },
            {
              "day": 19751,
              "timestamp": 1706486400,
              "rateHigh": "0.898050847972111",
              "rateLow": "0.8660033803007828",
              "rateAvg": "0.884734327989400857354618015963512",
              "rateLast": "0.8961756902195887"
            }
          ]
        },
        {
          "side": "LENDER",
          "token": {
            "id": "0xff970a61a04b1ca14834a43f5de4533ebddb5cc8",
            "symbol": "USDC"
          },
          "interestRateDaily": [
            {
              "day": 19752,
              "timestamp": 1706572800,
              "rateHigh": "4.6105271717526555",
              "rateLow": "4.5805080629061384",
              "rateAvg": "4.597496787585244830769230769230769",
              "rateLast": "4.6105271717526555"
            },
            {
              "day": 19751,
              "timestamp": 1706486400,
              "rateHigh": "4.8705019616179317",
              "rateLow": "4.5174246640835196",
              "rateAvg": "4.606543225966467343785632839224629",
              "rateLast": "4.5805076451297779"
            }
          ]
        }
      ]
    }
  }
}
```

{% endtab %}
{% endtabs %}

## Activity feed for a market

{% tabs %}
{% tab title="Request" %}

```graphql
query ActivityFeedBySilo(
  $Market: String = "0xac3333401e69574d433307b31f43a7826eb6f8fd"
) {
  events(
    first: 10
    orderBy: blockNumber
    orderDirection: desc
    where: { silo: $Market }
  ) {
    timestamp
    hash
    logIndex
    blockNumber
    id
    silo {
      id
    }
    asset {
      id
      symbol
    }
    amount
    amountUSD
    account {
      id
    }
    ... on Borrow {
      __typename
    }
    ... on Deposit {
      __typename
    }
    ... on Liquidate {
      __typename
    }
    ... on Repay {
      __typename
    }
    ... on Withdraw {
      __typename
    }
  }
}
```

{% endtab %}

{% tab title="Response" %}

```javascript
{
  "data": {
    "events": [
      {
        "timestamp": "1706120291",
        "hash": "0x119d7d6aa72432ff21b991870f7d77838377ff17bc92f6f4bc5817567fa9abf0",
        "logIndex": 163,
        "blockNumber": "19078233",
        "id": "0x119d7d6aa72432ff21b991870f7d77838377ff17bc92f6f4bc5817567fa9abf0-163",
        "silo": {
          "id": "0xac3333401e69574d433307b31f43a7826eb6f8fd"
        },
        "asset": {
          "id": "0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2",
          "symbol": "WETH"
        },
        "amount": "7868075660329299854",
        "amountUSD": "17603.92909864312688737739968775736",
        "account": {
          "id": "0x0a39b0b5279d70f7565a78ff59f702aa3b1ea56c"
        },
        "__typename": "Withdraw"
      },
      {
        "timestamp": "1706037959",
        "hash": "0xd7533c39f191ae937e6e2d56eafb478c06da2ec1e154cb9656685d3a2ed8f4dc",
        "logIndex": 163,
        "blockNumber": "19071439",
        "id": "0xd7533c39f191ae937e6e2d56eafb478c06da2ec1e154cb9656685d3a2ed8f4dc-163",
        "silo": {
          "id": "0xac3333401e69574d433307b31f43a7826eb6f8fd"
        },
        "asset": {
          "id": "0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2",
          "symbol": "WETH"
        },
        "amount": "1000000000000000000",
        "amountUSD": "2190.397447350112554485038763824315",
        "account": {
          "id": "0x5f205748ad7b643dfe71777493e55363879cfd7f"
        },
        "__typename": "Borrow"
      },
      {
        "timestamp": "1706037659",
        "hash": "0x994a673d20c184fca520c22d944300e2d2f67e4c38001789e3c01755108d6379",
        "logIndex": 352,
        "blockNumber": "19071414",
        "id": "0x994a673d20c184fca520c22d944300e2d2f67e4c38001789e3c01755108d6379-352",
        "silo": {
          "id": "0xac3333401e69574d433307b31f43a7826eb6f8fd"
        },
        "asset": {
          "id": "0xd7c9f0e536dc865ae858b0c0453fe76d13c3beac",
          "symbol": "XAI"
        },
        "amount": "2681349787519888639654",
        "amountUSD": "2681.349787519888639654",
        "account": {
          "id": "0x5f205748ad7b643dfe71777493e55363879cfd7f"
        },
        "__typename": "Repay"
      },
      {
        "timestamp": "1706035487",
        "hash": "0x8e7edce0569855c97591ba427d1cfa27b2a0c407e8e3285ae3c31492bd69085d",
        "logIndex": 292,
        "blockNumber": "19071234",
        "id": "0x8e7edce0569855c97591ba427d1cfa27b2a0c407e8e3285ae3c31492bd69085d-292",
        "silo": {
          "id": "0xac3333401e69574d433307b31f43a7826eb6f8fd"
        },
        "asset": {
          "id": "0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2",
          "symbol": "WETH"
        },
        "amount": "2460331170101647173",
        "amountUSD": "5447.528583581976694454702037776411",
        "account": {
          "id": "0x5f205748ad7b643dfe71777493e55363879cfd7f"
        },
        "__typename": "Borrow"
      },
      {
        "timestamp": "1706022539",
        "hash": "0x17a9c56a91d24779d634b68e5132327d21bad90a05c738e39395c57d2fa938da",
        "logIndex": 367,
        "blockNumber": "19070165",
        "id": "0x17a9c56a91d24779d634b68e5132327d21bad90a05c738e39395c57d2fa938da-367",
        "silo": {
          "id": "0xac3333401e69574d433307b31f43a7826eb6f8fd"
        },
        "asset": {
          "id": "0xd7c9f0e536dc865ae858b0c0453fe76d13c3beac",
          "symbol": "XAI"
        },
        "amount": "169471961174941922570444",
        "amountUSD": "169471.961174941922570444",
        "account": {
          "id": "0xc04f84a02cc65f14f4e8c982a7a467ee88c5311e"
        },
        "__typename": "Withdraw"
      },
      {
        "timestamp": "1706021675",
        "hash": "0x7fcf5ba6702d67cf44d23afd9758332dc4e116bdc39bc0d4b3c6c61fd0cfc7c7",
        "logIndex": 116,
        "blockNumber": "19070093",
        "id": "0x7fcf5ba6702d67cf44d23afd9758332dc4e116bdc39bc0d4b3c6c61fd0cfc7c7-116",
        "silo": {
          "id": "0xac3333401e69574d433307b31f43a7826eb6f8fd"
        },
        "asset": {
          "id": "0x4a220e6096b25eadb88358cb44068a3248254675",
          "symbol": "QNT"
        },
        "amount": "3250000000000000000000",
        "amountUSD": "331581.2585403913125212409169840359",
        "account": {
          "id": "0xf3fcaba0702b49c33664058ed6dc745ed6d393f1"
        },
        "__typename": "Withdraw"
      },
      {
        "timestamp": "1706021483",
        "hash": "0xa8f285261cc35a3e51809e4039edd1180f96117903fb209cf0b9b0eb1959a0e1",
        "logIndex": 143,
        "blockNumber": "19070077",
        "id": "0xa8f285261cc35a3e51809e4039edd1180f96117903fb209cf0b9b0eb1959a0e1-143",
        "silo": {
          "id": "0xac3333401e69574d433307b31f43a7826eb6f8fd"
        },
        "asset": {
          "id": "0xd7c9f0e536dc865ae858b0c0453fe76d13c3beac",
          "symbol": "XAI"
        },
        "amount": "156924329267870899364447",
        "amountUSD": "156924.329267870899364447",
        "account": {
          "id": "0xf3fcaba0702b49c33664058ed6dc745ed6d393f1"
        },
        "__typename": "Repay"
      },
      {
        "timestamp": "1706020391",
        "hash": "0xa30da887edaa6ba11891ed01b528597afd757e14bc1f7031dbae405613f242f6",
        "logIndex": 271,
        "blockNumber": "19069987",
        "id": "0xa30da887edaa6ba11891ed01b528597afd757e14bc1f7031dbae405613f242f6-271",
        "silo": {
          "id": "0xac3333401e69574d433307b31f43a7826eb6f8fd"
        },
        "asset": {
          "id": "0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2",
          "symbol": "WETH"
        },
        "amount": "8497614855983501807",
        "amountUSD": "18632.26522189283432615331390245473",
        "account": {
          "id": "0xf3fcaba0702b49c33664058ed6dc745ed6d393f1"
        },
        "__typename": "Repay"
      },
      {
        "timestamp": "1705728899",
        "hash": "0x6f57c3e0163f10bd3c07c09b2c00761778a1c469ee15ee7f9003e4675852e4c0",
        "logIndex": 164,
        "blockNumber": "19046015",
        "id": "0x6f57c3e0163f10bd3c07c09b2c00761778a1c469ee15ee7f9003e4675852e4c0-164",
        "silo": {
          "id": "0xac3333401e69574d433307b31f43a7826eb6f8fd"
        },
        "asset": {
          "id": "0xd7c9f0e536dc865ae858b0c0453fe76d13c3beac",
          "symbol": "XAI"
        },
        "amount": "22553136689219257663128",
        "amountUSD": "22553.136689219257663128",
        "account": {
          "id": "0x750aaa6b24f82faf710776a7d0bdea3cfe6cb064"
        },
        "__typename": "Withdraw"
      },
      {
        "timestamp": "1704830531",
        "hash": "0xcb5308c8ce81698567240be4736d801957a7241e7d8a83faf8fb88493a5c816c",
        "logIndex": 292,
        "blockNumber": "18971654",
        "id": "0xcb5308c8ce81698567240be4736d801957a7241e7d8a83faf8fb88493a5c816c-292",
        "silo": {
          "id": "0xac3333401e69574d433307b31f43a7826eb6f8fd"
        },
        "asset": {
          "id": "0x4a220e6096b25eadb88358cb44068a3248254675",
          "symbol": "QNT"
        },
        "amount": "547882313154235927965",
        "amountUSD": "61736.29915451742767388169947767397",
        "account": {
          "id": "0x57d3d0772fabccdd9be52ccb0da8e70dc64589dc"
        },
        "__typename": "Withdraw"
      }
    ]
  }
}
```

{% endtab %}
{% endtabs %}

## Week of metrics for a market

{% tabs %}
{% tab title="Request" %}

```graphql
query GetSiloMetricsWeek($silo: String = "CRV") {
  markets(where: { name: $silo }) {
    name
    dailySnapshots(orderBy: blockNumber, orderDirection: desc, first: 7) {
      dailyBorrowUSD
      dailyDepositUSD
      dailyLiquidateUSD
      dailyRepayUSD
      dailyWithdrawUSD
      timestamp
      totalBorrowBalanceUSD
      totalDepositBalanceUSD
      totalValueLockedUSD
    }
  }
}
```

{% endtab %}

{% tab title="Response" %}

```javascript
{
  "data": {
    "markets": [
      {
        "name": "CRV",
        "dailySnapshots": [
          {
            "dailyBorrowUSD": "0",
            "dailyDepositUSD": "0",
            "dailyLiquidateUSD": "0",
            "dailyRepayUSD": "0",
            "dailyWithdrawUSD": "273042.103393597947025428856075714",
            "timestamp": "1703152067",
            "totalBorrowBalanceUSD": "0",
            "totalDepositBalanceUSD": "-28161.045918982247698391937322368414",
            "totalValueLockedUSD": "28371.34018725441148948566523653374"
          },
          {
            "dailyBorrowUSD": "0",
            "dailyDepositUSD": "0",
            "dailyLiquidateUSD": "0",
            "dailyRepayUSD": "0",
            "dailyWithdrawUSD": "45749.06376813152434012275176141142",
            "timestamp": "1700475767",
            "totalBorrowBalanceUSD": "0",
            "totalDepositBalanceUSD": "-45645.610261003944948455363457239604",
            "totalValueLockedUSD": "309268.53956642940274617865844554"
          },
          {
            "dailyBorrowUSD": "0",
            "dailyDepositUSD": "44190.49744655230162757139485592844",
            "dailyLiquidateUSD": "0",
            "dailyRepayUSD": "0",
            "dailyWithdrawUSD": "0",
            "timestamp": "1700397731",
            "totalBorrowBalanceUSD": "0",
            "totalDepositBalanceUSD": "44293.53337290412840962713341505386",
            "totalValueLockedUSD": "263829.7074789957199261926226751454"
          },
          {
            "dailyBorrowUSD": "0",
            "dailyDepositUSD": "37300.27021281414521436632240523245",
            "dailyLiquidateUSD": "0",
            "dailyRepayUSD": "0",
            "dailyWithdrawUSD": "37300.27021281414521436632240523245",
            "timestamp": "1699614503",
            "totalBorrowBalanceUSD": "0",
            "totalDepositBalanceUSD": "37411.90682844212089014572308745332",
            "totalValueLockedUSD": "248552.0211957515698869587838495326"
          },
          {
            "dailyBorrowUSD": "0",
            "dailyDepositUSD": "0",
            "dailyLiquidateUSD": "0",
            "dailyRepayUSD": "14520.3716776996465247949538735491",
            "dailyWithdrawUSD": "0",
            "timestamp": "1696283231",
            "totalBorrowBalanceUSD": "29369.74515703264382151407838824996",
            "totalDepositBalanceUSD": "16540.20980002114382664653827306544",
            "totalValueLockedUSD": "239900.5777523712101101571712532575"
          },
          {
            "dailyBorrowUSD": "15231.99221322590538032037859688151",
            "dailyDepositUSD": "0",
            "dailyLiquidateUSD": "0",
            "dailyRepayUSD": "0",
            "dailyWithdrawUSD": "0",
            "timestamp": "1695918023",
            "totalBorrowBalanceUSD": "15231.99221322590538032037859688151",
            "totalDepositBalanceUSD": "32273.29928329608487263590682703001",
            "totalValueLockedUSD": "246654.5374347264186194517571316542"
          },
          {
            "dailyBorrowUSD": "0",
            "dailyDepositUSD": "0",
            "dailyLiquidateUSD": "0",
            "dailyRepayUSD": "14768.10388036167052671254042932216",
            "dailyWithdrawUSD": "0",
            "timestamp": "1695652943",
            "totalBorrowBalanceUSD": "29520.60681663771363720440956403727",
            "totalDepositBalanceUSD": "16963.81003153796650810817648088037",
            "totalValueLockedUSD": "242516.9016391561428020597063189442"
          }
        ]
      }
    ]
  }

```

{% endtab %}
{% endtabs %}

## Account based position info

{% tabs %}
{% tab title="Request" %}

```graphql
query QueryAccountPositions(
  $account: String = "0xc255e0a1be0a4b7b8bf5ebe8d0aba162cf75bae2"
) {
  positions(orderDirection: desc, where: { account: $account }) {
    account {
      id
    }
    depositCount
    balance
    blockNumberClosed
    blockNumberOpened
    borrowCount
    isCollateral
    liquidationCount
    repayCount
    side
    timestampClosed
    timestampOpened
    withdrawCount
  }
}
```

{% endtab %}

{% tab title="Response" %}

```javascript
{
  "data": {
    "positions": [
      {
        "account": {
          "id": "0xc255e0a1be0a4b7b8bf5ebe8d0aba162cf75bae2"
        },
        "depositCount": 0,
        "balance": "0",
        "blockNumberClosed": "0",
        "blockNumberOpened": "18834884",
        "borrowCount": 0,
        "isCollateral": true,
        "liquidationCount": 0,
        "repayCount": 0,
        "side": "LENDER",
        "timestampClosed": "0",
        "timestampOpened": "1703169479",
        "withdrawCount": 0
      },
      {
        "account": {
          "id": "0xc255e0a1be0a4b7b8bf5ebe8d0aba162cf75bae2"
        },
        "depositCount": 0,
        "balance": "0",
        "blockNumberClosed": "0",
        "blockNumberOpened": "18834888",
        "borrowCount": 0,
        "isCollateral": true,
        "liquidationCount": 0,
        "repayCount": 0,
        "side": "BORROWER",
        "timestampClosed": "0",
        "timestampOpened": "1703169527",
        "withdrawCount": 0
      }
    ]
  }
}

```

{% endtab %}
{% endtabs %}


# Contact Us

The fastest way to get in touch with the core contributors team is via the following channels:&#x20;

* For security-related issues, email us at <security@silo.finance>
* DM at Twitter <https://twitter.com/SiloFinance>
* Join Discord and drop a line in the #General channel <https://discord.gg/silo-finance>
* Get in touch with core contributor Aiham\_eth through [Telegram](http://t.me/aiham_eth) or [Twitter](https://twitter.com/aiham_eth)
* Email us at <info@silo.finance>


