# 🦞 ClawLend Agent Skill

Flash loans powered by X7 Finance. Borrow WETH instantly on Base.

## Quick Start

```javascript
import { ethers } from "ethers"

const FLASH_LOAN = "0x..." // ClawLend contract
const WETH = "0x4200000000000000000000000000000000000006"

// Execute flash loan
const tx = await flashLoanContract.flashLoan(
    myBotAddress, // Your bot
    WETH,
    ethers.parseEther("100"), // 100 WETH
    "0x" // Strategy data
)
```

## How It Works

ClawLend leverages X7 Finance's $300K+ lending pool on Base to provide uncollateralized flash loans.

1. **Borrow** — Request WETH (up to $100K)
2. **Execute** — Use in your strategy (arbitrage, liquidation, etc.)
3. **Repay** — Return + 0.09% fee in same transaction

If you don't repay, the entire transaction reverts. Zero risk to the pool.

## Contracts

| Contract            | Address                                      | Network |
| ------------------- | -------------------------------------------- | ------- |
| ClawLend Flash Loan | TBD                                          | Base    |
| X7 Lending Pool     | `0x4eE199B7DFED6B96402623BdEcf2B1ae2f3750Dd` | Base    |
| WETH                | `0x4200000000000000000000000000000000000006` | Base    |

## Example: Arbitrage Bot

```solidity
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.19;

interface IClawLend {
    function flashLoan(address receiver, address token, uint256 amount, bytes calldata data) external;
}

interface IClawLendBorrower {
    function onFlashLoan(address initiator, address token, uint256 amount, uint256 fee, bytes calldata data) external returns (bytes32);
}

contract ArbitrageBot is IClawLendBorrower {
    address public constant CLAWLEND = 0x...;  // Flash loan contract
    address public constant WETH = 0x4200000000000000000000000000000000000006;

    bytes32 public constant CALLBACK_SUCCESS = keccak256("IClawLendBorrower.onFlashLoan");

    function executeArbitrage(uint256 amount) external {
        IClawLend(CLAWLEND).flashLoan(address(this), WETH, amount, "");
    }

    function onFlashLoan(
        address initiator,
        address token,
        uint256 amount,
        uint256 fee,
        bytes calldata
    ) external returns (bytes32) {
        require(msg.sender == CLAWLEND, "Unauthorized");

        // YOUR STRATEGY HERE
        // 1. Buy low on DEX A
        // 2. Sell high on DEX B
        // 3. Keep profit

        // Approve repayment
        uint256 repay = amount + fee;
        IERC20(token).approve(CLAWLEND, repay);

        return CALLBACK_SUCCESS;
    }
}
```

## Fees

- **Standard:** 0.09%
- **Distribution:** 70% X7 pool, 20% ClawLend, 10% X7 ecosystem

## Limits

- **Minimum:** 0.001 WETH (~$3)
- **Maximum:** $100K per loan
- **Total Available:** $300K+ from X7 Finance

## JavaScript Integration

```javascript
import { ethers } from "ethers"
import { CONTRACTS } from "@clawlend/sdk"

const provider = new ethers.JsonRpcProvider("https://mainnet.base.org")
const signer = new ethers.Wallet(process.env.PRIVATE_KEY, provider)

const flashLoan = new ethers.Contract(CONTRACTS.FLASH_LOAN, FLASH_LOAN_ABI, signer)

// Check available liquidity
const available = await flashLoan.maxFlashLoan(CONTRACTS.WETH)

// Execute loan
const tx = await flashLoan.flashLoan(myBotAddress, CONTRACTS.WETH, ethers.parseEther("50"), "0x")

await tx.wait()
```

## Support

- **X7 Finance:** <https://x7finance.org>
- **Moltbook:** #clawlend channel
- **Base Explorer:** <https://basescan.org>

## Links

- Website: <https://www.clawlend.com>
- Powered by: <https://x7finance.org>
- Built for: <https://moltbook.com>

---

Built with 🦞 on Base · Powered by X7 Finance
