oneie 5.7.4 → 5.7.5

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.
@@ -0,0 +1,93 @@
1
+ /**
2
+ * `one swap` and `one hl` — swap any coin to any coin, or send it into Hyperliquid
3
+ * (text/swap-plan.md § CLI (A)).
4
+ *
5
+ * one swap 0.01 BTC hl dry price (default — R11)
6
+ * one swap 10 USDC@base to hl --live a real deposit address, checked with 1Click
7
+ * one swap status <depositAddress> where is it; --watch polls until it lands
8
+ * one swap assets every alias, chain, decimals and signer
9
+ * one hl balance [0x…] a Hyperliquid account: perps and spot, never summed
10
+ *
11
+ * THIS COMMAND NEVER SIGNS AND HOLDS NO KEY. The server only quotes and reads status. On
12
+ * --live, nothing printed as a send instruction comes from the ONE server unchecked: the CLI
13
+ * reads the quote back from 1Click DIRECTLY (a plain fetch to a fixed host) and runs the client
14
+ * check (R16) against its OWN values — asset ids from its own table, the amount from its own
15
+ * parseUnits, its own slippage — then builds the send line and the wallet URI itself from
16
+ * 1Click's record. A mismatch prints `quote_mismatch` and no send line.
17
+ *
18
+ * Everything goes over ask() — no new @oneie/sdk import (R2). Every exit closes with
19
+ * out(cmd, data): one JSON line under --json, an `error <name>` + the reason otherwise, exit 1
20
+ * on ok:false; `status --watch` exits 2 when it stops at its poll cap.
21
+ */
22
+ import { Command } from 'commander';
23
+ import { type SwapRow } from './lib/swap-core.js';
24
+ type Obj = Record<string, unknown>;
25
+ /** `--watch` polls every 5 s and stops after 360 polls (30 min) — then exits 2, still not final. */
26
+ export declare const WATCH_INTERVAL_MS = 5000;
27
+ export declare const WATCH_MAX_POLLS = 360;
28
+ export interface SwapDeps {
29
+ /** One receiver through the ask door; returns the resolver's own answer, or a named HTTP refusal. */
30
+ ask(receiver: string, data: Obj, opts?: {
31
+ anonymous?: boolean;
32
+ }): Promise<Obj>;
33
+ /** GET 1Click's own status record, directly — never through ONE. */
34
+ oneClick(url: string): Promise<{
35
+ ok: true;
36
+ body: unknown;
37
+ } | {
38
+ ok: false;
39
+ error: string;
40
+ status?: number;
41
+ }>;
42
+ now(): Date;
43
+ sleep(ms: number): Promise<void>;
44
+ /** A person at a TTY, not --json, not an agent shell: only then is a [y/N] asked. */
45
+ interactive: boolean;
46
+ confirm(question: string): Promise<boolean>;
47
+ /** Human lines (suppressed under --json by the caller). */
48
+ say(lines: string[]): void;
49
+ }
50
+ export interface Result {
51
+ data: Obj;
52
+ exitCode?: number;
53
+ }
54
+ export interface SwapArgs {
55
+ words: string[];
56
+ live?: boolean;
57
+ sendTo?: string;
58
+ exactOut?: boolean;
59
+ slippage?: string;
60
+ mine?: string;
61
+ }
62
+ export declare function runSwap(args: SwapArgs, deps: SwapDeps): Promise<Result>;
63
+ /** The --mine entries shaped like an address on this chain (several = the person must pick). */
64
+ export declare function mineOn(mine: readonly string[], chain: SwapRow['chain']): string[];
65
+ export interface StatusArgs {
66
+ depositAddress: string;
67
+ tx?: string;
68
+ watch?: boolean;
69
+ mine?: string;
70
+ /** The slippage you asked for when the address was minted (default 100); the record must match. */
71
+ slippage?: string;
72
+ /** The amount you asked to swap, in the from asset. The record must match it, or no send line (R18). */
73
+ amount?: string;
74
+ maxPolls?: number;
75
+ }
76
+ export declare function runStatus(args: StatusArgs, deps: SwapDeps): Promise<Result>;
77
+ /** The server's whole table, read from an `unknown_asset` refusal (R2 — no assets receiver). */
78
+ export declare function runAssets(deps: SwapDeps): Promise<Result>;
79
+ export interface HlArgs {
80
+ address?: string;
81
+ testnet?: boolean;
82
+ actor?: string;
83
+ }
84
+ export declare function runHlBalance(args: HlArgs, deps: SwapDeps): Promise<Result>;
85
+ /** Close the loop: out() for --json and the error head, the reason lines on stderr, the exit code last. */
86
+ export declare function emit(cmd: Command, res: Result): void;
87
+ interface Common {
88
+ api?: string;
89
+ key?: string;
90
+ }
91
+ export declare function swapCmd(deps?: (cmd: Command, o: Common) => SwapDeps): Command;
92
+ export declare function hlCmd(deps?: (cmd: Command, o: Common) => SwapDeps): Command;
93
+ export {};