@solana-compass/cli 0.1.0 → 0.2.1
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/.claude-plugin/plugin.json +6 -0
- package/README.md +38 -76
- package/bin/sol.mjs +2 -2
- package/dist/index.js +1 -1
- package/package.json +4 -2
- package/skills/solana-payments-wallets-trading/SKILL.md +190 -0
- package/skills/solana-payments-wallets-trading/references/json-output-format.md +132 -0
- package/skills/solana-payments-wallets-trading/references/lending-commands.md +174 -0
- package/skills/solana-payments-wallets-trading/references/portfolio-commands.md +128 -0
- package/skills/solana-payments-wallets-trading/references/staking-commands.md +150 -0
- package/skills/solana-payments-wallets-trading/references/trading-commands.md +207 -0
- package/skills/solana-payments-wallets-trading/references/troubleshooting.md +158 -0
- package/skills/solana-payments-wallets-trading/references/wallet-commands.md +150 -0
package/README.md
CHANGED
|
@@ -1,37 +1,31 @@
|
|
|
1
1
|
# sol — Solana for Humans and LLM Agents
|
|
2
2
|
|
|
3
|
-
A
|
|
3
|
+
A command-line tool that lets you work with Solana the way you'd describe it out loud. Pay people, buy and sell tokens, stake, lend, and track your portfolio — instead of constructing transactions and managing program instructions, you say what you want. Keys live locally on disk. No API keys, no private key env vars.
|
|
4
4
|
|
|
5
5
|
```bash
|
|
6
|
-
|
|
7
|
-
sol
|
|
8
|
-
sol lend deposit 100 usdc # Earn yield on Kamino
|
|
9
|
-
sol portfolio # See everything you hold
|
|
10
|
-
```
|
|
6
|
+
# Set up
|
|
7
|
+
sol wallet create --name "ClawdBot"
|
|
11
8
|
|
|
12
|
-
|
|
9
|
+
# Transfer some SOL to the agent wallet, then:
|
|
13
10
|
|
|
14
|
-
|
|
11
|
+
# Check balance
|
|
12
|
+
sol wallet balance
|
|
15
13
|
|
|
16
|
-
|
|
14
|
+
# Swap 50 USDC for BONK
|
|
15
|
+
sol token swap 50 usdc bonk
|
|
17
16
|
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
{
|
|
21
|
-
"ok": true,
|
|
22
|
-
"data": {
|
|
23
|
-
"inputToken": "USDC",
|
|
24
|
-
"outputToken": "BONK",
|
|
25
|
-
"inputAmount": 50,
|
|
26
|
-
"outputAmount": 3842519.52,
|
|
27
|
-
"signature": "4xK9...",
|
|
28
|
-
"explorerUrl": "https://solscan.io/tx/4xK9..."
|
|
29
|
-
},
|
|
30
|
-
"meta": { "elapsed_ms": 1823 }
|
|
31
|
-
}
|
|
32
|
-
```
|
|
17
|
+
# Stake idle SOL
|
|
18
|
+
sol stake new 10
|
|
33
19
|
|
|
34
|
-
|
|
20
|
+
# Deposit USDC to earn yield on Kamino
|
|
21
|
+
sol lend deposit 100 usdc
|
|
22
|
+
|
|
23
|
+
# See everything you hold
|
|
24
|
+
sol portfolio
|
|
25
|
+
|
|
26
|
+
# Snapshot for tracking over time
|
|
27
|
+
sol portfolio snapshot --label "post-rebalance"
|
|
28
|
+
```
|
|
35
29
|
|
|
36
30
|
---
|
|
37
31
|
|
|
@@ -49,6 +43,20 @@ npx @solana-compass/cli wallet list
|
|
|
49
43
|
|
|
50
44
|
Requires Node.js >= 20.
|
|
51
45
|
|
|
46
|
+
### Install as an Agent Skill
|
|
47
|
+
|
|
48
|
+
Sol CLI is available as a discoverable skill for Claude Code and other LLM agents:
|
|
49
|
+
|
|
50
|
+
```bash
|
|
51
|
+
# Claude Code plugin marketplace
|
|
52
|
+
/plugin marketplace add solanaguide/solana-cli
|
|
53
|
+
|
|
54
|
+
# skills.sh
|
|
55
|
+
npx skills add solanaguide/solana-cli
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
Once installed, the agent can use Sol commands directly when you ask it to send crypto, trade tokens, check balances, stake, lend, or track portfolio performance.
|
|
59
|
+
|
|
52
60
|
### First-time setup
|
|
53
61
|
|
|
54
62
|
```bash
|
|
@@ -80,7 +88,6 @@ sol wallet set-default trading # Change the active wallet
|
|
|
80
88
|
sol wallet label main --add trading # Tag wallets for organization
|
|
81
89
|
sol wallet history # Recent transaction activity
|
|
82
90
|
sol wallet history --type swap --limit 5 # Filtered
|
|
83
|
-
sol wallet fund --amount 100 # Generate fiat onramp URL (Transak)
|
|
84
91
|
```
|
|
85
92
|
|
|
86
93
|
Wallets are stored locally as key files. The first wallet created becomes the default for all commands. Change it with `sol wallet set-default <name>`, or override per-command with `--wallet <name-or-address>`.
|
|
@@ -194,11 +201,10 @@ sol tx 4xK9...abc # Look up a transaction by signatu
|
|
|
194
201
|
|
|
195
202
|
---
|
|
196
203
|
|
|
197
|
-
##
|
|
204
|
+
## Structured Output
|
|
198
205
|
|
|
199
|
-
Every command supports `--json` for
|
|
206
|
+
Every command supports `--json` for automation and scripting:
|
|
200
207
|
|
|
201
|
-
**Success:**
|
|
202
208
|
```json
|
|
203
209
|
{
|
|
204
210
|
"ok": true,
|
|
@@ -207,50 +213,7 @@ Every command supports `--json` for structured output. Responses follow a consis
|
|
|
207
213
|
}
|
|
208
214
|
```
|
|
209
215
|
|
|
210
|
-
|
|
211
|
-
```json
|
|
212
|
-
{
|
|
213
|
-
"ok": false,
|
|
214
|
-
"error": "SWAP_FAILED",
|
|
215
|
-
"message": "Insufficient SOL balance"
|
|
216
|
-
}
|
|
217
|
-
```
|
|
218
|
-
|
|
219
|
-
Error codes are predictable `UPPER_SNAKE_CASE` identifiers (`WALLET_CREATE_FAILED`, `LEND_DEPOSIT_FAILED`, etc.). An agent can branch on `ok`, read `data` for results, and use `error` codes for programmatic error handling without parsing human text.
|
|
220
|
-
|
|
221
|
-
### Agent workflow example
|
|
222
|
-
|
|
223
|
-
A Claude Code agent managing a DeFi portfolio might run:
|
|
224
|
-
|
|
225
|
-
```bash
|
|
226
|
-
# 1. Check what we're working with
|
|
227
|
-
sol wallet balance --json
|
|
228
|
-
sol portfolio --json
|
|
229
|
-
|
|
230
|
-
# 2. Sell some BONK for USDC
|
|
231
|
-
sol token swap 1000000 bonk usdc --json
|
|
232
|
-
|
|
233
|
-
# 3. Put idle USDC to work earning yield
|
|
234
|
-
sol lend deposit 100 usdc --json
|
|
235
|
-
|
|
236
|
-
# 4. Stake idle SOL
|
|
237
|
-
sol stake new 5 --json
|
|
238
|
-
|
|
239
|
-
# 5. Verify final state and snapshot for tracking
|
|
240
|
-
sol portfolio --json
|
|
241
|
-
sol portfolio snapshot --label "rebalanced" --json
|
|
242
|
-
```
|
|
243
|
-
|
|
244
|
-
Each step returns structured data the agent can parse and act on. No web scraping, no API key management, no transaction construction.
|
|
245
|
-
|
|
246
|
-
### What agents get for free
|
|
247
|
-
|
|
248
|
-
- **Wallet management** — Create and fund wallets without touching key files
|
|
249
|
-
- **Token resolution** — Say `sol` or `usdc` instead of mint addresses
|
|
250
|
-
- **Transaction handling** — Automatic retries, blockhash management, confirmation polling
|
|
251
|
-
- **Cost-basis tracking** — Every swap is logged with USD prices at execution time
|
|
252
|
-
- **Portfolio snapshots** — Track P&L across sessions without external databases
|
|
253
|
-
- **Error classification** — Structured errors distinguish transient failures (retry) from terminal ones (stop)
|
|
216
|
+
Error codes are predictable `UPPER_SNAKE_CASE` identifiers (`SWAP_FAILED`, `LEND_DEPOSIT_FAILED`, etc.).
|
|
254
217
|
|
|
255
218
|
---
|
|
256
219
|
|
|
@@ -259,11 +222,10 @@ Each step returns structured data the agent can parse and act on. No web scrapin
|
|
|
259
222
|
| Flag | Description |
|
|
260
223
|
|------|-------------|
|
|
261
224
|
| `--json` | Structured JSON output |
|
|
262
|
-
| `--wallet <name>` | Override default wallet |
|
|
263
225
|
| `--rpc <url>` | Override RPC endpoint |
|
|
264
226
|
| `--verbose` | Show debug logging |
|
|
265
227
|
|
|
266
|
-
|
|
228
|
+
Most commands also accept `--wallet <name-or-address>` to override the default wallet.
|
|
267
229
|
|
|
268
230
|
## RPC Resolution
|
|
269
231
|
|
|
@@ -291,7 +253,7 @@ The transaction log is the source of truth for cost basis and P&L — every swap
|
|
|
291
253
|
|
|
292
254
|
## Architecture
|
|
293
255
|
|
|
294
|
-
- **Runtime**: Node.js
|
|
256
|
+
- **Runtime**: Node.js (compiled from TypeScript)
|
|
295
257
|
- **CLI framework**: commander.js
|
|
296
258
|
- **Solana SDK**: `@solana/kit` v2
|
|
297
259
|
- **Swaps**: Jupiter REST API (no SDK, no API key)
|
package/bin/sol.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import { dirname, join } from 'node:path';
|
|
3
|
-
import { fileURLToPath } from 'node:url';
|
|
3
|
+
import { fileURLToPath, pathToFileURL } from 'node:url';
|
|
4
4
|
|
|
5
5
|
const __dirname = dirname(fileURLToPath(import.meta.url));
|
|
6
|
-
await import(join(__dirname, '..', 'dist', 'index.js'));
|
|
6
|
+
await import(pathToFileURL(join(__dirname, '..', 'dist', 'index.js')).href);
|
package/dist/index.js
CHANGED
|
@@ -14,7 +14,7 @@ const program = new Command();
|
|
|
14
14
|
program
|
|
15
15
|
.name('sol')
|
|
16
16
|
.description('Solana CLI for Humans and LLM Agents')
|
|
17
|
-
.version('0.
|
|
17
|
+
.version('0.2.0')
|
|
18
18
|
.option('--json', 'Output structured JSON')
|
|
19
19
|
.option('--rpc <url>', 'Override RPC endpoint')
|
|
20
20
|
.option('--verbose', 'Verbose output')
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@solana-compass/cli",
|
|
3
|
-
"version": "0.1
|
|
3
|
+
"version": "0.2.1",
|
|
4
4
|
"description": "Solana CLI for Humans and LLM Agents",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
@@ -34,7 +34,9 @@
|
|
|
34
34
|
},
|
|
35
35
|
"files": [
|
|
36
36
|
"bin/",
|
|
37
|
-
"dist/"
|
|
37
|
+
"dist/",
|
|
38
|
+
"skills/",
|
|
39
|
+
".claude-plugin/"
|
|
38
40
|
],
|
|
39
41
|
"repository": {
|
|
40
42
|
"type": "git",
|
|
@@ -0,0 +1,190 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: solana-payments-wallets-trading
|
|
3
|
+
description: >-
|
|
4
|
+
Pay people in SOL or USDC, buy and sell tokens, check prices, manage Solana
|
|
5
|
+
wallets, stake SOL, earn yield through lending, and track portfolio
|
|
6
|
+
performance — all from the command line. No API keys, no private key env
|
|
7
|
+
vars. Use when the user wants to send crypto, trade, check balances, earn
|
|
8
|
+
yield, or see how their holdings are doing.
|
|
9
|
+
license: MIT
|
|
10
|
+
metadata:
|
|
11
|
+
author: solanaguide
|
|
12
|
+
version: 0.2.0
|
|
13
|
+
openclaw:
|
|
14
|
+
requires:
|
|
15
|
+
bins:
|
|
16
|
+
- node
|
|
17
|
+
- npx
|
|
18
|
+
---
|
|
19
|
+
|
|
20
|
+
# Payments, Wallets and Trading on Solana
|
|
21
|
+
|
|
22
|
+
Sol is a command-line tool that lets you work with Solana the way you'd
|
|
23
|
+
describe it out loud. Instead of constructing transactions and managing
|
|
24
|
+
program instructions, you say what you want: pay someone, buy a token,
|
|
25
|
+
stake your SOL.
|
|
26
|
+
|
|
27
|
+
Keys live locally on disk — no private keys in environment variables,
|
|
28
|
+
no API keys to configure.
|
|
29
|
+
|
|
30
|
+
## Get Set Up
|
|
31
|
+
|
|
32
|
+
```bash
|
|
33
|
+
npm install -g @solana-compass/cli
|
|
34
|
+
sol config set rpc.url https://your-rpc-endpoint.com
|
|
35
|
+
sol wallet create --name my-wallet
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
The public RPC endpoint rate-limits aggressively. Use a dedicated RPC
|
|
39
|
+
for anything beyond testing — Helius, Triton, and QuickNode all offer
|
|
40
|
+
free tiers.
|
|
41
|
+
|
|
42
|
+
Or run without installing:
|
|
43
|
+
|
|
44
|
+
```bash
|
|
45
|
+
npx @solana-compass/cli wallet list
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
Requires Node.js >= 20.
|
|
49
|
+
|
|
50
|
+
## Pay Someone
|
|
51
|
+
|
|
52
|
+
Send SOL, USDC, or any Solana token to a wallet address.
|
|
53
|
+
|
|
54
|
+
```bash
|
|
55
|
+
sol token send 50 usdc GkX...abc
|
|
56
|
+
sol token send 2 sol 7nY...xyz
|
|
57
|
+
sol token send 1000 bonk AgE...def --yes
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
Use `--yes` to skip the confirmation prompt — useful for automated
|
|
61
|
+
payments between agents or apps. Confirmations are also skipped
|
|
62
|
+
automatically in `--json` mode.
|
|
63
|
+
|
|
64
|
+
See references/trading-commands.md for the full send reference.
|
|
65
|
+
|
|
66
|
+
## Buy and Sell Tokens
|
|
67
|
+
|
|
68
|
+
Swap any token for any other token. Prices come from Jupiter — best
|
|
69
|
+
rate across every Solana DEX, no API key needed.
|
|
70
|
+
|
|
71
|
+
```bash
|
|
72
|
+
sol token swap 50 usdc bonk # buy BONK with USDC
|
|
73
|
+
sol token swap 1.5 sol usdc # sell SOL for USDC
|
|
74
|
+
sol token swap 50 usdc bonk --quote-only # preview without executing
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
Every swap records the price at execution time, so you can track
|
|
78
|
+
cost basis and P&L later.
|
|
79
|
+
|
|
80
|
+
See references/trading-commands.md for slippage, wallet selection, etc.
|
|
81
|
+
|
|
82
|
+
## Check Prices
|
|
83
|
+
|
|
84
|
+
```bash
|
|
85
|
+
sol token price sol
|
|
86
|
+
sol token price sol usdc bonk eth # multiple at once
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
## See What You Have
|
|
90
|
+
|
|
91
|
+
```bash
|
|
92
|
+
sol wallet balance # all tokens with USD values
|
|
93
|
+
sol token list # just token balances
|
|
94
|
+
sol wallet list # all your wallets
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
## Create and Manage Wallets
|
|
98
|
+
|
|
99
|
+
Wallets are local key files in `~/.sol/wallets/` — no seed phrases
|
|
100
|
+
in environment variables.
|
|
101
|
+
|
|
102
|
+
```bash
|
|
103
|
+
sol wallet create # new wallet, auto-named
|
|
104
|
+
sol wallet create --name trading # pick a name
|
|
105
|
+
sol wallet import --solana-cli # import from Solana CLI
|
|
106
|
+
sol wallet set-default trading # switch active wallet
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
Any command can target a specific wallet with `--wallet <name>`.
|
|
110
|
+
|
|
111
|
+
See references/wallet-commands.md for import, export, labels, history.
|
|
112
|
+
|
|
113
|
+
## Stake SOL
|
|
114
|
+
|
|
115
|
+
Delegate SOL to a validator and earn staking rewards. One command
|
|
116
|
+
handles the entire process — creating the stake account, funding it,
|
|
117
|
+
and delegating.
|
|
118
|
+
|
|
119
|
+
```bash
|
|
120
|
+
sol stake new 10 # stake 10 SOL
|
|
121
|
+
sol stake list # your stake accounts + claimable tips
|
|
122
|
+
sol stake claim-mev # compound MEV rewards
|
|
123
|
+
sol stake withdraw 7gK...abc # unstake
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
See references/staking-commands.md for validator selection, partial
|
|
127
|
+
withdrawals, and force unstake.
|
|
128
|
+
|
|
129
|
+
## Earn Yield by Lending
|
|
130
|
+
|
|
131
|
+
Deposit tokens into Kamino Finance to earn interest, or borrow
|
|
132
|
+
against your deposits.
|
|
133
|
+
|
|
134
|
+
```bash
|
|
135
|
+
sol lend rates usdc # current APY
|
|
136
|
+
sol lend deposit 100 usdc # start earning
|
|
137
|
+
sol lend borrow 500 usdc --collateral sol
|
|
138
|
+
sol lend positions # everything you've got open
|
|
139
|
+
```
|
|
140
|
+
|
|
141
|
+
See references/lending-commands.md for full details.
|
|
142
|
+
|
|
143
|
+
## Track How Your Portfolio Is Doing
|
|
144
|
+
|
|
145
|
+
See everything in one place — tokens, staked SOL, lending positions.
|
|
146
|
+
|
|
147
|
+
```bash
|
|
148
|
+
sol portfolio # the full picture
|
|
149
|
+
sol portfolio snapshot --label "monday"
|
|
150
|
+
sol portfolio compare # what changed since last snapshot
|
|
151
|
+
sol portfolio pnl # profit and loss over time
|
|
152
|
+
```
|
|
153
|
+
|
|
154
|
+
See references/portfolio-commands.md for snapshot management.
|
|
155
|
+
|
|
156
|
+
## Structured Output
|
|
157
|
+
|
|
158
|
+
Every command supports `--json` for structured output. In JSON mode,
|
|
159
|
+
confirmations are skipped automatically.
|
|
160
|
+
|
|
161
|
+
```json
|
|
162
|
+
{ "ok": true, "data": { ... }, "meta": { "elapsed_ms": 450 } }
|
|
163
|
+
```
|
|
164
|
+
|
|
165
|
+
Error codes are `UPPER_SNAKE_CASE` (e.g. `SWAP_FAILED`). Check the
|
|
166
|
+
`ok` field before reading `data`.
|
|
167
|
+
|
|
168
|
+
See references/json-output-format.md for the full schema.
|
|
169
|
+
|
|
170
|
+
## Other Useful Commands
|
|
171
|
+
|
|
172
|
+
```bash
|
|
173
|
+
sol network # epoch, TPS, staking APY
|
|
174
|
+
sol tx 4xK9...abc # look up any transaction
|
|
175
|
+
sol config set rpc.url <url> # change RPC endpoint
|
|
176
|
+
```
|
|
177
|
+
|
|
178
|
+
## Tips
|
|
179
|
+
|
|
180
|
+
- Use mint addresses instead of symbols when you know the exact token
|
|
181
|
+
(avoids symbol ambiguity)
|
|
182
|
+
- Use `--quote-only` on swaps to preview before committing
|
|
183
|
+
- Use `--wallet <name>` to target a specific wallet
|
|
184
|
+
- The transaction log tracks all operations with USD prices at
|
|
185
|
+
execution time — useful for cost basis and P&L
|
|
186
|
+
|
|
187
|
+
## Troubleshooting
|
|
188
|
+
|
|
189
|
+
See references/troubleshooting.md for common issues (RPC rate limits,
|
|
190
|
+
token resolution, transaction timeouts).
|
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
# JSON Output Format Reference
|
|
2
|
+
|
|
3
|
+
Every Sol CLI command supports `--json` for structured output.
|
|
4
|
+
|
|
5
|
+
## Response Envelope
|
|
6
|
+
|
|
7
|
+
All responses use the `CommandResult<T>` envelope:
|
|
8
|
+
|
|
9
|
+
```json
|
|
10
|
+
{
|
|
11
|
+
"ok": true,
|
|
12
|
+
"data": { ... },
|
|
13
|
+
"meta": {
|
|
14
|
+
"elapsed_ms": 450
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
### Fields
|
|
20
|
+
|
|
21
|
+
| Field | Type | Description |
|
|
22
|
+
|-------|------|-------------|
|
|
23
|
+
| `ok` | `boolean` | `true` on success, `false` on failure |
|
|
24
|
+
| `data` | `T` | Command-specific response data (present on success) |
|
|
25
|
+
| `error` | `string` | Error code in `UPPER_SNAKE_CASE` (present on failure) |
|
|
26
|
+
| `message` | `string` | Human-readable error description (present on failure) |
|
|
27
|
+
| `meta` | `object` | Metadata — always includes `elapsed_ms` |
|
|
28
|
+
|
|
29
|
+
## Success Response
|
|
30
|
+
|
|
31
|
+
```json
|
|
32
|
+
{
|
|
33
|
+
"ok": true,
|
|
34
|
+
"data": {
|
|
35
|
+
"signature": "4xK9...abc",
|
|
36
|
+
"from_token": "USDC",
|
|
37
|
+
"to_token": "BONK",
|
|
38
|
+
"from_amount": 50,
|
|
39
|
+
"to_amount": 2500000
|
|
40
|
+
},
|
|
41
|
+
"meta": { "elapsed_ms": 2100 }
|
|
42
|
+
}
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
Always check `ok === true` before reading `data`.
|
|
46
|
+
|
|
47
|
+
## Error Response
|
|
48
|
+
|
|
49
|
+
```json
|
|
50
|
+
{
|
|
51
|
+
"ok": false,
|
|
52
|
+
"error": "SWAP_FAILED",
|
|
53
|
+
"message": "Insufficient balance: need 50 USDC, have 12.5 USDC",
|
|
54
|
+
"meta": { "elapsed_ms": 150 }
|
|
55
|
+
}
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
## Error Code Convention
|
|
59
|
+
|
|
60
|
+
Error codes follow `NOUN_VERB_FAILED` format in `UPPER_SNAKE_CASE`:
|
|
61
|
+
|
|
62
|
+
| Code | When |
|
|
63
|
+
|------|------|
|
|
64
|
+
| `WALLET_CREATE_FAILED` | Wallet creation fails |
|
|
65
|
+
| `BALANCE_FAILED` | Balance lookup fails |
|
|
66
|
+
| `SWAP_FAILED` | Token swap fails |
|
|
67
|
+
| `SEND_FAILED` | Token send fails |
|
|
68
|
+
| `STAKE_NEW_FAILED` | Stake creation fails |
|
|
69
|
+
| `STAKE_WITHDRAW_FAILED` | Stake withdrawal fails |
|
|
70
|
+
| `LEND_DEPOSIT_FAILED` | Lending deposit fails |
|
|
71
|
+
| `LEND_WITHDRAW_FAILED` | Lending withdrawal fails |
|
|
72
|
+
| `LEND_BORROW_FAILED` | Borrowing fails |
|
|
73
|
+
| `LEND_REPAY_FAILED` | Loan repayment fails |
|
|
74
|
+
| `PORTFOLIO_FETCH_FAILED` | Portfolio fetch fails |
|
|
75
|
+
| `CONFIG_SET_FAILED` | Config update fails |
|
|
76
|
+
| `NETWORK_FAILED` | Network info fetch fails |
|
|
77
|
+
| `TOKEN_LIST_FAILED` | Token list fetch fails |
|
|
78
|
+
|
|
79
|
+
## Exit Codes
|
|
80
|
+
|
|
81
|
+
- `0` — Success
|
|
82
|
+
- `1` — Command failed (error details in JSON response)
|
|
83
|
+
|
|
84
|
+
## JSON Mode Behavior
|
|
85
|
+
|
|
86
|
+
When `--json` is active:
|
|
87
|
+
|
|
88
|
+
- Confirmation prompts are skipped automatically (equivalent to `--yes`)
|
|
89
|
+
- Human-readable output is suppressed
|
|
90
|
+
- Only the JSON envelope is printed to stdout
|
|
91
|
+
- Debug/verbose output goes to stderr (if `--verbose` is also set)
|
|
92
|
+
|
|
93
|
+
## Global Flags
|
|
94
|
+
|
|
95
|
+
These flags work with any command:
|
|
96
|
+
|
|
97
|
+
```bash
|
|
98
|
+
sol <command> --json # structured output
|
|
99
|
+
sol <command> --rpc https://my-rpc.com # override RPC
|
|
100
|
+
sol <command> --verbose # debug logging
|
|
101
|
+
sol <command> --wallet trading # override wallet
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
## Usage in Scripts
|
|
105
|
+
|
|
106
|
+
```bash
|
|
107
|
+
# Check if a swap succeeded
|
|
108
|
+
result=$(sol token swap 50 usdc bonk --json)
|
|
109
|
+
if echo "$result" | jq -e '.ok' > /dev/null; then
|
|
110
|
+
sig=$(echo "$result" | jq -r '.data.signature')
|
|
111
|
+
echo "Swap succeeded: $sig"
|
|
112
|
+
else
|
|
113
|
+
error=$(echo "$result" | jq -r '.error')
|
|
114
|
+
echo "Swap failed: $error"
|
|
115
|
+
fi
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
## Usage in Agent Code
|
|
119
|
+
|
|
120
|
+
```javascript
|
|
121
|
+
import { execSync } from 'node:child_process';
|
|
122
|
+
|
|
123
|
+
const result = JSON.parse(
|
|
124
|
+
execSync('sol token swap 50 usdc bonk --json').toString()
|
|
125
|
+
);
|
|
126
|
+
|
|
127
|
+
if (result.ok) {
|
|
128
|
+
console.log(`Swapped — tx: ${result.data.signature}`);
|
|
129
|
+
} else {
|
|
130
|
+
console.error(`Failed: ${result.error} — ${result.message}`);
|
|
131
|
+
}
|
|
132
|
+
```
|