Communitygithub.com

Aave 信用委托 (Credit Delegation)

通过信用委托从 Aave 借入资金。代理通过借用委托人的抵押品来自我融资。支持借贷、偿还和健康检查。适用于 Aave V2/V3。

Aave 信用委托 (Credit Delegation) 是什么?

该技能使 AI 代理能够通过 Aave 协议的信用委托功能自主借入资金。其核心机制是,用户的主钱包提供抵押品,并通过调用 `approveDelegation()` 在特定的可变债务代币(VariableDebtToken)上授权代理借入特定资产和金额。代理钱包随后可代表用户执行借贷(borrow)和偿还(repay)操作,产生的债务将记入用户的抵押品头寸。该技能提供了一套完整的 Bash 脚本,用于检查状态(信用额度、健康因子、债务)、借入和偿还代币,并内置了严格的安全检查系统,在每笔借贷前验证信用额度、健康因子和单笔限额。技能兼容 OpenClaw、Claude Code 等框架,并可与 Bankr 等技能组合实现借贷后立即交换的自动化流程。

兼容平台✓Claude Code~Codex CLI~Cursor
npx skills add https://github.com/modbender/skill-library-mcp/tree/HEAD/data/agent-credit

在你喜欢的 AI 中提问

打开一个已预加载此 Agent Skill 的新对话。

文档

Aave 信用委托

使用 Aave 的委托信用借入资金。您的主钱包提供抵押品,并将借贷权委托给代理钱包。代理随后可以在需要时自主借入代币—债务会累积在委托人的头寸上。

协议: 适用于 Aave V3 和 Aave V2 — 信用委托的函数签名(borrow、repay、approveDelegation、borrowAllowance)在两个版本中完全相同。只需替换 V2 的 LendingPool 和 ProtocolDataProvider 地址即可。唯一的细微差别:V3 以 USD(8 位小数)返回抵押品/债务,V2 以 ETH(18 位小数)返回。健康因子安全检查在两个版本中均可正常工作。

兼容平台

  • OpenClaw — 作为技能安装,代理自主借贷
  • Claude Code — 直接从 Claude Code 会话运行脚本
  • 任何代理框架 — 纯 Bash + Foundry 的 cast,任何有 shell 的环境都可用

可与 Bankr 技能组合,实现借贷后交换的流程:通过委托借入 USDC,然后使用 Bankr 进行交换、桥接或部署。

信用委托如何工作

Aave V3 中的信用委托将借贷能力与委托授权分开。

借贷能力是整体的。 它来自您在所有资产中的整个抵押品头寸。如果您存入价值 1 万美元的 ETH,LTV 为 80%,您就拥有 8000 美元的借贷能力—就是这样。这个借贷能力并不锁定于任何特定资产。

委托授权是针对每个债务代币隔离的。 您通过调用各个 VariableDebtToken 上的 approveDelegation() 来控制代理可以借入哪些资产以及每种资产借入多少。每种资产都有自己的债务代币合约,每个授权都是独立的。

这意味着您可以,例如:

  • 存入 ETH 作为抵押品(为您提供广泛的借贷能力)
  • 授权代理最多借入 500 USDC(通过 USDC VariableDebtToken)
  • 授权代理最多借入 0.1 WETH(通过 WETH VariableDebtToken)
  • 保留 cbETH 未经授权(代理完全无法借入它)

代理只能借入您明确授权的资产,且金额受限于您设定的额度—但借贷的能力来自您的总抵押品,而非任何单一存款。

您的抵押品(整体)                 委托授权(隔离)
┌─────────────────────────┐        ┌──────────────────────────────┐
│  5000 美元 ETH                │        │  USDC DebtToken → 代理: 500    │
│  3000 美元 USDC               │  ───LTV───▶  │  WETH DebtToken → 代理: 0.1  │
│  2000 美元 cbETH              │   = 8000 美元  │  cbETH DebtToken → 代理: 0   │
│  总计: 10000 美元 @ 80% LTV  │  能力    └──────────────────────────────┘
└─────────────────────────┘

流程

