Skip to content
Lattice

IAaveV3Pool

Git Source

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

NameTypeDescription
assetaddressThe underlying asset to supply.
amountuint256The amount to supply.
onBehalfOfaddressThe address that receives the aTokens (the adapter).
referralCodeuint16Unused 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

NameTypeDescription
assetaddress
amountuint256
toaddress

Returns

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

NameTypeDescription
assetaddress
amountuint256
interestRateModeuint2562 = variable (1 = stable, deprecated on most markets).
referralCodeuint16
onBehalfOfaddress

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

NameTypeDescription
assetaddress
amountuint256
interestRateModeuint256
onBehalfOfaddress

Returns

NameTypeDescription
repaiduint256The final amount repaid.

setUserEMode

Sets the caller's eMode category (e.g. correlated-asset high-LTV looping).

function setUserEMode(uint8 categoryId) external;

Parameters

NameTypeDescription
categoryIduint8

getUserEMode

Returns the caller's eMode category id.

function getUserEMode(address user) external view returns (uint256);

Parameters

NameTypeDescription
useraddress

Returns

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

NameTypeDescription
useraddress

Returns

NameTypeDescription
totalCollateralBaseuint256Total collateral (base ccy, 8 decimals).
totalDebtBaseuint256Total debt (base ccy, 8 decimals).
availableBorrowsBaseuint256Remaining borrow capacity (base ccy).
currentLiquidationThresholduint256Weighted liquidation threshold (bps).
ltvuint256Weighted loan-to-value (bps).
healthFactoruint256Position 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

NameTypeDescription
assetaddress

Returns

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

NameTypeDescription
assetaddress

Returns

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

NameTypeDescription
configurationReserveConfigurationMap
liquidityIndexuint128
currentLiquidityRateuint128
variableBorrowIndexuint128
currentVariableBorrowRateuint128
currentStableBorrowRateuint128
lastUpdateTimestampuint40
iduint16
aTokenAddressaddress
stableDebtTokenAddressaddress
variableDebtTokenAddressaddress
interestRateStrategyAddressaddress
accruedToTreasuryuint128
unbackeduint128
isolationModeTotalDebtuint128

ReserveConfigurationMap

struct ReserveConfigurationMap {
        uint256 data;
    }

Properties

NameTypeDescription
datauint256