WDK logoWDK documentation

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: WalletAccountEvm | WalletAccountReadOnlyEvm | WalletAccountEvmErc4337 | WalletAccountReadOnlyEvmErc4337

Example:

const aave = new AaveProtocolEvm(account)

Methods

MethodDescriptionReturns
supply(options, config?)Add tokens to the poolPromise\<{hash: string, fee: bigint, approveHash?: string, resetAllowanceHash?: string}\>
quoteSupply(options, config?)Estimate cost to add tokensPromise\<{fee: bigint}\>
withdraw(options, config?)Remove tokens from the poolPromise\<{hash: string, fee: bigint}\>
quoteWithdraw(options, config?)Estimate cost to withdrawPromise\<{fee: bigint}\>
borrow(options, config?)Borrow tokensPromise\<{hash: string, fee: bigint}\>
quoteBorrow(options, config?)Estimate borrowing costPromise\<{fee: bigint}\>
repay(options, config?)Repay borrowed tokensPromise\<{hash: string, fee: bigint}\>
quoteRepay(options, config?)Estimate repayment costPromise\<{fee: bigint}\>
setUseReserveAsCollateral(token, use, config?)Toggle token as collateralPromise\<{hash: string, fee: bigint}\>
setUserEMode(categoryId, config?)Set user eModePromise\<{hash: string, fee: bigint}\>
getAccountData(account?)Read account statsPromise\<{ totalCollateralBase: bigint, totalDebtBase: bigint, availableBorrowsBase: bigint, currentLiquidationThreshold: bigint, ltv: bigint, healthFactor: bigint }\>

When AaveProtocolEvm is initialized with an ERC‑4337 smart account, the optional config argument on mutating and quote methods accepts the same gas-payment override families documented in @tetherto/wdk-wallet-evm-erc-4337: paymaster token, sponsorship policy, and native coins.

supply(options, config?)

Add tokens to the pool.

Options:

  • token (string): token address
  • amount (number | bigint): amount in base units
  • onBehalfOf (string, optional)

Returns:

  • May include approveHash and resetAllowanceHash for standard accounts (e.g., USD₮ allowance reset on Ethereum mainnet)

Example:

const res = await aave.supply({ token: 'TOKEN_ADDRESS', amount: 1000000n })

quoteSupply(options, config?)

Estimate fee to add tokens.

const q = await aave.quoteSupply({ token: 'TOKEN_ADDRESS', 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: 'TOKEN_ADDRESS', amount: 1000000n })

quoteWithdraw(options, config?)

Estimate fee to withdraw tokens.

const q = await aave.quoteWithdraw({ token: 'TOKEN_ADDRESS', amount: 1000000n })

borrow(options, config?)

Borrow tokens.

Options:

  • token (string)
  • amount (number | bigint)
  • onBehalfOf (string, optional)
const tx = await aave.borrow({ token: 'TOKEN_ADDRESS', amount: 1000000n })

quoteBorrow(options, config?)

Estimate fee to borrow tokens.

const q = await aave.quoteBorrow({ token: 'TOKEN_ADDRESS', amount: 1000000n })

repay(options, config?)

Repay borrowed tokens.

Options:

  • token (string)
  • amount (number | bigint)
  • onBehalfOf (string, optional)
const tx = await aave.repay({ token: 'TOKEN_ADDRESS', amount: 1000000n })

Returns:

  • For standard accounts, may include approveHash / resetAllowanceHash when applicable.

quoteRepay(options, config?)

Estimate fee to repay borrowed tokens.

const q = await aave.quoteRepay({ token: 'TOKEN_ADDRESS', amount: 1000000n })

setUseReserveAsCollateral(token, use, config?)

Toggle token as collateral for the user.

const tx = await aave.setUseReserveAsCollateral('TOKEN_ADDRESS', 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)

When the protocol uses WalletAccountEvmErc4337 or WalletAccountReadOnlyEvmErc4337, the optional config argument on supply, quoteSupply, withdraw, quoteWithdraw, borrow, quoteBorrow, repay, quoteRepay, setUseReserveAsCollateral, and setUserEMode accepts the wallet module's per-call gas-payment overrides.

  • 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

  • token must be a valid (non‑zero) address
  • amount > 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

Need Help?

On this page