aaveclaw - Aave V3 Lending on Base Sepolia
Interact with Aave V3 lending protocol on Base Sepolia testnet. Manages the full lending lifecycle using the wallet from ~/.x402-config.json.
Setup
Run setup.sh on first use to install dependencies (ethers v6):
CODEBLOCK0
Commands
Check Health Factor
Check the current lending position. Safe to run anytime, read-only.
CODEBLOCK1
If no address is provided, uses the configured wallet address.
Mint Test Tokens (Faucet)
Get testnet WETH or USDC from the Aave faucet. Run this first if the wallet has no tokens.
CODEBLOCK2
Deposit Collateral
Deposit WETH as collateral into Aave. Auto-wraps native ETH to WETH if needed.
CODEBLOCK3
Borrow USDC
Borrow USDC against deposited collateral. Uses variable interest rate.
CODEBLOCK4
Repay Debt
Repay borrowed USDC. Use "max" to repay entire debt.
CODEBLOCK5
Withdraw Collateral
Withdraw WETH collateral. Use "max" to withdraw everything (only if no debt).
CODEBLOCK6
Usage Guidelines
- - Always run
health.sh first to see the current position before making changes. - Ask the user for amounts before executing deposit, borrow, repay, or withdraw.
- Always show the health factor after any state-changing operation (the scripts do this automatically).
- Warn when health factor drops below 1.5 - the position is at risk of liquidation.
- Guide new users to the faucet to get test tokens before depositing.
- Typical flow: faucet (get tokens) -> deposit (add collateral) -> borrow (take loan) -> repay (pay back) -> withdraw (retrieve collateral).
Network Details
- - Network: Base Sepolia (chain ID 84532)
- Explorer: https://sepolia.basescan.org
- RPC: https://sepolia.base.org
- Tokens: WETH (18 decimals), USDC (6 decimals)
Error Handling
- - If private key is missing: direct user to create
~/.x402-config.json with INLINECODE4 - If insufficient balance: the scripts report exact balances and what is needed
- If health factor would drop too low after borrow: Aave reverts the transaction automatically
- If faucet fails: the faucet contract may have minting limits or may not be available
aaveclaw - Base Sepolia 上的 Aave V3 借贷
在 Base Sepolia 测试网上与 Aave V3 借贷协议交互。使用 ~/.x402-config.json 中的钱包管理完整的借贷生命周期。
设置
首次使用时运行 setup.sh 安装依赖(ethers v6):
bash scripts/setup.sh
命令
检查健康因子
检查当前借贷头寸。随时可安全运行,只读操作。
bash scripts/health.sh [地址]
如果未提供地址,则使用配置中的钱包地址。
铸造测试代币(水龙头)
从 Aave 水龙头获取测试网 WETH 或 USDC。如果钱包中没有代币,请先运行此命令。
bash scripts/faucet.sh weth 1 # 铸造 1 个 WETH
bash scripts/faucet.sh usdc 1000 # 铸造 1000 个 USDC
存入抵押品
将 WETH 作为抵押品存入 Aave。如有需要,会自动将原生 ETH 包装为 WETH。
bash scripts/deposit.sh 0.5 # 存入 0.5 个 WETH
借出 USDC
使用已存入的抵押品借出 USDC。采用浮动利率。
bash scripts/borrow.sh 100 # 借出 100 个 USDC
偿还债务
偿还已借出的 USDC。使用 max 偿还全部债务。
bash scripts/repay.sh 50 # 偿还 50 个 USDC
bash scripts/repay.sh max # 偿还全部债务
提取抵押品
提取 WETH 抵押品。使用 max 提取全部(仅当无债务时)。
bash scripts/withdraw.sh 0.5 # 提取 0.5 个 WETH
bash scripts/withdraw.sh max # 提取全部
使用指南
- - 始终先运行 health.sh,在进行任何更改前查看当前头寸。
- 在执行存入、借出、偿还或提取前向用户询问金额。
- 在任何状态变更操作后始终显示健康因子(脚本会自动执行此操作)。
- 当健康因子低于 1.5 时发出警告 - 头寸面临清算风险。
- 引导新用户使用水龙头,在存入前获取测试代币。
- 典型流程:水龙头(获取代币)-> 存入(添加抵押品)-> 借出(获取贷款)-> 偿还(还款)-> 提取(取回抵押品)。
网络详情
- - 网络:Base Sepolia(链 ID 84532)
- 浏览器:https://sepolia.basescan.org
- RPC:https://sepolia.base.org
- 代币:WETH(18 位小数),USDC(6 位小数)
错误处理
- - 如果缺少私钥:引导用户创建 ~/.x402-config.json,内容为 {private_key: 0x...}
- 如果余额不足:脚本会报告确切余额及所需金额
- 如果借出后健康因子会过低:Aave 会自动回退交易
- 如果水龙头失败:水龙头合约可能存在铸造限制或不可用