jaspervault_cli 1.0.28 → 1.0.30

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.
@@ -1,245 +1,200 @@
1
1
  # Trading Reference
2
2
 
3
- ## 1. Create Order (`jv order create`)
3
+ > All tools below are MCP tools. Call them directly — never run `jv` shell commands.
4
4
 
5
- Open, close, reduce, or add size to perpetual positions.
6
-
7
- ### Syntax
5
+ ## 1. Create Order `create_order`
8
6
 
9
- ```
10
- jv order create --side <long|short> --symbol <symbol> -m <margin> [options]
11
- ```
7
+ Open, close, reduce, or add size to perpetual positions.
12
8
 
13
- ### Options
14
-
15
- | Option | Required | Default | Description |
16
- |--------|----------|---------|-------------|
17
- | `--side <long\|short>` | Yes | — | Position side |
18
- | `--symbol <symbol>` | Yes | — | Asset symbol (e.g., `JBTC`, `CBBTC`) |
19
- | `-m, --margin <usdc>` | Yes | — | Margin (collateral) in USDC |
20
- | `--leverage <n>` | No | `50` (from chain config) | Leverage multiplier |
21
- | `--limit-price <price>` | No | — | Limit price in USDC (omit for market order) |
22
- | `--margin-account <addr>` | No | from profile | Override margin vault address |
23
- | `--position-account <addr>` | No | from profile | Override position vault address |
24
- | `--ppo` | No | | Enable PPO hedge option protection |
25
- | `--ppo-expire <duration>` | No | `30m` | PPO expiry: `30m` or `8h` |
26
- | `--ppo-category <ATM\|OTM>` | No | `ATM` | PPO option category |
27
- | `--ppo-tier <1-5>` | No | — | OTM strike offset tier (required if OTM) |
28
- | `--network <name>` | No | `jaspervault` | Network name |
29
- | `--ttl <seconds>` | No | `3600` | Order TTL in seconds |
30
- | `--pretty` | No | — | Pretty-print JSON output |
9
+ ### Parameters
10
+
11
+ | Parameter | Required | Default | Description |
12
+ |-----------|----------|---------|-------------|
13
+ | `side` | Yes | — | `long` or `short` |
14
+ | `symbol` | Yes | — | Asset symbol (e.g., `JBTC`, `CBBTC`) |
15
+ | `margin` | Yes | — | Margin (collateral) in USDC |
16
+ | `leverage` | No | `50` | Leverage multiplier |
17
+ | `limit_price` | No | — | Limit price in USDC (omit for market order) |
18
+ | `ppo` | No | | `true` to enable PPO hedge option protection |
19
+ | `ppo_expire` | No | `30m` | PPO expiry: `30m` or `8h` |
20
+ | `ppo_category` | No | `ATM` | PPO option category: `ATM` or `OTM` |
21
+ | `ppo_tier` | No | | OTM strike offset tier 1-5 (required if OTM) |
22
+ | `ttl` | No | `3600` | Order TTL in seconds |
31
23
 
32
24
  ### Market Order vs Limit Order
33
25
 
34
- - **Market order** (no `--limit-price`): Executes immediately at current market price. The CLI auto-waits up to 60s for the on-chain result via SSE.
35
- - **Limit order** (`--limit-price <N>`): Places a limit order that triggers when price reaches the target. Returns immediately with a `limitOrderId`.
26
+ - **Market order** (no `limit_price`): Executes immediately. The tool auto-waits up to 60s for the on-chain result.
27
+ - **Limit order** (`limit_price` set): Places a limit order that triggers when price reaches the target. Returns immediately with a `limitOrderId`.
36
28
 
37
- ### Market Order Output (TWO JSON lines)
29
+ ### Market Order Response
38
30
 
39
- **Line 1 Submission:**
40
- ```json
41
- {"success":true,"orderType":"market","jobId":"MARKET_ORDER_xxx","statusUrl":"/api/job/status/...","streamUrl":"/api/job/stream/..."}
42
- ```
31
+ The tool returns the final execution result:
43
32
 
44
- **Line 2 — Execution result (auto-waits up to 60s):**
45
33
  ```json
46
- {"jobId":"MARKET_ORDER_xxx","status":"completed","transactionHash":"0x..."}
34
+ {
35
+ "jobId": "MARKET_ORDER_xxx",
36
+ "status": "completed",
37
+ "transactionHash": "0x..."
38
+ }
47
39
  ```