委托人(您的钱包)                  代理钱包(被委托人)
    │                                        │
    │  1. 向 Aave 提供抵押品                 │
    │  2. 在 VariableDebtToken 上调用        │
    │     approveDelegation(代理, 金额)      │
    │                                        │
    │            ┌─── 3. borrow(资产,        │
    │            │       金额, onBehalfOf    │
    │            │       = 委托人)            │
    │            │                            │
    │     [债务在您的头寸上]        [代币在代理钱包中]
    │            │                            │
    │            └─── 4. repay(资产,         │
    │                    金额, onBehalfOf    │
    │                    = 委托人)            │

快速开始

前提条件

  1. 必须安装 Foundry(cast CLI):

    curl -L https://foundry.paradigm.xyz | bash && foundryup
    
  2. 委托人设置(由用户执行一次,代理不执行):

    • 向 Aave V3 提供抵押品(通过 app.aave.com 或合约)
    • 在您希望代理借入的资产的 VariableDebtToken 上调用 approveDelegation(agentAddress, maxAmount)
    • VariableDebtToken 地址可通过以下方式查找:cast call $DATA_PROVIDER "getReserveTokensAddresses(address)(address,address,address)" $ASSET --rpc-url $RPC
  3. 配置技能:

    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
    
  4. 验证设置:

    scripts/aave-setup.sh
    

核心用法

检查状态(额度、健康、债务)

# 完整状态报告
scripts/aave-status.sh

# 检查特定资产委托
scripts/aave-status.sh USDC

# 仅健康因子
scripts/aave-status.sh --health-only

通过委托借贷

# 借入 100 USDC
scripts/aave-borrow.sh USDC 100

# 借入 0.5 WETH
scripts/aave-borrow.sh WETH 0.5

借贷脚本自动:

  1. 检查委托额度(充足吗?)
  2. 检查委托人健康因子(借贷安全吗?)
  3. 执行借贷
  4. 报告结果

偿还债务

# 偿还 100 USDC
scripts/aave-repay.sh USDC 100

# 偿还所有 USDC 债务
scripts/aave-repay.sh USDC max

偿还脚本自动:

  1. 授权池花费该代币(如果需要)
  2. 执行偿还
  3. 报告剩余债务

安全系统

每次借贷操作在执行前都会运行以下检查:

  1. 委托额度 — 剩余额度 >= 请求金额?
  2. 健康因子 — 此次借贷后委托人的健康因子 > minHealthFactor(默认 1.5)?
  3. 单笔限额 — 金额 <= maxBorrowPerTx?
  4. 确认 — 在发送前记录完整操作详情

如果任何检查失败,借贷将被中止并显示清晰的错误信息。

⚠️ 代理绝不能绕过安全检查。 如果用户要求代理借贷但健康因子过低,代理应拒绝并解释原因。

能力

读取操作(无需 Gas)

  • 检查委托额度 — 代理还能借多少?
  • 检查健康因子 — 委托人的头寸安全吗?
  • 检查未偿债务 — 委托人每种资产欠多少?
  • 检查可用流动性 — Aave 池中是否有足够资金可借?
  • 解析债务代币地址 — 查找任意资产的 VariableDebtToken

写入操作(代理钱包需 Gas)

  • 借贷 — 从 Aave 提取资金,使用委托信用
  • 偿还 — 归还借入资金以减少委托人债务
  • 授权 — 授权池花费代币用于还款

支持的网络

网络池合约地址Gas 费用
Base0xA238Dd80C259a72e81d7e4664a9801593F98d1c5非常低
Ethereum0x87870Bca3F3fD6335C3F4ce8392D69350B4fA4E2高
Polygon0x794a61358D6845594F94dc1DB02A252b5b4814aD非常低
Arbitrum0x794a61358D6845594F94dc1DB02A252b5b4814aD低

查看 deployments.md 获取包括债务代币在内的完整地址列表。

常见模式

代理 Gas 自融资

# 检查是否有足够的 Gas
BALANCE=$(cast balance $AGENT_ADDRESS --rpc-url $RPC)
if [ "$BALANCE" -lt "1000000000000000" ]; then  # < 0.001 ETH
  # 借入少量 WETH 作为 Gas
  aave-borrow.sh WETH 0.005
fi

通过 Bankr 借贷 + 交换

# 从委托信用中借入 USDC
aave-borrow.sh USDC 100
# 使用 Bankr 交换为 ETH
bankr.sh "Swap 100 USDC for ETH on Base"

