$npx -y skills add basezh/agent-skills-on-base --skill clawlettOpenClaw skill for autonomous token swaps and Trenches trading, powered by Gnosis Safe + Zodiac Roles.
| 1 | # Clawlett |
| 2 | |
| 3 | <p align="center"> |
| 4 | <img src="assets/mascot.jpg" alt="Clawlett Mascot" width="400"> |
| 5 | </p> |
| 6 | |
| 7 | An [OpenClaw](https://openclaw.ai) skill for autonomous token swaps and Trenches trading, powered by Gnosis Safe + Zodiac Roles. |
| 8 | |
| 9 | **Supported chains:** Base (default), BNB Chain. All scripts accept `--chain <name>`. |
| 10 | |
| 11 | ## Overview |
| 12 | |
| 13 | This skill enables AI agents to perform secure, permissioned token swaps and Trenches token creation/trading through a Gnosis Safe. The agent operates through Zodiac Roles module which restricts operations to: |
| 14 | |
| 15 | - Swapping tokens via KyberSwap Aggregator (default) or CoW Protocol (MEV-protected) |
| 16 | - Creating tokens on Trenches |
| 17 | - Buying and selling Trenches tokens via factory |
| 18 | - Approving tokens only for KyberSwap Router, CoW Vault Relayer, and AgentKeyFactoryV3 |
| 19 | - All swapped tokens return to the Safe (no external transfers) |
| 20 | |
| 21 | The human owner retains full control of the Safe while the agent can only execute swaps and trades. |
| 22 | |
| 23 | ## Security Model |
| 24 | |
| 25 | ``` |
| 26 | ┌─────────────────────────────────────────────────────────┐ |
| 27 | │ Gnosis Safe │ |
| 28 | │ (holds all funds) │ |
| 29 | │ │ |
| 30 | │ Owner: Human Wallet (full control) │ |
| 31 | │ Module: Zodiac Roles (restricted agent access) │ |
| 32 | └─────────────────────────────────────────────────────────┘ |
| 33 | │ |
| 34 | ▼ |
| 35 | ┌─────────────────────────────────────────────────────────┐ |
| 36 | │ Zodiac Roles │ |
| 37 | │ │ |
| 38 | │ Agent can ONLY: │ |
| 39 | │ • Call ZodiacHelpers (swaps, approvals, wrapping) │ |
| 40 | │ • Approve tokens for KyberSwap Router & CoW Relayer │ |
| 41 | │ • Execute swaps via KyberSwap or CoW Protocol │ |
| 42 | │ │ |
| 43 | │ Agent CANNOT: │ |
| 44 | │ • Transfer tokens out of Safe │ |
| 45 | │ • Change Safe settings │ |
| 46 | │ • Add/remove owners │ |
| 47 | └─────────────────────────────────────────────────────────┘ |
| 48 | ``` |
| 49 | |
| 50 | ## Installation |
| 51 | |
| 52 | ```bash |
| 53 | cd clawlett/scripts |
| 54 | npm install |
| 55 | ``` |
| 56 | |
| 57 | ## Setup |
| 58 | |
| 59 | 1. Initialize the wallet (deploys Safe + Roles): |
| 60 | |
| 61 | ```bash |
| 62 | node clawlett/scripts/initialize.js --owner <YOUR_WALLET_ADDRESS> |
| 63 | # Or for BNB Chain: |
| 64 | node clawlett/scripts/initialize.js --chain bnb --owner <YOUR_WALLET_ADDRESS> |
| 65 | ``` |
| 66 | |
| 67 | 2. Fund the agent address with ~0.001 native token for gas (address shown in output) |
| 68 | |
| 69 | 3. Run the script again - it will complete the setup automatically |
| 70 | |
| 71 | 4. Fund your Safe with tokens to trade |
| 72 | |
| 73 | ## Usage |
| 74 | |
| 75 | ### Check Balances |
| 76 | |
| 77 | ```bash |
| 78 | # ETH balance |
| 79 | node clawlett/scripts/balance.js |
| 80 | |
| 81 | # Specific token |
| 82 | node clawlett/scripts/balance.js --token USDC |
| 83 | |
| 84 | # All verified tokens |
| 85 | node clawlett/scripts/balance.js --all |
| 86 | ``` |
| 87 | |
| 88 | ### Swap Tokens |
| 89 | |
| 90 | ```bash |
| 91 | # KyberSwap (default — optimal routes across DEXs) |
| 92 | node clawlett/scripts/swap.js --from ETH --to USDC --amount 0.1 |
| 93 | node clawlett/scripts/swap.js --from ETH --to USDC --amount 0.1 --execute |
| 94 | |
| 95 | # CoW Protocol (MEV-protected) |
| 96 | node clawlett/scripts/cow.js --from USDC --to WETH --amount 100 |
| 97 | node clawlett/scripts/cow.js --from USDC --to WETH --amount 100 --execute |
| 98 | |
| 99 | # Swap by address (for tokens not in verified list) |
| 100 | node clawlett/scripts/swap.js --from USDC --to 0xa1832f7f4e534ae557f9b5ab76de54b1873e498b --amount 100 --execute |
| 101 | ``` |
| 102 | |
| 103 | ### Trenches Trading |
| 104 | |
| 105 | Create tokens and trade on Trenches bonding curves: |
| 106 | |
| 107 | ```bash |
| 108 | # Create a new token |
| 109 | node clawlett/scripts/trenches.js create --name "My Token" --symbol MTK --description "A cool token" |
| 110 | node clawlett/scripts/trenches.js create --name "My Token" --symbol MTK --description "desc" --initial-buy 0.01 |
| 111 | |
| 112 | # Buy tokens with ETH |
| 113 | node clawlett/scripts/trenches.js buy --token MTK --amount 0.01 |
| 114 | |
| 115 | # Sell tokens for ETH |
| 116 | node clawlett/scripts/trenches.js sell --token MTK --amount 1000 |
| 117 | node clawlett/scripts/trenches.js sell --token MTK --all |
| 118 | |
| 119 | # Token info |
| 120 | node clawlett/scripts/trenches.js info MTK |
| 121 | ``` |
| 122 | |
| 123 | ### Token Discovery |
| 124 | |
| 125 | Browse trending and top-performing tokens on Trenches: |
| 126 | |
| 127 | ```bash |
| 128 | node clawlett/scripts/trenches.js trending |
| 129 | node clawlett/scripts/trenches.js trending --window 1h --limit 5 |
| 130 | node clawlett/scripts/trenches.js new |
| 131 | node clawlett/scripts/trenches.js top-volume |
| 132 | node clawlett/scripts/trenches.js gainers |
| 133 | node clawlett/scripts/trenches.js losers |
| 134 | ``` |
| 135 | |
| 136 | ### Custom RPC |
| 137 | |
| 138 | All scripts support `--rpc` flag for custom RPC endpoints: |
| 139 | |
| 140 | ```bash |
| 141 | node clawlett/scripts/balance.js --rpc https://base.llamarpc.com |
| 142 | node clawlett/scripts/swap.js --from ETH --to USDC --amount 0.1 --rpc https://base.llamarpc.com |
| 143 | ``` |
| 144 | |
| 145 | ## Verified Tokens |
| 146 | |
| 147 | Protected tokens can only resolve to verified addresse |