@ftptech/canton-agent-wallet 1.2.0 → 1.3.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/dist/swap.d.ts ADDED
@@ -0,0 +1,205 @@
1
+ /**
2
+ * swap — a self-custody swap primitive over Tradecraft (an AMM DEX on Canton).
3
+ * A Tradecraft swap is just an on-ledger transfer of the input token to a
4
+ * per-pair pool party (`tc-swp_{IN}-{OUT}::<amm_cid>`); the pool sends the
5
+ * counter-asset back within a minute or two, as a transfer OFFER when the output
6
+ * is not pre-approved (which `claimAll` accepts) or DIRECTLY when it is.
7
+ *
8
+ * SAFETY MODEL (what actually holds):
9
+ * - The recipient is ALWAYS a pool party derived from a trusted `amm_cid`
10
+ * (config/constant), never a client- or 402-supplied address. This is the one
11
+ * unconditional guarantee.
12
+ * - Slippage protection is OPTIONAL: Tradecraft reads the minimum from the
13
+ * transfer's memo field, so it is attached only when a memo key is configured
14
+ * (`ticket.memoKey`, from CANTON_AGENT_TRADECRAFT_MEMO_KEY). With NO key the
15
+ * swap fills at MARKET price — the proven bare flow — and `swap` warns.
16
+ * - Output preapproval is ON by default (`--no-preapprove` opts out), because a
17
+ * Tradecraft pool delivers a registry output only to a PREAPPROVED receiver.
18
+ * Tradecraft's docs note the hazard that on a DIRECT settlement an
19
+ * un-preapproved output can be "consumed on fill with no funds returned",
20
+ * which is exactly what the auto-provisioned preapproval prevents. An
21
+ * unfilled trade returns
22
+ * the input either way.
23
+ */
24
+ import { RelayClient } from "./relay-client.js";
25
+ import { type AgentWallet } from "./store.js";
26
+ import type { HashBindingOptions } from "./verify-prepared.js";
27
+ /** A registry instrument, or `null` for native Canton Coin. */
28
+ export type SwapInstrument = {
29
+ admin: string;
30
+ id: string;
31
+ } | null;
32
+ /** Everything needed to execute one swap, resolved up front (locally, or by the
33
+ * facilitator /swap fee-ticket which knows the network's registrars). */
34
+ export interface SwapTicket {
35
+ /** The pool party to send the input to: `tc-swp_{IN}-{OUT}::<amm_cid>`. */
36
+ poolParty: string;
37
+ /** Slippage-protected minimum output, as a ledger decimal string. Always
38
+ * computed for display; only ENFORCED when `memoKey` is set (see below). */
39
+ minOutput: string;
40
+ /** The transfer-meta key Tradecraft reads the minimum from ("the memo field").
41
+ * When set, the minimum is attached to the input transfer and the pool honors
42
+ * it (below-minimum → the trade fails and the input returns). When UNDEFINED,
43
+ * the swap executes at market price with no slippage protection — exactly the
44
+ * bare "send to the pool" flow, which works. Tradecraft's docs: the minimum is
45
+ * the first text in the memo field, a decimal with ≤10 places. */
46
+ memoKey?: string;
47
+ /** The raw quote (estimated output) that produced `minOutput`. */
48
+ quote: string;
49
+ /** The instrument being sent in (null = CC). */
50
+ inInstrument: SwapInstrument;
51
+ /** The instrument expected back (null = CC). */
52
+ outInstrument: SwapInstrument;
53
+ }
54
+ /** Per-input-token advisory minimums, mirrored from the Tradecraft web app (there
55
+ * is NO API endpoint for these — they are a hardcoded frontend constant). A trade
56
+ * below the minimum is ADVISORY only: the pool safely returns the funds if it will
57
+ * not fill (no loss), and amounts slightly under still often fill. `swap` warns
58
+ * when the amount is under the listed minimum but does not block. Symbols not
59
+ * listed have no advertised minimum. */
60
+ export declare const TRADECRAFT_MIN_INPUT: Readonly<Record<string, number>>;
61
+ /** The advisory minimum input for `symbol` (canonical), or undefined if none is
62
+ * advertised. Case-sensitive on the canonical symbol. */
63
+ export declare function tradecraftMinInput(symbol: string): number | undefined;
64
+ /** Derive the Tradecraft pool party for a pair: `tc-swp_{TOKEN1}-{TOKEN2}::<ammCid>`.
65
+ * `token1`/`token2` MUST be in the pool's CANONICAL order (as listed by /pools),
66
+ * NOT the swap direction: Tradecraft has one pool party per pair that accepts
67
+ * either token and returns the other, so `tc-swp_CC-USDCx` serves both CC→USDCx
68
+ * and USDCx→CC. Deriving from the swap direction (`{in}-{out}`) yields a
69
+ * non-existent party for one of the two directions. The amm_cid is a single
70
+ * AMM-rules contract shared by every pair. Pure. */
71
+ export declare function derivePoolParty(token1: string, token2: string, ammCid: string): string;
72
+ /** One pool row from Tradecraft `/v1/pools`, reduced to what a swap needs: the
73
+ * pair in the pool party's CANONICAL order. That order is the one in
74
+ * `lp_token_name` ("TC {TOKEN1}-{TOKEN2} LP"), which is what the on-ledger pool
75
+ * party `tc-swp_{TOKEN1}-{TOKEN2}::<ammCid>` uses — NOT the row's `token1`/`token2`
76
+ * fields, which are ordered differently for 9 of 34 live pools (e.g. the CBTC/CC
77
+ * pool lists token1=CC,token2=CBTC but its party and LP name are CBTC-CC). */
78
+ export interface TradecraftPool {
79
+ /** First symbol of the pool party, from lp_token_name. */
80
+ token1: string;
81
+ /** Second symbol of the pool party, from lp_token_name. */
82
+ token2: string;
83
+ }
84
+ /** Parse `/v1/pools` into rows carrying each pool's CANONICAL pair order (from
85
+ * `lp_token_name`, falling back to `token1`/`token2`). Tolerates a bare array or
86
+ * `{pools:[…]}`. Exported for unit testing. */
87
+ export declare function parseTradecraftPools(body: unknown): TradecraftPool[];
88
+ /** Find the pool whose pair equals {a, b} (case-insensitive, unordered) and
89
+ * return its CANONICAL token order (the pool party's order). Throws when no such
90
+ * pool exists — exactly the "send to a non-existent pool party" mistake we must
91
+ * not make. Exported for unit testing. */
92
+ export declare function resolvePoolPair(pools: TradecraftPool[], a: string, b: string): {
93
+ token1: string;
94
+ token2: string;
95
+ };
96
+ /** Slippage-protected minimum output: `quote * (1 - slippagePct/100)`, floored to
97
+ * 10 decimals (every DA-Utility instrument and Canton Coin use 10). Floored, not
98
+ * rounded — the minimum must never sit ABOVE the true floor, or an honest fill
99
+ * could be rejected. `slippagePct` must be in [0, 100). Pure. */
100
+ export declare function computeMinOutput(quote: number, slippagePct: number): string;
101
+ /** Parse Tradecraft's `/v1/quoteForFixedInput/{IN}/{OUT}?givingAmount=N` →
102
+ * `{ user_gets: number }`. Exported for unit testing the shape. */
103
+ export declare function parseTradecraftQuote(body: unknown): number;
104
+ /** Fetch a live quote from Tradecraft's public REST and build a ticket locally
105
+ * (the `--no-fee` / test path). The fee path gets its ticket from the
106
+ * facilitator /swap endpoint instead. */
107
+ export declare function buildLocalTicket(opts: {
108
+ tradecraftApi: string;
109
+ ammCid: string;
110
+ /** The memo key that enforces the minimum; omit to swap at market. */
111
+ memoKey?: string;
112
+ inSymbol: string;
113
+ outSymbol: string;
114
+ amount: string;
115
+ slippagePct: number;
116
+ inInstrument: SwapInstrument;
117
+ outInstrument: SwapInstrument;
118
+ fetchImpl?: typeof globalThis.fetch;
119
+ }): Promise<SwapTicket>;
120
+ /** Parse a swap-endpoint ticket response into a SwapTicket, validating the fields
121
+ * the local execute path relies on. Extra fields (e.g. ammCid) are ignored. */
122
+ export declare function parseEndpointTicket(body: unknown): SwapTicket;
123
+ /**
124
+ * Validate an endpoint-returned ticket against LOCALLY-TRUSTED values before it is
125
+ * ever executed. The swap endpoint is UNTRUSTED for money safety: the ticket's
126
+ * `poolParty` becomes the transfer receiver and its instruments become the assets
127
+ * moved, and verify-before-sign only pins those to caller INTENT — so if intent
128
+ * came from the endpoint unchecked, a malicious/compromised endpoint could name an
129
+ * attacker party and drain the swap amount. We therefore pin, client-side:
130
+ * - `poolParty` MUST be `tc-swp_{A}-{B}::<trustedAmmCid>` for the two canonical
131
+ * symbols the caller chose (either pair order) — its namespace equals our own
132
+ * trusted amm_cid, which a hostile endpoint cannot forge, and its localpart is
133
+ * the Tradecraft pool naming for exactly this pair;
134
+ * - the in/out instruments MUST equal the ones the caller resolved locally from
135
+ * KNOWN_INSTRUMENTS.
136
+ * The endpoint is then trusted ONLY for the price/minimum (a bad one loses at most
137
+ * a bad fill, which returns the input) — never for where the funds go.
138
+ */
139
+ export declare function assertTicketMatchesIntent(ticket: SwapTicket, expect: {
140
+ inCanon: string;
141
+ outCanon: string;
142
+ inInstrument: SwapInstrument;
143
+ outInstrument: SwapInstrument;
144
+ trustedAmmCid: string;
145
+ }): void;
146
+ /** Fetch a swap ticket from OUR x402-gated `/swap` endpoint (the default path): the
147
+ * managed router that stays current with Tradecraft's pools/amm_cid/minimums and
148
+ * charges a small fee. `payingFetch` is a `makePayingFetch` result, so the 402 is
149
+ * paid automatically from the agent's wallet. The endpoint is UNTRUSTED for money
150
+ * safety — the returned ticket is validated against the caller's locally-trusted
151
+ * amm_cid + instruments (see assertTicketMatchesIntent) before it is returned, so
152
+ * a hostile endpoint can only give a bad price, never redirect funds. */
153
+ export declare function fetchTicketFromEndpoint(opts: {
154
+ swapUrl: string;
155
+ inSymbol: string;
156
+ outSymbol: string;
157
+ amount: string;
158
+ slippagePct: number;
159
+ payingFetch: typeof globalThis.fetch;
160
+ /** Locally-resolved input instrument (null = CC) the ticket MUST match. */
161
+ inInstrument: SwapInstrument;
162
+ /** Locally-resolved output instrument (null = CC) the ticket MUST match. */
163
+ outInstrument: SwapInstrument;
164
+ /** The caller's OWN trusted amm_cid the pool party MUST derive from. */
165
+ trustedAmmCid: string;
166
+ }): Promise<SwapTicket>;
167
+ export interface ExecuteSwapOpts {
168
+ amount: string;
169
+ ticket: SwapTicket;
170
+ apiKey?: string | undefined;
171
+ hashBinding?: HashBindingOptions;
172
+ wallet?: AgentWallet;
173
+ relay?: RelayClient;
174
+ /**
175
+ * Self-provision a TransferPreapproval for the OUTPUT instrument before sending
176
+ * the input, so the pool can deliver the counter-asset DIRECTLY. This is
177
+ * REQUIRED for a registry output: a Tradecraft pool holds no preapproval for the
178
+ * payer and does not create a return offer, so without our preapproval the pool
179
+ * keeps the swapped-out asset (the trade does not complete on our side). Defaults
180
+ * to ON for a registry output (`outInstrument` set) and is a no-op for a CC
181
+ * output (Amulet needs none). Set false only to skip it deliberately (e.g. the
182
+ * preapproval already exists, or a test).
183
+ */
184
+ preapproveOutput?: boolean;
185
+ /** Injectable sleep + poll bounds for the return-claim (tests). */
186
+ sleep?: (ms: number) => Promise<void>;
187
+ claimAttempts?: number;
188
+ claimIntervalMs?: number;
189
+ }
190
+ export interface SwapResult {
191
+ /** updateId of the input transfer we sent to the pool. */
192
+ sentUpdateId: string;
193
+ /** How many returning transfers we claimed (0 if the pool settled directly to
194
+ * our preapproval, or if it has not arrived within the poll window). */
195
+ claimed: number;
196
+ claimedUpdateIds: string[];
197
+ }
198
+ /**
199
+ * Execute a swap from a resolved ticket: (1) pre-approve the output instrument so
200
+ * the pool's return can never be a consumed-input-no-return loss, (2) send the
201
+ * input to the pool with the minimum in meta, (3) claim the returning transfer if
202
+ * it arrives as an offer rather than settling directly.
203
+ */
204
+ export declare function executeSwap(opts: ExecuteSwapOpts): Promise<SwapResult>;
205
+ //# sourceMappingURL=swap.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"swap.d.ts","sourceRoot":"","sources":["../src/swap.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAIhD,OAAO,EAAc,KAAK,WAAW,EAAE,MAAM,YAAY,CAAC;AAC1D,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAE/D,+DAA+D;AAC/D,MAAM,MAAM,cAAc,GAAG;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,EAAE,EAAE,MAAM,CAAA;CAAE,GAAG,IAAI,CAAC;AAElE;0EAC0E;AAC1E,MAAM,WAAW,UAAU;IACzB,2EAA2E;IAC3E,SAAS,EAAE,MAAM,CAAC;IAClB;iFAC6E;IAC7E,SAAS,EAAE,MAAM,CAAC;IAClB;;;;;uEAKmE;IACnE,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,kEAAkE;IAClE,KAAK,EAAE,MAAM,CAAC;IACd,gDAAgD;IAChD,YAAY,EAAE,cAAc,CAAC;IAC7B,gDAAgD;IAChD,aAAa,EAAE,cAAc,CAAC;CAC/B;AAID;;;;;yCAKyC;AACzC,eAAO,MAAM,oBAAoB,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAejE,CAAC;AAEF;0DAC0D;AAC1D,wBAAgB,kBAAkB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AC;IACvB,eAAe,CAAC,EAAE,MAAM,CAAC;CAC1B;AAED,MAAM,WAAW,UAAU;IACzB,0DAA0D;IAC1D,YAAY,EAAE,MAAM,CAAC;IACrB;6EACyE;IACzE,OAAO,EAAE,MAAM,CAAC;IAChB,gBAAgB,EAAE,MAAM,EAAE,CAAC;CAC5B;AAKD;;;;;GAKG;AACH,wBAAsB,WAAW,CAAC,IAAI,EAAE,eAAe,GAAG,OAAO,CAAC,UAAU,CAAC,CA2E5E"}
package/dist/swap.js ADDED
@@ -0,0 +1,361 @@
1
+ /**
2
+ * swap — a self-custody swap primitive over Tradecraft (an AMM DEX on Canton).
3
+ * A Tradecraft swap is just an on-ledger transfer of the input token to a
4
+ * per-pair pool party (`tc-swp_{IN}-{OUT}::<amm_cid>`); the pool sends the
5
+ * counter-asset back within a minute or two, as a transfer OFFER when the output
6
+ * is not pre-approved (which `claimAll` accepts) or DIRECTLY when it is.
7
+ *
8
+ * SAFETY MODEL (what actually holds):
9
+ * - The recipient is ALWAYS a pool party derived from a trusted `amm_cid`
10
+ * (config/constant), never a client- or 402-supplied address. This is the one
11
+ * unconditional guarantee.
12
+ * - Slippage protection is OPTIONAL: Tradecraft reads the minimum from the
13
+ * transfer's memo field, so it is attached only when a memo key is configured
14
+ * (`ticket.memoKey`, from CANTON_AGENT_TRADECRAFT_MEMO_KEY). With NO key the
15
+ * swap fills at MARKET price — the proven bare flow — and `swap` warns.
16
+ * - Output preapproval is ON by default (`--no-preapprove` opts out), because a
17
+ * Tradecraft pool delivers a registry output only to a PREAPPROVED receiver.
18
+ * Tradecraft's docs note the hazard that on a DIRECT settlement an
19
+ * un-preapproved output can be "consumed on fill with no funds returned",
20
+ * which is exactly what the auto-provisioned preapproval prevents. An
21
+ * unfilled trade returns
22
+ * the input either way.
23
+ */
24
+ import { RelayClient } from "./relay-client.js";
25
+ import { withdraw } from "./withdraw.js";
26
+ import { selfProvisionRegistryPreapproval, claimAll } from "./tx.js";
27
+ import { resolveHashBinding } from "./hash-binding.js";
28
+ import { loadWallet } from "./store.js";
29
+ const AMM_PAIR_SEP = "-";
30
+ /** Per-input-token advisory minimums, mirrored from the Tradecraft web app (there
31
+ * is NO API endpoint for these — they are a hardcoded frontend constant). A trade
32
+ * below the minimum is ADVISORY only: the pool safely returns the funds if it will
33
+ * not fill (no loss), and amounts slightly under still often fill. `swap` warns
34
+ * when the amount is under the listed minimum but does not block. Symbols not
35
+ * listed have no advertised minimum. */
36
+ export const TRADECRAFT_MIN_INPUT = {
37
+ CC: 6,
38
+ USDCx: 1,
39
+ USDXLR: 1,
40
+ cETH: 6e-4,
41
+ CBTC: 1.25e-5,
42
+ HANDL: 100,
43
+ EDELx: 75,
44
+ HECTO: 500,
45
+ "FRXUSD.B": 1,
46
+ eXAG: 0.017,
47
+ eXAU: 2.5e-4,
48
+ TRKXRWA: 0.015,
49
+ USDM1: 1,
50
+ USTY: 1,
51
+ };
52
+ /** The advisory minimum input for `symbol` (canonical), or undefined if none is
53
+ * advertised. Case-sensitive on the canonical symbol. */
54
+ export function tradecraftMinInput(symbol) {
55
+ return TRADECRAFT_MIN_INPUT[symbol];
56
+ }
57
+ /** Derive the Tradecraft pool party for a pair: `tc-swp_{TOKEN1}-{TOKEN2}::<ammCid>`.
58
+ * `token1`/`token2` MUST be in the pool's CANONICAL order (as listed by /pools),
59
+ * NOT the swap direction: Tradecraft has one pool party per pair that accepts
60
+ * either token and returns the other, so `tc-swp_CC-USDCx` serves both CC→USDCx
61
+ * and USDCx→CC. Deriving from the swap direction (`{in}-{out}`) yields a
62
+ * non-existent party for one of the two directions. The amm_cid is a single
63
+ * AMM-rules contract shared by every pair. Pure. */
64
+ export function derivePoolParty(token1, token2, ammCid) {
65
+ return `tc-swp_${token1}${AMM_PAIR_SEP}${token2}::${ammCid}`;
66
+ }
67
+ /** Parse the canonical pair order out of an `lp_token_name` like "TC CBTC/CC LP".
68
+ * Returns undefined when it does not match (caller falls back). */
69
+ function parseLpName(lp) {
70
+ if (typeof lp !== "string")
71
+ return undefined;
72
+ const m = lp.match(/^TC\s+(\S+)\/(\S+)\s+LP$/);
73
+ return m ? { token1: m[1], token2: m[2] } : undefined;
74
+ }
75
+ /** Parse `/v1/pools` into rows carrying each pool's CANONICAL pair order (from
76
+ * `lp_token_name`, falling back to `token1`/`token2`). Tolerates a bare array or
77
+ * `{pools:[…]}`. Exported for unit testing. */
78
+ export function parseTradecraftPools(body) {
79
+ const rows = Array.isArray(body)
80
+ ? body
81
+ : Array.isArray(body?.pools)
82
+ ? body.pools
83
+ : undefined;
84
+ if (!rows) {
85
+ throw new Error(`swap: unexpected Tradecraft /pools response ${JSON.stringify(body)}`);
86
+ }
87
+ const out = [];
88
+ for (const r of rows) {
89
+ const fromLp = parseLpName(r.lp_token_name);
90
+ if (fromLp) {
91
+ out.push(fromLp);
92
+ continue;
93
+ }
94
+ const t1 = r.token1;
95
+ const t2 = r.token2;
96
+ if (typeof t1 === "string" && typeof t2 === "string") {
97
+ out.push({ token1: t1, token2: t2 });
98
+ }
99
+ }
100
+ return out;
101
+ }
102
+ /** Find the pool whose pair equals {a, b} (case-insensitive, unordered) and
103
+ * return its CANONICAL token order (the pool party's order). Throws when no such
104
+ * pool exists — exactly the "send to a non-existent pool party" mistake we must
105
+ * not make. Exported for unit testing. */
106
+ export function resolvePoolPair(pools, a, b) {
107
+ const lo = a.toLowerCase();
108
+ const ro = b.toLowerCase();
109
+ for (const p of pools) {
110
+ const p1 = p.token1.toLowerCase();
111
+ const p2 = p.token2.toLowerCase();
112
+ if ((p1 === lo && p2 === ro) || (p1 === ro && p2 === lo)) {
113
+ return { token1: p.token1, token2: p.token2 };
114
+ }
115
+ }
116
+ throw new Error(`swap: no Tradecraft pool for the pair ${a}/${b} — check the symbols and that a pool exists`);
117
+ }
118
+ /** Slippage-protected minimum output: `quote * (1 - slippagePct/100)`, floored to
119
+ * 10 decimals (every DA-Utility instrument and Canton Coin use 10). Floored, not
120
+ * rounded — the minimum must never sit ABOVE the true floor, or an honest fill
121
+ * could be rejected. `slippagePct` must be in [0, 100). Pure. */
122
+ export function computeMinOutput(quote, slippagePct) {
123
+ if (!Number.isFinite(quote) || quote < 0) {
124
+ throw new Error(`swap: invalid quote ${JSON.stringify(quote)}`);
125
+ }
126
+ if (!Number.isFinite(slippagePct) || slippagePct < 0 || slippagePct >= 100) {
127
+ throw new Error(`swap: slippage must be a percentage in [0, 100) (got ${JSON.stringify(slippagePct)})`);
128
+ }
129
+ const min = quote * (1 - slippagePct / 100);
130
+ // Floor to 10 decimal places by STRING TRUNCATION, never a float ×1e10 (which
131
+ // re-introduces noise: 0.693 * 1e10 === 6929999999.999…). Snap to 12 fractional
132
+ // places to absorb binary-float noise (0.693 → "0.693000000000"), then keep the
133
+ // first 10 fractional digits. Truncating (not rounding) keeps the result at or
134
+ // below the true minimum, so an honest fill is never rejected.
135
+ const fixed = min.toFixed(12); // always "<whole>.<12 digits>"
136
+ const [whole, frac12] = fixed.split(".");
137
+ const frac = frac12.slice(0, 10).replace(/0+$/, "");
138
+ return frac.length > 0 ? `${whole}.${frac}` : whole;
139
+ }
140
+ /** Parse Tradecraft's `/v1/quoteForFixedInput/{IN}/{OUT}?givingAmount=N` →
141
+ * `{ user_gets: number }`. Exported for unit testing the shape. */
142
+ export function parseTradecraftQuote(body) {
143
+ if (typeof body !== "object" ||
144
+ body === null ||
145
+ typeof body.user_gets !== "number") {
146
+ throw new Error(`swap: unexpected Tradecraft quote response ${JSON.stringify(body)}`);
147
+ }
148
+ return body.user_gets;
149
+ }
150
+ /** Fetch a live quote from Tradecraft's public REST and build a ticket locally
151
+ * (the `--no-fee` / test path). The fee path gets its ticket from the
152
+ * facilitator /swap endpoint instead. */
153
+ export async function buildLocalTicket(opts) {
154
+ const f = opts.fetchImpl ?? globalThis.fetch;
155
+ const base = opts.tradecraftApi.replace(/\/$/, "");
156
+ // Tradecraft's edge (Cloudflare) 403s a request with no User-Agent — node's
157
+ // fetch sends none by default. A plain UA is enough.
158
+ const get = async (path) => {
159
+ const res = await f(`${base}${path}`, {
160
+ headers: { "user-agent": "canton-agent-wallet", accept: "application/json" },
161
+ });
162
+ if (!res.ok) {
163
+ throw new Error(`swap: Tradecraft GET ${path} failed (HTTP ${res.status})`);
164
+ }
165
+ return res.json();
166
+ };
167
+ // Resolve the pool's CANONICAL pair order from /pools so the pool party is
168
+ // correct for BOTH swap directions (one party per pair serves either way). This
169
+ // also validates the pool exists before we send any funds.
170
+ const pools = parseTradecraftPools(await get("/v1/pools"));
171
+ const { token1, token2 } = resolvePoolPair(pools, opts.inSymbol, opts.outSymbol);
172
+ // The quote IS directional: giving `inSymbol`, receiving `outSymbol`.
173
+ const userGets = parseTradecraftQuote(await get(`/v1/quoteForFixedInput/${encodeURIComponent(opts.inSymbol)}/` +
174
+ `${encodeURIComponent(opts.outSymbol)}?givingAmount=${encodeURIComponent(opts.amount)}`));
175
+ return {
176
+ poolParty: derivePoolParty(token1, token2, opts.ammCid),
177
+ minOutput: computeMinOutput(userGets, opts.slippagePct),
178
+ ...(opts.memoKey ? { memoKey: opts.memoKey } : {}),
179
+ quote: String(userGets),
180
+ inInstrument: opts.inInstrument,
181
+ outInstrument: opts.outInstrument,
182
+ };
183
+ }
184
+ /** Validate a value as a SwapInstrument ({admin,id} or null). */
185
+ function asSwapInstrument(v) {
186
+ if (v === null || v === undefined)
187
+ return null;
188
+ const o = v;
189
+ if (typeof o.admin === "string" && typeof o.id === "string") {
190
+ return { admin: o.admin, id: o.id };
191
+ }
192
+ throw new Error(`swap: endpoint returned a malformed instrument ${JSON.stringify(v)}`);
193
+ }
194
+ /** Parse a swap-endpoint ticket response into a SwapTicket, validating the fields
195
+ * the local execute path relies on. Extra fields (e.g. ammCid) are ignored. */
196
+ export function parseEndpointTicket(body) {
197
+ const b = body;
198
+ if (typeof b?.poolParty !== "string" ||
199
+ typeof b?.minOutput !== "string" ||
200
+ typeof b?.quote !== "string") {
201
+ throw new Error(`swap: malformed ticket from endpoint ${JSON.stringify(body)}`);
202
+ }
203
+ return {
204
+ poolParty: b.poolParty,
205
+ minOutput: b.minOutput,
206
+ ...(typeof b.memoKey === "string" ? { memoKey: b.memoKey } : {}),
207
+ quote: b.quote,
208
+ inInstrument: asSwapInstrument(b.inInstrument),
209
+ outInstrument: asSwapInstrument(b.outInstrument),
210
+ };
211
+ }
212
+ /** True when two SwapInstruments are the same (both null, or same admin+id). */
213
+ function sameInstrument(a, b) {
214
+ if (a === null || b === null)
215
+ return a === b;
216
+ return a.admin === b.admin && a.id === b.id;
217
+ }
218
+ /**
219
+ * Validate an endpoint-returned ticket against LOCALLY-TRUSTED values before it is
220
+ * ever executed. The swap endpoint is UNTRUSTED for money safety: the ticket's
221
+ * `poolParty` becomes the transfer receiver and its instruments become the assets
222
+ * moved, and verify-before-sign only pins those to caller INTENT — so if intent
223
+ * came from the endpoint unchecked, a malicious/compromised endpoint could name an
224
+ * attacker party and drain the swap amount. We therefore pin, client-side:
225
+ * - `poolParty` MUST be `tc-swp_{A}-{B}::<trustedAmmCid>` for the two canonical
226
+ * symbols the caller chose (either pair order) — its namespace equals our own
227
+ * trusted amm_cid, which a hostile endpoint cannot forge, and its localpart is
228
+ * the Tradecraft pool naming for exactly this pair;
229
+ * - the in/out instruments MUST equal the ones the caller resolved locally from
230
+ * KNOWN_INSTRUMENTS.
231
+ * The endpoint is then trusted ONLY for the price/minimum (a bad one loses at most
232
+ * a bad fill, which returns the input) — never for where the funds go.
233
+ */
234
+ export function assertTicketMatchesIntent(ticket, expect) {
235
+ const wantA = derivePoolParty(expect.inCanon, expect.outCanon, expect.trustedAmmCid);
236
+ const wantB = derivePoolParty(expect.outCanon, expect.inCanon, expect.trustedAmmCid);
237
+ if (ticket.poolParty !== wantA && ticket.poolParty !== wantB) {
238
+ throw new Error(`swap: endpoint returned pool party ${JSON.stringify(ticket.poolParty)} which is not the ` +
239
+ `trusted ${expect.inCanon}/${expect.outCanon} pool — refusing (a compromised endpoint ` +
240
+ `cannot redirect the swap: the pool must be tc-swp of this pair under our own amm_cid)`);
241
+ }
242
+ if (!sameInstrument(ticket.inInstrument, expect.inInstrument)) {
243
+ throw new Error(`swap: endpoint returned a different input instrument than requested — refusing`);
244
+ }
245
+ if (!sameInstrument(ticket.outInstrument, expect.outInstrument)) {
246
+ throw new Error(`swap: endpoint returned a different output instrument than requested — refusing`);
247
+ }
248
+ if (!/^\d+(\.\d+)?$/.test(ticket.minOutput)) {
249
+ throw new Error(`swap: endpoint returned a non-numeric minOutput ${JSON.stringify(ticket.minOutput)} — refusing`);
250
+ }
251
+ }
252
+ /** Fetch a swap ticket from OUR x402-gated `/swap` endpoint (the default path): the
253
+ * managed router that stays current with Tradecraft's pools/amm_cid/minimums and
254
+ * charges a small fee. `payingFetch` is a `makePayingFetch` result, so the 402 is
255
+ * paid automatically from the agent's wallet. The endpoint is UNTRUSTED for money
256
+ * safety — the returned ticket is validated against the caller's locally-trusted
257
+ * amm_cid + instruments (see assertTicketMatchesIntent) before it is returned, so
258
+ * a hostile endpoint can only give a bad price, never redirect funds. */
259
+ export async function fetchTicketFromEndpoint(opts) {
260
+ const base = opts.swapUrl.replace(/\/$/, "");
261
+ const url = `${base}/swap?in=${encodeURIComponent(opts.inSymbol)}` +
262
+ `&out=${encodeURIComponent(opts.outSymbol)}` +
263
+ `&amount=${encodeURIComponent(opts.amount)}` +
264
+ `&slippage=${encodeURIComponent(String(opts.slippagePct))}`;
265
+ const res = await opts.payingFetch(url);
266
+ if (!res.ok) {
267
+ const text = await res.text().catch(() => "");
268
+ throw new Error(`swap: endpoint ${base}/swap failed (HTTP ${res.status}) ${text.slice(0, 200)}`);
269
+ }
270
+ const ticket = parseEndpointTicket(await res.json());
271
+ assertTicketMatchesIntent(ticket, {
272
+ inCanon: opts.inSymbol,
273
+ outCanon: opts.outSymbol,
274
+ inInstrument: opts.inInstrument,
275
+ outInstrument: opts.outInstrument,
276
+ trustedAmmCid: opts.trustedAmmCid,
277
+ });
278
+ return ticket;
279
+ }
280
+ const defaultSleep = (ms) => new Promise((r) => setTimeout(r, ms));
281
+ /**
282
+ * Execute a swap from a resolved ticket: (1) pre-approve the output instrument so
283
+ * the pool's return can never be a consumed-input-no-return loss, (2) send the
284
+ * input to the pool with the minimum in meta, (3) claim the returning transfer if
285
+ * it arrives as an offer rather than settling directly.
286
+ */
287
+ export async function executeSwap(opts) {
288
+ const wallet = opts.wallet ?? loadWallet();
289
+ if (!wallet)
290
+ throw new Error("no wallet — run `create` first");
291
+ const relay = opts.relay ??
292
+ new RelayClient({ relayUrl: wallet.relayUrl, apiKey: opts.apiKey });
293
+ const hashBinding = opts.hashBinding ?? resolveHashBinding();
294
+ const { ticket } = opts;
295
+ // (1) OUTPUT PREAPPROVAL (direct settlement). REQUIRED for a registry output:
296
+ // the pool delivers the counter-asset only to a preapproved receiver, so without
297
+ // this the swapped-out asset never reaches us. Defaults ON for a registry output;
298
+ // a CC output needs none (native Amulet). Idempotent — skipped when one already
299
+ // exists. Opt out with preapproveOutput:false.
300
+ const wantPreapprove = opts.preapproveOutput ?? true;
301
+ if (wantPreapprove && ticket.outInstrument) {
302
+ const { admin, id } = ticket.outInstrument;
303
+ const status = await relay.preapprovalStatus(wallet.party, admin, id);
304
+ if (status.hasPreapproval !== true) {
305
+ await selfProvisionRegistryPreapproval(relay, wallet, {
306
+ instrumentId: { admin, id },
307
+ hashBinding,
308
+ });
309
+ }
310
+ }
311
+ // (2) SEND THE INPUT to the pool, carrying the slippage floor in the AMM's meta
312
+ // key. The ticket's pool party was derived from (or validated against, on the
313
+ // endpoint path via assertTicketMatchesIntent) the CALLER's trusted amm_cid, so
314
+ // it cannot have been redirected by an untrusted quote source.
315
+ const sent = await withdraw({
316
+ to: ticket.poolParty,
317
+ amount: opts.amount,
318
+ apiKey: opts.apiKey,
319
+ hashBinding,
320
+ // Attach the slippage floor ONLY when a memo key is configured; without it
321
+ // the swap executes at market price (the pool needs no meta to fill).
322
+ ...(ticket.memoKey ? { meta: { [ticket.memoKey]: ticket.minOutput } } : {}),
323
+ ...(ticket.inInstrument
324
+ ? {
325
+ instrumentAdmin: ticket.inInstrument.admin,
326
+ instrumentId: ticket.inInstrument.id,
327
+ // A pool holds no preapproval, so a registry INPUT settles via the
328
+ // two-step offer shape — opt verify-before-sign into it. CC input uses
329
+ // the Amulet path and needs no such opt-in.
330
+ allowRegistryOffer: true,
331
+ }
332
+ : {}),
333
+ wallet,
334
+ relay,
335
+ });
336
+ // (3) CLAIM THE RETURN. When we pre-approved a registry output the pool settles
337
+ // it DIRECTLY — nothing to accept — so skip the poll. Otherwise (a CC output, or
338
+ // preapproval opted out) the return may land as an offer; poll a few times since
339
+ // it arrives within ~1-2 minutes. `claimAll` accepts every pending offer.
340
+ const preapprovedRegistryOutput = wantPreapprove && ticket.outInstrument !== null;
341
+ const claimedUpdateIds = [];
342
+ if (!preapprovedRegistryOutput) {
343
+ const sleep = opts.sleep ?? defaultSleep;
344
+ const attempts = opts.claimAttempts ?? 6;
345
+ const intervalMs = opts.claimIntervalMs ?? 15_000;
346
+ for (let i = 0; i < attempts; i++) {
347
+ const r = await claimAll(relay, wallet, { hashBinding });
348
+ claimedUpdateIds.push(...r.updateIds);
349
+ if (r.claimed > 0)
350
+ break;
351
+ if (i < attempts - 1)
352
+ await sleep(intervalMs);
353
+ }
354
+ }
355
+ return {
356
+ sentUpdateId: sent.updateId,
357
+ claimed: claimedUpdateIds.length,
358
+ claimedUpdateIds,
359
+ };
360
+ }
361
+ //# sourceMappingURL=swap.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"swap.js","sourceRoot":"","sources":["../src/swap.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AACzC,OAAO,EAAE,gCAAgC,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AACrE,OAAO,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAC;AACvD,OAAO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UAAU,CAAC,CAAC;QAChD,CAAC;IACH,CAAC;IAED,OAAO;QACL,YAAY,EAAE,IAAI,CAAC,QAAQ;QAC3B,OAAO,EAAE,gBAAgB,CAAC,MAAM;QAChC,gBAAgB;KACjB,CAAC;AACJ,CAAC"}
package/dist/tx.d.ts CHANGED
@@ -48,6 +48,11 @@ export declare function transfer(relay: RelayClient, wallet: AgentWallet, opts:
48
48
  * DSO). For Amulet leave false — the relay resolves the DSO itself, and