定期 DCA

# 代理每周借入 USDC 并交换为 ETH
aave-borrow.sh USDC 100
bankr.sh "Swap 100 USDC for ETH on Base"

安全优先的投资组合再平衡

# 始终先检查健康状态
aave-status.sh
# 仅在健康时借贷
aave-borrow.sh USDC 500

配置参考

config.json 字段

字段必需描述
chain是网络名称 (base, ethereum, polygon, arbitrum)
rpcUrl是JSON-RPC 端点 URL
agentPrivateKey是代理钱包私钥(0x 前缀)
delegatorAddress是委托信用的用户主钱包地址
poolAddress是Aave V3 池合约地址
dataProviderAddress是Aave V3 PoolDataProvider 地址
assets是符号 → {地址, 小数位} 的映射
safety.minHealthFactor否借贷后的最小 HF(默认: 1.5)
safety.maxBorrowPerTx否每笔交易最大借贷额(默认: 1000)
safety.maxBorrowPerTxUnit否maxBorrowPerTx 的单位(默认: USDC)

环境变量(覆盖配置)

变量覆盖项
AAVE_RPC_URLrpcUrl
AAVE_AGENT_PRIVATE_KEYagentPrivateKey
AAVE_DELEGATOR_ADDRESSdelegatorAddress
AAVE_POOL_ADDRESSpoolAddress
AAVE_MIN_HEALTH_FACTORsafety.minHealthFactor

错误处理

错误原因修复
INSUFFICIENT_ALLOWANCE超过了委托金额委托人必须再次调用 approveDelegation()
HEALTH_FACTOR_TOO_LOW借贷会面临清算风险减少金额或增加抵押品
AMOUNT_EXCEEDS_CAP达到每笔交易安全限额减少金额或更新配置
INSUFFICIENT_LIQUIDITYAave 池中资金不足尝试较小金额或不同资产
INSUFFICIENT_GAS代理钱包没有原生代币向代理钱包发送 Gas
EMODE_MISMATCH资产与委托人的 eMode 不兼容借入与同一 eMode 类别中的资产

安全性

查看 safety.md 了解完整的威胁模型和应急程序。

关键规则:

  1. 委托人的私钥绝不能出现在此仓库、配置或脚本中 — 这是代理的工作空间。委托人通过 Aave UI 或区块浏览器管理自己的一侧。
  2. 永远不要将 config.json 提交到版本控制 — 它包含代理的私钥
  3. 永远不要将 minHealthFactor 设置为低于 1.2 — 清算在 1.0 发生
  4. 始终限制委托金额 — 永远不要批准 type(uint256).max
  5. 监控委托人健康 — 如果 HF 低于 2.0 则设置警报
  6. 代理必须拒绝 在安全检查失败时借贷,即使被指示也要拒绝

资源

Individual skills in this repo

This repo contains 20 individual skills — each has its own dedicated page.

modbender/skill-library-mcp

Paid acquisition strategy, budget allocation, and avoiding common advertising mistakes across platforms

modbender/skill-library-mcp

Complete investment portfolio risk management system. Analyze positions, calculate risk metrics, stress test scenarios, optimize allocations, and generate institutional-grade risk reports — all wit...

modbender/skill-library-mcp

Discover and register autonomous AI agents. Use when: browsing the agent registry, submitting an agent for verification, or embedding agent badges. NOT for: general web search or agent capability analysis.

modbender/skill-library-mcp

Create AI avatar and talking head videos with OmniHuman, Fabric, PixVerse via inference.sh CLI. Models: OmniHuman 1.5, OmniHuman 1.0, Fabric 1.0, PixVerse Lipsync. Capabilities: audio-driven avatars, lipsync videos, talking head generation, virtual presenters. Use for: AI presenters, explainer videos, virtual influencers, dubbing, marketing videos. Triggers: ai avatar, talking head, lipsync, avatar video, virtual presenter, ai spokesperson, audio driven video, heygen alternative, synthesia alternative, talking avatar, lip sync, video avatar, ai presenter, digital human

modbender/skill-library-mcp

AI代码编辑器规则模板集合 - 为Cursor、Windsurf、Claude Code、Cline等AI编辑器提供项目规则配置。适用于需要配置AI编码助手规则的开发者,包含全栈Web、移动端、Vue3+SpringBoot等技术栈模板。

