Lending Aave EVM API Reference
API Reference for @tetherto/wdk-protocol-lending-aave-evm
API Reference
Class: AaveProtocolEvm
Main class for Aave V3 lending on EVM.
Constructor
new AaveProtocolEvm(account)Parameters:
account:IWalletAccount | IWalletAccountReadOnlyfrom@tetherto/wdk-wallet
Since beta.7, write methods check for a callable sendTransaction() rather than a concrete account class. The implementation still reads account._config.provider; supply an EVM-compatible JSON-RPC URL or EIP-1193 provider for a supported Aave deployment. Shared interfaces alone do not make another chain's account compatible. The selected operation also needs its account methods, such as getAddress(), getTokenBalance(), and quoteSendTransaction().
Before supplying or repaying, grant the Aave Pool enough token allowance through the account's approval API and wait for approval confirmation. The lending module does not approve or reset allowances automatically. Use the Pool and token addresses for the same chain. The examples below use 1 USD₮ on Ethereum, whose contract is 0xdAC17F958D2ee523a2206206994597C13D831ec7 with 6 decimals.
Example:
const USDT = '0xdAC17F958D2ee523a2206206994597C13D831ec7'
const aave = new AaveProtocolEvm(account)Methods
| Method | Description | Returns |
|---|---|---|
supply(options, config?) | Add tokens to the pool | Promise<{hash: string, fee: bigint}> |
quoteSupply(options, config?) | Estimate cost to add tokens | Promise<{fee: bigint}> |
withdraw(options, config?) | Remove tokens from the pool | Promise<{hash: string, fee: bigint}> |
quoteWithdraw(options, config?) | Estimate cost to withdraw | Promise<{fee: bigint}> |
borrow(options, config?) | Borrow tokens | Promise<{hash: string, fee: bigint}> |
quoteBorrow(options, config?) | Estimate borrowing cost | Promise<{fee: bigint}> |
repay(options, config?) | Repay borrowed tokens | Promise<{hash: string, fee: bigint}> |
quoteRepay(options, config?) | Estimate repayment cost | Promise<{fee: bigint}> |
setUseReserveAsCollateral(token, use, config?) | Toggle token as collateral | Promise<{hash: string, fee: bigint}> |
setUserEMode(categoryId, config?) | Set user eMode | Promise<{hash: string, fee: bigint}> |
getAccountData(account?) | Read account stats | Promise<{ totalCollateralBase: bigint, totalDebtBase: bigint, availableBorrowsBase: bigint, currentLiquidationThreshold: bigint, ltv: bigint, healthFactor: bigint }> |
Mutating methods and quote helpers accept an optional config argument and forward it to the account's send or quote method. The account determines which fields it supports.
Compatible ERC-4337 accounts use the gas-payment overrides documented in @tetherto/wdk-wallet-evm-erc-4337: paymaster token, sponsorship policy, and native coins. Standard WDK EVM accounts ignore these fields; compatible wrappers determine their own handling. Fees retain the account's denomination, which can be native wei, paymaster-token base units, or zero for sponsorship.
supply(options, config?)
Add tokens to the pool.
Options:
token(string): token addressamount(number | bigint): amount in base unitsonBehalfOf(string, optional)
Returns:
- The account's transaction result, including
hashandfee. The protocol does not add approval transaction hashes.
Example:
const res = await aave.supply({ token: USDT, amount: 1000000n })quoteSupply(options, config?)
Estimate fee to add tokens.
const q = await aave.quoteSupply({ token: USDT, amount: 1000000n })withdraw(options, config?)
Remove tokens from the pool.
Options:
token(string)amount(number | bigint)to(string, optional)
const tx = await aave.withdraw({ token: USDT, amount: 1000000n })quoteWithdraw(options, config?)
Estimate fee to withdraw tokens.
const q = await aave.quoteWithdraw({ token: USDT, amount: 1000000n })borrow(options, config?)
Borrow tokens.
Options:
token(string)amount(number | bigint)onBehalfOf(string, optional)
const tx = await aave.borrow({ token: USDT, amount: 1000000n })quoteBorrow(options, config?)
Estimate fee to borrow tokens.
const q = await aave.quoteBorrow({ token: USDT, amount: 1000000n })repay(options, config?)
Repay borrowed tokens.
Options:
token(string)amount(number | bigint)onBehalfOf(string, optional)
const tx = await aave.repay({ token: USDT, amount: 1000000n })Returns:
- The account's transaction result, including
hashandfee. Required approvals are separate operations.
quoteRepay(options, config?)
Estimate fee to repay borrowed tokens.
const q = await aave.quoteRepay({ token: USDT, amount: 1000000n })setUseReserveAsCollateral(token, use, config?)
Toggle token as collateral for the user.
const tx = await aave.setUseReserveAsCollateral(USDT, true)setUserEMode(categoryId, config?)
Set user eMode category.
const tx = await aave.setUserEMode(1)getAccountData(account?)
Read account stats like total collateral, debt, and health.
const data = await aave.getAccountData()Returns the following structure:
{
totalCollateralBase: bigint,
totalDebtBase: bigint,
availableBorrowsBase: bigint,
currentLiquidationThreshold: bigint,
ltv: bigint,
healthFactor: bigint
}ERC‑4337 Config Override (optional)
Mutating methods and quote helpers forward the optional config argument to the account. For compatible ERC-4337 accounts, the following fields control per-call gas payment.
- Paymaster token mode:
paymasterUrl,paymasterAddress,paymasterToken,transferMaxFee - Sponsorship policy mode:
isSponsored,paymasterUrl,sponsorshipPolicyId - Native coin mode:
useNativeCoins,transferMaxFee
Example:
const res = await aave.supply(
{ token: '0xdAC17F958D2ee523a2206206994597C13D831ec7', amount: 1000000n },
{
paymasterToken: {
address: '0xdAC17F958D2ee523a2206206994597C13D831ec7'
}
}
)Rules & Notes
tokenmust be a valid (non‑zero) addressamount> 0 and in token base units (use BigInt)onBehalfOf/to(if set) must be valid, non‑zero addresses- A provider is required to read/send transactions
- For USD₮ on mainnet, allowance may be reset to 0 then set again before actions
Node.js Quickstart
Get started with WDK in a Node.js environment
WDK Lending Aave EVM Protocol Configuration
Get started with WDK's Lending Aave EVM Protocol configuration
WDK Lending Aave EVM Protocol Usage
Get started with WDK's Lending Aave EVM Protocol usage