@jup-ag/cli 0.1.0 → 0.2.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/docs/config.md CHANGED
@@ -20,3 +20,14 @@ jup config set --output table
20
20
  ```bash
21
21
  jup config set --active-key <name>
22
22
  ```
23
+
24
+ ## Set API key
25
+
26
+ Use an API key from <https://portal.jup.ag/> for higher rate limits:
27
+
28
+ ```bash
29
+ jup config set --api-key <key>
30
+
31
+ # Delete or unset the API key
32
+ jup config set --api-key
33
+ ```
package/docs/perps.md ADDED
@@ -0,0 +1,271 @@
1
+ # Perpetual Futures Trading
2
+
3
+ Requires: an active key for all commands except `positions` (with `--address`) and `markets`. See [setup](setup.md).
4
+
5
+ ## Markets
6
+
7
+ Three perpetual markets are available: **SOL**, **BTC**, and **ETH**. Collateral can be deposited in SOL, BTC, ETH, or USDC. Minimum collateral is $10 for new positions.
8
+
9
+ ## Commands
10
+
11
+ ### View positions
12
+
13
+ ```bash
14
+ jup perps positions
15
+ jup perps positions --key mykey
16
+ jup perps positions --address <wallet-address>
17
+ ```
18
+
19
+ - Shows open positions with TP/SL details, and pending limit orders
20
+ - With no options, uses the active key's wallet
21
+
22
+ ```js
23
+ // Example JSON response:
24
+ {
25
+ "positions": [
26
+ {
27
+ "positionPubkey": "3qMZ...83tz", // use this to close or set TP/SL
28
+ "asset": "BTC",
29
+ "side": "long",
30
+ "leverage": 1.09,
31
+ "sizeUsd": 10.98, // position size in USD
32
+ "entryPriceUsd": 70522.85,
33
+ "markPriceUsd": 70424.52,
34
+ "pnlPct": -0.29, // percentage; -0.29 means -0.29%
35
+ "liquidationPriceUsd": 6601.55,
36
+ "tpsl": [
37
+ {
38
+ "pubkey": "7xKp...2mNq", // use this to cancel TP/SL
39
+ "type": "tp",
40
+ "triggerPriceUsd": 75000
41
+ }
42
+ ]
43
+ }
44
+ ],
45
+ "limitOrders": [
46
+ {
47
+ "orderPubkey": "9fGh...4kLm", // use this to update or cancel
48
+ "asset": "SOL",
49
+ "side": "long",
50
+ "sizeUsd": 50,
51
+ "triggerPriceUsd": 80
52
+ }
53
+ ]
54
+ }
55
+ ```
56
+
57
+ ### List markets
58
+
59
+ ```bash
60
+ jup perps markets
61
+ ```
62
+
63
+ ```js
64
+ // Example JSON response:
65
+ [
66
+ {
67
+ "asset": "SOL",
68
+ "priceUsd": 86.74,
69
+ "changePct24h": 2.35, // percentage; 2.35 means +2.35%
70
+ "highUsd24h": 88.10,
71
+ "lowUsd24h": 84.50,
72
+ "volumeUsd24h": 1250000
73
+ }
74
+ ]
75
+ ```
76
+
77
+ ### Open a position
78
+
79
+ Two sizing modes — provide either `--leverage` or `--size`, not both:
80
+
81
+ - `--leverage`: position size = amount × leverage
82
+ - `--size`: explicit position size in USD, leverage is derived
83
+
84
+ ```bash
85
+ # Market order with leverage
86
+ jup perps open --asset SOL --side long --amount 10 --input USDC --leverage 2
87
+
88
+ # Market order with explicit size
89
+ jup perps open --asset BTC --side short --amount 10 --input USDC --size 50
90
+
91
+ # Use SOL as collateral (default --input)
92
+ jup perps open --asset SOL --side long --amount 0.1 --leverage 5
93
+
94
+ # With take-profit and stop-loss
95
+ jup perps open --asset ETH --side long --amount 10 --input USDC --leverage 3 --tp 4000 --sl 3000
96
+
97
+ # Limit order (triggers when price reaches --limit)
98
+ jup perps open --asset BTC --side long --amount 10 --input USDC --leverage 2 --limit 65000
99
+ ```
100
+
101
+ - `--side` accepts `long`, `short`, `buy` (= long), or `sell` (= short)
102
+ - `--input` defaults to SOL; accepts SOL, BTC, ETH, or USDC
103
+ - `--slippage` defaults to 200 (2%); set in basis points
104
+ - `--tp` and `--sl` cannot be combined with `--limit`
105
+
106
+ ```js
107
+ // Example JSON response (market order):
108
+ {
109
+ "type": "market-order",
110
+ "positionPubkey": "A7SQ...q96c",
111
+ "asset": "SOL",
112
+ "side": "long",
113
+ "entryPriceUsd": 86.74,
114
+ "sizeUsd": 10.97,
115
+ "leverage": 1.09,
116
+ "liquidationPriceUsd": 8.12,
117
+ "openFeeUsd": 0.0066,
118
+ "signature": "2Goj...diEc"
119
+ }
120
+
121
+ // Example JSON response (limit order):
122
+ {
123
+ "type": "limit-order",
124
+ "positionPubkey": "B8TR...p23d",
125
+ "asset": "BTC",
126
+ "side": "long",
127
+ "triggerPriceUsd": 65000,
128
+ "sizeUsd": 20,
129
+ "leverage": 2,
130
+ "signature": "4xK2...9zH1"
131
+ }
132
+ ```
133
+
134
+ ### Update TP/SL or limit order
135
+
136
+ ```bash
137
+ # Set or update take-profit on a position
138
+ jup perps set --position <pubkey> --tp 100
139
+
140
+ # Set or update stop-loss on a position
141
+ jup perps set --position <pubkey> --sl 70
142
+
143
+ # Set both TP and SL
144
+ jup perps set --position <pubkey> --tp 100 --sl 70
145
+
146
+ # Update a limit order's trigger price
147
+ jup perps set --order <pubkey> --limit 64000
148
+ ```
149
+
150
+ - Get the `positionPubkey` or `orderPubkey` from `jup perps positions`
151
+
152
+ ```js
153
+ // Example JSON response (update limit order):
154
+ {
155
+ "action": "update-limit-order",
156
+ "triggerPriceUsd": 64000,
157
+ "signature": "5tPb...qdCD"
158
+ }
159
+
160
+ // Example JSON response (set TP/SL):
161
+ {
162
+ "action": "set-tpsl",
163
+ "updates": [
164
+ {
165
+ "type": "tp",
166
+ "action": "created", // or "updated"
167
+ "triggerPriceUsd": 100,
168
+ "signature": "3dV9...8zG1"
169
+ },
170
+ {
171
+ "type": "sl",
172
+ "action": "created",
173
+ "triggerPriceUsd": 70,
174
+ "signature": "7kM2...4pQ3"
175
+ }
176
+ ]
177
+ }
178
+ ```
179
+
180
+ ### Close a position or cancel an order
181
+
182
+ ```bash
183
+ # Close entire position (receive collateral token by default)
184
+ jup perps close --position <pubkey>
185
+
186
+ # Close entire position, receive USDC
187
+ jup perps close --position <pubkey> --receive USDC
188
+
189
+ # Partial close (reduce by $5)
190
+ jup perps close --position <pubkey> --size 5
191
+
192
+ # Close all positions
193
+ jup perps close --position all
194
+
195
+ # Cancel a limit order
196
+ jup perps close --order <pubkey>
197
+
198
+ # Cancel a TP/SL order
199
+ jup perps close --tpsl <pubkey>
200
+ ```
201
+
202
+ - `--receive` defaults to the position's collateral token; must be USDC or the market token (e.g. BTC for a BTC position)
203
+ - `--size` for partial close; omit to close entirely
204
+
205
+ ```js
206
+ // Example JSON response (close/decrease position):
207
+ {
208
+ "action": "close-position", // or "decrease-position" for partial
209
+ "positionPubkey": "3qMZ...83tz",
210
+ "sizeReducedUsd": 10.98,
211
+ "pnlUsd": 0.15,
212
+ "pnlPct": 1.37, // percentage; 1.37 means +1.37%
213
+ "received": "0.00015 BTC",
214
+ "receivedUsd": 10.50,
215
+ "feesUsd": 0.007,
216
+ "signature": "5YhT...9AKU"
217
+ }
218
+
219
+ // Example JSON response (close all):
220
+ {
221
+ "action": "close-all",
222
+ "signatures": ["5YhT...9AKU", "3Cn8...diEc"]
223
+ }
224
+
225
+ // Example JSON response (cancel order):
226
+ {
227
+ "action": "cancel-limit-order", // or "cancel-tpsl"
228
+ "signature": "4wYb...drLf"
229
+ }
230
+ ```
231
+
232
+ ## Workflows
233
+
234
+ ### Open a position with TP/SL
235
+
236
+ ```bash
237
+ jup perps open --asset SOL --side long --amount 10 --input USDC --leverage 3 --tp 100 --sl 70
238
+ ```
239
+
240
+ ### Check positions then close
241
+
242
+ ```bash
243
+ jup perps positions
244
+ # Copy the positionPubkey
245
+ jup perps close --position <pubkey>
246
+ ```
247
+
248
+ ### Add TP/SL to an existing position
249
+
250
+ ```bash
251
+ jup perps positions
252
+ # Copy the positionPubkey
253
+ jup perps set --position <pubkey> --tp 100 --sl 70
254
+ ```
255
+
256
+ ### Place a limit order then update it
257
+
258
+ ```bash
259
+ jup perps open --asset BTC --side long --amount 10 --input USDC --leverage 2 --limit 65000
260
+ jup perps positions
261
+ # Copy the orderPubkey
262
+ jup perps set --order <pubkey> --limit 64000
263
+ ```
264
+
265
+ ### Add collateral to reduce leverage
266
+
267
+ There is no dedicated deposit collateral command. Instead, open on the same asset/side with minimum leverage:
268
+
269
+ ```bash
270
+ jup perps open --asset BTC --side long --amount 10 --input USDC --leverage 1.1
271
+ ```
package/llms.txt CHANGED
@@ -11,7 +11,7 @@ On failure, commands exit with non-zero code with an error message. In JSON mode
11
11
  - [Setup](docs/setup.md): Installation of the CLI
