pragma-openclaw 0.1.0
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/LICENSE +21 -0
- package/agents/kairos/AGENTS.md +261 -0
- package/agents/kairos/SOUL.md +46 -0
- package/agents/pragma/AGENTS.md +248 -0
- package/agents/pragma/SOUL.md +46 -0
- package/agents/thymos/AGENTS.md +200 -0
- package/agents/thymos/SOUL.md +46 -0
- package/dist/index.js +27390 -0
- package/openclaw.plugin.json +16 -0
- package/package.json +46 -0
- package/server/index.js +242 -0
- package/skills/pragma-autonomous/SKILL.md +214 -0
- package/skills/pragma-core/SKILL.md +358 -0
- package/skills/pragma-delegation/SKILL.md +300 -0
- package/skills/pragma-mode/SKILL.md +42 -0
- package/skills/pragma-setup/SKILL.md +164 -0
|
@@ -0,0 +1,214 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: pragma-autonomous
|
|
3
|
+
description: Manages autonomous trading with sub-agents. Use when user mentions autonomous, background trading, AFK trading, monitoring while away, delegate trading, hands-free trading, while I sleep, overnight, keep running, monitor and execute, condition trigger, or run until.
|
|
4
|
+
tools:
|
|
5
|
+
- pragma_has_wallet
|
|
6
|
+
- pragma_get_all_balances
|
|
7
|
+
- pragma_get_balance
|
|
8
|
+
- pragma_get_account_info
|
|
9
|
+
- pragma_check_session_key_balance
|
|
10
|
+
- pragma_fund_session_key
|
|
11
|
+
- pragma_setup_session
|
|
12
|
+
- pragma_request_delegation
|
|
13
|
+
- pragma_poll_delegation
|
|
14
|
+
- pragma_retrieve_delegation
|
|
15
|
+
- pragma_create_sub_agent
|
|
16
|
+
- pragma_get_sub_agent_state
|
|
17
|
+
- pragma_fund_sub_agent
|
|
18
|
+
- pragma_list_sub_agents
|
|
19
|
+
- pragma_revoke_sub_agent
|
|
20
|
+
- pragma_report_agent_status
|
|
21
|
+
- pragma_get_agent_log
|
|
22
|
+
- pragma_write_agent_memo
|
|
23
|
+
- pragma_market_get_chart
|
|
24
|
+
- pragma_market_get_critical_news
|
|
25
|
+
- pragma_market_get_economic_events
|
|
26
|
+
- pragma_leverup_list_positions
|
|
27
|
+
- pragma_leverup_list_pairs
|
|
28
|
+
- pragma_nadfun_positions
|
|
29
|
+
requires:
|
|
30
|
+
- pragma
|
|
31
|
+
metadata:
|
|
32
|
+
openclaw:
|
|
33
|
+
requires: ["pragma"]
|
|
34
|
+
---
|
|
35
|
+
|
|
36
|
+
# Pragma Autonomous — Sub-Agent Trading
|
|
37
|
+
|
|
38
|
+
> Manages autonomous trading sessions using sub-agents for concurrent, isolated execution.
|
|
39
|
+
|
|
40
|
+
## Overview
|
|
41
|
+
|
|
42
|
+
Autonomous mode combines two systems:
|
|
43
|
+
- **OpenClaw `sessions_spawn`** — background execution lifecycle, timeout, announce results
|
|
44
|
+
- **Pragma sub-agents** — wallet isolation, scoped delegation chain, on-chain budget enforcement, trade journal
|
|
45
|
+
|
|
46
|
+
Each sub-agent gets its own wallet (no nonce conflicts), scoped permissions (kairos can only trade perps, thymos only memecoins), and budget tracking. The main agent monitors sub-agents via heartbeat and reports to the user.
|
|
47
|
+
|
|
48
|
+
---
|
|
49
|
+
|
|
50
|
+
## Phase 1: Setup Check
|
|
51
|
+
|
|
52
|
+
```
|
|
53
|
+
1. pragma_has_wallet → Wallet configured?
|
|
54
|
+
→ No: Guide user through pragma-setup skill first
|
|
55
|
+
→ Yes: Continue
|
|
56
|
+
|
|
57
|
+
2. pragma_get_all_balances → Portfolio baseline
|
|
58
|
+
3. pragma_check_session_key_balance → Gas available?
|
|
59
|
+
→ < 0.1 MON: Ask user to send gas to session key address
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
## Phase 2: Delegation
|
|
63
|
+
|
|
64
|
+
If no delegation exists, use the **pragma-delegation** skill:
|
|
65
|
+
1. Ask user about trading scope
|
|
66
|
+
2. Submit delegation request with on-chain caveats
|
|
67
|
+
3. Guide user to approval URL
|
|
68
|
+
4. Poll and retrieve signed delegation
|
|
69
|
+
|
|
70
|
+
If delegation already exists and is valid, skip this phase.
|
|
71
|
+
|
|
72
|
+
## Phase 3: Auto-Detect Agent Type
|
|
73
|
+
|
|
74
|
+
Based on the user's request, auto-select which sub-agent(s) to spawn:
|
|
75
|
+
|
|
76
|
+
| User intent | Agent | Why |
|
|
77
|
+
|-------------|-------|-----|
|
|
78
|
+
| "monitor BTC, open long when funding flips" | kairos | Perps strategy |
|
|
79
|
+
| "watch ETH/BTC ratio for squeeze" | kairos | Leveraged trading |
|
|
80
|
+
| "snipe new tokens on nad.fun" | thymos | Memecoin strategy |
|
|
81
|
+
| "buy momentum tokens, sell at 2x" | thymos | Bonding curve trading |
|
|
82
|
+
| "trade perps AND scan memecoins" | kairos + thymos | Both detected |
|
|
83
|
+
| "monitor market and execute when ready" | pragma | General/conditional |
|
|
84
|
+
| "swap USDC to MON when price drops 5%" | pragma | Spot/conditional |
|
|
85
|
+
|
|
86
|
+
The user never needs to name agents — they describe what they want.
|
|
87
|
+
|
|
88
|
+
## Phase 4: Create Sub-Agents
|
|
89
|
+
|
|
90
|
+
For each agent type detected:
|
|
91
|
+
|
|
92
|
+
```
|
|
93
|
+
pragma_create_sub_agent({
|
|
94
|
+
agentType: "kairos" | "thymos" | "pragma",
|
|
95
|
+
budgetMon: <from delegation scope>,
|
|
96
|
+
budgetUsd: <if applicable>,
|
|
97
|
+
expiryDays: <match delegation>,
|
|
98
|
+
maxCalls: <calculated from delegation>,
|
|
99
|
+
fundAmount: 0.5
|
|
100
|
+
})
|
|
101
|
+
→ Returns: { subAgentId, walletAddress, agentType }
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
If funding was not included in creation, fund separately:
|
|
105
|
+
```
|
|
106
|
+
pragma_fund_sub_agent({ subAgentId, amount: "0.5" })
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
## Phase 5: Spawn Background Sessions
|
|
110
|
+
|
|
111
|
+
For each created sub-agent, spawn a background session:
|
|
112
|
+
|
|
113
|
+
```
|
|
114
|
+
sessions_spawn({
|
|
115
|
+
task: "You are a [agentType] sub-agent.
|
|
116
|
+
Your pragma sub-agent ID is [subAgentId].
|
|
117
|
+
CRITICAL: Pass agentId=\"[subAgentId]\" to EVERY pragma_ trading tool call.
|
|
118
|
+
|
|
119
|
+
On start: call pragma_report_agent_status({ agentId: \"[subAgentId]\", status: \"running\" })
|
|
120
|
+
During execution: call pragma_write_agent_memo({ agentId: \"[subAgentId]\", text: \"...\", tag: \"...\" }) to persist reasoning
|
|
121
|
+
On finish: call pragma_report_agent_status({ agentId: \"[subAgentId]\", status: \"completed\" or \"failed\", reason: \"...\" })
|
|
122
|
+
|
|
123
|
+
Mission: [user's strategy description]",
|
|
124
|
+
label: "[agentType]-[short-id]",
|
|
125
|
+
runTimeoutSeconds: 86400
|
|
126
|
+
})
|
|
127
|
+
```
|
|
128
|
+
|
|
129
|
+
Tell the user which sub-agents were spawned and what they're doing.
|
|
130
|
+
|
|
131
|
+
## Phase 6: Heartbeat Monitoring
|
|
132
|
+
|
|
133
|
+
After spawning, update `HEARTBEAT.md` in the workspace:
|
|
134
|
+
|
|
135
|
+
```md
|
|
136
|
+
# Heartbeat checklist
|
|
137
|
+
- Check pragma sub-agents: call pragma_list_sub_agents, then pragma_get_sub_agent_state for each active one
|
|
138
|
+
- Report budget remaining, trades executed, gas balance, and errors to user
|
|
139
|
+
- If any sub-agent gas < 0.2 MON: alert user immediately
|
|
140
|
+
- If any sub-agent status = completed or failed: announce results and offer cleanup
|
|
141
|
+
- If delegation expiring < 24h: warn user and offer renewal
|
|
142
|
+
- If all sub-agents completed: remove this checklist from HEARTBEAT.md
|
|
143
|
+
```
|
|
144
|
+
|
|
145
|
+
The main agent wakes up on heartbeat every 30 minutes and:
|
|
146
|
+
1. Calls `pragma_list_sub_agents` → which are running?
|
|
147
|
+
2. Calls `pragma_get_sub_agent_state({ subAgentId })` for each active one → budget, gas, trades, errors
|
|
148
|
+
3. Calls `pragma_get_agent_log({ agentId, limit: 5 })` → recent decisions
|
|
149
|
+
4. Reports a concise summary to the user
|
|
150
|
+
5. Alerts on low gas, budget warnings, completions, errors
|
|
151
|
+
|
|
152
|
+
## Phase 7: Cleanup
|
|
153
|
+
|
|
154
|
+
When sub-agents complete or user requests stop:
|
|
155
|
+
|
|
156
|
+
```
|
|
157
|
+
pragma_revoke_sub_agent({ subAgentId, sweepBalance: true })
|
|
158
|
+
```
|
|
159
|
+
|
|
160
|
+
After all sub-agents are cleaned up, remove the monitoring checklist from `HEARTBEAT.md`.
|
|
161
|
+
|
|
162
|
+
---
|
|
163
|
+
|
|
164
|
+
## Sub-Agent Behavior (instructions passed via spawn task)
|
|
165
|
+
|
|
166
|
+
The spawned sub-agent receives its instructions via the `sessions_spawn` task. Key rules:
|
|
167
|
+
|
|
168
|
+
1. **Always pass agentId** to every `pragma_` trading tool call — this routes through the sub-agent's delegation chain
|
|
169
|
+
2. **Report status** via `pragma_report_agent_status` on start, completion, failure, or pause
|
|
170
|
+
3. **Write memos** via `pragma_write_agent_memo` to persist reasoning (survives context compaction):
|
|
171
|
+
- Tag `baseline`: Initial market analysis
|
|
172
|
+
- Tag `watchlist`: Pairs and trigger levels being monitored
|
|
173
|
+
- Tag `trade_plan`: Kill switch + bear case + trade params before entering
|
|
174
|
+
- Tag `position_health`: Monitoring snapshots
|
|
175
|
+
- Tag `post_trade`: Session summary and PnL
|
|
176
|
+
4. **Budget awareness**: The delegation chain enforces limits on-chain. If a tool returns budget/calls exceeded, stop and report.
|
|
177
|
+
5. **Gas awareness**: If a tool fails with gas errors, call `pragma_report_agent_status({ status: "paused", reason: "Low gas" })` — the main agent will see this on next heartbeat.
|
|
178
|
+
|
|
179
|
+
---
|
|
180
|
+
|
|
181
|
+
## Session Key Self-Funding
|
|
182
|
+
|
|
183
|
+
Delegations include transfer groups, allowing gas management:
|
|
184
|
+
|
|
185
|
+
- **Session key gas:** `pragma_fund_session_key(operationType: "swap", estimatedOperations: 5)` — uses delegation Group 3
|
|
186
|
+
- **Sub-agent gas:** `pragma_fund_sub_agent({ subAgentId, amount: "0.5" })` — plain EOA transfer from session key
|
|
187
|
+
|
|
188
|
+
**Constraints:**
|
|
189
|
+
- Self-funding requires > 0.02 MON gas to submit the transaction
|
|
190
|
+
- If gas is zero, tell the user: "Session key is out of gas. Please send at least 0.5 MON to: [address]"
|
|
191
|
+
- No UserOp on this platform
|
|
192
|
+
|
|
193
|
+
---
|
|
194
|
+
|
|
195
|
+
## Error Recovery
|
|
196
|
+
|
|
197
|
+
| Error | Recovery |
|
|
198
|
+
|-------|----------|
|
|
199
|
+
| Delegation expired | Notify user, use pragma-delegation skill to renew, then re-create sub-agents |
|
|
200
|
+
| Sub-agent gas low | Main agent funds it via `pragma_fund_sub_agent` on heartbeat |
|
|
201
|
+
| Session key gas low | Try `pragma_fund_session_key`, or ask user to send MON manually |
|
|
202
|
+
| Sub-agent budget exhausted | Sub-agent reports "completed", main agent announces results |
|
|
203
|
+
| Sub-agent failed | Main agent sees on heartbeat, reports error, offers restart |
|
|
204
|
+
| Network error | Sub-agent retries 3 times, then pauses and reports |
|
|
205
|
+
|
|
206
|
+
---
|
|
207
|
+
|
|
208
|
+
## Security
|
|
209
|
+
|
|
210
|
+
- Each sub-agent has its own wallet — isolated nonce sequence, no cross-contamination
|
|
211
|
+
- Sub-delegation scoped to agent type (kairos: perps only, thymos: nadfun only, pragma: all)
|
|
212
|
+
- On-chain enforcement via delegation caveats (value limit, call limit, timestamp)
|
|
213
|
+
- User approves delegation via browser (pr4gma.xyz) — cannot be bypassed
|
|
214
|
+
- Revocation sweeps remaining gas back to session key
|
|
@@ -0,0 +1,358 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: pragma-core
|
|
3
|
+
description: Operates pragma wallet for on-chain trading and market intelligence on Monad. Use when user mentions wallet, balance, portfolio, swap, trade, buy, sell, transfer, send, wrap, unwrap, tokens, DeFi, price, chart, market, position, leverage, perps, perpetuals, memecoin, nadfun, nad.fun, leverup, transaction, contract, block, gas, news, economic, forex, currency, MON, USDC, WMON, LVUSD, or any on-chain operation.
|
|
4
|
+
tools:
|
|
5
|
+
- pragma_has_wallet
|
|
6
|
+
- pragma_has_providers
|
|
7
|
+
- pragma_setup_wallet
|
|
8
|
+
- pragma_set_mode
|
|
9
|
+
- pragma_get_balance
|
|
10
|
+
- pragma_get_all_balances
|
|
11
|
+
- pragma_list_verified_tokens
|
|
12
|
+
- pragma_get_token_info
|
|
13
|
+
- pragma_get_account_info
|
|
14
|
+
- pragma_check_session_key_balance
|
|
15
|
+
- pragma_fund_session_key
|
|
16
|
+
- pragma_withdraw_session_key
|
|
17
|
+
- pragma_get_swap_quote
|
|
18
|
+
- pragma_execute_swap
|
|
19
|
+
- pragma_transfer
|
|
20
|
+
- pragma_wrap
|
|
21
|
+
- pragma_unwrap
|
|
22
|
+
- pragma_get_block
|
|
23
|
+
- pragma_get_gas_price
|
|
24
|
+
- pragma_explain_transaction
|
|
25
|
+
- pragma_get_onchain_activity
|
|
26
|
+
- pragma_explain_contract
|
|
27
|
+
- pragma_nadfun_status
|
|
28
|
+
- pragma_nadfun_quote
|
|
29
|
+
- pragma_nadfun_buy
|
|
30
|
+
- pragma_nadfun_sell
|
|
31
|
+
- pragma_nadfun_discover
|
|
32
|
+
- pragma_nadfun_token_info
|
|
33
|
+
- pragma_nadfun_positions
|
|
34
|
+
- pragma_nadfun_create
|
|
35
|
+
- pragma_leverup_list_pairs
|
|
36
|
+
- pragma_leverup_list_positions
|
|
37
|
+
- pragma_leverup_get_quote
|
|
38
|
+
- pragma_leverup_open_trade
|
|
39
|
+
- pragma_leverup_close_trade
|
|
40
|
+
- pragma_leverup_update_margin
|
|
41
|
+
- pragma_leverup_update_tpsl
|
|
42
|
+
- pragma_leverup_get_market_stats
|
|
43
|
+
- pragma_leverup_get_funding_rates
|
|
44
|
+
- pragma_leverup_open_limit_order
|
|
45
|
+
- pragma_leverup_list_limit_orders
|
|
46
|
+
- pragma_leverup_cancel_limit_order
|
|
47
|
+
- pragma_market_get_chart
|
|
48
|
+
- pragma_market_get_fx_reference
|
|
49
|
+
- pragma_market_get_currency_strength
|
|
50
|
+
- pragma_market_get_economic_events
|
|
51
|
+
- pragma_market_get_weekly_calendar
|
|
52
|
+
- pragma_market_get_critical_news
|
|
53
|
+
- pragma_market_search_news
|
|
54
|
+
- pragma_market_get_cb_speeches
|
|
55
|
+
- pragma_create_sub_agent
|
|
56
|
+
- pragma_get_sub_agent_state
|
|
57
|
+
- pragma_fund_sub_agent
|
|
58
|
+
- pragma_list_sub_agents
|
|
59
|
+
- pragma_revoke_sub_agent
|
|
60
|
+
- pragma_report_agent_status
|
|
61
|
+
- pragma_get_agent_log
|
|
62
|
+
- pragma_write_agent_memo
|
|
63
|
+
requires:
|
|
64
|
+
- pragma
|
|
65
|
+
metadata:
|
|
66
|
+
openclaw:
|
|
67
|
+
requires: ["pragma"]
|
|
68
|
+
---
|
|
69
|
+
|
|
70
|
+
# Pragma Core — Trading Skill
|
|
71
|
+
|
|
72
|
+
> On-chain trading and market intelligence on Monad.
|
|
73
|
+
|
|
74
|
+
## Critical Rules
|
|
75
|
+
|
|
76
|
+
1. **Call tools directly.** You MUST call the `pragma_` tools yourself — directly, in this conversation. NEVER spawn sub-agents, background tasks, or delegate to other agents for pragma operations. Sub-agents do not have access to pragma tools and will always fail. You have all the tools you need.
|
|
77
|
+
|
|
78
|
+
2. **Tool calls only.** ALL on-chain operations MUST use the `pragma_` tools listed below. NEVER run bash commands, create scripts, or use `exec` for blockchain operations. Tool names like `pragma_get_swap_quote` are MCP tool calls, NOT CLI commands — do not try to run them in a shell.
|
|
79
|
+
|
|
80
|
+
3. **Signing is automatic.** All write operations (swap, transfer, buy, sell, wrap, open trade, etc.) handle signing and delegation internally. You do NOT need to worry about signers, passkeys, Touch ID, or binaries. Just call the tool.
|
|
81
|
+
|
|
82
|
+
4. **No workarounds.** If a tool call fails, report the error to the user. Do NOT attempt workarounds like writing scripts, running bash commands, spawning sub-agents, or trying alternative approaches.
|
|
83
|
+
|
|
84
|
+
5. **Delegation is handled.** Before requesting a new delegation, try the operation first. Only use the pragma-delegation skill if a tool returns "Delegation expired" or "No delegation found". Do NOT proactively create delegations before attempting trades.
|
|
85
|
+
|
|
86
|
+
6. **Use the correct delegation tool.** When you need a new delegation, use `pragma_request_delegation` (the web-based approval flow). NEVER use `pragma_create_root_delegation` — that tool requires macOS Touch ID and will always fail on this platform.
|
|
87
|
+
|
|
88
|
+
---
|
|
89
|
+
|
|
90
|
+
## Prerequisites
|
|
91
|
+
|
|
92
|
+
Before ANY operation, verify wallet status:
|
|
93
|
+
|
|
94
|
+
```
|
|
95
|
+
pragma_has_wallet → if not set up → tell user to run setup first
|
|
96
|
+
pragma_get_all_balances → verify sufficient balance for operation
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
**NEVER skip the balance check.** Every trade, swap, or transfer must be preceded by a balance verification.
|
|
100
|
+
|
|
101
|
+
---
|
|
102
|
+
|
|
103
|
+
## Delegation Health
|
|
104
|
+
|
|
105
|
+
You do NOT need to check delegation before every operation — just try the operation. The MCP tools automatically use the stored delegation. But when an error occurs:
|
|
106
|
+
|
|
107
|
+
| Error from tool | What to do |
|
|
108
|
+
|----------------|------------|
|
|
109
|
+
| "Delegation expired" | Tell user → use pragma-delegation skill to renew |
|
|
110
|
+
| "No delegation found" | Tell user → use pragma-delegation skill to create one |
|
|
111
|
+
| "LimitedCalls exceeded" | Delegation used up all allowed calls → renew |
|
|
112
|
+
|
|
113
|
+
**Session key gas management:**
|
|
114
|
+
- **Low gas (> 0.02 MON remaining):** Use `pragma_fund_session_key` — it transfers MON from the user's Smart Account to the session key via delegation. No extra approval needed.
|
|
115
|
+
- **Zero gas (< 0.02 MON):** Self-funding CANNOT work because the session key needs gas to submit the funding transaction. Tell the user: "Your session key is out of gas. Please send at least 0.5 MON to: [session key address]"
|
|
116
|
+
- **No UserOp on this platform.** The bundler/UserOp path is not available here. Do NOT mention UserOp to the user.
|
|
117
|
+
|
|
118
|
+
---
|
|
119
|
+
|
|
120
|
+
## Tool Reference (54 Tools)
|
|
121
|
+
|
|
122
|
+
### Wallet & Account
|
|
123
|
+
|
|
124
|
+
| Tool | Purpose |
|
|
125
|
+
|------|---------|
|
|
126
|
+
| `pragma_has_wallet` | Check if wallet is configured |
|
|
127
|
+
| `pragma_has_providers` | Check API provider status |
|
|
128
|
+
| `pragma_setup_wallet` | Initialize wallet (file-based signer) |
|
|
129
|
+
| `pragma_set_mode` | Switch between BYOK and x402 modes |
|
|
130
|
+
| `pragma_get_account_info` | Smart Account address and details |
|
|
131
|
+
| `pragma_check_session_key_balance` | Session key gas balance |
|
|
132
|
+
| `pragma_fund_session_key` | Transfer MON/USDC from SA to session key via delegation |
|
|
133
|
+
| `pragma_withdraw_session_key` | Withdraw gas from session key |
|
|
134
|
+
|
|
135
|
+
### Balances & Tokens
|
|
136
|
+
|
|
137
|
+
| Tool | Purpose |
|
|
138
|
+
|------|---------|
|
|
139
|
+
| `pragma_get_balance` | Single token balance |
|
|
140
|
+
| `pragma_get_all_balances` | Full portfolio (all token balances) |
|
|
141
|
+
| `pragma_list_verified_tokens` | All verified tokens on Monad |
|
|
142
|
+
| `pragma_get_token_info` | Token metadata (name, symbol, decimals) |
|
|
143
|
+
|
|
144
|
+
### DeFi Operations
|
|
145
|
+
|
|
146
|
+
| Tool | Purpose |
|
|
147
|
+
|------|---------|
|
|
148
|
+
| `pragma_get_swap_quote` | Get swap quote from DEX aggregator |
|
|
149
|
+
| `pragma_execute_swap` | Execute token swap |
|
|
150
|
+
| `pragma_transfer` | Send tokens to address |
|
|
151
|
+
| `pragma_wrap` | MON → WMON |
|
|
152
|
+
| `pragma_unwrap` | WMON → MON |
|
|
153
|
+
|
|
154
|
+
### nad.fun (Memecoins)
|
|
155
|
+
|
|
156
|
+
| Tool | Purpose |
|
|
157
|
+
|------|---------|
|
|
158
|
+
| `pragma_nadfun_status` | Bonding curve progress, market cap, volume |
|
|
159
|
+
| `pragma_nadfun_quote` | Buy/sell price quotes |
|
|
160
|
+
| `pragma_nadfun_buy` | Buy tokens on bonding curve |
|
|
161
|
+
| `pragma_nadfun_sell` | Sell tokens from bonding curve |
|
|
162
|
+
| `pragma_nadfun_discover` | Trending tokens (by market cap, creation, latest trade) |
|
|
163
|
+
| `pragma_nadfun_token_info` | Token details, creator, metadata |
|
|
164
|
+
| `pragma_nadfun_positions` | Current holdings and unrealized PnL |
|
|
165
|
+
| `pragma_nadfun_create` | Launch new token on bonding curve |
|
|
166
|
+
|
|
167
|
+
### LeverUp (Perpetuals)
|
|
168
|
+
|
|
169
|
+
| Tool | Purpose |
|
|
170
|
+
|------|---------|
|
|
171
|
+
| `pragma_leverup_list_pairs` | Available pairs, prices, spreads |
|
|
172
|
+
| `pragma_leverup_list_positions` | Open positions, PnL, margin, liq distance |
|
|
173
|
+
| `pragma_leverup_get_quote` | Position quote (margin, fees, liq price) |
|
|
174
|
+
| `pragma_leverup_open_trade` | Open market position |
|
|
175
|
+
| `pragma_leverup_close_trade` | Close position |
|
|
176
|
+
| `pragma_leverup_update_margin` | Add/remove margin |
|
|
177
|
+
| `pragma_leverup_update_tpsl` | Update TP/SL levels |
|
|
178
|
+
| `pragma_leverup_get_market_stats` | OI, volume, spread per pair |
|
|
179
|
+
| `pragma_leverup_get_funding_rates` | Holding fee rates (carry cost) |
|
|
180
|
+
| `pragma_leverup_open_limit_order` | Place limit order |
|
|
181
|
+
| `pragma_leverup_list_limit_orders` | Pending limit orders |
|
|
182
|
+
| `pragma_leverup_cancel_limit_order` | Cancel limit order |
|
|
183
|
+
|
|
184
|
+
### Market Intelligence
|
|
185
|
+
|
|
186
|
+
| Tool | Purpose | x402 Cost |
|
|
187
|
+
|------|---------|-----------|
|
|
188
|
+
| `pragma_market_get_chart` | Price charts (Pyth Benchmark) | $0.005 |
|
|
189
|
+
| `pragma_market_get_fx_reference` | FX reference rates | $0.005 |
|
|
190
|
+
| `pragma_market_get_currency_strength` | Currency strength analysis | $0.01 |
|
|
191
|
+
| `pragma_market_get_economic_events` | Economic calendar | $0.01 |
|
|
192
|
+
| `pragma_market_get_weekly_calendar` | Weekly calendar by day | $0.005 |
|
|
193
|
+
| `pragma_market_get_critical_news` | Breaking/critical news | $0.02 |
|
|
194
|
+
| `pragma_market_search_news` | Search news by keyword | $0.015 |
|
|
195
|
+
| `pragma_market_get_cb_speeches` | Central bank communications | $0.01 |
|
|
196
|
+
|
|
197
|
+
### Chain Data
|
|
198
|
+
|
|
199
|
+
| Tool | Purpose |
|
|
200
|
+
|------|---------|
|
|
201
|
+
| `pragma_get_block` | Block number and timestamp |
|
|
202
|
+
| `pragma_get_gas_price` | Current gas prices |
|
|
203
|
+
| `pragma_explain_transaction` | Decode any transaction hash |
|
|
204
|
+
| `pragma_get_onchain_activity` | Transaction history for any address |
|
|
205
|
+
|
|
206
|
+
### Contract Analysis
|
|
207
|
+
|
|
208
|
+
| Tool | Purpose |
|
|
209
|
+
|------|---------|
|
|
210
|
+
| `pragma_explain_contract` | Analyze and explain smart contract |
|
|
211
|
+
|
|
212
|
+
### Sub-Agent Management (8)
|
|
213
|
+
|
|
214
|
+
| Tool | Purpose |
|
|
215
|
+
|------|---------|
|
|
216
|
+
| `pragma_create_sub_agent` | Create sub-agent with scoped delegation + wallet |
|
|
217
|
+
| `pragma_get_sub_agent_state` | Budget, trades, gas, errors, loop config |
|
|
218
|
+
| `pragma_fund_sub_agent` | Transfer MON from session key to sub-agent wallet |
|
|
219
|
+
| `pragma_list_sub_agents` | List all sub-agents and status |
|
|
220
|
+
| `pragma_revoke_sub_agent` | Revoke delegation, sweep balance, cleanup |
|
|
221
|
+
| `pragma_report_agent_status` | Sub-agent reports running/paused/completed/failed |
|
|
222
|
+
| `pragma_get_agent_log` | Read sub-agent journal entries (paginated, filterable by tag) |
|
|
223
|
+
| `pragma_write_agent_memo` | Write structured memo to sub-agent journal |
|
|
224
|
+
|
|
225
|
+
---
|
|
226
|
+
|
|
227
|
+
## Operation Flows
|
|
228
|
+
|
|
229
|
+
### Swap (Single)
|
|
230
|
+
|
|
231
|
+
```
|
|
232
|
+
1. pragma_get_all_balances → Verify source token balance
|
|
233
|
+
2. pragma_get_swap_quote(from, to, amount) → Show quote to user
|
|
234
|
+
3. pragma_execute_swap(from, to, amount) → Execute after confirmation
|
|
235
|
+
4. pragma_get_all_balances → Confirm new balances
|
|
236
|
+
```
|
|
237
|
+
|
|
238
|
+
### Swap (Batch)
|
|
239
|
+
|
|
240
|
+
For multiple swaps in sequence:
|
|
241
|
+
|
|
242
|
+
```
|
|
243
|
+
1. pragma_get_all_balances → Portfolio snapshot
|
|
244
|
+
2. For each swap:
|
|
245
|
+
a. pragma_get_swap_quote(...) → Get quote
|
|
246
|
+
b. pragma_execute_swap(...) → Execute
|
|
247
|
+
3. pragma_get_all_balances → Final portfolio
|
|
248
|
+
```
|
|
249
|
+
|
|
250
|
+
### Transfer
|
|
251
|
+
|
|
252
|
+
```
|
|
253
|
+
1. pragma_get_balance(token) → Verify sufficient balance
|
|
254
|
+
2. pragma_transfer(token, to, amount) → Execute transfer
|
|
255
|
+
3. pragma_get_balance(token) → Confirm new balance
|
|
256
|
+
```
|
|
257
|
+
|
|
258
|
+
### Wrap / Unwrap
|
|
259
|
+
|
|
260
|
+
```
|
|
261
|
+
1. pragma_get_all_balances → Check MON/WMON balance
|
|
262
|
+
2. pragma_wrap(amount) or pragma_unwrap(amount)
|
|
263
|
+
3. pragma_get_all_balances → Confirm
|
|
264
|
+
```
|
|
265
|
+
|
|
266
|
+
### nad.fun Buy
|
|
267
|
+
|
|
268
|
+
```
|
|
269
|
+
1. pragma_get_all_balances → Verify MON balance
|
|
270
|
+
2. pragma_nadfun_token_info(address) → Token details
|
|
271
|
+
3. pragma_nadfun_status(address) → Bonding curve progress
|
|
272
|
+
4. pragma_nadfun_quote(address, "buy", amount) → Price quote
|
|
273
|
+
5. pragma_nadfun_buy(address, amount) → Execute buy
|
|
274
|
+
6. pragma_nadfun_positions → Confirm position
|
|
275
|
+
```
|
|
276
|
+
|
|
277
|
+
### nad.fun Sell
|
|
278
|
+
|
|
279
|
+
```
|
|
280
|
+
1. pragma_nadfun_positions → Current holdings
|
|
281
|
+
2. pragma_nadfun_quote(address, "sell", amount) → Price quote
|
|
282
|
+
3. pragma_nadfun_sell(address, amount) → Execute sell
|
|
283
|
+
4. pragma_nadfun_positions → Confirm
|
|
284
|
+
```
|
|
285
|
+
|
|
286
|
+
### LeverUp Open Position
|
|
287
|
+
|
|
288
|
+
```
|
|
289
|
+
1. pragma_get_all_balances → Verify LVUSD/collateral balance
|
|
290
|
+
2. pragma_leverup_list_pairs → Current prices and spreads
|
|
291
|
+
3. pragma_leverup_get_quote(pair, direction, leverage, size) → Quote
|
|
292
|
+
4. pragma_leverup_open_trade(pair, direction, leverage, size, tp, sl)
|
|
293
|
+
5. pragma_leverup_list_positions → Confirm position opened
|
|
294
|
+
```
|
|
295
|
+
|
|
296
|
+
### LeverUp Close Position
|
|
297
|
+
|
|
298
|
+
```
|
|
299
|
+
1. pragma_leverup_list_positions → Find position to close
|
|
300
|
+
2. pragma_leverup_close_trade(positionId) → Close
|
|
301
|
+
3. pragma_get_all_balances → Confirm PnL settled
|
|
302
|
+
```
|
|
303
|
+
|
|
304
|
+
### Limit Order
|
|
305
|
+
|
|
306
|
+
```
|
|
307
|
+
1. pragma_leverup_list_pairs → Current prices
|
|
308
|
+
2. pragma_leverup_get_quote(pair, direction, leverage, size) → Quote at target
|
|
309
|
+
3. pragma_leverup_open_limit_order(pair, direction, leverage, size, triggerPrice, tp, sl)
|
|
310
|
+
4. pragma_leverup_list_limit_orders → Confirm order placed
|
|
311
|
+
```
|
|
312
|
+
|
|
313
|
+
---
|
|
314
|
+
|
|
315
|
+
## Token Resolution
|
|
316
|
+
|
|
317
|
+
Tokens can be specified by:
|
|
318
|
+
1. **Symbol** — `MON`, `USDC`, `WMON`, `LVUSD`
|
|
319
|
+
2. **Name** — `Monad`, `USD Coin`
|
|
320
|
+
3. **Address** — `0x...` (full contract address)
|
|
321
|
+
|
|
322
|
+
The MCP server handles resolution automatically. Use `pragma_list_verified_tokens` if the user asks about available tokens.
|
|
323
|
+
|
|
324
|
+
---
|
|
325
|
+
|
|
326
|
+
## Error Handling
|
|
327
|
+
|
|
328
|
+
| Error | Action |
|
|
329
|
+
|-------|--------|
|
|
330
|
+
| "Wallet not configured" | Tell user to run setup |
|
|
331
|
+
| "Insufficient balance" | Show current balance, suggest amount adjustment |
|
|
332
|
+
| "Slippage exceeded" | Retry with higher slippage or smaller amount |
|
|
333
|
+
| "Delegation expired" | Tell user to approve a new delegation |
|
|
334
|
+
| "Rate limited" | Wait and retry |
|
|
335
|
+
| "Network error" | Retry once, then report |
|
|
336
|
+
|
|
337
|
+
---
|
|
338
|
+
|
|
339
|
+
## Confirmation Rules
|
|
340
|
+
|
|
341
|
+
**Always confirm before execution:**
|
|
342
|
+
- Swaps over $50 value
|
|
343
|
+
- Transfers of any amount
|
|
344
|
+
- Opening leveraged positions
|
|
345
|
+
- Any action that moves funds
|
|
346
|
+
|
|
347
|
+
**Show the user:**
|
|
348
|
+
- What will happen (action + amounts)
|
|
349
|
+
- Current price / quote
|
|
350
|
+
- Expected outcome
|
|
351
|
+
- Any fees or slippage
|
|
352
|
+
|
|
353
|
+
**Execute without extra confirmation:**
|
|
354
|
+
- Balance checks
|
|
355
|
+
- Quote requests
|
|
356
|
+
- Market data queries
|
|
357
|
+
- Token info lookups
|
|
358
|
+
- Read-only operations
|