# Send Agent Credit to your agent
Hand the extracted package to your coding agent with a concrete install brief instead of figuring it out manually.
## Fast path
- Download the package from Yavira.
- Extract it into a folder your agent can access.
- Paste one of the prompts below and point your agent at the extracted folder.
## Suggested prompts
### New install

```text
I downloaded a skill package from Yavira. Read SKILL.md from the extracted folder and install it by following the included instructions. Then review README.md for any prerequisites, environment setup, or post-install checks. Tell me what you changed and call out any manual steps you could not complete.
```
### Upgrade existing

```text
I downloaded an updated skill package from Yavira. Read SKILL.md from the extracted folder, compare it with my current installation, and upgrade it while preserving any custom configuration unless the package docs explicitly say otherwise. Then review README.md for any prerequisites, environment setup, or post-install checks. Summarize what changed and any follow-up checks I should run.
```
## Machine-readable fields
```json
{
  "schemaVersion": "1.0",
  "item": {
    "slug": "agent-credit",
    "name": "Agent Credit",
    "source": "tencent",
    "type": "skill",
    "category": "AI 智能",
    "sourceUrl": "https://clawhub.ai/aaronjmars/agent-credit",
    "canonicalUrl": "https://clawhub.ai/aaronjmars/agent-credit",
    "targetPlatform": "OpenClaw"
  },
  "install": {
    "downloadUrl": "/downloads/agent-credit",
    "sourceDownloadUrl": "https://wry-manatee-359.convex.site/api/v1/download?slug=agent-credit",
    "sourcePlatform": "tencent",
    "targetPlatform": "OpenClaw",
    "packageFormat": "ZIP package",
    "primaryDoc": "SKILL.md",
    "includedAssets": [
      "deployments.md",
      "contracts.md",
      "aave-repay.sh",
      "safety.md",
      "README.md",
      "config.example.json"
    ],
    "downloadMode": "redirect",
    "sourceHealth": {
      "source": "tencent",
      "slug": "agent-credit",
      "status": "healthy",
      "reason": "direct_download_ok",
      "recommendedAction": "download",
      "checkedAt": "2026-04-29T06:02:16.247Z",
      "expiresAt": "2026-05-06T06:02:16.247Z",
      "httpStatus": 200,
      "finalUrl": "https://wry-manatee-359.convex.site/api/v1/download?slug=agent-credit",
      "contentType": "application/zip",
      "probeMethod": "head",
      "details": {
        "probeUrl": "https://wry-manatee-359.convex.site/api/v1/download?slug=agent-credit",
        "contentDisposition": "attachment; filename=\"agent-credit-1.0.0.zip\"",
        "redirectLocation": null,
        "bodySnippet": null,
        "slug": "agent-credit"
      },
      "scope": "item",
      "summary": "Item download looks usable.",
      "detail": "Yavira can redirect you to the upstream package for this item.",
      "primaryActionLabel": "Download for OpenClaw",
      "primaryActionHref": "/downloads/agent-credit"
    },
    "validation": {
      "installChecklist": [
        "Use the Yavira download entry.",
        "Review SKILL.md after the package is downloaded.",
        "Confirm the extracted package contains the expected setup assets."
      ],
      "postInstallChecks": [
        "Confirm the extracted package includes the expected docs or setup files.",
        "Validate the skill or prompts are available in your target agent workspace.",
        "Capture any manual follow-up steps the agent could not complete."
      ]
    }
  },
  "links": {
    "detailUrl": "https://openagent3.xyz/skills/agent-credit",
    "downloadUrl": "https://openagent3.xyz/downloads/agent-credit",
    "agentUrl": "https://openagent3.xyz/skills/agent-credit/agent",
    "manifestUrl": "https://openagent3.xyz/skills/agent-credit/agent.json",
    "briefUrl": "https://openagent3.xyz/skills/agent-credit/agent.md"
  }
}
```
## Documentation

### Aave Credit Delegation

Borrow 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.

### Compatible With

OpenClaw — Install as a skill, the agent borrows autonomously
Claude Code — Run scripts directly from a Claude Code session
Any agent framework — Plain bash + Foundry's cast, works anywhere with a shell

Combines with Bankr skills for borrow-then-swap flows: borrow USDC via delegation, then use Bankr to swap, bridge, or deploy it.

### How Credit Delegation Works

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:

Deposit ETH as collateral (gives you broad borrowing power)
Approve the agent to borrow up to 500 USDC (via the USDC VariableDebtToken)
Approve the agent to borrow up to 0.1 WETH (via the WETH VariableDebtToken)
Leave cbETH unapproved (agent cannot borrow it at all)

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   └──────────────────────────────┘
└─────────────────────────┘

### Flow

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)         │

### Prerequisites

Foundry must be installed (cast CLI):
curl -L https://foundry.paradigm.xyz | bash && foundryup



Delegator setup (done ONCE by the user, NOT the agent):

Supply collateral to Aave V3 (via app.aave.com or contract)
Call approveDelegation(agentAddress, maxAmount) on the VariableDebtToken of the asset you want the agent to borrow
The VariableDebtToken address can be found via: cast call $DATA_PROVIDER "getReserveTokensAddresses(address)(address,address,address)" $ASSET --rpc-url $RPC



Configure the skill:
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



Verify setup:
scripts/aave-setup.sh

### Check Status (allowance, health, debt)

# 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 via Delegation

# Borrow 100 USDC
scripts/aave-borrow.sh USDC 100

# Borrow 0.5 WETH
scripts/aave-borrow.sh WETH 0.5

The borrow script automatically:

Checks delegation allowance (sufficient?)
Checks delegator health factor (safe to borrow?)
Executes the borrow
Reports the result

