@anywalletkit/protocol-lending-aave-evm

中文文档
0.3.1发布于 2026/11/03Apache-2.0TypeScriptESM + CJS构建来源已验证近 30 天下载 2106

Aave v3 for @anywalletkit/wallet-evm accounts: supply, withdraw, borrow (variable rate) and repay on any Aave v3 market, native coin through WrappedTokenGatewayV3, one-transaction supply/repay with EIP-2612 permits, reserves with rates and caps, health fa

原始使用文档
文档目录9 节
  1. Install
  2. Markets
  3. Usage
  4. What happens before money moves
  5. Reads
  6. Config
  7. Tests
  8. Status
  9. Activity

@anywalletkit/protocol-lending-aave-evm

npm

Aave v3 for @anywalletkit/wallet-evm accounts: supply, withdraw, borrow (variable rate) and repay on any Aave v3 market, with the reads a wallet screen needs — reserves with rates and caps, the account's health factor and borrowing power, the position. Implements core's LendingProtocol (supply / withdraw / borrow / repay + quotes), like @anywalletkit/protocol-lending-mellow-evm does for vaults.

Install

npm install @anywalletkit/protocol-lending-aave-evm @anywalletkit/core
# or: pnpm add @anywalletkit/protocol-lending-aave-evm @anywalletkit/core  ·  yarn add @anywalletkit/protocol-lending-aave-evm @anywalletkit/core

On npm: @anywalletkit/protocol-lending-aave-evm, published from the release workflow with provenance.

Written from the protocol's own interfaces (aave-v3-origin) and the official address book (bgd-labs/aave-address-book); no Aave SDK, one dependency (viem).

Markets