48
40
 
49
- **CRITICAL rules after market order execution:**
50
- 1. If `status === "completed"` → the order IS executed. Do NOT retry or place another order.
41
+ **After market order execution:**
42
+ 1. If `status === "completed"` → the order IS executed. Don't retry.
51
43
  2. If `status === "failed"` → report the error to the user.
52
- 3. If `status === "timeout"` → use `jv job status <jobId> --pretty` to check later.
53
- 4. The `operation` field (if present) contains raw on-chain data in wei — do NOT interpret it.
54
- 5. To verify the actual position, run `jv orders list --pretty` and read the human-readable fields.
55
- 6. Report: "Order executed. Tx: {transactionHash}. Let me check your updated position..." then run `jv orders list --pretty`.
44
+ 3. If `status === "timeout"` → use `get_job_status` with the `jobId` to check later.
45
+ 4. The `operation` field (if present) contains raw on-chain data in wei — don't interpret it.
46
+ 5. To verify the actual position, call `list_orders` and read the human-readable fields.
47
+ 6. Report: "Order executed. Tx: {transactionHash}. Let me check your updated position..." then call `list_orders`.
48
+
49
+ ### Limit Order Response
56
50
 
57
- **Limit order output:**
58
51
  ```json
59
- {"success":true,"orderType":"limit","limitOrderId":"0x..."}
52
+ {
53
+ "success": true,
54
+ "orderType": "limit",
55
+ "limitOrderId": "0x..."
56
+ }
60
57
  ```
61
- Tell the user: "Limit order placed. ID: {limitOrderId}."
62
58
 
63
- ### Stderr Output
64
-
65
- Before submitting, the CLI prints an estimate to stderr:
66
- ```
67
- Estimated: ~0.043860 JBTC @ $68,476 (~$3,000 JUSDC total, 50x)
68
- ```
69
- This is informational only — the actual execution price may differ.
59
+ Tell the user: "Limit order placed. ID: {limitOrderId}."
70
60
 
71
61
  ### Common Patterns
72
62
 
73
63
  **Open a long position (market):**
74
- ```bash
75
- jv order create --side long --symbol JBTC -m 60 --pretty
64
+ ```json
65
+ { "side": "long", "symbol": "JBTC", "margin": 60 }
76
66
  ```
77
67
 
78
- **Open a short position (limit):**
79
- ```bash
80
- jv order create --side short --symbol JBTC -m 100 --limit-price 72000 --pretty
68
+ **Open a short position (limit at $72,000):**
69
+ ```json
70
+ { "side": "short", "symbol": "JBTC", "margin": 100, "limit_price": 72000 }
81
71
  ```
82
72
 
83
- **Close a long position (full close — use opposite side with same margin):**
84
- ```bash
85
- jv order create --side short --symbol JBTC -m 60 --pretty
73
+ **Close a long position (use opposite side with same margin):**
74
+ ```json
75
+ { "side": "short", "symbol": "JBTC", "margin": 60 }
86
76
  ```
87
77
 
88
78
  **Reduce a long position (partial close):**
89
- ```bash
90
- jv order create --side short --symbol JBTC -m 30 --pretty
79
+ ```json
80
+ { "side": "short", "symbol": "JBTC", "margin": 30 }
91
81
  ```
92
82
 
93
83
  **Add size to existing long:**
94
- ```bash
95
- jv order create --side long --symbol JBTC -m 50 --pretty
84
+ ```json
85
+ { "side": "long", "symbol": "JBTC", "margin": 50 }
96
86
  ```
97
87
 
98
88
  **Open with PPO protection (ATM, 30 min):**
99
- ```bash
100
- jv order create --side long --symbol JBTC -m 60 --ppo --pretty
89
+ ```json
90
+ { "side": "long", "symbol": "JBTC", "margin": 60, "ppo": true }
101
91
  ```
102
92
 
103
93
  **Open with PPO protection (OTM tier 3, 8 hours):**
