IAaveV3Pool
Title: IAaveV3Pool
Author: Vendored minimal subset of Aave v3 (https://github.com/aave/aave-v3-core/blob/master/contracts/interfaces/IPool.sol).
Upstream license: AGPL-3.0.
Minimal vendored subset of the Aave v3 Pool used by the Lattice Aave adapter: supply/withdraw (supply leg), borrow/repay/setUserEMode (leverage leg), plus the account-data and reserve-data reads needed for health and aToken resolution, and the v3.1+ virtual-balance read that caps a recall at the reserve's available cash.
Version-pinned to Aave v3.x. Only the selectors the adapter calls are declared.
Functions
supply
Supplies amount of asset into the protocol, minting aTokens to onBehalfOf.
function supply(address asset, uint256 amount, address onBehalfOf, uint16 referralCode) external;Parameters
| Name | Type | Description |
|---|---|---|
| asset | address | The underlying asset to supply. |
| amount | uint256 | The amount to supply. |
| onBehalfOf | address | The address that receives the aTokens (the adapter). |
| referralCode | uint16 | Unused by integrators; pass 0. |
withdraw
Withdraws amount of asset (or the full balance with type(uint256).max) to to.
function withdraw(address asset, uint256 amount, address to) external returns (uint256 withdrawn);Parameters
| Name | Type | Description |
|---|---|---|
| asset | address | |
| amount | uint256 | |
| to | address |
Returns
| Name | Type | Description |
|---|---|---|
| withdrawn | uint256 | The final amount withdrawn. |
borrow
Borrows amount of asset against the caller's collateral.
function borrow(address asset, uint256 amount, uint256 interestRateMode, uint16 referralCode, address onBehalfOf)
external;Parameters
| Name | Type | Description |
|---|---|---|
| asset | address | |
| amount | uint256 | |
| interestRateMode | uint256 | 2 = variable (1 = stable, deprecated on most markets). |
| referralCode | uint16 | |
| onBehalfOf | address |
repay
Repays amount of borrowed asset (type(uint256).max repays the full debt).
function repay(address asset, uint256 amount, uint256 interestRateMode, address onBehalfOf)
external
returns (uint256 repaid);Parameters
| Name | Type | Description |
|---|---|---|
| asset | address | |
| amount | uint256 | |
| interestRateMode | uint256 | |
| onBehalfOf | address |
Returns
| Name | Type | Description |
|---|---|---|
| repaid | uint256 | The final amount repaid. |
setUserEMode
Sets the caller's eMode category (e.g. correlated-asset high-LTV looping).
function setUserEMode(uint8 categoryId) external;Parameters
| Name | Type | Description |
|---|---|---|
| categoryId | uint8 |
getUserEMode
Returns the caller's eMode category id.
function getUserEMode(address user) external view returns (uint256);Parameters
| Name | Type | Description |
|---|---|---|
| user | address |
Returns
| Name | Type | Description |
|---|---|---|
| <none> | uint256 |
getUserAccountData
Returns aggregate account data, all base-currency amounts in 8 decimals.
function getUserAccountData(address user)
external
view
returns (
uint256 totalCollateralBase,
uint256 totalDebtBase,
uint256 availableBorrowsBase,
uint256 currentLiquidationThreshold,
uint256 ltv,
uint256 healthFactor
);Parameters
| Name | Type | Description |
|---|---|---|
| user | address |
Returns
| Name | Type | Description |
|---|---|---|
| totalCollateralBase | uint256 | Total collateral (base ccy, 8 decimals). |
| totalDebtBase | uint256 | Total debt (base ccy, 8 decimals). |
| availableBorrowsBase | uint256 | Remaining borrow capacity (base ccy). |
| currentLiquidationThreshold | uint256 | Weighted liquidation threshold (bps). |
| ltv | uint256 | Weighted loan-to-value (bps). |
| healthFactor | uint256 | Position health factor (WAD, 1e18 == 1.0). |
getReserveData
Returns the reserve data for asset (used to resolve the aToken address).
function getReserveData(address asset) external view returns (ReserveData memory);Parameters
| Name | Type | Description |
|---|---|---|
| asset | address |
Returns
| Name | Type | Description |
|---|---|---|
| <none> | ReserveData |
getVirtualUnderlyingBalance
Returns the reserve's virtual underlying balance: the cash the Pool lets suppliers withdraw and borrowers take. Unlike the aToken's raw underlying balance, it ignores direct transfers to the aToken.
Aave v3.1+ only (https://github.com/aave-dao/aave-v3-origin/blob/main/src/contracts/interfaces/IPool.sol). A v3.0 Pool has no such function, so callers must tolerate the call reverting.
function getVirtualUnderlyingBalance(address asset) external view returns (uint128);Parameters
| Name | Type | Description |
|---|---|---|
| asset | address |
Returns
| Name | Type | Description |
|---|---|---|
| <none> | uint128 |
Structs
ReserveData
Aave v3 reserve configuration + token addresses (subset we read).
The full struct is large; we only consume aTokenAddress. Field order MUST match
the on-chain struct so ABI decoding lines up.
struct ReserveData {
ReserveConfigurationMap configuration;
uint128 liquidityIndex;
uint128 currentLiquidityRate;
uint128 variableBorrowIndex;
uint128 currentVariableBorrowRate;
uint128 currentStableBorrowRate;
uint40 lastUpdateTimestamp;
uint16 id;
address aTokenAddress;
address stableDebtTokenAddress;
address variableDebtTokenAddress;
address interestRateStrategyAddress;
uint128 accruedToTreasury;
uint128 unbacked;
uint128 isolationModeTotalDebt;
}Properties
| Name | Type | Description |
|---|---|---|
| configuration | ReserveConfigurationMap | |
| liquidityIndex | uint128 | |
| currentLiquidityRate | uint128 | |
| variableBorrowIndex | uint128 | |
| currentVariableBorrowRate | uint128 | |
| currentStableBorrowRate | uint128 | |
| lastUpdateTimestamp | uint40 | |
| id | uint16 | |
| aTokenAddress | address | |
| stableDebtTokenAddress | address | |
| variableDebtTokenAddress | address | |
| interestRateStrategyAddress | address | |
| accruedToTreasury | uint128 | |
| unbacked | uint128 | |
| isolationModeTotalDebt | uint128 |
ReserveConfigurationMap
struct ReserveConfigurationMap {
uint256 data;
}Properties
| Name | Type | Description |
|---|---|---|
| data | uint256 |