[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M6CK38JKB2812ATATBZGPDP4":3,"skill-same:01M6CK38JKB2812ATATBZGPDP4":96},{"skillNo":4,"name":5,"nameZh":6,"description":7,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":15,"categories":16,"keywords":22,"publishedAt":26,"linkOnly":27,"markdownContent":28,"markdownBody":29,"frontMatter":30,"refName":31,"commitSha":32,"skillDirectory":33,"forksCount":34,"repositoryHtmlUrl":35,"repositoryHomepageUrl":6,"ownerHtmlUrl":36,"ownerBlogUrl":6,"ownerDescription":6,"updatedAt":37,"install":38,"resources":51},"01M6CK38JKB2812ATATBZGPDP4","agent-credit",null,"Borrow from Aave via credit delegation. Agent self-funds by borrowing against delegator collateral. Supports borrow, repay, health checks. Works on Aave V2\u002FV3.","kbarbel640-del\u002Fskills","kbarbel640-del","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F255315490?v=4","01M6CJPPQGCCESXMG3K7BBGQ5J","01M6CJPPX2PB2BCZERFVM2C2B3",1,"MIT","https:\u002F\u002Fgithub.com\u002Fkbarbel640-del\u002Fskills\u002Fblob\u002Fmain\u002Fskills\u002Faaronjmars\u002Fagent-credit\u002FSKILL.md",[17],{"categoryNo":18,"categoryName":19,"taxonomyType":20,"taxonomyTypeDesc":21},"01JBSEEDCAT000000000000023","Skill与智能体开发","SCENARIO","使用场景",[23,24,25],"agent credit","delegation","health","2026-11-10 10:12:30",false,"---\nname: agent-credit\ndescription: Borrow from Aave via credit delegation. Agent self-funds by borrowing against delegator collateral. Supports borrow, repay, health checks. Works on Aave V2\u002FV3.\n---\n\n# Aave Credit Delegation\n\nBorrow 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.\n\n> **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\u002Fdebt in USD (8 decimals), V2 in ETH (18 decimals). The health factor safety check works correctly on both.\n\n## Compatible With\n\n- **[OpenClaw](https:\u002F\u002Fopenclaw.ai\u002F)** — Install as a skill, the agent borrows autonomously\n- **[Claude Code](https:\u002F\u002Fwww.npmjs.com\u002Fpackage\u002F@anthropic-ai\u002Fclaude-code)** — Run scripts directly from a Claude Code session\n- **Any agent framework** — Plain bash + Foundry's `cast`, works anywhere with a shell\n\nCombines with **[Bankr](https:\u002F\u002Fbankr.bot\u002F)** skills for borrow-then-swap flows: borrow USDC via delegation, then use Bankr to swap, bridge, or deploy it.\n\n## How Credit Delegation Works\n\nCredit delegation in Aave V3 separates two things: **borrowing power** and **delegation approval**.\n\n**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.\n\n**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.\n\nThis means you can, for example:\n- Deposit ETH as collateral (gives you broad borrowing power)\n- Approve the agent to borrow up to 500 USDC (via the USDC VariableDebtToken)\n- Approve the agent to borrow up to 0.1 WETH (via the WETH VariableDebtToken)\n- Leave cbETH unapproved (agent cannot borrow it at all)\n\nThe 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.\n\n```\nYour Collateral (holistic)              Delegation Approvals (isolated)\n┌─────────────────────────┐             ┌──────────────────────────────┐\n│  $5k ETH                │             │  USDC DebtToken → agent: 500 │\n│  $3k USDC               │  ───LTV───▶ │  WETH DebtToken → agent: 0.1 │\n│  $2k cbETH              │   = $8k     │  cbETH DebtToken → agent: 0  │\n│  Total: $10k @ 80% LTV  │  capacity   └──────────────────────────────┘\n└─────────────────────────┘\n```\n\n## Flow\n\n```\nDelegator (your wallet)                 Agent Wallet (delegatee)\n    │                                        │\n    │  1. supply collateral to Aave          │\n    │  2. approveDelegation(agent, amount)   │\n    │        on the VariableDebtToken        │\n    │                                        │\n    │            ┌─── 3. borrow(asset,       │\n    │            │       amount, onBehalfOf   │\n    │            │       = delegator)         │\n    │            │                            │\n    │     [debt on YOUR position]    [tokens in agent wallet]\n    │            │                            │\n    │            └─── 4. repay(asset,         │\n    │                    amount, onBehalfOf   │\n    │                    = delegator)         │\n```\n\n## Quick Start\n\n### Prerequisites\n\n1. **Foundry** must be installed (`cast` CLI):\n   ```bash\n   curl -L https:\u002F\u002Ffoundry.paradigm.xyz | bash && foundryup\n   ```\n\n2. **Delegator setup** (done ONCE by the user, NOT the agent):\n   - Supply collateral to Aave V3 (via app.aave.com or contract)\n   - Call `approveDelegation(agentAddress, maxAmount)` on the **VariableDebtToken** of the asset you want the agent to borrow\n   - The VariableDebtToken address can be found via: `cast call $DATA_PROVIDER \"getReserveTokensAddresses(address)(address,address,address)\" $ASSET --rpc-url $RPC`\n\n3. **Configure the skill**:\n   ```bash\n   mkdir -p ~\u002F.openclaw\u002Fskills\u002Faave-delegation\n   cat > ~\u002F.openclaw\u002Fskills\u002Faave-delegation\u002Fconfig.json \u003C\u003C 'EOF'\n   {\n     \"chain\": \"base\",\n     \"rpcUrl\": \"https:\u002F\u002Fmainnet.base.org\",\n     \"agentPrivateKey\": \"0xYOUR_AGENT_PRIVATE_KEY\",\n     \"delegatorAddress\": \"0xYOUR_MAIN_WALLET\",\n     \"poolAddress\": \"0xA238Dd80C259a72e81d7e4664a9801593F98d1c5\",\n     \"dataProviderAddress\": \"0x2d8A3C5677189723C4cB8873CfC9C8976FDF38Ac\",\n     \"assets\": {\n       \"USDC\": {\n         \"address\": \"0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913\",\n         \"decimals\": 6\n       },\n       \"WETH\": {\n         \"address\": \"0x4200000000000000000000000000000000000006\",\n         \"decimals\": 18\n       }\n     },\n     \"safety\": {\n       \"minHealthFactor\": \"1.5\",\n       \"maxBorrowPerTx\": \"1000\",\n       \"maxBorrowPerTxUnit\": \"USDC\"\n     }\n   }\n   EOF\n   ```\n\n4. **Verify setup**:\n   ```bash\n   scripts\u002Faave-setup.sh\n   ```\n\n## Core Usage\n\n### Check Status (allowance, health, debt)\n\n```bash\n# Full status report\nscripts\u002Faave-status.sh\n\n# Check specific asset delegation\nscripts\u002Faave-status.sh USDC\n\n# Just health factor\nscripts\u002Faave-status.sh --health-only\n```\n\n### Borrow via Delegation\n\n```bash\n# Borrow 100 USDC\nscripts\u002Faave-borrow.sh USDC 100\n\n# Borrow 0.5 WETH\nscripts\u002Faave-borrow.sh WETH 0.5\n```\n\nThe borrow script automatically:\n1. Checks delegation allowance (sufficient?)\n2. Checks delegator health factor (safe to borrow?)\n3. Executes the borrow\n4. Reports the result\n\n### Repay Debt\n\n```bash\n# Repay 100 USDC\nscripts\u002Faave-repay.sh USDC 100\n\n# Repay all USDC debt\nscripts\u002Faave-repay.sh USDC max\n```\n\nThe repay script automatically:\n1. Approves the Pool to spend the token (if needed)\n2. Executes the repay\n3. Reports remaining debt\n\n## Safety System\n\n**Every borrow operation runs these checks BEFORE executing:**\n\n1. **Delegation allowance** — Is the remaining allowance >= requested amount?\n2. **Health factor** — Is the delegator's health factor > `minHealthFactor` (default 1.5) AFTER this borrow?\n3. **Per-tx cap** — Is the amount \u003C= `maxBorrowPerTx`?\n4. **Confirmation** — Logs the full operation details before sending\n\nIf ANY check fails, the borrow is **aborted** with a clear error message.\n\n⚠️ **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.\n\n## Capabilities\n\n### Read Operations (no gas needed)\n\n- **Check delegation allowance** — How much can the agent still borrow?\n- **Check health factor** — Is the delegator's position safe?\n- **Check outstanding debt** — How much does the delegator owe on each asset?\n- **Check available liquidity** — Is there enough in the Aave pool to borrow?\n- **Resolve debt token addresses** — Look up VariableDebtToken for any asset\n\n### Write Operations (needs gas in agent wallet)\n\n- **Borrow** — Draw funds from Aave against delegated credit\n- **Repay** — Return borrowed funds to reduce delegator's debt\n- **Approve** — Approve Pool to spend tokens for repayment\n\n## Supported Chains\n\n| Chain     | Pool Address                                 | Gas Cost  |\n|-----------|----------------------------------------------|-----------|\n| Base      | `0xA238Dd80C259a72e81d7e4664a9801593F98d1c5` | Very Low  |\n| Ethereum  | `0x87870Bca3F3fD6335C3F4ce8392D69350B4fA4E2` | High      |\n| Polygon   | `0x794a61358D6845594F94dc1DB02A252b5b4814aD` | Very Low  |\n| Arbitrum  | `0x794a61358D6845594F94dc1DB02A252b5b4814aD` | Low       |\n\nSee [deployments.md](deployments.md) for full address list including debt tokens.\n\n## Common Patterns\n\n### Agent Self-Funding for Gas\n\n```bash\n# Check if we have enough gas\nBALANCE=$(cast balance $AGENT_ADDRESS --rpc-url $RPC)\nif [ \"$BALANCE\" -lt \"1000000000000000\" ]; then  # \u003C 0.001 ETH\n  # Borrow a small amount of WETH for gas\n  aave-borrow.sh WETH 0.005\nfi\n```\n\n### Borrow + Swap via Bankr\n\n```bash\n# Borrow USDC from delegated credit\naave-borrow.sh USDC 100\n# Swap to ETH using Bankr\nbankr.sh \"Swap 100 USDC for ETH on Base\"\n```\n\n### Periodic DCA\n\n```bash\n# Agent borrows USDC weekly and swaps to ETH\naave-borrow.sh USDC 100\nbankr.sh \"Swap 100 USDC for ETH on Base\"\n```\n\n### Safety-First Portfolio Rebalance\n\n```bash\n# Always check health first\naave-status.sh\n# Only borrow if healthy\naave-borrow.sh USDC 500\n```\n\n## Configuration Reference\n\n### config.json Fields\n\n| Field                    | Required | Description                                   |\n|--------------------------|----------|-----------------------------------------------|\n| `chain`                  | Yes      | Chain name (base, ethereum, polygon, arbitrum) |\n| `rpcUrl`                 | Yes      | JSON-RPC endpoint URL                         |\n| `agentPrivateKey`        | Yes      | Agent wallet private key (0x-prefixed)        |\n| `delegatorAddress`       | Yes      | User's main wallet that delegated credit      |\n| `poolAddress`            | Yes      | Aave V3 Pool contract address                 |\n| `dataProviderAddress`    | Yes      | Aave V3 PoolDataProvider address              |\n| `assets`                 | Yes      | Map of symbol → {address, decimals}           |\n| `safety.minHealthFactor` | No       | Min HF after borrow (default: 1.5)            |\n| `safety.maxBorrowPerTx`  | No       | Max borrow per transaction (default: 1000)    |\n| `safety.maxBorrowPerTxUnit` | No    | Unit for maxBorrowPerTx (default: USDC)       |\n\n### Environment Variables (override config)\n\n| Variable                    | Overrides              |\n|-----------------------------|------------------------|\n| `AAVE_RPC_URL`              | `rpcUrl`               |\n| `AAVE_AGENT_PRIVATE_KEY`    | `agentPrivateKey`      |\n| `AAVE_DELEGATOR_ADDRESS`    | `delegatorAddress`     |\n| `AAVE_POOL_ADDRESS`         | `poolAddress`          |\n| `AAVE_MIN_HEALTH_FACTOR`    | `safety.minHealthFactor` |\n\n## Error Handling\n\n| Error                        | Cause                                     | Fix                                              |\n|------------------------------|-------------------------------------------|--------------------------------------------------|\n| `INSUFFICIENT_ALLOWANCE`     | Delegation amount exceeded                | Delegator must call `approveDelegation()` again   |\n| `HEALTH_FACTOR_TOO_LOW`      | Borrow would risk liquidation             | Reduce amount or add collateral                   |\n| `AMOUNT_EXCEEDS_CAP`         | Per-tx safety cap hit                     | Reduce amount or update config                    |\n| `INSUFFICIENT_LIQUIDITY`     | Not enough in Aave pool                   | Try smaller amount or different asset             |\n| `INSUFFICIENT_GAS`           | Agent wallet has no native token          | Send gas to agent wallet                          |\n| `EMODE_MISMATCH`             | Asset incompatible with delegator's eMode | Borrow an asset in the same eMode category        |\n\n## Security\n\nSee [safety.md](safety.md) for the full threat model and emergency procedures.\n\n**Critical rules:**\n1. **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.\n2. **Never commit config.json to version control** — it contains the agent's private key\n3. **Never set `minHealthFactor` below 1.2** — liquidation happens at 1.0\n4. **Always cap delegation amounts** — never approve `type(uint256).max`\n5. **Monitor delegator health** — set up alerts if HF drops below 2.0\n6. **Agent must refuse** to borrow if safety checks fail, even if instructed to\n\n## Resources\n\n- **Aave V3 Docs**: https:\u002F\u002Fdocs.aave.com\u002Fdevelopers\n- **Credit Delegation Guide**: https:\u002F\u002Fdocs.aave.com\u002Fdevelopers\u002Fguides\u002Fcredit-delegation\n- **Aave Address Book**: https:\u002F\u002Fgithub.com\u002Fbgd-labs\u002Faave-address-book\n- **Foundry Book**: https:\u002F\u002Fbook.getfoundry.sh\u002F\n- **DebtToken Reference**: https:\u002F\u002Fdocs.aave.com\u002Fdevelopers\u002Ftokens\u002Fdebttoken\n","# Aave Credit Delegation\n\nBorrow 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.\n\n> **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\u002Fdebt in USD (8 decimals), V2 in ETH (18 decimals). The health factor safety check works correctly on both.\n\n## Compatible With\n\n- **[OpenClaw](https:\u002F\u002Fopenclaw.ai\u002F)** — Install as a skill, the agent borrows autonomously\n- **[Claude Code](https:\u002F\u002Fwww.npmjs.com\u002Fpackage\u002F@anthropic-ai\u002Fclaude-code)** — Run scripts directly from a Claude Code session\n- **Any agent framework** — Plain bash + Foundry's `cast`, works anywhere with a shell\n\nCombines with **[Bankr](https:\u002F\u002Fbankr.bot\u002F)** skills for borrow-then-swap flows: borrow USDC via delegation, then use Bankr to swap, bridge, or deploy it.\n\n## How Credit Delegation Works\n\nCredit delegation in Aave V3 separates two things: **borrowing power** and **delegation approval**.\n\n**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.\n\n**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.\n\nThis means you can, for example:\n- Deposit ETH as collateral (gives you broad borrowing power)\n- Approve the agent to borrow up to 500 USDC (via the USDC VariableDebtToken)\n- Approve the agent to borrow up to 0.1 WETH (via the WETH VariableDebtToken)\n- Leave cbETH unapproved (agent cannot borrow it at all)\n\nThe 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.\n\n```\nYour Collateral (holistic)              Delegation Approvals (isolated)\n┌─────────────────────────┐             ┌──────────────────────────────┐\n│  $5k ETH                │             │  USDC DebtToken → agent: 500 │\n│  $3k USDC               │  ───LTV───▶ │  WETH DebtToken → agent: 0.1 │\n│  $2k cbETH              │   = $8k     │  cbETH DebtToken → agent: 0  │\n│  Total: $10k @ 80% LTV  │  capacity   └──────────────────────────────┘\n└─────────────────────────┘\n```\n\n## Flow\n\n```\nDelegator (your wallet)                 Agent Wallet (delegatee)\n    │                                        │\n    │  1. supply collateral to Aave          │\n    │  2. approveDelegation(agent, amount)   │\n    │        on the VariableDebtToken        │\n    │                                        │\n    │            ┌─── 3. borrow(asset,       │\n    │            │       amount, onBehalfOf   │\n    │            │       = delegator)         │\n    │            │                            │\n    │     [debt on YOUR position]    [tokens in agent wallet]\n    │            │                            │\n    │            └─── 4. repay(asset,         │\n    │                    amount, onBehalfOf   │\n    │                    = delegator)         │\n```\n\n## Quick Start\n\n### Prerequisites\n\n1. **Foundry** must be installed (`cast` CLI):\n   ```bash\n   curl -L https:\u002F\u002Ffoundry.paradigm.xyz | bash && foundryup\n   ```\n\n2. **Delegator setup** (done ONCE by the user, NOT the agent):\n   - Supply collateral to Aave V3 (via app.aave.com or contract)\n   - Call `approveDelegation(agentAddress, maxAmount)` on the **VariableDebtToken** of the asset you want the agent to borrow\n   - The VariableDebtToken address can be found via: `cast call $DATA_PROVIDER \"getReserveTokensAddresses(address)(address,address,address)\" $ASSET --rpc-url $RPC`\n\n3. **Configure the skill**:\n   ```bash\n   mkdir -p ~\u002F.openclaw\u002Fskills\u002Faave-delegation\n   cat > ~\u002F.openclaw\u002Fskills\u002Faave-delegation\u002Fconfig.json \u003C\u003C 'EOF'\n   {\n     \"chain\": \"base\",\n     \"rpcUrl\": \"https:\u002F\u002Fmainnet.base.org\",\n     \"agentPrivateKey\": \"0xYOUR_AGENT_PRIVATE_KEY\",\n     \"delegatorAddress\": \"0xYOUR_MAIN_WALLET\",\n     \"poolAddress\": \"0xA238Dd80C259a72e81d7e4664a9801593F98d1c5\",\n     \"dataProviderAddress\": \"0x2d8A3C5677189723C4cB8873CfC9C8976FDF38Ac\",\n     \"assets\": {\n       \"USDC\": {\n         \"address\": \"0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913\",\n         \"decimals\": 6\n       },\n       \"WETH\": {\n         \"address\": \"0x4200000000000000000000000000000000000006\",\n         \"decimals\": 18\n       }\n     },\n     \"safety\": {\n       \"minHealthFactor\": \"1.5\",\n       \"maxBorrowPerTx\": \"1000\",\n       \"maxBorrowPerTxUnit\": \"USDC\"\n     }\n   }\n   EOF\n   ```\n\n4. **Verify setup**:\n   ```bash\n   scripts\u002Faave-setup.sh\n   ```\n\n## Core Usage\n\n### Check Status (allowance, health, debt)\n\n```bash\n# Full status report\nscripts\u002Faave-status.sh\n\n# Check specific asset delegation\nscripts\u002Faave-status.sh USDC\n\n# Just health factor\nscripts\u002Faave-status.sh --health-only\n```\n\n### Borrow via Delegation\n\n```bash\n# Borrow 100 USDC\nscripts\u002Faave-borrow.sh USDC 100\n\n# Borrow 0.5 WETH\nscripts\u002Faave-borrow.sh WETH 0.5\n```\n\nThe borrow script automatically:\n1. Checks delegation allowance (sufficient?)\n2. Checks delegator health factor (safe to borrow?)\n3. Executes the borrow\n4. Reports the result\n\n### Repay Debt\n\n```bash\n# Repay 100 USDC\nscripts\u002Faave-repay.sh USDC 100\n\n# Repay all USDC debt\nscripts\u002Faave-repay.sh USDC max\n```\n\nThe repay script automatically:\n1. Approves the Pool to spend the token (if needed)\n2. Executes the repay\n3. Reports remaining debt\n\n## Safety System\n\n**Every borrow operation runs these checks BEFORE executing:**\n\n1. **Delegation allowance** — Is the remaining allowance >= requested amount?\n2. **Health factor** — Is the delegator's health factor > `minHealthFactor` (default 1.5) AFTER this borrow?\n3. **Per-tx cap** — Is the amount \u003C= `maxBorrowPerTx`?\n4. **Confirmation** — Logs the full operation details before sending\n\nIf ANY check fails, the borrow is **aborted** with a clear error message.\n\n⚠️ **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.\n\n## Capabilities\n\n### Read Operations (no gas needed)\n\n- **Check delegation allowance** — How much can the agent still borrow?\n- **Check health factor** — Is the delegator's position safe?\n- **Check outstanding debt** — How much does the delegator owe on each asset?\n- **Check available liquidity** — Is there enough in the Aave pool to borrow?\n- **Resolve debt token addresses** — Look up VariableDebtToken for any asset\n\n### Write Operations (needs gas in agent wallet)\n\n- **Borrow** — Draw funds from Aave against delegated credit\n- **Repay** — Return borrowed funds to reduce delegator's debt\n- **Approve** — Approve Pool to spend tokens for repayment\n\n## Supported Chains\n\n| Chain     | Pool Address                                 | Gas Cost  |\n|-----------|----------------------------------------------|-----------|\n| Base      | `0xA238Dd80C259a72e81d7e4664a9801593F98d1c5` | Very Low  |\n| Ethereum  | `0x87870Bca3F3fD6335C3F4ce8392D69350B4fA4E2` | High      |\n| Polygon   | `0x794a61358D6845594F94dc1DB02A252b5b4814aD` | Very Low  |\n| Arbitrum  | `0x794a61358D6845594F94dc1DB02A252b5b4814aD` | Low       |\n\nSee [deployments.md](deployments.md) for full address list including debt tokens.\n\n## Common Patterns\n\n### Agent Self-Funding for Gas\n\n```bash\n# Check if we have enough gas\nBALANCE=$(cast balance $AGENT_ADDRESS --rpc-url $RPC)\nif [ \"$BALANCE\" -lt \"1000000000000000\" ]; then  # \u003C 0.001 ETH\n  # Borrow a small amount of WETH for gas\n  aave-borrow.sh WETH 0.005\nfi\n```\n\n### Borrow + Swap via Bankr\n\n```bash\n# Borrow USDC from delegated credit\naave-borrow.sh USDC 100\n# Swap to ETH using Bankr\nbankr.sh \"Swap 100 USDC for ETH on Base\"\n```\n\n### Periodic DCA\n\n```bash\n# Agent borrows USDC weekly and swaps to ETH\naave-borrow.sh USDC 100\nbankr.sh \"Swap 100 USDC for ETH on Base\"\n```\n\n### Safety-First Portfolio Rebalance\n\n```bash\n# Always check health first\naave-status.sh\n# Only borrow if healthy\naave-borrow.sh USDC 500\n```\n\n## Configuration Reference\n\n### config.json Fields\n\n| Field                    | Required | Description                                   |\n|--------------------------|----------|-----------------------------------------------|\n| `chain`                  | Yes      | Chain name (base, ethereum, polygon, arbitrum) |\n| `rpcUrl`                 | Yes      | JSON-RPC endpoint URL                         |\n| `agentPrivateKey`        | Yes      | Agent wallet private key (0x-prefixed)        |\n| `delegatorAddress`       | Yes      | User's main wallet that delegated credit      |\n| `poolAddress`            | Yes      | Aave V3 Pool contract address                 |\n| `dataProviderAddress`    | Yes      | Aave V3 PoolDataProvider address              |\n| `assets`                 | Yes      | Map of symbol → {address, decimals}           |\n| `safety.minHealthFactor` | No       | Min HF after borrow (default: 1.5)            |\n| `safety.maxBorrowPerTx`  | No       | Max borrow per transaction (default: 1000)    |\n| `safety.maxBorrowPerTxUnit` | No    | Unit for maxBorrowPerTx (default: USDC)       |\n\n### Environment Variables (override config)\n\n| Variable                    | Overrides              |\n|-----------------------------|------------------------|\n| `AAVE_RPC_URL`              | `rpcUrl`               |\n| `AAVE_AGENT_PRIVATE_KEY`    | `agentPrivateKey`      |\n| `AAVE_DELEGATOR_ADDRESS`    | `delegatorAddress`     |\n| `AAVE_POOL_ADDRESS`         | `poolAddress`          |\n| `AAVE_MIN_HEALTH_FACTOR`    | `safety.minHealthFactor` |\n\n## Error Handling\n\n| Error                        | Cause                                     | Fix                                              |\n|------------------------------|-------------------------------------------|--------------------------------------------------|\n| `INSUFFICIENT_ALLOWANCE`     | Delegation amount exceeded                | Delegator must call `approveDelegation()` again   |\n| `HEALTH_FACTOR_TOO_LOW`      | Borrow would risk liquidation             | Reduce amount or add collateral                   |\n| `AMOUNT_EXCEEDS_CAP`         | Per-tx safety cap hit                     | Reduce amount or update config                    |\n| `INSUFFICIENT_LIQUIDITY`     | Not enough in Aave pool                   | Try smaller amount or different asset             |\n| `INSUFFICIENT_GAS`           | Agent wallet has no native token          | Send gas to agent wallet                          |\n| `EMODE_MISMATCH`             | Asset incompatible with delegator's eMode | Borrow an asset in the same eMode category        |\n\n## Security\n\nSee [safety.md](safety.md) for the full threat model and emergency procedures.\n\n**Critical rules:**\n1. **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.\n2. **Never commit config.json to version control** — it contains the agent's private key\n3. **Never set `minHealthFactor` below 1.2** — liquidation happens at 1.0\n4. **Always cap delegation amounts** — never approve `type(uint256).max`\n5. **Monitor delegator health** — set up alerts if HF drops below 2.0\n6. **Agent must refuse** to borrow if safety checks fail, even if instructed to\n\n## Resources\n\n- **Aave V3 Docs**: https:\u002F\u002Fdocs.aave.com\u002Fdevelopers\n- **Credit Delegation Guide**: https:\u002F\u002Fdocs.aave.com\u002Fdevelopers\u002Fguides\u002Fcredit-delegation\n- **Aave Address Book**: https:\u002F\u002Fgithub.com\u002Fbgd-labs\u002Faave-address-book\n- **Foundry Book**: https:\u002F\u002Fbook.getfoundry.sh\u002F\n- **DebtToken Reference**: https:\u002F\u002Fdocs.aave.com\u002Fdevelopers\u002Ftokens\u002Fdebttoken\n",{"name":5,"description":7},"main","e7e336ac628c3e3bd771aff1aaa469c93778f94a","skills\u002Faaronjmars\u002Fagent-credit",0,"https:\u002F\u002Fgithub.com\u002Fkbarbel640-del\u002Fskills","https:\u002F\u002Fgithub.com\u002Fkbarbel640-del","2026-08-23 22:39:37",{"source":8,"skillName":5,"commands":39,"prompt":49,"zipAvailable":50},[40,43,46],{"tool":41,"command":42},"npx","npx skills add kbarbel640-del\u002Fskills --skill agent-credit",{"tool":44,"command":45},"bunx","bunx skills add kbarbel640-del\u002Fskills --skill agent-credit",{"tool":47,"command":48},"pnpm","pnpm dlx skills add kbarbel640-del\u002Fskills --skill agent-credit","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002Fkbarbel640-del\u002Fskills\u002Fblob\u002Fmain\u002Fskills\u002Faaronjmars\u002Fagent-credit\u002FSKILL.md",true,[52,58,64,68,72,76,80,84,88,92],{"path":53,"resourceType":54,"resourceTypeDesc":55,"sizeBytes":56,"sourceHtmlUrl":57},"_meta.json","REFERENCE","参考文档",280,"https:\u002F\u002Fgithub.com\u002Fkbarbel640-del\u002Fskills\u002Fblob\u002Fmain\u002Fskills\u002Faaronjmars\u002Fagent-credit\u002F_meta.json",{"path":59,"resourceType":60,"resourceTypeDesc":61,"sizeBytes":62,"sourceHtmlUrl":63},"aave-borrow.sh","SCRIPT","脚本",9190,"https:\u002F\u002Fgithub.com\u002Fkbarbel640-del\u002Fskills\u002Fblob\u002Fmain\u002Fskills\u002Faaronjmars\u002Fagent-credit\u002Faave-borrow.sh",{"path":65,"resourceType":60,"resourceTypeDesc":61,"sizeBytes":66,"sourceHtmlUrl":67},"aave-repay.sh",6862,"https:\u002F\u002Fgithub.com\u002Fkbarbel640-del\u002Fskills\u002Fblob\u002Fmain\u002Fskills\u002Faaronjmars\u002Fagent-credit\u002Faave-repay.sh",{"path":69,"resourceType":60,"resourceTypeDesc":61,"sizeBytes":70,"sourceHtmlUrl":71},"aave-setup.sh",7080,"https:\u002F\u002Fgithub.com\u002Fkbarbel640-del\u002Fskills\u002Fblob\u002Fmain\u002Fskills\u002Faaronjmars\u002Fagent-credit\u002Faave-setup.sh",{"path":73,"resourceType":60,"resourceTypeDesc":61,"sizeBytes":74,"sourceHtmlUrl":75},"aave-status.sh",5768,"https:\u002F\u002Fgithub.com\u002Fkbarbel640-del\u002Fskills\u002Fblob\u002Fmain\u002Fskills\u002Faaronjmars\u002Fagent-credit\u002Faave-status.sh",{"path":77,"resourceType":54,"resourceTypeDesc":55,"sizeBytes":78,"sourceHtmlUrl":79},"config.example.json",749,"https:\u002F\u002Fgithub.com\u002Fkbarbel640-del\u002Fskills\u002Fblob\u002Fmain\u002Fskills\u002Faaronjmars\u002Fagent-credit\u002Fconfig.example.json",{"path":81,"resourceType":54,"resourceTypeDesc":55,"sizeBytes":82,"sourceHtmlUrl":83},"contracts.md",4397,"https:\u002F\u002Fgithub.com\u002Fkbarbel640-del\u002Fskills\u002Fblob\u002Fmain\u002Fskills\u002Faaronjmars\u002Fagent-credit\u002Fcontracts.md",{"path":85,"resourceType":54,"resourceTypeDesc":55,"sizeBytes":86,"sourceHtmlUrl":87},"deployments.md",10235,"https:\u002F\u002Fgithub.com\u002Fkbarbel640-del\u002Fskills\u002Fblob\u002Fmain\u002Fskills\u002Faaronjmars\u002Fagent-credit\u002Fdeployments.md",{"path":89,"resourceType":54,"resourceTypeDesc":55,"sizeBytes":90,"sourceHtmlUrl":91},"README.md",11019,"https:\u002F\u002Fgithub.com\u002Fkbarbel640-del\u002Fskills\u002Fblob\u002Fmain\u002Fskills\u002Faaronjmars\u002Fagent-credit\u002FREADME.md",{"path":93,"resourceType":54,"resourceTypeDesc":55,"sizeBytes":94,"sourceHtmlUrl":95},"safety.md",5271,"https:\u002F\u002Fgithub.com\u002Fkbarbel640-del\u002Fskills\u002Fblob\u002Fmain\u002Fskills\u002Faaronjmars\u002Fagent-credit\u002Fsafety.md",[97,128,153,174,180,200],{"skillNo":98,"name":99,"nameZh":6,"description":100,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":101,"categories":102,"keywords":108,"publishedAt":26},"01M6G8J55967D6281ACMKAKTEQ","crowd-prompting","A marketplace where AI agents improve prompts, system instructions, tool descriptions, and other text-based content with domain expertise from real-world operations — and earn tokens for valuable contributions.","https:\u002F\u002Fgithub.com\u002Fkbarbel640-del\u002Fskills\u002Fblob\u002Fmain\u002Fskills\u002Fzzadrian\u002Fcrowd-prompting\u002FSKILL.md",[103],{"categoryNo":104,"categoryName":105,"taxonomyType":106,"taxonomyTypeDesc":107},"01JBSEEDCAT000000000000036","内容创作者","PROFESSION","适用职业",[109,110,111,112,113,114,115,116,117,118,119,120,121,122,123,124,125,126,127],"crowd prompting","prompting","api","with","tokens","domain","world","prompts","operations","instructions","text","tool","system","improve","productivity","marketplace","https","content","ai agents",{"skillNo":129,"name":130,"nameZh":6,"description":131,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":132,"categories":133,"keywords":135,"publishedAt":26},"01M6G8J0PKPAYVET6BWE8W4C26","dilemm-ai","Compete in DilemmAI, the prisoner's dilemma AI arena at dilemm.ai. Use when an OpenClaw agent wants to create an account, design and submit strategy prompts for their bot, enter matchmaking, analyze historical matches and leaderboards, and iterate on bot strategy. Requires headless browser automation (no API available yet).","https:\u002F\u002Fgithub.com\u002Fkbarbel640-del\u002Fskills\u002Fblob\u002Fmain\u002Fskills\u002Fzyori\u002Fdilemm-ai\u002FSKILL.md",[134],{"categoryNo":18,"categoryName":19,"taxonomyType":20,"taxonomyTypeDesc":21},[136,111,137,138,139,140,141,142,143,144,145,146,147,148,149,150,151,116,152],"dilemm ai","arena","analyze","browser","openclaw agent","create","automation","browser automation","bot","openclaw","design","strategy","headless","compete","submit","matchmaking","use",{"skillNo":154,"name":155,"nameZh":6,"description":156,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":157,"categories":158,"keywords":162,"publishedAt":26},"01M6G8HWAF3K9SW7NP3Z83CPJ6","arxiv-paper-reviews","Interact with arXiv Crawler API to fetch papers, read reviews, and submit comments. Use when working with arXiv papers, fetching paper lists by date\u002Fcategory\u002Finterest, viewing paper details with comments, or submitting paper reviews via API at http:\u002F\u002F150.158.152.82:8000.","https:\u002F\u002Fgithub.com\u002Fkbarbel640-del\u002Fskills\u002Fblob\u002Fmain\u002Fskills\u002Fzxrys\u002Fweak-accept\u002FSKILL.md",[159],{"categoryNo":160,"categoryName":161,"taxonomyType":20,"taxonomyTypeDesc":21},"01JBSEEDCAT000000000000021","资料检索与研究",[163,164,165,166,167,168,169,112,170,150,152,171,111,172,173],"arxiv paper reviews","reviews","arxiv","paper","crawler","papers","comments","fetch","read","http","via",{"skillNo":175,"name":155,"nameZh":6,"description":156,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":176,"categories":177,"keywords":179,"publishedAt":26},"01M6G8HQJ7N7WMY6YV7D7SSJ16","https:\u002F\u002Fgithub.com\u002Fkbarbel640-del\u002Fskills\u002Fblob\u002Fmain\u002Fskills\u002Fzxrys\u002Farxiv-paper-reviews\u002FSKILL.md",[178],{"categoryNo":160,"categoryName":161,"taxonomyType":20,"taxonomyTypeDesc":21},[166,165,164,163,173,168,169,112,167,150,152,170,171,111,172],{"skillNo":181,"name":182,"nameZh":6,"description":183,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":184,"categories":185,"keywords":186,"publishedAt":26},"01M6G8HM95Y64JNVFC2HN4E2BG","git-summary","Get a quick summary of the current Git repository including status, recent commits, branches, and contributors.","https:\u002F\u002Fgithub.com\u002Fkbarbel640-del\u002Fskills\u002Fblob\u002Fmain\u002Fskills\u002Fzweack\u002Fgit-summary\u002FSKILL.md",[],[187,188,189,190,191,192,193,194,195,196,197,198,199],"git","summary","git summary","commits","repository","win32","status","linux","contributors","true","quick","get","branches",{"skillNo":201,"name":202,"nameZh":6,"description":203,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":204,"categories":205,"keywords":210,"publishedAt":26},"01M6G8HGEGF05CNEJCGVYFSC4R","agent-constitution","Interact with AgentConstitution governance contracts on Base Sepolia. Check compliance, read rules, log actions, query governance state.","https:\u002F\u002Fgithub.com\u002Fkbarbel640-del\u002Fskills\u002Fblob\u002Fmain\u002Fskills\u002Fztsalexey\u002Fagent-constitution\u002FSKILL.md",[206,207],{"categoryNo":18,"categoryName":19,"taxonomyType":20,"taxonomyTypeDesc":21},{"categoryNo":208,"categoryName":209,"taxonomyType":106,"taxonomyTypeDesc":107},"01JBSEEDCAT000000000000037","律师与法务",[211,212,213,214,112,215,216,31,217,171,218,219,220,221,222,125,223,224,225],"agent constitution","constitution","contracts","tree","query","base","log","check","Rules","projects","compliance","actions","state","governance","github"]