Every live Aave v3 market ships as a preset (AAVE_MARKETS[chainId][key]): Ethereum (core, lido, etherfi), Arbitrum, Optimism, Polygon, Base, Avalanche, BNB, Gnosis, Scroll, Linea, Sonic, Celo, Mantle, Soneium, Plasma, zkSync, Metis, Ink. A market not in the list takes addressesProvider and pool in the config: the Pool receives the approvals and permits, so it is never taken from the RPC alone, and a custom provider without pool is refused (a preset's provider on its own chain picks up the shipped Pool).

Only the PoolAddressesProvider is trusted from configuration. The Pool, price oracle and data provider are read from it on-chain, and the preset's Pool must match what the provider reports — a stale or wrong entry refuses instead of sending money to the wrong contract.

Usage

import WalletManagerEvm from '@anywalletkit/wallet-evm'
import { AaveProtocolEvm } from '@anywalletkit/protocol-lending-aave-evm'

const account = await new WalletManagerEvm(seed, { provider: 'https://…' }).getAccount(0)
const aave = new AaveProtocolEvm(account)              // chain from the account, market 'core'
// new AaveProtocolEvm(account, { market: 'lido' })    // Ethereum Lido instance
// new AaveProtocolEvm(account, { chainId: 8453 })     // Base, with an explicit chain

const USDT = '0xdAC17F958D2ee523a2206206994597C13D831ec7'

await aave.getSupplyApy(USDT)                          // 3.9 (percent, compounded like Aave's UI)
await aave.quoteSupply({ token: USDT, amount: 100_000_000n })   // { fee, approvals, permit, supplyApy }
await aave.supply({ token: USDT, amount: 100_000_000n })        // approve (exact) → wait → Pool.supply
await aave.supply({ token: 'native', amount: 10n ** 17n })      // WrappedTokenGatewayV3.depositETH

await aave.borrow({ token: USDT, amount: 50_000_000n })         // variable rate, checked against borrowing power
await aave.repay({ token: USDT, amount: 'max' })                // whole debt (+0.1 % approved for accruing interest)
await aave.withdraw({ token: USDT, amount: 'max' })             // uint256.max → everything
await aave.setCollateral({ token: USDT, enabled: false })

const { account: data, supplies, borrows } = await aave.getPosition()
data.healthFactor                                      // 2.6, or Infinity without debt

What happens before money moves

  • The reserve must be active, not paused, and not frozen (frozen allows only withdraw and repay). Supply and borrow caps are checked against the aToken / debt-token supply.
  • Borrows are compared with getUserAccountData().availableBorrowsBase at the oracle price, so an over-borrow is refused with the numbers instead of a bare revert. Credit delegation (onBehalfOf) is checked via borrowAllowance.
  • Every main transaction is proven with eth_call from the account; Aave's reverts — numeric codes on v3.0–3.3 ('35'), custom errors on v3.4+ (HealthFactorLowerThanLiquidationThreshold()) — become readable AaveErrors with the code attached.
  • ERC-20 allowances are exact, never unlimited; Ethereum's USDT gets the approve(0) reset it demands. When the token supports EIP-2612 and the account can signPermit (wallet-evm does), supply and repay take the one-transaction supplyWithPermit / repayWithPermit road.
  • Native legs go through WrappedTokenGatewayV3: depositETH, withdrawETH (after approving the aWETH to the gateway), borrowETH (after approveDelegation on the WETH debt token), repayETH (excess refunded). The gateway ABI is the v3.2+ one verified on Ethereum — borrowETH and repayETH no longer take a rate mode, unlike the protocol docs still show.

Reads

methodreturns
getMarket()pool, oracle, data provider, base currency unit, gateway, wrapped native
getReserves() / getReserve(token)configuration bits decoded (LTV, thresholds, caps, flags), rates (ray, APR, APY), aToken / debt token
getUserAccountData(user?)collateral, debt, borrowing power in base currency; LTV, liquidation threshold, health factor
getPosition()supplies (with the collateral flag) and borrows per reserve, plus the account data
getAssetPrice(token), getSupplyApy(token), getBorrowApy(token)oracle price; APYs in percent

Reserve reads go through Multicall3 (one round trip) and fall back to single calls where it is absent (zkSync).

Config

keydefaultmeaning
chainIdaccount's chain, else 1must match the account's eip155:N
market'core'preset key for the chain
addressesProvider, pool, wethGatewayfrom the presetexplicit market (pool required with a custom addressesProvider); wethGateway: null disables native legs
providerthe account'sRPC url(s) / EIP-1193 to read through
usePermittrueone-transaction supply / repay when possible
referralCode0inactive on every market
waitTimeoutMs180 000how long an approval may take to mine
multicallMulticall3address, or false

Tests

pnpm test — 38 offline tests over an in-memory Aave market (an EIP-1193 provider that decodes calldata: Pool, oracle, gateway, tokens, Multicall3, reverts in both dialects) plus the conformance suite. pnpm verify:live reads the Ethereum Core market through a public RPC: market discovery, reserves, prices, APYs, and proves a supply plan with eth_call.

Status

2026-10-10: built, offline tests green, live read-only verification against Ethereum mainnet. No funded transaction through the module yet.

Activity

describeActivity(tx, { own }) labels the module's own transactions for a wallet's history, offline and synchronously:

  • Recognized: a call whose target is a known Aave v3 Pool or WrappedTokenGatewayV3 — every preset market on the transaction's chain (AAVE_MARKETS) plus the market the instance was configured with. The 4-byte selector picks the kind: supply / supplyWithPermit / deposit and depositETH → supply; withdraw / withdrawETH → withdraw; borrow / borrowETH → borrow; repay / repayWithPermit / repayWithATokens / repayETH → repay; setUserUseReserveAsCollateral / setUserEMode → contract. Any other method on an Aave contract is still returned as contract ("Aave v3 transaction").
  • Title is "<Verb> <asset>" ("Supplied ETH", "Withdrew USDC"): the principal asset is the address asset argument when calldata is present, else the token that moved in the action's direction; the symbol comes from the source's transfer metadata. Subtitle is "Aave v3 · <chain>", counterparty the contract called, protocol the package name.
  • Assets: assetsIn / assetsOut are the wallet's net token movements from the receipt (aToken mints and burns included, so a supply shows the aToken arriving).
  • Null for everything else: another protocol, a plain transfer, a chain without a market.

Fixtures in fixtures/activity/ are the test wallet's funded Base run (depositETH / withdrawETH, 2026-10-10) and run through the conformance suite's activity half; fixtures/activity/negatives/ holds look-alikes that must yield null.

版本与发布记录

@anywalletkit/protocol-lending-aave-evm 共发布 12 个版本,首次发布于 2026/10/25;过去 12 个月发布了 12 个版本。最新版本附带 npm provenance 构建来源证明,可追溯到公开的 CI 构建记录。

版本发布日期距今
0.3.1latest2026/11/035 天前
0.3.02026/10/309 天前
0.2.102026/10/2910 天前
0.2.92026/10/2811 天前
0.2.82026/10/2712 天前
0.2.72026/10/2612 天前

关于 @anywalletkit/protocol-lending-aave-evm 的常见问题

@anywalletkit/protocol-lending-aave-evm 是什么?

Aave v3 for @anywalletkit/wallet-evm accounts: supply, withdraw, borrow (variable rate) and repay on any Aave v3 market, native coin through WrappedTokenGatewayV3, one-transaction supply/repay with EIP-2612 permits, reserves with rates and caps, health fa

如何安装 @anywalletkit/protocol-lending-aave-evm?

在项目目录运行 npm install @anywalletkit/protocol-lending-aave-evm,或使用 pnpm add / yarn add / bun add。它还需要宿主项目提供 peer 依赖:@anywalletkit/core(0.8.0)。npm 7 及以上与 pnpm 8 及以上默认会自动安装必需的 peer 依赖,Yarn 需要手动安装。

@anywalletkit/protocol-lending-aave-evm 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@anywalletkit/protocol-lending-aave-evm 支持 ESM 还是 CommonJS?

同时提供 ES Module 与 CommonJS 入口,import 和 require() 都可以使用,打包工具会自动选择合适的版本。

@anywalletkit/protocol-lending-aave-evm 需要什么版本的 Node.js?

package.json 的 engines 字段要求 Node.js >=22。版本不符时 npm 默认只给出警告,开启 engine-strict 后会拒绝安装。

@anywalletkit/protocol-lending-aave-evm 可以商用吗?

@anywalletkit/protocol-lending-aave-evm 使用 Apache-2.0 许可。宽松许可:允许商业使用、修改和再分发,并附带明确的专利授权;分发时需保留许可与 NOTICE 文件,修改过的文件要注明改动。以上为概括,不构成法律意见,请以许可原文为准。

@anywalletkit/protocol-lending-aave-evm 的下载量有多少?

根据 npm 官方下载统计,@anywalletkit/protocol-lending-aave-evm 在 2026/10/06 – 2026/11/04 这 30 天内被下载 2,106 次,日均约 70 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@anywalletkit/protocol-lending-aave-evm 还在维护吗?

最新版本 0.3.1 发布于 2026/11/03(5 天前);至今共发布 12 个版本,其中过去 12 个月发布了 12 个;首次发布于 2026/10/25。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。