12
12
  - [Config](docs/config.md): CLI settings and configurations
13
13
  - [Keys](docs/keys.md): Private key management
14
- - [Spot](docs/spot.md): Swaps, transfers, token and portfolio data
15
- - Perps: Perpetual futures (coming soon)
14
+ - [Spot](docs/spot.md): Spot trading, transfers, token and portfolio data
15
+ - [Perps](docs/perps.md): Perps trading (leveraged longs/shorts)
16
16
  - Lend: Lending and borrowing (coming soon)
17
17
  - Predictions: Create and trade prediction markets (coming soon)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jup-ag/cli",
3
- "version": "0.1.0",
3
+ "version": "0.2.0",
4
4
  "license": "GPL-3.0",
5
5
  "type": "module",
6
6
  "bin": {
@@ -22,14 +22,6 @@
22
22
  "ci": "bun run lint && bun run typecheck && bun run test",
23
23
  "prepublishOnly": "bun run build"
24
24
  },
25
- "devDependencies": {
26
- "@types/bun": "latest",
27
- "oxlint": "^1.53.0",
28
- "prettier": "^3.8.1"
29
- },
30
- "peerDependencies": {
31
- "typescript": "^5"
32
- },
33
25
  "dependencies": {
34
26
  "@scure/bip32": "^2.0.1",
35
27
  "@scure/bip39": "^2.0.1",
@@ -39,5 +31,11 @@
39
31
  "cli-table3": "^0.6.5",
40
32
  "commander": "^14.0.3",
41
33
  "ky": "^1.14.3"
34
+ },
35
+ "devDependencies": {
36
+ "@types/bun": "latest",
37
+ "oxlint": "^1.53.0",
38
+ "prettier": "^3.8.1",
39
+ "typescript": "^5.9.3"
42
40
  }
43
41
  }