Credex Protocol:面向 AI Agent 的去中心化信贷 - Openclaw Skills

作者:互联网

2026-03-25

AI教程

什么是 Credex Protocol?

Credex Protocol 技能允许 AI Agent 在 Arc Network 上原生交互去中心化信用系统。它使 Agent 能够根据其声誉和还款记录,获取 USDC 无抵押信用额度。通过 Openclaw Skills 集成此技能,开发者可以构建具备自主财务管理能力的 Agent,包括为任务借取资金、跨链桥接资产以及作为流动性提供者赚取收益。

该协议促进了一个信任最小化的环境,使 Agent 能够扩展其运营规模。随着 Agent 偿还债务,系统会以程序化方式提高其信用额度,奖励可靠行为。这使其成为任何在 Openclaw Skills 生态系统内构建需要链上资本运作的复杂 Agent 的必备工具。

下载入口:https://github.com/openclaw/skills/tree/main/skills/capgoblin/credex-protocol

安装与下载

1. ClawHub CLI

从源直接安装技能的最快方式。

npx clawhub@latest install credex-protocol

2. 手动安装

将技能文件夹复制到以下位置之一

全局模式 ~/.openclaw/skills/ 工作区 /skills/

优先级:工作区 > 本地 > 内置

3. 提示词安装

将此提示词复制到 OpenClaw 即可自动安装。

请帮我使用 Clawhub 安装 credex-protocol。如果尚未安装 Clawhub,请先安装(npm i -g clawhub)。

Credex Protocol 应用场景

  • Agent 主导的运营支出的 USDC 自动借款。
  • 通过持续还款建立 Agent 声誉,以解锁更高的信用额度。
  • 使用 Circle Bridge 在 Arc Testnet 和 Base Sepolia 之间进行跨链流动性管理。
  • 为作为流动性提供者 (LP) 的 Agent 产生被动收入。
  • 为自主实体提供实时信用坚控和债务管理。
Credex Protocol 工作原理
  1. Agent 初始化技能并验证其浅包状态和可用信用额度。
  2. Agent 执行借款命令,根据其当前声誉从 Credex 池中接收 USDC。
  3. 资金可在 Arc Network 上使用,或通过桥接至 Base Sepolia 进行跨链操作。
  4. 为了提高信用度,Agent 偿还债务(本金加利息),这将触发其未来信用额度增加 10%。
  5. 拥有过剩资本的 Agent 可以将 USDC 存入池中以获得 LP 份额,并从协议的借代活动中赚取利息。

Credex Protocol 配置指南

要在 Openclaw Skills 框架中开始使用此技能,请按照以下步骤操作:

# 进入技能目录
cd {baseDir}

# 确保已配置环境变量
export WALLET_PRIVATE_KEY=your_private_key_here
export RPC_URL=https://rpc.testnet.arc.network

# 检查您当前的信用和浅包状态
npx ts-node scripts/client.ts status

Credex Protocol 数据架构与分类体系

该技能为所有操作返回结构化的 JSON 数据,以确保机器可读性。关键数据字段包括:

字段 描述 类型
creditLimit 允许 Agent 借款的最大金额 字符串 (十进制)
principal 原始借款金额 字符串 (十进制)
debt 当前欠款总额(本金 + 利息) 字符串 (十进制)
availableCredit 剩余借款能力(额度 - 本金) 字符串 (十进制)
sharePrice 每个 LP 份额当前的 USDC 价值 字符串 (十进制)
txHash 操作的区块链交易哈希 字符串 (十六进制)
name: credex-protocol
description: Access unsecured credit lines for AI agents on the Arc Network using the Credex Protocol. Use for borrowing USDC against reputation, repaying debt to grow credit limits, providing liquidity as an LP, or managing cross-chain USDC via Circle Bridge. Triggers on "borrow from credex", "repay debt", "deposit to pool", "check credit status", "provide liquidity", or any credit/lending task on Arc.

Credex Protocol Skill

Interact with the Credex Protocol—a decentralized credit system for AI agents on the Arc Network.


Usage

Base Directory: {baseDir} (the directory containing this SKILL.md)

Run all commands from the project root:

cd {baseDir}
npx ts-node scripts/client.ts  [args]   # Borrower commands
npx ts-node scripts/lp.ts  [args]       # LP commands

Output Format: All scripts return JSON for machine readability. Parse the output to extract fields like creditLimit, txHash, debt, etc.


Environment Variables

Required (Must Be Set)

Variable Description
WALLET_PRIVATE_KEY Private key for signing transactions. Without this, all commands fail.
RPC_URL Arc Network RPC. Default: https://rpc.testnet.arc.network

Optional

Variable Description Default
CREDEX_POOL_ADDRESS Pool contract address 0x32239e52534c0b7e525fb37ed7b8d1912f263ad3
CREDEX_AGENT_URL Credex agent server URL http://localhost:10003

Pre-Flight Check: Before running any command, verify WALLET_PRIVATE_KEY is set. If missing, prompt the user.


Contract Addresses (Arc Testnet)

Contract Address
CredexPool 0x32239e52534c0b7e525fb37ed7b8d1912f263ad3
USDC (Arc) 0x3600000000000000000000000000000000000000
USDC (Base Sepolia) 0x036CbD53842c5426634e7929541eC2318f3dCF7e

Client Commands (Borrower)

Script: scripts/client.ts
Run as: npx ts-node scripts/client.ts [args]


status

Check credit status for an agent.

Usage:

npx ts-node scripts/client.ts status 

Args:

  • address (optional): Wallet address. Defaults to WALLET_PRIVATE_KEY address.

Returns: JSON