49
49
  * `expectInstrumentAdmin` still pins it in verify-before-sign. */
50
50
  registryInstrument?: boolean;
51
+ /** Opt into the registry two-step transfer-offer shape (receiver has no
52
+ * preapproval) — threaded to verify-before-sign. Only a caller that means to
53
+ * send a registry token to a non-preapproved receiver (a swap to a pool) sets
54
+ * this. See PreparedTransferExpectation.allowRegistryOffer. */
55
+ allowRegistryOffer?: boolean;
51
56
  }): Promise<string>;
52
57
  /**
53
58
  * transfer-factory ("V3") pay: PREPARE + VERIFY-BEFORE-SIGN + SIGN a relay-built
package/dist/tx.d.ts.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"tx.d.ts","sourceRoot":"","sources":["../src/tx.ts"],"names":[],"mappings":"AASA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AACrD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAC9C,OAAO,EAOL,KAAK,kBAAkB,EAKxB,MAAM,sBAAsB,CAAC;AAgI9B;;;;;;GAMG;AACH,wBAAsB,QAAQ,CAC5B,KAAK,EAAE,WAAW,EAClB,MAAM,EAAE,WAAW,EACnB,IAAI,EAAE;IACJ,QAAQ,EAAE,MAAM,CAAC;IACjB,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC9B,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAC5B;;6DAEyD;IACzD,oBAAoB,CAAC,EAAE,MAAM,CAAC;IAC9B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RegistryParties !== undefined
208
208
  ? { trustedRegistryParties: opts.trustedRegistryParties }
209
209
  : {}),
210
+ ...(opts.allowRegistryOffer === true ? { allowRegistryOffer: true } : {}),
210
211
  nowMs: Date.now(),
211
212
  },
212
213
  }, opts.hashBinding, opts.expectSynchronizerId);