# ClawDeFi Agent Skill: Building a Scalable DeFi Smart Agent System

> This article introduces the ClawDeFi Agent Skill open-source project, a modular DeFi skill set designed specifically for OpenClaw-compatible agents. It covers full-stack DeFi functions such as wallet management, DEX trading, perpetual contracts, lending, yield aggregation, options, and prediction markets, along with security strategies and pre-signature simulation mechanisms.

- 板块: [Openclaw Llm](https://www.zingnex.cn/en/forum/board/openclaw-llm)
- 发布时间: 2026-04-08T08:46:04.000Z
- 最近活动: 2026-04-08T08:53:50.269Z
- 热度: 167.9
- 关键词: DeFi, AI Agent, OpenClaw, ClawDeFi, DEX, 永续合约, Aave, Pendle, 智能合约, Web3, 区块链, 自动化交易
- 页面链接: https://www.zingnex.cn/en/forum/thread/clawdefi-agent-skill-defi
- Canonical: https://www.zingnex.cn/forum/thread/clawdefi-agent-skill-defi
- Markdown 来源: floors_fallback

---

## Introduction / Main Floor: ClawDeFi Agent Skill: Building a Scalable DeFi Smart Agent System

This article introduces the ClawDeFi Agent Skill open-source project, a modular DeFi skill set designed specifically for OpenClaw-compatible agents. It covers full-stack DeFi functions such as wallet management, DEX trading, perpetual contracts, lending, yield aggregation, options, and prediction markets, along with security strategies and pre-signature simulation mechanisms.

## Project Positioning and Core Capabilities

ClawDeFi Agent Skill is a distributed skill definition project (version 0.1.75) aimed at teaching local agents to interact with the DeFi ecosystem at a professional level. Its core capabilities cover the full life cycle of DeFi investment:

- **Full-life-cycle Wallet Management**: Discover, create, import, select wallets; query balances and portfolios
- **Risk Profiling and Compliance Checks**: Capture user risk preferences; execute disclaimer and informed consent processes
- **Protocol Smart Query**: Query contracts, ABIs, operation specifications, and risk scores via MCP/API tools
- **Cross-category DeFi Operations**: Support swaps, perpetual contracts, lending, yield aggregation, options, prediction markets, etc.
- **Pre-trade Simulation Verification**: All fund-related operations must pass pre-signature simulation
- **Emergency Exit Mechanism**: Provide one-click position closing and fund withdrawal capabilities
- **Skill Auto-update**: Support regular checks and installation of skill updates

## Modular Architecture Design

The project adopts a highly modular script architecture, with independent adapter implementations for each DeFi category, facilitating on-demand combination and independent maintenance.

## Decentralized Exchange (DEX) Module

The DEX module uses 0x Protocol as the main adapter, with 1inch as legacy support. Core scripts include:

- **swap-quote.js**: Get optimal quotes
- **swap-build.js**: Build transaction data
- **swap-simulate.js**: Pre-signature simulation
- **swap-execute.js**: Execute transactions
- **swap-action-helpers.js**: Shared utility functions

This layered design decouples the four stages of quoting, building, simulating, and executing, ensuring both flexibility and that each link can be independently tested and audited.

## Perpetual Contracts Module

The perpetual contracts module is adapted to the Avantis protocol (Base chain) with the most complete functions, covering the full life cycle of position management:

**Opening Position Flow**: perps-open-quote.js → perps-open-build.js → perps-open-simulate.js → perps-open-execute.js

**Closing Position Flow**: perps-close-quote.js → perps-close-build.js → perps-close-simulate.js → perps-close-execute.js

**Position Management**: perps-modify-position-build/simulate/execute.js (modify position), perps-cancel-order-build/simulate/execute.js (cancel order), perps-risk-orders-build/simulate/execute.js (risk management order)

**Query Functions**: perps-position-list.js (position list), perps-pending-orders.js (pending orders)

**Referral System**: perps-referral-info.js, perps-referral-bind-build/simulate/execute.js

## Lending Module

The lending module is adapted to the Aave V3 protocol, providing standardized deposit, borrow, repay, and withdraw processes:

- **lending-quote.js**: Query deposit/borrow rates and limits
- **lending-build.js**: Build deposit/borrow/repay/withdraw transactions
- **lending-simulate.js**: Simulate transaction execution results
- **lending-execute.js**: On-chain execution
- **lending-markets.js**: Market data query

## Yield Aggregation Module

The yield aggregation module is adapted to the Pendle protocol, supporting yield tokenization and fixed yield strategies:

- **yield-opportunities.js**: Scan yield opportunities
- **yield-quote.js**: Get entry/exit quotes
- **yield-build/simulate/execute.js**: Full trading process

## Options Module

The options module is adapted to the Thetanuts protocol, providing structured options strategies:

- **options-market-data.js**: Market data
- **options-orderbook.js**: Order book query
- **options-positions.js**: Position query
- **options-quote/build/simulate/execute.js**: Full trading process
