Zing Forum

Reading

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.

DeFiAI AgentOpenClawClawDeFiDEX永续合约AavePendle智能合约Web3
Published 2026-04-08 16:46Recent activity 2026-04-08 16:53Estimated read 7 min
ClawDeFi Agent Skill: Building a Scalable DeFi Smart Agent System
1

Section 01

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.

2

Section 02

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
3

Section 03

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.

4

Section 04

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.

5

Section 05

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

6

Section 06

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
7

Section 07

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
8

Section 08

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