oneie 5.7.3 → 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.
package/README.md CHANGED
@@ -193,6 +193,20 @@ one wallet keygen # mint a self-host
193
193
  one wallet paper # reprint the 24 words for paper — terminal only, same refusals as `one key new`
194
194
  ```
195
195
 
196
+ ### Swap — any coin, or straight into Hyperliquid
197
+
198
+ ```bash
199
+ one swap 0.01 BTC hl # price BTC into your Hyperliquid perps balance (dry — nothing minted)
200
+ one swap 10 USDC@base to hl --live # a real deposit address, read back from 1Click and checked first
201
+ one swap 25 SUI ETH --slippage 50 # SUI to ETH on ethereum, 0.5% max slippage
202
+ one swap 100 USDC@base hl --exact-out # receive exactly 100 USDC on Hyperliquid
203
+ one swap status <depositAddress> --watch # PENDING_DEPOSIT → PROCESSING → SUCCESS, with tx links
204
+ one swap assets # every alias, chain, decimals and who can sign it
205
+ one hl balance 0x… # Hyperliquid perps + spot (never summed); no address = your EVM wallet
206
+ ```
207
+
208
+ `swap` never signs and ONE never holds the coins: you send from your own wallet to a NEAR Intents 1Click deposit address. Quotes are dry until `--live`; a live quote is read back from 1Click directly and checked against what you typed (assets, amount, slippage, fees, recipient, refund address) before the CLI prints `Send exactly … before …` — any mismatch prints `quote_mismatch` and nothing to send. Every answer says `network: mainnet`: 1Click has no testnet, so a live deposit is real money. Pass `--mine <your addresses>` to require that delivery and refunds go to them — off a terminal (scripts, agents, `--json`) a live quote needs it, or it stops at `mine_required` before anything is minted. `one swap status <addr> --mine … --amount …` prints the send line again only when 1Click's record passes the same check against the amount you name (add `--slippage` if you minted with one); without `--amount` it says `amount_not_given` and prints nothing to send. Every fee shown comes from the live quote.
209
+
196
210
  `register` reads a `wallet keygen` output but transmits only its four address fields — the map it sends is built key-by-key from a fixed chain whitelist, so a `mnemonic` or `privateKey` in that file has no route onto the wire. The write is first-write-wins per chain and cannot be corrected afterwards (`address_conflict`), so it prints the addresses and asks for confirmation; `--yes` skips the prompt for scripted provisioning (needed when the JSON arrives on stdin, which leaves no terminal to answer with).
197
211
 
198
212
  `send` never signs — sign and broadcast the transfer yourself first (`agent-wallet-client.ts` for an agent, `/w` for a human), then pass the resulting transaction hash. The private key never crosses this command. `faucet` talks to `pay.one.ie` directly (its own protocol, not the `/ask` gateway) and needs no credential — funding any address is public by design, funding ≠ ownership.
package/dist/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "oneie",
3
- "version": "5.7.3",
3
+ "version": "5.7.5",
4
4
  "description": "ONE agent CLI",
5
5
  "type": "module",
6
6
  "bin": {
@@ -20,7 +20,7 @@
20
20
  },
21
21
  "dependencies": {
22
22
  "commander": "^12.0.0",
23
- "@oneie/sdk": "^0.17.0"
23
+ "@oneie/sdk": "^0.17.6"
24
24
  },
25
25
  "devDependencies": {
26
26
  "@oneie/evals": "^0.2.0",
@@ -10,7 +10,8 @@ export function displayBanner() {
10
10
  ██║ ██║██║╚██╗██║██╔══╝
11
11
  ╚██████╔╝██║ ╚████║███████╗
12
12
  ╚═════╝ ╚═╝ ╚═══╝╚══════╝
13
- Turn ideas into reality — https://one.ie
13
+ Give your agents financial superpowers.
14
+ https://one.ie
14
15
 
15
16
  `);
16
17
  }
package/dist/src/index.js CHANGED
@@ -19,6 +19,7 @@ import { evalCmd } from './eval.js';
19
19
  import { setupCmd } from './setup.js';
20
20
  import { clientCmd } from './client.js';