104
- ```bash
105
- jv order create --side long --symbol JBTC -m 60 --ppo --ppo-expire 8h --ppo-category OTM --ppo-tier 3 --pretty
94
+ ```json
95
+ { "side": "long", "symbol": "JBTC", "margin": 60, "ppo": true, "ppo_expire": "8h", "ppo_category": "OTM", "ppo_tier": 3 }
106
96
  ```
107
97
 
108
98
  ---
109
99
 
110
- ## 2. Add PPO Protection (`jv order protect`)
100
+ ## 2. Add PPO Protection `protect_order`
111
101
 
112
102
  Add hedge option protection to an **existing position** without changing position size.
113
103
 
114
- ### Syntax
115
-
116
- ```
117
- jv order protect --order-id <id> --symbol <symbol> [options]
118
- ```
119
-
120
- ### Options
104
+ ### Parameters
121
105
 
122
- | Option | Required | Default | Description |
123
- |--------|----------|---------|-------------|
124
- | `--order-id <id>` | Yes | — | Existing perps order ID |
125
- | `--symbol <symbol>` | Yes | — | Asset symbol (e.g., `JBTC`) |
126
- | `--ppo-expire <duration>` | No | `30m` | Option expiry: `30m` or `8h` |
127
- | `--ppo-category <ATM\|OTM>` | No | `ATM` | Option category |
128
- | `--ppo-tier <1-5>` | No | — | OTM strike offset tier (required if OTM) |
129
- | `--network <name>` | No | `jaspervault` | Network name |
130
- | `--ttl <seconds>` | No | `3600` | Signature TTL in seconds |
131
- | `--pretty` | No | — | Pretty-print JSON output |
106
+ | Parameter | Required | Default | Description |
107
+ |-----------|----------|---------|-------------|
108
+ | `order_id` | Yes | — | Existing perps order ID |
109
+ | `symbol` | Yes | — | Asset symbol (e.g., `JBTC`) |
110
+ | `ppo_expire` | No | `30m` | Option expiry: `30m` or `8h` |
111
+ | `ppo_category` | No | `ATM` | Option category: `ATM` or `OTM` |
112
+ | `ppo_tier` | No | — | OTM strike offset tier 1-5 (required if OTM) |
132
113
 
133
- ### Output
114
+ ### Response
134
115
 
135
- The command auto-waits up to 60s for the on-chain result via SSE:
116
+ The tool auto-waits up to 60s for the on-chain result:
136
117
  ```json
137
- {"jobId":"OPTION_ORDER_xxx","status":"completed","transactionHash":"0x..."}
118
+ {
119
+ "jobId": "OPTION_ORDER_xxx",
120
+ "status": "completed",
121
+ "transactionHash": "0x..."
122
+ }
138
123
  ```
139
124
 
140
125
  ### Important
141
126
 
142
- - Use `jv order protect` to add hedge to an **existing** position.
143
- - Do NOT use `jv order create --ppo` for this — that adds position size.
144
- - The CLI auto-detects position side (LONG/SHORT) from the order and selects the correct hedge type (PUT for LONG, CALL for SHORT).
127
+ - Use `protect_order` to add hedge to an **existing** position.
128
+ - Don't use `create_order` with `ppo: true` for this — that adds position size.
129
+ - The tool auto-detects position side (LONG/SHORT) and selects the correct hedge type.
145
130
 
146
131
  ---
147
132
 
148
- ## 3. Take-Profit (`jv tp set`)
133
+ ## 3. Take-Profit `set_take_profit`
149
134
 
150
135
  Set a take-profit limit order for an existing position.
151
136
 
152
- ### Syntax
153
-
154
- ```
155
- jv tp set --order-id <id> --price <usdc> --symbol <symbol> [options]
156
- ```
157
-
158
- ### Options
159
-
160
- | Option | Required | Default | Description |
161
- |--------|----------|---------|-------------|
162
- | `--order-id <id>` | Yes | — | Existing order ID (position to close) |
163
- | `--price <usdc>` | Yes | — | Target price in USDC |
164
- | `--symbol <symbol>` | Yes | — | Asset symbol (e.g., `JBTC`) |
165
- | `--side <long\|short>` | No | `long` | Position side being closed |
166
- | `--ppo` | No | — | Enable PPO hedge on the TP order |
167
- | `--ppo-expire <duration>` | No | `30m` | PPO expiry: `30m` or `8h` |
168
- | `--ppo-category <ATM\|OTM>` | No | `ATM` | PPO option category |
169
- | `--ppo-tier <1-5>` | No | — | OTM strike offset tier |
170
- | `--network <name>` | No | `jaspervault` | Network name |
171
- | `--ttl <seconds>` | No | `86400` | Order TTL in seconds (default: 24h) |
172
- | `--pretty` | No | — | Pretty-print JSON output |
137
+ ### Parameters
173
138
 
174
- ### Output
175
-
176
- ```json
177
- {"success":true,"orderType":"limit","limitOrderId":"0x..."}
178
- ```
139
+ | Parameter | Required | Default | Description |
140
+ |-----------|----------|---------|-------------|
141
+ | `order_id` | Yes | — | Existing order ID |
142
+ | `price` | Yes | — | Target price in USDC |
143
+ | `symbol` | Yes | — | Asset symbol |
144
+ | `side` | No | `long` | Position side being closed |
145
+ | `ppo` | No | — | Enable PPO hedge on the TP order |
146
+ | `ppo_expire` | No | `30m` | PPO expiry |
147
+ | `ppo_category` | No | `ATM` | PPO category |
148
+ | `ppo_tier` | No | — | OTM tier |
149
+ | `ttl` | No | `86400` | Order TTL (default: 24h) |
179
150
 
180
151
  ### Example
181
152
 
182
- ```bash
183
- # Set TP at $75,000 for a long position
184
- jv tp set --order-id 123 --price 75000 --symbol JBTC --pretty
185
-
186
- # Set TP for a short position
187
- jv tp set --order-id 456 --price 60000 --symbol JBTC --side short --pretty
153
+ Set TP at $75,000 for a long position:
154
+ ```json
155
+ { "order_id": "123", "price": 75000, "symbol": "JBTC" }
188
156
  ```
