@orderly.network/cli 1.0.0 → 2.2.3
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 +24 -111
- package/bin/orderly.js +34 -0
- package/lib/resolve.js +64 -0
- package/package.json +21 -55
- package/dist/index.js +0 -130
- package/dist/index.js.map +0 -7
package/README.md
CHANGED
|
@@ -1,127 +1,40 @@
|
|
|
1
1
|
# @orderly.network/cli
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
The Orderly Network CLI. Installs the native `orderly` binary for your platform
|
|
4
|
+
as an optional dependency — no install scripts, nothing downloaded at runtime.
|
|
4
5
|
|
|
5
|
-
##
|
|
6
|
+
## Install
|
|
6
7
|
|
|
7
|
-
|
|
8
|
-
- **AI-friendly** - Keys never exposed to AI context, CLI returns only results
|
|
9
|
-
- **Full trading support** - Place/cancel orders, manage positions, set leverage
|
|
10
|
-
- **Multi-chain** - Supports EVM (Arbitrum, Base, Optimism, etc.) and Solana
|
|
11
|
-
|
|
12
|
-
## Installation
|
|
13
|
-
|
|
14
|
-
```bash
|
|
8
|
+
```sh
|
|
15
9
|
npm install -g @orderly.network/cli
|
|
10
|
+
orderly --version
|
|
16
11
|
```
|
|
17
12
|
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
- **Node.js >= 22**
|
|
21
|
-
- **Linux**: `sudo apt install libsecret-1-0 libsecret-1-dev` (for OS keychain support)
|
|
22
|
-
|
|
23
|
-
## Quick Start (Testnet)
|
|
24
|
-
|
|
25
|
-
```bash
|
|
26
|
-
# 1. Create a new EVM wallet
|
|
27
|
-
orderly wallet-create --type EVM --network testnet
|
|
28
|
-
|
|
29
|
-
# 2. Register Orderly account
|
|
30
|
-
orderly wallet-register --broker-id demo --network testnet
|
|
31
|
-
|
|
32
|
-
# 3. Request test USDC (wait a few minutes for delivery)
|
|
33
|
-
orderly faucet-usdc <address> --broker-id demo --chain-id 421614 --network testnet
|
|
34
|
-
|
|
35
|
-
# 4. Add API key for trading (generates Ed25519 key automatically)
|
|
36
|
-
orderly wallet-add-key --broker-id demo --scope read,trading --network testnet
|
|
37
|
-
|
|
38
|
-
# 5. List accounts to get your account ID
|
|
39
|
-
orderly auth-list --network testnet
|
|
40
|
-
|
|
41
|
-
# 6. Check balance
|
|
42
|
-
orderly account-balance --account <account-id> --network testnet
|
|
43
|
-
|
|
44
|
-
# 7. Place an order
|
|
45
|
-
orderly order-place PERP_ETH_USDC BUY MARKET 0.01 --account <account-id> --network testnet
|
|
46
|
-
```
|
|
47
|
-
|
|
48
|
-
**Note:** The `--account` flag is required for all authenticated commands. Use `auth-list` to see available accounts.
|
|
49
|
-
|
|
50
|
-
## Common Commands
|
|
51
|
-
|
|
52
|
-
```bash
|
|
53
|
-
# Account management
|
|
54
|
-
orderly account-info --account <account-id>
|
|
55
|
-
orderly account-balance --account <account-id>
|
|
56
|
-
|
|
57
|
-
# Trading - Orders
|
|
58
|
-
orderly order-place PERP_ETH_USDC BUY LIMIT 0.01 --price 3500 --account <account-id>
|
|
59
|
-
orderly order-place PERP_ETH_USDC BUY MARKET 0.01 --client-order-id my-order-123 --account <account-id>
|
|
60
|
-
orderly order-cancel <order-id> --symbol PERP_ETH_USDC --account <account-id>
|
|
61
|
-
orderly order-list --status NEW --account <account-id>
|
|
62
|
-
|
|
63
|
-
# Trading - Algo Orders (TP/SL)
|
|
64
|
-
orderly algo-order-place PERP_ETH_USDC BUY STOP 0.01 --trigger-price 2000 --account <account-id>
|
|
65
|
-
orderly algo-order-place PERP_ETH_USDC SELL TP_SL 0.01 --tp-trigger-price 2500 --sl-trigger-price 1500 --account <account-id>
|
|
66
|
-
orderly algo-order-list --account <account-id>
|
|
67
|
-
|
|
68
|
-
# Positions
|
|
69
|
-
orderly positions-list --account <account-id>
|
|
70
|
-
orderly positions-close PERP_ETH_USDC --account <account-id>
|
|
71
|
-
|
|
72
|
-
# Market data
|
|
73
|
-
orderly market-price PERP_ETH_USDC
|
|
74
|
-
orderly market-trades PERP_ETH_USDC --limit 20
|
|
75
|
-
orderly funding-rates
|
|
76
|
-
orderly kline PERP_ETH_USDC 1h --limit 100 --account <account-id>
|
|
77
|
-
orderly symbols
|
|
78
|
-
```
|
|
79
|
-
|
|
80
|
-
## Output Format
|
|
13
|
+
Or without installing:
|
|
81
14
|
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
```bash
|
|
85
|
-
orderly market-price PERP_ETH_USDC
|
|
86
|
-
# {"symbol":"PERP_ETH_USDC","index_price":2124.82,"mark_price":2124.89,...}
|
|
87
|
-
```
|
|
88
|
-
|
|
89
|
-
Use `--csv` for tabular data (more token-efficient for lists):
|
|
90
|
-
|
|
91
|
-
```bash
|
|
92
|
-
orderly symbols --csv
|
|
93
|
-
# symbol,index_price,mark_price,...
|
|
94
|
-
# PERP_ETH_USDC,2124.82,2124.89,...
|
|
95
|
-
# PERP_BTC_USDC,71551.7,71551.7,...
|
|
15
|
+
```sh
|
|
16
|
+
npx @orderly.network/cli auth-list
|
|
96
17
|
```
|
|
97
18
|
|
|
98
|
-
|
|
19
|
+
### Platforms
|
|
99
20
|
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
21
|
+
| OS | Architectures |
|
|
22
|
+
| --- | --- |
|
|
23
|
+
| Linux (static musl) | x86_64, arm64 |
|
|
24
|
+
| macOS | x86_64, arm64 |
|
|
25
|
+
| Windows | x86_64, arm64 |
|
|
104
26
|
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
- Exposed in CLI output
|
|
108
|
-
- Accessible to AI agents
|
|
27
|
+
The binary lives in `@orderly.network/cli-<os>-<cpu>`. If your npm config skips
|
|
28
|
+
optional dependencies, reinstall with `--include=optional`.
|
|
109
29
|
|
|
110
|
-
##
|
|
30
|
+
## What it is not
|
|
111
31
|
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
```bash
|
|
117
|
-
yarn dev # Watch mode build
|
|
118
|
-
yarn build # Production build
|
|
119
|
-
yarn lint # Check for issues
|
|
120
|
-
yarn format # Format code
|
|
121
|
-
yarn typecheck # TypeScript check
|
|
122
|
-
yarn test # Run tests
|
|
123
|
-
```
|
|
32
|
+
- **Not a JavaScript API.** Programmatic request building and signing (browser,
|
|
33
|
+
Workers, Node) is [`@orderly.network/cli-wasm`](https://www.npmjs.com/package/@orderly.network/cli-wasm).
|
|
34
|
+
- **Not key storage in the package.** Wallet and API keys live in the OS keychain
|
|
35
|
+
(macOS Keychain, Windows Credential Manager, Linux Secret Service).
|
|
124
36
|
|
|
125
|
-
##
|
|
37
|
+
## Links
|
|
126
38
|
|
|
127
|
-
|
|
39
|
+
- Source: https://gitlab.com/orderlynetwork/orderly-fe/cli
|
|
40
|
+
- Installation, verification, building from source: `INSTALL.md` in the repository
|
package/bin/orderly.js
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
// Launcher for the native Orderly CLI.
|
|
3
|
+
//
|
|
4
|
+
// npm installs this package plus one platform package (os/cpu filtered). This
|
|
5
|
+
// script replaces itself with that binary, inheriting stdio so TTY prompts,
|
|
6
|
+
// colours and exit codes behave exactly as with a direct install.
|
|
7
|
+
import { spawn } from 'node:child_process';
|
|
8
|
+
import { resolveBinary } from '../lib/resolve.js';
|
|
9
|
+
|
|
10
|
+
let binary;
|
|
11
|
+
try {
|
|
12
|
+
binary = resolveBinary();
|
|
13
|
+
} catch (error) {
|
|
14
|
+
process.stderr.write(`${error.message}\n`);
|
|
15
|
+
process.exit(1);
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
const child = spawn(binary, process.argv.slice(2), {
|
|
19
|
+
stdio: 'inherit',
|
|
20
|
+
env: process.env,
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
child.on('error', (error) => {
|
|
24
|
+
process.stderr.write(`orderly: failed to start ${binary}: ${error.message}\n`);
|
|
25
|
+
process.exit(1);
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
child.on('close', (code, signal) => {
|
|
29
|
+
if (signal) {
|
|
30
|
+
process.kill(process.pid, signal);
|
|
31
|
+
return;
|
|
32
|
+
}
|
|
33
|
+
process.exit(code ?? 1);
|
|
34
|
+
});
|
package/lib/resolve.js
ADDED
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { createRequire } from 'node:module';
|
|
2
|
+
import path from 'node:path';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Native binaries ship as one npm package per platform. This map is the only
|
|
6
|
+
* place the launcher and the packer agree on which package holds which target;
|
|
7
|
+
* the packer's TARGETS list in scripts/npm-platforms.mjs must match.
|
|
8
|
+
*/
|
|
9
|
+
const PACKAGES = {
|
|
10
|
+
'linux-x64': '@orderly.network/cli-linux-x64',
|
|
11
|
+
'linux-arm64': '@orderly.network/cli-linux-arm64',
|
|
12
|
+
'darwin-x64': '@orderly.network/cli-darwin-x64',
|
|
13
|
+
'darwin-arm64': '@orderly.network/cli-darwin-arm64',
|
|
14
|
+
'win32-x64': '@orderly.network/cli-win32-x64',
|
|
15
|
+
'win32-arm64': '@orderly.network/cli-win32-arm64',
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
const requireFromHere = createRequire(import.meta.url);
|
|
19
|
+
const defaultResolve = (id) => requireFromHere.resolve(id);
|
|
20
|
+
|
|
21
|
+
/** npm package that carries the binary for a platform/arch pair. */
|
|
22
|
+
export function packageForPlatform(platform, arch) {
|
|
23
|
+
return PACKAGES[`${platform}-${arch}`] ?? null;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
/** Executable file name inside the platform package. */
|
|
27
|
+
export function binaryName(platform) {
|
|
28
|
+
return platform === 'win32' ? 'orderly.exe' : 'orderly';
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* Absolute path of the native binary for this machine.
|
|
33
|
+
*
|
|
34
|
+
* `resolve` is injectable so the mapping and error paths are testable without
|
|
35
|
+
* a real install.
|
|
36
|
+
*/
|
|
37
|
+
export function resolveBinary(
|
|
38
|
+
platform = process.platform,
|
|
39
|
+
arch = process.arch,
|
|
40
|
+
resolve = defaultResolve
|
|
41
|
+
) {
|
|
42
|
+
const pkg = packageForPlatform(platform, arch);
|
|
43
|
+
if (!pkg) {
|
|
44
|
+
throw new Error(
|
|
45
|
+
`orderly: no prebuilt CLI for ${platform}-${arch}.\n` +
|
|
46
|
+
'Supported platforms: linux (x64, arm64), macOS (x64, arm64), Windows (x64, arm64).\n' +
|
|
47
|
+
'Build from source instead: cargo install --path .'
|
|
48
|
+
);
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
let manifest;
|
|
52
|
+
try {
|
|
53
|
+
manifest = resolve(`${pkg}/package.json`);
|
|
54
|
+
} catch {
|
|
55
|
+
throw new Error(
|
|
56
|
+
`orderly: ${pkg} is not installed.\n` +
|
|
57
|
+
'It is an optional dependency of @orderly.network/cli, so the install either\n' +
|
|
58
|
+
'skipped optional dependencies or filtered by platform. Reinstall with:\n' +
|
|
59
|
+
' npm install -g @orderly.network/cli --include=optional'
|
|
60
|
+
);
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
return path.join(path.dirname(manifest), 'bin', binaryName(platform));
|
|
64
|
+
}
|
package/package.json
CHANGED
|
@@ -1,65 +1,31 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@orderly.network/cli",
|
|
3
|
-
"version": "
|
|
4
|
-
"description": "CLI
|
|
5
|
-
"
|
|
3
|
+
"version": "2.2.3",
|
|
4
|
+
"description": "Orderly Network CLI: the native binary is installed as an optional dependency",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"repository": {
|
|
7
|
+
"type": "git",
|
|
8
|
+
"url": "git+https://gitlab.com/orderlynetwork/orderly-fe/cli.git"
|
|
9
|
+
},
|
|
10
|
+
"homepage": "https://github.com/OrderlyNetwork/cli",
|
|
6
11
|
"type": "module",
|
|
7
12
|
"bin": {
|
|
8
|
-
"orderly": "
|
|
13
|
+
"orderly": "bin/orderly.js"
|
|
9
14
|
},
|
|
10
|
-
"
|
|
11
|
-
"
|
|
12
|
-
"dev": "node scripts/build.js --watch",
|
|
13
|
-
"start": "node dist/index.js",
|
|
14
|
-
"lint": "eslint src --ext .ts --report-unused-disable-directives --max-warnings 0",
|
|
15
|
-
"lint:fix": "eslint src --ext .ts --fix",
|
|
16
|
-
"format": "prettier --write \"src/**/*.{ts,json,md}\"",
|
|
17
|
-
"format:check": "prettier --check \"src/**/*.{ts,json,md}\"",
|
|
18
|
-
"typecheck": "tsc --noEmit",
|
|
19
|
-
"prepublishOnly": "yarn build && yarn typecheck"
|
|
15
|
+
"engines": {
|
|
16
|
+
"node": ">=18"
|
|
20
17
|
},
|
|
21
|
-
"keywords": [
|
|
22
|
-
"orderly",
|
|
23
|
-
"orderly-network",
|
|
24
|
-
"cli",
|
|
25
|
-
"trading",
|
|
26
|
-
"defi",
|
|
27
|
-
"perpetuals"
|
|
28
|
-
],
|
|
29
|
-
"author": "Orderly Network",
|
|
30
|
-
"license": "MIT",
|
|
31
18
|
"files": [
|
|
32
|
-
"
|
|
19
|
+
"bin",
|
|
20
|
+
"lib",
|
|
21
|
+
"README.md"
|
|
33
22
|
],
|
|
34
|
-
"
|
|
35
|
-
"
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
"@
|
|
39
|
-
"@orderly.network/
|
|
40
|
-
"
|
|
41
|
-
"bs58": "^6.0.0",
|
|
42
|
-
"cac": "6.7.14",
|
|
43
|
-
"ethers": "^6.16.0",
|
|
44
|
-
"keytar": "^7.9.0",
|
|
45
|
-
"kleur": "^4.1.5",
|
|
46
|
-
"prompts": "^2.4.2",
|
|
47
|
-
"zod": "^4.3.6"
|
|
48
|
-
},
|
|
49
|
-
"devDependencies": {
|
|
50
|
-
"@eslint/js": "^9.24.0",
|
|
51
|
-
"@types/node": "^24.0.0",
|
|
52
|
-
"@types/prompts": "^2.4.9",
|
|
53
|
-
"@typescript-eslint/eslint-plugin": "^8.57.0",
|
|
54
|
-
"@typescript-eslint/parser": "^8.57.0",
|
|
55
|
-
"esbuild": "^0.27.4",
|
|
56
|
-
"eslint": "^10.0.3",
|
|
57
|
-
"eslint-config-prettier": "^10.1.8",
|
|
58
|
-
"prettier": "^3.8.1",
|
|
59
|
-
"typescript": "^5.9.3",
|
|
60
|
-
"typescript-eslint": "^8.57.0"
|
|
61
|
-
},
|
|
62
|
-
"engines": {
|
|
63
|
-
"node": ">=22.0.0"
|
|
23
|
+
"optionalDependencies": {
|
|
24
|
+
"@orderly.network/cli-linux-x64": "2.2.3",
|
|
25
|
+
"@orderly.network/cli-linux-arm64": "2.2.3",
|
|
26
|
+
"@orderly.network/cli-darwin-x64": "2.2.3",
|
|
27
|
+
"@orderly.network/cli-darwin-arm64": "2.2.3",
|
|
28
|
+
"@orderly.network/cli-win32-x64": "2.2.3",
|
|
29
|
+
"@orderly.network/cli-win32-arm64": "2.2.3"
|
|
64
30
|
}
|
|
65
31
|
}
|