21
21
  import { walletCmd } from './wallet.js';
22
+ import { swapCmd, hlCmd } from './swap.js';
22
23
  import { keyCmd } from './key.js';
23
24
  import { secretsCmd } from './secrets.js';
24
25
  import { runCmd } from './secrets-run.js';
@@ -75,6 +76,8 @@ program.addCommand(doctorCmd());
75
76
  program.addCommand(whoamiCmd());
76
77
  program.addCommand(buildLoginCommand());
77
78
  program.addCommand(walletCmd());
79
+ program.addCommand(swapCmd());
80
+ program.addCommand(hlCmd());
78
81
  program.addCommand(keyCmd());
79
82
  program.addCommand(secretsCmd());
80
83
  program.addCommand(runCmd());
package/dist/src/init.js CHANGED
@@ -150,7 +150,7 @@ export function initCmd() {
150
150
  .option('--no-content', 'Skip generating a starter agent.md')
151
151
  .option('--api <url>', 'API base URL', DEFAULT_API)
152
152
  .option('--write-env', 'Also write ONE_API_KEY to .env.local in the current directory')
153
- .option('--dir <path>', 'Write the key into THIS project folder (.oneie/agent.key, 0600, gitignored) instead of the machine-wide ~/.config/one/key')
153
+ .option('--dir <path>', 'Write the key into THIS project folder (.one/agent.key, 0600, gitignored) instead of the machine-wide ~/.config/one/key')
154
154
  .option('--ttl-days <n>', 'Key lifetime in days (default 90, max 365)')
155
155
  .option('--no-wallet', 'Skip minting a local wallet and registering its addresses')
156
156
  .option('--yes-i-accept-plaintext-file', 'Write the new wallet as a 0600 PLAINTEXT file instead of sealing it with a passphrase — needed for a non-interactive run')
package/dist/src/join.js CHANGED
@@ -21,7 +21,7 @@ export function bareDoors(agent) {
21
21
  ' oneie onboard # provision + walk the lifecycle stages\n'
22
22
  : ' npx oneie create <name> # scaffold a new group\n';
23
23
  return ('new group:\n' +
24
- ' npx oneie [--email <owner>] # key → products → test sale → handover link\n' +
24
+ ' npx oneie [--email <owner>] # your key, a product, a test sale, then one link to hand it over\n' +
25
25
  newGroup +
26
26
  'existing group:\n' +
27
27
  ' oneie login # become someone — no new group\n' +
@@ -0,0 +1,33 @@
1
+ /**
2
+ * What bare `npx oneie` SAYS to a person — the words only. The walk itself is
3
+ * `journey.ts`, and its JourneyReport is the `--json` contract an agent reads;
4
+ * nothing here changes it. This file turns that report into the home page's
5
+ * journey (one.ie, `lib/home/home-copy.ts`) told in plain English, step by step.
6
+ *
7
+ * Four steps, not nine: the CLI walks key (with keep + wallets folded in),
8
+ * make, practise and hand over. Sign in and send happen after, in the browser.
9
+ *
10
+ * COPY LAW (text/home-text.md § 0), held here too:
11
+ * - the 24 words are never printed; `wallet paper` in the person's own terminal
12
+ * - the test sale is a TEST CARD (Stripe test mode), never "Sui testnet"
13
+ * - the owner link is a bearer credential: once, 7 days, send it to one person
14
+ * - every printed command exists, spelled through `cliPrefix()` so it runs as printed
15
+ */
16
+ import type { JourneyReport } from './journey.js';
17
+ /** A box around a title — plain characters, so it reads the same in a terminal and in Claude Code. */
18
+ export declare function box(lines: string[]): string[];
19
+ /** Shown before a first run: what is about to happen, so nothing pops up unannounced. */
20
+ export declare function journeyIntro(cli: string): string;
21
+ /** Shown before a re-run. */
22
+ export declare function journeyResume(workspace: string): string;
23
+ /** The whole report, in words. */
24
+ export declare function journeyWords(r: JourneyReport, cli: string, opts?: {
25
+ agent?: string;
26
+ }): string;
27
+ /**
28
+ * What the person can do now, each move twice: the words to say to Claude, and the
29
+ * command it runs. Every command exists in this CLI and works from this folder (the
30
+ * key and the group are read from .one/). Sending is the one move the CLI does not
31
+ * sign, so it is told as the screen that does, never as a command.
32
+ */
33
+ export declare function superpowers(r: JourneyReport, cli: string): string[];
@@ -0,0 +1,221 @@
1
+ const STEPS = [
2
+ { step: 'key', title: 'Your key', line: 'Your agent makes its own key on this machine, and its wallets.',
3
+ why: 'Whoever holds the key holds the money. Here that is this machine, not ONE.' },
4
+ { step: 'products', title: 'Your product', line: 'It opens a shop and makes a product with its own checkout page.',
5
+ why: 'A checkout page is how anyone, a person or an agent, pays you.' },
6
+ { step: 'sale', title: 'A test sale', line: 'You buy it once with a test card. No real money moves.',
7
+ why: 'You rehearse the whole sale before real money is ever at stake.' },
8
+ { step: 'handover', title: 'Hand over', line: 'It gives you one link. Open it, and the shop is yours.',
9
+ why: 'The agent does the work. A person owns what it built.' },
10
+ ];
11
+ const MARK = { done: '✓', pending: '…', waiting: '·', failed: '✗' };
12
+ /** The chains in the home page's order, whatever key the server named them by. */
13
+ const CHAINS = [
14
+ { label: 'Sui', keys: ['sui'] },
15
+ { label: 'EVM', keys: ['evm', 'eth', 'ethereum'], note: 'Ethereum, Base and the other EVM networks' },
16
+ { label: 'Solana', keys: ['sol', 'solana'] },
17
+ { label: 'Bitcoin', keys: ['btc', 'bitcoin'] },
18
+ { label: 'ASI', keys: ['asi', 'fet', 'fetch'] },
19
+ ];
20
+ /** `npx oneie` in a sentence becomes whatever this process was started as. */
21
+ const spell = (text, cli) => text.replaceAll('npx oneie', cli);
22
+ const indent = (lines, by = ' ') => lines.map((l) => (l ? by + l : l));
23
+ /** A box around a title — plain characters, so it reads the same in a terminal and in Claude Code. */
24
+ export function box(lines) {
25
+ const w = Math.max(...lines.map((l) => [...l].length));
26
+ return ['╭' + '─'.repeat(w + 4) + '╮', ...lines.map((l) => `│ ${l}${' '.repeat(w - [...l].length)} │`), '╰' + '─'.repeat(w + 4) + '╯'];
27
+ }
28
+ const HEADER = box(['ONE · Give your agents financial superpowers', 'A key, wallets, a shop and a first sale, from this folder.']);
29
+ /** Shown before a first run: what is about to happen, so nothing pops up unannounced. */
30
+ export function journeyIntro(cli) {
31
+ const width = Math.max(...STEPS.map((s) => s.title.length));
32
+ return [
33
+ ...HEADER,
34
+ '',
35
+ 'Here is the path. Four steps, and each one is checked before the next starts.',
36
+ '',
37
+ ...STEPS.map((s, i) => ` ${i + 1}. ${s.title.padEnd(width)} ${s.line}`),
38
+ '',
39
+ 'You are in control. Nothing here moves real money, and nothing secret is printed.',
40
+ `Stop at any step. Run ${cli} again and it picks up where it left off.`,
41
+ '',
42
+ ].join('\n') + '\n';
43
+ }
44
+ /** Shown before a re-run. */
45
+ export function journeyResume(workspace) {
46
+ return [...HEADER, '', `Picking up where you left off, for ${workspace}.`, '', ''].join('\n');
47
+ }
48
+ function addressLines(addresses) {
49
+ const seen = new Set();
50
+ const rows = [];
51
+ for (const c of CHAINS) {
52
+ const k = c.keys.find((key) => typeof addresses[key] === 'string' && addresses[key]);
53
+ if (!k)
54
+ continue;
55
+ seen.add(k);
56
+ rows.push([c.label, addresses[k], c.note]);
57
+ }
58
+ for (const [k, v] of Object.entries(addresses))
59
+ if (!seen.has(k) && v)
60
+ rows.push([k, v]);
61
+ const w = Math.max(0, ...rows.map((r) => r[0].length));
62
+ return rows.map(([label, addr, note]) => ` ${label.padEnd(w)} ${addr}${note ? ` (${note})` : ''}`);
63
+ }
64
+ function failed(s, cli) {
65
+ const out = ['This step stopped.'];
66
+ if (s.detail.error)
67
+ out.push(`Why: ${spell(String(s.detail.error), cli)}`);
68
+ if (s.detail.fix)
69
+ out.push(`To fix it: ${spell(String(s.detail.fix), cli)}`);
70
+ if (s.detail.workspace)
71
+ out.push(`Your group: ${String(s.detail.workspace)}`);
72
+ return out;
73
+ }
74
+ function keyLines(s, cli) {
75
+ if (s.status === 'failed')
76
+ return failed(s, cli);
77
+ const d = s.detail;
78
+ const addresses = (d.addresses && typeof d.addresses === 'object' ? d.addresses : {});
79
+ const n = Object.keys(addresses).length;
80
+ const keychain = String(d.sealed ?? '').startsWith('Apple');
81
+ if (s.reused) {
82
+ // A re-run: the key was told in full the first time. Say it is still here, and how it opens.
83
+ const chains = CHAINS.filter((c) => c.keys.some((k) => addresses[k])).map((c) => c.label);
84
+ return [
85
+ `Your agent's key is still here, ${keychain ? 'in your Apple Keychain. Touch ID opens it' : 'locked with your passphrase'}.`,
86
+ ...(chains.length ? [`Wallets on ${chains.length > 1 ? `${chains.slice(0, -1).join(', ')} and ${chains.at(-1)}` : chains[0]}.`] : []),
87
+ `Not on paper yet? Run ${cli} wallet paper in your own terminal.`,
88
+ ];
89
+ }
90
+ return [
91
+ 'Your agent made its own key, here on this machine. ONE never saw it.',
92
+ keychain ? 'It is locked in your Apple Keychain. Touch ID opens it.' : 'It is locked with the passphrase you chose.',
93
+ '',
94
+ n > 0
95
+ ? `One key, ${n === 1 ? 'one wallet' : `${n} wallets`}. Anyone can pay these addresses. Only your key can spend from them.`
96
+ : 'Your wallet is made.',
97
+ ...addressLines(addresses),
98
+ '',
99
+ 'Now keep it. Write the 24 words on paper. Run this in your own terminal:',
100
+ ` ${cli} wallet paper`,
101
+ 'The words are never printed here. Lose every copy and ONE cannot bring them back.',
102
+ '',
103
+ `Your group: ${String(d.workspace ?? '')}`,
104
+ ];
105
+ }
106
+ function productLines(s, cli) {
107
+ if (s.status === 'failed')
108
+ return failed(s, cli);
109
+ const products = Array.isArray(s.detail.products) ? s.detail.products.map(String) : [];
110
+ return [
111
+ 'Your shop is open, in test mode. Each product has its own checkout page:',
112
+ ...products.map((p) => {
113
+ // "Name 1.00 USD https://…" — drawn as columns; anything else prints as it came.
114
+ const m = /^(.*) (\d+\.\d{2}) ([A-Z]{3}) (\S+)$/.exec(p);
115
+ return m ? ` ${m[1]} ${m[2]} ${m[3]} ${m[4]}` : ` ${p}`;
116
+ }),
117
+ ];
118
+ }
119
+ function saleLines(s, cli) {
120
+ if (s.status === 'failed')
121
+ return failed(s, cli);
122
+ if (s.status === 'done') {
123
+ const n = Number(s.detail.purchases ?? 1);
124
+ return [`${n === 1 ? 'One sale' : `${n} sales`} counted, read back from your shop. Test money: nothing real moved.`];
125
+ }
126
+ const [number, ...rest] = String(s.detail.card ?? '').split(' · ');
127
+ return [
128
+ 'Nothing sold yet. Make the first sale yourself, with test money:',
129
+ '',
130
+ ` 1. Open this page ${String(s.detail.pay ?? '')}`,
131
+ ` 2. Pay with test card ${number}`,
132
+ ...(rest.length ? [` ${rest.join(', ')}`] : []),
133
+ ` 3. Then come back, run ${cli}`,
134
+ '',
135
+ 'No real card is charged. The sale counts only once your shop reads it back.',
136
+ ];
137
+ }
138
+ function handoverLines(s, cli) {
139
+ if (s.status === 'failed')
140
+ return failed(s, cli);
141
+ if (s.status === 'waiting')
142
+ return ['This waits for the test sale. Once it is counted, your link appears here.'];
143
+ return [
144
+ 'Your agent built it. Now it is yours to take.',
145
+ 'Open this link, make your own key in the browser, and press Accept:',
146
+ ` ${String(s.detail.link ?? '')}`,
147
+ ...(s.detail.emailed ? [`We also sent it to ${String(s.detail.emailed)}.`] : []),
148
+ '',
149
+ 'Keep it private. Anyone with this link can claim the owner seat.',
150
+ 'It works once and lasts 7 days. Sales stay on test money until you take the shop live.',
151
+ ];
152
+ }
153
+ const LINES = {
154
+ key: keyLines, products: productLines, sale: saleLines, handover: handoverLines,
155
+ };
156
+ /** The whole report, in words. */
157
+ export function journeyWords(r, cli, opts = {}) {
158
+ const out = [];
159
+ r.steps.forEach((s) => {
160
+ const n = STEPS.findIndex((x) => x.step === s.step);
161
+ const title = STEPS[n]?.title ?? s.step;
162
+ const tag = s.reused && s.status === 'done' ? ' (done on an earlier run)' : '';
163
+ out.push(`${MARK[s.status] ?? '?'} ${n + 1} of ${STEPS.length} ${title}${tag}`);
164
+ if (STEPS[n] && !s.reused && s.status !== 'failed')
165
+ out.push(` Why it matters: ${STEPS[n].why}`, '');
166
+ out.push(...indent((LINES[s.step] ?? ((x) => failed(x, cli)))(s, cli)), '');
167
+ });
168
+ // Steps never reached (an early stop) still show, so the person sees the whole path.
169
+ for (let i = r.steps.length; i < STEPS.length; i++) {
170
+ out.push(`· ${i + 1} of ${STEPS.length} ${STEPS[i].title}`, ` Not started. ${STEPS[i].line}`, '');
171
+ }
172
+ const panel = superpowers(r, cli);
173
+ if (panel.length)
174
+ out.push(...panel, '');
175
+ // The one thing to do now goes last, under everything, where the eye lands.
176
+ const allDone = r.ok && r.steps.length === STEPS.length && r.steps.every((s) => s.status === 'done');
177
+ if (allDone) {
178
+ out.push('Done. Your agent has a key, a shop and a first test sale, and you hold the link that makes it yours.');
179
+ }
180
+ else if (r.next) {
181
+ const next = spell(r.next, cli).replaceAll('`', '');
182
+ out.push(`Next: ${next.charAt(0).toUpperCase()}${next.slice(1)}`);
183
+ }
184
+ if (opts.agent === 'claude-code') {
185
+ out.push('', '(Claude: offer the person these moves as choices and run the one they pick. The 24 words are theirs to write down in their own terminal. Never ask for them.)');
186
+ }
187
+ return out.join('\n') + '\n';
188
+ }
189
+ /**
190
+ * What the person can do now, each move twice: the words to say to Claude, and the
191
+ * command it runs. Every command exists in this CLI and works from this folder (the
192
+ * key and the group are read from .one/). Sending is the one move the CLI does not
193
+ * sign, so it is told as the screen that does, never as a command.
194
+ */
195
+ export function superpowers(r, cli) {
196
+ const key = r.steps.find((s) => s.step === 'key');
197
+ if (!key || key.status !== 'done')
198
+ return [];
199
+ const addresses = (key.detail.addresses ?? {});
200
+ const sui = addresses.sui ?? '<your Sui address>';
201
+ const moves = [
202
+ { what: 'See your balances', say: 'show my balances', run: `${cli} wallet get` },
203
+ { what: 'Get free test coins', say: 'fill my wallet with test coins', run: `${cli} wallet faucet ${sui} --chain sui --network testnet` },
204
+ { what: 'Sell something new', say: 'sell a mug for $12.50', run: `${cli} --product "Mug=12.50"` },
205
+ { what: 'See what came in', say: 'what payments came in?', run: `${cli} wallet transactions` },
206
+ { what: 'Ask ONE anything', say: 'how do I get paid in USDC?', run: `${cli} message "how do I get paid in USDC?"` },
207
+ ];
208
+ const w = Math.max(...moves.map((m) => m.what.length));
209
+ const pad = ' '.repeat(w + 4);
210
+ return [
211
+ ...box(['Your superpowers', 'Say it to Claude, or run it yourself. Every one is real.']),
212
+ '',
213
+ ...moves.flatMap((m) => [` ${m.what.padEnd(w)} "${m.say}"`, `${pad}${m.run}`, '']),
214
+ ` ${'Send money'.padEnd(w)} "how do I send USDC?"`,
215
+ `${pad}Once you own it: https://one.ie/wallets, press Send.`,
216
+ `${pad}Your key signs on your device. Stablecoins wallet to wallet on Sui:`,
217
+ `${pad}ONE takes no fee. Sui charges its own small network fee, paid in SUI.`,
218
+ '',
219
+ ` Every command: ${cli} --help`,
220
+ ];
221
+ }
@@ -225,12 +225,12 @@ export async function runJourney(deps, o) {
225
225
  const k = await keyStep(deps, o, deps.load());
226
226
  steps.push(k.report);
227
227
  if (!k.state || !k.key)
228
- return { ok: false, steps, next: 'fix the key step and run `npx oneie` again' };
228
+ return { ok: false, steps, next: 'fix what stopped the key step above, then run `npx oneie` again' };
229
229
  const state = k.state;
230
230
  const products = await productsStep(deps, o, state, k.key);
231
231
  steps.push(products);
232
232
  if (products.status !== 'done') {
233
- return { ok: false, workspace: state.workspace, steps, next: 'fix the products step and run `npx oneie` again' };
233
+ return { ok: false, workspace: state.workspace, steps, next: 'fix what stopped the product step above, then run `npx oneie` again' };
234
234
  }
235
235
  // A re-run: the shop already had its products before this run, so someone was sent to pay.
236
236
  const sale = await saleStep(deps, o, state, k.key, products.reused === true);
@@ -239,7 +239,7 @@ export async function runJourney(deps, o) {
239
239
  steps.push(handover);
240
240
  const failed = steps.some((s) => s.status === 'failed');
241
241
  const next = sale.status === 'pending'
242
- ? 'pay with the test card at the link above, then run `npx oneie` again — it waits for the sale to land (or `npx oneie --wait 30` to wait here now)'
242
+ ? 'pay with the test card at the link above, then run `npx oneie` again. It waits a few seconds for the sale to land. Or run `npx oneie --wait 30` to wait here while you pay'
243
243
  : undefined;
244
244
  return { ok: !failed, workspace: state.workspace, steps, ...(next ? { next } : {}) };
245
245
  }
@@ -0,0 +1,163 @@
1
+ /**
2
+ * swap-core — the pure half of `one swap` (text/swap-plan.md § CLI).
3
+ *
4
+ * The CLI cannot import one.ie/web code and must not import a new @oneie/sdk export
5
+ * (R2: packages/cli/node_modules resolves another tree's SDK, so a new subpath would pass
6
+ * hollow). So the four things the client check needs are ported here, verbatim in behaviour,
7
+ * and tests/swap-parity.test.ts runs them against the web originals so the copy cannot drift:
8
+ *
9
+ * SWAP_TABLE + resolveAlias ← one.ie/web/src/lib/swap/assets.ts (SWAP_ASSETS, resolveAsset)
10
+ * parseUnits + formatUnits ← one.ie/web/src/lib/units.ts
11
+ * checkQuote ← one.ie/web/src/lib/swap/core.ts (R16, incl. 3fef1b14c fields)
12
+ * sendUri ← one.ie/web/src/lib/swap/core.ts
13
+ *
14
+ * Nothing here touches the network, and nothing here ever signs. No Number cast touches an amount.
15
+ */
16
+ export type SwapChain = 'ethereum' | 'base' | 'arbitrum' | 'solana' | 'sui' | 'bitcoin' | 'hyperliquid';
17
+ export type SwapSigner = 'browser' | 'external' | 'none';
18
+ export interface SwapRow {
19
+ alias: string;
20
+ chain: SwapChain;
21
+ symbol: string;
22
+ assetId: string;
23
+ decimals: number;
24
+ contract: string | null;
25
+ signer: SwapSigner;
26
+ origin: boolean;
27
+ destination: boolean;
28
+ }
29
+ export declare const HL_USDC_ASSET_ID = "1cs_v1:hypercore:hip1:0x6d1e7cde53ba9467b783cb7c530ce054";
30
+ /** Copied from one.ie/web/src/lib/swap/assets.ts — tests/swap-parity.test.ts pins it row by row. */
31
+ export declare const SWAP_TABLE: readonly SwapRow[];
32
+ export type AliasResult = {
33
+ ok: true;
34
+ asset: SwapRow;
35
+ } | {
36
+ ok: false;
37
+ error: 'unknown_asset';
38
+ } | {
39
+ ok: false;
40
+ error: 'ambiguous_asset';
41
+ options: string[];
42
+ } | {
43
+ ok: false;
44
+ error: 'not_a_destination';
45
+ asset: SwapRow;
46
+ };
47
+ /** Same rules as the web resolveAsset — a parity test compares every alias both ways. */
48
+ export declare function resolveAlias(input: unknown, side: 'from' | 'to'): AliasResult;
49
+ export declare function rowById(assetId: unknown): SwapRow | undefined;
50
+ export declare function parseUnits(input: string, decimals: number): bigint | null;
51
+ export declare function formatUnits(value: bigint, decimals: number): string;
52
+ /** The one rule (plan § CLI): the amount is the token that looks like a plain decimal. */
53
+ export declare const AMOUNT_TOKEN: RegExp;
54
+ export type Words = {
55
+ ok: true;
56
+ amount: string;
57
+ from: string;
58
+ to: string;
59
+ } | {
60
+ ok: false;
61
+ error: 'bad_amount' | 'usage';
62
+ next: string;
63
+ };
64
+ /**
65
+ * `one swap 0.01 BTC hl` = `one swap 0.01 BTC to hl` = `one swap BTC hl 0.01`.
66
+ * Exactly one plain-decimal amount (nonzero), a literal `to` dropped, two asset words left
67
+ * in order (from, to). `1e3`, `0x10`, `-1`, `.5` and `0` are refused here, before any call.
68
+ */
69
+ export declare function parseSwapWords(words: readonly string[]): Words;
70
+ /** --slippage <bps>: an integer 1..500, read by regex and parseInt, never a Number cast. */
71
+ export declare function parseSlippage(s: string | undefined): {
72
+ ok: true;
73
+ bps?: number;
74
+ } | {
75
+ ok: false;
76
+ };
77
+ /** --mine a,b,c → the caller's own addresses, as typed. */
78
+ export declare function parseMine(s: string | undefined): string[];
79
+ export declare const ONECLICK = "https://1click.chaindefuser.com";
80
+ export declare const ONECLICK_PROTOCOL_RECIPIENT = "5880ad2b362620fadf759cbceb1cd5737ce8c6ed7fb8e9942881e6731f9247dd";
81
+ export declare const DEFAULT_SLIPPAGE_BPS = 100;
82
+ /** ONE's app fee, pinned in client code (null = none, so any non-1Click fee row fails). Same as core.ts. */
83
+ export declare const ONE_APP_FEE: {
84
+ recipient: string;
85
+ bps: number;
86
+ } | null;
87
+ /** Cap on summed 1Click protocol rows — measured 0/1/20 bps over 74 keyless routes (max 20), 25 = the documented no-key 0.25%. Same as core.ts. */
88
+ export declare const PROTOCOL_FEE_CAP_BPS = 25;
89
+ /** 1Click's own status URL for a deposit address — a fixed host, the address in URLSearchParams. */
90
+ export declare function oneClickStatusUrl(depositAddress: string): string;
91
+ export declare function depositAddressFits(addr: unknown): addr is string;
92
+ export declare const HL_ADDRESS: RegExp;
93
+ export interface MyQuoteValues {
94
+ depositAddress: string;
95
+ recipient: string;
96
+ refundTo: string;
97
+ originAsset: string;
98
+ destinationAsset: string;
99
+ exact: 'in' | 'out';
100
+ amountBase: string;
101
+ maxAmountInBase?: string;
102
+ slippageBps?: number;
103
+ appFeeCapBps?: number;
104
+ appFeeRecipient?: string;
105
+ protocolFeeCapBps?: number;
106
+ }
107
+ export type CheckField = 'stored' | 'depositAddress' | 'recipient' | 'refundTo' | 'originAsset' | 'destinationAsset' | 'depositType' | 'depositMode' | 'memo' | 'swapType' | 'amount' | 'amountIn' | 'refundType' | 'recipientType' | 'slippageTolerance' | 'appFees';
108
+ export type CheckResult = {
109
+ ok: true;
110
+ } | {
111
+ ok: false;
112
+ error: 'quote_mismatch';
113
+ field: CheckField;
114
+ };
115
+ type Obj = Record<string, unknown>;
116
+ export declare function sameAddress(a: unknown, b: unknown): boolean;
117
+ export declare function checkQuote(stored: unknown, mine: MyQuoteValues): CheckResult;
118
+ /** What 1Click itself recorded for a deposit address — read straight out of its status body. */
119
+ export interface StoredRecord {
120
+ recipient?: string;
121
+ refundTo?: string;
122
+ originAsset?: string;
123
+ destinationAsset?: string;
124
+ amountInBase?: string;
125
+ amountOutBase?: string;
126
+ minAmountOutBase?: string;
127
+ /** quoteRequest.swapType and quoteRequest.amount — what the status door re-checks (R16). */
128
+ swapType?: string;
129
+ amountBase?: string;
130
+ refundAfter?: string;
131
+ addressExpires?: string;
132
+ quotedAt?: string;
133
+ status?: string;
134
+ }
135
+ export declare function storedRecord(body: unknown): StoredRecord;
136
+ /** Never print a send line inside the last five minutes before refunds begin. */
137
+ export declare const SEND_MARGIN_MS: number;
138
+ /**
139
+ * Is there still time to send? `quotedAt` (1Click's clock) corrects this machine's skew:
140
+ * skew = localNowAtQuote − quotedAt; 1Click's now ≈ localNow − skew.
141
+ */
142
+ export declare function stillSendable(refundAfter: string | undefined, now: Date, skewMs?: number): boolean;
143
+ export declare function sendUri(asset: SwapRow, to: string, amountBase: bigint): string | undefined;
144
+ /**
145
+ * The page origin a link points at. The server's own link is only trusted for its ORIGIN, and
146
+ * only when that origin is https://one.ie or localhost — a gateway call can come back as
147
+ * https://api.one.ie/swap, which is no page. The query is always built here, never copied.
148
+ */
149
+ export declare function pageOrigin(serverLink: unknown): string;
150
+ export declare function swapLink(origin: string, q: {
151
+ from: string;
152
+ to: string;
153
+ amount: string;
154
+ exact?: 'in' | 'out';
155
+ }): string;
156
+ export declare function depositLink(origin: string, depositAddress: string): string;
157
+ /** The quote, one fact per line. `network: mainnet` is always the first line. */
158
+ export declare function quoteLines(r: Obj): string[];
159
+ export declare function statusLines(r: Obj): string[];
160
+ /** Perps and spot, side by side — never summed (unified accounts show everything in spot). */
161
+ export declare function hlLines(h: Obj): string[];
162
+ export declare function assetLines(assets: readonly Obj[]): string[];
163
+ export {};