### Repay Debt

# Repay 100 USDC
scripts/aave-repay.sh USDC 100

# Repay all USDC debt
scripts/aave-repay.sh USDC max

The repay script automatically:

Approves the Pool to spend the token (if needed)
Executes the repay
Reports remaining debt

### Safety System

Every borrow operation runs these checks BEFORE executing:

Delegation allowance — Is the remaining allowance >= requested amount?
Health factor — Is the delegator's health factor > minHealthFactor (default 1.5) AFTER this borrow?
Per-tx cap — Is the amount <= maxBorrowPerTx?
Confirmation — Logs the full operation details before sending

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.

### Read Operations (no gas needed)

Check delegation allowance — How much can the agent still borrow?
Check health factor — Is the delegator's position safe?
Check outstanding debt — How much does the delegator owe on each asset?
Check available liquidity — Is there enough in the Aave pool to borrow?
Resolve debt token addresses — Look up VariableDebtToken for any asset

### Write Operations (needs gas in agent wallet)

Borrow — Draw funds from Aave against delegated credit
Repay — Return borrowed funds to reduce delegator's debt
Approve — Approve Pool to spend tokens for repayment

### Supported Chains

ChainPool AddressGas CostBase0xA238Dd80C259a72e81d7e4664a9801593F98d1c5Very LowEthereum0x87870Bca3F3fD6335C3F4ce8392D69350B4fA4E2HighPolygon0x794a61358D6845594F94dc1DB02A252b5b4814aDVery LowArbitrum0x794a61358D6845594F94dc1DB02A252b5b4814aDLow

See deployments.md for full address list including debt tokens.

### Agent Self-Funding for Gas

# 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 + Swap via Bankr

# Borrow USDC from delegated credit
aave-borrow.sh USDC 100
# Swap to ETH using Bankr
bankr.sh "Swap 100 USDC for ETH on Base"

### Periodic DCA

# Agent borrows USDC weekly and swaps to ETH
aave-borrow.sh USDC 100
bankr.sh "Swap 100 USDC for ETH on Base"

### Safety-First Portfolio Rebalance

# Always check health first
aave-status.sh
# Only borrow if healthy
aave-borrow.sh USDC 500

### config.json Fields

FieldRequiredDescriptionchainYesChain name (base, ethereum, polygon, arbitrum)rpcUrlYesJSON-RPC endpoint URLagentPrivateKeyYesAgent wallet private key (0x-prefixed)delegatorAddressYesUser's main wallet that delegated creditpoolAddressYesAave V3 Pool contract addressdataProviderAddressYesAave V3 PoolDataProvider addressassetsYesMap of symbol → {address, decimals}safety.minHealthFactorNoMin HF after borrow (default: 1.5)safety.maxBorrowPerTxNoMax borrow per transaction (default: 1000)safety.maxBorrowPerTxUnitNoUnit for maxBorrowPerTx (default: USDC)

### Environment Variables (override config)

VariableOverridesAAVE_RPC_URLrpcUrlAAVE_AGENT_PRIVATE_KEYagentPrivateKeyAAVE_DELEGATOR_ADDRESSdelegatorAddressAAVE_POOL_ADDRESSpoolAddressAAVE_MIN_HEALTH_FACTORsafety.minHealthFactor

### Error Handling

ErrorCauseFixINSUFFICIENT_ALLOWANCEDelegation amount exceededDelegator must call approveDelegation() againHEALTH_FACTOR_TOO_LOWBorrow would risk liquidationReduce amount or add collateralAMOUNT_EXCEEDS_CAPPer-tx safety cap hitReduce amount or update configINSUFFICIENT_LIQUIDITYNot enough in Aave poolTry smaller amount or different assetINSUFFICIENT_GASAgent wallet has no native tokenSend gas to agent walletEMODE_MISMATCHAsset incompatible with delegator's eModeBorrow an asset in the same eMode category

### Security

See safety.md for the full threat model and emergency procedures.

Critical rules:

The delegator's private key must NEVER be in this repo, config, or scripts — this is the agent's workspace. The delegator manages their side via the Aave UI or a block explorer.
Never commit config.json to version control — it contains the agent's private key
Never set minHealthFactor below 1.2 — liquidation happens at 1.0
Always cap delegation amounts — never approve type(uint256).max
Monitor delegator health — set up alerts if HF drops below 2.0
Agent must refuse to borrow if safety checks fail, even if instructed to

### Resources

Aave V3 Docs: https://docs.aave.com/developers
Credit Delegation Guide: https://docs.aave.com/developers/guides/credit-delegation
Aave Address Book: https://github.com/bgd-labs/aave-address-book
Foundry Book: https://book.getfoundry.sh/
DebtToken Reference: https://docs.aave.com/developers/tokens/debttoken
## Trust
- Source: tencent
- Verification: Indexed source record
- Publisher: aaronjmars
- Version: 1.0.0
## Source health
- Status: healthy
- Item download looks usable.
- Yavira can redirect you to the upstream package for this item.
- Health scope: item
- Reason: direct_download_ok
- Checked at: 2026-04-29T06:02:16.247Z
- Expires at: 2026-05-06T06:02:16.247Z
- Recommended action: Download for OpenClaw
## Links
- [Detail page](https://openagent3.xyz/skills/agent-credit)
- [Send to Agent page](https://openagent3.xyz/skills/agent-credit/agent)
- [JSON manifest](https://openagent3.xyz/skills/agent-credit/agent.json)
- [Markdown brief](https://openagent3.xyz/skills/agent-credit/agent.md)
- [Download page](https://openagent3.xyz/downloads/agent-credit)