# Overview

Tydro Powers Flexible, Institutional Grade Lending Markets on Ink offering Fixed Rate Loans, Isolated and Cross Margin Borrowing, and Qualified Custodian Support via Kraken Custody.

### What is Tydro?

The Tydro App hosts lending markets, letting users lend assets to earn interest and borrow assets against posted collateral. The protocol is built on the Aave V3 codebase that has processed over $20B+ of loans and runs on the Ink network, an Ethereum Layer 2 blockchain with native exchange integrations and compliance layer.

Tydro V2 powers on chain SOFR, offering fixed-rate, floating-term overcollateralized loans.

* Borrowers lock in a set rate that does not change, with no maturity date, so the cost of holding a position stays predictable regardless of utilization or market swings.&#x20;
* Suppliers earn a floating yield that moves with the market.
* Borrowers post collateral against the assets they want to borrow.

At launch, Tydro V2 offers a fixed-rate secured loan facility against kBTC with instant liquidity for borrowers and lenders. As additional markets, allocators, and vaults go live, the collateral set will expand to include assets such as tokenized equities, gold, RWAs, and other assets held in qualified custody. Over time additional vault products, fixed-term lending facilities, fixed rate products, and more will be developed alongside Tydro's partners and surfaced on the app.tydro.com interface. Current and future security audits will be hosted on the [audit reports](/vi.-security/audit-reports) page.&#x20;

> **Important note**: [tydro.com](https://tydro.com) is the only official URL of the tydro app and documentation, always verify the [official URLs](/vii.-developers/developer-overview/official-links), protocol [contract addresses](/vii.-developers/developer-overview/smart-contracts) and {# website status page link } before interacting to mitigate potential phishing attempts. The team will never ask you to use another interface or ask for sensitive information such as private keys or personal information.

<table><thead><tr><th width="188.37493896484375">Item</th><th>Definition</th></tr></thead><tbody><tr><td><strong>Tydro Protocol</strong></td><td>Open source lending smart contracts running on Aave 3.7 managed by Tydro Governance and Risk Stewards</td></tr><tr><td><strong>Tydro App</strong></td><td>Web interface maintained by the Tydro team, hosted at <a href="https://app.tydro.com">app.tydro.com</a></td></tr><tr><td><strong>Tydro Integrations</strong></td><td>External interfaces that access the protocol. These are not managed or controlled by the Tydro team, exercise caution and research providers</td></tr></tbody></table>

{% hint style="info" %}
**Tydro is supported by a set of service providers, all of whom do not provide investment, legal, or tax advice. Read the** [**Risk Overview & Disclosures**](/v.-risk/disclosures) **carefully before using the protocol.**
{% endhint %}

### Who is this documentation for?

* **Lenders** who supply assets and want to understand rates and risk.
* **Borrowers** who post collateral to open and manage a position.
* **Users** evaluating Tydro's [security](/vi.-security/security-overview), [management](/ii.-core-concepts/protocol-governance), setup, function, [qualified custody](/iv.-tydro-institutional/institutional-overview/qualified-custody), liquidity, [interest rate models](/ii.-core-concepts/interest-rates), and [permissioned markets](/iv.-tydro-institutional/institutional-overview/permissioned-markets).
* **Developers** looking to integrate Tydro's liquidity, flash loans, swaps, or other products.

### Where to start?

* **New to lending?** start with [Lending & Borrowing Basics](/i.-introduction/overview/lending-and-borrowing-basics).
* **Ready to use the protocol?** see *Section III. Using Tydro.*
* **Evaluating the design?** start with the [Tech Stack](/i.-introduction/overview/tech-stack) and [Markets](/ii.-core-concepts/markets).
* **Building on Tydro?** visit the [Developers](/vii.-developers/developer-overview) section.


# Tech Stack

Overview of the components of the Tydro Protocol

### Lending Engine

Tydro is built on the Aave V3 codebase. Aave V3 is open source, audited, and has over $10B of deposits across multiple networks. Tydro inherits a battle-tested lending implementation without new core logic. Markets, rate models, liquidation flows, and position accounting all follow Aave V3.

For how the markets are configured, see [Markets](/ii.-core-concepts/markets) and [Interest Rates](/ii.-core-concepts/interest-rates).

### Network

Tydro runs on Ink, an Ethereum Layer 2 built on the OP Stack and part of the Optimism Superchain. Ink is deployed by Kraken, providing the settlement layer for the protocol and adds chain-level monitoring and security tooling.

Tydro's security stack includes real-time monitoring and threat response from [Hypernative](https://www.hypernative.io), alongside best practices in risk modeling, frontend, smart contract, operational security, and external audits.&#x20;

### Qualified Custodian

Tydro integrates with Kraken custody, allowing eligible users to borrow, lend, and hold assets within a qualified custodian. See [Qualified Custody](/iv.-tydro-institutional/institutional-overview/qualified-custody).

### Asset Managers & Vaults

External managers can run strategies and deploy capital through vaults. A manager can also post first-loss capital where a strategy provides coverage for its depositors. Vaults are planned. See [Vaults](/vii.-developers/developer-overview/smart-contracts/vaults) and [Institutional Overview](/iv.-tydro-institutional/institutional-overview).


# Lending & Borrowing Basics

A short primer on the mechanics behind Tydro

### Supplying

When a lender supplies an asset to a market, it becomes available for borrowers, and the lender earns interest paid by borrowers. Supplied assets are not locked. A lender can withdraw as long as the market holds enough free liquidity.

### Borrowing

To borrow, a borrower first posts collateral. The borrower can then borrow another asset up to a limit set by the collateral's loan-to-value ratio. Borrowing accrues interest, which the borrower repays with the principal.

In Tydro's launch market, a borrower posts kBTC as collateral and borrows USDC. See [Isolated Markets](/ii.-core-concepts/markets/isolated-markets).

### Collateral and health

Each collateral asset carries two key parameters:

* **Loan-to-value (LTV):** the most a borrower can borrow against the asset, as a share of its value.
* **Liquidation threshold (LT):** the point at which a position becomes eligible for liquidation.

A borrower's position has a health factor that summarizes how close it is to liquidation. Above 1 is safe. At or below 1, the position can be liquidated.&#x20;

### Interest rates

Borrow and supply rates move with utilization, the share of supplied liquidity currently borrowed. Rates rise as utilization rises. The curve is set per market.&#x20;

Tydro V2's first launch market use a flat borrow rate that does not change with utilization, so a borrower holds a fixed rate with no maturity. The supply side floats: a lender earns a yield that varies with utilization, the share of supplied liquidity currently borrowed.&#x20;

### Liquidation

If a position's health factor falls to 1 or below, a liquidator can repay part of the debt and receive an equivalent amount of collateral plus a bonus. This keeps the market solvent. See [Liquidations](/ii.-core-concepts/liquidations-and-risk-management).

{% hint style="warning" %}
Borrowing carries liquidation risk. If your collateral falls in value or your debt grows, you can lose collateral to liquidation. Monitor your health factor.
{% endhint %}


# Glossary

Overview of key terms in the documentation

| Term                       | Definition                                                                                                                                                                                                                                                        |
| -------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| Aave V3                    | The open-source lending protocol Tydro is built on. Provides the core market, interest rate, and liquidation logic.                                                                                                                                               |
| APY                        | Annual Percentage Yield. The yield earned over a year including compounding. Differs from APR, which does not account for compounding.                                                                                                                            |
| aTokens                    | Interest-bearing tokens a lender receives when supplying assets to Tydro. aTokens represent the lender's share of the liquidity pool and accrue interest in real time.                                                                                            |
| Borrow                     | To take a loan of an asset against posted collateral, repaid with interest.                                                                                                                                                                                       |
| Borrow cap                 | A limit on the maximum amount of a specific asset that can be borrowed from the protocol. Helps manage exposure and reduce systemic risk.                                                                                                                         |
| Cluster                    | A planned market type that groups related assets so they can share collateral and margin within defined limits. See Clusters.                                                                                                                                     |
| Collateral                 | An asset a borrower posts to back a borrowing position. The collateral value must exceed the borrowed amount to keep the position solvent. In the launch market, collateral is kBTC.                                                                              |
| Cooldown period            | A mandatory waiting period before staked tokens can be unstaked from a staking or safety module.                                                                                                                                                                  |
| Credit delegation          | A feature that lets one user delegate borrowing power to another, so the delegate can borrow against the delegator's collateral through Tydro's smart contracts. \[ FLAG: confirm enabled at launch; Aave V3 feature that may not be live in the launch market. ] |
| Debt ceiling               | The maximum debt that can be issued against an isolated asset, used to limit exposure to a single collateral type.                                                                                                                                                |
| E-Mode                     | Efficiency Mode. Lets borrowers access higher borrowing power when using correlated assets, such as stablecoins.                                                                                                                                                  |
| Flash loan                 | An uncollateralized loan that must be borrowed and repaid within a single transaction block.                                                                                                                                                                      |
| GHO                        | Aave’s native decentralized stablecoin, pegged to the US dollar.                                                                                                                                                                                                  |
| Health factor              | A ratio summarizing how close a borrower's position is to liquidation, comparing collateral value against borrowed value. Above 1 is safe. At or below 1, the position can be liquidated.                                                                         |
| Ink                        | The Ethereum Layer 2 network Tydro runs on and transactions settle on. Built on the OP Stack and deployed by Kraken.                                                                                                                                              |
| Isolated market            | A market with one collateral asset and one loan asset, with risk contained to that market.                                                                                                                                                                        |
| Isolation mode             | An Aave V3 mode that restricts a collateral asset to isolated use with a debt ceiling, capping debt against a single collateral type.                                                                                                                             |
| kBTC                       | A token that represents bitcoin, used as collateral in the launch market.                                                                                                                                                                                         |
| Kraken                     | A cryptocurrency exchange and custody provider. Developed Ink and provides the custody integration in the Tydro stack.                                                                                                                                            |
| Liquidation                | The process triggered when a borrower's health factor falls to 1 or below. A liquidator repays part of the debt in exchange for collateral plus a bonus, restoring the position to a safer level and keeping the market solvent.                                  |
| Liquidation bonus          | The discount a liquidator receives on collateral when liquidating a position, expressed as a percentage. Set per market.                                                                                                                                          |
| Liquidation threshold (LT) | The collateral-to-debt ratio at which a position becomes eligible for liquidation. Defined per asset.                                                                                                                                                             |
| Liquidity index            | Tracks the cumulative interest earned by a reserve over time, used to calculate interest accrual accurately.                                                                                                                                                      |
| Loan-to-value (LTV)        | The maximum a borrower can borrow against a collateral asset, as a share of its value. For example, a 75% LTV means collateral worth 1 unit allows borrowing up to 0.75 units.                                                                                    |
| Market                     | A venue pairing collateral with a borrowable asset under a defined set of parameters.                                                                                                                                                                             |
| Network risk               | Risk associated with the underlying network where Tydro is deployed, such as congestion, security vulnerabilities, or downtime.                                                                                                                                   |
| Oracle                     | A service that provides external data such as asset prices to Tydro, used to value collateral and debt and to trigger liquidations. Tydro uses Chainlink.                                                                                                         |
| Ray units                  | A unit of precision with 27 decimals used internally by Tydro for calculations such as interest and exchange rates.                                                                                                                                               |
| Reserve factor             | The share of borrow interest allocated to the protocol reserve rather than paid to suppliers, supporting long-term sustainability.                                                                                                                                |
| Risk admin                 | An entity responsible for adjusting risk parameters such as LTVs, borrow caps, and liquidation thresholds to keep the protocol aligned with market conditions.                                                                                                    |
| Safety module              | A staking mechanism where tokens are staked as insurance against a shortfall event, with stakers earning rewards but exposed to slashing.                                                                                                                         |
| Siloed borrowing           | A restriction that allows certain assets to be borrowed only in isolation, mitigating risks from illiquid or volatile assets.                                                                                                                                     |
| Superchain                 | A network of OP Stack chains that share standards and interoperability. Ink is part of the Optimism Superchain.                                                                                                                                                   |
| Supply                     | To deposit an asset into a market to earn interest from borrowers.                                                                                                                                                                                                |
| Supply cap                 | A limit on the total amount of a specific asset that can be supplied to the protocol. Helps control exposure to risky assets.                                                                                                                                     |
| Tranche                    | A planned position type that splits a loan into senior and junior claims, where junior capital absorbs losses first. See Tranching.                                                                                                                               |
| USDC                       | A US dollar stablecoin. The loan asset in the launch market.                                                                                                                                                                                                      |
| Utilization                | The ratio of borrowed assets to total supplied liquidity in a reserve. Higher utilization indicates stronger borrowing demand.                                                                                                                                    |
| Vault                      | A planned product where managers deploy capital and run strategies on top of Tydro markets, following the ERC-4626 standard or an equivalent. See [Vaults](/vii.-developers/developer-overview/smart-contracts/vaults).                                           |


# Markets

How collateral is valued and loans are taken from Tydro markets

A market defines what asset(s) can be used as collateral, what can be borrowed, how much, and the risk, interest rate model, oracle (price feed), and liquidation rules surrounding the position.&#x20;

### Market structure

Tydro v1 was built on Aave v3 supporting a pooled collateral market and segragated corrleated lending strategies such as ETH lending and USDe. Each market used&#x20;

Tydro v2 launches with further market isolation, where risk is priced per market and not shared across a larger lending pool. See [Isolated Markets](/ii.-core-concepts/markets/isolated-markets).

Clusters and pools group correlated assets so they can share collateral and margin within set limits. See [Clusters and Pooled Markets](/ii.-core-concepts/markets/clusters-and-pooled-markets).

### What a market defines

* Collateral asset and loan asset.
* Risk parameters: LTV, liquidation threshold, and caps. See [Risk Parameters](/ii.-core-concepts/risk-paramaters).
* An interest rate model, flat or kinked. See [Interest Rates](/ii.-core-concepts/interest-rates).
* Oracle sources. See [Oracles](/vii.-developers/developer-overview/smart-contracts/oracles).

### Markets reference

On-chain values are authoritative. Asset contract addresses are listed here; oracle feed and CAPO adapter addresses live on the Oracles page, and this table references the feeds by name.


# Isolated Markets

## Isolated Markets

An isolated market pairs one collateral asset with one borrowable asset and contains risk to that market. This page describes how isolated markets work and documents Tydro's launch market.

### How isolation works

In an isolated market, the posted collateral backs borrowing of a single loan asset, and risk does not cross into other markets. If the collateral asset comes under stress, the effect stays within that market rather than spreading across the protocol.

Each market keeps its own parameters and oracle configuration. A new asset can be listed in its own market without changing the risk profile of existing markets.

### Initial market: kBTC / USDC

At launch, Tydro operates one isolated market. kBTC is posted as collateral and USDC is borrowed against it.

* **Collateral:** kBTC, Kraken Wrapped Bitcoin, issued by Kraken and backed 1:1 by BTC held in Kraken's segregated custody. Contract address `0x73E0C0d45E048D25Fc26Fa3159b0aA04BfA4Db98` (8 decimals).&#x20;
* **Loan asset:** USDC. Contract address `0x2d270e6886d130d724215a266106e6832161eaed`.
* **Interest rate model:** fixed borrow rate, set through a flat model and held by governance. The borrow rate does not climb with utilization and there is no kink. See [Interest Rates](/ii.-core-concepts/interest-rates).
* **Term:** open-ended. The loan has no maturity date, so the position can be repaid or exited at any time.
* **Oracle:** Chainlink BTC/USD and USDC/USD feeds, routed through the TydroOracle contract. See the [Oracles](/vii.-developers/developer-overview/smart-contracts/oracles) reference for addresses.

A fixed borrow rate paired with an open-ended term is what sets this market apart from a standard variable pool. The cost is set up front and held for as long as the position is open.

### Parameters

On-chain values are authoritative. See the [Markets](/ii.-core-concepts/markets) reference for live parameters and addresses.

### Borrowing in this market

1. Post kBTC as collateral.
2. Borrow USDC up to the market LTV, at the fixed borrow rate.
3. Monitor the position's health factor. See [Using Tydro](/iii.-using-tydro/before-you-start).
4. Repay USDC and withdraw kBTC to close the position, on any schedule.

> **Warning:** This market borrows USDC against kBTC. A fall in the kBTC price relative to USDC lowers the position's health factor and can lead to liquidation. See [Liquidation Risk](/v.-risk/risk-types-and-overview/liquidation-risk).


# Clusters and Pooled Markets

### Clusters

A cluster groups assets that move together, so one position can draw on several of them at once. Borrowing capacity reflects the combined collateral in the cluster, weighted by each asset's parameters, rather than one asset standing alone. This is cross-asset margin: post a mix of correlated collateral and borrow against the whole.

Each cluster sets its own parameters and caps, so exposure stays managed at the group level. Each asset is priced by its own oracle feed, and the cluster's combined collateral value updates as those feeds move.

Asset isolation and borrow configurations are managed using [Efficiency Mode (eMode)](/ii.-core-concepts/markets/efficiency-mode-emode).

### Pools

A pool widens the boundary further, sharing liquidity across a defined set of assets so suppliers and borrowers meet in one venue rather than many. Suppliers provide liquidity that any borrower in the pool can draw on, and borrowers gain access to deeper liquidity than a single market offers. Pools suit strategies where breadth of liquidity matters more than tight isolation.

### Comparison

| Dimension          | Isolated market                | Cluster                               | Pool                              |
| ------------------ | ------------------------------ | ------------------------------------- | --------------------------------- |
| Risk scope         | one collateral, one loan asset | a group of correlated assets          | a defined set sharing one venue   |
| Margin             | single-asset                   | cross-asset, shared                   | shared liquidity                  |
| Capital efficiency | lowest                         | higher                                | highest                           |
| Risk containment   | strongest                      | group level                           | broadest                          |
| Best suited to     | listing new or volatile assets | borrowing against correlated holdings | strategies needing deep liquidity |

### Choosing the right structure

Isolated markets keep risk inside one collateral asset. Clusters and pools relax that boundary on purpose, in exchange for capital efficiency across assets that already track each other. The cost of that efficiency is shared exposure: stress in one asset can reach the others in the same group. Tydro sizes caps and parameters per cluster to keep that exposure inside set limits.

{% hint style="info" %}
Correlated assets are not identical assets. If an asset in a cluster de-pegs or breaks from the group, shared margin can transmit that stress to other positions in the same cluster. See [Market and Collateral Risk](/v.-risk/risk-types-and-overview/market-and-collateral-risk).
{% endhint %}

On-chain values are authoritative. See the [Markets](/ii.-core-concepts/markets) reference for live parameters and addresses.


# Efficiency Mode (eMode)

Efficiency Mode (eMode) unlocks higher borrowing power when collateral and debt are correlated assets, for example, borrowing one stablecoin against another

In standard mode, each asset's loan-to-value (LTV) is set individually. eMode overrides those per-asset LTVs with a higher, category-level LTV for assets that share a category, reflecting their lower relative price risk.

### How it works

Each eMode category groups assets that are expected to track each other in price. Activating an eMode category applies that category's custom LTV and liquidation threshold to the position, instead of the default per-asset values.

A position in an active eMode category can only borrow assets that belong to that category. Attempting to borrow an out-of-category asset reverts. Switching categories is also blocked if it would push the health factor below the liquidation threshold.

Category 0 is reserved and represents the default non-eMode state.

### Activating eMode

Enable an eMode category:

```solidity
setUserEMode(categoryId)
```

Check the category currently active for an address:

```solidity
getUserEMode(userAddress)
```

Retrieve all available categories and their parameters (LTV, liquidation threshold, eligible assets):

```solidity
getEModes(provider)        // via UiPoolDataProvider
getEModeCategoryData(id)   // via Pool
```

### eMode categories

| Category | Label       | LTV            | Assets      |
| -------- | ----------- | -------------- | ----------- |
| 1        | STABLECOINS | query on-chain | USDG, USDT0 |

The exact LTV and asset bitmaps for each category are set by governance and can change. Query `getEModes(provider)` for current values.

### Credit delegation and eMode

If a delegator is in eMode, delegated borrowing is restricted to assets within that same category. A delegatee cannot borrow assets outside a delegator's active eMode. See [Credit Delegation](/vii.-developers/credit-delegation).&#x20;


# Interest Rates

How borrower and lender interest rates are determined

### Utilization

Utilization is the share of supplied liquidity that is currently borrowed. When most of the supplied asset is borrowed, utilization is high. When little is borrowed, it is low.

The supply rate responds to utilization in every market, which keeps borrowing and supply in balance and preserves liquidity for withdrawals. Whether the borrow rate moves with utilization depends on the market's rate model of Fixed or Variable.

### Fixed borrow rate model

The kBTC / USDC market uses a flat interest rate. The borrow rate is constant across all utilization levels: it does not climb as more of the pool is borrowed, and there is no kink. A borrower locks a known cost and keeps it, with no maturity date and no rollover cost. The rate changes only through governance decisions that are implemted through a timelock.

This differs from a standard variable pool: the borrow rate is fixed and the supply rate floats with utilization. A borrower sets the cost up front and chooses when to exit.

#### Supply rate

Suppliers earn from the interest borrowers pay. The supply rate is the borrow rate scaled by utilization, after the reserve factor share is removed. Suppliers earn more as more of the pool is in use, and less when liquidity sits idle. Even in a market with a fixed borrow rate, the supplier yield still moves with changes in capital utilization.

Because of the flat borrow rate in Tydro V2, suppliers earn more at all levels below the optimal utilization level.&#x20;

It rises as utilization rises and stays below the borrow rate. At 0% utilization the supply rate is zero. Because the launch market holds the borrow rate at a fixed level rather than starting near zero, the supply rate earns from the first dollar borrowed — at low utilization it can sit above what a standard kinked curve would pay at the same utilization.

### The variable model

Tydro also supports the standard Aave linear model for markets that use a variable borrow rate. The borrow rate follows two slopes that meet at a target utilization point called the kink.

* **Slope 1** — applies below the optimal utilization point. Rates rise gradually as utilization increases.
* **Optimal utilization (kink)** — the target utilization the model is tuned around.
* **Slope 2** — applies above the kink. Rates rise steeply to discourage further borrowing and protect withdrawal liquidity. At 100% utilization no liquidity remains available for withdrawal; Slope 2 exists to push utilization back toward the target before that point is reached.

Below the kink, borrowing stays relatively cheap. Once utilization passes the kink, the second slope raises rates sharply, which drives utilization back toward the optimal target.

### Rate accrual

Interest accrues on a continual basis (per block) and is represented by an increasing aToken balance.

### Parameters

| Parameter                  | Description                                                                          |
| -------------------------- | ------------------------------------------------------------------------------------ |
| Rate model                 | Flat (fixed borrow rate) or kinked (variable).                                       |
| Fixed borrow rate          | Af fixed interest rate across utilization levels.                                    |
| Base rate                  | Y-intercept of Borrow rate at 0% utilization, set to 0 in standard variable markets. |
| Slope 1                    | Rate slope below the kink, for variable markets.                                     |
| Optimal utilization (kink) | Target utilization where the slope changes, for variable markets.                    |
| Slope 2                    | Rate slope above the kink, for variable markets.                                     |
| Reserve factor             | Share of interest routed to the protocol reserve.                                    |

Per-market values are in the Markets interface at [app.tydro.com](https://app.tydro.com). Rate parameters can be changed through governance. See [Protocol Governance](/ii.-core-concepts/protocol-governance) for more details on market management.


# Asset Price Feeds (Oracles)

Tydro prices collateral and debt using external price feeds. This page describes the oracle sources. Reliability and fallback are covered in Oracle reliability

### Why oracles matter

The protocol needs an accurate price for every asset to value collateral and debt and to know when a position's health factor has reached the liquidation point. Those prices come from oracles. A wrong or stale price can value positions incorrectly, which is why Tydro uses established feeds and validates them before acting.

### Sources

Tydro prices assets from Chainlink, routed through the AaveOracle contract (`0x4758213271BFdC72224A7a8742dC865fC97756e1`). The feeds are live and in daily use.

{% hint style="info" %}
A multi-source redundancy layer that cross-checks independent providers is on the roadmap, not live today. See [Price Feed Security](/vi.-security/security-overview/technical-security/price-feed-security) for what protects price feeds now.
{% endhint %}


# Liquidations & Risk Management

How the Tydro Protocol operates to manage risk through an open market liquidation process

## Overview

Liquidation keeps every market solvent by closing positions that fall below their safety threshold. Tydro uses the Aave V3 permissionless liquidation model.&#x20;

### Health Factor

Each borrow position has a health factor, which represents a position's collateral value relative to its debt and distance from liquidation. Positions with a Health Factor below 1 can be liquidated.&#x20;

$$
\text{Health Factor} = \frac{\sum \left( \text{Collateral} \times \text{Liquidation Threshold} \right)}{\text{Total Debt}}
$$

### When liquidations occur

While the Health remains above 1, the position can not be liquidated. When it reaches 1 or below, the position becomes eligible for liquidation. A health factor drops for two reasons: collateral falls in value, or debt grows as interest accrues.&#x20;

### How a liquidation runs

1. A position's health factor reaches 1 or below
2. A liquidator repays part of the outstanding debt on the position's behalf
3. In return, the liquidator receives an equal value of the position's collateral, plus the liquidation bonus
4. The repayment lowers the debt and lifts the health factor back above 1<br>

Liquidation is permissionless. Anyone running a bot can participate to earn the liquidation bonus.

### Avoiding liquidation

Add collateral or repay debt to raise the position's health factor before it reaches the threshold. Borrow at a manageable LTV and monitor your positions actively in times of market stress.

### OTC loan liquidations

OTC loans have LT and LTV triggers negotiated and managed at the custodian level, and do not directly interact with the Tydro smart contracts for permissionless liquidations like other markets. <br>


# Risk Paramaters

How risk parameters impact markets

### Loan-to-value (LTV)

LTV caps borrowing against a collateral asset, as a share of its value. A higher LTV allows more borrowing per unit of collateral and leaves a smaller buffer.&#x20;

### Liquidation threshold (LT)

LT is the point at which a position becomes eligible for liquidation, measured as a collateral ratio. The gap between LTV and LT is the buffer a borrower has before liquidation. See [Health Factor + Position Management](/iii.-using-tydro/health-factor-+-position-management).

### Liquidation bonus

The liquidation bonus is the discount a liquidator receives on collateral when closing part of an unhealthy position. It compensates liquidators for acting and is set per market. See [Liquidations](/ii.-core-concepts/liquidations-and-risk-management).

### Supply and borrow caps

Caps limit the total that can be supplied or borrowed in a market.<br>

* Supply cap: the maximum amount of an asset the market accepts as deposits.
* Borrow cap: the maximum amount of an asset that can be borrowed.

Caps contain concentration and let a market scale exposure in a controlled way.

### Where values are set

Parameters are set per market and can be adjusted through governance within defined limits. On-chain values are authoritative; the [Markets](/ii.-core-concepts/markets) reference lists current figures.

| Parameter             | What it controls                  |
| --------------------- | --------------------------------- |
| LTV                   | Maximum borrow against collateral |
| Liquidation threshold | Liquidation eligibility point     |
| Liquidation bonus     | Liquidator's collateral discount  |
| Supply cap            | Maximum deposits in the market    |
| Borrow cap            | Maximum borrowing in the market   |


# Protocol Governance

How the Tydro Protocol is maintained

## Governance

Governance sets market parameters, lists new markets, and holds the powers needed to keep the protocol safe. Tydro uses the Aave V3 governance roles. This page maps the roles and what each one can do.

### The governance body

Tydro's parameters, listings, and upgrades are managed by a Tydro governance body that operates through a multisig, with directors who review risk reports and approve listings. The body is made up of service providers, risk and security contributors, and other participants.

### Roles

Tydro splits authority across scoped roles, so routine adjustments, emergency action, and structural changes are handled by the right party with the right limits.

| Role         | What it does                                            | Scope                                                                                        |
| ------------ | ------------------------------------------------------- | -------------------------------------------------------------------------------------------- |
| Risk Steward | Adjusts risk parameters within preset bounds            | Fast, bounded changes such as caps and rate settings, without a full governance cycle. Live. |
| Guardian     | Pauses a market or the protocol in an emergency         | Protective only. Cannot move funds or change parameters. Live.                               |
| Governance   | Lists markets, sets parameter ranges, controls upgrades | The broad authority behind the protocol.                                                     |

### Parameter bounds

The Risk Steward can only move parameters inside ranges governance has already approved.&#x20;

### Addresses

| Role / contract       | Address                                      |
| --------------------- | -------------------------------------------- |
| Risk Steward contract | `0xC1d38a1cdfb53Fce012A3A8CB42B64ddF60d4332` |
| Guardian multisig     | `0x00C2B13eF4F70Bf1827179Fe6d8facF7cFf6AcD2` |
| Risk Council          | `0xEcD37F855bB9814D75A83F0021815dc5cd6fd889` |

### Key functions

* **List a market:** governance brings a new market live with its assets, parameters, and oracle configuration.
* **Adjust risk parameters:** the Risk Steward tightens or loosens settings like LTV, caps, and rate parameters within the bounds governance has set. In the launch market, the fixed borrow rate is one of those governance-held settings.
* **Pause:** the Guardian halts activity in a market or across the protocol if a threat appears, then resumes once it clears. See Smart contract security.
* **Upgrade:** governance applies improvements and fixes to the protocol's contracts.

### Why mutable markets matter

Tydro markets are mutable, which means governance can adjust their parameters after launch with strict role based access and timelock controls. Immutable markets are fixed at deployment and cannot change, so when conditions shift, the only lever a user has is to exit.

Mutability enables active risk management. If volatility rises, the Risk Steward can lower LTV or tighten caps to protect existing positions. If a threat appears, the Guardian can pause the market in the same step. During May 2025 Tydro migrated oracles during a potential vulerability due to the data providers, this transition only possible due to Aave's market mutability

That control comes with a clear tradeoff. Mutable markets require trust that the parties holding these roles act responsibly, which is why every power is scoped, the Guardian can only pause, and the Risk Steward can only move parameters inside bounds governance has already approved. See Smart contract security.


# Lending Vaults

Managed capital allocation to various lending markets

Vaults let managers run strategies and deploy capital on top of Tydro markets. This page describes the vault types Tydro supports, defined by what they do and who can control them.

A vault follows the ERC-4626 standard or an equivalent. A depositor supplies an asset, the vault puts it to work under a manager, and each share tracks the depositor's portion of the result. The standard is flexible, so a clear description of each vault's function, permissions, and access control matters the most.&#x20;

### Vault types

* **Lending vaults.** A curator and allocator move capital across whitelisted lending markets seeking a target risk-adjusted return. Suited to depositors who want diversified exposure across markets rather than managing positions themselves. See [Morpho Vaults](https://morpho.org/blog/vaults-the-future-of-noncustodial-finance/) for a conceptual overview.
* **Manager-directed vaults.** A manager holds defined roles over the asset, strategy, and venue, within a single or multi-strategy mandate. The role structure is explicit, so depositors can see what the manager can and cannot do.
* **Vault-held assets.** The manager completes KYB and acquires assets or securities through an entity or SPV, then represents them in the vault. This is how real-world and off-chain exposure reaches on-chain depositors under a defined legal structure.

Tydro supports a variety of vault products, including Sentora's Kraken Earn vaults.

{% hint style="info" %}
External vaults that allocate to Tydro should be independently diligenced by investors. Using a permissionless market for yield is not an endorsement from Tydro of the vault manager or strategy.
{% endhint %}

### Permissions and control

Every vault runs on role-based access control. Each role, whether curator, allocator, or manager, has a defined set of actions and clear limits. The Tydro app states relevant information for each vault, so depositors know who controls their capital and what those parties are able to do with it.


# Tranching

Tranching splits a loan into senior and junior claims so lenders can choose their place in the loss waterfall for their preferred risk & return profile

### The loss waterfall

Lending through a tranche means holding a position in a stack. Losses hit the bottom of the stack first and work upward. Yield is distributed to match, so the positions that absorb losses first earn more.

* **Junior:** takes losses first and earns the highest yield. This is the first-loss position.
* **Senior:** is paid first and takes losses last, in exchange for a lower yield.

Because the junior absorbs losses before the senior, junior capital provides coverage for the senior position. A senior position is protected up to the size of the junior capital beneath it.

### How it works on Tydro

Supplying USDC to the launch market returns an ***aUSDC*** receipt token. Because the market is isolated, that receipt represents a share of the single aggregate loan pool against kBTC, not broad exposure across the protocol. The receipt token can be deposited into tranching smart contracts or triparty agreements that split it into junior and senior positions.

The tranche contracts are live. The user interface and the contract audits are still in progress, so this will be available shortly after v2 launch.&#x20;


# Term Lending

Bespoke term loans can be facilited via Kraken Instiutional. See [Work With Us](/iv.-tydro-institutional/work-with-us)


# Fixed Rates


# Strategies

How externally managed capital is

Strategies are managed allocations that put capital to work across Tydro markets and the wider set of opportunities on Ink. This page introduces the model for retail and institutional allocators.

A strategy packages a defined approach into a single position an allocator can hold. Rather than managing markets, tranches, and terms directly, an allocator deposits into a strategy and a manager runs it to a stated mandate. Strategies are built for retail allocators who want a managed position and for institutional allocators putting larger capital to work under clear terms.


# Before You Start

A plain-language guide to using Tydro. Read this to understand the basics, then follow the links for detail.

## Using Tydro

Tydro does two things: earn interest by supplying an asset, or borrow an asset by putting up collateral. Those are the two core actions, and the rest of this guide fills in the detail.

### Before you start

Using Tydro takes a wallet connected to the Ink network with some assets in it.

* **Wallets:** any EVM-compatible wallet, such as MetaMask, Coinbase Wallet, or WalletConnect. For Bitcoin-native flows, Leather and Xverse are supported.
* **Bridging onto Ink:** Bungee, Super Bridge, the USDT0 Native Bridge, and the Aave Bridge.

### Earn by supplying

Supplying is lending. An asset deposited into a market is lent out, and borrowers pay interest for the use of it.

* Interest accrues for as long as the deposit stays in the market.
* The supply rate moves with demand. More borrowing means a higher supply rate.
* The deposit is not locked. It can be withdrawn whenever the market has free liquidity.

How much a deposit earns depends on how much is being borrowed. See Interest rates.

### Borrow against collateral

Borrowing raises liquidity without selling what is held. Post collateral, then borrow another asset against it. In the first market, that means posting kBTC and borrowing USDC — dollars to use without selling the bitcoin.

A few things to know:

* Borrowing is capped at a limit, set as a percentage of the collateral's value. This is the loan-to-value, or LTV.
* In the launch market the borrow rate is fixed. It is set for the market and does not climb as utilization rises.
* Interest accrues on the borrowed amount and adds to the debt over time.
* There is no repayment schedule. The loan has no maturity date, so it can be repaid at any time, as long as the position stays healthy.

### Keep the position healthy

Every borrow position has a health factor, a safety gauge for the position.

* Above 1, the position is fine.
* At 1 or below, the position can be liquidated.

Two things push the gauge down: collateral dropping in value, and interest building up on the debt. To push it back up, add more collateral or repay some of what is owed.

{% hint style="warning" %}
Watch the health factor. If collateral falls in value, the gauge drops, and collateral can be lost to liquidation.
{% endhint %}

### Repay and withdraw

To close a position, repay the borrowed amount plus interest, then withdraw the collateral. This can also be done in parts: repay some debt to free up borrowing room, or withdraw spare collateral while keeping the position open.

### If a position gets liquidated

If the health factor hits 1 or below, a liquidator can step in, repay part of the debt, and take an equal value of collateral plus a small bonus. This brings the position back above 1 and keeps the market solvent. The borrowed asset is kept, but the collateral that was used is lost.

The way to avoid it is to keep the health factor well above 1.

### Where to go next

* The mechanics behind all of this: How lending and borrowing work.
* The market in use: [Isolated Markets](/ii.-core-concepts/markets/isolated-markets).
* The risks worth understanding first: [Risk Parameters](/ii.-core-concepts/risk-paramaters) and [Disclosures](/v.-risk/disclosures).


# Supplying Assets

Supplying tokens to Tydro allows users to earn interest on their digital assets and utilize supplied tokens as collateral. When tokens are supplied, they are transferred to Tydro’s liquidity pools, a system of smart contracts that facilitates overcollateralised borrowing of tokens. In Tydro, supplied tokens automatically accrue interest based on the current market supply rate. As the balance of supplied tokens increases, interest is accrued dynamically, reflecting the current rate allocated to suppliers.

Interest rates for supplied tokens are determined by protocol parameters such as the borrow utilization rate, which measures the proportion of assets currently borrowed against the total supplied in the pool. These parameters are adjusted through internal configurations that influence incentives across markets, directing capital either towards lenders or borrowers by modifying the effective yield or borrowing cost. As liquidity is supplied, borrowed, repaid, or withdrawn from the pool, the interest rates are updated accordingly.


# Originating a Loan

Borrowing tokens from Tydro allows users to unlock liquidity by using their supplied tokens as collateral, up to the collateral's maximum LTV

If the value of the collateral drops below the Liquidation Threshold, the position will become elligible for liquidation


# Health Factor + Position Management

Overview of managing borrow positions on Tydro

## Health Factor

A health factor above 1 means a position is solvent. A health factor below 1 means the collateral no longer covers the debt at the required threshold, and the position becomes eligible for liquidation.

$$
\text{Health Factor} = \frac{\sum \left( \text{Collateral} \times \text{Liquidation Threshold} \right)}{\text{Total Debt}}
$$

The health factor moves continuously as asset prices update through oracle feeds. A position that is healthy can become eligible for liquidation if collateral prices fall, borrowed asset prices rise, or interest accumulation.

### Liquidation threshold vs. LTV

These two parameters are distinct:

* **Loan-to-value (LTV)** is the maximum that can be borrowed when opening or adding to a position. It sets the starting limit.
* **Liquidation threshold (LT)** is the point at which an existing position becomes eligible for liquidation. It is always higher than the LTV.

The gap between LTV and LT is the safety buffer. Borrowing at the LTV limit leaves no room for price movement before the LT is breached. Prudent borrowing means leaving space between the actual borrow and the LTV.

### When liquidation is triggered

When a position's health factor drops below 1, any address may act as a liquidator. The liquidator repays a portion of the outstanding debt and receives a corresponding amount of collateral in return, plus a liquidation bonus.

The liquidation bonus compensates the liquidator for taking on the position. The protocol fee is deducted from the bonus and routed to the protocol reserve, so the liquidator receives the bonus minus the fee.

### Liquidations in clusters

In a cluster, margin is shared across correlated assets. A price decline in any cluster asset lowers the health factor of the whole cluster position, not only the position tied to that specific asset. When the health factor falls below 1, collateral from any asset in the cluster may be seized in liquidation.

See [Clusters and Pooled Markets](/ii.-core-concepts/markets/clusters-and-pooled-markets) for how shared margin works.

### Avoiding liquidation

The most reliable way to avoid liquidation is to borrow well below maximum borrowing capacity and monitor the health factor as prices move.

**Practical steps:**

* **Borrow conservatively.** Borrowing at the LTV limit leaves no buffer, and a modest price move is enough to breach the liquidation threshold. Leave a meaningful gap between debt and the LTV limit.
* **Monitor the health factor.** The HF updates continuously with oracle prices.&#x20;
* **Add collateral.** Supplying more collateral raises the health factor without requiring any part of the position to close.
* **Repay debt.** Reducing outstanding debt raises the health factor directly.

### Oracle prices and liquidation timing

Liquidation eligibility is determined by on-chain oracle prices, not exchange prices. A position becomes liquidatable the moment its health factor drops below 1 according to the oracle feed. Price latency between the oracle and the broader market is a known risk. See Oracles and Market and collateral risk.

### Developer integration

Liquidators interact directly with the Pool contract to repay debt and claim collateral.&#x20;


# Repay Loans & Withdraw

How to repay loans and withdraw positions

## Repay

Repayment improves the health factor of a position by increasing the collateralization ratio. By reducing the outstanding debt relative to the collateral posted, repayment lowers liquidation risk and may allow borrowers to safely withdraw a portion of their collateral.

## Withdraw

Tydro allows suppliers to withdraw their supplied tokens, including accrued interest, as long as there is sufficient unborrowed liquidity in the reserve. The withdrawal amount is limited by the available underlying assets, and that the user’s ability to maintain a sufficient collateral ratio for their borrow position.&#x20;

Periphery features such as collateral and debt swaps allow users to redeem their supplied liquidity in a different token, providing more options for efficient asset management.

When withdrawing with an active borrow position, it’s crucial to maintain a healthy collateralization ratio to avoid liquidation. Reducing collateral can lower the health factor, increasing the risk of liquidation. To remain safe, after the withdrawal, the account must stay above the liquidation threshold parameters. Therefore, withdrawals require careful management and consideration of the overall borrow positions to avoid liquidation.


# Institutional Overview

Tydro is built for institutional on chain credit markets. This page lays out what the protocol offers institutions, with further detail in the section pages.

Tydro provides the lending engine, the network, and custody into one stack. Aave V3 supplies an audited lending core. Ink adds chain-level compliance, monitoring and security. Kraken qualified custody connects the protocol to a regulated custody and distribution network. The result narrows the risk premium of operating on-chain and gives institutions a venue that meets their standards for custody, controls, and risk management.&#x20;

### What Tydro offers institutions

* **Qualified custody with direct on chain vault + assets.** Earn yield and borrow within Kraken qualified custody. Custody supports triparty and OTC loans.
* **First-loss capital.** Post verifiable first-loss capital in markets to provide coverage for depositors.&#x20;
* **Insurance.** Arrange coverage for institutional positions through established insurance providers.&#x20;
* **Permissioned and RWA markets.** Launch markets designed for tradable securities.&#x20;
* **Vault curation.** Run strategies as a curator or allocator under a defined role structure.
* **Term and duration loans.** Lend or borrow for a fixed term with defined yield.&#x20;
* **Tranched exposure.** Take a senior or junior position sized to your risk profile.&#x20;

### Built to scale

New markets, clusters, and products deploy at the asset, vault, and market level, so the protocol adapts to an institution's assets and mandate rather than the other way around. As liquidity deepens, parameters and caps scale with it under governance. See [Governance](/ii.-core-concepts/protocol-governance).

{% hint style="info" %}
Tydro is lending infrastructure, not financial, legal, or tax advice. Engagements are subject to eligibility and onboarding. See [Work With Us](/iv.-tydro-institutional/work-with-us).
{% endhint %}


# Qualified Custody

Tydro connects to Kraken qualified custody, so institutions can use the protocol while their assets stay with a regulated custodian

Most on-chain lending asks you to hold assets in a wallet you manage yourself. Qualified custody changes that. Your assets sit with Kraken under a regulated custody arrangement, with the segregation, controls, and operational standards an institution requires, while still working through Tydro markets.

This is a core part of the stack. Pairing the protocol with qualified custody removes a major source of operational risk for institutions and is one of the ways Tydro lowers the cost of transacting on-chain. See The Tydro stack.

For the risks that remain, see Custody and counterparty risk. To begin onboarding, see Work with us.


# Permissioned Markets

Tydro supports permissioned markets and real-world asset collateral, segregated from permissionless markets. This page gives an overview for institutions on accessing markets or listing assets.

Some institutions can only transact in venues that restrict participation to verified counterparties. Tydro supports KYB-gated markets, where access is limited to participants who have completed business verification. The market runs on the same engine as an open market, with participation controlled at the entry point.

### Real-world assets

Tydro lists real-world assets as collateral. A manager completes business verification and acquires the asset or security through an entity or SPV, then represents it on-chain for use in a market or vault. This is how off-chain exposure, from tokenized equities to tokenized gold, reaches the protocol under a defined legal structure. See Vaults.

### Deploying a market

New markets deploy at the asset, vault, and market level, so a permissioned or RWA market can be brought live to fit an institution's assets and compliance needs.

For the risks specific to these assets, see [RWA and permissioned-asset risk](/iv.-tydro-institutional/institutional-overview/permissioned-markets). To list an asset or open a permissioned market, see [Work with us](/iv.-tydro-institutional/work-with-us).


# Triparty & Term Loans

Tydro facilitates fixed-term lending and borrowing for institutional partners.

To arrange a term facility, reach out under [Work With Us](/iv.-tydro-institutional/work-with-us).


# Vault curation

Curators and allocators run strategies on Tydro through vaults, under a defined role structure. This page covers what each role does

### Roles

**Curator.** Sets the vault's strategy: which markets the vault can use, what risk limits apply, and how the vault is positioned for depositors. The curator defines the boundaries within which the vault operates.

**Allocator.** Moves capital across the approved markets to run the strategy within the limits the curator has set. The allocator cannot act outside those limits.

Both roles have permissions enforced on-chain. A curator cannot unilaterally withdraw depositor funds, and an allocator cannot approve new markets or change risk limits, since those actions belong to the curator role. Depositors can verify what each role is permitted to do before committing capital. See Access control and roles.

**A curator can post first-loss capital in the vault's markets.** This gives depositors verifiable on-chain coverage: if losses occur, the curator's capital absorbs them first, before depositor funds are affected. The curator takes on higher yield in exchange for holding the first-loss position.

See [First-loss capital](/iv.-tydro-institutional/institutional-overview/first-loss-capital-and-insurance) and [Tranching](/ii.-core-concepts/tranching) for how the capital structure works.

### Running a vault

Curators are onboarded through a verification process before launching a vault that is surfaced on the Tydro App.

To apply, see [Work With Us](/iv.-tydro-institutional/work-with-us)


# First-loss capital & Insurance

First-loss capital absorbs losses before other lenders are affected. Tydro lets institutions post it verifiably in markets to provide coverage for their depositors

### How it works

A first-loss provider commits capital that sits at the bottom of the loss waterfall. If a covered position takes a loss, the first-loss capital absorbs it before any senior lender or depositor is touched. The coverage is posted on-chain, so depositors can verify it exists and see its size rather than relying on an assurance.

For a manager, first-loss capital is how you stand behind your own strategy. By posting it, you give your depositors verifiable protection and, in return, hold the position that carries the higher yield for taking on that risk.


# CLO, ABS, ETFs, Equties, Credit


# Work With Us

Tydro works directly with institutions on custody, liquidity, and integration support.

If you need any of the following, get in touch with the Ink & Kraken Institutional teams:

* **KYB and onboarding.** Complete business verification to access permissioned markets and institutional products.
* **Liquidity.** Discuss supplying or borrowing at size, or seeding a new market.
* **Kraken Qualified Custody.**&#x20;
* **Running a vault or strategy.** Curate a vault, run a strategy, or arrange a term facility.&#x20;

{% hint style="info" %}
**Kraken Institutional engagements are subject to eligibility, verification, KYB, minimums, regulatory compliance, and applicable terms. Tydro does not provide financial, legal, or tax advice.**
{% endhint %}

*Given the rise in phishing attacks, we prefer new connections to reach out with a warm introduction*


# Risk Types & Overview

Using Tydro puts capital at risk. This page summarizes those risks and links to the detail on each. Read it before supplying, borrowing, or allocating.

{% hint style="danger" %}
Using Tydro can result in the loss of some or all of the assets supplied, posted as collateral, or allocated to a vault or strategy. Tydro is lending infrastructure, not financial, legal, or tax advice. Do not commit capital that cannot be afforded as a loss.
{% endhint %}

### Risk is the user's responsibility

Tydro is software for permissionless and institutional lending. It does not assess whether a position is suitable, monitor any account on a user's behalf, or guarantee any outcome. Once capital is committed, the obligation to manage the position rests with the user.

An unhealthy position can be liquidated automatically and without notice. The protocol will not pause to protect a position. Real-time LTV alerts are available in the app to help with monitoring, but the responsibility to act on them rests with the user. See [Liquidation Risk](/v.-risk/risk-types-and-overview/liquidation-risk).

### Summary of risks

Each risk has its own page. The protections referenced on those pages lower risk; they do not remove it.

**Smart contract risk.** Code can contain errors or be exploited, and upgrade powers can change how the protocol behaves. See [Smart Contract Risk](/v.-risk/risk-types-and-overview/smart-contract-risk).

**Governance risk.** Governance can change risk parameters, rate models, supply and borrow caps, and upgrade contracts. A fixed borrow rate is set by governance, not locked forever, and can be adjusted within defined bounds. Parameter changes can affect the value of existing positions. See [Governance](/ii.-core-concepts/protocol-governance).

**Market and collateral risk.** Collateral can fall in value sharply, liquidity can disappear, and a market can be left with bad debt. See [Market and Collateral risk](/v.-risk/risk-types-and-overview/market-and-collateral-risk).

**Liquidity and withdrawal risk.** Suppliers may not be able to withdraw at all times. When utilization is high, insufficient liquidity may remain in the pool to fulfill a withdrawal until borrowers repay. In fixed-rate markets, the borrow rate does not automatically correct high utilization the way a variable model does, which can extend the period during which withdrawal is constrained. See [Market and Collateral Risk](/v.-risk/risk-types-and-overview/market-and-collateral-risk).

**Liquidation risk.** A position that falls below its liquidation threshold can lose collateral and incur a penalty. In a cluster, a price decline in any cluster asset lowers the health factor of the whole position. See [Liquidation Risk](/v.-risk/risk-types-and-overview/liquidation-risk).

**Oracle risk.** Prices come from external feeds that can be wrong, stale, or manipulated, which can trigger or prevent liquidations incorrectly. See [Price Feed Risk](/v.-risk/risk-types-and-overview/price-feed-risk).

**Tranche risk.** A junior position can lose its full value before a senior position is touched. See [Tranching](/ii.-core-concepts/tranching).

**Vault and curator risk.** Depositing into a vault introduces the curator's and allocator's decisions as an additional risk layer. Curator strategy, allocator execution, and the adequacy of first-loss capital can all affect vault performance independently of the underlying protocol. See [Vault Curation](/iv.-tydro-institutional/institutional-overview/vault-curation) and [First-loss capital](/iv.-tydro-institutional/institutional-overview/first-loss-capital-and-insurance).

**Custody and counterparty risk.** Use of a custodian and other counterparties introduces risks outside the protocol's code. See [Custodian & Counterparty Risk](/v.-risk/risk-types-and-overview/custodian-and-counterparty-risk).

**RWA and permissioned-asset risk.** Real-world assets depend on off-chain legal structures and parties that can fail or be subject to legal action.&#x20;

**Regulatory risk.** Tydro operates in a regulatory environment that continues to evolve. Legal action, regulatory orders, or compliance requirements could affect the protocol, its operators, or specific assets, including forcing pauses, restricting access, or freezing assets. This risk is heightened for permissioned assets and real-world asset markets.

**Bridging risk.** Tydro runs on Ink. Assets bridged to Ink to use the protocol carry bridge risk in addition to protocol risk. A bridge failure or exploit can affect assets before they ever reach Tydro. See [Bridge to Ink](/viii.-resources/bridge-to-ink).

### No guarantee of return

Rates on Tydro are set by the market utilization and interest rate model, and they can change. A fixed borrow rate in a market is fixed by governance based on market conditions at the time of being set, not guaranteed forever. Supply rates depend on utilization and can fall to zero if utilization falls to zero. Nothing in this documentation is a promise or projection of yield, return, or performance.&#x20;

### These risks are not exhaustive

This section describes the risks Tydro considers most significant. It does not describe every risk. New risks can arise from market conditions, regulation, third parties, and the broader environment the protocol runs in. The absence of a risk from this section is not a statement that the risk does not exist.

{% hint style="info" %}
The Security section describes the controls Tydro runs against these risks. A control can lower how often a risk occurs or how much it costs. The risk still remains.
{% endhint %}


# Smart Contract Risk

## Smart contract risk

Tydro is software. Software can contain errors, and the powers that govern it can be misused. This page describes the risk in the protocol's code and control surface.

### Code can fail

Tydro is built on the Aave V3 codebase, which is widely deployed and has been audited and used at scale. That history lowers the odds of an undiscovered flaw in the core lending logic, though it cannot drive them to zero. No audit or track record proves code is free of bugs, and a flaw that has not surfaced is still a flaw.

Tydro also adds its own surface area on top of that base. Configuration, oracle integration, custody connections, tranching, and vaults are all places where errors can be introduced, and they have not accumulated the same history as the underlying engine. A failure in any of them can lead to loss of funds.

Known attack classes include flash loan exploits, oracle price manipulation, and reentrancy. The protocol is designed to defend against these, but no design eliminates the risk entirely.

{% hint style="warning" %}
A smart contract exploit or critical bug can result in the partial or total loss of assets held in the protocol, with no guarantee of full recovery. **Umbrella provides a first layer of coverage against shortfalls, but does not guarantee complete restitution. See** [**Umbrella**](/viii.-resources/umbrella)**.**
{% endhint %}

### Upgrade powers carry their own risk

Tydro markets are mutable. Governance can change parameters and upgrade contracts. This is useful for managing risk, and it is also a risk in itself. If an upgrade key is compromised, or an upgrade is made in error, the behavior of the protocol can change in ways that harm users.

Tydro scopes these powers and separates them across roles to limit that exposure, but the powers exist.

Where a component is immutable, the opposite applies. It cannot be changed by a compromised key, and it also cannot be fixed if a flaw is found in it.

### What an audit can and cannot tell

Audits and reviews are one input to security. An audit reflects a defined scope and a point in time. It can miss issues, and it does not cover changes made afterward. Treat a completed audit as evidence of the diligence applied, not as proof that funds are safe.

**On Aave V3 audits:** Tydro's core lending logic is the Aave V3 codebase. The Aave V3 audit set is directly relevant to that base layer and is linked from the Audit reports page. Those audits cover the base codebase, not Tydro's additions. Tydro-specific components, including configuration, oracles, tranching, and vaults, require their own audits, which are listed separately.

See [Audit Reports](/vi.-security/audit-reports).

### Bug bounty and incident response

Details to come.

### Dependencies and integrations

Tydro relies on external systems, including price feeds, the Ink network and its bridge, and the custody integration. A failure in any dependency can affect the protocol even when Tydro's own code is sound. See [Price Feed Risk](/v.-risk/risk-types-and-overview/price-feed-risk) and Custody and counterparty risk.


# Market & Collateral Risk

## Market and collateral risk

The value and liquidity of the assets in a market can move against a position. This page describes the risks that come from the market itself rather than from the code.

### Collateral can fall in value

Collateral assets are volatile. A sharp drop in the price of the collateral lowers the health factor and can push a position into liquidation quickly. Crypto assets can move far in a short window, including outside normal hours, and a position that looks comfortable can reach its liquidation threshold within minutes. See [Positions and Account Health](/iii.-using-tydro/health-factor-+-position-management).

### Correlated assets can fall together

Clusters group assets that tend to move together so they can share margin. The same correlation that makes a cluster efficient works against the position in a downturn, because the assets backing it can decline at the same time rather than offsetting each other. Concentration in correlated collateral can amplify a loss. See [Clusters and Pooled Markets](/ii.-core-concepts/markets/clusters-and-pooled-markets).

### Liquidity can disappear

A market depends on available liquidity. If a large share of supplied assets is borrowed, suppliers may be unable to withdraw until borrowers repay or new supply arrives. On the other side, thin liquidity can leave a position unable to be liquidated at a fair price, which contributes to bad debt. See [Interest Rates](/ii.-core-concepts/interest-rates).

### A market can be left with bad debt

In severe conditions, the value of a position's collateral can fall below its debt before liquidation completes. When that happens, liquidation does not fully cover the debt and the market is left with a shortfall. Bad debt can affect suppliers in the affected market. Caps and conservative parameters reduce how often this occurs, and a sufficiently extreme move can still produce it. See [Liquidation Risk](/v.-risk/risk-types-and-overview/liquidation-risk).

### Stablecoin and peg risk

The loan asset in the launch market is a stablecoin. A stablecoin can lose its peg. A de-peg changes the real value of debt and supply in the market and can disrupt liquidations that assume a stable price.&#x20;

{% hint style="warning" %}
Loan-to-value limits, liquidation thresholds, and caps are tools for managing these risks. They cap exposure within set bounds. A severe enough market move can still produce a loss beyond what those bounds anticipate.
{% endhint %}


# Price Feed Risk

Tydro markets use price feeds for every position. If wrong, a position can be liquidated when it should not be, or not liquidated when it should be. This page describes the risks of bad pricing

### Why the price matters

The protocol uses oracle prices to value collateral and debt and to decide when a position can be liquidated. The protocol acts on the price it is given. If that price does not reflect the real market, the protocol still acts on it.

### How feeds fail

Price feeds can fail in several ways. A feed can go stale and stop updating. It can report a value that is wrong. It can be manipulated, particularly for assets whose underlying spot markets have thin liquidity, which makes those markets easier to move. The infrastructure delivering the feed can go down.

The consequences fall on positions. A price reported too low can trigger liquidations that should not happen. A price reported too high, or one that fails to update during a real decline, can stop liquidations that should happen and leave the market exposed to bad debt.

### What the current safeguards cover, and what they do not

Tydro prices assets from Chainlink. Chainlink aggregates prices across multiple sources, which reduces exposure to any single exchange. On top of that, Tydro applies staleness and deviation checks: if a price update is too old or moves by more than a defined threshold, it is treated as invalid. The PriceOracleSentinel adds a further layer specifically for L2 sequencer downtime. It restricts new borrows and liquidations when the Ink sequencer is unavailable, preventing the protocol from acting on prices that have not updated because the network itself is down.

These controls reduce the chance of acting on a bad reading. They do not remove oracle risk. Tydro currently relies on Chainlink as its primary price source so a failure or manipulation of that source is a concentration to be aware of.

{% hint style="warning" %}
An oracle failure can trigger liquidations that should not happen or prevent ones that should, and either can cause loss.
{% endhint %}


# Liquidation Risk

A position that falls below its liquidation threshold can lose collateral. This page describes how that happens and what can help prevent it

### What liquidation costs

When the health factor reaches 1 or below, a liquidator repays part of the debt and takes an equal value of collateral, plus the liquidation bonus. The bonus is a real cost to the borrower. The borrowed assets are kept, but the collateral lost is worth more than the debt that was repaid. See [Liquidations](/v.-risk/risk-types-and-overview/liquidation-risk).

{% hint style="warning" %}
Liquidation is automatic and permissionless. It happens without notice and without the borrower's involvement the moment a position becomes eligible.
{% endhint %}

### Acting in time may not be possible

Avoiding liquidation means adding collateral or repaying debt before the health factor reaches the threshold. A fast market may not leave the chance. Prices can move faster than a borrower can react, transactions can be delayed when the network is congested, and a position can cross the threshold while the borrower is still preparing to act.

Tydro runs on Ink. If the network or its sequencer is degraded or unavailable, a transaction to protect a position may not go through, or the transaction may land after another transaction with a higher priority fee within a given flashblock while prices continue to move and liquidation occurs.&#x20;

Tydro Governance can implement a 2 hour liquidation grace period in extreme circumstances. This feature has only been used once in a precautionary measure after migrating to Chainlink oracles in May 2025.&#x20;

### Liquidation may not clear the debt

In extreme volatility, collateral can fall below the value of the debt before a position can be fully liquidated. The position can then be left with bad debt that liquidation does not cover. In the event of bad debt, losses may be shared amongst lenders or tranche holders.&#x20;


# Junior Tranche Risk (Leveraged Downside)


# Custodian & Counterparty Risk

Using Tydro can involve a custodian and other counterparties. These introduce risks that sit outside the protocol's code

### Custodian risk

Where assets are held through Kraken qualified custody, the holder relies on that custodian. A custodian can suffer operational failure, become insolvent, freeze or restrict access to assets, or be subject to legal or regulatory action that affects those assets. Qualified custody brings regulated standards and controls to how assets are held, while leaving counterparty exposure to the custodian itself. See [Qualified Custody](/iv.-tydro-institutional/institutional-overview/qualified-custody).

{% hint style="warning" %}
Holding assets with a custodian means access to those assets depends on the custodian's solvency, operations, and legal standing.
{% endhint %}

### Counterparty risk in products

Some products involve other parties. A vault depends on its curator and allocator to act within their mandate. A term facility depends on the parties to it. A first-loss provider depends on the capital being present and sufficient. Each relationship is a counterparty exposure in addition to the protocol. See [Lending Vaults](/ii.-core-concepts/lending-vaults) and [Vault Curation](/iv.-tydro-institutional/institutional-overview/vault-curation).

### Insurance is conditional and may not apply

Where insurance coverage is arranged, it is subject to its own terms, scope, limits, and exclusions, and it may not cover a given loss or be in force for a given position. Do not treat insurance as a backstop for a position unless the coverage is confirmed to apply to it. See [Insurance Coverage](/iv.-tydro-institutional/institutional-overview/first-loss-capital-and-insurance).

### Regulatory risk

The legal and regulatory treatment of on-chain lending, custody, and the assets involved can change. Regulatory action can affect access to the protocol, the status of an asset, or a counterparty the position depends on.&#x20;


# Wrapped Asset Risk


# Bridging Risk


# RWA NAV Risk

### The on-chain token depends on an off-chain claim

A real-world asset is a token that represents an off-chain asset or security held through an entity or SPV. The token is only worth what that off-chain claim is worth, and only if the claim is enforceable. If the holding structure fails, if the assets are not there, or if the legal claim cannot be enforced, the token can lose value regardless of how the protocol behaves. See Permissioned and RWA markets.

{% hint style="warning" %}
A real-world asset token can fall to zero if the off-chain structure behind it fails or its claim cannot be enforced, even if the protocol functions exactly as intended.
{% endhint %}

### Issuer and counterparty default

These assets depend on the issuer and the parties that hold and administer the underlying. Default, insolvency, or misconduct by any of them can impair the asset. This is credit and counterparty risk of a kind that does not exist for native crypto collateral.

### Redemption may not be available

The ability to redeem a real-world asset token for the underlying can be limited, delayed, or suspended. A token that cannot be redeemed when expected can trade away from the value of the asset it represents.

### Legal and regulatory risk

Real-world assets are subject to law and regulation in the jurisdictions that govern them. Assets can be frozen, seized, or made non-transferable by legal or regulatory action. The regulatory status of a tokenized asset can change after it is listed.

### Permissioning can change

Access to a permissioned market depends on meeting and maintaining its requirements. Access can be revoked, and eligibility can change, which can affect the ability to manage or exit a position in that market.&#x20;


# Risk Mitigation & Response Plan


# Disclosures

### Terms of Service

<https://tydro.com/terms-of-service>&#x20;

### Privacy Policy

<https://tydro.com/privacy-policy>

### No guarantee of return

Rates on Tydro are set by the market utilization and interest rate model, and they can change. A fixed borrow rate in a market is fixed by governance based on market conditions at the time of being set, not guaranteed forever. Supply rates depend on utilization and can fall to zero if utilization falls to zero. Nothing in this documentation is a promise or projection of yield, return, or performance.&#x20;


# Security Overview

## Security overview

Security at Tydro is layered. Technical, economic, and operational controls work together, on top of an audited lending base, a monitored network, and qualified custody. This page maps the layers and how they address the protocol's risks.

### A layered model

No single control secures a lending protocol. Tydro runs defense in depth, so a failure in one layer is met by others.

**Technical security** protects the code and the data it depends on: the audited contract base, the protective pause, market parameterization, and price feed integrity. See Technical security.

**Economic security** protects capital with underwriting, first-loss coverage, insurance, and quantitative risk modeling. See Economic security.

**Operational security** protects the keys and people who operate the protocol. See Operational security.

The stack reinforces all three. The Aave V3 codebase brings a security history measured in years and large deposits across networks. Ink adds monitoring at the network layer. Kraken qualified custody removes a large share of the self-custody risk institutions carry elsewhere. See The Tydro stack.

### How controls map to risks

Every risk in the Risk section is met by specific controls here. This table is the map.

| Risk                            | Primary controls                                                                         | Where                                              |
| ------------------------------- | ---------------------------------------------------------------------------------------- | -------------------------------------------------- |
| Smart contract risk             | Audited base, protective pause, scoped upgrade roles                                     | Smart contract security                            |
| Market and collateral risk      | LTV and liquidation thresholds, caps, market isolation, underwriting                     | Market and collateral security, Asset underwriting |
| Liquidation risk                | Conservative parameters, the liquidation engine, bounded parameter changes               | Market and collateral security                     |
| Oracle risk                     | Chainlink feeds, staleness and deviation checks, the PriceOracleSentinel, Guardian pause | Price feed security                                |
| Tranche risk                    | First-loss capital, asset underwriting                                                   | Economic security                                  |
| Custody and counterparty risk   | Qualified custody, key management, operational controls                                  | Operational security                               |
| RWA and permissioned-asset risk | Asset underwriting, access controls                                                      | Asset underwriting                                 |

{% hint style="info" %}
This section describes what Tydro does to secure the protocol. Every control here lowers risk without erasing it; the Risk section sets out what remains once each one is in place.
{% endhint %}


# Technical Security

Technical security protects Tydro's code and the data it acts on.

The protocol's technical defenses run at three points. The contracts themselves are built on an audited base and wrapped in protective controls. The markets are parameterized to contain risk before it spreads. The price feeds that the protocol acts on are validated before use. Ink adds monitoring at the network layer.

### This section covers

* Smart contract security. The audited base, the protective pause, and upgrade controls.
* Market and collateral security. Parameters, isolation, and caps as active controls.
* Price feed security. Validated pricing and restriction on bad data.


# Smart Contract Security

Tydro defends its contracts with an audited base, a protective pause, and tightly scoped upgrade powers

### An audited base

Tydro is built on the Aave v3 codebase, deployed across multiple networks and securing a large volume of deposits over several years. Building on reviewed code means Tydro does not reinvent core lending logic, which is where the highest-severity bugs tend to live. Tydro's own additions are reviewed separately. See [Audit Reports](/vi.-security/audit-reports).

### Pausing

The Guardian can pause a single market or the protocol as a whole in response to a threat, then lift the pause once it clears. This contains an incident rather than letting it run while a response is organized. The pause power is protective only. It cannot move funds or alter balances.

### Upgrade controls

Tydro markets are mutable, so the protocol can adapt parameters and ship fixes. That power is deliberately constrained.

* Scoped roles. Authority is split. The Risk Steward adjusts parameters within preset bounds. The Guardian can pause but cannot change parameters or move funds. Governance holds the broad powers, including upgrades. See Governance.
* Bounded parameter changes. The Risk Steward can only move parameters inside ranges governance has already approved, so fast adjustments cannot exceed safe limits.
* Separation of duties. No single role holds enough authority to compromise the protocol on its own.<br>

For how these roles work end to end, see [Governance](/ii.-core-concepts/protocol-governance). For key custody behind these roles, see [Operational Security](/vi.-security/security-overview/technical-security/operational-security).

### Immutable components

Where a component is immutable, it cannot be altered by any key, which removes upgrade risk for that component. The tradeoff is that immutable code cannot be patched if a flaw is found. Tydro applies mutability and immutability deliberately by component.

For the residual risk these controls reduce, see [Smart Contract Risk](/v.-risk/risk-types-and-overview/smart-contract-risk).

<br>


# Market & Collateral Security

Tydro contains market and collateral risk through isolation, conservative parameters, and caps

### Isolation contains failure

Tydro launches with isolated markets. A single collateral asset backs a single loan asset, and stress in that asset stays inside the market rather than spreading across the protocol. A new asset can be listed in its own market without changing the risk profile of existing ones. See [Isolated Markets](/ii.-core-concepts/markets/isolated-markets).<br>

Where markets share margin through clusters, exposure is managed at the cluster level with its own parameters and caps, so correlation is accounted for. See [Clusters and Pools](/ii.-core-concepts/markets/clusters-and-pooled-markets).

### Parameters as controls

Risk parameters are the protocol's first line of defense against a falling market.<br>

* Loan-to-value and liquidation threshold set the borrowing limit and the liquidation point, with a buffer between them. Conservative values leave more room before a position is at risk.
* The liquidation engine closes unhealthy positions automatically and permissionlessly, which keeps markets backed by sufficient collateral. See [Liquidations](/ii.-core-concepts/liquidations-and-risk-management).
* Caps limit total supply and borrowing in a market, which contains concentration and lets exposure scale in controlled steps.

These values are set through underwriting before a market launches, and adjusted as conditions change. See [Asset Underwriting](/vi.-security/security-overview/economic-security/asset-underwriting) and [Risk Parameters](/ii.-core-concepts/risk-paramaters).

### Active adjustment

Because markets are mutable, parameters respond to conditions. If volatility rises, the Risk Steward can lower LTV or tighten caps within approved bounds to protect existing positions, without waiting for a full governance cycle. If a threat appears, the Guardian can pause the market in the same step. See [Governance](/ii.-core-concepts/protocol-governance).<br>

{% hint style="info" %}
Conservative parameters and caps limit how much can go wrong in a market and how fast. They are sized through underwriting and monitored continuously.&#x20;
{% endhint %}

For the residual risk these controls reduce, see [Market and Collateral Risk](/v.-risk/risk-types-and-overview/market-and-collateral-risk) and [Liquidation Risk](/v.-risk/risk-types-and-overview/liquidation-risk).


# Price Feed Security

## Price feed security

Tydro prices every position from Chainlink, validates the feed before acting on it, and restricts protocol activity when a feed degrades. This page describes the price feed controls.

### Why this layer matters

The protocol acts on the prices it is given, to value collateral and to decide when a position can be liquidated. A wrong or stale price is a direct threat to solvency. Tydro treats price integrity as a security problem, not just a data feed.

### Current controls

* Validated source. Prices come from Chainlink, routed through the TydroOracle contract.
* Staleness checks. A feed that has stopped updating within its expected window is treated as stale.&#x20;
* Deviation checks. The underlying Chainlink feeds carry deviation bounds.&#x20;
* Restriction on bad data. If a price is stale or invalid, the PriceOracleSentinel restricts new borrows and liquidations until a valid price returns, and the Guardian can pause the affected market.<br>

### On the roadmap

A multi-source redundancy layer that reads more than one independent provider and resolves disagreement between them is planned but not yet live. Until it ships, the protocol relies on Chainlink as its price source. See Oracle reliability.<br>

For the residual risk these controls reduce, see [Price Feed Risk](/v.-risk/risk-types-and-overview/price-feed-risk).

<br>


# Operational Security

## Operational security

Operational security protects the keys and the people who operate Tydro. This page describes the key management, access controls, and operational posture behind the protocol.

### Key management

The keys that hold protocol authority are the highest-value target in any deployment, so they are protected accordingly.

* Multi-party computation, so no single party holds a complete key and no single device is a point of failure.
* Dedicated, hardened signing devices rather than general-purpose machines.
* Multi-factor authentication across the systems that operate the protocol.
* Encryption of sensitive material at rest and in transit.

These controls sit behind the governance roles, so the powers in Smart contract security can only be exercised through this protected path.

### Access control

The protocol runs on role-based access control. Each role has a defined set of actions and clear limits, authority is separated so no individual can act alone where it matters, and access follows least privilege. The same model extends to vaults, where curator and allocator permissions are explicit. See [Governance](/ii.-core-concepts/protocol-governance) and [Vault Curation](/iv.-tydro-institutional/institutional-overview/vault-curation).

### Custody

Where assets are held through Kraken qualified custody, they sit with a regulated custodian under institutional controls for segregation and operations, which removes much of the self-custody risk institutions carry elsewhere. See [Qualified Custody](/iv.-tydro-institutional/institutional-overview/qualified-custody).

### Personnel and physical security

Operational security extends to people. Tydro applies controls around the identities and physical security of key personnel.

### Incident response

If an incident occurs, the Guardian can pause an affected market or the protocol while a response is carried out, then resume once the threat clears. See [Smart Contract Security](/vi.-security/security-overview/technical-security/smart-contract-security).

For the residual risk these controls reduce, see [Custody and Counterparty Risk](#custody).


# Economic Security


# Asset Underwriting


# VaR & Risk Modelling


# Audit Reports

This page covers the audits that apply to Tydro: the audits of the Aave V3 base codebase, and any audits of other dependencies.

### Two layers of review

Tydro's security review has two parts. The lending base is the Aave V3 codebase, which has been independently audited across multiple rounds by six firms and formally verified by Certora. Tydro then adds its own contracts and configuration on top, and those are reviewed separately. A deployment's own code and modifications are not covered by audits of the base.

### **Tydro v2 audits**

**Multiply Review**

<table><thead><tr><th width="235.12109375">Auditor</th><th>Date</th><th>Report</th></tr></thead><tbody><tr><td>Zellic</td><td>August 2026</td><td><div data-gb-custom-block data-tag="file" data-src="/files/0Pkiuh2lrJVxi5UUSPTv"></div><p></p></td></tr></tbody></table>

**Payload/Economic Review**

<table><thead><tr><th width="235.12109375">Auditor</th><th>Date</th><th>Report</th></tr></thead><tbody><tr><td>Zellic</td><td>August 2026</td><td><div data-gb-custom-block data-tag="file" data-src="/files/ITxH98nnd5OkM0YReeZU"></div><p></p></td></tr></tbody></table>

### Aave V3 base codebase audits

These audits cover the core lending logic Tydro is built on. They do not cover Tydro's own contracts, configuration, or integrations.

**V3 Round 1, October 2021**

| Auditor       | Date          | Report                                                                                                    |
| ------------- | ------------- | --------------------------------------------------------------------------------------------------------- |
| ABDK          | January 2022  | [View report](https://github.com/aave/aave-v3-core/blob/master/audits/27-01-2022_ABDK_AaveV3.pdf)         |
| OpenZeppelin  | November 2021 | [View report](https://github.com/aave/aave-v3-core/blob/master/audits/01-11-2021_OpenZeppelin_AaveV3.pdf) |
| Trail of Bits | January 2022  | [View report](https://github.com/aave/aave-v3-core/blob/master/audits/07-01-2022_TrailOfBits_AaveV3.pdf)  |
| PeckShield    | January 2022  | [View report](https://github.com/aave/aave-v3-core/blob/master/audits/14-01-2022_PeckShield_AaveV3.pdf)   |

**V3 Round 2, December 2021**

| Auditor    | Date         | Report                                                                                                  |
| ---------- | ------------ | ------------------------------------------------------------------------------------------------------- |
| SigmaPrime | January 2022 | [View report](https://github.com/aave/aave-v3-core/blob/master/audits/27-01-2022_SigmaPrime_AaveV3.pdf) |

**V3.0.1, December 2022**

| Auditor    | Date          | Report                                                                                                      |
| ---------- | ------------- | ----------------------------------------------------------------------------------------------------------- |
| PeckShield | December 2022 | [View report](https://github.com/aave/aave-v3-core/blob/master/audits/09-12-2022_PeckShield_AaveV3-0-1.pdf) |
| SigmaPrime | December 2022 | [View report](https://github.com/aave/aave-v3-core/blob/master/audits/23-12-2022_SigmaPrime_AaveV3-0-1.pdf) |

**Formal verification, November 2021 to January 2022**

| Auditor | Date         | Report                                                                                                                 |
| ------- | ------------ | ---------------------------------------------------------------------------------------------------------------------- |
| Certora | January 2022 | [View report](https://github.com/aave/aave-v3-core/blob/master/certora/Aave_V3_Formal_Verification_Report_Jan2022.pdf) |

<table><thead><tr><th width="235.12109375">Auditor</th><th>Date</th><th>Report</th></tr></thead><tbody><tr><td>Zellic</td><td>August 2026</td><td><p><a href="https://files.gitbook.com/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FUBm7pNGfoWEDcBs1hL6I%2Fuploads%2Fakc507jHCVuMyDTeQgCx%2FMultiply%20-%20Zellic%20Audit%20Report%20(1).pdf?alt=media&#x26;token=c977ba6a-b21b-4c17-8d74-d4b973183f72">View report</a></p><p></p></td></tr><tr><td>LlamaRisk</td><td>August 2026</td><td><a href="https://files.gitbook.com/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FUBm7pNGfoWEDcBs1hL6I%2Fuploads%2FmQNBksTR9jAV0e5inBGS%2FTydro_%20kBTC%20Parameter%20Review%20-%20LlamaRisk%20v2.pdf?alt=media&#x26;token=0e2c6cb8-2658-4b36-ba22-db33c401ea72">View report</a></td></tr></tbody></table>

### Note: how to read an audit report

An audit is one input to security. A report reflects a defined scope and a point in time. It does not cover code changed after the review, and a clean report does not prove the absence of bugs. Read these reports and evaluate the level of the diligence applied, alongside the controls described in Smart contract security architecture.

### Bug bounties

Tydro has a bug bounty for verified issues. Reach out via official channels to contact our engineers.


# Developer Overview


# Official Links

Official Tydro links and the projects Tydro builds on. Always confirm you are using an official link before connecting a wallet or sending funds

{% hint style="danger" %}
Always confirm you are on an official Tydro domain before connecting a wallet or approving a transaction. Links shared by third parties may be malicious. Verify contract addresses against Contract Addresses.
{% endhint %}

### Tydro Official Links

| Resource | Link                         |
| -------- | ---------------------------- |
| App      | <https://tydro.com>          |
| Docs     | <https://docs.tydro.com>     |
| X        | <https://x.com/tydroHQ>      |
| GitHub   | <https://github.com/tydrohq> |

### Partner Links

| Project             | Link                               |
| ------------------- | ---------------------------------- |
| Ink                 | <https://inkonchain.com>           |
| Ink documentation   | <https://docs.inkonchain.com>      |
| Kraken              | <https://www.kraken.com>           |
| Aave                | <https://aave.com>                 |
| Aave developer docs | <https://docs.aave.com/developers> |
| Chainlink           | <https://chain.link>               |


# Smart Contracts

Tydro is built on a modular set of smart contracts, all available on [<mark style="color:blue;">GitHub</mark>](https://github.com/aave-dao/aave-v3-origin).\
Developers can integrate contract addresses directly into Solidity or JavaScript projects using the [<mark style="color:blue;">Tydro Address Book</mark>.](/vii.-developers/developer-overview/smart-contracts/contract-addresses)

The repository is organized into the following categories:

* Pool
* Configuration
* Logic
* Tokenization
* Helpers
* Misc

### Pool

#### Pool

The [Pool](/vii.-developers/developer-overview/smart-contracts/pool) is the central entry point to Tydro. All core user interactions such as supplying, borrowing, and repaying flow through this contract. Ownership of the Pool is tracked by the PoolAddressesProvider, and admin-level actions (like changing parameters) are routed through the PoolConfigurator.

#### L2Pool

The [L2Pool](/vii.-developers/developer-overview/smart-contracts/l2-pool) is an optimized version of the Pool contract, designed specifically for rollups.\
It enables gas-efficient interactions by accepting compact, byte-encoded calldata. This reduces transaction costs while maintaining the same functionality as the Pool.

#### PoolConfigurator

The [PoolConfigurator](/vii.-developers/developer-overview/smart-contracts/pool-configurator) manages risk parameters and configuration for the Pool. Only addresses with the appropriate permissions, assigned through the ACLManager, can call its write functions.

### Configuration

ACLManager

The [ACLManager](/vii.-developers/developer-overview/smart-contracts/aclmanager) is the registry of protocol roles and permissions. It defines and enforces access control across the system.

#### PoolAddressesProvider

The [PoolAddressesProvider](/vii.-developers/developer-overview/smart-contracts/pool-addresses-provider) is a registry of various components of the protocol, including the ACLManager and Pool contracts. It has the ability to  update pointers and proxy implementations to support upgrades.

### Logic

[Libraries](https://github.com/aave-dao/aave-v3-origin/blob/main/src/contracts/protocol/libraries/logic/) that implement the underlying mechanics of protocol operations. These libraries ensure that Pool interactions execute reliably and securely.

### Tokenization

#### aToken

Supplying assets mints [aTokens](/vii.-developers/developer-overview/smart-contracts/tokenization) which represent the depositor’s balance and automatically accrue yield. aTokens are burned when assets are withdrawn from the Pool

#### VariableDebtToken

Borrowing at a variable rate issues [VariableDebtTokens](/vii.-developers/developer-overview/smart-contracts/tokenization). These non-transferable tokens track a borrower’s position and increase automatically as interest accrues.

### Helpers

#### L2Encoder

The [L2Encoder](https://github.com/aave-dao/aave-v3-origin/blob/main/src/contracts/helpers/L2Encoder.sol) is a helper contract to encode calldata that is passed to the L2Pool. It is used to optimize calldata size in L2Pool for transaction cost reduction. It is only intended to help generate calldata for users/frontends.

#### TydroProtocolDataProvider

The [TydroProtocolDataProvider](/vii.-developers/developer-overview/smart-contracts/view-contracts#view-contracts) and formats data from the Pool, making it easier for applications to access key protocol information.

### Misc

#### TydroOracle

The [TydroOracle](/vii.-developers/developer-overview/smart-contracts/oracles#aaveoracle) manages reserve oracles and provides reference prices for assets. It ensures accurate pricing and updates sources as needed.

#### DefaultReserveInterestRateStrategy

The [DefaultReserveInterestRateStrategy](/vii.-developers/developer-overview/smart-contracts/interest-rate-strategy) calculates borrowing costs and yields based on the state of each reserve. It defines the parameters and logic used to update interest rates dynamically.

#### PriceOracleSentinel

The [PriceOracleSentinel](/vii.-developers/developer-overview/smart-contracts/oracles) safeguards the protocol during oracle disruptions. If a price feed becomes unavailable, it restricts operations until recovery and provides users with a grace period to restore healthy positions.


# Contract Addresses

<table><thead><tr><th width="285">Smart Contract Name</th><th width="456">Address</th></tr></thead><tbody><tr><td>TydroProtocolDataProvider</td><td>0x96086C25d13943C80Ff9a19791a40Df6aFC08328</td></tr><tr><td>ACLAdmin</td><td>0x1dF462e2712496373A347f8ad10802a5E95f053D</td></tr><tr><td>ACLManager</td><td>0x86E2938daE289763D4e09a7e42c5cCcA62Cf9809</td></tr><tr><td>Collector</td><td>0x9138E2cAdFEB23AFFdc0419F2912CaB8F135dba9</td></tr><tr><td>ConfigEngine</td><td>0xea9989569Cf2D860597b4d649c9A963c15ab84fa</td></tr><tr><td>ATokenInstance</td><td>0xd8247C7926841337E8adf9fD9E87026992C45062</td></tr><tr><td>DefaultIncentivesController</td><td>0xD93e3Ae8f69D04d484d1652Ca569d4b0522414DF</td></tr><tr><td>VariableDebtToken</td><td>0x294daB91f3539f5a74Ed995a59235eE62A14A345</td></tr><tr><td>Dustbin</td><td>0xb50881a9e7Ca0d1c08A59f4da1dE2f3D75B1E34E</td></tr><tr><td>EmissionManager</td><td>0x9CbcEf2c44cF28ff2aa36Bff7BaB315398209A79</td></tr><tr><td>L2Encoder </td><td>0x988B5d3863bdEE83339Be41cD31344Dfd9FD197c</td></tr><tr><td>TydroOracle</td><td>0x4758213271BFdC72224A7a8742dC865fC97756e1</td></tr><tr><td>Pool</td><td>0x2816cf15F6d2A220E789aA011D5EE4eB6c47FEbA</td></tr><tr><td>PoolAddressesProvider</td><td>0x4172E6aAEC070ACB31aaCE343A58c93E4C70f44D</td></tr><tr><td>PoolAddressesProviderRegistry</td><td>0x501B4c19dd9C2e06E94dA7b6D5Ed4ddA013EC741</td></tr><tr><td>PoolConfigurator</td><td>0x4f221e5c0B7103f7e3291E10097de6D9e3BfC02d</td></tr><tr><td>PoolConfiguratorInstance</td><td>0xe892E40C92c2E4D281Be59b2E6300F271d824E75</td></tr><tr><td>L2PoolInstance</td><td>0x2aB3580a805fB10CbAd567212C70e26C1B6769eC</td></tr><tr><td>StataFactory</td><td>0x5362dBb1e601abF3a4c14c22ffEdA64042E5eAA3</td></tr><tr><td>UIIncentiveDataProvider</td><td>0x25Ec457d1778b0E5316e7f38f3c22baF413F1A8C</td></tr><tr><td>UIPoolDataProvider</td><td>0x39bc1bfDa2130d6Bb6DBEfd366939b4c7aa7C697</td></tr><tr><td>WalletBalanceProvider</td><td>0xB1532b76D054c9F9E61b25c4d91f69B4133E4671</td></tr><tr><td>WETHGateway</td><td>0xDe090EfCD6ef4b86792e2D84E55a5fa8d49D25D2</td></tr><tr><td>BorrowLogic</td><td>0xFeD9871528E713B5038c4c44BbE7a315f56cAdc6</td></tr><tr><td>EModeLogic</td><td>0xD1bddC05A3BB5A7907d82A1b4F1E21dBCE69c3d5</td></tr><tr><td>FlashLoanLogic</td><td>0x5e84CEe2afb7B37d2AB14722C39A7c1C26F5B0BB</td></tr><tr><td>LiquidationLogic</td><td>0x36Ae486289bB807C3C79A1427b9c3D934294ef43</td></tr><tr><td>PoolLogic</td><td>0xE51B69e5722Bf547866A4d7Bc190c6e81b626806</td></tr><tr><td>SupplyLogic</td><td>0x034Fd14b9Ae6bB066a1F9f85A55e990b0b25c168</td></tr></tbody></table>


# Pool

This contract is the main user-facing contract. Most user interactions with Tydro occur via the Pool contract. It exposes the liquidity management methods that can be invoked using either ***Solidity*** or ***Web3*** libraries.

The Pool contract is the main entry point for users in Tydro. Most interactions such as supplying, borrowing, repaying, or managing collateral are executed through this contract. It exposes all core liquidity functions and can be called directly in Solidity or through Web3 libraries.

#### Functions available through Pool

Users can interact with the Pool contract to:

* Supply assets into the protocol
* Withdraw supplied assets
* Borrow against collateral
* Repay borrowed assets
* Enable or disable assets as collateral
* Liquidate undercollateralised positions

The Pool contract is deployed behind a proxy and registered with the [PoolAddressesProvider](/vii.-developers/developer-overview/smart-contracts/pool-addresses-provider) of each market. Administrative actions are routed through the  [PoolConfigurator](/vii.-developers/developer-overview/smart-contracts/pool-configurator) contract referenced in the [PoolAddressesProvider](/vii.-developers/developer-overview/smart-contracts/pool-addresses-provider).

The source code is available on [<mark style="color:blue;">GitHub</mark>](https://github.com/aave-dao/aave-v3-origin/blob/main/src/contracts/protocol/pool/Pool.sol).

### Write Methods

#### initialize

```
function initialize(IPoolAddressesProvider provider) external virtual
```

Initializes the Pool.

Function is invoked by the proxy contract when the Pool contract is added to the [PoolAddressesProvider](/vii.-developers/developer-overview/smart-contracts/pool-addresses-provider) of the market.

Caches the address of the [PoolAddressesProvider](/vii.-developers/developer-overview/smart-contracts/pool-addresses-provider) in order to reduce gas consumption on subsequent operations.

#### Input Parameters:

| Name     | Type      | Description                              |
| -------- | --------- | ---------------------------------------- |
| provider | `address` | The address of the PoolAddressesProvider |

#### supply

```
function supply(
    address asset,
    uint256 amount,
    address onBehalfOf,
    uint16 referralCode
) public virtual override
```

Supplies a certain amount of an asset into the protocol, minting the same amount of corresponding aTokens and transferring them to the onBehalfOf address. For example, if a user supplies 100 USDC and onBehalfOf address is the same as msg.sender, they will get 100 aUSDC in return.

The referralCode is emitted in Supply event and can be for third-party referral integrations. To activate the referral feature and obtain a unique referral code, integrators need to submit a proposal to Tydro.

> ⚠️ **Warning:** When supplying, the `Pool` contract must have `allowance()` to spend funds on behalf of `msg.sender` for at least the amount for the asset being supplied. This can be done via the standard ERC20 `approve()` method on the underlying token contract.

{% hint style="info" %}
Referral supply is currently inactive, you can pass 0 as referralCode. This program may be activated in the future through a Tydro proposal.
{% endhint %}

#### Input Parameters:

| Name         | Type      | Description                                                                                                                                                                                                                                                                                                                |
| ------------ | --------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| asset        | `address` | The address of the underlying asset being supplied to the pool                                                                                                                                                                                                                                                             |
| amount       | `uint256` | The amount of asset to be supplied                                                                                                                                                                                                                                                                                         |
| onBehalfOf   | `address` | The address that will receive the corresponding aTokens. This is the only address that will be able to withdraw the asset from the pool. This will be the same as `msg.sender` if the user wants to receive aTokens into their own wallet, or use a different address if the beneficiary of aTokens is a different wallet. |
| referralCode | `uint16`  | Referral supply is currently inactive, you can pass `0`. This code is used to register the integrator originating the operation, for potential rewards. `0` if the action is executed directly by the user, without any middle-men.                                                                                        |

#### supplyWithPermit

```
function supplyWithPermit(
    address asset,
    uint256 amount,
    address onBehalfOf,
    uint16 referralCode,
    uint256 deadline,
    uint8 permitV,
    bytes32 permitR,
    bytes32 permitS
) public virtual override
```

Supply with transfer approval of the asset to be supplied via permit function. This method removes the need for separate approval tx before supplying asset to the pool. See: <https://eips.ethereum.org/EIPS/eip-2612>.

{% hint style="info" %}
Permit signature must be signed by msg.sender with spender as Pool address.
{% endhint %}

{% hint style="info" %}
Referral program is currently inactive, you can pass 0 as referralCode. This program may be activated in the future through a Tydro proposal.
{% endhint %}

#### Input Parameters:

| Name         | Type      | Description                                                                                                                                                                                                                        |
| ------------ | --------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| asset        | `address` | The address of underlying asset being supplied. The same asset as used in permit `v`, `s`, and `r`                                                                                                                                 |
| amount       | `uint256` | The amount of asset to be supplied and signed for approval. The same amount as used in permit `v`, `s`, and `r`                                                                                                                    |
| onBehalfOf   | `address` | The address that will receive the aTokens. This will be the same as `msg.sender` if the user wants to receive aTokens into their own wallet, or use a different address if the beneficiary of aTokens is a different wallet        |
| referralCode | `uint16`  | Referral supply is currently inactive, you can pass `0`. This code is used to register the integrator originating the operation, for potential rewards. `0` if the action is executed directly by the user, without any middle-men |
| deadline     | `uint256` | The unix timestamp up until which the permit signature is valid                                                                                                                                                                    |
| permitV      | `uint8`   | The `v` parameter of the ERC712 permit signature                                                                                                                                                                                   |
| permitR      | `bytes32` | The `r` parameter of the ERC712 permit signature                                                                                                                                                                                   |
| permitS      | `bytes32` | The `s` parameter of the ERC712 permit signature                                                                                                                                                                                   |

#### withdraw

```
function withdraw(address asset, uint256 amount, address to) public virtual override returns (uint256)
```

Withdraws an amount of underlying asset from the reserve, burning the equivalent aTokens owned. For example, if a user has 100 aUSDC and calls withdraw(), they will receive 100 USDC, burning the 100 aUSDC.

If user has any existing debt backed by the underlying token, then the maximum amountavailable to withdraw is the amount that will not leave user's health factor < 1 after withdrawal.

{% hint style="info" %}
When withdrawing to another address, msg.sender should have aToken that will be burned by Pool.
{% endhint %}

{% hint style="info" %}
Reserves with a Loan To Value parameter of 0% must be disabled as collateral (using Pool.setUserUseReserveAsCollateral or by fully withdrawing the supplied balance) before other assets can be withdrawn.
{% endhint %}

#### Input Parameters:

| Name   | Type      | Description                                                                                                                                                                                                                    |
| ------ | --------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| asset  | `address` | The address of the underlying asset to withdraw, not the aToken                                                                                                                                                                |
| amount | `uint256` | The underlying amount to be withdrawn (the amount supplied), expressed in wei units. Use `type(uint).max` to withdraw the entire aToken balance                                                                                |
| to     | `address` | The address that will receive the underlying `asset`. This will be the same as `msg.sender` if the user wants to receive the tokens into their own wallet, or use a different address if the beneficiary is a different wallet |

#### Return Values:

| Type      | Description                |
| --------- | -------------------------- |
| `uint256` | The final amount withdrawn |

#### borrow

```
function borrow(
    address asset,
    uint256 amount,
    uint256 interestRateMode,
    uint16 referralCode,
    address onBehalfOf
) public virtual override
```

Allows users to borrow a specific amount of the reserve underlying asset, provided the borrower has already supplied enough collateral, or they were given enough allowance by a credit delegator on the corresponding debt token (VariableDebtToken). For example, if a user borrows 100 USDC passing their own address as onBehalfOf, they will receive 100 USDC into their wallet and 100 variable debt tokens.

{% hint style="info" %}
NOTE: If onBehalfOf is not the same as msg.sender, then onBehalfOf must have supplied enough collateral via supply() and have delegated credit to msg.sender via approveDelegation().
{% endhint %}

{% hint style="info" %}
Referral program is currently inactive, you can pass 0 as referralCode. This program may be activated in the future.
{% endhint %}

#### Input Parameters:

| Name             | Type      | Description                                                                                                                                                                                                                        |
| ---------------- | --------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| asset            | `address` | The address of the underlying asset to borrow                                                                                                                                                                                      |
| amount           | `uint256` | The amount to be borrowed, expressed in wei units                                                                                                                                                                                  |
| interestRateMode | `uint256` | Should always be passed a value of `2` (variable rate mode)                                                                                                                                                                        |
| referralCode     | `uint16`  | Referral supply is currently inactive, you can pass `0`. This code is used to register the integrator originating the operation, for potential rewards. `0` if the action is executed directly by the user, without any middle-men |
| onBehalfOf       | `address` | This should be the address of the borrower calling the function if they want to borrow against their own collateral, or the address of the credit delegator if the caller has been given credit delegation allowance               |

repay

```
function repay(
    address asset,
    uint256 amount,
    uint256 interestRateMode,
    address onBehalfOf
) public virtual override returns (uint256)
```

Repays a borrowed amount on a specific reserve, burning the equivalent debt tokens owned. For example, if a user repays 100 USDC, the 100 variable debt tokens owned by the onBehalfOfaddress will be burned.

> ⚠️ **Warning:**  When repaying, the `Pool` contract must have allowance to spend funds on behalf of `msg.sender` for at least the `amount` for the asset you are repaying with. This can be done via the standard ERC20 `approve()` method on the underlying token contract.

#### Input Parameters:

| Name             | Type      | Description                                                                                                                                                                                                                                                                                                   |
| ---------------- | --------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| asset            | `address` | The address of the borrowed underlying asset previously borrowed                                                                                                                                                                                                                                              |
| amount           | `uint256` | The amount to repay, expressed in wei units. Use `type(uint256).max` in order to repay the whole debt, ONLY when the repayment is not executed on behalf of a 3rd party. In case of repayments on behalf of another user, it's recommended to send an amount slightly higher than the current borrowed amount |
| interestRateMode | `uint256` | Only available option is `2` (variableRateMode)                                                                                                                                                                                                                                                               |
| onBehalfOf       | `address` | The address of the user who will get their debt reduced/removed. This should be the address of the user calling the function if they want to reduce/remove their own debt, or the address of any other borrower whose debt should be removed                                                                  |

#### repayWithPermit

```
function repayWithPermit(
    address asset,
    uint256 amount,
    uint256 interestRateMode,
    address onBehalfOf,
    uint256 deadline,
    uint8 permitV,
    bytes32 permitR,
    bytes32 permitS
) public virtual override returns (uint256)
```

Repay with transfer approval of the borrowed asset to be repaid, done via permit function. This method removes the need for separate approval tx before repaying asset to the pool. See: <https://eips.ethereum.org/EIPS/eip-2612>.

{% hint style="info" %}
Permit signature must be signed by msg.sender with spender value as Pool address.
{% endhint %}

#### Input Parameters:

| Name             | Type      | Description                                                                                                                                                                                                                                  |
| ---------------- | --------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| asset            | `address` | The address of the borrowed underlying asset previously borrowed. The same asset as used in permit `v`, `r`, and `s`                                                                                                                         |
| amount           | `uint256` | The amount to repay, expressed in wei units. Use `type(uint256).max` in order to repay the whole debt to pay without leaving aToken dust. The same amount as used in permit `v`,`r`,`s`                                                      |
| interestRateMode | `uint256` | Only available option is `2` (variableRateMode)                                                                                                                                                                                              |
| onBehalfOf       | `address` | The address of the user who will get their debt reduced/removed. This should be the address of the user calling the function if they want to reduce/remove their own debt, or the address of any other borrower whose debt should be removed |
| deadline         | `uint256` | The unix timestamp up until which the permit signature is valid                                                                                                                                                                              |
| permitV          | `uint8`   | The `v` parameter of the ERC712 permit signature                                                                                                                                                                                             |
| permitR          | `bytes32` | The `r` parameter of the ERC712 permit signature                                                                                                                                                                                             |
| permitS          | `bytes32` | The `s` parameter of the ERC712 permit signature                                                                                                                                                                                             |

**Return Values:**

| Type      | Description             |
| --------- | ----------------------- |
| `uint256` | The final amount repaid |

repayWithATokens

```
function repayWithATokens(address asset, uint256 amount, uint256 interestRateMode
) public virtual override returns (uint256)
```

Allows a user to repay a borrowed amount on a specific reserve using the reserve aTokens, burning the equivalent debt tokens. For example, a user repays 100 USDC using 100 aUSDC, burning 100 variable debt tokens. Passing uint256.maxas the amount will clean up any residual aToken dust balance, if the user aToken balance is not enough to cover the whole debt.

#### Input Parameters:

| Name             | Type      | Description                                                                                                                  |
| ---------------- | --------- | ---------------------------------------------------------------------------------------------------------------------------- |
| asset            | `address` | The address of the borrowed underlying asset previously borrowed                                                             |
| amount           | `uint256` | The amount to repay. Use `type(uint256).max` in order to repay the whole debt for `asset` to pay without leaving aToken dust |
| interestRateMode | `uint256` | Only available option is `2` (variableRateMode)                                                                              |

**Return Values:**

| Type      | Description             |
| --------- | ----------------------- |
| `uint256` | The final amount repaid |

#### setUserUseReserveAsCollateral

```
function setUserUseReserveAsCollateral(address asset, bool useAsCollateral) public virtual override
```

Allows suppliers to enable/disable a specific supplied asset as collateral. Sets the <kbd>asset</kbd> of <kbd>msg.sender</kbd> to be used as collateral or not.

{% hint style="info" %}
An asset in Isolation Mode can be enabled to use as collateral only if no other asset is already enabled to use as collateral.
{% endhint %}

{% hint style="info" %}
An asset with LTV parameter of 0% cannot be enabled as collateral.
{% endhint %}

{% hint style="info" %}
The user won’t be able to disable an asset as collateral if they have an outstanding debt position which could be left with the Health Factor < HEALTH\_FACTOR\_LIQUIDATION\_THRESHOLD on disabling the given asset as collateral.
{% endhint %}

**Input Parameters:**

| Name            | Type      | Description                                                                 |
| --------------- | --------- | --------------------------------------------------------------------------- |
| asset           | `address` | The address of the underlying asset supplied                                |
| useAsCollateral | `bool`    | `true` if the user wants to use the supply as collateral, `false` otherwise |

#### liquidationCall

```
function liquidationCall(
    address collateralAsset,
    address debtAsset,
    address user,
    uint256 debtToCover,
    bool receiveAToken
) public virtual override
```

Function to liquidate a non-healthy position collateral-wise, with Health Factor below 1.

When the health factor of a position is below 1, the caller (liquidator) repays the debtToCoveramount of debt of the user getting liquidated. This is part or all of the outstanding borrowed amount on behalf of the borrower. The caller then receives a proportional amount of the collateralAsset (discounted amount of collateral) plus a liquidation bonus to cover market risk.

Liquidators can decide if they want to receive an equivalent amount of collateral aTokens instead of the underlying asset. When the liquidation is completed successfully, the health factor of the position is increased, bringing the health factor above 1.

Liquidators can only close a certain amount of collateral defined by a close factor. Currently the **close factor is 0.5**. In other words, liquidators can only liquidate a maximum of 50% of the amount pending to be repaid in a position. The liquidation discount applies to this amount.

* *In most scenarios*, profitable liquidators will choose to liquidate as much as they can (50% of the user position).
* debtToCover parameter can be set to uint(-1) and the protocol will proceed with the highest possible liquidation allowed by the close factor.
* To check a user's health factor, use \[getUserAccountData()].

{% hint style="info" %}
Liquidators must approve() the Pool contract to use debtToCover of the underlying ERC20 of the asset used for the liquidation.
{% endhint %}

**Input Parameters:**

| Name            | Type      | Description                                                                                                                                                            |
| --------------- | --------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| collateralAsset | `address` | The address of the underlying asset used as collateral, to receive as result of the liquidation                                                                        |
| debtAsset       | `address` | The address of the underlying borrowed asset to be repaid with the liquidation                                                                                         |
| user            | `address` | The address of the borrower getting liquidated                                                                                                                         |
| debtToCover     | `uint256` | The debt amount of borrowed `asset` the liquidator will repay                                                                                                          |
| receiveAToken   | `bool`    | `true` if the liquidator wants to receive the aTokens equivalent of the purchased collateral, `false` if they want to receive the underlying collateral asset directly |

#### flashLoan

```
function flashLoan(
    address receiverAddress,
    address[] calldata assets,
    uint256[] calldata amounts,
    uint256[] calldata interestRateModes,
    address onBehalfOf,
    bytes calldata params,
    uint16 referralCode
) public virtual override
```

Allows users to access liquidity of the pool for a given list of assets within one transaction, as long as the amount taken plus a fee is returned. The receiver must approve the Pool contract for at least the *amount borrowed + fee*, otherwise the transaction will revert.

The flash loan fee is waived for approved FLASH\_BORROWER.

There are security concerns for developers of flashloan receiver contracts that must be taken into consideration. For further details, visit [Flash Loan Developers Guide](broken://pages/eL6fnJhWHjQSrO6sYVSY).

{% hint style="info" %}
Referral program is currently inactive, you can pass 0 as referralCode. This program may be activated in the future through a Tydro proposal.
{% endhint %}

**Input Parameters:**

| Name              | Type       | Description                                                                                                                                                                                                                                                                                                                     |
| ----------------- | ---------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| receiverAddress   | address    | The address of the contract receiving the flash-borrowed funds, implementing the IFlashLoanReceiver interface                                                                                                                                                                                                                   |
| assets            | address\[] | The addresses of the assets being flash-borrowed                                                                                                                                                                                                                                                                                |
| amounts           | uint256\[] | The amounts of the assets being flash-borrowed. This needs to contain the same number of entries as assets                                                                                                                                                                                                                      |
| interestRateModes | uint256\[] | The types of the debt position to open if the flash loan is not returned: 0 -> Don't open any debt, the amount + fee must be paid in this case or just revert if the funds can't be transferred from the receiver. 2 -> Open variable rate borrow position for the value of the amount flash-borrowed to the onBehalfOf address |
| onBehalfOf        | address    | The address that will receive the debt if the associated interestRateModes is 1 or 2. onBehalfOf must already have approved sufficient borrow allowance of the associated asset to msg.sender                                                                                                                                   |
| params            | bytes      | Variadic packed params to pass to the receiver as extra information                                                                                                                                                                                                                                                             |
| referralCode      | uint16     | Referral supply is currently inactive, you can pass 0. This code is used to register the integrator originating the operation, for potential rewards. 0 if the action is executed directly by the user, without any middle-men                                                                                                  |

#### flashLoanSimple

```
function flashLoanSimple(    address receiverAddress,    address asset,    uint256 amount,    bytes calldata params,    uint16 referralCode) public virtual override
```

Allows users to access liquidity of the pool for a given asset within one transaction, as long as the amount taken plus a fee is returned. The receiver must approve the Pool contract for at least the *amount borrowed + fee*, otherwise the transaction will revert.

This function does not waive the fee for approved FLASH\_BORROWER, nor does it allow for opening a debt position instead of repaying.

There are security concerns for developers of flashloan receiver contracts that must be kept into consideration.

Referral program is currently inactive, you can pass 0 as referralCode. This program may be activated in the future through an Tydro proposal

**Input Parameters:**

| Name            | Type    | Description                                                                                                                                                                                                                    |
| --------------- | ------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| receiverAddress | address | The address of the contract receiving the flash-borrowed funds, implementing the IFlashLoanReceiver interface                                                                                                                  |
| asset           | address | The address of the asset being flash-borrowed                                                                                                                                                                                  |
| amount          | uint256 | The amount of the asset being flash-borrowed                                                                                                                                                                                   |
| params          | bytes   | Variadic packed params to pass to the receiver as extra information                                                                                                                                                            |
| referralCode    | uint16  | Referral supply is currently inactive, you can pass 0. This code is used to register the integrator originating the operation, for potential rewards. 0 if the action is executed directly by the user, without any middle-men |

#### mintToTreasury

```
function mintToTreasury(address[] calldata assets) external virtual override
```

Mints the assets accrued through the reserve factor to the treasury in the form of aTokens for the given list of assets.

**Input Parameters:**

| Name   | Type       | Description                                                     |
| ------ | ---------- | --------------------------------------------------------------- |
| assets | address\[] | The list of reserves for which the minting needs to be executed |

#### finalizeTransfer

```
function finalizeTransfer(    address asset,    address from,    address to,    uint256 amount,    uint256 balanceFromBefore,    uint256 balanceToBefore) external virtual override
```

Validates and finalizes an aToken transfer. It is only callable by the overlying aToken of the asset.

**Input Parameters:**

| Name              | Type    | Description                                             |
| ----------------- | ------- | ------------------------------------------------------- |
| asset             | address | The address of the underlying asset of the aToken       |
| from              | address | The user from which the aTokens are transferred         |
| to                | address | The user receiving the aTokens                          |
| amount            | uint256 | The amount being transferred/withdrawn                  |
| balanceFromBefore | uint256 | The aToken balance of the from user before the transfer |
| balanceToBefore   | uint256 | The aToken balance of the to user before the transfer   |

#### setUserEMode

```
function setUserEMode(uint8 categoryId) external virtual override
```

Allows a user to use the protocol in efficiency mode. The category id must be a valid id already defined by *Pool or Risk Admins*.

Will revert if user is borrowing non-compatible asset or if the change will drop the Health Factor < HEALTH\_FACTOR\_LIQUIDATION\_THRESHOLD.

**Input Parameters:**

| Name       | Type  | Description                                                                                                 |
| ---------- | ----- | ----------------------------------------------------------------------------------------------------------- |
| categoryId | uint8 | The eMode category id (0 - 255) defined by Risk or Pool Admins. categoryId set to 0 is a non eMode category |

#### mintUnbacked

```
function mintUnbacked(
    address asset,
    uint256 amount,
    address onBehalfOf,
    uint16 referralCode
) external virtual override onlyBridge
```

Allows contracts with BRIDGE role permission to mint an amount of unbacked aTokens to the `onBehalfOf` address.

Only available to the addresses with BRIDGE role. Bridge addresses can be whitelisted by Tydro.

Referral program is currently inactive, you can pass 0 as referralCode. This program may be activated in the future through a Tydro proposal.

**Input Parameters:**

| Name         | Type    | Description                                                                                                                                                                                                                    |
| ------------ | ------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| asset        | address | The address of the underlying asset to mint                                                                                                                                                                                    |
| amount       | uint256 | The amount to mint                                                                                                                                                                                                             |
| onBehalfOf   | address | The address that will receive the aTokens                                                                                                                                                                                      |
| referralCode | uint16  | Referral supply is currently inactive, you can pass 0. This code is used to register the integrator originating the operation, for potential rewards. 0 if the action is executed directly by the user, without any middle-men |

#### backUnbacked

```
function backUnbacked(    address asset,    uint256 amount,    uint256 fee) external virtual override onlyBridge returns (uint256)
```

Allows contracts with BRIDGE role permission to back the current unbacked underlying aTokens with amount and pay fee

Only available to the addresses with BRIDGE role. Bridge addresses can be whitelisted by Tydro.

**Input Parameters:**

| Name   | Type    | Description                                              |
| ------ | ------- | -------------------------------------------------------- |
| asset  | address | The address of the underlying asset to back              |
| amount | uint256 | The amount of asset supplied to back the unbacked tokens |
| fee    | uint256 | The amount paid in fees                                  |

**Return Value:**

| Type    | Description                                                                                                                                                                |
| ------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| uint256 | The final amount backed, representing the portion of assets that were successfully supplied to back the unbacked aTokens, including any fees that were taken into account. |

#### initReserve

```
function initReserve(    address asset,    address aTokenAddress,    address stableDebtAddress,    address variableDebtAddress,    address interestRateStrategyAddress) external virtual override onlyPoolConfigurator
```

Initializes a reserve, activating it, assigning an aToken and debt tokens and an interest rate strategy.

Only callable by the [PoolConfigurator](/vii.-developers/developer-overview/smart-contracts/pool-configurator) contract.

**Input Parameters:**

| Name                        | Type    | Description                                                                          |
| --------------------------- | ------- | ------------------------------------------------------------------------------------ |
| asset                       | address | The address of the underlying asset of the reserve                                   |
| aTokenAddress               | address | The address of the aToken that will be assigned to the reserve                       |
| stableDebtAddress           | address | The address of the StableDebtToken that will be assigned to the reserve (deprecated) |
| variableDebtAddress         | address | The address of the VariableDebtToken that will be assigned to the reserve            |
| interestRateStrategyAddress | address | The address of the interest rate strategy contract                                   |

#### dropReserve

```
function dropReserve(address asset) external virtual override onlyPoolConfigurator
```

Drop a reserve.

Only callable by the [PoolConfigurator](/vii.-developers/developer-overview/smart-contracts/pool-configurator) contract.

**Input Parameters:**

| Name  | Type    | Description                                        |
| ----- | ------- | -------------------------------------------------- |
| asset | address | The address of the underlying asset of the reserve |

#### setReserveInterestRateStrategyAddress

```
function setReserveInterestRateStrategyAddress(address asset, address rateStrategyAddress) external virtual override onlyPoolConfigurator
```

Updates the address of the interest rate strategy contract.

Only callable by the [PoolConfigurator](/vii.-developers/developer-overview/smart-contracts/pool-configurator) contract.

**Input Parameters:**

| Name                | Type    | Description                                        |
| ------------------- | ------- | -------------------------------------------------- |
| asset               | address | The address of the underlying asset of the reserve |
| rateStrategyAddress | address | The address of the interest rate strategy contract |

#### setConfiguration

```
function setConfiguration(address asset, DataTypes.ReserveConfigurationMap calldata configuration) external virtual override onlyPoolConfigurator
```

Sets the configuration bitmap of the reserve as a whole.

Only callable by the [PoolConfigurator](/vii.-developers/developer-overview/smart-contracts/pool-configurator) contract.

**Input Parameters:**

| Name          | Type                              | Description                                        |
| ------------- | --------------------------------- | -------------------------------------------------- |
| asset         | address                           | The address of the underlying asset of the reserve |
| configuration | DataTypes.ReserveConfigurationMap | The new configuration bitmap                       |

The [DataTypes.ReserveConfigurationMap](https://github.com/aave-dao/aave-v3-origin/blob/3aad8ca184159732e4b3d8c82cd56a8707a106a2/src/core/contracts/protocol/libraries/types/DataTypes.sol#L79) struct is composed of the following fields:

| bit     | Description                                                                                   |
| ------- | --------------------------------------------------------------------------------------------- |
| 0-15    | LTV                                                                                           |
| 16-31   | Liquidation threshold                                                                         |
| 32-47   | Liquidation bonus                                                                             |
| 48-55   | Decimals                                                                                      |
| 56      | Reserve is active                                                                             |
| 57      | Reserve is frozen                                                                             |
| 58      | Borrowing is enabled                                                                          |
| 59      | Stable rate borrowing enabled (deprecated)                                                    |
| 60      | Asset is paused                                                                               |
| 61      | Borrowing in isolation mode is enabled                                                        |
| 62      | Siloed borrowing is enabled                                                                   |
| 63      | Flashloaning is enabled                                                                       |
| 64-79   | Reserve factor                                                                                |
| 80-115  | Borrow cap in whole tokens, borrowCap == 0 => no cap                                          |
| 116-151 | Supply cap in whole tokens, supplyCap == 0 => no cap                                          |
| 152-167 | Liquidation protocol fee                                                                      |
| 168-175 | eMode category (deprecated)                                                                   |
| 176-211 | Unbacked mint cap in whole tokens, unbackedMintCap == 0 => minting disabled                   |
| 212-251 | Debt ceiling for isolation mode with (ReserveConfiguration::DEBT\_CEILING\_DECIMALS) decimals |
| 252     | Virtual accounting is enabled                                                                 |
| 253-255 | Unused                                                                                        |

#### updateBridgeProtocolFee

```
function updateBridgeProtocolFee(uint256 protocolFee) external virtual override onlyPoolConfigurator
```

Updates the protocol fee on the bridging.

Only callable by the [PoolConfigurator](/vii.-developers/developer-overview/smart-contracts/pool-configurator) contract.

**Input Parameters:**

| Name        | Type    | Description                                           |
| ----------- | ------- | ----------------------------------------------------- |
| protocolFee | uint256 | The part of the premium sent to the protocol treasury |

#### updateFlashloanPremiums

```
function updateFlashloanPremiums(uint128 flashLoanPremiumTotal, uint128 flashLoanPremiumToProtocol) external virtual override onlyPoolConfigurator
```

Updates flash loan premiums. A flash loan premium consists of two parts:

* A part is sent to aToken holders as extra, one time accumulated interest
* A part is collected by the protocol treasury

The total premium is calculated on the total borrowed amount. The premium to protocol is calculated on the total premium, being a percentage of flashLoanPremiumTotal.

Only callable by the [PoolConfigurator](/vii.-developers/developer-overview/smart-contracts/pool-configurator) contract.

**Input Parameters:**

| Name                       | Type    | Description                                                             |
| -------------------------- | ------- | ----------------------------------------------------------------------- |
| flashLoanPremiumTotal      | uint128 | The total premium, expressed in bps                                     |
| flashLoanPremiumToProtocol | uint128 | The part of the premium sent to the protocol treasury, expressed in bps |

#### configureEModeCategory

```
function configureEModeCategory(uint8 id, DataTypes.EModeCategory memory category) external virtual override onlyPoolConfigurator
```

Configures a new category for the eMode. In eMode, the protocol allows very high borrowing power to borrow assets of the same category. The category 0 is reserved for volatile heterogeneous assets and it's always disabled.

Each eMode category has a custom ltv and liquidation threshold. Each eMode category may or may not have a custom oracle to override the individual assets price oracles.

Only callable by the [PoolConfigurator](/vii.-developers/developer-overview/smart-contracts/pool-configurator) contract.

**Input Parameters:**

| Name     | Type                    | Description                         |
| -------- | ----------------------- | ----------------------------------- |
| id       | uint8                   | The total premium, expressed in bps |
| category | DataTypes.EModeCategory | The configuration of the category   |

The [DataTypes.EModeCategory](https://github.com/aave-dao/aave-v3-origin/blob/3aad8ca184159732e4b3d8c82cd56a8707a106a2/src/core/contracts/protocol/libraries/types/DataTypes.sol#L114) struct is composed of the following fields:

| Name                 | Type    | Description                                             |
| -------------------- | ------- | ------------------------------------------------------- |
| ltv                  | uint16  | The custom Loan to Value for the eMode category         |
| liquidationThreshold | uint16  | The custom liquidation threshold for the eMode category |
| liquidationBonus     | uint16  | The liquidation bonus for the eMode category            |
| collateralBitmap     | uint128 | Bitmap of collateral assets in the category             |
| label                | string  | The custom label describing the eMode category          |
| borrowableBitmap     | uint128 | Bitmap of borrowable assets in the category             |

#### resetIsolationModeTotalDebt

```
function resetIsolationModeTotalDebt(address asset) external virtual override onlyPoolConfigurator
```

Resets the isolation mode total debt of the given asset to zero. It requires the given asset to have a zero debt ceiling.

Only callable by the [PoolConfigurator](/vii.-developers/developer-overview/smart-contracts/pool-configurator) contract.

**Input Parameters:**

| Name  | Type    | Description                                                             |
| ----- | ------- | ----------------------------------------------------------------------- |
| asset | address | The address of the underlying asset to reset the isolationModeTotalDebt |

#### rescueTokens

```
function rescueTokens(
    address token,
    address to,
    uint256 amount
) external virtual override onlyPoolAdmin
```

Rescue and transfer tokens locked in this contract.

Only available to [POOL\_ADMIN](/vii.-developers/developer-overview/smart-contracts/aclmanager) role. The Pool Admin is designated by Tydro.

**Input Parameters:**

| Name   | Type    | Description                     |
| ------ | ------- | ------------------------------- |
| token  | address | The address of the token        |
| to     | address | The address of the recipient    |
| amount | uint256 | The amount of token to transfer |

#### eliminateReserveDeficit

Covers the deficit of a specified reserve by burning the equivalent aToken amount for assets with virtual accounting enabled or the equivalent amount of underlying for assets with virtual accounting disabled (e.g. GHO). Only callable by address with onlyUmbrella modifier.

```
function eliminateReserveDeficit(address asset, uint256 amount) external;
```

**Input Parameters:**

| Name   | Type    | Description                                                                       |
| ------ | ------- | --------------------------------------------------------------------------------- |
| asset  | address | Underlying token address                                                          |
| amount | uint256 | The amount to be covered, in aToken or underlying on non-virtual accounted assets |

### View Methods

#### getUserAccountData

```
function getUserAccountData(address user) external view virtual override returns (    uint256 totalCollateralBase,    uint256 totalDebtBase,    uint256 availableBorrowsBase,    uint256 currentLiquidationThreshold,    uint256 ltv,    uint256 healthFactor)
```

Returns the user account data across all the reserves.

**Input Parameters:**

| Name | Type    | Description             |
| ---- | ------- | ----------------------- |
| user | address | The address of the user |

**Return Values:**

| Name                        | Type    | Description                                                                      |
| --------------------------- | ------- | -------------------------------------------------------------------------------- |
| totalCollateralBase         | uint256 | The total collateral of the user in the base currency used by the price feed     |
| totalDebtBase               | uint256 | The total debt of the user in the base currency used by the price feed           |
| availableBorrowsBase        | uint256 | The borrowing power left of the user in the base currency used by the price feed |
| currentLiquidationThreshold | uint256 | The liquidation threshold of the user                                            |
| ltv                         | uint256 | The loan to value of the user                                                    |
| healthFactor                | uint256 | The current health factor of the user                                            |

#### getConfiguration

```
function getConfiguration(address asset) external view virtual override returns (DataTypes.ReserveConfigurationMap memory)
```

Returns the configuration of the reserve.

**Input Parameters:**

| Name  | Type    | Description                                        |
| ----- | ------- | -------------------------------------------------- |
| asset | address | The address of the underlying asset of the reserve |

**Return Values:**

| Type                              | Description                      |
| --------------------------------- | -------------------------------- |
| DataTypes.ReserveConfigurationMap | The configuration of the reserve |

The [DataTypes.ReserveConfigurationMap](https://github.com/aave-dao/aave-v3-origin/blob/3aad8ca184159732e4b3d8c82cd56a8707a106a2/src/core/contracts/protocol/libraries/types/DataTypes.sol#L79) struct is composed of the following fields:

| bit     | Description                                                                                   |
| ------- | --------------------------------------------------------------------------------------------- |
| 0-15    | LTV                                                                                           |
| 16-31   | Liquidation threshold                                                                         |
| 32-47   | Liquidation bonus                                                                             |
| 48-55   | Decimals                                                                                      |
| 56      | Reserve is active                                                                             |
| 57      | Reserve is frozen                                                                             |
| 58      | Borrowing is enabled                                                                          |
| 59      | Stable rate borrowing enabled (deprecated)                                                    |
| 60      | Asset is paused                                                                               |
| 61      | Borrowing in isolation mode is enabled                                                        |
| 62      | Siloed borrowing enabled                                                                      |
| 63      | Flashloaning enabled                                                                          |
| 64-79   | Reserve factor                                                                                |
| 80-115  | Borrow cap in whole tokens, borrowCap == 0 => no cap                                          |
| 116-151 | Supply cap in whole tokens, supplyCap == 0 => no cap                                          |
| 152-167 | Liquidation protocol fee                                                                      |
| 168-175 | eMode category (deprecated)                                                                   |
| 176-211 | Unbacked mint cap in whole tokens, unbackedMintCap == 0 => minting disabled                   |
| 212-251 | Debt ceiling for isolation mode with (ReserveConfiguration::DEBT\_CEILING\_DECIMALS) decimals |
| 252     | Virtual accounting is enabled for the reserve                                                 |
| 253-255 | Unused                                                                                        |

#### getUserConfiguration

```
function getUserConfiguration(address user) external view virtual override returns (DataTypes.UserConfigurationMap memory)
```

Returns the configuration of the user across all the reserves.

**Input Parameters:**

| Name | Type    | Description      |
| ---- | ------- | ---------------- |
| user | address | The user address |

**Return Values:**

| Type                           | Description                   |
| ------------------------------ | ----------------------------- |
| DataTypes.UserConfigurationMap | The configuration of the user |

The [DataTypes.UserConfigurationMap](https://github.com/aave-dao/aave-v3-origin/blob/3aad8ca184159732e4b3d8c82cd56a8707a106a2/src/core/contracts/protocol/libraries/types/DataTypes.sol#L105) struct is composed of the following fields:

<table data-header-hidden><thead><tr><th valign="top"></th><th valign="top"></th><th></th></tr></thead><tbody><tr><td valign="top">Name</td><td valign="top">Type</td><td>Description</td></tr><tr><td valign="top">Data</td><td valign="top">uint256</td><td>Bitmap of the users collaterals and borrows. It is divided into pairs of bits, one pair per asset. The first bit indicates if an asset is used as collateral by the user, the second whether an asset is borrowed by the user. The corresponding assets are in the same position as getReservesList(). For example, if the hex value returned is 0x40020, which represents a decimal value of 262176, then in binary it is 1000000000000100000. If we format the binary value into pairs, starting from the right, we get 1 00 00 00 00 00 00 10 00 00. If we start from the right and move left in the above binary pairs, the third pair is 10. Therefore the 1 indicates that third asset from the reserveList is used as collateral, and 0 indicates it has not been borrowed by this user</td></tr></tbody></table>

#### getReserveNormalizedIncome

```
function getReserveNormalizedIncome(address asset) external view virtual override returns (uint256)
```

Returns the ongoing normalized income for the reserve.

A value of 1e27 means there is no income. As time passes, the yield is accrued. A value of 2\*1e27 means for each unit of asset, one unit of income has been accrued.

**Input Parameters:**

| Name  | Type    | Description                                        |
| ----- | ------- | -------------------------------------------------- |
| asset | address | The address of the underlying asset of the reserve |

**Return Values:**

| Type    | Description                     |
| ------- | ------------------------------- |
| uint256 | The reserve's normalized income |

#### getReserveNormalizedVariableDebt

```
function getReserveNormalizedVariableDebt(address asset) external view virtual override returns (uint256)
```

Returns the normalized variable debt per unit of asset.

A value of 1e27 means there is no debt. As time passes, the debt is accrued. A value of 2\*1e27means that for each unit of debt, one unit worth of interest has been accumulated.

**Input Parameters:**

| Name  | Type    | Description                                        |
| ----- | ------- | -------------------------------------------------- |
| asset | address | The address of the underlying asset of the reserve |

**Return Values:**

| Type    | Description                          |
| ------- | ------------------------------------ |
| uint256 | The reserve normalized variable debt |

#### getReservesList

```
function getReservesList() external view virtual override returns (address[] memory)
```

Returns the list of the underlying assets of all the initialized reserves. It does not include dropped reserves.

**Return Values:**

| Type       | Description                                                        |
| ---------- | ------------------------------------------------------------------ |
| address\[] | The addresses of the underlying assets of the initialized reserves |

#### getReserveAddressById

```
function getReserveAddressById(uint16 id) external view returns (address)
```

Returns the address of the underlying asset of a reserve by the reserve id as stored in the [DataTypes.ReserveData](https://github.com/aave-dao/aave-v3-origin/blob/3aad8ca184159732e4b3d8c82cd56a8707a106a2/src/core/contracts/protocol/libraries/types/DataTypes.sol#L42) struct.

**Input Parameters:**

| Name | Type   | Description                                                                                                                                                                                                                   |
| ---- | ------ | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| id   | uint16 | The id of the reserve as stored in the [DataTypes.ReserveData](https://github.com/aave-dao/aave-v3-origin/blob/3aad8ca184159732e4b3d8c82cd56a8707a106a2/src/core/contracts/protocol/libraries/types/DataTypes.sol#L42) struct |

**Return Values:**

| Type    | Description                                   |
| ------- | --------------------------------------------- |
| address | The address of the reserve associated with id |

#### getEModeCategoryData

```
function getEModeCategoryData(uint8 id) external view virtual override returns (DataTypes.EModeCategory memory)
```

Returns the data of an eMode category.

Each eMode category has a custom LTV and liquidation threshold. Each eMode category may or may not have a custom oracle to override the individual assets' price oracles.

**Input Parameters:**

| Name | Type  | Description            |
| ---- | ----- | ---------------------- |
| id   | uint8 | The id of the category |

**Return Values:**

| Type                    | Description                            |
| ----------------------- | -------------------------------------- |
| DataTypes.EModeCategory | The configuration data of the category |

The [DataTypes.EModeCategory](https://github.com/aave-dao/aave-v3-origin/blob/3aad8ca184159732e4b3d8c82cd56a8707a106a2/src/core/contracts/protocol/libraries/types/DataTypes.sol#L114) struct is composed of the following fields:

| Name                 | Type    | Description                                             |
| -------------------- | ------- | ------------------------------------------------------- |
| ltv                  | uint16  | The custom Loan to Value for the eMode category         |
| liquidationThreshold | uint16  | The custom liquidation threshold for the eMode category |
| liquidationBonus     | uint16  | The liquidation bonus for the eMode category            |
| collateralBitmap     | uint128 | Bitmap of collateral assets in the category             |
| label                | string  | The custom label describing the eMode category          |
| borrowableBitmap     | uint128 | Bitmap of borrowable assets in the category             |

#### getReserveData

```
function getReserveData(address asset) external view virtual override returns (DataTypes.ReserveData memory)
```

Returns the state and configuration of the reserve.

**Input Parameters:**

| Name  | Type    | Description                                        |
| ----- | ------- | -------------------------------------------------- |
| asset | address | The address of the underlying asset of the reserve |

**Return Values:**

| Type                  | Description                                     |
| --------------------- | ----------------------------------------------- |
| DataTypes.ReserveData | The state and configuration data of the reserve |

The [DataTypes.ReserveData](https://github.com/aave-dao/aave-v3-origin/blob/3aad8ca184159732e4b3d8c82cd56a8707a106a2/src/core/contracts/protocol/libraries/types/DataTypes.sol#L42) struct is composed of the following fields:

| Name                                 | Type                    | Description                                                                                                                                                                                |
| ------------------------------------ | ----------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| configuration                        | ReserveConfigurationMap | Stores the [reserve configuration](https://github.com/aave-dao/aave-v3-origin/blob/3aad8ca184159732e4b3d8c82cd56a8707a106a2/src/core/contracts/protocol/libraries/types/DataTypes.sol#L42) |
| liquidityIndex                       | uint128                 | The yield generated by the reserve during time interval since lastUpdatedTimestamp. Expressed in ray                                                                                       |
| currentLiquidityRate                 | uint128                 | The current supply rate. Expressed in ray                                                                                                                                                  |
| variableBorrowIndex                  | uint128                 | The yield accrued by reserve during time interval since lastUpdatedTimestamp. Expressed in ray                                                                                             |
| currentVariableBorrowRate            | uint128                 | The current variable borrow rate. Expressed in ray                                                                                                                                         |
| \_\_deprecatedStableBorrowRate       | uint128                 | DEPRECATED on v3.2.0                                                                                                                                                                       |
| lastUpdateTimestamp                  | uint40                  | The timestamp of when reserve data was last updated. Used for yield calculation                                                                                                            |
| id                                   | uint16                  | The id of the reserve. It represents the reserve’s position in the list of active reserves                                                                                                 |
| liquidationGracePeriodUntil          | uint40                  | The timestamp until liquidations are not allowed on the reserve. If set to the past, liquidations will be allowed                                                                          |
| aTokenAddress                        | address                 | The address of associated aToken                                                                                                                                                           |
| \_\_deprecatedStableDebtTokenAddress | address                 | DEPRECATED on v3.2.0                                                                                                                                                                       |
| variableDebtTokenAddress             | address                 | The address of associated variable debt token                                                                                                                                              |
| interestRateStrategyAddress          | address                 | The address of interest rate strategy                                                                                                                                                      |
| accruedToTreasury                    | uint128                 | The current treasury balance (scaled)                                                                                                                                                      |
| unbacked                             | uint128                 | The outstanding unbacked aTokens minted through the bridging feature                                                                                                                       |
| isolationModeTotalDebt               | uint128                 | The outstanding debt borrowed against this asset in isolation mode                                                                                                                         |
| virtualUnderlyingBalance             | uint128                 | The virtual balance of the underlying asset for yield calculation purposes                                                                                                                 |

#### getUserEMode

```
function getUserEMode(address user) external view virtual override returns (uint256)
```

Returns eMode the user is using. 0 is a non eMode category.

**Input Parameters:**

| Name | Type    | Description             |
| ---- | ------- | ----------------------- |
| user | address | The address of the user |

**Return Values:**

| Type    | Description  |
| ------- | ------------ |
| uint256 | The eMode id |

#### FLASHLOAN\_PREMIUM\_TOTAL

```
function FLASHLOAN_PREMIUM_TOTAL() public view virtual override returns (uint128)
```

Returns the percent of total flashloan premium paid by the borrower.

A part of this premium is added to reserve's liquidity index i.e. paid to the liquidity provider and the other part is paid to the protocol i.e. accrued to the treasury.

**Return Values:**

| Type    | Description                 |
| ------- | --------------------------- |
| uint128 | The total fee on flashloans |

#### BRIDGE\_PROTOCOL\_FEE

```
function BRIDGE_PROTOCOL_FEE() public view virtual override returns (uint256)
```

Returns the part of the bridge fees sent to protocol.

**Return Values:**

| Type    | Description                                                       |
| ------- | ----------------------------------------------------------------- |
| uint256 | The percentage of available liquidity to borrow, expressed in bps |

#### FLASHLOAN\_PREMIUM\_TO\_PROTOCOL

```
function FLASHLOAN_PREMIUM_TO_PROTOCOL() public view virtual override returns (uint128)
```

Returns the percent of flashloan premium that is accrued to the treasury.

**Return Values:**

| Type    | Description                                                       |
| ------- | ----------------------------------------------------------------- |
| uint128 | The percentage of available liquidity to borrow, expressed in bps |

#### MAX\_NUMBER\_RESERVES

```
function MAX_NUMBER_RESERVES() public view virtual override returns (uint16)
```

Returns the maximum number of reserves supported to be listed in this Pool.

**Return Values:**

| Type   | Description                              |
| ------ | ---------------------------------------- |
| uint16 | The maximum number of reserves supported |

#### getLiquidationGracePeriod

Returns the liquidation grace period of the given asset

```
function getLiquidationGracePeriod(address asset) external view virtual override returns (uint40)
```

**Input Parameters:**

| Name  | Type    | Description              |
| ----- | ------- | ------------------------ |
| asset | address | Underlying token address |

**Return Values:**

| Type    | Description                                          |
| ------- | ---------------------------------------------------- |
| uint256 | Timestamp when the liquidation grace period will end |

#### getReserveDeficit

Returns the current deficit of a reserve.

```
function getReserveDeficit(address asset) external view returns (uint256);
```

**Input Parameters:**

| Name  | Type    | Description              |
| ----- | ------- | ------------------------ |
| asset | address | Underlying token address |

**Return Values:**

| Type    | Description                                                       |
| ------- | ----------------------------------------------------------------- |
| uint256 | Current reserve deficit from undercollateralized borrow positions |

#### getReserveAToken

Returns the aToken address of a reserve.

```
function getReserveAToken(address asset) external view returns (address);
```

**Input Parameters:**

| Name  | Type    | Description              |
| ----- | ------- | ------------------------ |
| asset | address | Underlying token address |

**Return Values:**

| Type    | Description               |
| ------- | ------------------------- |
| address | The address of the AToken |

#### getReserveVariableDebtToken

Returns the variableDebtToken address of a reserve.

```
function getReserveVariableDebtToken(address asset) external view returns (address);
```

**Input Parameters:**

| Name  | Type    | Description              |
| ----- | ------- | ------------------------ |
| asset | address | Underlying token address |

**Return Values:**

| Type    | Description                          |
| ------- | ------------------------------------ |
| address | The address of the VariableDebtToken |

### Pure Methods

#### getRevision

```
function getRevision() internal pure virtual override returns (uint256)
```

Returns the revision number of the contract. Needs to be defined in the inherited class as a constant.

Returns 0x1.

**Return Values:**

| Type    | Description         |
| ------- | ------------------- |
| uint256 | The revision number |


# L2 Pool

On Layer 2 networks, the main cost of transactions comes from calldata. To reduce this cost, Tydro uses a specialised contract on L2 that compresses the calldata of Pool methods.

The L2Pool contract provides the L2-optimised user-facing methods of the protocol. It accepts byte-encoded input arguments and exposes the same liquidity management functions available in the standard Pool contract. Users can interact with L2Pool through Solidity or Web3 libraries. By using compact calldata representations, L2Pool helps lower transaction costs on rollups.

Not all methods are redefined in L2Pool.sol. Functions such as `flashLoan` and `setUserEMode` remain identical to their implementation in the base Pool contract. For those functions, refer to the [Pool](/vii.-developers/developer-overview/smart-contracts/pool) documentation.

Because L2 networks use a limited set of supported assets, each asset is assigned an individual 16-bit asset ID, which replaces the standard 160-bit asset address in encoded arguments.

The source code is available on [<mark style="color:blue;">GitHub</mark>](https://github.com/aave-dao/aave-v3-origin/blob/main/src/contracts/protocol/pool/L2Pool.sol).

Tydro also provides an [<mark style="color:blue;">L2Encoder</mark>](https://github.com/aave-dao/aave-v3-origin/blob/main/src/contracts/helpers/L2Encoder.sol) helper contract with view methods to encode transaction parameters for the compressed L2Pool functions. This ensures developers can efficiently generate the calldata required for low-cost interactions.

### Methods

#### supply

```
function supply(bytes32 args) external override
```

Calldata efficient wrapper of the supply function on behalf of the caller. Supplies asset into the protocol, minting the same amount of corresponding aTokens, and transferring them to msg.sender.

You can use data returned from encodeSupplyParams() method in [<mark style="color:blue;">L2Encoder</mark>](https://github.com/aave-dao/aave-v3-origin/blob/main/src/contracts/helpers/L2Encoder.sol) helper contract to pass to this method.

**Input Parameters:**

| Name | Type    | Description                                                                                                                                                                                                                                                                                                                                                  |
| ---- | ------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| args | bytes32 | <p>Arguments for the supply function packed in one bytes32<br>bit 0-15: uint16 assetId - the index of the asset in the reservesList<br>bit 16-143: uint128 shortenedAmount - cast to 256 bits at decode time, if type(uint128).max the value will be expanded to type(uint256).max<br>bit 144-159: uint16 referralCode - used for 3rd party integrations</p> |

#### supplyWithPermit

```
function supplyWithPermit(bytes32 args, bytes32 r, bytes32 s) external override
```

Calldata efficient wrapper of the supplyWithPermit function on behalf of the caller. Supply with transfer approval of supplied asset via permit function. This method removes the need for separate approval transaction before supplying asset to the pool.

You can use data returned from encodeSupplyWithPermitParams() method in [<mark style="color:blue;">L2Encoder</mark>](https://github.com/aave-dao/aave-v3-origin/blob/main/src/contracts/helpers/L2Encoder.sol) helper contract to pass to this method.

**Input Parameters:**

<table data-header-hidden><thead><tr><th valign="top"></th><th valign="top"></th><th></th></tr></thead><tbody><tr><td valign="top">Name</td><td valign="top">Type</td><td>Description</td></tr><tr><td valign="top">args</td><td valign="top">bytes32</td><td>Arguments for the supply function packed in one bytes32<br>bit 0-15: uint16 assetId - the index of the asset in the reservesList<br>bit 16-143: uint128 shortenedAmount - cast to 256 bits at decode time, if type(uint128).max the value will be expanded to type(uint256).max<br>bit 144-159: uint16 referralCode - used for 3rd party integrations<br>bit 160-191: uint32 shortenedDeadline - shortened deadline from the original uint256<br>bit 192-199: uint8 permitV - the V parameter of ERC712 permit signature</td></tr><tr><td valign="top">r</td><td valign="top">bytes32</td><td>The R parameter of ERC712 permit signature</td></tr><tr><td valign="top">s</td><td valign="top">bytes32</td><td>The S parameter of ERC712 permit signature</td></tr></tbody></table>

#### withdraw

```
function withdraw(bytes32 args) external override returns (uint256)
```

Calldata efficient wrapper of the withdraw function, withdrawing to the caller. Withdraws amount of the underlying asset, i.e. redeems the underlying token and burns the aTokens.

If the user has any existing debt backed by the underlying token, the maximum amount available to withdraw is the amount that will not leave the user with a health factor < 1 after the withdrawal.

You can use data returned from encodeWithdrawParams() method in [<mark style="color:blue;">L2Encoder</mark>](https://github.com/aave-dao/aave-v3-origin/blob/main/src/contracts/helpers/L2Encoder.sol) helper contract to pass to this method.

**Input Parameters:**

| Name | Type    | Description                                                                                                                                                                                                                                                                              |
| ---- | ------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| args | bytes32 | <p>Arguments for the withdraw function packed in one bytes32<br>bit 0-15: uint16 assetId - the index of the asset in the reservesList<br>bit 16-143: uint128 shortenedAmount - cast to 256 bits at decode time, if type(uint128).max the value will be expanded to type(uint256).max</p> |

**Return Value:**

| Name   | Type    | Description                                                                                                                                                                                                                                                             |
| ------ | ------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| amount | uint256 | The final amount of the underlying asset withdrawn, denominated in the base unit of the asset (e.g., wei for ETH, smallest unit for ERC-20 tokens). This is the amount actually transferred to the caller, accounting for constraints like liquidity and health factor. |

#### borrow

```
function borrow(bytes32 args) external override
```

Calldata efficient wrapper of the borrow function, borrowing on behalf of the caller. Borrows amount of asset with interestRateMode, sending the amount to msg.sender, with the debt being incurred by onBehalfOf.

You can use data returned from encodeBorrowParams() method in [<mark style="color:blue;">L2Encoder</mark>](https://github.com/aave-dao/aave-v3-origin/blob/main/src/contracts/helpers/L2Encoder.sol) helper contract to pass to this method.

**Input Parameters:**

<table data-header-hidden><thead><tr><th valign="top"></th><th valign="top"></th><th></th></tr></thead><tbody><tr><td valign="top">Name</td><td valign="top">Type</td><td>Description</td></tr><tr><td valign="top">args</td><td valign="top">bytes32</td><td>Arguments for the borrow function packed in one bytes32<br>bit 0-15: uint16 assetId - the index of the asset in the reservesList<br>bit 16-143: uint128 shortenedAmount - cast to 256 bits at decode time, if type(uint128).max the value will be expanded to type(uint256).max<br>bit 144 - 151: uint8 shortenedInterestRateMode<br>bit 152 - 167: uint16 referralCode - used for 3rd party integrations</td></tr></tbody></table>

#### repay

```
function repay(bytes32 args) external override returns (uint256)
```

Calldata efficient wrapper of the repay function, repaying on behalf of the caller. Repays debt of an asset for the given interestRateMode.

You can use data returned from encodeRepayParams() method in [<mark style="color:blue;">L2Encoder</mark>](https://github.com/aave-dao/aave-v3-origin/blob/main/src/contracts/helpers/L2Encoder.sol) helper contract to pass to this method.

**Input Parameters:**

<table data-header-hidden><thead><tr><th valign="top"></th><th valign="top"></th><th></th></tr></thead><tbody><tr><td valign="top">Name</td><td valign="top">Type</td><td>Description</td></tr><tr><td valign="top">args</td><td valign="top">bytes32</td><td>Arguments for the repay function packed in one bytes32<br>bit 0-15: uint16 assetId - the index of the asset in the reservesList<br>bit 16-143: uint128 shortenedAmount - cast to 256 bits at decode time, if type(uint128).max the value will be expanded to type(uint256).max<br>bit 144 - 151: uint8 shortenedInterestRateMode</td></tr></tbody></table>

**Return Values:**

| Type    | Description             |
| ------- | ----------------------- |
| uint256 | The final amount repaid |

#### repayWithPermit

```
function repayWithPermit(bytes32 args, bytes32 r, bytes32 s) external override returns (uint256)
```

Calldata efficient wrapper of the repayWithPermit function, repaying on behalf of the caller. Repay with transfer approval of borrowed asset via permit function. This method removes the need for separate approval transaction before repaying asset to the pool.

You can use data returned from encodeRepayWithPermitParams() method in [<mark style="color:blue;">L2Encoder</mark>](https://github.com/aave-dao/aave-v3-origin/blob/main/src/contracts/helpers/L2Encoder.sol) helper contract to pass to this method.​

**Input Parameters:**

<table data-header-hidden><thead><tr><th valign="top"></th><th valign="top"></th><th></th></tr></thead><tbody><tr><td valign="top">Name</td><td valign="top">Type</td><td>Description</td></tr><tr><td valign="top">args</td><td valign="top">bytes32</td><td>Arguments for the repayWithPermit function packed in one bytes32<br>bit 0-15: uint16 assetId - the index of the asset in the reservesList<br>bit 16-143: uint128 shortenedAmount - cast to 256 bits at decode time, if type(uint128).max the value will be expanded to type(uint256).max<br>bit 144 - 151: uint8 shortenedInterestRateMode<br>bit 152-183: uint32 shortenedDeadline - shortened deadline from original uint256<br>bit 184-191: uint8 permitV - the V parameter of ERC712 permit signature</td></tr><tr><td valign="top">r</td><td valign="top">bytes32</td><td>The R parameter of ERC712 permit signature</td></tr><tr><td valign="top">s</td><td valign="top">bytes32</td><td>The S parameter of ERC712 permit signature</td></tr></tbody></table>

**Return Values:**

| Type    | Description             |
| ------- | ----------------------- |
| uint256 | The final amount repaid |

#### repayWithATokens

```
function repayWithATokens(bytes32 args) external override returns (uint256)
```

Calldata efficient wrapper of the repayWithATokens function. Allows user to repay with aTokens of the underlying debt asset without any approvals, for example, Pay DAI debt using aDAI tokens.

You can use data data returned from encodeRepayWithATokensParams() method in [<mark style="color:blue;">L2Encoder</mark>](https://github.com/aave-dao/aave-v3-origin/blob/main/src/contracts/helpers/L2Encoder.sol) helper contract to pass to this method.

**Input Parameters:**

<table data-header-hidden><thead><tr><th valign="top"></th><th valign="top"></th><th></th></tr></thead><tbody><tr><td valign="top">Name</td><td valign="top">Type</td><td>Description</td></tr><tr><td valign="top">args</td><td valign="top">bytes32</td><td>Arguments for the repayWithATokens function packed in one bytes32<br>bit 0-15: uint16 assetId - the index of the asset in the reservesList<br>bit 16-143: uint128 shortenedAmount - cast to 256 bits at decode time, if type(uint128).max the value will be expanded to type(uint256).max<br>bit 144 - 151: uint8 shortenedInterestRateMode</td></tr></tbody></table>

**Return Values:**

| Type    | Description             |
| ------- | ----------------------- |
| uint256 | The final amount repaid |

#### setUserUseReserveAsCollateral

```
function setUserUseReserveAsCollateral(bytes32 args) external override
```

Calldata efficient wrapper of the setUserUseReserveAsCollateral function. Sets the asset of msg.sender to be used as collateral or not.

You can use data returned from encodeSetUserUseReserveAsCollateral() method in [<mark style="color:blue;">L2Encoder</mark>](https://github.com/aave-dao/aave-v3-origin/blob/main/src/contracts/helpers/L2Encoder.sol) helper contract to pass to this method.​

**Input Parameters:**

<table data-header-hidden><thead><tr><th valign="top"></th><th valign="top"></th><th></th></tr></thead><tbody><tr><td valign="top">Name</td><td valign="top">Type</td><td>Description</td></tr><tr><td valign="top">args</td><td valign="top">bytes32</td><td>Arguments for the setUserUseReserveAsCollateral function packed in one bytes32<br>bit 0-15: uint16 assetId - the index of the asset in the reservesList<br>bit 16: 0 => enable useAsCollateral, 1 => disable useAsCollateral</td></tr></tbody></table>

#### liquidationCall

```
function liquidationCall(bytes32 args1, bytes32 args2) external override
```

Calldata efficient wrapper of the liquidationCall function. Liquidate positions with a health factor below 1.

You can use data returned from encodeLiquidationCall() method in [<mark style="color:blue;">L2Encoder</mark>](https://github.com/aave-dao/aave-v3-origin/blob/main/src/contracts/helpers/L2Encoder.sol) helper contract to pass to this method.​

**Input Parameters:**

<table data-header-hidden><thead><tr><th valign="top"></th><th valign="top"></th><th></th></tr></thead><tbody><tr><td valign="top">Name</td><td valign="top">Type</td><td>Description</td></tr><tr><td valign="top">args1</td><td valign="top">bytes32</td><td>Part of the arguments for the liquidationCall function packed in one bytes32<br>bit 0-15: uint16 collateralAssetId - the index of the collateral asset in the reservesList<br>bit 16-31: uint16 debtAssetId - the index of the debt asset in the reservesList<br>bit 32-191: address of the user being liquidated</td></tr><tr><td valign="top">args2</td><td valign="top">bytes32</td><td>Part of the arguments for the liquidationCall function packed in one bytes32<br>bit 0-127: uint128 shortenedDebtToCover is cast to 256 bits at decode time, if type(uint128).max the value will be expanded to type(uint256).max<br>bit 128: receiveAToken - 0 => receive aToken, 1 => receive underlying asset</td></tr></tbody></table>


# Wrapped Token Gateway

Tydro operates exclusively with ERC-20 [reserve](broken://pages/kerX5iR815wa6iT4zM7O) tokens. To support native gas tokens such as ETH or POL, Tydro provides the WrappedTokenGateway (previously called WETHGateway).

This helper contract allows users to wrap or unwrap gas tokens so they can interact with Pool methods. Through WrappedTokenGateway, users can:

* Supply gas tokens
* Borrow gas tokens
* Repay positions using gas tokens
* Withdraw supplied gas tokens

The smart contract source code is available on Aave's [<mark style="color:blue;">GitHub</mark>](https://github.com/aave-dao/aave-v3-origin/blob/main/src/contracts/helpers/WrappedTokenGatewayV3.sol).

### Write Methods

#### depositETH

```
function depositETH(
    address,
    address onBehalfOf,
    uint16 referralCode
) external payable override
```

Wraps and supplies gas tokens to Tydro. A corresponding amount of the wrapped aTokens are minted to the onBehalfOf address.

The amount of network gas tokens to be supplied is specified in the msg.value field of the transaction.

**Input Parameters:**

<table data-header-hidden><thead><tr><th valign="top"></th><th valign="top"></th><th></th></tr></thead><tbody><tr><td valign="top">Name</td><td valign="top">Type</td><td>Description</td></tr><tr><td valign="top">onBehalfOf</td><td valign="top">address</td><td>The address of the user who will receive the aTokens representing the supplied tokens</td></tr><tr><td valign="top">referralCode</td><td valign="top">uint16</td><td>Inactive, can pass 0 as placeholder</td></tr></tbody></table>

#### withdrawETH

```
function withdrawETH(
    address,
    uint256 amount,
    address to
) external override
```

Withdraws amount of the supplied wrapped gas token, unwraps it and transfers to the toaddress. If the amount is uint(-1), the entire balance is withdrawn.

The WrappedTokenGateway contract must have an approved token allowance to spend aWETH on behalf of the user, example:IERC20(aWETHAddress).approve(wrappedTokenGatewayAddress, amount)

**Input Parameters:**

<table data-header-hidden><thead><tr><th valign="top"></th><th valign="top"></th><th></th></tr></thead><tbody><tr><td valign="top">Name</td><td valign="top">Type</td><td>Description</td></tr><tr><td valign="top">amount</td><td valign="top">uint256</td><td>amount of aWETH to withdraw and receive native ETH</td></tr><tr><td valign="top">to</td><td valign="top">address</td><td>The address of the user who will receive native ETH</td></tr></tbody></table>

#### repayETH

```
function repayETH(
    address,
    uint256 amount,
    uint256 rateMode,
    address onBehalfOf
) external payable override
```

Repays a borrow position of onBehalfOf's address for the specified amount (or for the whole amount, if amount of uint256(-1) is passed).

The amount of network gas token to be repaid must also be specified in the msg.value field of the transaction.

**Input Parameters:**

| Name       | Type    | Description                                                               |
| ---------- | ------- | ------------------------------------------------------------------------- |
| amount     | uint256 | The amount to repay, or uint256(-1) if the user wants to repay everything |
| rateMode   | uint256 | Should always be passed a value of 2 (variable rate mode)                 |
| onBehalfOf | address | The address for which msg.sender is repaying                              |

#### borrowETH

```
function borrowETH(
    address,
    uint256 amount,
    uint256 interestRateMode,
    uint16 referralCode
) external override
```

Borrows amount of unwrapped network gas tokens to msg.sender.

The WrappedTokenGateway contract must have an approved [credit delegation](/vii.-developers/credit-delegation) to borrow WETH (or corresponding wrapped gas token of the network) on behalf of the the caller, example:IVariableDebtToken(wethAddress).approveDelegation(wrappedTokenGatewayAddress, amount)

**Input Parameters:**

| Name             | Type    | Description                                                                  |
| ---------------- | ------- | ---------------------------------------------------------------------------- |
| amount           | uint256 | The amount of ETH to borrow                                                  |
| interestRateMode | uint256 | Should always be passed a value of 2 (variable rate mode)                    |
| referralCode     | uint16  | Integrators are assigned a referral code and can potentially receive rewards |

#### withdrawETHWithPermit

```
function withdrawETHWithPermit(
    address,
    uint256 amount,
    address to,
    uint256 deadline,
    uint8 permitV,
    bytes32 permitR,
    bytes32 permitS
) external override
```

Withdraws amount of the supplied wrapped gas token, unwraps it and transfers to the toaddress. If the amount is uint(-1), the entire balance is withdrawn.

**Input Parameters:**

| Name     | Type    | Description                                            |
| -------- | ------- | ------------------------------------------------------ |
| amount   | uint256 | The amount of aWETH to withdraw and receive native ETH |
| to       | address | The address of the user who will receive native ETH    |
| deadline | uint256 | Timestamp of signature expiration                      |
| permitV  | uint8   | V parameter of ERC712 permit sig                       |
| permitR  | bytes32 | R parameter of ERC712 permit sig                       |
| permitS  | bytes32 | S parameter of ERC712 permit sig                       |

### View Methods

#### getWETHAddress

```
function getWETHAddress() external view returns (address)
```

Get WETH address used by WrappedTokenGatewayV3.

**Return Values:**

| Type    | Description                                    |
| ------- | ---------------------------------------------- |
| address | The WETH address used by WrappedTokenGatewayV3 |


# View Contracts

## View Contracts

Tydro has several view contracts to assist with querying onchain data.

### UiPoolDataProvider

Contract that returns an array of all reserve or user data for a particular market (for example, liquidity, token addresses, rate strategy), used by the [<mark style="color:blue;">Tydro Interface</mark>](https://tydro-page.webflow.io) to display Markets and Dashboard data. \
\
The [Utilities SDK](https://github.com/aave/aave-utilities) includes an interface to make calls to this contract, and functions to format the response for frontend use-cases

The source code is available on Aave's [<mark style="color:blue;">GitHub</mark>](https://github.com/aave-dao/aave-v3-origin/blob/main/src/contracts/helpers/UiPoolDataProviderV3.sol)<mark style="color:blue;">.</mark>

### View Methods

#### getReservesList

```
function getReservesList(IPoolAddressesProvider provider) public view override returns (address[] memory)
```

Returns the list of initialised reserves in the Pool associated with the given [provider](/vii.-developers/developer-overview/smart-contracts/pool-addresses-provider).

**Input Parameters:**

| Name     | Type                   | Description                                |
| -------- | ---------------------- | ------------------------------------------ |
| provider | IPoolAddressesProvider | The given provider for the associated pool |

**Return Values:**

| Type       | Description                                  |
| ---------- | -------------------------------------------- |
| address\[] | The list of initialised reserves in the Pool |

#### getReservesData

```
function getReservesData(IPoolAddressesProvider provider) public view override returns (AggregatedReserveData[] memory, BaseCurrencyInfo memory)
```

Returns BaseCurrencyInfo of the Pool and AggregatedReserveData\[] for all the initialised reserves in the Pool associated with the given [provider](/vii.-developers/developer-overview/smart-contracts/pool-addresses-provider).

**Input Parameters:**

| Name     | Type                   | Description                                |
| -------- | ---------------------- | ------------------------------------------ |
| provider | IPoolAddressesProvider | The given provider for the associated pool |

**Return Values:**

| Type                     | Description                   |
| ------------------------ | ----------------------------- |
| BaseCurrencyInfo         | The base currency information |
| AggregatedReserveData\[] | The aggregated reserve data   |

The BaseCurrencyInfo struct is composed of the following fields:

| Name                              | Type    | Description                                       |
| --------------------------------- | ------- | ------------------------------------------------- |
| marketReferenceCurrencyUnit       | uint256 | Reference aka base currency of the Tydro market   |
| marketReferenceCurrencyPriceInUsd | int256  | Price of reference aka base currency in USD       |
| networkBaseTokenPriceInUsd        | int256  | Price of native token of the network/chain in USD |
| networkBaseTokenPriceDecimals     | uint8   | Decimals of native token of the network/chain     |

The AggregatedReserveData struct is composed of the following fields:

| Name                           | Type    | Description                                                            |
| ------------------------------ | ------- | ---------------------------------------------------------------------- |
| underlyingAsset                | address | The address of the underlying asset of the reserve                     |
| name                           | string  | The name of the underlying reserve asset                               |
| symbol                         | string  | The symbol of the underlying reserve asset                             |
| decimals                       | uint256 | The number of decimals of the reserve                                  |
| baseLTVasCollateral            | uint256 | The ltv of the reserve                                                 |
| reserveLiquidationThreshold    | uint256 | The liquidation threshold of the reserve                               |
| reserveLiquidationBonus        | uint256 | The liquidation bonus of the resurve                                   |
| reserveFactor                  | uint256 | The reserve factor of the reserve                                      |
| usageAsCollateralEnabled       | bool    | true if the asset is enabled to be used as collateral, false otherwise |
| borrowingEnabled               | bool    | true if borrowing is enabled, false otherwise                          |
| isActive                       | bool    | true if reserve is active, false otherwise                             |
| isFrozen                       | bool    | true if reserve is frozen, false otherwise                             |
| BASE DATA                      |         |                                                                        |
| liquidityIndex                 | uint128 | The liquidity index of the reserve                                     |
| variableBorrowIndex            | uint128 | The variable borrow index of the reserve                               |
| liquidityRate                  | uint128 | The liquidity rate of the reserve                                      |
| variableBorrowRate             | uint128 | The variable borrow rate of the reserve                                |
| lastUpdateTimestamp            | uint40  | The timestamp of the last update of the reserve                        |
| aTokenAddress                  | address | The AToken address of the reserve                                      |
| variableDebtTokenAddress       | address | The VariableDebtToken address of the reserve                           |
| interestRateStrategyAddress    | address | The address of the Interest Rate strategy                              |
| availableLiquidity             | uint256 | The liquidity available                                                |
| totalScaledVariableDebt        | uint256 | The total scaled variable debt                                         |
| priceInMarketReferenceCurrency | uint256 | Price of reference aka base currency of Tydro market                   |
| priceOracle                    | address | The address of the price oracle used by the associated market          |
| variableRateSlope1             | uint256 | The variable rate slope                                                |
| variableRateSlope2             | uint256 | The variable rate slope                                                |
| baseVariableBorrowRate         | uint256 | The base variable borrow rate, expressed in ray                        |
| optimalUsageRatio              | uint256 | The optimal usage ratio                                                |
|                                |         |                                                                        |
| V3 ONLY                        |         |                                                                        |
| isPaused                       | bool    | true if the pool is paused, false otherwise                            |
| isSiloedBorrowing              | bool    | true if the asset is siloed for borrowing                              |
| accruedToTreasury              | uint128 | The amount of tokens accrued to treasury that is to be minted          |
| unbacked                       | uint128 | The amount of unbacked aTokens of the reserve                          |
| isolationModeTotalDebt         | uint128 | The outstanding debt borrowed against this asset in isolation mode     |
| flashLoanEnabled               | bool    | true is asset is available to borrow in flash loan transaction         |
| debtCeiling                    | uint256 | The debt ceiling of the reserve                                        |
|                                |         |                                                                        |
| debtCeilingDecimals            | uint256 | The debt ceiling decimals                                              |
| eModeCategoryId                | uint8   | The eMode id of the reserve                                            |
| borrowCap                      | uint256 | The borrow cap of the reserve                                          |
| supplyCap                      | uint256 | The supply cap of the reserve                                          |
| borrowableInIsolation          | bool    | true is asset available to borrow against isolated collateral assets   |
| v3.1                           |         |                                                                        |
| virtualAccActive               | bool    | true if virtual accounting is enabled for a reserve                    |
| virtualUnderlyingBalance       | uint128 | Balance of reserve if virtual accounting is used                       |

#### getUserReservesData

```
function getUserReservesData(IPoolAddressesProvider provider, address user) external view override returns (UserReserveData[] memory, uint8)
```

Returns UserReserveData\[] for all user reserves in the Pool associated with the given [provider](/vii.-developers/developer-overview/smart-contracts/pool-addresses-provider).

**Input Parameters:**

| Name     | Type                   | Description                                |
| -------- | ---------------------- | ------------------------------------------ |
| provider | IPoolAddressesProvider | The given provider for the associated pool |
| user     | address                | The address of the user                    |

#### UserReserveData

| Type               | Description           |
| ------------------ | --------------------- |
| UserReserveData\[] | The user reserve data |

The [UserReserveData](https://github.com/aave-dao/aave-v3-origin/blob/main/src/contracts/helpers/interfaces/IUiPoolDataProviderV3.sol) struct is composed of the following fields:

| Name                           | Type    | Description                                                                                  |
| ------------------------------ | ------- | -------------------------------------------------------------------------------------------- |
| underlyingAsset                | address | The address of the underlying asset supplied/borrowed                                        |
| scaledATokenBalance            | uint256 | The scaled balance of the aToken. scaledBalance = balance/liquidityIndex                     |
| usageAsCollateralEnabledOnUser | bool    | true if the supplied asset is enabled to be used as collateral, false otherwise              |
| scaledVariableDebt             | uint256 | The scaled balance of borrow position: (current balance = scaled balance \* liquidity index) |

#### getEModes

Returns an array of all available E-mode categories in the Pool associated with the [provider](/vii.-developers/developer-overview/smart-contracts/pool-addresses-provider).

```
function getEModes(IPoolAddressesProvider provider) external view returns (Emode[] memory)
```

**Input Parameters:**

| Name     | Type                   | Description                                                                     |
| -------- | ---------------------- | ------------------------------------------------------------------------------- |
| provider | IPoolAddressesProvider | The PoolAddressesProvider for the associated Pool to fetch EMode categories for |

**Return Parameters:**

| Name       | Type     | Description                               |
| ---------- | -------- | ----------------------------------------- |
| categories | Emode\[] | The list of E-Modes available in the pool |

**Emode**

The Emode struct is composed of the following fields:

| Name  | Type                    | Description                         |
| ----- | ----------------------- | ----------------------------------- |
| id    | uint8                   | The unique identifier of the E-Mode |
| eMode | DataTypes.EModeCategory | The E-Mode configuration details    |

**DataTypes.EModeCategory**

The EModeCategory struct is composed of the following fields:

| Name                 | Type    | Description                                             |
| -------------------- | ------- | ------------------------------------------------------- |
| ltv                  | uint16  | Loan-to-Value ratio for the E-Mode category             |
| liquidationThreshold | uint16  | The threshold at which liquidation is triggered         |
| liquidationBonus     | uint16  | The bonus applied during liquidation                    |
| collateralBitmap     | uint128 | Bitmap representing eligible collateral for this E-Mode |
| label                | string  | The label describing the E-Mode category                |
| borrowableBitmap     | uint128 | Bitmap representing borrowable assets for this E-Mode   |

### WalletBalanceProvider

Fetches tokens balances for all underlying tokens of Tydro reserves for one user address.

This contract is not used within the Tydro. It is an accessory contract used to reduce the number of calls towards the blockchain from the Tydro backend.

For getting ETH (native chain token) balance use MOCK\_ETH\_ADDRESS = 0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE.

The source code is available on Aave's [GitHub](https://github.com/aave-dao/aave-v3-origin/blob/main/src/contracts/helpers/WalletBalanceProvider.sol).

### View Methods

#### balanceOf

```
function balanceOf(address user, address token) public view returns (uint256)
```

Checks the token balance of a wallet in a token contract. Returns the balance of the token for user (ETH included with MOCK\_ETH\_ADDRESS).

**Input Parameters:**

| Name  | Type    | Description              |
| ----- | ------- | ------------------------ |
| user  | address | The address of the user  |
| token | address | The address of the token |

**Return Values:**

| Type    | Description                                                             |
| ------- | ----------------------------------------------------------------------- |
| uint256 | The balance of the token for user. Returns 0 for a non-contract address |

#### batchBalanceOf

```
function batchBalanceOf(address[] calldata users, address[] calldata tokens) external view returns (uint256[] memory)
```

Returns balances for a list of users and tokens (ETH included with MOCK\_ETH\_ADDRESS).

**Input Parameters:**

| Name   | Type       | Description        |
| ------ | ---------- | ------------------ |
| users  | address\[] | The list of users  |
| tokens | address\[] | The list of tokens |

**Return Values:**

| Type       | Description                      |
| ---------- | -------------------------------- |
| uint256\[] | A list of balances for each user |

#### getUserWalletBalances

```
function getUserWalletBalances(address provider, address user) external view returns (address[] memory, uint256[] memory)
```

Provides balances of user wallet for all reserves available on the pool.

**Input Parameters:**

| Name     | Type    | Description                 |
| -------- | ------- | --------------------------- |
| provider | address | The address of the provider |
| user     | address | The address of the user     |

**Return Values:**

| Type       | Description                      |
| ---------- | -------------------------------- |
| address\[] | A list of user wallets           |
| uint256\[] | A list of balances for each user |

## UiIncentiveDataProviderV3

Contract that returns an array of all reserve incentives or user claimable rewards within a particular market, used by the Tydro Interface to display incentives data.

The Tydro Utilties SDK includes an interface to make calls to this contract, and functions to format the response for frontend use-cases.&#x20;

The source code is available on Aave's [GitHub](https://github.com/aave-dao/aave-v3-origin/blob/main/src/contracts/helpers/UiIncentiveDataProviderV3.sol).

### View Methods

**getFullReservesIncentiveData**

```
function getFullReservesIncentiveData(IPoolAddressesProvider provider, address user)    external    view    override    returns (AggregatedReserveIncentiveData[] memory, UserReserveIncentiveData[] memory)
```

Returns both AggregatedReserveIncentiveData\[] and UserReserveIncentiveData\[] for the given user for the pool associated with the given [provider](/vii.-developers/developer-overview/smart-contracts/pool-addresses-provider).

**Input Parameters:**

| Name     | Type                   | Description                                |
| -------- | ---------------------- | ------------------------------------------ |
| provider | IPoolAddressesProvider | The given provider for the associated pool |
| user     | address                | The address of the user                    |

**Return Values:**

| Type                              | Description                           |
| --------------------------------- | ------------------------------------- |
| AggregatedReserveIncentiveData\[] | The aggregated reserve incentive data |
| UserReserveIncentiveData\[]       | The user reserve incentive data       |

The AggregatedReserveIncentiveData struct is composed of the following fields:

| Name            | Type          | Description                                                                                               |
| --------------- | ------------- | --------------------------------------------------------------------------------------------------------- |
| underlyingAsset | address       | Address of the asset supplied/borrowed in Pool                                                            |
| aIncentiveData  | IncentiveData | Details of rewards distributed for supplying to Tydro Pool i.e. rewards for aToken holders                |
| vIncentiveData  | IncentiveData | Details of rewards distributed for variable debt borrowed from Tydro Pool i.e. rewards for vToken holders |

The UserReserveIncentiveData struct is composed of the following fields:

| Name                     | Type              | Description                                                                                             |
| ------------------------ | ----------------- | ------------------------------------------------------------------------------------------------------- |
| underlyingAsset          | address           | Address of the asset supplied/borrowed in Pool                                                          |
| aTokenIncentivesUserData | UserIncentiveData | Details of user rewards received for supplying to Tydro Pool i.e. rewards for aToken                    |
| vTokenIncentivesUserData | UserIncentiveData | Details of user rewards received for borrowing at variable rate from Tydro Pool i.e. rewards for vToken |

**getReservesIncentivesData**

```
function getReservesIncentivesData(IPoolAddressesProvider provider) external view override returns (AggregatedReserveIncentiveData[] memory)
```

Returns AggregatedReserveIncentiveData\[] for the pool associated with the given [provider](/vii.-developers/developer-overview/smart-contracts/pool-addresses-provider).

**Input Parameters:**

| Name     | Type                   | Description                                |
| -------- | ---------------------- | ------------------------------------------ |
| provider | IPoolAddressesProvider | The given provider for the associated pool |

**Return Values:**

| Type                              | Description                           |
| --------------------------------- | ------------------------------------- |
| AggregatedReserveIncentiveData\[] | The aggregated reserve incentive data |

The AggregatedReserveIncentiveData struct is composed of the following fields:

| Name            | Type          | Description                                                                                               |
| --------------- | ------------- | --------------------------------------------------------------------------------------------------------- |
| underlyingAsset | address       | Address of the asset supplied/borrowed in Pool                                                            |
| aIncentiveData  | IncentiveData | Details of rewards distributed for supplying to Tydro Pool i.e. rewards for aToken holders                |
| vIncentiveData  | IncentiveData | Details of rewards distributed for variable debt borrowed from Tydro Pool i.e. rewards for vToken holders |

**getUserReservesIncentivesData**

```
function getUserReservesIncentivesData(IPoolAddressesProvider provider, address user) external view override returns (UserReserveIncentiveData[] memory)
```

Returns the UserReserveIncentiveData\[] for the given user for the pool associated with the given [provider](/vii.-developers/developer-overview/smart-contracts/pool-addresses-provider).

**Input Parameters:**

| Name     | Type                   | Description                                |
| -------- | ---------------------- | ------------------------------------------ |
| provider | IPoolAddressesProvider | The given provider for the associated pool |

**Return Values:**

| Type                        | Description                     |
| --------------------------- | ------------------------------- |
| UserReserveIncentiveData\[] | The user reserve incentive data |

The UserReserveIncentiveData struct is composed of the following fields:

| Name                     | Type              | Description                                                                                             |
| ------------------------ | ----------------- | ------------------------------------------------------------------------------------------------------- |
| underlyingAsset          | address           | Address of the asset supplied/borrowed in Pool                                                          |
| aTokenIncentivesUserData | UserIncentiveData | Details of user rewards received for supplying to Tydro Pool i.e. rewards for aToken                    |
| vTokenIncentivesUserData | UserIncentiveData | Details of user rewards received for borrowing at variable rate from Tydro Pool i.e. rewards for vToken |

### TydroProtocolDataProvider

The TydroProtocolDataProvider is a peripheral contract to collect and pre-process information from the [Pool](/vii.-developers/developer-overview/smart-contracts/pool). This contract contains methods for querying token addresses, reserve parameters, and user account information. The methods of the PoolDataProvider are more granular than the UiPoolDataProvider, which queries data for reserve tokens or user balances simultaneously.

The source code is available on Aave's [<mark style="color:blue;">GitHub</mark>](https://github.com/aave-dao/aave-v3-origin/blob/main/src/contracts/helpers/AaveProtocolDataProvider.sol).

### View Methods

#### getAllReservesTokens

```
function getAllReservesTokens() external view returns (TokenData[] memory)
```

Returns a list of the existing reserves in the pool, pairs include the symbol and tokenAddress. Handles MKR and ETH in a different way since they do not have standard symbol functions.

**Return Values:**

| Type         | Description                                          |
| ------------ | ---------------------------------------------------- |
| TokenData\[] | The list of reserves, pairs of symbols and addresses |

The TokenData struct is composed of the following fields:

| Name         | Type    | Description                                 |
| ------------ | ------- | ------------------------------------------- |
| symbol       | string  | The symbol of the underlying reserve asset  |
| tokenAddress | address | The address of the underlying reserve asset |

#### getAllATokens

```
function getAllATokens() external view returns (TokenData[] memory)
```

Returns a list of the existing ATokens in the pool, pairs include the symbol and tokenAddress.

**Return Values:**

| Type         | Description                                         |
| ------------ | --------------------------------------------------- |
| TokenData\[] | The list of ATokens, pairs of symbols and addresses |

The TokenData struct is composed of the following fields:

| Name         | Type    | Description                          |
| ------------ | ------- | ------------------------------------ |
| symbol       | string  | The symbol of aToken of the reserve  |
| tokenAddress | address | The address of aToken of the reserve |

#### getReserveConfigurationData

```
function getReserveConfigurationData(address asset) external view returns (    uint256 decimals,    uint256 ltv,    uint256 liquidationThreshold,    uint256 liquidationBonus,    uint256 reserveFactor,    bool usageAsCollateralEnabled,    bool borrowingEnabled,    bool stableBorrowRateEnabled,    bool isActive,    bool isFrozen)
```

Returns the configuration data of the reserve as described below. Does not return borrow and supply caps, nor pause flag for compatibility.

**Input Parameters:**

| Name  | Type    | Description                                        |
| ----- | ------- | -------------------------------------------------- |
| asset | address | The address of the underlying asset of the reserve |

**Return Values:**

| Name                     | Type    | Description                                                 |
| ------------------------ | ------- | ----------------------------------------------------------- |
| decimals                 | uint256 | The number of decimals of the reserve                       |
| ltv                      | uint256 | The ltv of the reserve                                      |
| liquidationThreshold     | uint256 | The liquidation threshold of the reserve                    |
| liquidationBonus         | uint256 | The liquidation bonus of the reserve                        |
| reserveFactor            | uint256 | The reserve factor of the reserve                           |
| usageAsCollateralEnabled | bool    | true if the usage as collateral is enabled, false otherwise |
| borrowingEnabled         | bool    | true if borrowing is enabled, false otherwise               |
| stableBorrowRateEnabled  | bool    | Always false (deprecated)                                   |
| isActive                 | bool    | true if reserve is active, false otherwise                  |
| isFrozen                 | bool    | true if reserve is frozen, false otherwise                  |

#### getReserveCaps

```
function getReserveCaps(address asset) external view returns (uint256 borrowCap, uint256 supplyCap)
```

Returns the caps parameters of the reserve.

**Input Parameters:**

| Name  | Type    | Description                                        |
| ----- | ------- | -------------------------------------------------- |
| asset | address | The address of the underlying asset of the reserve |

#### Return Values:

| Name      | Type    | Description                   |
| --------- | ------- | ----------------------------- |
| borrowCap | uint256 | The borrow cap of the reserve |
| supplyCap | uint256 | The supply cap of the reserve |

#### getPaused

```
function getPaused(address asset) external view returns (bool isPaused)
```

Returns true if the pool isPaused.

**Input Parameters:**

| Name  | Type    | Description                                        |
| ----- | ------- | -------------------------------------------------- |
| asset | address | The address of the underlying asset of the reserve |

**Return Values:**

| Name     | Type | Description                                 |
| -------- | ---- | ------------------------------------------- |
| isPaused | bool | true if the pool is paused, false otherwise |

#### getSiloedBorrowing

```
function getSiloedBorrowing(address asset) external view override returns (bool)
```

Returns the siloed borrowing flag. It returns true if the asset is <mark style="color:blue;">siloed for borrowing.</mark>

**Input Parameters:**

| Name  | Type    | Description                                        |
| ----- | ------- | -------------------------------------------------- |
| asset | address | The address of the underlying asset of the reserve |

**Return Values:**

| Type | Description                               |
| ---- | ----------------------------------------- |
| bool | true if the asset is siloed for borrowing |

#### getLiquidationProtocolFee

```
function getLiquidationProtocolFee(address asset) external view override returns (uint256)
```

Returns the protocol fee on the liquidation bonus.

**Input Parameters:**

| Name  | Type    | Description                                        |
| ----- | ------- | -------------------------------------------------- |
| asset | address | The address of the underlying asset of the reserve |

**Return Values:**

| Type    | Description                     |
| ------- | ------------------------------- |
| uint256 | The protocol fee on liquidation |

#### getUnbackedMintCap

```
function getUnbackedMintCap(address asset) external view override returns (uint256)
```

Returns the unbacked mint cap of the reserve.

**Input Parameters:**

| Name  | Type    | Description                                        |
| ----- | ------- | -------------------------------------------------- |
| asset | address | The address of the underlying asset of the reserve |

**Return Values:**

| Type    | Description                          |
| ------- | ------------------------------------ |
| uint256 | The unbacked mint cap of the reserve |

#### getDebtCeiling

```
function getDebtCeiling(address asset) external view override returns (uint256)
```

Returns the debt ceiling of the reserve.

**Input Parameters:**

| Name  | Type    | Description                                        |
| ----- | ------- | -------------------------------------------------- |
| asset | address | The address of the underlying asset of the reserve |

**Return Values:**

| Type    | Description                     |
| ------- | ------------------------------- |
| uint256 | The debt ceiling of the reserve |

#### getReserveData

```
function getReserveData(address asset) external view override returns (    uint256 unbacked,    uint256 accruedToTreasuryScaled,    uint256 totalAToken,    uint256 totalStableDebt,    uint256 totalVariableDebt,    uint256 liquidityRate,    uint256 variableBorrowRate,    uint256 stableBorrowRate,    uint256 averageStableBorrowRate,    uint256 liquidityIndex,    uint256 variableBorrowIndex,    uint40 lastUpdateTimestamp)
```

Returns the reserve data.

**Input Parameters:**

| Name  | Type    | Description                                        |
| ----- | ------- | -------------------------------------------------- |
| asset | address | The address of the underlying asset of the reserve |

**Return Values:**

| Name                    | Type    | Description                                                          |
| ----------------------- | ------- | -------------------------------------------------------------------- |
| unbacked                | uint256 | The amount of unbacked aTokens of the reserve                        |
| accruedToTreasuryScaled | uint256 | The scaled amount of tokens accrued to treasury that is to be minted |
| totalAToken             | uint256 | The total supply of the aToken                                       |
| totalStableDebt         | uint256 | The total stable debt of the reserve (deprecated)                    |
| totalVariableDebt       | uint256 | The total variable debt of the reserve                               |
| liquidityRate           | uint256 | The liquidity rate of the reserve                                    |
| variableBorrowRate      | uint256 | The variable borrow rate of the reserve                              |
| stableBorrowRate        | uint256 | The stable borrow rate of the reserve (deprecated)                   |
| averageStableBorrowRate | uint256 | The average stable borrow rate of the reserve (deprecated)           |
| liquidityIndex          | uint256 | The liquidity index of the reserve                                   |
| variableBorrowIndex     | uint256 | The variable borrow index of the reserve                             |
| lastUpdateTimestamp     | uint40  | The timestamp of the last update of the reserve                      |

#### getATokenTotalSupply

```
function getATokenTotalSupply(address asset) external view override returns (uint256)
```

Returns the total supply of aTokens for a given asset.

**Input Parameters:**

| Name  | Type    | Description                                        |
| ----- | ------- | -------------------------------------------------- |
| asset | address | The address of the underlying asset of the reserve |

**Return Values:**

| Type    | Description                    |
| ------- | ------------------------------ |
| uint256 | The total supply of the aToken |

#### getTotalDebt

```
function getTotalDebt(address asset) external view override returns (uint256)
```

Returns the total debt for a given asset.

**Input Parameters:**

| Name  | Type    | Description                                        |
| ----- | ------- | -------------------------------------------------- |
| asset | address | The address of the underlying asset of the reserve |

**Return Values:**

| Type    | Description                    |
| ------- | ------------------------------ |
| uint256 | The total borrows for an asset |

#### getUserReserveData

```
function getUserReserveData(address asset, address user) external view returns (    uint256 currentATokenBalance,    uint256 currentStableDebt,    uint256 currentVariableDebt,    uint256 principalStableDebt,    uint256 scaledVariableDebt,    uint256 stableBorrowRate,    uint256 liquidityRate,    uint40 stableRateLastUpdated,    bool usageAsCollateralEnabled)
```

Returns the following user reserve data.

**Input Parameters:**

| Name  | Type    | Description                                        |
| ----- | ------- | -------------------------------------------------- |
| asset | address | The address of the underlying asset of the reserve |
| user  | address | The address of the user                            |

**Return Values:**

| Name                     | Type    | Description                                                           |
| ------------------------ | ------- | --------------------------------------------------------------------- |
| currentATokenBalance     | uint256 | The current AToken balance of the user                                |
| currentStableDebt        | uint256 | The current stable debt of the user (deprecated)                      |
| currentVariableDebt      | uint256 | The current variable debt of the user                                 |
| principalStableDebt      | uint256 | The principal stable debt of the user (deprecated)                    |
| scaledVariableDebt       | uint256 | The scaled variable debt of the user                                  |
| stableBorrowRate         | uint256 | The stable borrow rate of the user (deprecated)                       |
| liquidityRate            | uint256 | The liquidity rate of the reserve                                     |
| stableRateLastUpdated    | uint40  | The timestamp of the last update of the user stable rate (deprecated) |
| usageAsCollateralEnabled | bool    | true if the user is using the asset as collateral, else false         |

#### getReserveTokensAddresses

```
function getReserveTokensAddresses(address asset) external view override returns (    address aTokenAddress,    address stableDebtTokenAddress,    address variableDebtTokenAddress)
```

Returns the addresses of the aToken, stableDebtToken and variableDebtToken of the reserve.

**Input Parameters:**

| Name  | Type    | Description                                        |
| ----- | ------- | -------------------------------------------------- |
| asset | address | The address of the underlying asset of the reserve |

**Return Values:**

| Name                     | Type    | Description                                             |
| ------------------------ | ------- | ------------------------------------------------------- |
| aTokenAddress            | address | The AToken address of the reserve                       |
| stableDebtTokenAddress   | address | The StableDebtToken address of the reserve (deprecated) |
| variableDebtTokenAddress | address | The VariableDebtToken address of the reserve            |

#### getInterestRateStrategyAddress

```
function getInterestRateStrategyAddress(address asset) external view override returns (address irStrategyAddress)
```

Returns the address of the Interest Rate strategy.

**Input Parameters:**

| Name  | Type    | Description                                        |
| ----- | ------- | -------------------------------------------------- |
| asset | address | The address of the underlying asset of the reserve |

**Return Values:**

| Name              | Type    | Description                               |
| ----------------- | ------- | ----------------------------------------- |
| irStrategyAddress | address | The address of the Interest Rate strategy |

#### getReserveDeficit

```
function getReserveDeficit(address asset) external view override returns (uint256)
```

**Input Parameters:**

| Name  | Type    | Description                                        |
| ----- | ------- | -------------------------------------------------- |
| asset | address | The address of the underlying asset of the reserve |

**Return Values:**

| Type    | Description                                                       |
| ------- | ----------------------------------------------------------------- |
| uint256 | Current reserve deficit from undercollateralized borrow positions |

### Pure Methods

**getDebtCeilingDecimals**

```
function getDebtCeilingDecimals() external pure override returns (uint256)
```

Returns the debt ceiling decimals.

**Return Values:**

| Type    | Description               |
| ------- | ------------------------- |
| uint256 | The debt ceiling decimals |

### LiquidationDataProvider

This contract is a utility for fetching and pre-processing liquidation-related parameters for a given user. It aggregates data from the underlying Pool and Price Oracle to determine a user’s position, collateral, borrow details, and liquidation limits according to the protocol parameters.

The source code is available on [<mark style="color:blue;">GitHub</mark>](https://github.com/bgd-labs/aave-v3-origin/blob/1f4df52c1be2633b720b3638a299d74b3d5dcbb7/src/contracts/helpers/LiquidationDataProvider.sol).

### View Methods

#### getUserPositionFullInfo

```
getUserPositionFullInfo(address user) public view override returns (UserPositionFullInfo memory)
```

Returns aggregated position information for a user including total collateral, total debt, available borrows, current liquidation threshold, loan-to-value (LTV), and health factor. All values are denominated in the base currency.

**Input Parameters:**

| Name | Type    | Description                                       |
| ---- | ------- | ------------------------------------------------- |
| user | address | The address of the user whose position is queried |

**Return Values:**

| Name                 | Type   | Description                                     |
| -------------------- | ------ | ----------------------------------------------- |
| UserPositionFullInfo | struct | The aggregated position information of the user |

The UserPositionFullInfo struct is composed of the following fields:

| Name                           | Type    | Description                          |
| ------------------------------ | ------- | ------------------------------------ |
| totalCollateralInBaseCurrency  | uint256 | Total collateral in base currency    |
| totalDebtInBaseCurrency        | uint256 | Total debt in base currency          |
| availableBorrowsInBaseCurrency | uint256 | Available borrows in base currency   |
| currentLiquidationThreshold    | uint256 | Current liquidation threshold        |
| ltv                            | uint256 | Loan-to-value ratio                  |
| healthFactor                   | uint256 | Health factor of the user’s position |

#### getCollateralFullInfo

```
getCollateralFullInfo(address user, address collateralAsset) external view override returns (CollateralFullInfo memory)
```

Returns detailed information regarding a user’s collateral for a given asset. The returned struct includes the asset’s unit (based on decimals), its current price (via the Price Oracle), the associated aToken address, the raw collateral balance, and its equivalent value in the base currency.

**Input Parameters:**

| Name            | Type    | Description                                                  |
| --------------- | ------- | ------------------------------------------------------------ |
| user            | address | The address of the user                                      |
| collateralAsset | address | The address of the collateral asset to fetch information for |

**Return Values:**

| Name               | Type   | Description                                             |
| ------------------ | ------ | ------------------------------------------------------- |
| CollateralFullInfo | struct | Detailed collateral information for the specified asset |

The CollateralFullInfo struct is composed of the following fields:

| Name                            | Type    | Description                                         |
| ------------------------------- | ------- | --------------------------------------------------- |
| assetUnit                       | uint256 | The unit value of the asset (10^decimals)           |
| price                           | uint256 | Current price of the asset from the Price Oracle    |
| aToken                          | address | Address of the aToken associated with the asset     |
| collateralBalance               | uint256 | The raw collateral balance of the user              |
| collateralBalanceInBaseCurrency | uint256 | Collateral balance denominated in the base currency |

#### getDebtFullInfo&#x20;

```
getDebtFullInfo(address user, address debtAsset) external view override returns (DebtFullInfo memory)
```

Returns detailed information regarding a user’s debt for a given asset. The returned struct includes the asset’s unit, current price, the associated variable debt token address, the debt balance, and its equivalent value in the base currency.

**Input Parameters:**

| Name      | Type    | Description                                            |
| --------- | ------- | ------------------------------------------------------ |
| user      | address | The address of the user                                |
| debtAsset | address | The address of the debt asset to fetch information for |

**Return Values:**

| Name         | Type   | Description                                       |
| ------------ | ------ | ------------------------------------------------- |
| DebtFullInfo | struct | Detailed debt information for the specified asset |

The DebtFullInfo struct is composed of the following fields:

| Name                      | Type    | Description                                                  |
| ------------------------- | ------- | ------------------------------------------------------------ |
| assetUnit                 | uint256 | The unit value of the asset (10^decimals)                    |
| price                     | uint256 | Current price of the asset from the Price Oracle             |
| variableDebtToken         | address | Address of the variable debt token associated with the asset |
| debtBalance               | uint256 | The raw debt balance of the user                             |
| debtBalanceInBaseCurrency | uint256 | Debt balance denominated in the base currency                |

#### getLiquidationInfo (without custom debt amount)

```
getLiquidationInfo(address user, address collateralAsset, address debtAsset) public view override returns (LiquidationInfo memory)
```

A convenience function that returns liquidation parameters for a user using the maximum possible debt liquidation amount. Internally, it calls the overloaded version with debtLiquidationAmount set to the maximum (type(uint256).max).

**Input Parameters:**

| Name            | Type    | Description                         |
| --------------- | ------- | ----------------------------------- |
| user            | address | The address of the user             |
| collateralAsset | address | The address of the collateral asset |
| debtAsset       | address | The address of the debt asset       |

**Return Values:**

| Name            | Type   | Description                                                        |
| --------------- | ------ | ------------------------------------------------------------------ |
| LiquidationInfo | struct | Detailed liquidation information for the specified user and assets |

The LiquidationInfo struct is composed of the following fields:

| Name                          | Type    | Description                                                          |
| ----------------------------- | ------- | -------------------------------------------------------------------- |
| userInfo                      | struct  | Aggregated position details of the user (UserPositionFullInfo above) |
| collateralInfo                | struct  | Detailed collateral information (CollateralFullInfo above)           |
| debtInfo                      | struct  | Detailed debt information (DebtFullInfo above)                       |
| maxCollateralToLiquidate      | uint256 | Maximum collateral that can be liquidated                            |
| maxDebtToLiquidate            | uint256 | Maximum debt that can be liquidated                                  |
| liquidationProtocolFee        | uint256 | Protocol fee applied on the liquidation bonus                        |
| amountToPassToLiquidationCall | uint256 | Adjusted debt amount for the liquidation call                        |

#### getLiquidationInfo (with custom debt liquidation amount)

```
getLiquidationInfo(address user, address collateralAsset, address debtAsset, uint256 debtLiquidationAmount) public view override returns (LiquidationInfo memory)
```

Returns comprehensive liquidation parameters for a user given a specific collateral asset and debt asset, considering a custom maximum debt liquidation amount. The function aggregates the user’s position, collateral and debt details, checks if liquidation conditions are met, and computes the optimal amounts for liquidation—including any applicable protocol fees.

**Input Parameters:**

| Name                  | Type    | Description                                                                            |
| --------------------- | ------- | -------------------------------------------------------------------------------------- |
| user                  | address | The address of the user                                                                |
| collateralAsset       | address | The address of the collateral asset to be liquidated                                   |
| debtAsset             | address | The address of the debt asset to be repaid                                             |
| debtLiquidationAmount | uint256 | The maximum debt amount that can be liquidated (if lower than the user’s debt balance) |

**Return Values:**

| Name            | Type   | Description                                                        |
| --------------- | ------ | ------------------------------------------------------------------ |
| LiquidationInfo | struct | Detailed liquidation information for the specified user and assets |

The LiquidationInfo struct is composed of the following fields:

| Name                          | Type    | Description                                                          |
| ----------------------------- | ------- | -------------------------------------------------------------------- |
| userInfo                      | struct  | Aggregated position details of the user (UserPositionFullInfo above) |
| collateralInfo                | struct  | Detailed collateral information (CollateralFullInfo above)           |
| debtInfo                      | struct  | Detailed debt information (DebtFullInfo above)                       |
| maxCollateralToLiquidate      | uint256 | Maximum collateral that can be liquidated                            |
| maxDebtToLiquidate            | uint256 | Maximum debt that can be liquidated                                  |
| liquidationProtocolFee        | uint256 | Protocol fee applied on the liquidation bonus                        |
| amountToPassToLiquidationCall | uint256 | Adjusted debt amount for the liquidation call                        |


# Incentives

The [UiIncentiveDataProvider](/vii.-developers/developer-overview/smart-contracts/view-contracts) contract provides methods to query all active incentive emissions and the claimable user incentives for a specific Tydro market. This contract is primarily used by frontends to display incentive information for suppliers and borrowers.

## RewardsController

* Rewards accrue automatically for users holding incentivised ERC-20 assets. No staking or locking is required.
* Users can claim all rewards in a single transaction or claim individual rewards with more granularity.
* On every transfer, incentivised assets call the `handleAction` method to account for updated reward balances.

Key properties:

The RewardsController is the main rewards contract where users interact to claim rewards from their Tydro positions. It is designed as an abstract template that can be extended to create distributor contracts for ERC-20 rewards.

The source code is available on [<mark style="color:blue;">GitHub</mark>](https://github.com/aave-dao/aave-v3-origin/blob/main/src/contracts/rewards/RewardsController.sol).

### Write Methods

#### initialize

```
function initialize(address) external initializer
```

Initialize RewardsController instance.

**Input Parameters:**

| Type    | Description                                                                        |
| ------- | ---------------------------------------------------------------------------------- |
| address | Unused but required due to being initialized by PoolAddressProvider.\_updateImpl() |

#### configureAssets

```
function configureAssets(RewardsDataTypes.RewardsConfigInput[] memory config) external override onlyEmissionManager
```

Configure assets to incentivize with an emission of rewards per second until the end of distribution.

**Input Parameters:**

| Name   | Type                                   | Description                                             |
| ------ | -------------------------------------- | ------------------------------------------------------- |
| config | RewardsDataTypes.RewardsConfigInput\[] | The emission per second following rewards unit decimals |

The [<mark style="color:blue;">RewardsDataTypes.RewardsConfigInput</mark>](https://github.com/aave-dao/aave-v3-origin/blob/main/src/contracts/rewards/libraries/RewardsDataTypes.sol) struct is composed of the following fields:

| Name              | Type                | Description                                                                                                                                                   |
| ----------------- | ------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| emissionPerSecond | uint88              | The emission per second following rewards unit decimals                                                                                                       |
| totalSupply       | uint256             | The total supply of the asset to incentivize                                                                                                                  |
| distributionEnd   | uint32              | The end of the distribution of the incentives for an asset                                                                                                    |
| asset             | address             | The asset address to incentivize                                                                                                                              |
| reward            | address             | The reward token address                                                                                                                                      |
| transferStrategy  | ITransferStrategy   | The TransferStrategy address with the install hook and claim logic                                                                                            |
| rewardOracle      | IEACAggregatorProxy | The Price Oracle of a reward to visualize the incentives at the UI frontend. Must follow Chainlink Aggregator IEACAggregatorProxy interface to be compatible. |

#### setTransferStrategy

```
function setTransferStrategy(address reward, ITransferStrategyBase transferStrategy) external onlyEmissionManager
```

Sets a TransferStrategy logic contract that determines the logic of the rewards transfer.

**Input Parameters:**

| Name             | Type    | Description                                        |
| ---------------- | ------- | -------------------------------------------------- |
| reward           | address | The address of the reward token                    |
| transferStrategy | address | The address of the TransferStrategy logic contract |

#### setRewardOracle

```
function setRewardOracle(address reward, IEACAggregatorProxy rewardOracle) external onlyEmissionManager
```

Sets an Aave Oracle contract to enforce rewards with a source of value.

At the moment of reward configuration, the Incentives Controller performs a check to see if the reward asset oracle is compatible with IEACAggregator proxy. This check is enforced for integrators to show incentives at the current Aave UI without needing to set up an external price registry.

**Input Parameters:**

| Name         | Type                | Description                                                                    |
| ------------ | ------------------- | ------------------------------------------------------------------------------ |
| reward       | address             | The address of the reward to set the price aggregator                          |
| rewardOracle | IEACAggregatorProxy | The address of price aggregator that follows the IEACAggregatorProxy interface |

#### handleAction

```
function handleAction(address user, uint256 totalSupply, uint256 userBalance) external override
```

Called by the corresponding asset on transfer hook to update the rewards distribution of a user.

**Input Parameters:**

| Name        | Type    | Description                   |
| ----------- | ------- | ----------------------------- |
| user        | address | The address of the user       |
| totalSupply | uint256 | The user balance of the asset |
| userBalance | uint256 | The total supply of the asset |

#### claimRewards

```
function claimRewards(    address[] calldata assets,    uint256 amount,    address to,    address reward) external override returns (uint256)
```

Claims reward for a user to the desired address, on all the assets of the pool, accumulating the pending rewards. Rewards are received by the to address.

**Input Parameters:**

| Name   | Type       | Description                                                                                                   |
| ------ | ---------- | ------------------------------------------------------------------------------------------------------------- |
| assets | address\[] | The list of assets to check eligible distributions before claiming rewards. Pass a/s/vToken addresses         |
| amount | uint256    | The amount of rewards to claim, expressed in wei. Pass MAX\_UINT to claim the entire unclaimed reward balance |
| to     | address    | The address that will be receiving the rewards                                                                |
| reward | address    | The address of the reward token (e.g., stkAAVE)                                                               |

**Return Values:**

| Type    | Description                                           |
| ------- | ----------------------------------------------------- |
| uint256 | The amount of rewards claimed for one specific reward |

The msg.sender must be an authorized claimer set using the setClaimer() method

#### claimRewardsOnBehalf

```
function claimAllRewardsOnBehalf(
    address[] calldata assets,
    address user,
    address to
) external override onlyAuthorizedClaimers(msg.sender, user) returns (address[] memory rewardsList, uint256[] memory claimedAmounts)
```

Claims rewards for a user on behalf, on all the assets of the pool, accumulating the pending rewards of the assets passed by the first argument. The caller must be whitelisted via the <kbd>allowClaimOnBehalf</kbd> function by the EmissionManager role held by Tydro. Rewards are received by the Press <kbd>to</kbd> address. address.

**Input Parameters:**

| Name   | Type       | Description                                                                                                   |
| ------ | ---------- | ------------------------------------------------------------------------------------------------------------- |
| assets | address\[] | The list of assets to check eligible distributions before claiming rewards. Pass a/s/vToken addresses         |
| amount | uint256    | The amount of rewards to claim, expressed in wei. Pass MAX\_UINT to claim the entire unclaimed reward balance |
| user   | address    | The address to check and claim rewards                                                                        |
| to     | address    | The address that will be receiving the rewards                                                                |
| reward | address    | The address of the reward token being claimed (e.g., stkAAVE)                                                 |

**Return Values:**

| Type    | Description                   |
| ------- | ----------------------------- |
| uint256 | The amount of rewards claimed |

#### claimRewardsToSelf

```
function claimRewardsToSelf(address[] calldata assets, uint256 amount, address reward) external override returns (uint256)
```

Claims reward for msg.sender, on all the assets of the pool, accumulating the pending rewards passed by the first input parameter. Rewards are received by msg.sender.

**Input Parameters:**

| Name   | Type       | Description                                                                                                   |
| ------ | ---------- | ------------------------------------------------------------------------------------------------------------- |
| assets | address\[] | The list of assets to check eligible distributions before claiming rewards. Pass a/s/vToken addresses         |
| amount | uint256    | The amount of rewards to claim, expressed in wei. Pass MAX\_UINT to claim the entire unclaimed reward balance |
| reward | address    | The address of the reward token                                                                               |

**Return Values:**

| Type    | Description                                           |
| ------- | ----------------------------------------------------- |
| uint256 | The amount of rewards claimed for one specific reward |

#### claimAllRewards

```
function claimAllRewards(address[] calldata assets, address to) external override returns (address[] memory rewardsList, uint256[] memory claimedAmounts)
```

Claims all rewards for a user to the desired address, on all the assets of the pool, accumulating the pending rewards passed by the first input parameter. Rewards are received by the toaddress.

**Input Parameters:**

| Name   | Type       | Description                                                                                                        |
| ------ | ---------- | ------------------------------------------------------------------------------------------------------------------ |
| assets | address\[] | The list of assets to check eligible distributions before claiming rewards (aToken or variableDebtToken addresses) |
| to     | address    | The address that will be receiving the rewards                                                                     |

**Return Values:**

| Name           | Type       | Description                                                                                   |
| -------------- | ---------- | --------------------------------------------------------------------------------------------- |
| rewardsList    | address\[] | The list of addresses of the reward tokens                                                    |
| claimedAmounts | uint256\[] | The list that contains the claimed amount per reward, following the same order as rewardsList |

#### claimAllRewardsOnBehalf

```
function claimAllRewardsOnBehalf(    address[] calldata assets,    address user,    address to) external override onlyAuthorizedClaimers(msg.sender, user) returns (address[] memory rewardsList, uint256[] memory claimedAmounts)
```

Claims all rewards for a user on behalf, on all the assets of the pool, accumulating the pending rewards passed by the first input parameter. The caller must be whitelisted via the allowClaimOnBehalf function by the EmissionManager role held by Tydro. Rewards are received by the to address.

**Input Parameters:**

| Name   | Type       | Description                                                                                           |
| ------ | ---------- | ----------------------------------------------------------------------------------------------------- |
| assets | address\[] | The list of assets to check eligible distributions before claiming rewards. Pass a/s/vToken addresses |
| user   | address    | The address to check and claim rewards                                                                |
| to     | address    | The address that will be receiving the rewards                                                        |

**Return Values:**

| Name           | Type       | Description                                                                                   |
| -------------- | ---------- | --------------------------------------------------------------------------------------------- |
| rewardsList    | address\[] | The list of addresses of the reward tokens                                                    |
| claimedAmounts | uint256\[] | The list that contains the claimed amount per reward, following the same order as rewardsList |

#### claimAllRewardsToSelf

```
function claimAllRewardsToSelf(address[] calldata assets) external override returns (address[] memory rewardsList, uint256[] memory claimedAmounts)
```

Claims all rewards accrued by msg.sender, on all assets of the pool, accumulating the pending rewards by the first input parameter. Rewards are received by msg.sender.

**Input Parameters:**

| Name   | Type       | Description                                                                                           |
| ------ | ---------- | ----------------------------------------------------------------------------------------------------- |
| assets | address\[] | The list of assets to check eligible distributions before claiming rewards. Pass a/s/vToken addresses |

**Return Values:**

| Name           | Type       | Description                                                                                   |
| -------------- | ---------- | --------------------------------------------------------------------------------------------- |
| rewardsList    | address\[] | The list of addresses of the reward tokens                                                    |
| claimedAmounts | uint256\[] | The list that contains the claimed amount per reward, following the same order as rewardsList |

#### setClaimer

```
function setClaimer(address user, address caller) external override onlyEmissionManager
```

Whitelists an address to claim rewards on behalf of another address. Can only be called by the EmissionManager help by Tydro

**Input Parameters:**

| Name   | Type    | Description                |
| ------ | ------- | -------------------------- |
| user   | address | The address of the user    |
| caller | address | The address of the claimer |

### View Methods

#### getClaimer

```
function getClaimer(address user) external view override returns (address)
```

Returns the whitelisted claimer for a certain address. It returns the 0x0 address if it is not set.

**Input Parameters:**

| Name | Type    | Description             |
| ---- | ------- | ----------------------- |
| user | address | The address of the user |

**Return Values:**

| Type    | Description         |
| ------- | ------------------- |
| address | The claimer address |

#### getRewardOracle

```
function getRewardOracle(address reward) external view override returns (address)
```

Get the price aggregator oracle address.

| Name   | Type    | Description                     |
| ------ | ------- | ------------------------------- |
| reward | address | The address of the reward token |

**Return Values:**

| Type    | Description                      |
| ------- | -------------------------------- |
| address | The address of the reward oracle |

#### getTransferStrategy

```
function getTransferStrategy(address reward) external view override returns (address)
```

Returns the Transfer Strategy implementation contract address being used for a reward address.

| Name   | Type    | Description               |
| ------ | ------- | ------------------------- |
| reward | address | The address of the reward |

**Return Values:**

| Type    | Description                                  |
| ------- | -------------------------------------------- |
| address | The address of the TransferStrategy contract |

### Pure Methods

```
function getRevision() internal pure override returns (uint256)
```

Returns the revision of the implementation contract.

**Return Values:**

| Type    | Description                  |
| ------- | ---------------------------- |
| uint256 | The current revision version |


# Tokenization

### AToken

aTokens are tokens minted when assets are supplied to a Tydro market and burned when assets are withdrawn. They represent both the amount of crypto assets supplied and the yield earned on those assets.

* The value of an aToken is pegged 1:1 to the underlying asset.
* aTokens can be stored, transferred, or traded like standard ERC-20 tokens.
* Yield is distributed directly to aToken holders by continuously increasing their wallet balance.

The aToken contract is the interest-bearing token implementation for Tydro. It inherits from [<mark style="color:blue;">ScaledBalanceTokenBase</mark>](https://github.com/aave-dao/aave-v3-origin/blob/main/src/contracts/protocol/tokenization/base/ScaledBalanceTokenBase.sol) and [<mark style="color:blue;">EIP712Base</mark>](https://github.com/aave-dao/aave-v3-origin/blob/main/src/contracts/protocol/tokenization/base/EIP712Base.sol) token contracts.

All standard ERC-20 methods are implemented, including:

* `balanceOf`
* `transfer`
* `transferFrom`
* `approve`
* `totalSupply`

The `balanceOf` function always returns the most up-to-date user balance, combining both the principal supplied and the yield earned.

The source code is available on Aave's [<mark style="color:blue;">GitHub</mark>](https://github.com/aave-dao/aave-v3-origin/blob/main/src/contracts/protocol/tokenization/AToken.sol).

### Write Methods

#### initialize

```
function initialize(
    IPool initializingPool,
    address treasury,
    address underlyingAsset,
    IAaveIncentivesController incentivesController,
    uint8 aTokenDecimals,
    string calldata aTokenName,
    string calldata aTokenSymbol,
    bytes calldata params
) public virtual
```

Called when aToken instance is initialized.

**Input Parameters:**

| Name                 | Type                      | Description                                               |
| -------------------- | ------------------------- | --------------------------------------------------------- |
| initializingPool     | IPool                     | The address of the associated pool                        |
| treasury             | address                   | The address of the treasury                               |
| underlyingAsset      | address                   | The address of the underlying asset                       |
| incentivesController | IAaveIncentivesController | The address of the incentives controller for this aToken  |
| aTokenDecimals       | uint8                     | The decimals of the underlying asset                      |
| aTokenName           | string                    | The name of the aToken                                    |
| aTokenSymbol         | string                    | The symbol of the aToken                                  |
| params               | bytes                     | A set of encoded parameters for additional initialization |

#### mint

```
function mint(
    address caller,
    address onBehalfOf,
    uint256 amount,
    uint256 index
) external virtual override onlyPool returns (bool)
```

Mints amount aTokens to user.

**Input Parameters:**

| Name       | Type    | Description                                                  |
| ---------- | ------- | ------------------------------------------------------------ |
| caller     | address | The address performing the mint                              |
| onBehalfOf | address | The address of the user that will receive the minted aTokens |
| amount     | uint256 | The amount of tokens getting minted                          |
| index      | uint256 | The next liquidity index of the reserve                      |

**Return Values:**

| Type | Description                                        |
| ---- | -------------------------------------------------- |
| bool | true if the the previous balance of the user was 0 |

#### burn

```
function burn(
    address from,
    address receiverOfUnderlying,
    uint256 amount,
    uint256 index
) external virtual override onlyPool
```

In some instances, the mint event could be emitted from a burn transaction if the amount to burn is less than the interest that the user accrued.

**Input Parameters:**

| Name                 | Type    | Description                                        |
| -------------------- | ------- | -------------------------------------------------- |
| from                 | address | The address from which the aTokens will be burned  |
| receiverOfUnderlying | address | The address that will receive the underlying asset |
| amount               | uint256 | The amount of tokens that will be burned           |
| index                | uint256 | The next liquidity index of the reserve            |

#### mintToTreasury

```
function mintToTreasury(uint256 amount, uint256 index) external override onlyPool
```

Mints aTokens to the reserve treasury.

**Input Parameters:**

| Name   | Type    | Description                                        |
| ------ | ------- | -------------------------------------------------- |
| amount | uint256 | The amount of tokens getting minted                |
| index  | uint256 | The address that will receive the underlying asset |

#### transferOnLiquidation

```
function transferOnLiquidation(
    address from,
    address to,
    uint256 value
) virtual override onlyPool
```

Transfers aTokens in the event of a borrow being liquidated, in case the liquidator reclaims the aToken.

**Input Parameters:**

| Name  | Type    | Description                                                  |
| ----- | ------- | ------------------------------------------------------------ |
| from  | address | The address getting liquidated, current owner of the aTokens |
| to    | address | The recipient of aTokens                                     |
| value | uint256 | The amount of tokens getting transferred                     |

#### transferUnderlyingTo

```
function transferUnderlyingTo(address target, uint256 amount) external virtual override onlyPool
```

Transfers the underlying asset to target.

Used by the [Pool](/vii.-developers/developer-overview/smart-contracts/pool) to transfer assets in borrow(), withdraw() and flashLoan().

**Input Parameters:**

| Name   | Type    | Description                     |
| ------ | ------- | ------------------------------- |
| user   | address | The recipient of the underlying |
| amount | uint256 | The amount getting transferred  |

#### handleRepayment

```
function handleRepayment(address user, address onBehalfOf, uint256 amount) external virtual override onlyPool
```

Handles the underlying received by the aToken after the transfer has been completed.

The default implementation is empty as with standard ERC20 tokens, nothing needs to be done after the transfer is concluded. However in the future there may be aTokens that allow for example to stake the underlying to receive LM rewards. In that case, handleRepayment() would perform the staking of the underlying asset.

**Input Parameters:**

| Name       | Type      | Description                                         |
| ---------- | --------- | --------------------------------------------------- |
| user       | address   | The user executing the repayment                    |
| onBehalfOf | address\` | The address for which the borrow position is repaid |
| amount     | uint256   | The amount getting repaid                           |

#### permit

```
function permit(
    address owner,
    address spender,
    uint256 value,
    uint256 deadline,
    uint8 v,
    bytes32 r,
    bytes32 s
) external override
```

Allows a user to permit another account (or contract) to use their funds using a signed message. This enables gas-less transactions and single approval/transfer transactions. Allow passing a signed message to approve spending.

Implements the permit function as for EIP-2612.

**Input Parameters:**

| Name     | Type    | Description                                                       |
| -------- | ------- | ----------------------------------------------------------------- |
| owner    | address | The owner of the funds                                            |
| spender  | address | The spender of the funds                                          |
| value    | uint256 | The amount the spender is permitted to spend                      |
| deadline | uint256 | The deadline timestamp, use type(uint256).max for max/no deadline |
| v        | uint8   | The V signature parameter                                         |
| r        | bytes32 | The R signature parameter                                         |
| s        | bytes32 | The S signature parameter                                         |

Example of signing and utilizing permit:

```
import { signTypedData_v4 } from "eth-sig-util";
import { fromRpcSig } from "ethereumjs-util";
// ... other imports
import aTokenAbi from "./aTokenAbi.json";
// ... setup your web3 provider
const aTokenAddress = "ATOKEN_ADDRESS";
const aTokenContract = new web3.eth.Contract(aTokenAbi, aTokenAddress);
const privateKey = "YOUR_PRIVATE_KEY_WITHOUT_0x";
const chainId = 1;
const owner = "OWNER_ADDRESS";
const spender = "SPENDER_ADDRESS";
const value = 100; // Amount the spender is permitted
const nonce = 1; // The next valid nonce, use `_nonces()`
const deadline = 1600093162;
const permitParams = {
  types: {
    EIP712Domain: [
      { name: "name", type: "string" },
      { name: "version", type: "string" },
      { name: "chainId", type: "uint256" },
      { name: "verifyingContract", type: "address" },
    ],
    Permit: [
      { name: "owner", type: "address" },
      { name: "spender", type: "address" },
      { name: "value", type: "uint256" },
      { name: "nonce", type: "uint256" },
      { name: "deadline", type: "uint256" },
    ],
  },
  primaryType: "Permit",
  domain: {
    name: "aTOKEN_NAME",
    version: "1",
    chainId: chainId,
    verifyingContract: aTokenAddress,
  },
  message: {
    owner,
    spender,
    value,
    nonce,
    deadline,
  },
};
const signature = signTypedData_v4(Buffer.from(privateKey, "hex"), {
  data: permitParams,
});
// The signature can now be used to execute the transaction
const { v, r, s } = fromRpcSig(signature);
await aTokenContract.methods
  .permit({
    owner,
    spender,
    value,
    deadline,
    v,
    r,
    s,
  })
  .send()
  .catch((e) => {
    throw Error(`Error permitting: ${e.message}`);
  });
```

#### rescueTokens

```
function rescueTokens(
    address token,
    address to,
    uint256 amount
) external override onlyPoolAdmin
```

Rescue and transfer tokens locked in this contract. Only callable by [POOL\_ADMIN](/vii.-developers/developer-overview/smart-contracts/aclmanager).

**Input Parameters:**

| Name   | Type    | Description                     |
| ------ | ------- | ------------------------------- |
| token  | address | The address of the token        |
| to     | address | The address of the recipient    |
| amount | uint256 | The amount of token to transfer |

### View Methods

#### balanceOf

```
function balanceOf(address user)
    public
    view
    virtual
    override(IncentivizedERC20, IERC20)
    returns (uint256)
```

Returns the amount of tokens owned by user.

Overrides the base function.

**Input Parameters:**

| Name | Type    | Description             |
| ---- | ------- | ----------------------- |
| user | address | The address of the user |

**Return Values:**

| Type    | Description                        |
| ------- | ---------------------------------- |
| uint256 | The amount of tokens owned by user |

#### totalSupply

```
function totalSupply() public view virtual override(IncentivizedERC20, IERC20 returns (uint256)
```

Returns the amount of tokens in existence.

Overrides the base function.

**Return Values:**

| Type    | Description                       |
| ------- | --------------------------------- |
| uint256 | The amount of tokens in existence |

#### RESERVE\_TREASURY\_ADDRESS

```
function RESERVE_TREASURY_ADDRESS() external view override returns (address)
```

Returns the address of the Tydro treasury, controlled by Tydro, receiving the fees on this aToken.

**Return Values:**

| Type    | Description                      |
| ------- | -------------------------------- |
| address | The address of the Aave treasury |

#### UNDERLYING\_ASSET\_ADDRESS

```
function UNDERLYING_ASSET_ADDRESS() external view override returns (address)
```

Returns the address of the underlying reserve asset of this aToken (E.g. WETH for aWETH).

**Return Values:**

| Type    | Description                         |
| ------- | ----------------------------------- |
| address | The address of the underlying asset |

#### DOMAIN\_SEPARATOR

```
function DOMAIN_SEPARATOR() public view override(IAToken, EIP712Base) returns (bytes32)
```

Get the domain separator for the token at the current chain.

Return cached value if chainId matches cache, otherwise recomputes separator.

Overrides the base function to fully implement IAToken.

**Return Values:**

| Type    | Description                                        |
| ------- | -------------------------------------------------- |
| bytes32 | The domain separator of the token at current chain |

#### nonces

```
function nonces(address owner) public view override(IAToken, EIP712Base) returns (uint256)
```

Returns the nonce value for address specified as parameter. This is the nonce used when calling permit().

Overrides the base function to fully implement IAToken.

**Input Parameters:**

| Name  | Type    | Description              |
| ----- | ------- | ------------------------ |
| owner | address | The address of the owner |

**Return Values:**

| Type    | Description            |
| ------- | ---------------------- |
| uint256 | The nonce of the owner |

Example:

```
const token = new Contract(aTokenAddress, aToken.abi, provider);
await token.nonces(user);
```

### Pure Methods

#### getRevision

```
function getRevision() internal pure virtual override returns (uint256)
```

Returns the revision number of the contract. Needs to be defined in the inherited class as a constant.

Returns 0x1.

**Return Values:**

| Type    | Description         |
| ------- | ------------------- |
| uint256 | The revision number |

## StaticATokenFactory

The StataTokenFactory is a factory and registry contract that manages all deployed StataToken instances for a specified Aave pool. It allows deploying new StataToken instances on demand and validates that there is only one StataToken instance per underlying asset. This contract maintains a mapping between underlying assets and their corresponding StataTokenaddresses.

StataTokens are ERC-4626 compliant tokens that wrap Aave's aTokens to provide a non-rebasing yield accrual mechanism.

The source code is available on Aave's [<mark style="color:blue;">GitHub</mark>.](https://github.com/aave-dao/aave-v3-origin/blob/main/src/contracts/protocol/tokenization/StataTokenFactory.sol)

### Write Methods

#### initialize

```
function initialize() external initializer
```

Initializes the StataTokenFactory contract. This function is part of the Initializable pattern and is required to initialize the contract after deployment. In this implementation, it does not perform any actions.

#### createStataTokens

```
function createStataTokens(address[] memory underlyings) external returns (address[] memory)
```

Creates new StataToken instances for the given underlying assets if they do not already exist. For each provided underlying asset, the function checks if a StataToken already exists. If it does, the existing StataToken address is returned. If not, it deploys a new StataToken for that underlying asset, registers it, and returns the new address.

**Input Parameters:**

| Name        | Type       | Description                            |
| ----------- | ---------- | -------------------------------------- |
| underlyings | address\[] | An array of underlying asset addresses |

**Return Values:**

| Type       | Description                                                                      |
| ---------- | -------------------------------------------------------------------------------- |
| address\[] | An array of StataToken addresses corresponding to the provided underlying assets |

**Emits:**

* StataTokenCreated(address indexed stataToken, address indexed underlying) event for each new StataToken created.

**Reverts:**

* NotListedUnderlying(address underlying) if the underlying asset is not listed in the Aave pool.

### View Methods

#### getStataTokens

```
function getStataTokens() external view returns (address[] memory)
```

Returns all StataToken instances deployed via this factory.

**Return Values:**

| Type       | Description                                   |
| ---------- | --------------------------------------------- |
| address\[] | An array of all StataToken contract addresses |

#### getStataToken

```
function getStataToken(address underlying) external view returns (address)
```

Returns the StataToken address for a given underlying asset.

**Input Parameters:**

| Name       | Type    | Description                         |
| ---------- | ------- | ----------------------------------- |
| underlying | address | The address of the underlying asset |

**Return Values:**

| Type    | Description                                                                  |
| ------- | ---------------------------------------------------------------------------- |
| address | The address of the corresponding StataToken; returns address(0) if not found |

#### POOL

```
function POOL() external view returns (IPool)
```

Returns the address of the Aave pool associated with this factory.

**Return Values:**

| Type  | Description                             |
| ----- | --------------------------------------- |
| IPool | The address of the associated Aave pool |

#### PROXY\_ADMIN

```
function PROXY_ADMIN() external view returns (address)
```

Returns the address of the proxy admin used for the StataToken proxies.

**Return Values:**

| Type    | Description                    |
| ------- | ------------------------------ |
| address | The address of the proxy admin |

#### TRANSPARENT\_PROXY\_FACTORY

```
function TRANSPARENT_PROXY_FACTORY() external view returns (ITransparentProxyFactory)
```

Returns the address of the transparent proxy factory used for creating new StataToken proxies.

**Return Values:**

| Type                     | Description                                  |
| ------------------------ | -------------------------------------------- |
| ITransparentProxyFactory | The address of the transparent proxy factory |

#### STATA\_TOKEN\_IMPL

```
function STATA_TOKEN_IMPL() external view returns (address)
```

Returns the address of the StataToken implementation used when deploying new StataTokeninstances.

**Return Values:**

| Type    | Description                                  |
| ------- | -------------------------------------------- |
| address | The address of the StataToken implementation |

## VariableDebtToken

Implements a variable debt token to track the borrowing positions of users at variable rate mode.

transfer and approve functionalities are disabled as variable debt tokens are non-transferable.

The vToken value is pegged 1:1 to the value of underlying borrowed asset and represents the current total amount owed to the protocol i.e. principal debt + interest accrued.

The VariableDebtToken contract inherits the [<mark style="color:blue;">DebtTokenBase</mark>](https://github.com/aave-dao/aave-v3-origin/blob/main/src/contracts/protocol/tokenization/base/DebtTokenBase.sol) and [<mark style="color:blue;">ScaledBalanceTokenBase</mark>](https://github.com/aave-dao/aave-v3-origin/blob/main/src/contracts/protocol/tokenization/base/ScaledBalanceTokenBase.sol) token contracts.

The source code is available on Aave's [<mark style="color:blue;">GitHub</mark>](https://github.com/aave-dao/aave-v3-origin/blob/main/src/contracts/protocol/tokenization/VariableDebtToken.sol).

### Write Methods

#### initialize

```
function initialize(
    IPool initializingPool,
    address underlyingAsset,
    IAaveIncentivesController incentivesController,
    uint8 debtTokenDecimals,
    string memory debtTokenName,
    string memory debtTokenSymbol,
    bytes calldata params
) external virtual
```

Called when variableDebtToken instance is initialised.

**Input Parameters:**

| Name                 | Type                      | Description                                                              |
| -------------------- | ------------------------- | ------------------------------------------------------------------------ |
| initializingPool     | IPool                     | The pool contract that is initializing this contract                     |
| underlyingAsset      | address                   | The address of the underlying asset of this aToken (E.g. WETH for aWETH) |
| incentivesController | IAaveIncentivesController | The smart contract managing potential incentives distribution            |
| debtTokenDecimals    | uint8                     | The decimals of the variableDebtToken, same as the underlying asset's    |
| debtTokenName        | string                    | The name of the variable debt token                                      |
| debtTokenSymbol      | string                    | The symbol of the variable debt token                                    |
| params               | bytes                     | A set of encoded parameters for additional initialization                |

#### mint

```
function mint(
    address user,
    address onBehalfOf,
    uint256 amount,
    uint256 index
) external virtual override onlyPool returns (bool, uint256)
```

Mints the variable debt token to the onBehalfOf address.

**Input Parameters:**

| Name       | Type    | Description                                                                                                                    |
| ---------- | ------- | ------------------------------------------------------------------------------------------------------------------------------ |
| user       | address | The address receiving the borrowed underlying, being the delegatee in case of credit delegate, or same as onBehalfOf otherwise |
| onBehalfOf | address | The address receiving the variable debt tokens                                                                                 |
| amount     | uint256 | The amount of variable debt tokens to mint                                                                                     |
| index      | uint256 | The variable debt index of the reserve                                                                                         |

**Return Values:**

| Type    | Description                                                    |
| ------- | -------------------------------------------------------------- |
| bool    | true if the previous balance of the user is 0, false otherwise |
| uint256 | The scaled total debt of the reserve                           |

#### burn

```
function burn(
    address from,
    uint256 amount,
    uint256 index
) external virtual override onlyPool returns (uint256)
```

Burns user variable debt.

In some instances, a burn transaction will emit a mint event if the amount to burn is less than the interest that the user accrued.

**Input Parameters:**

| Name   | Type    | Description                                    |
| ------ | ------- | ---------------------------------------------- |
| from   | address | The address from which the debt will be burned |
| amount | uint256 | The amount of debt tokens that will be burned  |
| index  | uint256 | The variable debt index of the reserve         |

**Return Values:**

| Type    | Description                          |
| ------- | ------------------------------------ |
| uint256 | The scaled total debt of the reserve |

### View Methods

#### UNDERLYING\_ASSET\_ADDRESS

```
function UNDERLYING_ASSET_ADDRESS() external view override returns (address)
```

Returns the address of the underlying asset of this variableDebtToken (e.g. WETH for variableDebtWETH)

**Return Values:**

| Type    | Description                         |
| ------- | ----------------------------------- |
| address | The address of the underlying asset |

#### balanceOf

```
function balanceOf(address account) public view virtual override returns (uint256)
```

Returns the amount of tokens owned by account - the most up to date accumulated debt (principal + interest) of the user.

Standard ERC20 function.

**Input Parameters:**

| Name    | Type    | Description                 |
| ------- | ------- | --------------------------- |
| account | address | The balance of this address |

**Return Values:**

| Type    | Description                           |
| ------- | ------------------------------------- |
| uint256 | The amount of tokens owned by account |

#### totalSupply

```
function totalSupply() public view virtual override returns (uint256)
```

Returns the amount of tokens in existence - the most up to date total debt accrued by all protocol users for that specific variable rate of debt token.

Standard ERC20 function.

**Return Values:**

| Type    | Description                       |
| ------- | --------------------------------- |
| uint256 | The amount of tokens in existence |

### Pure Methods

#### getRevision

```
function getRevision() internal pure virtual override returns (uint256)
```

Returns the revision number of the contract. Needs to be defined in the inherited class as a constant.

Returns 0x1.

**Return Values:**

| Type    | Description         |
| ------- | ------------------- |
| uint256 | The revision number |

### NOT SUPPORTED OPERATIONS

Being non-transferrable, the variable debt token does not implement any of the standard ERC20 functions for transfer and allowance.

The following functions below will revert with the error code 80, OPERATION\_NOT\_SUPPORTED: transfer, allowance, approve, transferFrom, increaseAllowance, decreaseAllowance.


# Interest Rate Strategy

This contract implements the calculation of interest rates based on the state of each reserve. The model follows a **two-slope structure**:

* One slope applies when utilisation is below the `OPTIMAL_USAGE_RATIO`.
* A steeper slope applies once utilisation rises above the optimal point, up to 100%.

Each Tydro market deploys its own instance of the interest rate strategy contract, as it caches the [`PoolAddressesProvider`](/vii.-developers/developer-overview/smart-contracts/pool-addresses-provider) and cannot be shared across markets

The source code is available on [<mark style="color:blue;">GitHub</mark>](https://github.com/aave-dao/aave-v3-origin/blob/main/src/contracts/misc/DefaultReserveInterestRateStrategyV2.sol).

### View Methods

#### getVariableRateSlope1

```
function getVariableRateSlope1(address reserve) external view returns (uint256)
```

Returns the variable rate slope below the optimal usage ratio for the specified reserve. This is the variable rate when the usage ratio is between 0 and OPTIMAL\_USAGE\_RATIO.

**Input Parameters:**

| Name    | Type    | Description                |
| ------- | ------- | -------------------------- |
| reserve | address | The address of the reserve |

**Return Values:**

| Type    | Description             |
| ------- | ----------------------- |
| uint256 | The variable rate slope |

#### getVariableRateSlope2

```
function getVariableRateSlope2(address reserve) external view returns (uint256)
```

Returns the variable rate slope above the optimal usage ratio for the specified reserve. This is the variable rate when the usage ratio is greater than OPTIMAL\_USAGE\_RATIO.

**Input Parameters:**

| Name    | Type    | Description                |
| ------- | ------- | -------------------------- |
| reserve | address | The address of the reserve |

**Return Values:**

| Type    | Description             |
| ------- | ----------------------- |
| uint256 | The variable rate slope |

#### getBaseVariableBorrowRate

```
function getBaseVariableBorrowRate(address reserve) external view override returns (uint256)
```

Returns the base variable borrow rate for the specified reserve.

**Input Parameters:**

| Name    | Type    | Description                |
| ------- | ------- | -------------------------- |
| reserve | address | The address of the reserve |

**Return Values:**

| Type    | Description                                     |
| ------- | ----------------------------------------------- |
| uint256 | The base variable borrow rate, expressed in ray |

#### getMaxVariableBorrowRate

```
function getMaxVariableBorrowRate(address reserve) external view override returns (uint256)
```

Returns the maximum variable borrow rate for the specified reserve.

**Input Parameters:**

| Name    | Type    | Description                |
| ------- | ------- | -------------------------- |
| reserve | address | The address of the reserve |

**Return Values:**

| Type    | Description                                        |
| ------- | -------------------------------------------------- |
| uint256 | The maximum variable borrow rate, expressed in ray |

#### calculateInterestRates

```
function calculateInterestRates(    DataTypes.CalculateInterestRatesParams memory params) external view override returns (uint256, uint256)
```

Calculates the interest rates depending on the reserve's state and configurations. This function returns only two values: the liquidity rate and the variable borrow rate.

**Input Parameters:**

| Name   | Type                                   | Description                                       |
| ------ | -------------------------------------- | ------------------------------------------------- |
| params | DataTypes.CalculateInterestRatesParams | The parameters needed to calculate interest rates |

The DataTypes.CalculateInterestRatesParams struct is composed of the following fields:

| Name                     | Type    | Description                                                                 |
| ------------------------ | ------- | --------------------------------------------------------------------------- |
| unbacked                 | uint256 | The amount of unbacked tokens                                               |
| liquidityAdded           | uint256 | The liquidity added during the operation                                    |
| liquidityTaken           | uint256 | The liquidity taken during the operation                                    |
| totalDebt                | uint256 | The total borrowed from the reserve                                         |
| reserveFactor            | uint256 | The reserve portion of the interest that goes to the treasury of the market |
| reserve                  | address | The address of the reserve                                                  |
| usingVirtualBalance      | bool    | Flag to indicate if the virtual balance is being used                       |
| virtualUnderlyingBalance | uint256 | The virtual balance of underlying asset used for mintable assets            |

**Return Values:**

| Name               | Type    | Description                                |
| ------------------ | ------- | ------------------------------------------ |
| liquidityRate      | uint256 | The liquidity rate, expressed in ray       |
| variableBorrowRate | uint256 | The variable borrow rate, expressed in ray |


# ACLManager

The ACLManager (Access Control List Manager) is the registry of roles and permissions within Tydro. It ensures that sensitive operations are restricted to authorised addresses and that responsibilities are clearly separated across different roles.

Tydro implements an access control list to segregate powers and/or benefits that can be allocated to different entities on the protocol. The ACL\_MANAGER contract is managed by the [PoolAddressesProvider](/vii.-developers/developer-overview/smart-contracts/pool-addresses-provider) contract.

ACLManager keeps track of the individual roles and its holders, and allows a *Role Admin* to manage roles. *Role Admin* is itself a role that is managed by the DEFAULT\_ADMIN\_ROLE.

The DEFAULT\_ADMIN\_ROLE is held by the [ACL\_ADMIN](#acl_admin), and should be initialized in the [PoolAddressesProvider](/vii.-developers/developer-overview/smart-contracts/pool-addresses-provider) beforehand.

### Roles

Below we outline the responsibilities/powers of the roles and the specific methods that are only accessible to the holders of these roles.

The [FLASH\_BORROWER](/vii.-developers/developer-overview/smart-contracts/aclmanager#flash_borrower) and [BRIDGE](/vii.-developers/developer-overview/smart-contracts/aclmanager#bridge) roles have few direct responsibilities and can primarily access specific features of the protocol, while ADMIN roles have the power and responsibility to handle risk or configuration parameters.

#### FLASH\_BORROWER

Holders of this role will have the premium on flash loans waived (this does not include the simple flash loan).

**Methods Accessible:**

[**Pool**](/vii.-developers/developer-overview/smart-contracts/pool):

**Methods Accessible:**

[**Pool**](/vii.-developers/developer-overview/smart-contracts/pool):

* [mintUnbacked()](/vii.-developers/developer-overview/smart-contracts/pool#mintunbacked)
* [backUnbacked()](/vii.-developers/developer-overview/smart-contracts/pool#backunbacked)

#### ASSET\_LISTING\_ADMIN

Holders of this role can:

* Update asset oracle sources and the fallback oracle.
* Add new assets to the Tydro market.

**Methods Accessible:**

[TydroOracles:](/vii.-developers/developer-overview/smart-contracts/oracles)

* [setAssetSources()](/vii.-developers/developer-overview/smart-contracts/oracles#setassetsources)
* [setFallbackOracle()](/vii.-developers/developer-overview/smart-contracts/oracles#setfallbackoracle)

[**PoolConfigurator**](/vii.-developers/developer-overview/smart-contracts/pool-configurator):

* [initReserves()](/vii.-developers/developer-overview/smart-contracts/pool-configurator#initreserves)

#### RISK\_ADMIN

Holders of this role can:

* Update the grace period of Oracle Sentinels.
* Update reserve parameters such as reserve factor, caps, E-Mode category, borrowing enabled, freeze/unfreeze, LTV, liquidation threshold, liquidation bonus (cannot pause/unpause or activate/deactivate a reserve).
* Create new and update existing E-Mode categories (not category 0).
* Update unbacked mint cap and liquidation protocol fee.

**Methods Accessible:**

[**PoolConfigurator**](/vii.-developers/developer-overview/smart-contracts/pool-configurator):

* [setReserveBorrowing()](/vii.-developers/developer-overview/smart-contracts/pool-configurator#setreserveborrowing)
* [configureReserveAsCollateral()](/vii.-developers/developer-overview/smart-contracts/pool-configurator#configurereserveascollateral)
* [setReserveFreeze()](/vii.-developers/developer-overview/smart-contracts/pool-configurator#setreservefreeze)
* [setBorrowableInIsolation()](/vii.-developers/developer-overview/smart-contracts/pool-configurator#setborrowableinisolation)
* [setReserveFactor()](/vii.-developers/developer-overview/smart-contracts/pool-configurator#setreservefactor)
* [setDebtCeiling()](/vii.-developers/developer-overview/smart-contracts/pool-configurator#setdebtceiling)
* [setSiloedBorrowing()](/vii.-developers/developer-overview/smart-contracts/pool-configurator#setsiloedborrowing)
* [setBorrowCap()](/vii.-developers/developer-overview/smart-contracts/pool-configurator#setborrowcap)
* [setSupplyCap()](/vii.-developers/developer-overview/smart-contracts/pool-configurator#setsupplycap)
* [setLiquidationProtocolFee()](/vii.-developers/developer-overview/smart-contracts/pool-configurator#setliquidationprotocolfee)
* [setEModeCategory()](/vii.-developers/developer-overview/smart-contracts/pool-configurator#setemodecategory)
* [setAssetCollateralInEMode()](/vii.-developers/developer-overview/smart-contracts/pool-configurator#setassetcollateralinemode)
* [setUnbackedMintCap()](/vii.-developers/developer-overview/smart-contracts/pool-configurator#setunbackedmintcap)
* [setReserveInterestRateStrategyAddress()](/vii.-developers/developer-overview/smart-contracts/pool-configurator#setreserveinterestratestrategyaddress)
* [setReserveInterestRateData()](/vii.-developers/developer-overview/smart-contracts/pool-configurator#setreserveinterestratedata)
* [disableLiquidationGracePeriod()](/vii.-developers/developer-overview/smart-contracts/pool-configurator#disableliquidationgraceperiod)
* [setReserveFlashLoaning()](/vii.-developers/developer-overview/smart-contracts/pool-configurator#setreserveflashloaning)

[**PriceOracleSentinel**](/vii.-developers/developer-overview/smart-contracts/oracles):

* [setGracePeriod()](/vii.-developers/developer-overview/smart-contracts/oracles#setgraceperiod)

#### ACL\_ADMIN

Holders of this role manage the role admins in the ACLManager. The DEFAULT\_ADMIN\_ROLE is held by the ACL\_ADMIN, and should be initialized in the PoolAddressesProvider beforehand.

**Methods Accessible:**

[**ACLManager**](/vii.-developers/developer-overview/smart-contracts/aclmanager):

* [setRoleAdmin()](/vii.-developers/developer-overview/smart-contracts/aclmanager#setroleadmin)
* [addPoolAdmin()](/vii.-developers/developer-overview/smart-contracts/aclmanager#addpooladmin)
* [removePoolAdmin()](/vii.-developers/developer-overview/smart-contracts/aclmanager#removepooladmin)
* [addEmergencyAdmin()](/vii.-developers/developer-overview/smart-contracts/aclmanager#addemergencyadmin)
* [removeEmergencyAdmin()](/vii.-developers/developer-overview/smart-contracts/aclmanager#removeemergencyadmin)
* [addRiskAdmin()](/vii.-developers/developer-overview/smart-contracts/aclmanager#addriskadmin)
* [removeRiskAdmin()](/vii.-developers/developer-overview/smart-contracts/aclmanager#removeriskadmin)
* [addFlashBorrower()](/vii.-developers/developer-overview/smart-contracts/aclmanager#addflashborrower)
* [removeFlashBorrower()](/vii.-developers/developer-overview/smart-contracts/aclmanager#removeflashborrower)
* [addBridge()](/vii.-developers/developer-overview/smart-contracts/aclmanager#addbridge)
* [removeBridge()](/vii.-developers/developer-overview/smart-contracts/aclmanager#removebridge)
* [addAssetListingAdmin()](/vii.-developers/developer-overview/smart-contracts/aclmanager#addassetlistingadmin)
* [removeAssetListingAdmin()](/vii.-developers/developer-overview/smart-contracts/aclmanager#removeassetlistingadmin)

#### EMERGENCY\_ADMIN

Holders of this role can pause and unpause the pool or an individual reserve.

**Methods Accessible:**

[**PoolConfigurator**](/vii.-developers/developer-overview/smart-contracts/pool-configurator):

* [setReservePause()](/vii.-developers/developer-overview/smart-contracts/pool-configurator#setreservepause)
* [setPoolPause()](/vii.-developers/developer-overview/smart-contracts/pool-configurator#setpoolpause)
* [setReserveActive()](/vii.-developers/developer-overview/smart-contracts/pool-configurator#setreserveactive)
* [setReserveFreeze()](/vii.-developers/developer-overview/smart-contracts/pool-configurator#setreservefreeze)

#### POOL\_ADMIN

Holders of this role can update token implementations, drop, (un)pause and (de)activate reserves, update premiums along with everything the [ASSET\_LISTING\_ADMIN](/vii.-developers/developer-overview/smart-contracts/aclmanager#asset_listing_admin) and [RISK\_ADMIN](/vii.-developers/developer-overview/smart-contracts/aclmanager#risk_admin) can do.

The [POOL\_ADMIN](/vii.-developers/developer-overview/smart-contracts/aclmanager#pool_admin) role is governed by the Guardians multisig.

**Methods Accessible:**

All methods accessible to ASSET\_LISTING\_ADMIN.

All methods accessible to RISK\_ADMIN.

[**AToken**](/vii.-developers/developer-overview/smart-contracts/tokenization):

* [rescueTokens()](/vii.-developers/developer-overview/smart-contracts/tokenization#rescuetokens)

[**Pool**](/vii.-developers/developer-overview/smart-contracts/pool):

* [rescueTokens()](/vii.-developers/developer-overview/smart-contracts/pool#rescuetokens)

[**PoolConfigurator**](/vii.-developers/developer-overview/smart-contracts/pool-configurator):

* [dropReserve()](/vii.-developers/developer-overview/smart-contracts/pool-configurator#dropreserve)
* [updateAToken()](/vii.-developers/developer-overview/smart-contracts/pool-configurator#updateatoken)
* [updateVariableDebtToken()](/vii.-developers/developer-overview/smart-contracts/pool-configurator#updatevariabledebttoken)
* [setReserveActive()](/vii.-developers/developer-overview/smart-contracts/pool-configurator#setreserveactive)
* [updateBridgeProtocolFee()](/vii.-developers/developer-overview/smart-contracts/pool-configurator#updatebridgeprotocolfee)
* [updateFlashloanPremiumTotal()](/vii.-developers/developer-overview/smart-contracts/pool-configurator#updateflashloanpremiumtotal)
* [updateFlashloanPremiumToProtocol()](/vii.-developers/developer-overview/smart-contracts/pool-configurator#updateflashloanpremiumtoprotocol)
* [setAssetBorrowableInEMode()](/vii.-developers/developer-overview/smart-contracts/pool-configurator#setassetborrowableinemode)
* [setReserveInterestRateData()](/vii.-developers/developer-overview/smart-contracts/pool-configurator#setreserveinterestratedata)
* [setReserveInterestRateStrategyAddress()](/vii.-developers/developer-overview/smart-contracts/pool-configurator#setreserveinterestratestrategyaddress)

[**PriceOracleSentinel**](/vii.-developers/developer-overview/smart-contracts/oracles):

* [setSequencerOracle()](/vii.-developers/developer-overview/smart-contracts/oracles#setsequenceroracle)

### Write Methods

#### setRoleAdmin

```
function setRoleAdmin(bytes32 role, bytes32 adminRole) external override onlyRole(DEFAULT_ADMIN_ROLE)
```

Sets the role as admin of a specific role. By default, the adminRole for all roles is [DEFAULT\_ADMIN\_ROLE](/vii.-developers/developer-overview/smart-contracts/aclmanager#acl_admin).

This method can only be called by an address with [DEFAULT\_ADMIN\_ROLE](/vii.-developers/developer-overview/smart-contracts/aclmanager#acl_admin).

**Input Parameters:**

| Name      | Type    | Description                                                                                                                                                                   |
| --------- | ------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| role      | bytes32 | The role to be managed by the admin role - keccak256 hash of one of the following: POOL\_ADMIN, EMERGENCY\_ADMIN, RISK\_ADMIN, FLASH\_BORROWER, BRIDGE, ASSET\_LISTING\_ADMIN |
| adminRole | bytes32 | The admin role. 0x00 is reserved for the DEFAULT\_ADMIN\_ROLE                                                                                                                 |

#### addPoolAdmin

```
function addPoolAdmin(address admin) external override
```

Adds a new admin as *Pool Admin*. The address is added to the list of members with the [POOL\_ADMIN](/vii.-developers/developer-overview/smart-contracts/aclmanager#acl_admin) role. Holders of this role can update token implementations, drop, (un)pause and (de)activate reserves, update premiums and do everything the [ASSET\_LISTING\_ADMIN](/vii.-developers/developer-overview/smart-contracts/aclmanager#asset_listing_admin) and [RISK\_ADMIN](/vii.-developers/developer-overview/smart-contracts/aclmanager#risk_admin) can do.

This method can only be called by the *Role Admin*, specified by Tydro, responsible for managing the [POOL\_ADMIN](/vii.-developers/developer-overview/smart-contracts/aclmanager#pool_admin) role.

**Input Parameters:**

| Name  | Type    | Description                                            |
| ----- | ------- | ------------------------------------------------------ |
| admin | address | The address which will be granted the POOL\_ADMIN role |

#### removePoolAdmin

```
function removePoolAdmin(address admin) external override
```

Removes an admin as *Pool Admin*. The given address is removed from the list of members with the [POOL\_ADMIN](/vii.-developers/developer-overview/smart-contracts/aclmanager#pool_admin) role.

This method can only be called by the *Role Admin*, specified by Tydro, responsible for managing the [POOL\_ADMIN](/vii.-developers/developer-overview/smart-contracts/aclmanager#pool_admin) role.

**Input Parameters:**

| Name  | Type    | Description                                                            |
| ----- | ------- | ---------------------------------------------------------------------- |
| admin | address | The address for which the POOL\_ADMIN role permissions will be removed |

#### addEmergencyAdmin

```
function addEmergencyAdmin(address admin) external override
```

Adds a new admin as an *Emergency Admin*. The address is added to the list of members with the [EMERGENCY\_ADMIN](/vii.-developers/developer-overview/smart-contracts/aclmanager#emergency_admin) role. Holders of this role can pause and unpause the pool or an individual reserve.

This method can only be called by the *Role Admin*, specified by Tydro, responsible for managing the [EMERGENCY\_ADMIN](/vii.-developers/developer-overview/smart-contracts/aclmanager#emergency_admin) role.

**Input Parameters:**

| Name  | Type    | Description                                                 |
| ----- | ------- | ----------------------------------------------------------- |
| admin | address | The address which will be granted the EMERGENCY\_ADMIN role |

#### removeEmergencyAdmin

```
function removeEmergencyAdmin(address admin) external override
```

Removes an admin as *Emergency Admin*. The given address is removed from the list of members with the [EMERGENCY\_ADMIN](/vii.-developers/developer-overview/smart-contracts/aclmanager#emergency_admin) role.

This method can only be called by the *Role Admin*, specified by Tydro, responsible for managing the [EMERGENCY\_ADMIN](/vii.-developers/developer-overview/smart-contracts/aclmanager#emergency_admin) role.

**Input Parameters:**

| Name  | Type    | Description                                                                 |
| ----- | ------- | --------------------------------------------------------------------------- |
| admin | address | The address for which the EMERGENCY\_ADMIN role permissions will be removed |

#### addRiskAdmin

```
function addRiskAdmin(address admin) external override
```

Adds a new admin as a *Risk Admin*. The address is added to the list of members with the [RISK\_ADMIN](/vii.-developers/developer-overview/smart-contracts/aclmanager#risk_admin) role. Holders of this role can update grace period of Oracle Sentinels, reserve params, unbacked mint cap, liquidation fee and eMode categories.

**Input Parameters:**

| Name  | Type    | Description                                            |
| ----- | ------- | ------------------------------------------------------ |
| admin | address | The address which will be granted the RISK\_ADMIN role |

#### removeRiskAdmin

```
function removeRiskAdmin(address admin) external override
```

Removes an admin as *Risk Admin*. The given address is removed from the list of members with the [RISK\_ADMIN](/vii.-developers/developer-overview/smart-contracts/aclmanager#risk_admin) role.

**Input Parameters:**

| Name  | Type    | Description                                                            |
| ----- | ------- | ---------------------------------------------------------------------- |
| admin | address | The address for which the RISK\_ADMIN role permissions will be removed |

#### addFlashBorrower

```
function addFlashBorrower(address borrower) external override
```

Adds a new borrower address as *Flash Borrower*. The address is added to the list of members with the [FLASH\_BORROWER](/vii.-developers/developer-overview/smart-contracts/aclmanager#flash_borrower) role. Holders of this role do not pay premium for flash loan (does not apply to flashLoanSimple).

**Input Parameters:**

| Name     | Type    | Description                                                |
| -------- | ------- | ---------------------------------------------------------- |
| borrower | address | The address which will be granted the FLASH\_BORROWER role |

#### removeFlashBorrower

```
function removeFlashBorrower(address borrower) external override
```

Removes an admin as *Flash Borrower*. The given borrower address is removed from the list of members with the [FLASH\_BORROWER](/vii.-developers/developer-overview/smart-contracts/aclmanager#flash_borrower) role.

**Input Parameters:**

| Name     | Type    | Description                                                                |
| -------- | ------- | -------------------------------------------------------------------------- |
| borrower | address | The address for which the FLASH\_BORROWER role permissions will be removed |

**Input Parameters:**

| Name   | Type    | Description                                   |
| ------ | ------- | --------------------------------------------- |
| bridge | address | The address which will be granted BRIDGE role |

#### addAssetListingAdmin

```
function addAssetListingAdmin(address admin) external override
```

Adds a new admin as *Asset Listing Admin*. The address is added to the list of members with the [ASSET\_LISTING\_ADMIN](/vii.-developers/developer-overview/smart-contracts/aclmanager#asset_listing_admin) role. Holder of this role can update oracles and add new assets to the Aave market.

**Input Parameters:**

| Name  | Type    | Description                                                  |
| ----- | ------- | ------------------------------------------------------------ |
| admin | address | The address which will be granted ASSET\_LISTING\_ADMIN role |

#### removeAssetListingAdmin

```
function removeAssetListingAdmin(address admin) external override
```

Removes an admin as *Asset Listing Admin*. The given address is removed from the list of members with the [ASSET\_LISTING\_ADMIN](/vii.-developers/developer-overview/smart-contracts/aclmanager#asset_listing_admin) role.

**Input Parameters:**

| Name  | Type    | Description                                                                  |
| ----- | ------- | ---------------------------------------------------------------------------- |
| admin | address | The address for which ASSET\_LISTING\_ADMIN role permissions will be removed |

### View Methods

#### isPoolAdmin

```
function isPoolAdmin(address admin) external view override returns (bool)
```

Returns true if the address has the [POOL\_ADMIN](/vii.-developers/developer-overview/smart-contracts/aclmanager#pool_admin) role, false otherwise.

**Input Parameters:**

| Name  | Type    | Description          |
| ----- | ------- | -------------------- |
| admin | address | The address to check |

**Return Values:**

| Type | Description                                               |
| ---- | --------------------------------------------------------- |
| bool | true if the given address is POOL\_ADMIN, false otherwise |

#### isEmergencyAdmin

```
function isEmergencyAdmin(address admin) external view override returns (bool)
```

Returns true if the address has the [EMERGENCY\_ADMIN](/vii.-developers/developer-overview/smart-contracts/aclmanager#emergency_admin) role, false otherwise.

**Input Parameters:**

| Name  | Type    | Description          |
| ----- | ------- | -------------------- |
| admin | address | The address to check |

**Return Values:**

| Type | Description                                                    |
| ---- | -------------------------------------------------------------- |
| bool | true if the given address is EMERGENCY\_ADMIN, false otherwise |

#### isRiskAdmin

```
function isRiskAdmin(address admin) external view override returns (bool)
```

Returns true if the address has the [RISK\_ADMIN](/vii.-developers/developer-overview/smart-contracts/aclmanager#risk_admin) role, false otherwise.

**Input Parameters:**

| Name  | Type    | Description          |
| ----- | ------- | -------------------- |
| admin | address | The address to check |

**Return Values:**

| Type | Description                                               |
| ---- | --------------------------------------------------------- |
| bool | true if the given address is RISK\_ADMIN, false otherwise |

#### isFlashBorrower

```
function isFlashBorrower(address borrower) external view override returns (bool)
```

Returns true if the address has the [FLASH\_BORROWER](/vii.-developers/developer-overview/smart-contracts/aclmanager#flash_borrower) role, false otherwise.

**Input Parameters:**

| Name     | Type    | Description          |
| -------- | ------- | -------------------- |
| borrower | address | The address to check |

**Return Values:**

| Type | Description                                                   |
| ---- | ------------------------------------------------------------- |
| bool | true if the given address is FLASH\_BORROWER, false otherwise |

#### isBridge

```
function isBridge(address bridge) external view override returns (bool)
```

Returns true if the address has [BRIDGE](/vii.-developers/developer-overview/smart-contracts/aclmanager#isbridge) role, false otherwise.

**Input Parameters:**

| Name   | Type    | Description          |
| ------ | ------- | -------------------- |
| bridge | address | The address to check |

**Return Values:**

| Type | Description                                          |
| ---- | ---------------------------------------------------- |
| bool | true if the given address is BRIDGE, false otherwise |

#### isAssetListingAdmin

```
function isAssetListingAdmin(address admin) external view override returns (bool)
```

Returns true if the address has the [ASSET\_LISTING\_ADMIN](/vii.-developers/developer-overview/smart-contracts/aclmanager#asset_listing_admin) role, false otherwise.

**Input Parameters:**

| Name  | Type    | Description          |
| ----- | ------- | -------------------- |
| admin | address | The address to check |

**Return Values:**

| Type | Description                                                         |
| ---- | ------------------------------------------------------------------- |
| bool | true if the given address is ASSET\_LISTING\_ADMIN, false otherwise |


# Oracles

Contract to get asset prices and manage price sources.

The source code is available on Aave's [<mark style="color:blue;">GitHub</mark>](https://github.com/aave-dao/aave-v3-origin/blob/main/src/contracts/misc/AaveOracle.sol).

{% hint style="info" %}
This contract is owned by Tydro
{% endhint %}

### Write Methods

#### setAssetSources

```
function setAssetSources(address[] calldata assets, address[] calldata sources) external override onlyAssetListingOrPoolAdmins
```

Sets the price sources for given list of assets.

This method can only be called by a POOL\_ADMIN or ASSET\_LISTING\_ADMIN. Please look at the [ACLManager](/vii.-developers/developer-overview/smart-contracts/aclmanager) contract for further details on system roles.

**Input Parameters:**

| Name    | Type       | Description                                                                                |
| ------- | ---------- | ------------------------------------------------------------------------------------------ |
| assets  | address\[] | The addresses of the assets for which source is being set                                  |
| sources | address\[] | The address of the source of each asset. Length of assets and sources array should be same |

#### setFallbackOracle

```
function setFallbackOracle(address fallbackOracle) external override onlyAssetListingOrPoolAdmins
```

Sets/updates the fallbackOracle.

This method can only be called by a POOL\_ADMIN or ASSET\_LISTING\_ADMIN. Please look at the [ACLManager](/vii.-developers/developer-overview/smart-contracts/aclmanager) contract for further details on system roles.

**Input Parameters:**

| Name           | Type    | Description                        |
| -------------- | ------- | ---------------------------------- |
| fallbackOracle | address | The address of the fallback oracle |

### View Methods

#### getAssetPrice

```
function getAssetPrice(address asset) public view override returns (uint256)
```

Returns the price of the supported asset in [<mark style="color:blue;">BASE\_CURRENCY</mark>](https://github.com/aave-dao/aave-v3-origin/blob/main/src/contracts/interfaces/IPriceOracleGetter.sol) of the Tydro market in wei.

**Input Parameters:**

| Name  | Type    | Description              |
| ----- | ------- | ------------------------ |
| asset | address | The address of the asset |

**Return Values:**

| Type    | Description                                                         |
| ------- | ------------------------------------------------------------------- |
| uint256 | The price of the asset in BASE\_CURRENCY of the Tydro market in wei |

#### getAssetsPrices

```
function getAssetsPrices(address[] calldata assets) external view override returns (uint256[] memory)
```

Returns a list of prices from a list of the supported assets addresses in [<mark style="color:blue;">BASE\_CURRENCY</mark>](https://github.com/aave-dao/aave-v3-origin/blob/main/src/contracts/interfaces/IPriceOracleGetter.sol) of the Tydro market. All prices are in wei.

**Input Parameters:**

| Name   | Type       | Description                                                   |
| ------ | ---------- | ------------------------------------------------------------- |
| assets | address\[] | The list of assets addresses for which price is being queried |

**Return Values:**

| Type       | Description                                                                 |
| ---------- | --------------------------------------------------------------------------- |
| uint256\[] | The prices of the given assets in BASE\_CURRENCY of the Tydro market in wei |

#### getSourceOfAsset

```
function getSourceOfAsset(address asset) external view override returns (address)
```

Returns the address of the price source for an asset address.

**Input Parameters:**

| Name  | Type    | Description              |
| ----- | ------- | ------------------------ |
| asset | address | The address of the asset |

**Return Values:**

| Type    | Description               |
| ------- | ------------------------- |
| address | The address of the source |

#### getFallbackOracle

```
function getFallbackOracle() external view returns (address)
```

Returns the address of the fallback oracle.

**Return Values:**

| Type    | Description                        |
| ------- | ---------------------------------- |
| address | The address of the fallback oracle |

## PriceOracleSentinel

The PriceOracleSentinel contract validates if the operations are allowed depending on the PriceOracle health.

This feature introduces a grace period for liquidations and disables borrowing under specific circumstances.

This feature has been specifically designed for L2s to handle eventual downtime of the sequencer (but can be extended to handle other cases, even on L1s, in the future).

Once the PriceOracle gets up after an outage or downtime, users can make their positions healthy during a grace period. The PriceOracle is considered healthy once its completely up and the grace period has passed.

The source code is available on [<mark style="color:blue;">Github</mark>](https://github.com/aave-dao/aave-v3-origin/blob/main/src/contracts/misc/PriceOracleSentinel.sol).

### Write Methods

#### setSequencerOracle

```
function setSequencerOracle(address newSequencerOracle) external onlyPoolAdmin
```

Updates the address of the sequencer oracle.

This method can only be called by PoolAdmin.

This method can only be called by the *Role Admin*, responsible for managing the [POOL\_ADMIN](/vii.-developers/developer-overview/smart-contracts/aclmanager#pool_admin) role.

**Input Parameters:**

| Name               | Type    | Description                                       |
| ------------------ | ------- | ------------------------------------------------- |
| newSequencerOracle | address | The address of the new Sequencer Oracle to be set |

#### setGracePeriod

```
function setGracePeriod(uint256 newGracePeriod) public onlyRiskOrPoolAdmins
```

Updates the duration of the grace period.

Can only be called by PoolAdmin or RiskAdmin.

**Input Parameters:**

| Name           | Type    | Description                                 |
| -------------- | ------- | ------------------------------------------- |
| newGracePeriod | uint256 | The duration of new grace period in seconds |

### View Methods

#### isBorrowAllowed

```
function isBorrowAllowed() external view override returns (bool)
```

Returns true if the borrow operation is allowed. The operation is not allowed when PriceOracleis down or the grace period has not passed.

**Return Values:**

| Type | Description                                                                                                          |
| ---- | -------------------------------------------------------------------------------------------------------------------- |
| bool | Returns true if the borrow operation is allowed (the PriceOracle is up and grace period has passed), false otherwise |

#### isLiquidationAllowed

```
function isLiquidationAllowed() external view override returns (bool)
```

Returns true if the liquidation operation is allowed. The operation is not allowed when PriceOracle is down or the grace period has not passed.

**Return Values:**

| Type | Description                                                                                                               |
| ---- | ------------------------------------------------------------------------------------------------------------------------- |
| bool | Returns true if the liquidation operation is allowed (the PriceOracle is up and grace period has passed), false otherwise |

#### getSequencerOracle

```
function getSequencerOracle() external view returns (address)
```

Returns the SequencerOracle.

**Return Values:**

| Type    | Description                                  |
| ------- | -------------------------------------------- |
| address | The address of the sequencer oracle contract |

#### getGracePeriod

```
function getGracePeriod() external view returns (uint256)
```

Returns the grace period.

**Return Values:**

| Type    | Description                                 |
| ------- | ------------------------------------------- |
| uint256 | The duration of the grace period in seconds |


# Pool Addresses Provider

The PoolAddressesProvider is the central registry of addresses for Tydro. It stores the addresses of all core modules and permissioned roles within a specific market. The PoolAddressesProvider also works as the admin of proxy contracts and can update their implementations when needed. For example:

* Updating the address of the [ACLManager](/vii.-developers/developer-overview/smart-contracts/aclmanager)
* Updating the implementation of the [Pool](/vii.-developers/developer-overview/smart-contracts/pool)

This contract defines the initial holder of the  [DEFAULT\_ADMIN\_ROLE](/vii.-developers/developer-overview/smart-contracts/aclmanager#acl_admin), which is immutable once set.

When interacting with the Pool, it is recommended to always fetch the address directly from the PoolAddressesProvider to ensure the correct implementation is used.

The source code is available on Aave's [<mark style="color:blue;">GitHub</mark>](https://github.com/aave-dao/aave-v3-origin/blob/main/src/contracts/protocol/configuration/PoolAddressesProvider.sol).

### Write Methods

#### setMarketId

```
function setMarketId(string memory newMarketId) external override onlyOwner
```

Updates the identifier of the Aave market by associating an id with a specific PoolAddressesProvider. This can be used to create an on-chain registry of pool addresses providers to identify and validate multiple Aave markets.

**Input Parameters:**

| Name        | Type   | Description              |
| ----------- | ------ | ------------------------ |
| newMarketId | string | The new id of the market |

#### setAddress

```
function setAddress(bytes32 id, address newAddress) external override onlyOwner
```

Sets the address of the protocol contract stored at the given id, replacing the address saved in the addresses map.

For example, utils.keccak256(utils.toUtf8Bytes("INCENTIVES\_CONTROLLER")), is set to the address of INCENTIVES\_CONTROLLER.

Use this function carefully, as it will do a hard replacement of the current address in the addresses map.

**Input Parameters:**

| Name       | Type    | Description                                              |
| ---------- | ------- | -------------------------------------------------------- |
| id         | bytes32 | keccak256 hash of UTF8Bytes string representing contract |
| newAddress | address | The new address to be set corresponding to the id        |

#### setAddressAsProxy

```
function setAddressAsProxy(bytes32 id, address newImplementationAddress) external override onlyOwner
```

Updates the implementation address of a proxy contract with a specified id.

If there is no proxy registered, it will instantiate one and set the implementation as the newImplementationAddress.

Use this function carefully, only for ids that do not have an explicit setter function in order to avoid unexpected consequences.

**Input Parameters:**

| Name                     | Type    | Description                                                           |
| ------------------------ | ------- | --------------------------------------------------------------------- |
| id                       | bytes32 | The id of the proxy contract                                          |
| newImplementationAddress | address | The address of new implementation contract corresponding to the proxy |

#### setPoolImpl

```
function setPoolImpl(address newPoolImpl) external override onlyOwner
```

Updates the implementation of the [Pool](/vii.-developers/developer-overview/smart-contracts/pool) contract, or creates a proxy.

**Input Parameters:**

| Name        | Type    | Description                                     |
| ----------- | ------- | ----------------------------------------------- |
| newPoolImpl | address | The address of new Pool implementation contract |

#### setPoolConfiguratorImpl

```
function setPoolConfiguratorImpl(address newPoolConfiguratorImpl) external override onlyOwner
```

Updates the implementation of the [PoolConfigurator](/vii.-developers/developer-overview/smart-contracts/pool-configurator) contract, or creates a proxy.

**Input Parameters:**

| Name                    | Type    | Description                                                 |
| ----------------------- | ------- | ----------------------------------------------------------- |
| newPoolConfiguratorImpl | address | The address of new PoolConfigurator implementation contract |

#### setPriceOracle

```
function setPriceOracle(address newPriceOracle) external override onlyOwner
```

Updates the address of the price oracle.

**Input Parameters:**

| Name           | Type    | Description                     |
| -------------- | ------- | ------------------------------- |
| newPriceOracle | address | The address of new price oracle |

#### setACLManager

```
function setACLManager(address newAclManager) external override onlyOwner
```

Updates the address of the Access Control List Manager.

**Input Parameters:**

| Name          | Type    | Description                       |
| ------------- | ------- | --------------------------------- |
| newAclManager | address | The address of the new ACLManager |

#### setACLAdmin

```
function setACLAdmin(address newAclAdmin) external override onlyOwner
```

Updates the address of the Access Control List Admin.

**Input Parameters:**

| Name        | Type    | Description                 |
| ----------- | ------- | --------------------------- |
| newAclAdmin | address | The address of new ACLAdmin |

#### setPriceOracleSentinel

```
function setPriceOracleSentinel(address newPriceOracleSentinel) external override onlyOwner
```

Updates the address of the price oracle sentinel.

**Input Parameters:**

| Name                   | Type    | Description                            |
| ---------------------- | ------- | -------------------------------------- |
| newPriceOracleSentinel | address | The address of new PriceOracleSentinel |

#### setPoolDataProvider

```
function setPoolDataProvider(address newDataProvider) external override onlyOwner
```

Updates the address of the data provider.

**Input Parameters:**

| Name            | Type    | Description                     |
| --------------- | ------- | ------------------------------- |
| newDataProvider | address | The address of new DataProvider |

### View Methods

#### getMarketId

```
function getMarketId() external view override returns (string memory)
```

Returns the market id of the associated Tydro market.

**Return Values:**

| Type   | Description                              |
| ------ | ---------------------------------------- |
| string | A string representation of the market id |

#### getAddress

```
function getAddress(bytes32 id) public view override returns (address)
```

Returns the address of protocol contract stored at the given id. The returned address might be an EOA or a contract, which may be proxied. It will return ZERO if there is no registered address with the given id.

**Input Parameters:**

| Name | Type    | Description                                                 |
| ---- | ------- | ----------------------------------------------------------- |
| id   | bytes32 | The id. For example, the Protocol Data Provider uses id 0x1 |

**Return Values:**

| Type    | Description                               |
| ------- | ----------------------------------------- |
| address | The address associated with the id passed |

**Example:**

```
// Get address of incentive controllerimport { utils } from "@ethers/lib/utils";
const id = utils.keccak256(utils.toUtf8Bytes("INCENTIVES_CONTROLLER"));const address = poolAddressProvider.getAddress(id);
```

#### getPool

```
function getPool() external view override returns (address)
```

Returns the address of the latest Pool proxy contract.

**Return Values:**

| Type    | Description                              |
| ------- | ---------------------------------------- |
| address | The address of the associated Pool proxy |

#### getPoolConfigurator

```
function getPoolConfigurator() external view override returns (address)
```

Returns the address of the PoolConfigurator proxy. Used for configuration methods, like init reserves or update token implementation etc, of the market.

**Return Values:**

| Type    | Description                        |
| ------- | ---------------------------------- |
| address | The PoolConfigurator proxy address |

#### getPriceOracle

```
function getPriceOracle() external view override returns (address)
```

Returns the address of the Price Oracle used by the market.

**Return Values:**

| Type    | Description                                                   |
| ------- | ------------------------------------------------------------- |
| address | The address of the price oracle used by the associated market |

#### getACLManager

```
function getACLManager() external view override returns (address)
```

Returns the address of the Access Control List Manager (ACLManager) that manages the system role of the market.

**Return Values:**

| Type    | Description                                                                             |
| ------- | --------------------------------------------------------------------------------------- |
| address | The address of the ACLManger contract managing the system role of the associated market |

#### getACLAdmin

```
function getACLAdmin() external view override returns (address)
```

Returns the address of the Access Control List Admin (ACLAdmin) of the market which holds the DEFAULT\_ADMIN\_ROLE in ACLManager.

**Return Values:**

| Type    | Description                                                           |
| ------- | --------------------------------------------------------------------- |
| address | The address of the Access Control List admin of the associated market |

#### getPriceOracleSentinel

```
function getPriceOracleSentinel() external view override returns (address)
```

Returns the address of the price oracle sentinel.

**Return Values:**

<table data-header-hidden><thead><tr><th></th><th></th><th data-hidden></th></tr></thead><tbody><tr><td>Type</td><td>Description</td><td></td></tr><tr><td>address</td><td>The address of the PriceOracleSentinel of the associated market</td><td></td></tr></tbody></table>

#### getPoolDataProvider

```
function getPoolDataProvider() external view override returns (address)
```

Returns the address of latest pool data provider.

**Return Values:**

| Type    | Description                                                    |
| ------- | -------------------------------------------------------------- |
| address | The address of the pool data provider of the associated market |


# Pool Configurator

The PoolConfigurator contract contains the configuration methods for Tydro. These methods control how reserves and markets are set up and maintained.

The write methods exposed by PoolConfigurator are restricted to specific permissioned roles, which are managed by the [ACLManager](/vii.-developers/developer-overview/smart-contracts/aclmanager)

The source code is available on [Aave's Github](https://github.com/aave-dao/aave-v3-origin/blob/main/src/contracts/protocol/pool/PoolConfigurator.sol)

### Write Methods

### Only Asset Listing Or Pool Admins Methods

#### initReserves

```
function initReserves(ConfiguratorInputTypes.InitReserveInput[] calldata input) external override onlyAssetListingOrPoolAdmins
```

Initialzes multiple reserves using the array of initialization parameters as input.

**Input Parameters:**

| Name  | Type                                       | Description                            |
| ----- | ------------------------------------------ | -------------------------------------- |
| input | ConfiguratorInputTypes.InitReserveInput\[] | The array of initialization parameters |

The [<mark style="color:blue;">ConfiguratorInputTypes.InitReserveInput\[\]</mark>](https://github.com/aave-dao/aave-v3-origin/blob/main/src/contracts/protocol/libraries/types/ConfiguratorInputTypes.sol) struct is composed of the following fields:

| Name                        | Type    | Description                                                         |
| --------------------------- | ------- | ------------------------------------------------------------------- |
| aTokenImpl                  | address | The address of the aToken contract implementation                   |
| variableDebtTokenImpl       | address | The address of the variable debt token contract                     |
| useVirtualBalance           | bool    | true if reserve is utilising virtual balance accounting             |
| interestRateStrategyAddress | address | The address of the interest rate strategy contract for this reserve |
| underlyingAsset             | address | The address of the underlying asset                                 |
| treasury                    | address | The address of the treasury                                         |
| incentivesController        | address | The address of the incentives controller for this aToken            |
| aTokenName                  | string  | The name of the aToken                                              |
| aTokenSymbol                | string  | The symbol of the aToken                                            |
| variableDebtTokenName       | string  | The name of the variable debt token                                 |
| variableDebtTokenSymbol     | string  | The symbol of the variable debt token                               |
| params                      | bytes   | A set of encoded parameters for additional initialization           |
| interestRateData            | bytes   | Encoded interest rate strategy data                                 |

### Only Emergency Admin Methods

#### setPoolPause

```
function setPoolPause(bool paused) external override onlyEmergencyOrPoolAdmin
```

Pauses or unpauses all the protocol reserves. In the paused state all the protocol interactions are suspended.

**Input Parameters:**

| Name   | Type | Description                                              |
| ------ | ---- | -------------------------------------------------------- |
| paused | bool | true if the protocol needs to be paused, otherwise false |

### Only Emergency Or Pool Admin Methods

#### setReservePause

```
function setReservePause(address asset, bool paused) public override onlyEmergencyOrPoolAdmin
```

Pauses a reserve. A paused reserve does not allow any interaction (supply, borrow, repay, liquidate, atoken transfers).

**Input Parameters:**

| Name   | Type    | Description                                                 |
| ------ | ------- | ----------------------------------------------------------- |
| asset  | address | The address of the underlying asset of the reserve          |
| paused | bool    | true if pausing the reserve, false if unpausing the reserve |

### Only Pool Admin Methods

#### dropReserve

```
function dropReserve(address asset) external override onlyPoolAdmin
```

Drops a reserve entirely.

**Input Parameters:**

| Name  | Type    | Description                        |
| ----- | ------- | ---------------------------------- |
| asset | address | The address of the reserve to drop |

#### updateAToken

```
function updateAToken(ConfiguratorInputTypes.UpdateATokenInput calldata input) external override onlyPoolAdmin
```

Updates the aToken implementation for the reserve. Takes the aToken update parameters as input.

**Input Parameters:**

| Name  | Type                                     | Description                  |
| ----- | ---------------------------------------- | ---------------------------- |
| input | ConfiguratorInputTypes.UpdateATokenInput | The aToken update parameters |

The [ConfiguratorInputTypes.UpdateATokenInput](https://github.com/aave-dao/aave-v3-origin/blob/main/src/contracts/protocol/libraries/types/ConfiguratorInputTypes.sol) struct is composed of the following fields:

| Name                 | Type    | Description                                               |
| -------------------- | ------- | --------------------------------------------------------- |
| asset                | address | The address of the underlying asset of the reserve        |
| treasury             | address | The address of the treasury                               |
| incentivesController | address | The address of the incentives controller for this aToken  |
| name                 | string  | The name of the aToken                                    |
| symbol               | string  | The symbol of the aToken                                  |
| implementation       | address | The new aToken implementation                             |
| params               | bytes   | A set of encoded parameters for additional initialization |

#### updateVariableDebtToken

```
function updateVariableDebtToken(ConfiguratorInputTypes.UpdateDebtTokenInput calldata input) external override onlyPoolAdmin
```

**Input Parameters:**

| Name  | Type                                        | Description                             |
| ----- | ------------------------------------------- | --------------------------------------- |
| input | ConfiguratorInputTypes.UpdateDebtTokenInput | The variableDebtToken update parameters |

The [<mark style="color:blue;">ConfiguratorInputTypes.UpdateDebtTokenInput</mark>](https://github.com/aave-dao/aave-v3-origin/blob/main/src/contracts/protocol/libraries/types/ConfiguratorInputTypes.sol) struct is composed of the following fields:

| Name                 | Type    | Description                                                         |
| -------------------- | ------- | ------------------------------------------------------------------- |
| asset                | address | The address of the underlying asset of the reserve                  |
| incentivesController | address | The address of the incentives controller for this variableDebtToken |
| name                 | string  | The name of the variableDebtToken                                   |
| symbol               | string  | The symbol of the variableDebtToken                                 |
| implementation       | address | The new variableDebtToken implementation                            |
| params               | bytes   | A set of encoded parameters for additional initialization           |

#### setReserveActive

```
function setReserveActive(address asset, bool active) external override onlyPoolAdmin
```

Activate or deactivate a reserve.

**Input Parameters:**

| Name   | Type    | Description                                             |
| ------ | ------- | ------------------------------------------------------- |
| asset  | address | The address of the underlying asset of the reserve      |
| active | bool    | true if the reserve needs to be active, false otherwise |

#### updateBridgeProtocolFee

```
function updateBridgeProtocolFee(uint256 newBridgeProtocolFee) external override onlyPoolAdmin
```

Updates the bridge fee collected by the protocol reserves.

**Input Parameters:**

| Name                 | Type    | Description                                                         |
| -------------------- | ------- | ------------------------------------------------------------------- |
| newBridgeProtocolFee | uint256 | The part of the fee sent to the protocol treasury, expressed in bps |

#### setReserveFlashLoaning

```
function setReserveFlashLoaning(address asset, bool enabled) external override onlyRiskOrPoolAdmins
```

Enables or disables flash loans for a reserve.

**Input Parameters:**

| Name    | Type    | Description                      |
| ------- | ------- | -------------------------------- |
| asset   | address | Address of the reserve asset     |
| enabled | bool    | true to enable, false to disable |

#### updateFlashloanPremiumTotal

```
function updateFlashloanPremiumTotal(uint128 newFlashloanPremiumTotal) external override onlyPoolAdmin
```

Updates the total flash loan premium. The premium is calculated on the total amount borrowed, and is expressed in bps.

The total flash loan premium consists of two parts:

* A part is sent to aToken holders as extra balance, and
* A part is collected by the protocol reserves.

**Input Parameters:**

| Name                     | Type    | Description                 |
| ------------------------ | ------- | --------------------------- |
| newFlashloanPremiumTotal | uint128 | The total flashloan premium |

#### updateFlashloanPremiumToProtocol

```
function updateFlashloanPremiumToProtocol(uint128 newFlashloanPremiumToProtocol) external override onlyPoolAdmin
```

Updates the flash loan premium collected by protocol reserves. The premium to protocol is calculated on the total flashloan premium, and is expressed in bps.

**Input Parameters:**

| Name                          | Type    | Description                                                     |
| ----------------------------- | ------- | --------------------------------------------------------------- |
| newFlashloanPremiumToProtocol | uint128 | The part of the flashloan premium sent to the protocol treasury |

### Only Risk Or Pool Admins Methods

#### setReserveBorrowing

```
function setReserveBorrowing(address asset, bool enabled) external override onlyRiskOrPoolAdmins
```

**Input Parameters:**

| Name    | Type    | Description                                            |
| ------- | ------- | ------------------------------------------------------ |
| asset   | address | The address of the underlying asset of the reserve     |
| enabled | bool    | true if borrowing needs to be enabled, false otherwise |

#### configureReserveAsCollateral

```
function configureReserveAsCollateral(
    address asset,
    uint256 ltv,
    uint256 liquidationThreshold,
    uint256 liquidationBonus
) external override onlyRiskOrPoolAdmins
```

Configures the reserve collateralization parameters. All the values are expressed in bps. A value of 10000 results in 100.00%. The liquidationBonus is always above 100%. A value of 105% means the liquidator will receive a 5% bonus.

**Input Parameters:**

| Name                 | Type    | Description                                                                                        |
| -------------------- | ------- | -------------------------------------------------------------------------------------------------- |
| asset                | address | The address of the underlying asset of the reserve                                                 |
| ltv                  | uint256 | The loan to value of the asset when used as collateral                                             |
| liquidationThreshold | uint256 | The threshold at which loans using this asset as collateral will be considered undercollateralized |
| liquidationBonus     | uint256 | The bonus liquidators receive to liquidate this asset                                              |

#### setReserveFreeze

```
function setReserveFreeze(address asset, bool freeze) external override onlyRiskOrPoolAdmins
```

Freeze or unfreeze a reserve. A frozen reserve doesn't allow any new supply or borrow but allows repayments, liquidations, rate rebalances and withdrawals.

**Input Parameters:**

| Name   | Type    | Description                                             |
| ------ | ------- | ------------------------------------------------------- |
| asset  | address | The address of the underlying asset of the reserve      |
| freeze | bool    | true if the reserve needs to be frozen, false otherwise |

#### setBorrowableInIsolation

```
function setBorrowableInIsolation(address asset, bool borrowable) external override onlyRiskOrPoolAdmins
```

Sets the borrowable in isolation flag for the reserve. When this flag is set to true, the asset will be borrowable against isolated collaterals and the borrowed amount will be accumulated in the isolated collateral's total debt exposure. Only assets of the same family (e.g. USD stablecoins) should be borrowable in isolation mode to keep consistency in the debt ceiling calculations.

**Input Parameters:**

| Name       | Type    | Description                                                          |
| ---------- | ------- | -------------------------------------------------------------------- |
| asset      | address | The address of the underlying asset of the reserve                   |
| borrowable | bool    | true if the asset should be borrowable in isolation, false otherwise |

#### setReserveFactor

```
function setReserveFactor(address asset, uint256 newReserveFactor) external override onlyRiskOrPoolAdmins
```

Updates the reserve factor of a reserve.

**Input Parameters:**

| Name             | Type    | Description                                        |
| ---------------- | ------- | -------------------------------------------------- |
| asset            | address | The address of the underlying asset of the reserve |
| newReserveFactor | uint256 | The new reserve factor of the reserve              |

#### setDebtCeiling

```
function setDebtCeiling(address asset, uint256 newDebtCeiling) external override onlyRiskOrPoolAdmins
```

Sets the debt ceiling for an asset.

**Input Parameters:**

| Name           | Type    | Description                                        |
| -------------- | ------- | -------------------------------------------------- |
| asset          | address | The address of the underlying asset of the reserve |
| newDebtCeiling | uint256 | The new debt ceiling                               |

#### setSiloedBorrowing

```
function setSiloedBorrowing(address asset, bool newSiloed) external override onlyRiskOrPoolAdmins
```

Sets siloed borrowing for an asset

**Input Parameters:**

| Name      | Type    | Description                                                                         |
| --------- | ------- | ----------------------------------------------------------------------------------- |
| asset     | address | The address of the underlying asset of the reserve                                  |
| newSiloed | bool    | The new siloed borrowing state - enable or disable siloed borrowing for the reserve |

#### setBorrowCap

```
function setBorrowCap(address asset, uint256 newBorrowCap) external override onlyRiskOrPoolAdmins
```

Updates the borrow cap of a reserve. Allows [RISK\_ADMIN](/vii.-developers/developer-overview/smart-contracts/aclmanager#risk_admin) and [POOL\_ADMIN](/vii.-developers/developer-overview/smart-contracts/aclmanager#pool_admin) to add/update cap on the total borrow that can be borrowed from the reserve. Once the borrow cap is reached, no more borrow positions for the given reserve asset can be initiated.

**Input Parameters:**

| Name         | Type    | Description                                                                                         |
| ------------ | ------- | --------------------------------------------------------------------------------------------------- |
| asset        | address | The address of the underlying asset of the reserve                                                  |
| newBorrowCap | uint256 | The new borrow cap of the reserve in whole tokens. A borrow cap of 0 signifies that there is no cap |

#### setSupplyCap

```
function setSupplyCap(address asset, uint256 newSupplyCap) external override onlyRiskOrPoolAdmins
```

Updates the supply cap of a reserve. Allows [RISK\_ADMIN](/vii.-developers/developer-overview/smart-contracts/aclmanager#risk_admin) and [POOL\_ADMIN](/vii.-developers/developer-overview/smart-contracts/aclmanager#pool_admin) to add/update liquidity supply cap on the reserve. Once the supply cap is reached, no more liquidity for the given reserve asset can be supplied to the pool.

**Input Parameters:**

| Name         | Type    | Description                                                                                         |
| ------------ | ------- | --------------------------------------------------------------------------------------------------- |
| asset        | address | The address of the underlying asset of the reserve                                                  |
| newSupplyCap | uint256 | The new supply cap of the reserve in whole tokens. A supply cap of 0 signifies that there is no cap |

#### disableLiquidationGracePeriod

```
function disableLiquidationGracePeriod(address asset) external override onlyEmergencyOrPoolAdmin
```

Disables the liquidation grace period for a reserve.

**Input Parameters**

| Name  | Type    | Description                  |
| ----- | ------- | ---------------------------- |
| asset | address | Address of the reserve asset |

#### setLiquidationProtocolFee

```
function setLiquidationProtocolFee(address asset, uint256 newFee) external override onlyRiskOrPoolAdmins
```

Updates the liquidation protocol fee of reserve.

**Input Parameters:**

| Name   | Type    | Description                                                       |
| ------ | ------- | ----------------------------------------------------------------- |
| asset  | address | The address of the underlying asset of the reserve                |
| newFee | uint256 | The new liquidation protocol fee of the reserve, expressed in bps |

#### setEModeCategory

```
function setEModeCategory(
    uint8 categoryId,
    uint16 ltv,
    uint16 liquidationThreshold,
    uint16 liquidationBonus,
    string calldata label
) external override onlyRiskOrPoolAdmins
```

Adds a new efficiency mode (eMode) category. Allows [RISK\_ADMIN](/vii.-developers/developer-overview/smart-contracts/aclmanager#risk_admin) and [POOL\_ADMIN](/vii.-developers/developer-overview/smart-contracts/aclmanager#pool_admin) to configure existing or add new eModeCategory

If zero is provided as oracle address, the default asset oracles will be used to compute the overall debt and overcollateralization of the users using this category. The new ltv and liquidation threshold must be greater than the base ltvs and liquidation thresholds of all assets within the eMode category.

**Input Parameters:**

| Name                 | Type   | Description                                                                                                                   |
| -------------------- | ------ | ----------------------------------------------------------------------------------------------------------------------------- |
| categoryId           | uint8  | The id of the category to be configured. categoryId ≠ 0. NOTE: category 0 is reserved for the default category i.e. non-eMode |
| ltv                  | uint16 | The loan to value for the associated eMode category. It must be less than or equal to the liquidationThreshold                |
| liquidationThreshold | uint16 | The liquidation threshold associated with the category                                                                        |
| liquidationBonus     | uint16 | The liquidation bonus associated with the category                                                                            |
| label                | string | A custom label identifying the category                                                                                       |

#### setAssetCollateralInEMode

```
function setAssetCollateralInEMode(address asset, uint8 categoryId, bool allowed) external override onlyRiskOrPoolAdmins
```

Assign collateral status to an asset for a particular efficiency mode (eMode) category. Allows [RISK\_ADMIN](/vii.-developers/developer-overview/smart-contracts/aclmanager#risk_admin) and [POOL\_ADMIN](/vii.-developers/developer-overview/smart-contracts/aclmanager#pool_admin) to configure eModeCategory of an asset.

**Input Parameters:**

| Name       | Type    | Description                                                     |
| ---------- | ------- | --------------------------------------------------------------- |
| asset      | address | The address of the underlying asset of the reserve              |
| categoryId | uint8   | eMode category id to set asset collateral status for            |
| allowed    | bool    | true if asset is enabled as collateral in designated categoryId |

#### setAssetBorrowableInEMode

```
function setAssetBorrowableInEMode(address asset, uint8 categoryId, bool borrowable) external override onlyRiskOrPoolAdmins
```

Configures if an asset can be borrowed in a specific eMode category.

**Input Parameters:**

| Name       | Type    | Description                      |
| ---------- | ------- | -------------------------------- |
| asset      | address | Address of the reserve asset     |
| categoryId | uint8   | eMode category ID                |
| borrowable | bool    | true to enable, false to disable |

#### setUnbackedMintCap

```
function setUnbackedMintCap(address asset, uint256 newUnbackedMintCap) external override onlyRiskOrPoolAdmins
```

Updates the unbacked mint cap of reserve.

**Input Parameters:**

| Name               | Type    | Description                                        |
| ------------------ | ------- | -------------------------------------------------- |
| asset              | address | The address of the underlying asset of the reserve |
| newUnbackedMintCap | uint256 | The new unbacked mint cap of the reserve           |

#### setReserveInterestRateData

```
function setReserveInterestRateData(address asset, bytes calldata rateData) external onlyRiskOrPoolAdmins
```

Sets custom interest rate parameters for a reserve.

**Input Parameters:**

| Name     | Type    | Description                      |
| -------- | ------- | -------------------------------- |
| asset    | address | Address of the reserve asset     |
| rateData | bytes   | Encodes rate strategy parameters |

#### setReserveInterestRateStrategyAddress

```
function setReserveInterestRateStrategyAddress(address asset, address rateStrategyAddress, bytes calldata rateData) external override onlyRiskOrPoolAdmins
```

Sets the interest rate strategy of a reserve.

**Input Parameters:**

| Name                | Type    | Description                                        |
| ------------------- | ------- | -------------------------------------------------- |
| asset               | address | The address of the underlying asset of the reserve |
| rateStrategyAddress | address | The address of the interest strategy contract      |
| rateData            | bytes   | Encoded interst rate strategy data                 |

### Pure Methods

#### getRevision

```
function getRevision() internal pure virtual override returns (uint256)
```

Returns the revision number of the contract. Needs to be defined in the inherited class as a constant.

Returns 0x1.

**Return Values:**

| Type    | Description         |
| ------- | ------------------- |
| uint256 | The revision number |


# Vaults

## ATokenVault

The ATokenVault contract is an ERC-4626 compliant yield-bearing vault designed for Aave V3. It allows users to supply and withdraw ERC-20 tokens supported by Aave V3, automatically managing asset supply and withdrawal within the Aave Protocol. This vault also enables managers to collect a fee on the yield generated.

The smart contract source code is available on <mark style="color:blue;">GitHub</mark>.

### Write Methods

#### initialize

```
function initialize(    address owner,    uint256 initialFee,    string memory shareName,    string memory shareSymbol,    uint256 initialLockDeposit) external initializer
```

Initializes the vault, setting its initial parameters and initializing inherited contracts. An initial non-zero deposit (in underlying tokens) is required to prevent frontrunning attacks. It does not initialize the OwnableUpgradeable contract to avoid setting the proxy admin as the owner.

**Input Parameters:**

| Name               | Type    | Description                                                                                                                                    |   |
| ------------------ | ------- | ---------------------------------------------------------------------------------------------------------------------------------------------- | - |
| owner              | address | The address to set as the owner of the vault.                                                                                                  |   |
| initialFee         | uint256 | The initial fee to set, expressed in wad, where (1 \times 10^18) is 100%.                                                                      |   |
| shareName          | string  | The name to set for the vault's shares.                                                                                                        |   |
| shareSymbol        | string  | The symbol to set for the vault's shares.                                                                                                      |   |
| initialLockDeposit | uint256 | The initial amount of underlying assets to deposit. This must be a non-zero, non-trivial amount, depending on the underlying asset's decimals. |   |

#### deposit

```
function deposit(uint256 assets, address receiver) public override returns (uint256)
```

Deposits assets (underlying tokens) into the vault and mints a corresponding amount of vault shares to the receiver.

**Input Parameters:**

| Name     | Type    | Description                                       |   |
| -------- | ------- | ------------------------------------------------- | - |
| assets   | uint256 | The amount of underlying assets to deposit.       |   |
| receiver | address | The address to which vault shares will be minted. |   |

**Return Values:**

| Type    | Description                        |   |
| ------- | ---------------------------------- | - |
| uint256 | The amount of vault shares minted. |   |

#### depositATokens

```
function depositATokens(uint256 assets, address receiver) public override returns (uint256)
```

Deposits assets (aTokens) directly into the vault and mints a corresponding amount of vault shares to the receiver.

**Input Parameters:**

| Name     | Type    | Description                                       |   |
| -------- | ------- | ------------------------------------------------- | - |
| assets   | uint256 | The amount of aTokens to deposit.                 |   |
| receiver | address | The address to which vault shares will be minted. |   |

**Return Values:**

| Type    | Description                        |   |
| ------- | ---------------------------------- | - |
| uint256 | The amount of vault shares minted. |   |

#### depositWithSig

```
function depositWithSig(    uint256 assets,    address receiver,    address depositor,    EIP712Signature calldata sig) public override returns (uint256)
```

Deposits assets (underlying tokens) into the vault on behalf of a depositor, authenticated by an EIP-712 signature. Vault shares are minted to the receiver.

**Input Parameters:**

| Name      | Type            | Description                                                                                    |   |
| --------- | --------------- | ---------------------------------------------------------------------------------------------- | - |
| assets    | uint256         | The amount of underlying assets to deposit.                                                    |   |
| receiver  | address         | The address to which vault shares will be minted.                                              |   |
| depositor | address         | The address of the actual depositor, whose signature is provided.                              |   |
| sig       | EIP712Signature | The EIP-712 signature for the deposit transaction, including v, r, s parameters, and deadline. |   |

**Return Values:**

| Type    | Description                        |   |
| ------- | ---------------------------------- | - |
| uint256 | The amount of vault shares minted. |   |

#### depositATokensWithSig

```
function depositATokensWithSig(    uint256 assets,    address receiver,    address depositor,    EIP712Signature calldata sig) public override returns (uint256)
```

Deposits assets (aTokens) directly into the vault on behalf of a depositor, authenticated by an EIP-712 signature. Vault shares are minted to the receiver.

**Input Parameters:**

| Name      | Type            | Description                                                                                    |   |
| --------- | --------------- | ---------------------------------------------------------------------------------------------- | - |
| assets    | uint256         | The amount of aTokens to deposit.                                                              |   |
| receiver  | address         | The address to which vault shares will be minted.                                              |   |
| depositor | address         | The address of the actual depositor, whose signature is provided.                              |   |
| sig       | EIP712Signature | The EIP-712 signature for the deposit transaction, including v, r, s parameters, and deadline. |   |

**Return Values:**

| Type    | Description                        |   |
| ------- | ---------------------------------- | - |
| uint256 | The amount of vault shares minted. |   |

#### mint

```
function mint(uint256 shares, address receiver) public override returns (uint256)
```

Mints an exact amount of shares (vault shares) to the receiver by depositing the calculated amount of underlying assets.

**Input Parameters:**

| Name     | Type    | Description                                       |   |
| -------- | ------- | ------------------------------------------------- | - |
| shares   | uint256 | The exact amount of vault shares to mint.         |   |
| receiver | address | The address to which vault shares will be minted. |   |

**Return Values:**

| Type    | Description                                                            |   |
| ------- | ---------------------------------------------------------------------- | - |
| uint256 | The amount of underlying assets required to mint the specified shares. |   |

#### mintWithATokens

```
function mintWithATokens(uint256 shares, address receiver) public override returns (uint256)
```

Mints an exact amount of shares (vault shares) to the receiver by depositing the calculated amount of aTokens.

**Input Parameters:**

| Name     | Type    | Description                                       |   |
| -------- | ------- | ------------------------------------------------- | - |
| shares   | uint256 | The exact amount of vault shares to mint.         |   |
| receiver | address | The address to which vault shares will be minted. |   |

**Return Values:**

| Type    | Description                                                  |   |
| ------- | ------------------------------------------------------------ | - |
| uint256 | The amount of aTokens required to mint the specified shares. |   |

#### mintWithSig

```
function mintWithSig(    uint256 shares,    address receiver,    address depositor,    EIP712Signature calldata sig) public override returns (uint256)
```

Mints an exact amount of shares (vault shares) to the receiver on behalf of a depositor, authenticated by an EIP-712 signature, by depositing the calculated amount of underlying assets.

**Input Parameters:**

| Name      | Type            | Description                                                                                 |   |
| --------- | --------------- | ------------------------------------------------------------------------------------------- | - |
| shares    | uint256         | The exact amount of vault shares to mint.                                                   |   |
| receiver  | address         | The address to which vault shares will be minted.                                           |   |
| depositor | address         | The address of the actual depositor, whose signature is provided.                           |   |
| sig       | EIP712Signature | The EIP-712 signature for the mint transaction, including v, r, s parameters, and deadline. |   |

**Return Values:**

| Type    | Description                                                            |   |
| ------- | ---------------------------------------------------------------------- | - |
| uint256 | The amount of underlying assets required to mint the specified shares. |   |

#### mintWithATokensWithSig

```
function mintWithATokensWithSig(    uint256 shares,    address receiver,    address depositor,    EIP712Signature calldata sig) public override returns (uint256)
```

Mints an exact amount of shares (vault shares) to the receiver on behalf of a depositor, authenticated by an EIP-712 signature, by depositing the calculated amount of aTokens.

**Input Parameters:**

| Name      | Type            | Description                                                                                 |   |
| --------- | --------------- | ------------------------------------------------------------------------------------------- | - |
| shares    | uint256         | The exact amount of vault shares to mint.                                                   |   |
| receiver  | address         | The address to which vault shares will be minted.                                           |   |
| depositor | address         | The address of the actual depositor, whose signature is provided.                           |   |
| sig       | EIP712Signature | The EIP-712 signature for the mint transaction, including v, r, s parameters, and deadline. |   |

**Return Values:**

| Type    | Description                                                  |   |
| ------- | ------------------------------------------------------------ | - |
| uint256 | The amount of aTokens required to mint the specified shares. |   |

#### withdraw

```
function withdraw(    uint256 assets,    address receiver,    address owner) public override returns (uint256)
```

Withdraws assets (underlying tokens) from the vault and sends them to the receiver. The corresponding vault shares are burned from the owner.

**Input Parameters:**

| Name     | Type    | Description                                              |   |
| -------- | ------- | -------------------------------------------------------- | - |
| assets   | uint256 | The amount of underlying assets to withdraw.             |   |
| receiver | address | The address to which the underlying assets will be sent. |   |
| owner    | address | The address from which vault shares will be burned.      |   |

**Return Values:**

| Type    | Description                                           |   |
| ------- | ----------------------------------------------------- | - |
| uint256 | The amount of vault shares burned for the withdrawal. |   |

#### withdrawATokens

```
function withdrawATokens(uint256 assets, address receiver, address owner) public override returns (uint256)
```

Withdraws assets (aTokens) directly from the vault and sends them to the receiver. The corresponding vault shares are burned from the owner.

**Input Parameters:**

| Name     | Type    | Description                                         |   |
| -------- | ------- | --------------------------------------------------- | - |
| assets   | uint256 | The amount of aTokens to withdraw.                  |   |
| receiver | address | The address to which the aTokens will be sent.      |   |
| owner    | address | The address from which vault shares will be burned. |   |

**Return Values:**

| Type    | Description                                           |   |
| ------- | ----------------------------------------------------- | - |
| uint256 | The amount of vault shares burned for the withdrawal. |   |

#### withdrawWithSig

```
function withdrawWithSig(    uint256 assets,    address receiver,    address owner,    EIP712Signature calldata sig) public override returns (uint256)
```

Withdraws assets (underlying tokens) from the vault and sends them to the receiver. The corresponding vault shares are burned from the owner, authenticated by an EIP-712 signature.

**Input Parameters:**

| Name     | Type            | Description                                                                                       |   |
| -------- | --------------- | ------------------------------------------------------------------------------------------------- | - |
| assets   | uint256         | The amount of underlying assets to withdraw.                                                      |   |
| receiver | address         | The address to which the underlying assets will be sent.                                          |   |
| owner    | address         | The address from which vault shares will be burned. This address must be the signatory.           |   |
| sig      | EIP712Signature | The EIP-712 signature for the withdrawal transaction, including v, r, s parameters, and deadline. |   |

**Return Values:**

| Type    | Description                                           |   |
| ------- | ----------------------------------------------------- | - |
| uint256 | The amount of vault shares burned for the withdrawal. |   |

#### withdrawATokensWithSig

```
function withdrawATokensWithSig(    uint256 assets,    address receiver,    address owner,    EIP712Signature calldata sig) public override returns (uint256)
```

Withdraws assets (aTokens) directly from the vault and sends them to the receiver. The corresponding vault shares are burned from the owner, authenticated by an EIP-712 signature.

**Input Parameters:**

| Name     | Type            | Description                                                                                       |   |
| -------- | --------------- | ------------------------------------------------------------------------------------------------- | - |
| assets   | uint256         | The amount of aTokens to withdraw.                                                                |   |
| receiver | address         | The address to which the aTokens will be sent.                                                    |   |
| owner    | address         | The address from which vault shares will be burned. This address must be the signatory.           |   |
| sig      | EIP712Signature | The EIP-712 signature for the withdrawal transaction, including v, r, s parameters, and deadline. |   |

**Return Values:**

| Type    | Description                                           |   |
| ------- | ----------------------------------------------------- | - |
| uint256 | The amount of vault shares burned for the withdrawal. |   |

#### redeem

```
function redeem(    uint256 shares,    address receiver,    address owner) public override returns (uint256)
```

Redeems shares (vault shares) for the underlying assets, which are sent to the receiver. The shares are burned from the owner.

**Input Parameters:**

| Name     | Type    | Description                                              |   |
| -------- | ------- | -------------------------------------------------------- | - |
| shares   | uint256 | The amount of vault shares to redeem.                    |   |
| receiver | address | The address to which the underlying assets will be sent. |   |
| owner    | address | The address from which vault shares will be burned.      |   |

**Return Values:**

| Type    | Description                                              |   |
| ------- | -------------------------------------------------------- | - |
| uint256 | The amount of underlying assets received for the shares. |   |

#### redeemAsATokens

```
function redeemAsATokens(uint256 shares, address receiver, address owner) public override returns (uint256)
```

Redeems shares (vault shares) for aTokens, which are sent to the receiver. The shares are burned from the owner.

**Input Parameters:**

| Name     | Type    | Description                                         |   |
| -------- | ------- | --------------------------------------------------- | - |
| shares   | uint256 | The amount of vault shares to redeem.               |   |
| receiver | address | The address to which the aTokens will be sent.      |   |
| owner    | address | The address from which vault shares will be burned. |   |

**Return Values:**

| Type    | Description                                    |   |
| ------- | ---------------------------------------------- | - |
| uint256 | The amount of aTokens received for the shares. |   |

#### redeemWithSig

```
function redeemWithSig(    uint256 shares,    address receiver,    address owner,    EIP712Signature calldata sig) public override returns (uint256)
```

Redeems shares (vault shares) for the underlying assets, which are sent to the receiver. The shares are burned from the owner, authenticated by an EIP-712 signature.

**Input Parameters:**

| Name     | Type            | Description                                                                                       |   |
| -------- | --------------- | ------------------------------------------------------------------------------------------------- | - |
| shares   | uint256         | The amount of vault shares to redeem.                                                             |   |
| receiver | address         | The address to which the underlying assets will be sent.                                          |   |
| owner    | address         | The address from which vault shares will be burned. This address must be the signatory.           |   |
| sig      | EIP712Signature | The EIP-712 signature for the redemption transaction, including v, r, s parameters, and deadline. |   |

**Return Values:**

| Type    | Description                                              |   |
| ------- | -------------------------------------------------------- | - |
| uint256 | The amount of underlying assets received for the shares. |   |

#### redeemWithATokensWithSig

```
function redeemWithATokensWithSig(    uint256 shares,    address receiver,    address owner,    EIP712Signature calldata sig) public override returns (uint256)
```

Redeems shares (vault shares) for aTokens, which are sent to the receiver. The shares are burned from the owner, authenticated by an EIP-712 signature.

**Input Parameters:**

| Name     | Type            | Description                                                                                       |   |
| -------- | --------------- | ------------------------------------------------------------------------------------------------- | - |
| shares   | uint256         | The amount of vault shares to redeem.                                                             |   |
| receiver | address         | The address to which the aTokens will be sent.                                                    |   |
| owner    | address         | The address from which vault shares will be burned. This address must be the signatory.           |   |
| sig      | EIP712Signature | The EIP-712 signature for the redemption transaction, including v, r, s parameters, and deadline. |   |

**Return Values:**

| Type    | Description                                    |   |
| ------- | ---------------------------------------------- | - |
| uint256 | The amount of aTokens received for the shares. |   |

#### setFee

```
function setFee(uint256 newFee) public override onlyOwner
```

Sets a new fee percentage for the vault. This function can only be called by the vault owner. Accrues current yield before updating the fee.

**Input Parameters:**

| Name   | Type    | Description                                                           |   |
| ------ | ------- | --------------------------------------------------------------------- | - |
| newFee | uint256 | The new fee to set, expressed in wad, where (1 \times 10^18) is 100%. |   |

#### withdrawFees

```
function withdrawFees(address to, uint256 amount) public override onlyOwner
```

Withdraws amount of accumulated fees (in aTokens) to the specified to address. This function can only be called by the vault owner. Accrues current yield before withdrawing fees.

**Input Parameters:**

| Name   | Type    | Description                                           |   |
| ------ | ------- | ----------------------------------------------------- | - |
| to     | address | The address to which the collected fees will be sent. |   |
| amount | uint256 | The amount of fees to withdraw.                       |   |

#### claimRewards

```
function claimRewards(address to) public override onlyOwner
```

Claims any pending rewards accumulated by the vault and sends them to the specified toaddress. This function can only be called by the vault owner.

**Input Parameters:**

| Name | Type    | Description                                            |   |
| ---- | ------- | ------------------------------------------------------ | - |
| to   | address | The address to which the claimed rewards will be sent. |   |

#### emergencyRescue

```
function emergencyRescue(    address token,    address to,    uint256 amount) public override onlyOwner
```

Allows the vault owner to rescue an arbitrary amount of an ERC-20 token that was mistakenly sent to the vault, transferring it to the to address. This function cannot be used to rescue the AToken that the vault is designed to hold.

**Input Parameters:**

| Name   | Type    | Description                                                              |   |
| ------ | ------- | ------------------------------------------------------------------------ | - |
| token  | address | The address of the ERC-20 token to rescue. Cannot be the vault's AToken. |   |
| to     | address | The address to which the rescued tokens will be sent.                    |   |
| amount | uint256 | The amount of tokens to rescue.                                          |   |

### View Methods

#### maxDeposit

```
function maxDeposit(address) public view override returns (uint256)
```

Returns the maximum amount of underlying assets that can be deposited into the vault. This is determined by the Aave protocol's supply cap and the current supplied amount.

**Input Parameters:**

| Name | Type    | Description                                         |   |
| ---- | ------- | --------------------------------------------------- | - |
| -    | address | Placeholder for receiver (not used in computation). |   |

**Return Values:**

| Type    | Description                                                    |   |
| ------- | -------------------------------------------------------------- | - |
| uint256 | The maximum amount of underlying assets that can be deposited. |   |

#### maxMint

```
function maxMint(address) public view override returns (uint256)
```

Returns the maximum amount of vault shares that can be minted. This is derived from the maximum suppliable assets converted to shares.

**Input Parameters:**

| Name | Type    | Description                                         |   |
| ---- | ------- | --------------------------------------------------- | - |
| -    | address | Placeholder for receiver (not used in computation). |   |

**Return Values:**

| Type    | Description                                            |   |
| ------- | ------------------------------------------------------ | - |
| uint256 | The maximum amount of vault shares that can be minted. |   |

#### maxWithdraw

```
function maxWithdraw(address owner) public view override returns (uint256)
```

Returns the maximum amount of underlying assets that can be withdrawn by a specific owner. This is limited by the vault's balance and Aave's available liquidity.

**Input Parameters:**

| Name  | Type    | Description                                                               |   |
| ----- | ------- | ------------------------------------------------------------------------- | - |
| owner | address | The address of the share owner whose maximum withdrawal is being queried. |   |

**Return Values:**

| Type    | Description                                                    |   |
| ------- | -------------------------------------------------------------- | - |
| uint256 | The maximum amount of underlying assets that can be withdrawn. |   |

#### maxRedeem

```
function maxRedeem(address owner) public view override returns (uint256)
```

Returns the maximum amount of vault shares that can be redeemed by a specific owner. This is limited by the vault's balance and Aave's available liquidity.

**Input Parameters:**

| Name  | Type    | Description                                                               |   |
| ----- | ------- | ------------------------------------------------------------------------- | - |
| owner | address | The address of the share owner whose maximum redemption is being queried. |   |

**Return Values:**

| Type    | Description                                              |   |
| ------- | -------------------------------------------------------- | - |
| uint256 | The maximum amount of vault shares that can be redeemed. |   |

#### previewDeposit

```
function previewDeposit(uint256 assets) public view override returns (uint256)
```

Provides a preview of the amount of vault shares that would be minted for a given assetsdeposit.

**Input Parameters:**

| Name   | Type    | Description                                             |   |
| ------ | ------- | ------------------------------------------------------- | - |
| assets | uint256 | The amount of underlying assets to preview deposit for. |   |

**Return Values:**

| Type    | Description                                        |   |
| ------- | -------------------------------------------------- | - |
| uint256 | The amount of vault shares that would be received. |   |

#### previewMint

```
function previewMint(uint256 shares) public view override returns (uint256)
```

Provides a preview of the amount of underlying assets that would be required to mint a given shares amount of vault shares.

**Input Parameters:**

| Name   | Type    | Description                                     |   |
| ------ | ------- | ----------------------------------------------- | - |
| shares | uint256 | The amount of vault shares to preview mint for. |   |

**Return Values:**

| Type    | Description                                             |   |
| ------- | ------------------------------------------------------- | - |
| uint256 | The amount of underlying assets that would be required. |   |

#### previewWithdraw

```
function previewWithdraw(uint256 assets) public view override returns (uint256)
```

Provides a preview of the amount of vault shares that would be burned for a given assetswithdrawal.

**Input Parameters:**

| Name   | Type    | Description                                                |   |
| ------ | ------- | ---------------------------------------------------------- | - |
| assets | uint256 | The amount of underlying assets to preview withdrawal for. |   |

**Return Values:**

| Type    | Description                                      |   |
| ------- | ------------------------------------------------ | - |
| uint256 | The amount of vault shares that would be burned. |   |

#### previewRedeem

```
function previewRedeem(uint256 shares) public view override returns (uint256)
```

Provides a preview of the amount of underlying assets that would be received for a given shares redemption.

**Input Parameters:**

| Name   | Type    | Description                                       |   |
| ------ | ------- | ------------------------------------------------- | - |
| shares | uint256 | The amount of vault shares to preview redeem for. |   |

**Return Values:**

| Type    | Description                                             |   |
| ------- | ------------------------------------------------------- | - |
| uint256 | The amount of underlying assets that would be received. |   |

#### domainSeparator

```
function domainSeparator() public view override returns (bytes32)
```

Returns the EIP-712 domain separator for this contract.

**Return Values:**

| Type    | Description                   |   |
| ------- | ----------------------------- | - |
| bytes32 | The EIP-712 domain separator. |   |

#### totalAssets

```
function totalAssets() public view override returns (uint256)
```

Reports the total assets managed by the vault, net of fees, for vault share logic.

**Return Values:**

| Type    | Description                                                 |   |
| ------- | ----------------------------------------------------------- | - |
| uint256 | The total amount of assets held by the vault (net of fees). |   |

#### getClaimableFees

```
function getClaimableFees() public view override returns (uint256)
```

Calculates and returns the total amount of fees that are currently claimable by the vault manager.

**Return Values:**

| Type    | Description                                   |   |
| ------- | --------------------------------------------- | - |
| uint256 | The total amount of fees that can be claimed. |   |

#### getSigNonce

```
function getSigNonce(address signer) public view override returns (uint256)
```

Returns the current nonce for a given signer address, used for EIP-712 signatures to prevent replay attacks.

**Input Parameters:**

| Name   | Type    | Description                                                 |   |
| ------ | ------- | ----------------------------------------------------------- | - |
| signer | address | The address whose EIP-712 signature nonce is being queried. |   |

**Return Values:**

| Type    | Description                                 |   |
| ------- | ------------------------------------------- | - |
| uint256 | The current nonce for the specified signer. |   |

#### getLastVaultBalance

```
function getLastVaultBalance() public view override returns (uint256)
```

Returns the last recorded balance of the vault's AToken. This value is updated when yield is accrued.

**Return Values:**

| Type    | Description                                             |   |
| ------- | ------------------------------------------------------- | - |
| uint256 | The last recorded balance of ATokens held by the vault. |   |

#### getFee

```
function getFee() public view override returns (uint256)
```

Returns the current fee percentage set for the vault.

**Return Values:**

| Type    | Description                                                        |   |
| ------- | ------------------------------------------------------------------ | - |
| uint256 | The current fee, expressed in wad, where (1 \times 10^18) is 100%. |   |


# Swap Features

The [Aave Labs interface](https://app.aave.com/) integrates multiple features integrating token swaps detailed below.

### Swap Tokens

The *Swap Tokens* feature enables users to swap between tokens using [ParaSwap](https://app.paraswap.io/) or [CoW Swap](https://swap.cow.fi/)as the swap provider, depending on network availability. Tokens traded using CoW Swap will incur a fee depending on token pair. A discounted fee of 15bps is applied to swaps between correlated assets (e.g. ETH/wstETH), for all other swaps a fee of 25bps is applied — the list of correlated assets is reviewed and updated periodically:

* **Stablecoin asset group**: USDC, USDT, DAI, GHO, EURC, USDbC, USDe, USDS, sUSDe, RLUSD, PYUSD, LUSD, sDAI, crvUSD, USD₮0, USDC.e, EURe, xDAI, wxDAI
* **ETH correlated asset group**: weETH, ETH, WETH, wstETH, cbETH, ezETH, wrsETH, osETH, rETH, ETHx
* **BTC correlated asset group**: cbBTC, WBTC, LBTC, tBTC, eBTC

### Swap Adapter Contracts

The swap adapter contracts integrate Aave's Flash Loans and the [ParaSwap](https://app.paraswap.io/) DEX aggregator to facilitate advanced actions such as repaying borrow positions using collateral, swapping collateral assets, swapping borrow positions, and withdrawing and swapping assets. They allow users to perform complex operations in a single transaction, leveraging the liquidity of the Aave protocol and the atomic swapping capabilities of decentralized exchanges.

The table below outlines swap feature availability across V3 markets on the [Aave Labs interface](https://app.aave.com/):

| Market           | Token Swap | Repay With Collateral | Collateral Swap | Debt Swap | Withdraw & Swap |   |
| ---------------- | ---------- | --------------------- | --------------- | --------- | --------------- | - |
| Ethereum Core    |            |                       |                 |           |                 |   |
| Ethereum Prime   |            |                       |                 |           |                 |   |
| Ethereum EtherFi |            |                       |                 |           |                 |   |
| Arbitrum         |            |                       |                 |           |                 |   |
| Avalanche        |            |                       |                 |           |                 |   |
| Base             |            |                       |                 |           |                 |   |
| BNB              |            |                       |                 |           |                 |   |
| Optimism         |            |                       |                 |           |                 |   |
| Polygon          |            |                       |                 |           |                 |   |
| Gnosis           |            |                       |                 |           |                 |   |
| Metis            |            |                       |                 |           |                 |   |
| Scroll           |            |                       |                 |           |                 |   |
| ZKsync           |            |                       |                 |           |                 |   |
| Sonic            |            |                       |                 |           |                 |   |
| Celo             |            |                       |                 |           |                 |   |
| Soneium          |            |                       |                 |           |                 |   |

### Repay With Collateral

The ParaSwapRepayAdapter contract enables users to repay their borrow positions on Aave using their supplied collateral directly, without the need to unwind their positions or provide additional liquidity. It leverages Aave's Flash Loans and the ParaSwap DEX aggregator to swap the user's collateral for the borrowed asset and repay the borrow position in a single atomic transaction.

By using this adapter, users can efficiently manage their positions and reduce their borrow positions using their existing collateral, saving on transaction costs and avoiding manual steps.

The source code is available on [GitHub](https://github.com/aave-dao/aave-v3-origin/blob/main/src/contracts/extensions/paraswap-adapters/ParaSwapRepayAdapter.sol).

Reference Integration: [useCollateralRepaySwap.tsx](https://github.com/aave/interface/blob/main/src/hooks/paraswap/useCollateralRepaySwap.tsx)

#### Write Methods

**executeOperation**

```
function executeOperation(    address asset,    uint256 amount,    uint256 premium,    address initiator,    bytes calldata params) external override nonReentrant returns (bool)
```

Uses the received funds from the flash loan to repay a borrow position on the protocol on behalf of the user. Then, pulls the collateral from the user and swaps it to the debt asset to repay the flash loan.

The user should give this contract allowance to pull the aTokens in order to withdraw the underlying asset, swap it, and repay the flash loan.

Supports only one asset on the flash loan.

The params parameter should be the ABI-encoded values of the following:

* IERC20Detailed debtAsset — The address of the borrow position asset
* uint256 debtRepayAmount — The amount of the borrow position to be repaid
* uint256 buyAllBalanceOffset — Offset in the ParaSwap calldata if swapping all balance
* uint256 rateMode — The rate mode of the borrow position to be repaid
* bytes paraswapData — Data for the ParaSwap Adapter
* PermitSignature permitSignature — Struct containing the permit signature, set to zeroes if not used

**Input Parameters:**

| Name      | Type    | Description                                                       |   |
| --------- | ------- | ----------------------------------------------------------------- | - |
| asset     | address | The address of the flash-borrowed asset                           |   |
| amount    | uint256 | The amount of the flash-borrowed asset                            |   |
| premium   | uint256 | The fee of the flash-borrowed asset                               |   |
| initiator | address | The address of the flash loan initiator                           |   |
| params    | bytes   | The byte-encoded parameters passed when initiating the flash loan |   |

**Return Values:**

| Type | Description                                                      |   |
| ---- | ---------------------------------------------------------------- | - |
| bool | True if the execution of the operation succeeds, false otherwise |   |

**swapAndRepay**

```
function swapAndRepay(    IERC20Detailed collateralAsset,    IERC20Detailed debtAsset,    uint256 collateralAmount,    uint256 debtRepayAmount,    uint256 debtRateMode,    uint256 buyAllBalanceOffset,    bytes calldata paraswapData,    PermitSignature calldata permitSignature) external nonReentrant
```

Swaps the user's collateral for the debt asset and then repays the borrow position on the protocol on behalf of the user without using flash loans. This method can be used when the temporary transfer of the collateral asset to this contract does not affect the user's position.

The user should give this contract allowance to pull the aTokens in order to withdraw the underlying asset.

**Input Parameters:**

| Name                | Type            | Description                                                                         |   |
| ------------------- | --------------- | ----------------------------------------------------------------------------------- | - |
| collateralAsset     | IERC20Detailed  | The address of the collateral asset to be swapped                                   |   |
| debtAsset           | IERC20Detailed  | The address of the debt asset                                                       |   |
| collateralAmount    | uint256         | The maximum amount of the collateral to be swapped                                  |   |
| debtRepayAmount     | uint256         | The amount of the borrow position to be repaid, or maximum amount when repaying all |   |
| debtRateMode        | uint256         | The rate mode of the borrow position to be repaid                                   |   |
| buyAllBalanceOffset | uint256         | Offset in the ParaSwap calldata if swapping all balance, otherwise 0                |   |
| paraswapData        | bytes           | Data for the ParaSwap Adapter                                                       |   |
| permitSignature     | PermitSignature | Struct containing the permit signature, set to zeroes if not used                   |   |

**PermitSignature Struct**

```
struct PermitSignature {    uint256 deadline;    uint8 v;    bytes32 r;    bytes32 s;}
```

**Members:**

| Name     | Type    | Description                                     |   |
| -------- | ------- | ----------------------------------------------- | - |
| deadline | uint256 | The deadline timestamp for the permit signature |   |
| v        | uint8   | The V parameter of the ECDSA signature          |   |
| r        | bytes32 | The R parameter of the ECDSA signature          |   |
| s        | bytes32 | The S parameter of the ECDSA signature          |   |

***

### Collateral Swap

The ParaSwapLiquiditySwapAdapter contract allows users to swap their supplied collateral from one asset to another in a single transaction using Aave's Flash Loans and the ParaSwap DEX aggregator.

This adapter enables users to rebalance their collateral positions without needing to withdraw and re-supply assets manually. By leveraging flash loans, the user can swap their existing collateral to a new asset and supply it back into the Aave protocol in a single transaction.

The source code is available on [GitHub](https://github.com/aave-dao/aave-v3-origin/blob/main/src/contracts/extensions/paraswap-adapters/ParaSwapLiquiditySwapAdapter.sol).

Reference Integration: [useCollateralSwap.tsx](https://github.com/aave/interface/blob/main/src/hooks/paraswap/useCollateralSwap.tsx)

#### Write Methods

**executeOperation**

```
function executeOperation(    address asset,    uint256 amount,    uint256 premium,    address initiator,    bytes calldata params) external override nonReentrant returns (bool)
```

Swaps the received amount from the flash loan into the specified asset. The received funds from the swap are then supplied into the protocol on behalf of the user.

The user should give this contract allowance to pull the aTokens in order to withdraw the underlying asset and repay the flash loan.

The params parameter should be the ABI-encoded values of the following:

* IERC20Detailed assetToSwapTo — The address of the underlying asset to be swapped to and supplied
* uint256 minAmountToReceive — The minimum amount to be received from the swap
* uint256 swapAllBalanceOffset — Offset in the Augustus calldata if swapping all balance, otherwise 0
* bytes swapCalldata — Calldata for ParaSwap's Augustus Swapper contract
* IParaSwapAugustus augustus — Address of ParaSwap's Augustus Swapper contract
* PermitSignature permitParams — Struct containing the permit signature, set to zeroes if not used

**Input Parameters:**

| Name      | Type    | Description                                                       |   |
| --------- | ------- | ----------------------------------------------------------------- | - |
| asset     | address | The address of the flash-borrowed asset                           |   |
| amount    | uint256 | The amount of the flash-borrowed asset                            |   |
| premium   | uint256 | The fee of the flash-borrowed asset                               |   |
| initiator | address | The address of the flash loan initiator                           |   |
| params    | bytes   | The byte-encoded parameters passed when initiating the flash loan |   |

**Return Values:**

| Type | Description                                                      |   |
| ---- | ---------------------------------------------------------------- | - |
| bool | True if the execution of the operation succeeds, false otherwise |   |

**swapAndDeposit**

```
function swapAndDeposit(    IERC20Detailed assetToSwapFrom,    IERC20Detailed assetToSwapTo,    uint256 amountToSwap,    uint256 minAmountToReceive,    uint256 swapAllBalanceOffset,    bytes calldata swapCalldata,    IParaSwapAugustus augustus,    PermitSignature calldata permitParams) external nonReentrant
```

Swaps an amount of an asset to another and supplies the new asset amount on behalf of the user without using a flash loan. This method can be used when the temporary transfer of the collateral asset to this contract does not affect the user's position.

The user should give this contract allowance to pull the aTokens in order to withdraw the underlying asset and perform the swap.

**Input Parameters:**

| Name                 | Type              | Description                                                       |   |
| -------------------- | ----------------- | ----------------------------------------------------------------- | - |
| assetToSwapFrom      | IERC20Detailed    | The address of the underlying asset to be swapped from            |   |
| assetToSwapTo        | IERC20Detailed    | The address of the underlying asset to be swapped to and supplied |   |
| amountToSwap         | uint256           | Amount to be swapped, or maximum amount when swapping all balance |   |
| minAmountToReceive   | uint256           | Minimum amount to be received from the swap                       |   |
| swapAllBalanceOffset | uint256           | Offset in Augustus calldata if swapping all balance, otherwise 0  |   |
| swapCalldata         | bytes             | Calldata for ParaSwap's Augustus Swapper contract                 |   |
| augustus             | IParaSwapAugustus | Address of ParaSwap's Augustus Swapper contract                   |   |
| permitParams         | PermitSignature   | Struct containing the permit signature, set to zeroes if not used |   |

***

### Borrow Position Swap

The ParaSwapDebtSwapAdapter contracts allow users to swap their borrow positions from one asset to another. They leverage Aave's Flash Loans and the ParaSwap DEX aggregator to perform the swap in a single atomic transaction.

There are two versions of the adapter:

* **ParaSwapDebtSwapAdapterV3**: The standard version that supports swapping any borrow position asset.
  * Source Code: [GitHub](https://github.com/bgd-labs/aave-debt-swap/blob/main/src/contracts/ParaSwapDebtSwapAdapterV3.sol)
  * Reference Integration: [useDebtSwitch.tsx](https://github.com/aave/interface/blob/main/src/hooks/paraswap/useDebtSwitch.tsx)
* **ParaSwapDebtSwapAdapterV3GHO**: A specialized version that supports GHO, where GHO can be flash minted via the ERC-3156 interface.
  * Source Code: [GitHub](https://github.com/bgd-labs/aave-debt-swap/blob/main/src/contracts/ParaSwapDebtSwapAdapterV3GHO.sol)
  * Reference Integration: [useDebtSwitch.tsx](https://github.com/aave/interface/blob/main/src/hooks/paraswap/useDebtSwitch.tsx)

#### ParaSwapDebtSwapAdapterV3

The ParaSwapDebtSwapAdapterV3 contract allows users to swap their borrow positions from one asset to another, enabling borrow position refinancing on the Aave protocol.

This adapter leverages Aave's Flash Loans and the ParaSwap DEX aggregator to perform the borrow position swap in a single transaction.

**Write Methods**

**executeOperation**

```
function executeOperation(    address[] calldata assets,    uint256[] calldata amounts,    uint256[] calldata,    address initiator,    bytes calldata params) external returns (bool)
```

Performs the borrow position swap operation using the received funds from the flash loan.

Performs the swap and repay operation using the borrowed funds from the flash loan, and then re-borrows the new borrow position asset to maintain the overall borrow position.

The params parameter should be the ABI-encoded values required for the operation, such as:

* The addresses of the borrow position assets involved
* The rate modes of the borrow positions
* ParaSwap swap data
* Any necessary permit signatures

**Input Parameters:**

| Name      | Type       | Description                                                       |   |
| --------- | ---------- | ----------------------------------------------------------------- | - |
| assets    | address\[] | The addresses of the assets being borrowed in the flash loan      |   |
| amounts   | uint256\[] | The amounts of the assets being borrowed                          |   |
| premiums  | uint256\[] | The fees for the flash loans                                      |   |
| initiator | address    | The address of the flash loan initiator                           |   |
| params    | bytes      | Arbitrary data containing the parameters needed for the operation |   |

**Return Values:**

| Type | Description                                                      |   |
| ---- | ---------------------------------------------------------------- | - |
| bool | True if the execution of the operation succeeds, false otherwise |   |

#### ParaSwapDebtSwapAdapterV3GHO

The ParaSwapDebtSwapAdapterV3GHO contract is a specialized version of the borrow position swap adapter that supports GHO, allowing users to swap their borrow positions involving GHO. It utilizes the ERC-3156 flash mint interface for GHO.

Performs the swap and repay operation using the borrowed funds from the flash loan, and then re-borrows the borrow position asset to maintain the overall borrow position.

**Write Methods**

**onFlashLoan**

```
function onFlashLoan(    address initiator,    address token,    uint256 amount,    uint256 fee,    bytes calldata data) external override returns (bytes32)
```

This is the ERC-3156 Flash Loan callback function that gets called when the contract receives a flash loan (in this case, flash mint) from the GHO Flash Minter.

**Input Parameters:**

| Name      | Type    | Description                                                       |   |
| --------- | ------- | ----------------------------------------------------------------- | - |
| initiator | address | The initiator of the flash loan                                   |   |
| token     | address | The address of the token being borrowed                           |   |
| amount    | uint256 | The amount of tokens being borrowed                               |   |
| fee       | uint256 | The fee for the flash loan                                        |   |
| data      | bytes   | Arbitrary data containing the parameters needed for the operation |   |

**Return Values:**

| Type    | Description                                                         |   |
| ------- | ------------------------------------------------------------------- | - |
| bytes32 | The keccak256 hash of the string 'ERC3156FlashBorrower.onFlashLoan' |   |

***

### Withdraw & Swap

The ParaSwapWithdrawSwapAdapter contract allows users to withdraw their supplied assets from Aave and swap them to another asset in a single transaction using the ParaSwap DEX aggregator.

This adapter enables users to efficiently exit positions and swap their assets without having to perform multiple transactions, reducing gas costs and simplifying the user experience.

The source code is available on [GitHub](https://github.com/aave-dao/aave-v3-origin/blob/main/src/contracts/extensions/paraswap-adapters/ParaSwapWithdrawSwapAdapter.sol).

Reference Integration: [WithdrawAndSwitchActions.tsx](https://github.com/aave/interface/blob/main/src/components/transactions/Withdraw/WithdrawAndSwitchActions.tsx)

#### Write Methods

**withdrawAndSwap**

```
function withdrawAndSwap(    IERC20Detailed assetToSwapFrom,    IERC20Detailed assetToSwapTo,    uint256 amountToSwap,    uint256 minAmountToReceive,    uint256 swapAllBalanceOffset,    bytes calldata swapCalldata,    IParaSwapAugustus augustus,    PermitSignature calldata permitParams) external nonReentrant
```

Swaps an amount of an asset to another after a withdrawal and transfers the new asset to the user. The user should give this contract allowance to pull the aTokens in order to withdraw the underlying asset and perform the swap.

**Input Parameters:**

| Name                 | Type              | Description                                                       |   |
| -------------------- | ----------------- | ----------------------------------------------------------------- | - |
| assetToSwapFrom      | IERC20Detailed    | The address of the underlying asset to be swapped from            |   |
| assetToSwapTo        | IERC20Detailed    | The address of the underlying asset to be swapped to              |   |
| amountToSwap         | uint256           | Amount to be swapped, or maximum amount when swapping all balance |   |
| minAmountToReceive   | uint256           | Minimum amount to be received from the swap                       |   |
| swapAllBalanceOffset | uint256           | Offset in Augustus calldata if swapping all balance, otherwise 0  |   |
| swapCalldata         | bytes             | Calldata for ParaSwap's Augustus Swapper contract                 |   |
| augustus             | IParaSwapAugustus | Address of ParaSwap's Augustus Swapper contract                   |   |
| permitParams         | PermitSignature   | Struct containing the permit signature, set to zeroes if not used |   |

**executeOperation**

Note that in this contract, the executeOperation method is overridden but simply reverts with NOT\_SUPPORTED, so it's not intended to be used.


# MCP

Use Tydro's MCP to query live rates, check positions, and execute onchain actions like supply, borrow, repay, and withdraw

### Installation

```
npm install
npm run build
```

### Configuration

```
# Required: network (mainnet only for now)
export TYDRO_NETWORK=mainnet

# Optional: only needed for write operations (supply/borrow/repay/withdraw)
export PRIVATE_KEY=0x...
```

### Usage with Claude Desktop

```
{
  "mcpServers": {
    "tydro": {
      "command": "node",
      "args": ["/path/to/tydro-mcp/build/index.js"],
      "env": {
        "TYDRO_NETWORK": "mainnet",
        "PRIVATE_KEY": "0x..."
      }
    }
  }
}
```

### Tools

#### `get_reserve_data`

Get supply/borrow APYs, liquidity, and utilization for any reserve.

```
{ "asset": "WETH" }
{ "asset": "kBTC" }
{ "asset": "USDT0" }
```

#### `get_user_account`

Get overall health factor, collateral, debt, and borrow capacity.

```
{ "address": "0x..." }
```

#### `get_user_reserve`

Get a user's position for a specific asset (supplied, borrowed, collateral status).

```
{ "asset": "USDT0", "address": "0x..." }
```

#### `supply`

Deposit assets to earn interest. Auto-approves if needed.

```
{ "asset": "USDT0", "amount": "1000" }
{ "asset": "WETH",  "amount": "0.5"  }
```

#### `borrow`

Borrow against collateral. Variable rate only (stable rate deprecated in Aave V3).

```
{ "asset": "USDT0", "amount": "500" }
```

#### `repay`

Repay borrowed assets. Use `"max"` to repay full debt including accrued interest.

```
{ "asset": "USDT0", "amount": "500"  }
{ "asset": "WETH",  "amount": "max"  }
```

#### `withdraw`

Withdraw supplied assets. Use `"max"` to withdraw full aToken balance.

```
{ "asset": "USDT0", "amount": "max" }
```

### Notes

* **Read-only tools** (`get_reserve_data`, `get_user_account`, `get_user_reserve`) work without `PRIVATE_KEY`
* **Write tools** (`supply`, `borrow`, `repay`, `withdraw`) require `PRIVATE_KEY`
* Approvals are checked before sending — no redundant approval transactions
* Max repay/withdraw uses `type(uint256).max` — Aave caps at actual balance/debt
* Health factor warnings trigger below 1.5 (liquidation threshold is 1.0)


# Testing & Debugging

This guide explains how to test and debug Tydro integrations effectively.

### Testing

There are two main ways to test with Tydro:

1. Using a **testnet**
2. Creating **fork networks**

### Testnet

Tydro is available on the Sepolia testnet. You can connect to the Sepolia market through the Tydro app by enabling testnet mode in the top-right corner.

To get started:

1. Open the Sepolia test market in the Tydro app.
2. Use the Faucet tab to claim test tokens available in the market.
3. Supply those tokens into the protocol.
4. Try operations such as borrowing, repaying, and withdrawing to confirm functionality.

#### Fork Networks

A fork network replicates the state of a live chain, letting you test in a controlled sandbox that mirrors mainnet conditions. This is useful for scenarios that depend on deployed contracts or existing liquidity.

Popular tools for forking include:

* Tenderly: transaction simulations, debugging, and dashboards
* Foundry: modular toolkit for smart contract development
* Hardhat: local Ethereum development environment

On a fork, you can fund your account by impersonating an address that holds tokens (findable via block explorers) and transferring assets.

**Connecting a Fork to the UI**

The Tydro app can also connect directly to a forked network. This requires setting specific variables through the browser console. See the integration guide for full instructions.

**Debugging**

When working with Tydro contracts, you may hit errors or failed transactions. This section covers error codes, debugging tools, and common issues.

#### Error Codes

Tydro uses dedicated error codes to explain why a transaction reverted. Each protocol version defines them in its own `Errors.sol` file.

* Tydro V3 Error Codes: `Errors.sol`
* Tydro V2 Error Codes: `Errors.sol`

Understanding these codes is essential for resolving failures.

#### Debugging Tools

* Tenderly: Simulate transactions by providing `to`, `from`, `data`, and `value`. Step through execution, see error codes, and review stack traces.
* Hardhat: Run a local chain, fork mainnet, log from Solidity, and inspect detailed stack traces.
* Foundry: Portable toolkit with `forge` for testing/debugging contracts and simulating transactions.

**Understanding “Gas Estimation Failed”**

This error means the transaction would revert if executed. To debug:

1. Collect the transaction’s `to`, `from`, `data`, and `value`.
2. Simulate the call using Tenderly, Hardhat, or Foundry.
3. Identify the specific error code or exception.
4. Trace the call stack to pinpoint the issue.

### Common Errors

#### Pool Interactions

* Token Approval: Before supplying or repaying, you must approve the Tydro Pool to transfer your ERC-20 tokens. Call `approve()` on the token contract with the Pool as spender.
* Insufficient Collateral: Borrowing requires enough collateral at or above the required Loan-to-Value (LTV). Supply additional assets or check your ratios.
* Borrow Cap Reached: If an asset’s borrow cap is maxed out, no new borrows are possible until positions are repaid or more liquidity is supplied.

#### Loan To Value = 0% (LTV0)

If a reserve’s LTV is set to 0%, the asset behaves differently:

* It does not contribute to borrowing power.
* It cannot be enabled as collateral.
* If received via transfer, it won’t auto-enable as collateral.
* To withdraw other assets, you must first disable LTV0 assets as collateral (via `Pool.setUserUseReserveAsCollateral`) or fully withdraw them.

#### WrappedTokenGateway

When dealing with ETH in Tydro, the WrappedTokenGateway handles wrapping/unwrapping ETH into WETH.\
Common issues include:

* Not sending ETH along with a deposit transaction
* Calling the wrong function for wrapping/unwrapping

Check the WrappedTokenGateway docs for full usage and potential revert cases.


# Running a Liquidator Bot


# Credit Delegation

Credit delegation allows a supplier to contribute liquidity to Tydro to earn interest, and delegate their borrowing power (i.e. their credit) to another address.\
The enforcement of the borrow position and its terms are agreed upon between the supplier (delegator) and the borrower (delegatee), which can happen either off-chain (via legal agreements) or on-chain (via smart contracts).

This enables:

* The delegator to earn extra yield on top of their base lending yield
* The delegatee to access uncollateralized liquidity

Borrowing by a delegatee must be consistent with the delegator’s eMode category. For example, if a delegator is in the STABLECOINS eMode:

* Delegatee can only borrow assets within the STABLECOINS category
* If a delegatee attempts to borrow a non-STABLECOIN asset (e.g. WETH), the transaction will revert

Additionally, the delegatee cannot cause liquidation of the delegator. If a delegated borrow causes the delegator’s Health Factor to drop below the liquidation threshold, the transaction will fail.

### Approving the delegation

The approveDelegation or delegationWithSig function on the [VariableDebtToken](/vii.-developers/developer-overview/smart-contracts/tokenization#variabledebttoken) contract must be called by the supplier (delegator), approving the borrower (delegatee) a certain amount.

This is done for each debt token that needs to be delegated.

The delegator does not need to already have supplied funds in the protocol to approveDelegation. However, **before** the delegatee executes borrow, there must be sufficient collateral supplied by delegator in the protocol.

### Borrowing the credit

The borrower (delegatee) calls the borrow function on the [Pool](/vii.-developers/developer-overview/smart-contracts/pool), using the supplier's (delegator's) address in final parameter onBehalfOf.

The borrower's available credit is reduced by the borrowed amount.

### Repaying the credit

Anyone can repay the borrow position *OnBehalf* of the user, by calling one of the following [Pool](/vii.-developers/developer-overview/smart-contracts/pool) functions - repay or repayWithPermit. The supplier (aka creditor) can also use the repayWithATokens function to repay a borrow position with their *aTokens* of the underlying asset in the same pool.


# Bridge to Ink

Potential options to move assets from other networks to Ink for use in Tydro, Nado, and other Ink protocols.

To use protocols on Ink such as Tydro, users may need to transfer assets to the network. This can be achieved through Kraken's Exchange or with third-party bridges, which are independent protocols that enable assets to move between blockchains. Bridging allows users to bring liquidity securely into Ink while maintaining asset-standard compatibility with Tydro and other applications on Ink.

**As of writing, Ink does not operate a native bridge. All bridging and asset transfer is managed by third-party services that have added support for the Ink network.**

{% hint style="info" %}
Bridging assets carries risks. Options displayed in the Tydro app and documentation may rely on third parties to facilitate order execution. Support for transfers to/from Ink does not constitute an endorsement by the Ink Foundation. Do your own research and select providers accordingly.&#x20;
{% endhint %}

Bridges use different mechanisms to move liquidity. Some rely on liquidity pools and relayers, while others use lock and mint or burn and redeem models. Each approach carries its own trade-offs in terms of speed, cost, security, and trust assumptions. Users should select providers that best match their needs.

**Here are some of the ways you can bridge assets into Ink:**

* CCIP
* CCTP
* LayerZero OFT bridging
* Officiail Asset briedged (Ethena, USDT0, etc)

#### Bungee Exchange <a href="#bungee-exchange" id="bungee-exchange"></a>

Bungee is an aggregator of multiple bridges, providing a simple and unified interface for transferring assets to INK. It automatically routes your transfer through the most efficient bridge, minimizing cost and time.

Best For: Users who want to bridge quickly and cheaply without manually selecting routes or understanding underlying protocols.

Bridge to INK: [Bungee Bridge](https://www.bungee.exchange/?fromChainId=10\&fromTokenAddress=0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee\&toChainId=57073\&toTokenAddress=0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee)​

#### Superbridge <a href="#superbridge" id="superbridge"></a>

Superbridge focuses on simplicity and user experience, offering a streamlined interface for bridging ETH and other assets to INK. It abstracts the technical details while maintaining reliability and minimal slippage.

Best For: Users bridging ETH or native assets who want a clean UX and little slippage.

Bridge to INK: [Superbridge](https://superbridge.app/optimism)​

#### USDT0 Native Transfer <a href="#usdt0-native-transfer" id="usdt0-native-transfer"></a>

USDT0 is a native stablecoin transfer mechanism designed for direct movement of USDT between supported Superchain networks and INK. It eliminates traditional bridging complexity by using canonical token contracts on each network, ensuring instant settlement and no wrapping or synthetic assets.

Best For: Users who want to bridge stablecoins such as USDT or USDT0 into INK quickly, securely, and without conversion risk.

Bridge to INK: [USDT0 Site](https://usdt0.to/transfer?source=ethereum\&destination=ink)​

#### Eco Bridge <a href="#eco-bridge" id="eco-bridge"></a>

Eco focuses on simplicity and user experience. It provides a straightforward interface for moving assets into Ink without exposing much of the underlying complexity.

Eco is often the best choice for users who want to bridge stablecoins only.

Bridge to INK: [Eco Portal](https://portal.eco.com/)​

#### Across <a href="#across" id="across"></a>

Across is optimised for speed and low cost, particularly when transferring from Ethereum mainnet and Layer 2 networks. It relies on a relayer network that fronts liquidity to deliver funds quickly, with settlement finalised on the source chain later.

Across is well-suited for users who want fast transfers from rollups with minimal fees

Bridge to INK: [Across Bridge ](https://app.across.to/bridge?)

#### Aave (GHO Bridge) <a href="#eco-bridge" id="eco-bridge"></a>

Aave is a leading DeFi protocol for lending and borrowing crypto assets. It also launched GHO, a decentralized stablecoin that users can mint by supplying collateral. GHO is available across multiple networks and supports native bridging via Aave’s cross-chain system.

Best For: Purchasing or minting GHO and bridging it from Ethereum, Base, or Arbitrum to INK.

Supported Assets: GHO

Bridge to INK: [Aave Markets](https://app.aave.com/markets/)

## **Bridge Comparison Table**

| **Bridge**      | **Best For**                                                              | **Supported Assets**  | **Approx. Fee**              | **Link**                                                                                          |
| --------------- | ------------------------------------------------------------------------- | --------------------- | ---------------------------- | ------------------------------------------------------------------------------------------------- |
| **Bungee**      | Cheapest, fastest option across multiple bridges                          | ETH, USDT0, USDC, GHO | Varies (auto-routed)         | [Bungee Bridge](https://www.notion.so/Updated-Bridge-Doc-29759f6be93380b19c2cc71e83bfe0dc?pvs=21) |
| **Superbridge** | Bridging ETH from Ethereum mainnet with zero fees                         | ETH, others           | ETH: **Free**; Others: 0.05% | [Superbridge](https://www.notion.so/Updated-Bridge-Doc-29759f6be93380b19c2cc71e83bfe0dc?pvs=21)   |
| **USDT0**       | Simple & safe USDT bridging with no wrapping                              | USDT / USDT0          | \~**0.1**                    | [USDT0 Site](https://usdt0.to/transfer?source=ethereum\&destination=ink)                          |
| **Across**      | Fast ETH transfers from Layer 2s                                          | ETH                   | Varies by network            | [Across Bridge](https://www.notion.so/Updated-Bridge-Doc-29759f6be93380b19c2cc71e83bfe0dc?pvs=21) |
| **Aave**        | \*\*Aave (GHO)\*\*Purchasing or minting **GHO** and bridging it to INKGHO | GHO                   | Varies by network            | [Aave Markets](https://app.aave.com/markets/)                                                     |

#### **Tip: A Simple Way to Get Started**

One of the smoothest ways to get major assets into Ink and start using Tydro is:

1. Bridge USDT to INK using [USDT0](https://usdt0.to/transfer?source=ethereum\&destination=ink)
2. Then, swap USDT0 for other tokens on [Velodrome (DEX)](https://velodrome.finance/swap)

This route minimizes steps and lets you access key assets on Ink with less friction.


# Code Licensing

Tydro, a fork of the Aave Protocol operates on decentralized blockchain networks, with smart contracts that are self-executing and publicly auditable. These smart contracts and peripheral interfaces are licensed to define and regulate the use of the underlying code. The code exists across multiple GitHub repositories, and below are examples of some key licenses that apply to different Aave components:

* **Aave v3.3 Smart Contracts**: Business Source License 1.1 permits non-commercial use and modification, restricting competitive use for four years, with a transition to the MIT License on March 6, 2027​. ([GitHub](https://github.com/aave-dao/aave-v3-origin/blob/main/LICENSE))
* **Aave v3.2 Smart Contracts**: Business Source License 1.1 permits non-commercial use and modification, restricting competitive use for four years, with a transition to the MIT License on March 6, 2027​. ([GitHub](https://github.com/aave-dao/aave-v3-origin/blob/main/LICENSE))
* **GHO Stablecoin**: MIT License grants free and unrestricted rights to use, copy, modify, and distribute the software, provided the original copyright notice and license are included. The software is provided "as is," with no warranties or liabilities for any issues arising from its use. ([GitHub](https://github.com/aave/gho-core/blob/main/LICENSE))
* **Aave v2 Smart Contracts**: GNU Affero General Public License ([GitHub](https://github.com/aave/protocol-v2/blob/master/LICENSE.md))
* **Aave v1 Smart Contracts**: GNU Affero General Public License ([GitHub](https://github.com/aave/aave-protocol/blob/master/LICENSE.md))
* **Aave Labs Interface**: All Rights Reserved. ([GitHub](https://github.com/aave/interface/blob/main/LICENSE.md))


# Tydro Vaults

Tydro Vaults are ERC-4626 compliant yield-bearing vaults that allow users to supply and withdraw ERC-20 tokens supported by Aave V3. Vaults manage the supply and withdrawal of assets in the Aave Protocol while enabling vault managers to take a fee on the yield earned.

To deploy a vault, clone and deploy from the [Aave Vault contract repository](https://github.com/aave/aave-vault/).

### Aave ERC-4626 Vaults

#### Overview

Aave Vaults follow the [ERC-4626 Tokenized Vault Standard](https://eips.ethereum.org/EIPS/eip-4626), which standardizes the interface for yield-bearing vaults. This standard simplifies integration with various applications and aggregators while improving interoperability across the DeFi ecosystem.

Each vault allows depositors to:

* Deposit supported tokens (assets) and receive vault shares in return
* Redeem vault shares for the underlying assets plus accrued yield
* Automatically earn yield from Aave V3 markets without direct interaction with the protocol

#### Architecture

Aave Vaults consist of three key components:

1. **ERC-4626 Interface**: Standardized methods for deposit, withdrawal, and accounting of assets.
2. **Yield Strategy**: Manages deposits into Aave V3 markets and handles yield accrual.
3. **Fee Management**: Enables vault managers to collect a percentage of the yield generated.

When a user deposits an asset into a vault:

* The vault mints proportional vault shares (ERC-20 tokens) to the user
* The vault deposits the underlying assets into the corresponding Aave V3 market
* The vault receives aTokens from Aave, which automatically accrue yield
* Yield is reflected in the increasing value of vault shares over time

#### Fee Structure

Vault managers can set a fee percentage on the yield generated by the vault. This fee structure includes:

* **Performance Fee**: A percentage of the yield earned that goes to the vault manager
* **Max Fee**: A maximum limit on the performance fee that can be charged
* **Fee Recipient**: The address that receives the collected fees

Fees are collected when yield is realized through:

* User withdrawals or redemptions
* Explicit fee collection by the vault manager

The fee is only applied to the yield portion of the assets and not to the principal amount deposited by users.

#### Interacting with Vaults

Vaults implement the standard ERC-4626 interface with methods such as:

* deposit(uint256 assets, address receiver): Deposit assets and receive vault shares
* withdraw(uint256 assets, address receiver, address owner): Withdraw assets by burning vault shares
* mint(uint256 shares, address receiver): Mint exact amount of shares by depositing assets
* redeem(uint256 shares, address receiver, address owner): Redeem shares for underlying assets

Additionally, vaults provide view functions to check:

* totalAssets(): Total assets managed by the vault
* convertToShares(uint256 assets): Convert asset amount to vault shares
* convertToAssets(uint256 shares): Convert vault shares to asset amount
* previewDeposit(uint256 assets): Preview shares received for a deposit
* previewWithdraw(uint256 assets): Preview shares needed for a withdrawal

For a detailed contract reference, see [here](https://aave.com/docs/smart-contracts/vaults).

#### Benefits for Users

* **Simplified Yield**: Earn yield from Aave V3 without managing multiple transactions
* **Gas Efficiency**: Lower gas costs compared to direct protocol interactions
* **Standard Interface**: Easier integration with other DeFi protocols and applications
* **Composability**: Vault shares can be used in other DeFi applications

#### Benefits for Vault Managers

* **Yield Capture**: Earn fees on yield generated by user deposits
* **Customization**: Configure fee parameters to suit different strategies
* **Standardization**: Leverage the ERC-4626 standard for broader integration


# Umbrella

Aave Umbrella is a modular, onchain risk management system that automates bad debt coverage for Aave v3 pools. It enables users to stake wrapped aTokens or GHO, and earn protocol rewards.

### System Overview

Umbrella is built from three main contract types:

* **UmbrellaCore:** Orchestrates deficit monitoring, slashing, and asset coverage for each Aave v3 pool.
* **StakeToken:** ERC4626 Vault per asset and network that handles staking, cooldown, slashing, and integrates with the rewards controller.
* **RewardsController:** Manages multi-token rewards, emission curves, and user reward accounting.
* **UmbrellaBatchHelper**: Periphery contract enabling multiple actions to be batched into a single transaction.

### Staking

To participate, users deposit supported assets (wrapped aTokens or GHO) into the appropriate StakeToken contract. This action mints shares representing their position. The StakeToken uses an exchange rate that starts at 1:1 and only decreases if slashing occurs.

Staking can be performed with a standard ERC20 approve and deposit, or with EIP-2612 permit signature using depositWithPermit. Users may also set a cooldown operator to manage their cooldowns.

```
IERC20 underlying = IERC20(stakeToken.asset());underlying.approve(address(stakeToken), amount);stakeToken.deposit(amount, msg.sender);
```

### Unstaking

To withdraw, users must first activate a cooldown by calling cooldown(). The cooldown period is 20 days (configurable by governance), followed by a 2-day unstake window. During cooldown, rewards continue to accrue and funds remain slashable. Only one cooldown record is allowed per user at a time. If a user transfers shares after activating cooldown, the amount available for withdrawal is reduced. Depositing more after cooldown does not affect the cooldowned amount.

After the cooldown period, users can withdraw within the unstake window using redeem or withdraw. If the window is missed, the cooldown must be restarted. Withdrawals are always subject to the current exchange rate, which may have changed due to slashing.

```
stakeToken.cooldown();// ...wait for cooldown period...stakeToken.redeem(shares, msg.sender, msg.sender);
```

### Slashing

Slashing is triggered automatically by UmbrellaCore when a deficit in the corresponding Aave pool exceeds the configured offset. Slashing reduces total assets in the StakeToken, lowering the value of all shares. The contract enforces a minimum assets floor to prevent full depletion. Only UmbrellaCore (the owner) can call slash, and slashed assets are sent to the Aave Collector for deficit coverage.

```
function slash(uint256 amount) external onlyOwner;
```

### Rewards

Rewards are managed by the RewardsController, which supports up to 8 reward tokens per StakeToken. Emission rates are governed by a piecewise linear curve, targeting optimal liquidity. Below the target liquidity, rewards are boosted to attract stakers; at target, emission is maximized; above target, emission tapers off to discourage over-staking. Governance sets up new assets and rewards, while a Rewards Admin can adjust emission rates and distribution end times.

Users can claim all available rewards for their assets at any time, or authorize a claimer to do so on their behalf.

```
rewardsController.claimAllRewards([address(stakeToken)], msg.sender);
```

To claim a specific reward:

```
rewardsController.claimRewards(    [address(stakeToken)],    amount,    msg.sender,    rewardToken);
```

To set a claimer:

```
rewardsController.setClaimer(user, claimer);
```

### Deployed Contracts

| Name                                                | Address                                                                                                               |   |
| --------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------- | - |
| **UMBRELLA**                                        | [0xD400fc38ED4732893174325693a63C30ee3881a8](https://etherscan.io/address/0xD400fc38ED4732893174325693a63C30ee3881a8) |   |
| **UMBRELLA\_IMPL**                                  | [0x929e21D24D3f2A529621AdC248D227012B72646d](https://etherscan.io/address/0x929e21D24D3f2A529621AdC248D227012B72646d) |   |
| **UMBRELLA\_STAKE\_TOKEN\_IMPL**                    | [0x75e8aC0c063B6966E2A9954adEdf39BdE9370197](https://etherscan.io/address/0x75e8aC0c063B6966E2A9954adEdf39BdE9370197) |   |
| **UMBRELLA\_REWARDS\_CONTROLLER**                   | [0x4655Ce3D625a63d30bA704087E52B4C31E38188B](https://etherscan.io/address/0x4655Ce3D625a63d30bA704087E52B4C31E38188B) |   |
| **UMBRELLA\_REWARDS\_CONTROLLER\_IMPL**             | [0x85C3371044e49782DbE3dC23de1D77a078aFb5d0](https://etherscan.io/address/0x85C3371044e49782DbE3dC23de1D77a078aFb5d0) |   |
| **PERMISSIONED\_PAYLOADS\_CONTROLLER**              | [0xF86F77F7531B3374274E3f725E0A81D60bC4bB67](https://etherscan.io/address/0xF86F77F7531B3374274E3f725E0A81D60bC4bB67) |   |
| **PERMISSIONED\_PAYLOADS\_CONTROLLER\_EXECUTOR**    | [0x2759de67aD133C747C9f41d56F1b8A343cE679a1](https://etherscan.io/address/0x2759de67aD133C747C9f41d56F1b8A343cE679a1) |   |
| **UMBRELLA\_BATCH\_HELPER**                         | [0xCe6Ced23118EDEb23054E06118a702797b13fc2F](https://etherscan.io/address/0xCe6Ced23118EDEb23054E06118a702797b13fc2F) |   |
| **UMBRELLA\_CONFIG\_ENGINE**                        | [0x3f3EfAeba02bbA78BA7E89Dc6Ec503C8fe5fd5a4](https://etherscan.io/address/0x3f3EfAeba02bbA78BA7E89Dc6Ec503C8fe5fd5a4) |   |
| **DATA\_AGGREGATION\_HELPER**                       | [0xcc8FD820B1b9C5EBACA8615927f2fFc1f74B9dB3](https://etherscan.io/address/0xcc8FD820B1b9C5EBACA8615927f2fFc1f74B9dB3) |   |
| **DEFICIT\_OFFSET\_CLINIC\_STEWARD**                | [0x6c1DC85f2aE71C3DAcd6E44Bb57DEeF61b540a5A](https://etherscan.io/address/0x6c1DC85f2aE71C3DAcd6E44Bb57DEeF61b540a5A) |   |
| **AAVE**                                            | [0x7Fc66500c84A76Ad7e9c93437bFc5Ac33E2DDaE9](https://etherscan.io/address/0x7Fc66500c84A76Ad7e9c93437bFc5Ac33E2DDaE9) |   |
| **AAVE\_ORACLE**                                    | [0x547a514d5e3769680Ce22B2361c10Ea13619e8a9](https://etherscan.io/address/0x547a514d5e3769680Ce22B2361c10Ea13619e8a9) |   |
| **STK\_AAVE**                                       | [0x4da27a545c0c5B758a6BA100e3a049001de870f5](https://etherscan.io/address/0x4da27a545c0c5B758a6BA100e3a049001de870f5) |   |
| **GHO**                                             | [0x40D16FC0246aD3160Ccc09B8D0D3A2cD28aE6C2f](https://etherscan.io/address/0x40D16FC0246aD3160Ccc09B8D0D3A2cD28aE6C2f) |   |
| **GHO\_ORACLE**                                     | [0x3f12643d3f6f874d39c2a4c9f2cd6f2dbac877fc](https://etherscan.io/address/0x3f12643d3f6f874d39c2a4c9f2cd6f2dbac877fc) |   |
| **STK\_GHO**                                        | [0x1a88Df1cFe15Af22B3c4c783D4e6F7F9e0C1885d](https://etherscan.io/address/0x1a88Df1cFe15Af22B3c4c783D4e6F7F9e0C1885d) |   |
| **STK\_AAVE\_WSTETH\_BALANCER\_POOL\_V2**           | [0x9eDA81C21C273a82BE9Bbc19B6A6182212068101](https://etherscan.io/address/0x9eDA81C21C273a82BE9Bbc19B6A6182212068101) |   |
| **STK\_AAVE\_WSTETH\_BALANCER\_POOL\_V2\_ORACLE**   | [0xADf86b537eF08591c2777E144322E8b0Ca7E82a7](https://etherscan.io/address/0xADf86b537eF08591c2777E144322E8b0Ca7E82a7) |   |
| **STK\_AAVE\_WSTETH\_BALANCER\_POOL\_V2\_MIGRATOR** | [0xecD4bd3121F9FD604ffaC631bF6d41ec12f1fafb](https://etherscan.io/address/0xecD4bd3121F9FD604ffaC631bF6d41ec12f1fafb) |   |
| **STK\_AAVE\_ETH\_BALANCER\_POOL\_V1** (deprecated) | [0xa1116930326D21fB917d5A27F1E9943A9595fb47](https://etherscan.io/address/0xa1116930326D21fB917d5A27F1E9943A9595fb47) |   |
| **STK\_AAVE\_ETH\_BALANCER\_POOL\_V1** (deprecated) | [0x209Ad99bd808221293d03827B86cC544bcA0023b](https://etherscan.io/address/0x209Ad99bd808221293d03827B86cC544bcA0023b) |   |

### Resources

* [Smart Contracts](https://github.com/aave-dao/aave-umbrella)
* [Frontend Implemenation](https://github.com/aave-dao/aave-umbrella-ui)

\ <br>


