pragma-openclaw 0.1.0 → 0.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md ADDED
@@ -0,0 +1,553 @@
1
+ # pragma
2
+
3
+ > Vibetrading for OpenClaw
4
+
5
+ [![OpenClaw](https://img.shields.io/badge/OpenClaw-plugin-FF6B35?logo=data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCAyNCAyNCI+PHBhdGggZD0iTTEyIDJMMiAyMmgyMEwxMiAyeiIgZmlsbD0id2hpdGUiLz48L3N2Zz4=)](https://openclaw.ai)
6
+ [![Monad](https://img.shields.io/badge/Monad-live-836EF9)](https://monad.xyz)
7
+ [![npm](https://img.shields.io/npm/v/pragma-openclaw)](https://www.npmjs.com/package/pragma-openclaw)
8
+ [![Version](https://img.shields.io/badge/version-0.1.2-green.svg)](CHANGELOG.md)
9
+ [![License](https://img.shields.io/badge/license-MIT-blue.svg)](LICENSE)
10
+
11
+ > **Beta Software.** pragma is experimental and under active development. Trading involves risk of loss — use at your own discretion and never trade more than you can afford to lose.
12
+
13
+ pragma is an [OpenClaw](https://openclaw.ai) plugin that turns OpenClaw agents into on-chain trading agents. Swap tokens, trade perpetuals, scalp memecoins, analyze markets, and run autonomous trading agents — all through natural conversation.
14
+
15
+ **Currently live on [Monad](https://monad.xyz).** Built with [MetaMask Smart Accounts Kit](https://docs.metamask.io/smart-accounts-kit/) and [x402](https://www.x402.org/) (pay-per-API-call with USDC — no keys to configure).
16
+
17
+ > **Headless by design.** pragma-openclaw runs on Linux servers without macOS, Touch ID, or Keychain. Session keys are stored as encrypted files. Delegations are approved through a web flow at [pr4gma.xyz](https://pr4gma.xyz) — the user signs with their passkey in the browser, and the agent retrieves the signed delegation via polling.
18
+
19
+ ## Table of Contents
20
+
21
+ - [pragma vs pragma-openclaw](#pragma-vs-pragma-openclaw)
22
+ - [Features](#features)
23
+ - [Installation](#installation)
24
+ - [Quick Start](#quick-start)
25
+ - [Commands](#commands)
26
+ - [Modes](#modes)
27
+ - [Tools](#tools)
28
+ - [How It Works](#how-it-works)
29
+ - [Architecture](#architecture)
30
+ - [Session Keys](#session-keys)
31
+ - [Delegations](#delegations)
32
+ - [Web Delegation Flow](#web-delegation-flow)
33
+ - [Autonomous Agents](#autonomous-agents)
34
+ - [Security Model](#security-model)
35
+ - [x402 Protocol](#x402-protocol)
36
+ - [Pricing](#pricing)
37
+ - [Requirements](#requirements)
38
+ - [Troubleshooting](#troubleshooting)
39
+ - [Acknowledgments](#acknowledgments)
40
+ - [Support](#support)
41
+ - [License](#license)
42
+
43
+ ---
44
+
45
+ ## pragma vs pragma-openclaw
46
+
47
+ pragma exists as two plugins for two different agent runtimes. Same wallet, same tools, different platforms.
48
+
49
+ | | pragma (Claude Code) | pragma-openclaw (OpenClaw) |
50
+ | ---------------------- | ---------------------------------- | ----------------------------------------- |
51
+ | **Runtime** | Claude Code CLI / Desktop / Cowork | OpenClaw |
52
+ | **Platform** | macOS only | Linux servers (headless) |
53
+ | **Key storage** | macOS Keychain + Touch ID | File-based (`~/.pragma/session-key.json`) |
54
+ | **Delegation signing** | Touch ID (local biometric) | Web approval at pr4gma.xyz |
55
+ | **Autonomous agents** | Claude Code agent teams | OpenClaw `sessions_spawn` |
56
+ | **Package** | `pragma` (Claude Code marketplace) | `pragma-openclaw` (npm) |
57
+ | **MCP bridge** | Native (runs MCP server directly) | Child process (stdio transport) |
58
+
59
+ If you're on macOS and using Claude Code, use [pragma](https://github.com/s0nderlabs/pragma). If you're running OpenClaw agents on a server, you're in the right place.
60
+
61
+ ---
62
+
63
+ ## Features
64
+
65
+ **Trading**
66
+
67
+ - Token swaps via DEX aggregator (best route, batch support)
68
+ - Perpetual futures on [LeverUp](https://leverup.xyz) (up to 1001x leverage, 20 pairs)
69
+ - Memecoin trading on [nad.fun](https://nad.fun) bonding curves
70
+ - Wrapping and transfers
71
+
72
+ **Market Intelligence**
73
+
74
+ - OHLCV charts from Pyth oracles (all timeframes)
75
+ - Economic calendar, central bank speeches, critical news
76
+ - Currency strength matrix, FX reference rates
77
+ - Funding rates, open interest, squeeze detection
78
+
79
+ **Autonomous Trading**
80
+
81
+ - Three specialized agents: Kairos (perps), Thymos (memecoins), Pragma (general)
82
+ - Background trading via OpenClaw `sessions_spawn`
83
+ - On-chain budget enforcement via smart contract caveats
84
+ - Multi-agent coordination with independent wallets
85
+
86
+ **On-Chain Analysis**
87
+
88
+ - Transaction decoding and explanation
89
+ - Contract analysis (ABI, proxy detection, security notes)
90
+ - Activity history with token flow tracking
91
+
92
+ ---
93
+
94
+ ## Installation
95
+
96
+ Install via OpenClaw CLI:
97
+
98
+ ```bash
99
+ openclaw plugins install pragma-openclaw
100
+ ```
101
+
102
+ On first load, the plugin automatically:
103
+
104
+ 1. Creates a session key at `~/.pragma/session-key.json` (secp256k1, `0600` permissions)
105
+ 2. Creates a config at `~/.pragma/config.json` (Monad mainnet, chainId 143)
106
+ 3. Spawns the pragma MCP server as a child process
107
+ 4. Discovers and registers all available tools with the OpenClaw API
108
+
109
+ Then run setup through the agent:
110
+
111
+ ```
112
+ Set up pragma
113
+ ```
114
+
115
+ The agent will guide you through linking your Smart Account and creating a trading delegation.
116
+
117
+ ### Plugin Configuration
118
+
119
+ Optional settings in your OpenClaw config:
120
+
121
+ ```json
122
+ {
123
+ "plugins": {
124
+ "pragma-openclaw": {
125
+ "mode": "x402",
126
+ "configPath": "~/.pragma/config.json",
127
+ "sessionKeyPath": "~/.pragma/session-key.json"
128
+ }
129
+ }
130
+ }
131
+ ```
132
+
133
+ | Option | Default | Description |
134
+ | ---------------- | ---------------------------- | ------------------------------------------------------------- |
135
+ | `mode` | `x402` | API mode: `x402` (paid) or `byok` (free, bring your own keys) |
136
+ | `configPath` | `~/.pragma/config.json` | Path to pragma config file |
137
+ | `sessionKeyPath` | `~/.pragma/session-key.json` | Path to session key file |
138
+
139
+ ---
140
+
141
+ ## Quick Start
142
+
143
+ Once set up, just talk to the agent:
144
+
145
+ ```
146
+ What's my balance?
147
+ ```
148
+
149
+ ```
150
+ Swap 1 MON for USDC
151
+ ```
152
+
153
+ ```
154
+ Show me the BTC chart on the 4H timeframe
155
+ ```
156
+
157
+ ```
158
+ Open a 10x long on ETH with 5 LVUSD margin, SL at $2,200
159
+ ```
160
+
161
+ ```
162
+ What's trending on nad.fun?
163
+ ```
164
+
165
+ ```
166
+ Run kairos with $50 budget for 7 days — trade perps, focus on macro setups
167
+ ```
168
+
169
+ pragma activates automatically when you mention anything related to trading, wallets, tokens, or on-chain operations.
170
+
171
+ ---
172
+
173
+ ## Commands
174
+
175
+ | Skill | Description |
176
+ | ------------------- | --------------------------------------------- |
177
+ | `pragma-setup` | First-time onboarding and wallet setup |
178
+ | `pragma-delegation` | Create, renew, and manage trading delegations |
179
+ | `pragma-core` | Trading, market intelligence, wallet ops |
180
+ | `pragma-autonomous` | Background agent trading with sub-agents |
181
+ | `pragma-mode` | Switch between BYOK and x402 modes |
182
+
183
+ For everything else — swaps, transfers, balances, trading — just describe what you want in plain English. Skills activate automatically based on intent.
184
+
185
+ ---
186
+
187
+ ## Modes
188
+
189
+ pragma operates in two modes.
190
+
191
+ ### x402 Mode (Default)
192
+
193
+ Pay-per-API-call using USDC from your session key. No API keys to configure — everything works out of the box.
194
+
195
+ New wallets get **50 free API calls** to bootstrap (enough to swap MON for USDC and fund your session key). After that, calls cost fractions of a cent each.
196
+
197
+ ### BYOK Mode (Free)
198
+
199
+ Bring Your Own Keys. You provide RPC, bundler, quote, and data API endpoints. The plugin is free — you only pay your own API providers.
200
+
201
+ ---
202
+
203
+ ## Tools
204
+
205
+ pragma provides **54+ MCP tools** across 12 categories, bridged from the pragma-mcp server to the OpenClaw API.
206
+
207
+ | Category | Tools | Description |
208
+ | ----------- | ----- | --------------------------------------------------------------------------------------- |
209
+ | Setup | 4 | Wallet setup, mode switching, provider config |
210
+ | Balance | 3 | Token balances, portfolio, account info |
211
+ | Tokens | 2 | Token lookup, verified token list |
212
+ | Trading | 2 | DEX quotes (single + batch), swap execution |
213
+ | Transfers | 3 | Send tokens, wrap/unwrap MON |
214
+ | Session Key | 3 | Gas funding, balance check, withdrawal |
215
+ | Blockchain | 2 | Block info, gas price |
216
+ | Analysis | 3 | Transaction decoding, activity history, contract analysis |
217
+ | nad.fun | 7 | Status, discover, quote, buy, sell, positions, token info |
218
+ | LeverUp | 12 | Pairs, positions, quotes, open/close, margin, TP/SL, limit orders, stats, funding rates |
219
+ | Market | 8 | Charts, economic events, news, FX rates, currency strength, CB speeches |
220
+ | Delegation | 4 | Web-based delegation request, poll, retrieve, session setup |
221
+ | Sub-Agents | 8 | Create, fund, revoke, status, journal, wallet pool |
222
+
223
+ **Blocked tools:**
224
+
225
+ | Tool | Why Blocked | Alternative |
226
+ |------|-------------|-------------|
227
+ | `create_root_delegation` | Requires passkey signing via macOS Touch ID (`pragma-signer` binary). The delegation struct must be signed by the P-256 passkey stored in macOS Keychain — there's no headless equivalent for this signature type. | Use `request_delegation` → web approval at pr4gma.xyz (user signs with passkey in browser) |
228
+ | `nadfun_create` | Deploying a new token on nad.fun requires a direct passkey signature from the smart account owner. This operation can't go through the delegation chain because nad.fun's factory contract requires the account itself to call `create()`, not a delegate. | Not available on this platform — create tokens from macOS CLI or pragma wallet |
229
+
230
+ ---
231
+
232
+ ## How It Works
233
+
234
+ ### Architecture
235
+
236
+ pragma-openclaw is an OpenClaw plugin that bridges the pragma MCP server into the OpenClaw agent runtime.
237
+
238
+ ```mermaid
239
+ graph TD
240
+ A["OpenClaw Agent"]
241
+ B["pragma-openclaw<br/>(OpenClaw plugin)"]
242
+ C["pragma-mcp<br/>(MCP server, stdio child)"]
243
+ D["Monad<br/>(on-chain)"]
244
+ E["pr4gma.xyz<br/>(web delegation)"]
245
+ F["x402 API<br/>(api.pr4gma.xyz)"]
246
+
247
+ A -->|"tool calls"| B
248
+ B -->|"MCP protocol<br/>(stdio)"| C
249
+ C -->|"RPC / bundler"| D
250
+ C -->|"API calls"| F
251
+ B -->|"delegation flow"| E
252
+
253
+ style A fill:#FF6B35,stroke:#FF8C5A,color:#fff,stroke-width:2px
254
+ style B fill:#1e40af,stroke:#3b82f6,color:#fff,stroke-width:2px
255
+ style C fill:#7c3aed,stroke:#a78bfa,color:#fff,stroke-width:2px
256
+ style D fill:#836EF9,stroke:#a78bfa,color:#fff,stroke-width:2px
257
+ style E fill:#047857,stroke:#10b981,color:#fff,stroke-width:2px
258
+ style F fill:#b45309,stroke:#f59e0b,color:#fff,stroke-width:2px
259
+ ```
260
+
261
+ On startup, the plugin:
262
+
263
+ 1. Generates or loads a file-based session key (secp256k1)
264
+ 2. Ensures `~/.pragma/config.json` exists with Monad mainnet settings
265
+ 3. Spawns `pragma-mcp` as a child process via stdio transport
266
+ 4. Discovers all MCP tools and registers them individually with OpenClaw
267
+ 5. Registers delegation gateway methods (RPC endpoints + agent tools)
268
+
269
+ The MCP bridge uses `@modelcontextprotocol/sdk` Client with `StdioClientTransport`. Every tool call from the agent is proxied through the bridge to the MCP server.
270
+
271
+ ### Session Keys
272
+
273
+ On OpenClaw (Linux), session keys are **file-based** instead of Keychain-based.
274
+
275
+ | Aspect | pragma (macOS) | pragma-openclaw (Linux) |
276
+ | ----------- | ----------------------------------------- | ------------------------------------ |
277
+ | Key type | secp256k1 | secp256k1 |
278
+ | Storage | macOS Keychain (`xyz.pragma.session-key`) | File (`~/.pragma/session-key.json`) |
279
+ | Permissions | Keychain ACL (per-app) | `0600` (owner read/write only) |
280
+ | Touch ID | Not required to read | N/A |
281
+ | Generation | `viem/accounts` `generatePrivateKey` | `viem/accounts` `generatePrivateKey` |
282
+
283
+ The session key is a standard Ethereum EOA that the agent uses for:
284
+
285
+ - **Gas payments:** Holds MON for transaction gas
286
+ - **x402 micropayments:** Signs USDC payment authorizations for API calls
287
+ - **Delegation execution:** Submits `redeemDelegations()` transactions on-chain
288
+
289
+ The session key cannot move funds from your smart account on its own. It can only execute operations through delegations that you've signed with your passkey.
290
+
291
+ ### Delegations
292
+
293
+ Delegations are signed on-chain permissions that authorize the agent to trade through your Smart Account. They use [MetaMask Smart Accounts Kit](https://docs.metamask.io/smart-accounts-kit/) caveats (enforcers) to constrain scope:
294
+
295
+ | Caveat | What It Enforces |
296
+ | ---------------------------- | ----------------------------------------------------------- |
297
+ | **TimestampEnforcer** | Delegation expires after a set time |
298
+ | **LimitedCallsEnforcer** | Maximum number of on-chain calls |
299
+ | **ValueLteEnforcer** | Maximum MON per transaction |
300
+ | **AllowedTargetsEnforcer** | Whitelist of contract addresses |
301
+ | **AllowedMethodsEnforcer** | Whitelist of function selectors |
302
+ | **AllowedCalldataEnforcer** | Whitelist of calldata patterns (transfer recipients) |
303
+ | **LogicalOrWrapperEnforcer** | Groups caveats with OR logic (approve OR trade OR transfer) |
304
+
305
+ These are enforced by smart contracts on-chain. The agent cannot bypass, extend, or modify them after signing.
306
+
307
+ ### Web Delegation Flow
308
+
309
+ Since Touch ID isn't available on Linux servers, pragma-openclaw uses a **web-based delegation flow**. The user approves delegations by signing with their passkey in a browser at [pr4gma.xyz](https://pr4gma.xyz).
310
+
311
+ ```mermaid
312
+ sequenceDiagram
313
+ participant A as Agent (OpenClaw)
314
+ participant API as pr4gma.xyz API
315
+ participant U as User (Browser)
316
+
317
+ A->>A: Build delegation struct + EIP-712 typed data
318
+ A->>API: POST /delegation/request
319
+ API-->>A: { requestId, approvalUrl }
320
+ A->>U: "Please approve at: [approvalUrl]"
321
+ U->>U: Open URL, review scope
322
+ U->>API: Sign with passkey
323
+ API-->>API: Store signature
324
+
325
+ loop Poll every 30s
326
+ A->>API: GET /delegation/request/{id}/status
327
+ API-->>A: { status: "pending" | "approved" }
328
+ end
329
+
330
+ A->>API: GET /delegation/request/{id}
331
+ API-->>A: { signedDelegation }
332
+ A->>A: Store at ~/.pragma/delegations/root/delegation.json
333
+ A->>A: Verify with test transaction (wrap 0.001 MON)
334
+ ```
335
+
336
+ The delegation is built locally by the plugin with full on-chain caveats (protocol targets, function selectors, value limits, time bounds, transfer groups). Only the signature comes from the user's browser — the agent controls the scope, and the user approves or rejects.
337
+
338
+ **Delegation groups (LogicalOr):**
339
+
340
+ | Group | Purpose | Example |
341
+ | ------------------- | ----------------------------------------- | ------------------------------------ |
342
+ | 0 — Approve | ERC-20 token approvals | `approve(spender, amount)` |
343
+ | 1 — Trading | Swaps, perps, memecoins, wrap/unwrap | `swap()`, `openTrade()`, `deposit()` |
344
+ | 2 — ERC20 Transfer | Token transfers to whitelisted recipients | `transfer(sessionKey, amount)` |
345
+ | 3 — Native Transfer | MON transfers to whitelisted recipients | Send MON to session key for gas |
346
+
347
+ Groups 2 and 3 enable the agent to self-fund its session key with gas and tokens from the user's Smart Account, without requiring a separate approval.
348
+
349
+ ### Autonomous Agents
350
+
351
+ pragma ships with three specialized trading agents, each with its own personality, methodology, and tool access:
352
+
353
+ #### Kairos — Strategic Perpetuals
354
+
355
+ _"The right moment" (kairos)_
356
+
357
+ An institutional-grade perpetuals trader with a 7-phase workflow: macro scan, market structure analysis, trade planning (with mandatory bear case and kill switch), execution, monitoring (10-15 min cycles), context recovery via journal memos, and session summary. 34 tools (12 LeverUp + 8 market intelligence + support). Strict risk rules: 2% max risk per trade, 6% daily drawdown limit, mandatory SL/TP.
358
+
359
+ #### Thymos — Momentum Memecoins
360
+
361
+ _"Spirit, conviction" (thymos)_
362
+
363
+ A fast-moving memecoin scalper for nad.fun bonding curves. 5-phase workflow: discover trending tokens, quick due diligence (30-second filter), entry with controlled sizing (5% max per token), monitor with hard exits (sell 50% at 2x, all at 5x, cut at -15%), rotate capital. 23 tools (8 nad.fun + market intelligence + support).
364
+
365
+ #### Pragma — General Purpose
366
+
367
+ _"Action, deed" (pragma)_
368
+
369
+ A faithful executor that follows your instructions exactly. No trading methodology, no opinions — condition-based execution (monitor, detect, execute, report). 46 tools (full protocol access). Use for conditional execution, custom strategies, multi-protocol tasks, or anything that doesn't fit Kairos or Thymos.
370
+
371
+ #### How Agents Are Spawned
372
+
373
+ On OpenClaw, autonomous agents run via `sessions_spawn` — OpenClaw's native background session mechanism. Each agent gets its own wallet from a pool and a sub-delegation scoped to its role.
374
+
375
+ ```mermaid
376
+ graph TD
377
+ A["User<br/>(signs delegation in browser)"]
378
+ B["Session Key<br/>(main agent)"]
379
+ C["Kairos<br/>$50 perps budget"]
380
+ D["Thymos<br/>$25 memecoin budget"]
381
+ E["Pragma<br/>$25 general budget"]
382
+
383
+ A -->|"Root delegation<br/>$100 / 7 days / 100 calls"| B
384
+ B -->|"Sub-delegation"| C
385
+ B -->|"Sub-delegation"| D
386
+ B -->|"Sub-delegation"| E
387
+
388
+ style A fill:#7c3aed,stroke:#a78bfa,color:#fff,stroke-width:2px
389
+ style B fill:#b45309,stroke:#f59e0b,color:#fff,stroke-width:2px
390
+ style C fill:#be123c,stroke:#fb7185,color:#fff,stroke-width:2px
391
+ style D fill:#0e7490,stroke:#22d3ee,color:#fff,stroke-width:2px
392
+ style E fill:#047857,stroke:#10b981,color:#fff,stroke-width:2px
393
+ ```
394
+
395
+ Sub-delegations can only **narrow** the root scope — an agent can't spend more than its budget or trade on contracts not in the root whitelist. Capital stays in your smart account; agent wallets only hold MON for gas.
396
+
397
+ The main agent monitors sub-agents via heartbeat every 30 minutes, checking budget, gas, trade status, and errors. Agents write structured journal entries that persist through context compaction.
398
+
399
+ ### Security Model
400
+
401
+ | | How It Works |
402
+ | ------------------------ | -------------------------------------------------------------- |
403
+ | **Session key storage** | File-based, `0600` permissions (owner read/write only) |
404
+ | **Delegation approval** | User signs with passkey in browser — cannot be bypassed |
405
+ | **On-chain enforcement** | Smart contract caveats (time, value, calls, targets, methods) |
406
+ | **Spender whitelist** | Approvals only sent to known protocol contracts |
407
+ | **Transfer recipients** | Whitelist enforced by AllowedCalldataEnforcer |
408
+ | **Sub-agent isolation** | Each agent gets its own wallet (no nonce conflicts) |
409
+ | **Revocation** | On-chain nonce increment invalidates all delegations instantly |
410
+
411
+ **What you control:**
412
+
413
+ - Your passkey never leaves your device (browser Secure Enclave)
414
+ - Your smart account holds all funds
415
+ - All trades execute on your account, not a shared pool
416
+ - Delegations are time-bound, call-limited, and target-restricted on-chain
417
+ - Instant revocation via `revoke_sub_agent` or `revoke_root_delegation`
418
+
419
+ **What the agent can do:**
420
+
421
+ - Execute trades within delegation constraints
422
+ - Cannot extend its own permissions
423
+ - Cannot access funds without a valid delegation
424
+ - Autonomous agents have strictly narrower scope than the root
425
+
426
+ ### x402 Protocol
427
+
428
+ In x402 mode, API calls are paid with USDC micropayments:
429
+
430
+ ```mermaid
431
+ sequenceDiagram
432
+ participant A as Agent
433
+ participant S as x402 API Server
434
+ participant U as Upstream Provider
435
+
436
+ A->>S: API request (e.g., /rpc, /chart)
437
+ S-->>A: 402 Payment Required (price + address)
438
+ A->>A: Session key signs USDC permit
439
+ A->>S: Retry with X-Payment header
440
+ S->>S: Verify payment signature
441
+ S->>U: Proxy request to upstream
442
+ U-->>S: Response data
443
+ S->>S: Settle USDC on-chain
444
+ S-->>A: Response data
445
+ Note over A,S: No charge if upstream fails
446
+ ```
447
+
448
+ If the upstream request fails, you're not charged. Payment only settles when data is successfully returned.
449
+
450
+ ---
451
+
452
+ ## Pricing
453
+
454
+ ### x402 Mode Costs
455
+
456
+ | Category | Operation | Cost (USDC) |
457
+ | ------------ | ------------------- | ----------- |
458
+ | **Basic** | RPC call | $0.001 |
459
+ | | Bundler call | $0.001 |
460
+ | | Swap quote | $0.001 |
461
+ | | Token / data lookup | $0.001 |
462
+ | **Market** | FX reference rates | $0.005 |
463
+ | | Weekly calendar | $0.005 |
464
+ | | Charts (Pyth OHLCV) | $0.005 |
465
+ | | Currency strength | $0.01 |
466
+ | | Economic events | $0.01 |
467
+ | | CB speeches | $0.01 |
468
+ | | News search | $0.015 |
469
+ | | Critical news | $0.02 |
470
+ | **Analysis** | Activity history | $0.02 |
471
+ | | Transaction decode | $0.03 |
472
+ | | Contract analysis | $0.05 |
473
+
474
+ New wallets get 50 free API calls. 1 USDC covers ~1,000 basic calls (RPC, quotes, token data).
475
+
476
+ ### BYOK Mode
477
+
478
+ Free. You provide your own API keys.
479
+
480
+ ### Gas Costs (On-Chain)
481
+
482
+ All operations execute through delegated smart account calls. Gas is paid by the session key in MON.
483
+
484
+ | Operation | Approximate Cost |
485
+ | ------------------ | ---------------- |
486
+ | Swap | ~0.14 MON |
487
+ | Transfer | ~0.04 MON |
488
+ | Wrap / Unwrap | ~0.04 MON |
489
+ | LeverUp open/close | ~0.14 MON |
490
+
491
+ ---
492
+
493
+ ## Requirements
494
+
495
+ - **Node.js 20+** (`crypto.subtle` required, unavailable in Node 18)
496
+ - **Linux or macOS** (designed for headless Linux servers)
497
+ - **OpenClaw** agent runtime
498
+ - **MON tokens** for gas (~0.5 MON to start)
499
+ - **A pragma Smart Account** — create one at [pr4gma.xyz/setup](https://pr4gma.xyz/setup)
500
+
501
+ ---
502
+
503
+ ## Troubleshooting
504
+
505
+ **MCP server fails to start**
506
+ Ensure Node.js 20+ is installed: `node -v`. The pragma MCP server requires `crypto.subtle`.
507
+
508
+ **"No delegation found" on every operation**
509
+ Run the delegation flow first: tell the agent "create a trading delegation". You'll get a link to approve in your browser.
510
+
511
+ **Session key has no gas**
512
+ The agent can self-fund via delegation (transfers MON from your Smart Account). If the session key has zero gas, self-funding can't work — manually send at least 0.5 MON to the session key address shown in the agent output.
513
+
514
+ **"pragma-signer binary not found"**
515
+ You're calling a macOS-only tool. `create_root_delegation` and `nadfun_create` require Touch ID and are blocked on this platform. Use `request_delegation` (web flow) instead.
516
+
517
+ **Delegation expired**
518
+ Tell the agent "renew my delegation" — it will create a new request with the same or updated scope.
519
+
520
+ **Sub-agent stuck**
521
+ Check agent status with `list_sub_agents`. If an agent is stuck, `revoke_sub_agent` cleans up its delegation and releases the wallet back to the pool.
522
+
523
+ **Tools not appearing in agent**
524
+ Restart the OpenClaw agent. Tool discovery happens at plugin startup when the MCP bridge connects.
525
+
526
+ ---
527
+
528
+ ## Acknowledgments
529
+
530
+ - [MetaMask Smart Accounts Kit](https://docs.metamask.io/smart-accounts-kit/) — smart account + delegation framework
531
+ - [x402](https://www.x402.org/) — HTTP 402 micropayment protocol
532
+ - [LeverUp](https://leverup.xyz) — perpetuals DEX on Monad
533
+ - [nad.fun](https://nad.fun) — memecoin launchpad on Monad
534
+ - [Monad](https://monad.xyz) — high-performance EVM L1
535
+ - [OpenClaw](https://openclaw.ai) — the agent runtime
536
+
537
+ ---
538
+
539
+ ## Support
540
+
541
+ - **X:** [@0xelpabl0](https://x.com/0xelpabl0)
542
+ - **Email:** s0nderlabs.hq@gmail.com
543
+ - **Issues:** [github.com/s0nderlabs/pragma-openclaw/issues](https://github.com/s0nderlabs/pragma-openclaw/issues)
544
+
545
+ ---
546
+
547
+ ## License
548
+
549
+ MIT
550
+
551
+ ---
552
+
553
+ [s0nderlabs](https://github.com/s0nderlabs)