Skip to main content
Supply assets to earn yield, borrow against your collateral, and monitor your health factor — all through natural language commands powered by the Aave V3 integration on Arbitrum.

Aave V3 on Arbitrum

The AaveV3Adapter integrates with the Aave V3 lending pool on Arbitrum One, providing four core operations:

Supply

Deposit assets to earn variable yield. You receive aTokens that represent your position and accrue interest continuously.

Borrow

Borrow assets against your supplied collateral at variable interest rates. Requires sufficient health factor.

Repay

Repay outstanding borrows partially or in full. Pass the maximum uint256 value to repay the entire debt.

Withdraw

Withdraw supplied collateral by burning aTokens. Pass the maximum uint256 value to withdraw everything.

How It Works

Supplying Assets

When you supply an asset to Aave V3:
  1. The agent approves the Aave V3 Pool to pull your tokens
  2. Calls pool.supply(asset, amount, onBehalfOf, referralCode)
  3. You receive an equivalent amount of aTokens (e.g., supply USDC and get aUSDC)
  4. Your aToken balance increases over time as interest accrues
aTokens are rebasing — their balance grows in your wallet automatically. There is no need to claim or harvest yield.

Borrowing Assets

To borrow, you must first supply collateral. The amount you can borrow depends on the loan-to-value (LTV) ratio of your collateral asset.
  1. The agent calls pool.borrow(asset, amount, interestRateMode, referralCode, onBehalfOf)
  2. Borrowed tokens are transferred to your wallet
  3. Your debt accrues interest at the variable rate
Borrowing reduces your health factor. If it drops below 1.0, your position becomes eligible for liquidation. The agent monitors this and warns you proactively.

Repaying Debt

Repaying works in two modes:
  • Partial repay: specify the exact amount to repay
  • Full repay: the agent passes type(uint256).max to clear the entire debt including accrued interest
The agent approves the pool to pull your tokens before submitting the repay transaction.

Withdrawing Collateral

Withdrawal burns your aTokens and returns the underlying asset. Withdrawing collateral reduces your health factor, so the agent checks that the withdrawal will not put your position at liquidation risk.

Health Factor

The health factor is the single most important metric for lending positions. It represents how safe your position is from liquidation. The agent fetches your health factor via pool.getUserAccountData(address), which returns:
Ask the agent “what’s my health factor?” at any time to get a snapshot of your Aave position. The agent will flag positions below 1.5 as requiring attention.

Liquidation Monitor Contract

For proactive health monitoring at scale, the platform includes a LiquidationMonitor Stylus contract written in Rust. This contract runs on-chain with 10-100x gas savings compared to equivalent Solidity.

Dynamic Protocol Registry

The LiquidationMonitor maintains a registry of lending and perp protocols using indexed mappings:
  • Lending protocols: Aave V3 pools (extensible to Radiant, Compound V3)
  • Perp protocols: GMX V2 readers (future)
  • Soft-delete pattern: protocols can be deactivated without reindexing

How Scanning Works

  1. The contract stores a list of tracked account addresses
  2. A configurable risk_threshold defines the health factor warning level
  3. When scanAccounts() is called, it iterates through tracked accounts and checks each against all registered lending protocols
  4. Accounts below the risk threshold emit an AccountAtRisk event with the health factor and timestamp

Events

The contract emits events that the off-chain agent can monitor:
The LiquidationMonitor is a Stylus contract that compiles to WASM and runs on the Arbitrum Stylus VM. It is not yet deployed to mainnet — see the deployment guide for instructions.

Contract Addresses

Example Prompts

SDK Reference

The lending adapter is in the @arb-agent/adapters package as AaveV3Adapter.

supply(params)

Supplies an asset to earn yield. Accepts SupplyParams:

borrow(params)

Borrows an asset at variable rate. Accepts BorrowParams:

repay(asset, amount)

Repays a borrow position. Pass 2n ** 256n - 1n to repay the full debt.

withdraw(asset, amount)

Withdraws supplied collateral. Pass 2n ** 256n - 1n to withdraw everything.

getAccountData()

Returns the full account summary including health factor, collateral, debt, and available borrows.