agent-creditBorrow from Aave via credit delegation. Agent self-funds by borrowing against delegator collateral. Supports borrow, repay, health checks. Works on Aave V2/V3.
Install via ClawdBot CLI:
clawdbot install aaronjmars/agent-creditBorrow funds from Aave using delegated credit. Your main wallet supplies collateral and delegates borrowing power to the agent's wallet. The agent can then autonomously borrow tokens when needed β the debt accrues against the delegator's position.
Protocol: Works on Aave V3 and Aave V2 β the function signatures for credit delegation (borrow,repay,approveDelegation,borrowAllowance) are identical across both versions. Just swap in the V2 LendingPool and ProtocolDataProvider addresses. The only cosmetic difference: V3 returns collateral/debt in USD (8 decimals), V2 in ETH (18 decimals). The health factor safety check works correctly on both.
cast, works anywhere with a shellCombines with Bankr skills for borrow-then-swap flows: borrow USDC via delegation, then use Bankr to swap, bridge, or deploy it.
Credit delegation in Aave V3 separates two things: borrowing power and delegation approval.
Borrowing power is holistic. It comes from your entire collateral position across all assets. If you deposit $10k worth of ETH at 80% LTV, you have $8k of borrowing power β period. That borrowing power isn't locked to any specific asset.
Delegation approval is isolated per debt token. You control which assets the agent can borrow and how much of each by calling approveDelegation() on individual VariableDebtTokens. Each asset has its own debt token contract, and each approval is independent.
This means you can, for example:
The agent can only borrow assets you've explicitly approved, up to the amounts you've set β but the capacity to borrow comes from your total collateral, not from any single deposit.
Your Collateral (holistic) Delegation Approvals (isolated)
βββββββββββββββββββββββββββ ββββββββββββββββββββββββββββββββ
β $5k ETH β β USDC DebtToken β agent: 500 β
β $3k USDC β βββLTVββββΆ β WETH DebtToken β agent: 0.1 β
β $2k cbETH β = $8k β cbETH DebtToken β agent: 0 β
β Total: $10k @ 80% LTV β capacity ββββββββββββββββββββββββββββββββ
βββββββββββββββββββββββββββ
Delegator (your wallet) Agent Wallet (delegatee)
β β
β 1. supply collateral to Aave β
β 2. approveDelegation(agent, amount) β
β on the VariableDebtToken β
β β
β ββββ 3. borrow(asset, β
β β amount, onBehalfOf β
β β = delegator) β
β β β
β [debt on YOUR position] [tokens in agent wallet]
β β β
β ββββ 4. repay(asset, β
β amount, onBehalfOf β
β = delegator) β
cast CLI):
curl -L https://foundry.paradigm.xyz | bash && foundryup
approveDelegation(agentAddress, maxAmount) on the VariableDebtToken of the asset you want the agent to borrowcast call $DATA_PROVIDER "getReserveTokensAddresses(address)(address,address,address)" $ASSET --rpc-url $RPC
mkdir -p ~/.openclaw/skills/aave-delegation
cat > ~/.openclaw/skills/aave-delegation/config.json << 'EOF'
{
"chain": "base",
"rpcUrl": "https://mainnet.base.org",
"agentPrivateKey": "0xYOUR_AGENT_PRIVATE_KEY",
"delegatorAddress": "0xYOUR_MAIN_WALLET",
"poolAddress": "0xA238Dd80C259a72e81d7e4664a9801593F98d1c5",
"dataProviderAddress": "0x2d8A3C5677189723C4cB8873CfC9C8976FDF38Ac",
"assets": {
"USDC": {
"address": "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913",
"decimals": 6
},
"WETH": {
"address": "0x4200000000000000000000000000000000000006",
"decimals": 18
}
},
"safety": {
"minHealthFactor": "1.5",
"maxBorrowPerTx": "1000",
"maxBorrowPerTxUnit": "USDC"
}
}
EOF
scripts/aave-setup.sh
# Full status report
scripts/aave-status.sh
# Check specific asset delegation
scripts/aave-status.sh USDC
# Just health factor
scripts/aave-status.sh --health-only
# Borrow 100 USDC
scripts/aave-borrow.sh USDC 100
# Borrow 0.5 WETH
scripts/aave-borrow.sh WETH 0.5
The borrow script automatically:
# Repay 100 USDC
scripts/aave-repay.sh USDC 100
# Repay all USDC debt
scripts/aave-repay.sh USDC max
The repay script automatically:
Every borrow operation runs these checks BEFORE executing:
minHealthFactor (default 1.5) AFTER this borrow?maxBorrowPerTx?If ANY check fails, the borrow is aborted with a clear error message.
β οΈ The agent must NEVER bypass safety checks. If the user asks the agent to borrow and the health factor is too low, the agent should refuse and explain why.
| Chain | Pool Address | Gas Cost |
|-----------|----------------------------------------------|-----------|
| Base | 0xA238Dd80C259a72e81d7e4664a9801593F98d1c5 | Very Low |
| Ethereum | 0x87870Bca3F3fD6335C3F4ce8392D69350B4fA4E2 | High |
| Polygon | 0x794a61358D6845594F94dc1DB02A252b5b4814aD | Very Low |
| Arbitrum | 0x794a61358D6845594F94dc1DB02A252b5b4814aD | Low |
See deployments.md for full address list including debt tokens.
# Check if we have enough gas
BALANCE=$(cast balance $AGENT_ADDRESS --rpc-url $RPC)
if [ "$BALANCE" -lt "1000000000000000" ]; then # < 0.001 ETH
# Borrow a small amount of WETH for gas
aave-borrow.sh WETH 0.005
fi
# Borrow USDC from delegated credit
aave-borrow.sh USDC 100
# Swap to ETH using Bankr
bankr.sh "Swap 100 USDC for ETH on Base"
# Agent borrows USDC weekly and swaps to ETH
aave-borrow.sh USDC 100
bankr.sh "Swap 100 USDC for ETH on Base"
# Always check health first
aave-status.sh
# Only borrow if healthy
aave-borrow.sh USDC 500
| Field | Required | Description |
|--------------------------|----------|-----------------------------------------------|
| chain | Yes | Chain name (base, ethereum, polygon, arbitrum) |
| rpcUrl | Yes | JSON-RPC endpoint URL |
| agentPrivateKey | Yes | Agent wallet private key (0x-prefixed) |
| delegatorAddress | Yes | User's main wallet that delegated credit |
| poolAddress | Yes | Aave V3 Pool contract address |
| dataProviderAddress | Yes | Aave V3 PoolDataProvider address |
| assets | Yes | Map of symbol β {address, decimals} |
| safety.minHealthFactor | No | Min HF after borrow (default: 1.5) |
| safety.maxBorrowPerTx | No | Max borrow per transaction (default: 1000) |
| safety.maxBorrowPerTxUnit | No | Unit for maxBorrowPerTx (default: USDC) |
| Variable | Overrides |
|-----------------------------|------------------------|
| AAVE_RPC_URL | rpcUrl |
| AAVE_AGENT_PRIVATE_KEY | agentPrivateKey |
| AAVE_DELEGATOR_ADDRESS | delegatorAddress |
| AAVE_POOL_ADDRESS | poolAddress |
| AAVE_MIN_HEALTH_FACTOR | safety.minHealthFactor |
| Error | Cause | Fix |
|------------------------------|-------------------------------------------|--------------------------------------------------|
| INSUFFICIENT_ALLOWANCE | Delegation amount exceeded | Delegator must call approveDelegation() again |
| HEALTH_FACTOR_TOO_LOW | Borrow would risk liquidation | Reduce amount or add collateral |
| AMOUNT_EXCEEDS_CAP | Per-tx safety cap hit | Reduce amount or update config |
| INSUFFICIENT_LIQUIDITY | Not enough in Aave pool | Try smaller amount or different asset |
| INSUFFICIENT_GAS | Agent wallet has no native token | Send gas to agent wallet |
| EMODE_MISMATCH | Asset incompatible with delegator's eMode | Borrow an asset in the same eMode category |
See safety.md for the full threat model and emergency procedures.
Critical rules:
minHealthFactor below 1.2 β liquidation happens at 1.0type(uint256).maxAI Usage Analysis
Analysis is being generated⦠refresh in a few seconds.
Captures learnings, errors, and corrections to enable continuous improvement. Use when: (1) A command or operation fails unexpectedly, (2) User corrects Clau...
Helps users discover and install agent skills when they ask questions like "how do I do X", "find a skill for X", "is there a skill that can...", or express interest in extending capabilities. This skill should be used when the user is looking for functionality that might exist as an installable skill.
Search and analyze your own session logs (older/parent conversations) using jq.
Typed knowledge graph for structured agent memory and composable skills. Use when creating/querying entities (Person, Project, Task, Event, Document), linking related objects, enforcing constraints, planning multi-step actions as graph transformations, or when skills need to share state. Trigger on "remember", "what do I know about", "link X to Y", "show dependencies", entity CRUD, or cross-skill data access.
Ultimate AI agent memory system for Cursor, Claude, ChatGPT & Copilot. WAL protocol + vector search + git-notes + cloud backup. Never lose context again. Vibe-coding ready.
Headless browser automation CLI optimized for AI agents with accessibility tree snapshots and ref-based element selection