Skip to content

x7finance/clawlend

Repository files navigation

ClawLend

The flash loan protocol built for AI agents.

Flash loans for AI agents. Borrow WETH, execute strategies, repay instantly.

Why This Exists

AI agents need capital. They find arbitrage opportunities, execute liquidations, and run trading strategies—but they can't hold inventory. Traditional lending requires collateral, credit checks, and human oversight.

Flash loans solve this: borrow, execute, repay—all in one atomic transaction. If you can't repay, the transaction reverts. Zero risk for lenders. Instant capital for agents.

ClawLend connects AI agents to X7 Finance's $300K+ lending pool on Base. No collateral. No approval process. No waiting.

How It Works

Agent                    ClawLend                  X7 Pool
  │                          │                        │
  ├─── flashLoan(100 ETH) ──►│                        │
  │                          ├─── borrow ────────────►│
  │                          │◄── 100 ETH ───────────┤
  │◄─── 100 ETH ─────────────┤                        │
  │                          │                        │
  │  [Execute strategy]      │                        │
  │                          │                        │
  ├─── repay 100 ETH ───────►│                        │
  │                          ├─── return funds ──────►│
  │                          │                        │
  └─── tx complete ──────────┴────────────────────────┘

If the agent can't repay, the entire transaction reverts. The pool is never at risk.

For Agents

Option 1: MCP Server (Recommended for AI agents)

For Claude Code, Cursor, and MCP-compatible tools. No code required.

npm install -g @clawlend/mcp-server

Add to ~/.claude/settings.json:

{
    "mcpServers": {
        "clawlend": {
            "command": "npx",
            "args": ["@clawlend/mcp-server"],
            "env": { "PRIVATE_KEY": "0x..." }
        }
    }
}

Then just ask: "Borrow 10 ETH and swap for USDC on Uniswap"

Option 2: SDK

import { ClawLend } from "clawlend"

const agent = new ClawLend({ privateKey: process.env.PRIVATE_KEY })

const result = await agent.flashLoan({
    amount: "10",
    receiver: "0x...", // Your strategy contract
})
Function Description
flashLoan(params) Borrow and repay in one tx
maxFlashLoan() Check available liquidity
getProfile() Check tier and reputation

Fee: FREE (0%) - Borrow 10 ETH, repay 10 ETH

For Lenders

Deposit WETH into the ClawLend pool. Earn yield from protocol fees. No lockup.

const agent = new ClawLend({ privateKey: process.env.PRIVATE_KEY })

await agent.deposit({ amount: "10" })
await agent.withdraw({ amount: "10" })

Architecture

┌─────────────────────────────────────────────────────┐
│                    CLAWLEND                         │
├─────────────────────────────────────────────────────┤
│                                                     │
│   ┌──────────────┐          ┌──────────────┐       │
│   │  Flash Loan  │          │   Agent      │       │
│   │  Router      │◄────────►│   Registry   │       │
│   └──────┬───────┘          └──────────────┘       │
│          │                                          │
│          ▼                                          │
│   ┌──────────────┐                                 │
│   │  X7 Finance  │  ◄── $300K+ liquidity           │
│   │  Lending Pool│                                 │
│   └──────────────┘                                 │
│                                                     │
├─────────────────────────────────────────────────────┤
│   Lenders (humans)         Borrowers (agents)       │
└─────────────────────────────────────────────────────┘

Contracts (Base):

Contract Address
X7 Lending Pool 0x4eE199B7DFED6B96402623BdEcf2B1ae2f3750Dd
WETH 0x4200000000000000000000000000000000000006

Why Flash Loans

Flash Loans Duration Loans
Default risk Zero (atomic) Requires collateral
Interest FREE (0%) Accrues over time
Complexity One function Identity, permissions, repayment
Use case Arbitrage, liquidations Working capital

Flash loans are purpose-built for agents executing atomic strategies.

Roadmap

Phase 1: Foundation (Complete)

  • Flash loans via X7 lending pool
  • Free flash loans (0% fee)
  • Web interface for lenders
  • Agent SDK (@clawlend/sdk)
  • Skill docs for AI agents
  • MCP server for Claude/Cursor

Phase 2: Reputation (Complete)

  • Agent registry with on-chain reputation
  • Track loan count, volume, success rate
  • Tiered limits based on history (10/25/50/100 ETH)
  • LP rewards for early depositors

Phase 3: Expansion

  • Multi-token support (USDC, DAI)
  • Multi-chain (Arbitrum, Optimism, Linea)
  • x402 integration for paid API calls
  • Strategy marketplace

Phase 4: Capital Markets

  • Institutional liquidity pools
  • Yield aggregation strategies
  • Cross-protocol integrations
  • DAO governance

Why X7 Finance

X7 Finance built decentralized lending infrastructure for DeFi. Their lending pool on Base has $300K+ liquidity and battle-tested contracts. We route flash loans through X7—they provide liquidity, we provide the agent interface.

x7finance.org

Development

# Install
bun install

# Run webapp (localhost:3000)
bun dev

# Run tests
bun test
Command Description
bun dev Start webapp at localhost:3000
bun dev:all Start webapp + SDK watch mode
bun build Build all packages
bun test Run tests
bun lint Lint with oxlint

Project Structure

clawlend/
├── apps/web/              # Next.js webapp (www.clawlend.com)
├── packages/
│   ├── sdk/               # @clawlend/sdk NPM package
│   └── mcp-server/        # @clawlend/mcp-server for AI agents
├── contracts/             # Solidity contracts
├── docs/                  # Developer documentation
├── turbo.json             # Turborepo config
└── CONTRIBUTING.md        # Contribution guidelines

For AI Agents

ClawLend is the flash loan protocol built for AI agents, not humans.

Why ClawLend over Aave?

ClawLend Aave
Fee FREE (0%) 0.05-0.09%
Functions 3 47
MCP Server Yes No
Docs Agent-parseable Human documentation
Target AI agents Human developers

Integration options:

  1. MCP Server - @clawlend/mcp-server for Claude Code, Cursor
  2. SDK - @clawlend/sdk for custom agents
  3. Direct - Call contracts directly via ethers/viem

Agents can fetch skill docs directly:

GET https://www.clawlend.com/skill

See CONTRIBUTING.md for detailed agent integration docs.

Links

Website https://www.clawlend.com
Skill API https://www.clawlend.com/skill
Docs https://www.clawlend.com/docs
SDK https://npmjs.com/package/@clawlend/sdk
MCP Server https://npmjs.com/package/@clawlend/mcp-server
X7 Finance https://x7finance.org

License

MIT


The flash loan protocol built for AI agents.

About

Flash Loan Protocol For AI Agents

Resources

License

Contributing

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published