{
  "creditLimit": "100.000000",
  "principal": "5.000000",
  "interest": "0.050000",
  "debt": "5.050000",
  "availableCredit": "95.000000",
  "active": true,
  "frozen": false
}

Action: Use availableCredit to check if sufficient funds before calling borrow.


borrow

Borrow USDC from the pool.

Usage:

npx ts-node scripts/client.ts borrow 

Args:

  • amount (required): USDC amount as decimal string (e.g., "5.0").

Returns: JSON

{
  "success": true,
  "txHash": "0x...",
  "borrowed": "5.000000",
  "newDebt": "5.000000",
  "availableCredit": "95.000000"
}

Fails if: amount > availableCredit. Check status first.


repay

Repay debt to the pool.

Usage:

npx ts-node scripts/client.ts repay 

Args:

  • amount: Specific USDC amount to repay (e.g., "5.0").
  • all: Calculates total debt + 1% buffer and repays fully. The contract caps at actual debt owed.

Returns: JSON

{
  "success": true,
  "txHash": "0x...",
  "repaid": "5.050000",
  "remainingDebt": "0.000000",
  "newCreditLimit": "110.000000"
}

Note: Repayments pay interest first, then principal. Each successful repayment increases credit limit by 10%.


bridge

Bridge USDC between Arc Testnet and Base Sepolia.

Usage:

npx ts-node scripts/client.ts bridge   

Args:

  • amount: USDC amount (e.g., "10.0").
  • from: Source chain (arc or base).
  • to: Destination chain (arc or base).

Returns: JSON

{
  "success": true,
  "amount": "10.000000",
  "from": "Arc_Testnet",
  "to": "Base_Sepolia",
  "estimatedArrival": "5-10 minutes"
}

Fails if: from === to. Chains must be different.


balance

Check wallet balance on both chains.

Usage:

npx ts-node scripts/client.ts balance

Returns: JSON

{
  "arc": "50.000000",
  "base": "25.000000",
  "total": "75.000000"
}

LP Commands (Liquidity Provider)

Script: scripts/lp.ts
Run as: npx ts-node scripts/lp.ts [args]


pool-status

Check overall pool health and metrics.

Usage:

npx ts-node scripts/lp.ts pool-status

Returns: JSON

{
  "totalAssets": "1000.000000",
  "totalLiquidity": "800.000000",
  "totalDebt": "200.000000",
  "totalShares": "950.000000",
  "sharePrice": "1.052631",
  "utilizationPercent": 20
}

deposit

Deposit USDC to receive LP shares.

Usage:

npx ts-node scripts/lp.ts deposit 

Args:

  • amount: USDC to deposit (e.g., "100.0").

Returns: JSON

{
  "success": true,
  "txHash": "0x...",
  "deposited": "100.000000",
  "sharesReceived": "95.000000",
  "totalShares": "95.000000"
}

withdraw

Burn LP shares to withdraw USDC.

Usage:

npx ts-node scripts/lp.ts withdraw 

Args:

  • shares: Number of shares to burn (e.g., "50.0").
  • all: Withdraw maximum possible based on available liquidity.

Returns: JSON

{
  "success": true,
  "txHash": "0x...",
  "sharesBurned": "50.000000",
  "usdcReceived": "52.631579",
  "remainingShares": "45.000000"
}

Note: Withdrawal may be capped if liquidity is fully utilized (all USDC lent out).


lp-balance

Check LP position for an address.

Usage:

npx ts-node scripts/lp.ts lp-balance [address]

Returns: JSON

{
  "shares": "95.000000",
  "value": "100.000000"
}

Protocol Mechanics

Interest Accrual

  • Rate: 0.1% per interval (10 basis points)
  • Interval: 1 minute (testnet accelerated)
  • Formula: debt = principal + accrued_interest

Credit Limit Growth

After each repayment:

newLimit = currentLimit × 1.10

Maximum: 10,000 USDC.

Available Credit

availableCredit = creditLimit - principal

Interest does NOT reduce borrowing power—only principal.

Share Price (LP)

sharePrice = totalAssets / totalShares

Where totalAssets = liquidity + outstandingDebt.


Workflow Examples

Borrower Flow

1. Check status     → npx ts-node scripts/client.ts status
2. Borrow           → npx ts-node scripts/client.ts borrow 5
3. Use funds        → (perform task on Arc or bridge to Base)
4. Bridge back      → npx ts-node scripts/client.ts bridge 5 base arc
5. Repay            → npx ts-node scripts/client.ts repay all
6. Verify growth    → npx ts-node scripts/client.ts status (limit increased!)

LP Flow

1. Check pool       → npx ts-node scripts/lp.ts pool-status
2. Deposit          → npx ts-node scripts/lp.ts deposit 100
3. Monitor          → npx ts-node scripts/lp.ts lp-balance
4. Withdraw         → npx ts-node scripts/lp.ts withdraw all

Common Errors & Recovery

Error Cause Recovery
WALLET_PRIVATE_KEY required Env var missing Set WALLET_PRIVATE_KEY before running
Exceeds credit limit amount > availableCredit Call status, borrow less
Insufficient balance Wallet has no USDC Bridge funds or acquire testnet USDC
Insufficient liquidity Pool is fully utilized Wait for borrowers to repay or LPs to deposit
Nonce too low Transaction conflict Wait 10 seconds and retry
Bridge timeout Circle Bridge delay Wait 5-10 minutes, check balances on both chains
Same chain error from === to in bridge Use different source and destination

References

  • See references/contracts.md for full ABIs and type definitions.
  • See scripts/client.ts and scripts/lp.ts for implementation.

相关推荐