@ftptech/canton-agent-wallet 1.2.0 → 1.3.0

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