modbender/skill-library-mcp

Generate landing page code from product descriptions

modbender/skill-library-mcp

Create AI marketing videos for ads, promos, product launches, and brand content. Models: Veo, Seedance, Wan, FLUX for visuals, Kokoro for voiceover. Types: product demos, testimonials, explainers, social ads, brand videos. Use for: Facebook ads, YouTube ads, product launches, brand awareness. Triggers: marketing video, ad video, promo video, commercial, brand video, product video, explainer video, ad creative, video ad, facebook ad video, youtube ad, instagram ad, tiktok ad, promotional video, launch video

modbender/skill-library-mcp

Generate AI music videos end-to-end. Creates music with Suno (sunoapi.org), generates visuals with OpenAI/Seedream/Google/Seedance, and assembles into music video with ffmpeg. Supports timestamped lyrics (auto SRT), Suno native music video generation, slideshow/video/hybrid modes. Token-based cost tracking per generation.

modbender/skill-library-mcp

Generate AI-powered notes from videos (document, outline, or graphic-text formats)

modbender/skill-library-mcp

The video AI notes tool is provided by Baidu. Based on the video download address provided by the user, it downloads and parses the video, and finally generates AI notes corresponding to the video (a total of three types of notes can be generated: document notes, outline notes, and image-text notes).

modbender/skill-library-mcp

Automated appointment management for beauty salons, clinics, studios, and photo booths. Handles booking requests, calendar sync, conflict detection, reminders, no-show tracking, and waitlist management.

modbender/skill-library-mcp

Bird identification, life list tracking, and trading card generation. Use this skill when the user: sends a bird photo to identify, says "set up my Birdfolio" or "set my region", asks "how's my checklist", asks "Birdfolio progress", asks "how many birds have I found", asks "show my Birdfolio" or "show my life list", asks "what's my rarest bird", or asks "tell me about [bird species]". Handles everything from first-time setup through ongoing life list tracking and visual trading card generation.

modbender/skill-library-mcp

Multi-project task and research management (JSON-first CLI)

modbender/skill-library-mcp

Track stock and crypto portfolios with CLI - real-time prices, P&L, dividend tracking, multiple portfolios

modbender/skill-library-mcp

Track cryptocurrency portfolios with real-time prices, P&L calculations, and allocation analysis. Query Bitcoin, Ethereum, Solana and 10,000+ token holdings.

modbender/skill-library-mcp

加密貨幣Portfolio追蹤 - 支援TRON/ETH/BSC,分析持倉、收益、Gas費用

modbender/skill-library-mcp

Lead strategy with competitive analysis, strategic planning, growth roadmaps, and business portfolio management.

modbender/skill-library-mcp

Create ATS-optimized resumes and CVs with proper structure, metrics, and industry targeting.

modbender/skill-library-mcp

Use this skill when the user asks to build, create, design, develop, or improve ANY frontend interface, web page, UI component, or visual element. This includes: - Building landing pages, websites, web apps, dashboards, portfolios, or any web interface - Creating UI components (buttons, forms, cards, navbars, modals, etc.) - Designing pages with React, Vue, Next.js, Svelte, or any frontend framework - Adding styling or improving visual design of existing components - Implementing specific design aesthetics (modern, dark, minimalist, brutalist, etc.) - User mentions "frontend", "UI", "UX", "design", "interface", "web design", or "styling" - User asks for "beautiful", "modern", "professional", "clean", or any aesthetic adjective - User requests help with CSS, Tailwind, styled-components, or any styling approach This skill automatically retrieves the appropriate design system prompt (Neo-brutalism, Modern Dark, Bauhaus, Cyberpunk, Material, etc.) to help create visually distinctive, production-grade frontend...

modbender/skill-library-mcp

Native video analysis using Google Gemini API. Upload and analyze video files — describe scenes, extract text/UI, answer questions about content, transcribe speech, identify objects and actions. Use when: (1) User sends a video file and wants it analyzed, (2) Video summarization or description needed, (3) Extracting text, UI elements, or information from screen recordings, (4) Answering questions about video content, (5) Comparing multiple videos, (6) Analyzing tutorials, demos, or walkthroughs.

相关技能