oneie 5.7.5 → 5.7.6
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 +1 -0
- package/dist/package.json +5 -2
- package/dist/src/balances.d.ts +89 -0
- package/dist/src/balances.js +202 -0
- package/dist/src/hl-run.d.ts +119 -0
- package/dist/src/hl-run.js +480 -0
- package/dist/src/hl.d.ts +17 -0
- package/dist/src/hl.js +148 -0
- package/dist/src/index.js +2 -1
- package/dist/src/key-sweep.d.ts +19 -3
- package/dist/src/key-sweep.js +63 -20
- package/dist/src/lib/hl-core/actions.d.ts +99 -0
- package/dist/src/lib/hl-core/actions.js +69 -0
- package/dist/src/lib/hl-core/eip712.d.ts +33 -0
- package/dist/src/lib/hl-core/eip712.js +107 -0
- package/dist/src/lib/hl-core/errors.d.ts +10 -0
- package/dist/src/lib/hl-core/errors.js +15 -0
- package/dist/src/lib/hl-core/exchange.d.ts +24 -0
- package/dist/src/lib/hl-core/exchange.js +47 -0
- package/dist/src/lib/hl-core/index.d.ts +13 -0
- package/dist/src/lib/hl-core/index.js +14 -0
- package/dist/src/lib/hl-core/meta.d.ts +57 -0
- package/dist/src/lib/hl-core/meta.js +110 -0
- package/dist/src/lib/hl-core/msgpack.d.ts +18 -0
- package/dist/src/lib/hl-core/msgpack.js +136 -0
- package/dist/src/lib/hl-core/net.d.ts +2 -0
- package/dist/src/lib/hl-core/net.js +7 -0
- package/dist/src/lib/hl-core/signing.d.ts +103 -0
- package/dist/src/lib/hl-core/signing.js +295 -0
- package/dist/src/lib/hl-core/wire.d.ts +34 -0
- package/dist/src/lib/hl-core/wire.js +81 -0
- package/dist/src/lib/journey-words.d.ts +54 -3
- package/dist/src/lib/journey-words.js +159 -20
- package/dist/src/lib/journey.js +1 -1
- package/dist/src/lib/key-source.d.ts +9 -0
- package/dist/src/lib/key-source.js +33 -0
- package/dist/src/lib/network.d.ts +15 -0
- package/dist/src/lib/network.js +41 -0
- package/dist/src/lib/qr.d.ts +21 -0
- package/dist/src/lib/qr.js +402 -0
- package/dist/src/lib/sale-card.d.ts +117 -0
- package/dist/src/lib/sale-card.js +261 -0
- package/dist/src/lib/sui-grpc-send.d.ts +50 -0
- package/dist/src/lib/sui-grpc-send.js +89 -0
- package/dist/src/lib/wallet-money.d.ts +222 -0
- package/dist/src/lib/wallet-money.js +578 -0
- package/dist/src/lib/wallet-request.d.ts +50 -0
- package/dist/src/lib/wallet-request.js +86 -0
- package/dist/src/onboard.js +4 -3
- package/dist/src/shop.js +38 -1
- package/dist/src/staff.js +10 -0
- package/dist/src/start.js +14 -6
- package/dist/src/wallet-money.d.ts +152 -0
- package/dist/src/wallet-money.js +564 -0
- package/dist/src/wallet.js +169 -24
- package/package.json +5 -2
package/README.md
CHANGED
|
@@ -185,6 +185,7 @@ Every actor — human or agent — gets real, self-custodied multi-chain wallets
|
|
|
185
185
|
```bash
|
|
186
186
|
one wallet create --workspace <slug> --kind agent # provision a wallet row (idempotent)
|
|
187
187
|
one wallet get --workspace <slug> # credits, ceiling, live balances, delegated wallets
|
|
188
|
+
one ask wallet:get --data '{"net":"mainnet"}' # the same on mainnet (wallet:get / MCP wallet_get take net; no --net flag yet)
|
|
188
189
|
one wallet register --from keys.json --workspace <slug> # register the PUBLIC receiving addresses — first write wins, permanent
|
|
189
190
|
one wallet transactions --workspace <slug> --limit 50 # unified feed across every settlement rail
|
|
190
191
|
one wallet faucet <address> --chain sui # fund from testnet — sui/sol auto-fund, others return a manual URL
|
package/dist/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "oneie",
|
|
3
|
-
"version": "5.7.
|
|
3
|
+
"version": "5.7.6",
|
|
4
4
|
"description": "ONE agent CLI",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
@@ -20,7 +20,10 @@
|
|
|
20
20
|
},
|
|
21
21
|
"dependencies": {
|
|
22
22
|
"commander": "^12.0.0",
|
|
23
|
-
"@oneie/sdk": "^0.17.6"
|
|
23
|
+
"@oneie/sdk": "^0.17.6",
|
|
24
|
+
"@noble/curves": "^2.2.0",
|
|
25
|
+
"@noble/hashes": "^2.2.0",
|
|
26
|
+
"@mysten/sui": "^2.20.0"
|
|
24
27
|
},
|
|
25
28
|
"devDependencies": {
|
|
26
29
|
"@oneie/evals": "^0.2.0",
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `one wallet balances [address]` — what is REALLY at the wallet you loaded, on mainnet.
|
|
3
|
+
*
|
|
4
|
+
* `wallet get` reads ONE's own ledger, which for most chains is test money: it printed
|
|
5
|
+
* 0.000000 for an address that held real ETH and USDC (measured 2026-11-09). This reads the
|
|
6
|
+
* chains themselves, through public read-only endpoints, with no key and nothing signed:
|
|
7
|
+
* EVM ETH, USDC, USDT on Ethereum, Base and Arbitrum
|
|
8
|
+
* Sui SUI on mainnet
|
|
9
|
+
* Hyperliquid perps and spot, never summed (HyperCore keeps them apart)
|
|
10
|
+
*
|
|
11
|
+
* A read that FAILS is `unavailable`, never 0: a short answer must say it is short.
|
|
12
|
+
*/
|
|
13
|
+
import { Command } from 'commander';
|
|
14
|
+
export type Obj = Record<string, unknown>;
|
|
15
|
+
export type Fetch = (url: string, init?: {
|
|
16
|
+
method?: string;
|
|
17
|
+
headers?: Record<string, string>;
|
|
18
|
+
body?: string;
|
|
19
|
+
}) => Promise<{
|
|
20
|
+
ok: boolean;
|
|
21
|
+
json(): Promise<unknown>;
|
|
22
|
+
}>;
|
|
23
|
+
export declare const isEvmAddress: (s: string) => boolean;
|
|
24
|
+
export declare const isSuiAddress: (s: string) => boolean;
|
|
25
|
+
interface Token {
|
|
26
|
+
symbol: string;
|
|
27
|
+
contract: string;
|
|
28
|
+
decimals: number;
|
|
29
|
+
}
|
|
30
|
+
interface EvmChain {
|
|
31
|
+
name: string;
|
|
32
|
+
rpc: string;
|
|
33
|
+
tokens: Token[];
|
|
34
|
+
}
|
|
35
|
+
export declare const EVM_CHAINS: EvmChain[];
|
|
36
|
+
/** Sui's public JSON-RPC was switched off; GraphQL is the supported public read (measured 2026-11-09). */
|
|
37
|
+
export declare const SUI_GRAPHQL = "https://graphql.mainnet.sui.io/graphql";
|
|
38
|
+
export declare const HL_INFO = "https://api.hyperliquid.xyz/info";
|
|
39
|
+
export interface BalanceRow {
|
|
40
|
+
chain: string;
|
|
41
|
+
asset: string;
|
|
42
|
+
amount: string | null;
|
|
43
|
+
unavailable?: string;
|
|
44
|
+
}
|
|
45
|
+
/** Base units → a plain decimal, no float. */
|
|
46
|
+
export declare function formatUnits(raw: bigint, decimals: number): string;
|
|
47
|
+
export declare function readEvm(address: string, f: Fetch): Promise<BalanceRow[]>;
|
|
48
|
+
export declare function readSui(address: string, f: Fetch): Promise<BalanceRow[]>;
|
|
49
|
+
export interface HlRead {
|
|
50
|
+
perps: string | null;
|
|
51
|
+
withdrawable: string | null;
|
|
52
|
+
spot: {
|
|
53
|
+
coin: string;
|
|
54
|
+
total: string;
|
|
55
|
+
}[] | null;
|
|
56
|
+
unavailable?: string;
|
|
57
|
+
}
|
|
58
|
+
export declare function readHyperliquid(address: string, f: Fetch): Promise<HlRead>;
|
|
59
|
+
export interface BalancesResult {
|
|
60
|
+
ok: true;
|
|
61
|
+
network: 'mainnet';
|
|
62
|
+
rows: BalanceRow[];
|
|
63
|
+
hyperliquid?: HlRead;
|
|
64
|
+
/** Plain words for the person: every empty row is real, every `unavailable` row is not a zero. */
|
|
65
|
+
note: string;
|
|
66
|
+
}
|
|
67
|
+
export declare function readBalances(addresses: {
|
|
68
|
+
evm?: string;
|
|
69
|
+
sui?: string;
|
|
70
|
+
}, f: Fetch): Promise<BalancesResult>;
|
|
71
|
+
export declare function balanceLines(r: BalancesResult, addresses: {
|
|
72
|
+
evm?: string;
|
|
73
|
+
sui?: string;
|
|
74
|
+
}): string[];
|
|
75
|
+
export interface BalancesDeps {
|
|
76
|
+
fetch: Fetch;
|
|
77
|
+
/** The addresses of the loaded wallet — the workspace's own — when none is typed. */
|
|
78
|
+
addresses(opts: {
|
|
79
|
+
workspace?: string;
|
|
80
|
+
actor?: string;
|
|
81
|
+
api: string;
|
|
82
|
+
key?: string;
|
|
83
|
+
}): Promise<{
|
|
84
|
+
evm?: string;
|
|
85
|
+
sui?: string;
|
|
86
|
+
}>;
|
|
87
|
+
}
|
|
88
|
+
export declare function balancesCmd(deps: BalancesDeps, defaultApi: string): Command;
|
|
89
|
+
export {};
|
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `one wallet balances [address]` — what is REALLY at the wallet you loaded, on mainnet.
|
|
3
|
+
*
|
|
4
|
+
* `wallet get` reads ONE's own ledger, which for most chains is test money: it printed
|
|
5
|
+
* 0.000000 for an address that held real ETH and USDC (measured 2026-11-09). This reads the
|
|
6
|
+
* chains themselves, through public read-only endpoints, with no key and nothing signed:
|
|
7
|
+
* EVM ETH, USDC, USDT on Ethereum, Base and Arbitrum
|
|
8
|
+
* Sui SUI on mainnet
|
|
9
|
+
* Hyperliquid perps and spot, never summed (HyperCore keeps them apart)
|
|
10
|
+
*
|
|
11
|
+
* A read that FAILS is `unavailable`, never 0: a short answer must say it is short.
|
|
12
|
+
*/
|
|
13
|
+
import { Command } from 'commander';
|
|
14
|
+
const EVM_ADDRESS = /^0x[0-9a-fA-F]{40}$/;
|
|
15
|
+
const SUI_ADDRESS = /^0x[0-9a-fA-F]{64}$/;
|
|
16
|
+
export const isEvmAddress = (s) => EVM_ADDRESS.test(s);
|
|
17
|
+
export const isSuiAddress = (s) => SUI_ADDRESS.test(s);
|
|
18
|
+
export const EVM_CHAINS = [
|
|
19
|
+
{
|
|
20
|
+
name: 'ethereum', rpc: 'https://ethereum-rpc.publicnode.com',
|
|
21
|
+
tokens: [
|
|
22
|
+
{ symbol: 'USDC', contract: '0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48', decimals: 6 },
|
|
23
|
+
{ symbol: 'USDT', contract: '0xdac17f958d2ee523a2206206994597c13d831ec7', decimals: 6 },
|
|
24
|
+
],
|
|
25
|
+
},
|
|
26
|
+
{ name: 'base', rpc: 'https://base-rpc.publicnode.com', tokens: [{ symbol: 'USDC', contract: '0x833589fcd6edb6e08f4c7c32d4f71b54bda02913', decimals: 6 }] },
|
|
27
|
+
{
|
|
28
|
+
name: 'arbitrum', rpc: 'https://arbitrum-one-rpc.publicnode.com',
|
|
29
|
+
tokens: [
|
|
30
|
+
{ symbol: 'USDC', contract: '0xaf88d065e77c8cc2239327c5edb3a432268e5831', decimals: 6 },
|
|
31
|
+
{ symbol: 'USDT', contract: '0xfd086bc7cd5c481dcc9c85ebe478a1c0b69fcbb9', decimals: 6 },
|
|
32
|
+
],
|
|
33
|
+
},
|
|
34
|
+
];
|
|
35
|
+
/** Sui's public JSON-RPC was switched off; GraphQL is the supported public read (measured 2026-11-09). */
|
|
36
|
+
export const SUI_GRAPHQL = 'https://graphql.mainnet.sui.io/graphql';
|
|
37
|
+
export const HL_INFO = 'https://api.hyperliquid.xyz/info';
|
|
38
|
+
/** Base units → a plain decimal, no float. */
|
|
39
|
+
export function formatUnits(raw, decimals) {
|
|
40
|
+
const neg = raw < 0n;
|
|
41
|
+
const s = (neg ? -raw : raw).toString().padStart(decimals + 1, '0');
|
|
42
|
+
const whole = s.slice(0, s.length - decimals);
|
|
43
|
+
const frac = s.slice(s.length - decimals).replace(/0+$/, '');
|
|
44
|
+
return `${neg ? '-' : ''}${whole}${frac ? `.${frac}` : ''}`;
|
|
45
|
+
}
|
|
46
|
+
async function post(f, url, body) {
|
|
47
|
+
const res = await f(url, { method: 'POST', headers: { 'content-type': 'application/json' }, body: JSON.stringify(body) });
|
|
48
|
+
if (!res.ok)
|
|
49
|
+
throw new Error('http_error');
|
|
50
|
+
return res.json();
|
|
51
|
+
}
|
|
52
|
+
const row = (chain, asset, read, decimals) => read().then((raw) => ({ chain, asset, amount: formatUnits(raw, decimals) }), (e) => ({ chain, asset, amount: null, unavailable: e instanceof Error ? e.message : 'read_failed' }));
|
|
53
|
+
const rpcHex = async (f, url, method, params) => {
|
|
54
|
+
const r = (await post(f, url, { jsonrpc: '2.0', id: 1, method, params }));
|
|
55
|
+
if (typeof r.result !== 'string' || !/^0x[0-9a-fA-F]*$/.test(r.result))
|
|
56
|
+
throw new Error('bad_answer');
|
|
57
|
+
return r.result === '0x' ? 0n : BigInt(r.result);
|
|
58
|
+
};
|
|
59
|
+
export async function readEvm(address, f) {
|
|
60
|
+
const pad = address.slice(2).toLowerCase().padStart(64, '0');
|
|
61
|
+
const reads = [];
|
|
62
|
+
for (const c of EVM_CHAINS) {
|
|
63
|
+
reads.push(row(c.name, 'ETH', () => rpcHex(f, c.rpc, 'eth_getBalance', [address, 'latest']), 18));
|
|
64
|
+
for (const t of c.tokens) {
|
|
65
|
+
reads.push(row(c.name, t.symbol, () => rpcHex(f, c.rpc, 'eth_call', [{ to: t.contract, data: `0x70a08231${pad}` }, 'latest']), t.decimals));
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
return Promise.all(reads);
|
|
69
|
+
}
|
|
70
|
+
export async function readSui(address, f) {
|
|
71
|
+
return [
|
|
72
|
+
await row('sui', 'SUI', async () => {
|
|
73
|
+
const r = (await post(f, SUI_GRAPHQL, {
|
|
74
|
+
query: 'query($a: SuiAddress!) { address(address: $a) { balance(coinType: "0x2::sui::SUI") { totalBalance } } }',
|
|
75
|
+
variables: { a: address },
|
|
76
|
+
}));
|
|
77
|
+
const b = r.data?.address?.balance?.totalBalance;
|
|
78
|
+
// An address that never held SUI has a null balance object: that is a real zero only when the
|
|
79
|
+
// address itself answered.
|
|
80
|
+
if (r.data?.address && r.data.address.balance === null)
|
|
81
|
+
return 0n;
|
|
82
|
+
if (typeof b !== 'string' || !/^\d+$/.test(b))
|
|
83
|
+
throw new Error('bad_answer');
|
|
84
|
+
return BigInt(b);
|
|
85
|
+
}, 9),
|
|
86
|
+
];
|
|
87
|
+
}
|
|
88
|
+
export async function readHyperliquid(address, f) {
|
|
89
|
+
try {
|
|
90
|
+
const [p, s] = await Promise.all([
|
|
91
|
+
post(f, HL_INFO, { type: 'clearinghouseState', user: address }),
|
|
92
|
+
post(f, HL_INFO, { type: 'spotClearinghouseState', user: address }),
|
|
93
|
+
]);
|
|
94
|
+
return {
|
|
95
|
+
perps: p.marginSummary?.accountValue ?? null,
|
|
96
|
+
withdrawable: p.withdrawable ?? null,
|
|
97
|
+
spot: (s.balances ?? []).map((b) => ({ coin: b.coin, total: b.total })),
|
|
98
|
+
};
|
|
99
|
+
}
|
|
100
|
+
catch (e) {
|
|
101
|
+
return { perps: null, withdrawable: null, spot: null, unavailable: e instanceof Error ? e.message : 'read_failed' };
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
export async function readBalances(addresses, f) {
|
|
105
|
+
const [evm, sui, hl] = await Promise.all([
|
|
106
|
+
addresses.evm ? readEvm(addresses.evm, f) : Promise.resolve([]),
|
|
107
|
+
addresses.sui ? readSui(addresses.sui, f) : Promise.resolve([]),
|
|
108
|
+
addresses.evm ? readHyperliquid(addresses.evm, f) : Promise.resolve(undefined),
|
|
109
|
+
]);
|
|
110
|
+
return {
|
|
111
|
+
ok: true,
|
|
112
|
+
network: 'mainnet',
|
|
113
|
+
rows: [...evm, ...sui],
|
|
114
|
+
...(hl ? { hyperliquid: hl } : {}),
|
|
115
|
+
note: 'Mainnet, read from the chains themselves. `wallet get` shows ONE\'s own ledger, which is test money for most chains. A row that says unavailable was not read; it is not zero.',
|
|
116
|
+
};
|
|
117
|
+
}
|
|
118
|
+
export function balanceLines(r, addresses) {
|
|
119
|
+
const lines = [];
|
|
120
|
+
const pad = (s, n) => s.padEnd(n);
|
|
121
|
+
if (addresses.evm)
|
|
122
|
+
lines.push(`evm ${addresses.evm}`);
|
|
123
|
+
if (addresses.sui)
|
|
124
|
+
lines.push(`sui ${addresses.sui}`);
|
|
125
|
+
for (const x of r.rows) {
|
|
126
|
+
const v = x.amount === null ? `unavailable (${x.unavailable ?? 'read_failed'})` : x.amount;
|
|
127
|
+
if (x.amount === '0')
|
|
128
|
+
continue;
|
|
129
|
+
lines.push(`${pad(x.chain, 10)}${pad(x.asset, 6)}${v}`);
|
|
130
|
+
}
|
|
131
|
+
const nonzero = r.rows.filter((x) => x.amount !== '0').length;
|
|
132
|
+
if (nonzero === 0)
|
|
133
|
+
lines.push('(every chain read answered: nothing here)');
|
|
134
|
+
if (r.hyperliquid) {
|
|
135
|
+
const h = r.hyperliquid;
|
|
136
|
+
if (h.unavailable)
|
|
137
|
+
lines.push(`hyperliquid unavailable (${h.unavailable})`);
|
|
138
|
+
else {
|
|
139
|
+
lines.push(`hyperliquid perps ${h.perps ?? '0'} (withdrawable ${h.withdrawable ?? '0'})`);
|
|
140
|
+
lines.push(`hyperliquid spot ${h.spot && h.spot.length ? h.spot.map((b) => `${b.total} ${b.coin}`).join(', ') : 'none'}`);
|
|
141
|
+
lines.push('perps and spot are separate balances; they are not summed');
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
return lines;
|
|
145
|
+
}
|
|
146
|
+
export function balancesCmd(deps, defaultApi) {
|
|
147
|
+
return new Command('balances')
|
|
148
|
+
.description('What is really in your wallet on mainnet: ETH, USDC, USDT on Ethereum, Base and Arbitrum; SUI; Hyperliquid perps and spot. No key, nothing signed. No address = your workspace wallet')
|
|
149
|
+
.argument('[address]', 'a 0x EVM address (40 hex) or a Sui address (64 hex)')
|
|
150
|
+
.option('--workspace <slug>', 'Workspace (defaults to AGENCY_SLUG)')
|
|
151
|
+
.option('--actor <id>', 'Actor within the workspace (defaults to workspace)')
|
|
152
|
+
.option('--api <url>', 'API base URL', defaultApi)
|
|
153
|
+
.option('--key <key>', 'API key (needed only without an address)')
|
|
154
|
+
.action(async function (address, opts) {
|
|
155
|
+
const json = Boolean(this.optsWithGlobals().json);
|
|
156
|
+
let addrs;
|
|
157
|
+
if (address) {
|
|
158
|
+
const a = address.trim();
|
|
159
|
+
if (isEvmAddress(a))
|
|
160
|
+
addrs = { evm: a };
|
|
161
|
+
else if (isSuiAddress(a))
|
|
162
|
+
addrs = { sui: a };
|
|
163
|
+
else {
|
|
164
|
+
const err = { ok: false, error: 'bad_address', next: 'Pass a 0x EVM address (40 hex characters) or a Sui address (64).' };
|
|
165
|
+
if (json)
|
|
166
|
+
process.stdout.write(JSON.stringify(err) + '\n');
|
|
167
|
+
else
|
|
168
|
+
console.error('✗', err.next);
|
|
169
|
+
process.exit(1);
|
|
170
|
+
return;
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
else {
|
|
174
|
+
try {
|
|
175
|
+
addrs = await deps.addresses(opts);
|
|
176
|
+
}
|
|
177
|
+
catch (e) {
|
|
178
|
+
const msg = e instanceof Error ? e.message : 'wallet_read_failed';
|
|
179
|
+
if (json)
|
|
180
|
+
process.stdout.write(JSON.stringify({ ok: false, error: 'wallet_read_failed', detail: msg, next: 'Pass an address: one wallet balances 0x…' }) + '\n');
|
|
181
|
+
else
|
|
182
|
+
console.error('✗', msg, '\n Pass an address: one wallet balances 0x…');
|
|
183
|
+
process.exit(1);
|
|
184
|
+
return;
|
|
185
|
+
}
|
|
186
|
+
if (!addrs.evm && !addrs.sui) {
|
|
187
|
+
const err = { ok: false, error: 'no_address', next: 'Your workspace has no wallet address registered. Pass one: one wallet balances 0x…' };
|
|
188
|
+
if (json)
|
|
189
|
+
process.stdout.write(JSON.stringify(err) + '\n');
|
|
190
|
+
else
|
|
191
|
+
console.error('✗', err.next);
|
|
192
|
+
process.exit(1);
|
|
193
|
+
return;
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
const r = await readBalances(addrs, deps.fetch);
|
|
197
|
+
if (json)
|
|
198
|
+
process.stdout.write(JSON.stringify({ ...r, addresses: addrs }) + '\n');
|
|
199
|
+
else
|
|
200
|
+
console.log(balanceLines(r, addrs).join('\n'));
|
|
201
|
+
});
|
|
202
|
+
}
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
import * as hl from './lib/hl-core/index.js';
|
|
2
|
+
import type { HlNet } from './lib/hl-core/net.js';
|
|
3
|
+
type Obj = Record<string, unknown>;
|
|
4
|
+
export interface VaultKey {
|
|
5
|
+
chain: string;
|
|
6
|
+
address: string;
|
|
7
|
+
privateKeyHex: string;
|
|
8
|
+
}
|
|
9
|
+
export interface HlDeps {
|
|
10
|
+
/** Every Hyperliquid read and the one /exchange post go through this. */
|
|
11
|
+
fetchImpl: typeof fetch;
|
|
12
|
+
/** The signing machine's ms clock — the nonce (H13). */
|
|
13
|
+
now(): number;
|
|
14
|
+
env: NodeJS.ProcessEnv;
|
|
15
|
+
/** A person at a terminal: stdin and stdout are TTYs and --json is off. */
|
|
16
|
+
interactive: boolean;
|
|
17
|
+
home: string;
|
|
18
|
+
realpath(p: string): string | null;
|
|
19
|
+
unlock(dir: string): Promise<{
|
|
20
|
+
keys: VaultKey[];
|
|
21
|
+
} | {
|
|
22
|
+
error: string;
|
|
23
|
+
}>;
|
|
24
|
+
confirm(question: string): Promise<boolean>;
|
|
25
|
+
say(lines: string[]): void;
|
|
26
|
+
/** A ONE receiver (wallet:get only — to find the workspace's EVM address when none is named). */
|
|
27
|
+
ask(receiver: string, data: Obj): Promise<Obj>;
|
|
28
|
+
}
|
|
29
|
+
export interface Result {
|
|
30
|
+
data: Obj;
|
|
31
|
+
exitCode?: number;
|
|
32
|
+
}
|
|
33
|
+
export interface LiveArgs {
|
|
34
|
+
testnet?: boolean;
|
|
35
|
+
live?: boolean;
|
|
36
|
+
dir?: string;
|
|
37
|
+
yes?: boolean;
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* A Signer over one secp256k1 key from the vault. It rebuilds the digest from (domain, types,
|
|
41
|
+
* message) itself — the seam hands it no digest — and answers r ‖ s ‖ v, v = 27 + recovery.
|
|
42
|
+
*/
|
|
43
|
+
export declare function vaultSigner(key: {
|
|
44
|
+
address: string;
|
|
45
|
+
privateKeyHex: string;
|
|
46
|
+
}): hl.Signer;
|
|
47
|
+
export interface HlBalance {
|
|
48
|
+
perps: {
|
|
49
|
+
accountValue: string | null;
|
|
50
|
+
withdrawable: string | null;
|
|
51
|
+
};
|
|
52
|
+
spot: Array<{
|
|
53
|
+
coin: string;
|
|
54
|
+
total: string;
|
|
55
|
+
hold: string;
|
|
56
|
+
}>;
|
|
57
|
+
}
|
|
58
|
+
/** perps + spot, or null when either read failed — a failed read is never a zero balance. */
|
|
59
|
+
export declare function readBalance(address: string, net: HlNet, deps: HlDeps): Promise<HlBalance | null>;
|
|
60
|
+
/** The account a keyless read is about: the address named, else the workspace's one EVM address. */
|
|
61
|
+
export declare function resolveAccount(address: string | undefined, actor: string | undefined, deps: HlDeps): Promise<{
|
|
62
|
+
ok: true;
|
|
63
|
+
address: string;
|
|
64
|
+
} | Result>;
|
|
65
|
+
export declare function runPositions(args: {
|
|
66
|
+
address?: string;
|
|
67
|
+
actor?: string;
|
|
68
|
+
testnet?: boolean;
|
|
69
|
+
}, deps: HlDeps): Promise<Result>;
|
|
70
|
+
export declare function runOrders(args: {
|
|
71
|
+
address?: string;
|
|
72
|
+
actor?: string;
|
|
73
|
+
testnet?: boolean;
|
|
74
|
+
}, deps: HlDeps): Promise<Result>;
|
|
75
|
+
/** What a verb hands the runner: its action for a nonce + signer, and the words for a person. */
|
|
76
|
+
interface Built {
|
|
77
|
+
action: hl.HlAction;
|
|
78
|
+
opts: hl.DryRunOpts;
|
|
79
|
+
words: string[];
|
|
80
|
+
facts: Obj;
|
|
81
|
+
}
|
|
82
|
+
interface Prepared {
|
|
83
|
+
cmdline: string;
|
|
84
|
+
build(nonce: number, signer: string | null): Built;
|
|
85
|
+
}
|
|
86
|
+
export interface OrderArgs extends LiveArgs {
|
|
87
|
+
side: string;
|
|
88
|
+
size: string;
|
|
89
|
+
coin: string;
|
|
90
|
+
limit?: string;
|
|
91
|
+
tif?: string;
|
|
92
|
+
reduceOnly?: boolean;
|
|
93
|
+
slippage?: string;
|
|
94
|
+
}
|
|
95
|
+
export declare function prepareOrder(a: OrderArgs, deps: HlDeps): Promise<Prepared | Result>;
|
|
96
|
+
export declare function prepareCancel(a: LiveArgs & {
|
|
97
|
+
coin: string;
|
|
98
|
+
oid: string;
|
|
99
|
+
}, deps: HlDeps): Promise<Prepared | Result>;
|
|
100
|
+
export declare function prepareTransfer(a: LiveArgs & {
|
|
101
|
+
amount: string;
|
|
102
|
+
to?: string;
|
|
103
|
+
address?: string;
|
|
104
|
+
actor?: string;
|
|
105
|
+
}, deps: HlDeps): Promise<Prepared | Result>;
|
|
106
|
+
export declare function prepareWithdraw(a: LiveArgs & {
|
|
107
|
+
amount: string;
|
|
108
|
+
to?: string;
|
|
109
|
+
address?: string;
|
|
110
|
+
actor?: string;
|
|
111
|
+
}, deps: HlDeps, agentShell: boolean): Promise<Prepared | Result>;
|
|
112
|
+
/** Refuse BEFORE any vault opens — no Touch ID prompt for a run that cannot go on. */
|
|
113
|
+
export declare function liveGate(a: LiveArgs, deps: HlDeps): Result | null;
|
|
114
|
+
/** The plain-words line for userAbstraction: unified / portfolio accounts margin perps from spot. */
|
|
115
|
+
export declare function abstractionWords(ab: unknown): string;
|
|
116
|
+
export declare function runAction(verb: string, a: LiveArgs, prepare: () => Promise<Prepared | Result>, deps: HlDeps, o?: {
|
|
117
|
+
abstractionFor?: string | null;
|
|
118
|
+
}): Promise<Result>;
|
|
119
|
+
export {};
|