189
157
 
190
158
  ---
191
159
 
192
- ## 4. Stop-Loss (`jv sl set`)
193
-
194
- Set a stop-loss limit order for an existing position. Same options as `jv tp set`.
160
+ ## 4. Stop-Loss `set_stop_loss`
195
161
 
196
- ### Syntax
197
-
198
- ```
199
- jv sl set --order-id <id> --price <usdc> --symbol <symbol> [options]
200
- ```
201
-
202
- Options are identical to `jv tp set` (see above).
162
+ Same parameters as `set_take_profit`. Set a stop-loss limit order for an existing position.
203
163
 
204
164
  ### Example
205
165
 
206
- ```bash
207
- # Set SL at $65,000 for a long position
208
- jv sl set --order-id 123 --price 65000 --symbol JBTC --pretty
209
-
210
- # Set SL for a short position
211
- jv sl set --order-id 456 --price 80000 --symbol JBTC --side short --pretty
166
+ Set SL at $65,000 for a long position:
167
+ ```json
168
+ { "order_id": "123", "price": 65000, "symbol": "JBTC" }
212
169
  ```
213
170
 
214
171
  ---
215
172
 
216
173
  ## 5. PPO (Perpetual Put Option) Details
217
174
 
218
- PPO provides hedge protection for positions. Key concepts:
219
-
220
175
  ### Option Categories
221
176
 
222
- | Category | Description | `--ppo-tier` |
223
- |----------|-------------|--------------|
177
+ | Category | Description | `ppo_tier` |
178
+ |----------|-------------|------------|
224
179
  | `ATM` (default) | At-the-money — strike = current price | Not needed |
225
180
  | `OTM` | Out-of-the-money — strike offset from current price | Required (1-5) |
226
181
 
227
182
  ### OTM Tiers
228
183
 
229
- | Tier | Strike Offset | Ratio |
230
- |------|---------------|-------|
231
- | 1 | 0.1% | 0.001 |
232
- | 2 | 0.2% | 0.002 |
233
- | 3 | 0.3% | 0.003 |
234
- | 4 | 0.4% | 0.004 |
235
- | 5 | 0.5% | 0.005 |
184
+ | Tier | Strike Offset |
185
+ |------|---------------|
186
+ | 1 | 0.1% |
187
+ | 2 | 0.2% |
188
+ | 3 | 0.3% |
189
+ | 4 | 0.4% |
190
+ | 5 | 0.5% |
236
191
 
237
192
  ### Expiry Options
238
193
 
239
- | Duration | Seconds | Flag |
240
- |----------|---------|------|
241
- | 30 minutes (default) | 1800 | `--ppo-expire 30m` |
242
- | 8 hours | 28800 | `--ppo-expire 8h` |
194
+ | Duration | Flag |
195
+ |----------|------|
196
+ | 30 minutes (default) | `ppo_expire: "30m"` |
197
+ | 8 hours | `ppo_expire: "8h"` |
243
198
 
244
199
  ### Hedge Type (auto-selected)
245
200
 
@@ -248,27 +203,24 @@ PPO provides hedge protection for positions. Key concepts:
248
203
 
249
204
  ### Intent Mapping
250
205
 
251
- | User Says | Action | Command |
252
- |-----------|--------|---------|
253
- | "加保护" / "add protection" to existing | `jv order protect` | `jv order protect --order-id <id> --symbol JBTC` |
254
- | "开仓 + 保护" / "open with protection" | `jv order create --ppo` | `jv order create --side long -m 60 --symbol JBTC --ppo` |
255
- | "加仓 + 保护" / "add size with protection" | `jv order create --ppo` (same side) | `jv order create --side long -m 50 --symbol JBTC --ppo` |
256
- | "8小时" / "8 hour" | Add `--ppo-expire 8h` | |
257
- | "OTM" / "价外" | Add `--ppo-category OTM`, then ask for tier | |
258
- | "ATM" / "平价" or nothing | Default ATM, 30 min | |
259
- | "取消PPO" / "cancel PPO" / "remove hedge" | Order WITHOUT `--ppo` | See below |
260
-
261
- ### PPO Cancellation (IMPORTANT)
262
-
263
- The smart contract **automatically cancels** existing PPO hedge options when you execute any position operation (reduce, close, add size) **without** the `--ppo` flag. There is **NO separate "cancel PPO" command**.
264
-
265
- | User Request | Correct Action | Command |
266
- |--------------|---------------|---------|
267
- | "减仓 + 取消PPO" | Single reduce order without `--ppo` | `jv order create --side <opposite> -m <amount> --symbol JBTC` |
268
- | "加仓 + 取消PPO" | Single add-size order without `--ppo` | `jv order create --side <same> -m <amount> --symbol JBTC` |
269
- | "平仓" (full close) | Close order without `--ppo` | `jv order create --side <opposite> -m <full_margin> --symbol JBTC` |
270
- | "减仓 + 保留PPO" | Reduce order WITH `--ppo` | `jv order create --side <opposite> -m <amount> --symbol JBTC --ppo` |
271
-
272
- **NEVER do this:**
273
- - Do NOT try to cancel PPO as a separate step. There is no "cancel PPO" command.
274
- - Do NOT send two orders when one suffices. "减仓 + 取消PPO" = ONE order without `--ppo`.
206
+ | User Says | Tool | Parameters |
207
+ |-----------|------|------------|
208
+ | "add protection" to existing | `protect_order` | `{ order_id, symbol }` |
209
+ | "open with protection" | `create_order` | `{ side, symbol, margin, ppo: true }` |
210
+ | "add size with protection" | `create_order` (same side) | `{ side, symbol, margin, ppo: true }` |
211
+ | "8 hours" | any PPO tool | add `ppo_expire: "8h"` |
212
+ | "OTM" | any PPO tool | add `ppo_category: "OTM"`, then need `ppo_tier` |
213
+ | "cancel PPO" / "remove hedge" | `create_order` | without `ppo` see below |
214
+
215
+ ### PPO Cancellation
216
+
217
+ The smart contract **automatically cancels** existing PPO when you execute any position operation without `ppo: true`. There is no separate "cancel PPO" tool.
218
+
219
+ | User Request | Action | Parameters |
220
+ |-------------|--------|------------|
221
+ | "reduce + cancel PPO" | Single reduce order without `ppo` | `{ side: <opposite>, symbol, margin }` |
222
+ | "add size + cancel PPO" | Single add-size order without `ppo` | `{ side: <same>, symbol, margin }` |
223
+ | "close position" | Close order without `ppo` | `{ side: <opposite>, symbol, margin: <full> }` |
224
+ | "reduce + keep PPO" | Reduce order WITH `ppo` | `{ side: <opposite>, symbol, margin, ppo: true }` |
225
+
226
+ Never try to cancel PPO separately — there is no such tool. One order handles everything.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "jaspervault_cli",
3
- "version": "1.0.28",
3
+ "version": "1.0.30",
4
4
  "description": "JasperVault CLI for interacting with the JasperVault Manager API",
5
5
  "type": "module",
6
6
  "bin": {