@xochi/client 0.0.0-stage → 0.1.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.
Files changed (125) hide show
  1. package/CHANGELOG.md +54 -0
  2. package/LICENSE +21 -0
  3. package/README.md +119 -2
  4. package/dist/cjs/claim.d.ts +33 -0
  5. package/dist/cjs/claim.js +44 -0
  6. package/dist/cjs/fee.d.ts +247 -0
  7. package/dist/cjs/fee.js +295 -0
  8. package/dist/cjs/index.d.ts +18 -0
  9. package/dist/cjs/index.js +33 -0
  10. package/dist/cjs/machine/claimInfo.d.ts +29 -0
  11. package/dist/cjs/machine/claimInfo.js +26 -0
  12. package/dist/cjs/machine/decisions.d.ts +452 -0
  13. package/dist/cjs/machine/decisions.js +665 -0
  14. package/dist/cjs/machine/deposit.d.ts +113 -0
  15. package/dist/cjs/machine/deposit.js +265 -0
  16. package/dist/cjs/machine/index.d.ts +23 -0
  17. package/dist/cjs/machine/index.js +53 -0
  18. package/dist/cjs/machine/machine.d.ts +409 -0
  19. package/dist/cjs/machine/machine.js +1615 -0
  20. package/dist/cjs/machine/phase.d.ts +24 -0
  21. package/dist/cjs/machine/phase.js +45 -0
  22. package/dist/cjs/machine/quoteChecks.d.ts +41 -0
  23. package/dist/cjs/machine/quoteChecks.js +82 -0
  24. package/dist/cjs/machine/receipt.d.ts +151 -0
  25. package/dist/cjs/machine/receipt.js +69 -0
  26. package/dist/cjs/machine/recipientEcho.d.ts +16 -0
  27. package/dist/cjs/machine/recipientEcho.js +27 -0
  28. package/dist/cjs/machine/solverPin.d.ts +110 -0
  29. package/dist/cjs/machine/solverPin.js +214 -0
  30. package/dist/cjs/machine/state.d.ts +167 -0
  31. package/dist/cjs/machine/state.js +31 -0
  32. package/dist/cjs/machine/transition.d.ts +15 -0
  33. package/dist/cjs/machine/transition.js +20 -0
  34. package/dist/cjs/machine/validateRequest.d.ts +15 -0
  35. package/dist/cjs/machine/validateRequest.js +127 -0
  36. package/dist/cjs/machine/view.d.ts +3 -0
  37. package/dist/cjs/machine/view.js +74 -0
  38. package/dist/cjs/machine/wire.d.ts +527 -0
  39. package/dist/cjs/machine/wire.js +280 -0
  40. package/dist/cjs/package.json +1 -0
  41. package/dist/cjs/shared/api.d.ts +9 -0
  42. package/dist/cjs/shared/api.js +5 -0
  43. package/dist/cjs/shared/chains.d.ts +243 -0
  44. package/dist/cjs/shared/chains.js +250 -0
  45. package/dist/cjs/shared/eip712.d.ts +44 -0
  46. package/dist/cjs/shared/eip712.js +64 -0
  47. package/dist/cjs/shared/index.d.ts +15 -0
  48. package/dist/cjs/shared/index.js +31 -0
  49. package/dist/cjs/shared/intentStream.d.ts +74 -0
  50. package/dist/cjs/shared/intentStream.js +59 -0
  51. package/dist/cjs/shared/intents.d.ts +88 -0
  52. package/dist/cjs/shared/intents.js +227 -0
  53. package/dist/cjs/shared/schemas.d.ts +928 -0
  54. package/dist/cjs/shared/schemas.js +524 -0
  55. package/dist/cjs/shared/stealth.d.ts +53 -0
  56. package/dist/cjs/shared/stealth.js +68 -0
  57. package/dist/cjs/shared/trading.d.ts +153 -0
  58. package/dist/cjs/shared/trading.js +185 -0
  59. package/dist/cjs/shared/types.d.ts +37 -0
  60. package/dist/cjs/shared/types.js +7 -0
  61. package/dist/cjs/shared/validators.d.ts +30 -0
  62. package/dist/cjs/shared/validators.js +79 -0
  63. package/dist/cjs/transport/client.d.ts +234 -0
  64. package/dist/cjs/transport/client.js +1456 -0
  65. package/dist/esm/claim.d.ts +33 -0
  66. package/dist/esm/claim.js +41 -0
  67. package/dist/esm/fee.d.ts +247 -0
  68. package/dist/esm/fee.js +285 -0
  69. package/dist/esm/index.d.ts +18 -0
  70. package/dist/esm/index.js +17 -0
  71. package/dist/esm/machine/claimInfo.d.ts +29 -0
  72. package/dist/esm/machine/claimInfo.js +23 -0
  73. package/dist/esm/machine/decisions.d.ts +452 -0
  74. package/dist/esm/machine/decisions.js +640 -0
  75. package/dist/esm/machine/deposit.d.ts +113 -0
  76. package/dist/esm/machine/deposit.js +260 -0
  77. package/dist/esm/machine/index.d.ts +23 -0
  78. package/dist/esm/machine/index.js +23 -0
  79. package/dist/esm/machine/machine.d.ts +409 -0
  80. package/dist/esm/machine/machine.js +1609 -0
  81. package/dist/esm/machine/phase.d.ts +24 -0
  82. package/dist/esm/machine/phase.js +42 -0
  83. package/dist/esm/machine/quoteChecks.d.ts +41 -0
  84. package/dist/esm/machine/quoteChecks.js +78 -0
  85. package/dist/esm/machine/receipt.d.ts +151 -0
  86. package/dist/esm/machine/receipt.js +64 -0
  87. package/dist/esm/machine/recipientEcho.d.ts +16 -0
  88. package/dist/esm/machine/recipientEcho.js +24 -0
  89. package/dist/esm/machine/solverPin.d.ts +110 -0
  90. package/dist/esm/machine/solverPin.js +210 -0
  91. package/dist/esm/machine/state.d.ts +167 -0
  92. package/dist/esm/machine/state.js +28 -0
  93. package/dist/esm/machine/transition.d.ts +15 -0
  94. package/dist/esm/machine/transition.js +17 -0
  95. package/dist/esm/machine/validateRequest.d.ts +15 -0
  96. package/dist/esm/machine/validateRequest.js +123 -0
  97. package/dist/esm/machine/view.d.ts +3 -0
  98. package/dist/esm/machine/view.js +71 -0
  99. package/dist/esm/machine/wire.d.ts +527 -0
  100. package/dist/esm/machine/wire.js +266 -0
  101. package/dist/esm/shared/api.d.ts +9 -0
  102. package/dist/esm/shared/api.js +4 -0
  103. package/dist/esm/shared/chains.d.ts +243 -0
  104. package/dist/esm/shared/chains.js +236 -0
  105. package/dist/esm/shared/eip712.d.ts +44 -0
  106. package/dist/esm/shared/eip712.js +61 -0
  107. package/dist/esm/shared/index.d.ts +15 -0
  108. package/dist/esm/shared/index.js +15 -0
  109. package/dist/esm/shared/intentStream.d.ts +74 -0
  110. package/dist/esm/shared/intentStream.js +55 -0
  111. package/dist/esm/shared/intents.d.ts +88 -0
  112. package/dist/esm/shared/intents.js +213 -0
  113. package/dist/esm/shared/schemas.d.ts +928 -0
  114. package/dist/esm/shared/schemas.js +521 -0
  115. package/dist/esm/shared/stealth.d.ts +53 -0
  116. package/dist/esm/shared/stealth.js +64 -0
  117. package/dist/esm/shared/trading.d.ts +153 -0
  118. package/dist/esm/shared/trading.js +182 -0
  119. package/dist/esm/shared/types.d.ts +37 -0
  120. package/dist/esm/shared/types.js +6 -0
  121. package/dist/esm/shared/validators.d.ts +30 -0
  122. package/dist/esm/shared/validators.js +74 -0
  123. package/dist/esm/transport/client.d.ts +234 -0
  124. package/dist/esm/transport/client.js +1447 -0
  125. package/package.json +61 -4
@@ -0,0 +1,928 @@
1
+ /**
2
+ * Zod Schemas
3
+ *
4
+ * The Worker's quote and execute RESPONSE wire contract (`/api/intent/quote`,
5
+ * `/api/intent/execute`), with the primitives it closes over. Types are derived
6
+ * from schemas via z.infer -- single source of truth.
7
+ */
8
+ import { z } from "zod";
9
+ /** Ethereum address: 0x-prefixed, 42 hex chars. Single source: validators.ts. */
10
+ export declare const ethAddress: z.ZodString;
11
+ /**
12
+ * Tron base58check address: leading `T`, 34 chars, base58 alphabet (no
13
+ * 0/O/I/l). Structural check mirroring `TRON_ADDRESS_REGEX` in validators.ts;
14
+ * kept inline here so the schema module stays free of the viem import chain.
15
+ */
16
+ export declare const tronAddress: z.ZodString;
17
+ /**
18
+ * Recipient address for a non-EVM destination: the user's own address on the
19
+ * destination chain (EVM routes settle to the signing wallet, so it is
20
+ * optional). EVM hex20 or Tron base58.
21
+ */
22
+ export declare const recipientAddress: z.ZodUnion<[z.ZodString, z.ZodString]>;
23
+ /** Settlement type */
24
+ export declare const settlementType: z.ZodEnum<["public", "shielded", "stealth"]>;
25
+ /**
26
+ * Pull+gas payment method the quote's eip712 authorizes.
27
+ *
28
+ * `deposit` is the odd one out and is not a pull at all: on a non-EVM origin
29
+ * (Tron) the user sends the tokens themselves to a served `deposit_address`,
30
+ * at their own network cost, with no wallet signature anywhere in the flow.
31
+ * It is in this enum because it is what belongs in this FIELD, which answers
32
+ * "how does the origin leg get funded".
33
+ *
34
+ * Without it the wire lies: a Tron-origin quote reports `payment_method:
35
+ * "permit2"` next to `gasless: false` and a `deposit_address`, describing a
36
+ * Permit2 pull on a chain that has no Permit2. The browser papers over it
37
+ * (`resolvePaymentMethod` overrides to `deposit` whenever a deposit address is
38
+ * present), so a human never sees the wrong label; every non-browser consumer
39
+ * does: the MCP server, the OpenAPI contract, and any agent branching on this
40
+ * field to decide whether to prepare a signature.
41
+ */
42
+ export declare const paymentMethod: z.ZodEnum<["erc3009", "permit2", "pimlico", "x402", "mpp", "approval", "deposit"]>;
43
+ /**
44
+ * A referral code as stored (xochi#583): 3-32 of `A-Z 0-9 _ -`, starting with a
45
+ * letter or digit. Stored and compared uppercase, so a link's `?ref=summer` and
46
+ * `SUMMER` are the same code. Migration 0019 enforces the same shape.
47
+ */
48
+ export declare const REFERRAL_CODE_REGEX: RegExp;
49
+ /**
50
+ * The note served when a `ref` was sent and is not applied. ONE text for every
51
+ * reason (unknown, expired, revoked, scoped to another key, a key that does not
52
+ * accept referrals, self-referral): a per-reason note would let a caller
53
+ * enumerate which codes exist.
54
+ */
55
+ export declare const REFERRAL_NOT_APPLIED_NOTE = "Referral code not applied.";
56
+ /**
57
+ * The neutral referral line (xochi#603): served on a quote whose `ref` was
58
+ * applied when the request is not signed in as the quoting wallet. One fixed
59
+ * text, identical whether or not the wallet has a referral binding.
60
+ */
61
+ export declare const REFERRAL_NEUTRAL_NOTE = "A referrer may earn part of the routing fee on this trade.";
62
+ export declare const QuoteReferralSchema: z.ZodUnion<[z.ZodObject<{
63
+ code: z.ZodString;
64
+ name: z.ZodString;
65
+ }, "strict", z.ZodTypeAny, {
66
+ code: string;
67
+ name: string;
68
+ }, {
69
+ code: string;
70
+ name: string;
71
+ }>, z.ZodObject<{
72
+ neutral: z.ZodLiteral<true>;
73
+ note: z.ZodLiteral<"A referrer may earn part of the routing fee on this trade.">;
74
+ }, "strict", z.ZodTypeAny, {
75
+ neutral: true;
76
+ note: "A referrer may earn part of the routing fee on this trade.";
77
+ }, {
78
+ neutral: true;
79
+ note: "A referrer may earn part of the routing fee on this trade.";
80
+ }>]>;
81
+ /**
82
+ * A promo code as stored (xochi#584): 3-32 of `A-Z 0-9 _ -`, starting with a
83
+ * letter or digit. Stored and compared uppercase, so `launch10` and `LAUNCH10`
84
+ * are the same code. Migration 0020 enforces the same shape.
85
+ */
86
+ export declare const PROMO_CODE_REGEX: RegExp;
87
+ /**
88
+ * The inline error served when a `promo` was sent and cannot be used. ONE text
89
+ * for every reason (unknown, malformed, expired, revoked, used up, used up by
90
+ * this wallet, not accepted under this publishable key, lookup ceiling, the
91
+ * feature off): a per-reason message would let a caller enumerate which codes
92
+ * exist.
93
+ */
94
+ export declare const PROMO_NOT_APPLIED_NOTE = "This code can't be applied.";
95
+ /**
96
+ * The note served when a valid code was sent but the caller's trust tier
97
+ * already discounts at least as much (discount = max(tier, capped promo), never
98
+ * both; an Institutional wallet always lands here). The code is
99
+ * not consumed.
100
+ */
101
+ export declare const PROMO_TIER_BETTER_NOTE = "Your trust tier already gives you a fee at least as low as this code.";
102
+ export declare const QuotePromoSchema: z.ZodObject<{
103
+ code: z.ZodString;
104
+ discount_bps: z.ZodNumber;
105
+ }, "strict", z.ZodTypeAny, {
106
+ code: string;
107
+ discount_bps: number;
108
+ }, {
109
+ code: string;
110
+ discount_bps: number;
111
+ }>;
112
+ /**
113
+ * EIP-712 typed data the user signs. Internal keys follow the EIP-712
114
+ * standard (camelCase: domain.chainId, domain.verifyingContract, primaryType)
115
+ * and are part of the signed payload -- they are intentionally NOT snake_cased.
116
+ * Passed through verbatim from the solver. Mirrors the `Eip712TypedData`
117
+ * schema in public/openapi.yaml.
118
+ */
119
+ export declare const Eip712TypedDataSchema: z.ZodObject<{
120
+ domain: z.ZodObject<{
121
+ name: z.ZodString;
122
+ version: z.ZodString;
123
+ chainId: z.ZodNumber;
124
+ verifyingContract: z.ZodOptional<z.ZodString>;
125
+ salt: z.ZodOptional<z.ZodString>;
126
+ }, "strip", z.ZodTypeAny, {
127
+ name: string;
128
+ version: string;
129
+ chainId: number;
130
+ verifyingContract?: string | undefined;
131
+ salt?: string | undefined;
132
+ }, {
133
+ name: string;
134
+ version: string;
135
+ chainId: number;
136
+ verifyingContract?: string | undefined;
137
+ salt?: string | undefined;
138
+ }>;
139
+ types: z.ZodRecord<z.ZodString, z.ZodArray<z.ZodObject<{
140
+ name: z.ZodString;
141
+ type: z.ZodString;
142
+ }, "strip", z.ZodTypeAny, {
143
+ type: string;
144
+ name: string;
145
+ }, {
146
+ type: string;
147
+ name: string;
148
+ }>, "many">>;
149
+ primaryType: z.ZodString;
150
+ message: z.ZodRecord<z.ZodString, z.ZodUnknown>;
151
+ }, "strip", z.ZodTypeAny, {
152
+ message: Record<string, unknown>;
153
+ domain: {
154
+ name: string;
155
+ version: string;
156
+ chainId: number;
157
+ verifyingContract?: string | undefined;
158
+ salt?: string | undefined;
159
+ };
160
+ types: Record<string, {
161
+ type: string;
162
+ name: string;
163
+ }[]>;
164
+ primaryType: string;
165
+ }, {
166
+ message: Record<string, unknown>;
167
+ domain: {
168
+ name: string;
169
+ version: string;
170
+ chainId: number;
171
+ verifyingContract?: string | undefined;
172
+ salt?: string | undefined;
173
+ };
174
+ types: Record<string, {
175
+ type: string;
176
+ name: string;
177
+ }[]>;
178
+ primaryType: string;
179
+ }>;
180
+ export declare const SettlementOptionSchema: z.ZodObject<{
181
+ type: z.ZodEnum<["public", "shielded", "stealth"]>;
182
+ available: z.ZodBoolean;
183
+ reason: z.ZodOptional<z.ZodString>;
184
+ }, "strip", z.ZodTypeAny, {
185
+ type: "public" | "shielded" | "stealth";
186
+ available: boolean;
187
+ reason?: string | undefined;
188
+ }, {
189
+ type: "public" | "shielded" | "stealth";
190
+ available: boolean;
191
+ reason?: string | undefined;
192
+ }>;
193
+ export declare const ClaimInfoSchema: z.ZodObject<{
194
+ factory_address: z.ZodString;
195
+ salt: z.ZodNumber;
196
+ }, "strip", z.ZodTypeAny, {
197
+ salt: number;
198
+ factory_address: string;
199
+ }, {
200
+ salt: number;
201
+ factory_address: string;
202
+ }>;
203
+ /**
204
+ * Itemized fee breakdown (economics.md Part 1). snake_case wire shape the worker
205
+ * emits and the frontend renders against. Layers are three additive bps lines on
206
+ * a never-discounted cost floor (solver + gas), plus venue and routing.
207
+ *
208
+ * The layer AMOUNTS carry no denomination of their own. The token they are
209
+ * measured in is named by `fee_denomination` on the enclosing quote response.
210
+ */
211
+ export declare const FeeBreakdownSchema: z.ZodObject<{
212
+ tier: z.ZodEnum<["standard", "trusted", "verified", "premium", "institutional"]>;
213
+ asset_class: z.ZodEnum<["stable", "volatile"]>;
214
+ gas_floor: z.ZodObject<{
215
+ amount: z.ZodString;
216
+ usd: z.ZodString;
217
+ }, "strip", z.ZodTypeAny, {
218
+ amount: string;
219
+ usd: string;
220
+ }, {
221
+ amount: string;
222
+ usd: string;
223
+ }>;
224
+ solver_fee_bps: z.ZodNumber;
225
+ solver_fee: z.ZodString;
226
+ price_impact_bps: z.ZodNumber;
227
+ price_impact: z.ZodString;
228
+ venue_fee_bps: z.ZodNumber;
229
+ venue_fee: z.ZodString;
230
+ routing_fee_bps: z.ZodNumber;
231
+ routing_fee: z.ZodString;
232
+ total_bps: z.ZodNumber;
233
+ total_fee: z.ZodString;
234
+ total_usd: z.ZodString;
235
+ surplus_share_pct: z.ZodNumber;
236
+ discount: z.ZodOptional<z.ZodObject<{
237
+ source: z.ZodEnum<["tier", "promo"]>;
238
+ bps: z.ZodNumber;
239
+ amount: z.ZodString;
240
+ }, "strict", z.ZodTypeAny, {
241
+ amount: string;
242
+ source: "tier" | "promo";
243
+ bps: number;
244
+ }, {
245
+ amount: string;
246
+ source: "tier" | "promo";
247
+ bps: number;
248
+ }>>;
249
+ }, "strip", z.ZodTypeAny, {
250
+ tier: "standard" | "trusted" | "verified" | "premium" | "institutional";
251
+ asset_class: "stable" | "volatile";
252
+ gas_floor: {
253
+ amount: string;
254
+ usd: string;
255
+ };
256
+ solver_fee_bps: number;
257
+ solver_fee: string;
258
+ price_impact_bps: number;
259
+ price_impact: string;
260
+ venue_fee_bps: number;
261
+ venue_fee: string;
262
+ routing_fee_bps: number;
263
+ routing_fee: string;
264
+ total_bps: number;
265
+ total_fee: string;
266
+ total_usd: string;
267
+ surplus_share_pct: number;
268
+ discount?: {
269
+ amount: string;
270
+ source: "tier" | "promo";
271
+ bps: number;
272
+ } | undefined;
273
+ }, {
274
+ tier: "standard" | "trusted" | "verified" | "premium" | "institutional";
275
+ asset_class: "stable" | "volatile";
276
+ gas_floor: {
277
+ amount: string;
278
+ usd: string;
279
+ };
280
+ solver_fee_bps: number;
281
+ solver_fee: string;
282
+ price_impact_bps: number;
283
+ price_impact: string;
284
+ venue_fee_bps: number;
285
+ venue_fee: string;
286
+ routing_fee_bps: number;
287
+ routing_fee: string;
288
+ total_bps: number;
289
+ total_fee: string;
290
+ total_usd: string;
291
+ surplus_share_pct: number;
292
+ discount?: {
293
+ amount: string;
294
+ source: "tier" | "promo";
295
+ bps: number;
296
+ } | undefined;
297
+ }>;
298
+ /**
299
+ * Which token the `fee_breakdown` layer amounts are measured in. See the
300
+ * `fee_denomination` field on {@link QuoteResponseSchema}.
301
+ */
302
+ export declare const FeeDenominationSchema: z.ZodEnum<["origin", "destination"]>;
303
+ /** Which token a served `fee_breakdown`'s layer amounts are denominated in. */
304
+ export type FeeDenomination = z.infer<typeof FeeDenominationSchema>;
305
+ /**
306
+ * The WIRE shape of a fee breakdown (snake_case), distinct from the camelCase
307
+ * `FeeBreakdown` domain type in `types.ts`. Named apart on purpose: the two
308
+ * describe the same fifteen values in two different casings, and a worker that
309
+ * forwards the wire form must not be handed the domain type by mistake.
310
+ * `mapQuoteResponse` is the one place that converts between them.
311
+ */
312
+ export type FeeBreakdownWire = z.infer<typeof FeeBreakdownSchema>;
313
+ /**
314
+ * Canonical quote response: the Xochi worker's `/api/intent/quote` output and
315
+ * the pinned agent contract. snake_case envelope; the `eip712` value is
316
+ * verbatim EIP-712 typed data. When `can_solve` is true, `to_amount`,
317
+ * `payment_method`, and `eip712` are present. Mirrors `QuoteResponse` in
318
+ * public/openapi.yaml -- keep all three in lockstep.
319
+ */
320
+ export declare const QuoteResponseSchema: z.ZodObject<{
321
+ success: z.ZodBoolean;
322
+ intent_id: z.ZodString;
323
+ quote_id: z.ZodString;
324
+ can_solve: z.ZodBoolean;
325
+ /** Non-executable price exploration: never persisted and carries no signing material. */
326
+ preview: z.ZodOptional<z.ZodBoolean>;
327
+ to_amount: z.ZodOptional<z.ZodString>;
328
+ min_to_amount: z.ZodOptional<z.ZodString>;
329
+ xochi_fee: z.ZodOptional<z.ZodString>;
330
+ xochi_fee_rate: z.ZodOptional<z.ZodString>;
331
+ cost_bps: z.ZodOptional<z.ZodNumber>;
332
+ fee_breakdown: z.ZodOptional<z.ZodObject<{
333
+ tier: z.ZodEnum<["standard", "trusted", "verified", "premium", "institutional"]>;
334
+ asset_class: z.ZodEnum<["stable", "volatile"]>;
335
+ gas_floor: z.ZodObject<{
336
+ amount: z.ZodString;
337
+ usd: z.ZodString;
338
+ }, "strip", z.ZodTypeAny, {
339
+ amount: string;
340
+ usd: string;
341
+ }, {
342
+ amount: string;
343
+ usd: string;
344
+ }>;
345
+ solver_fee_bps: z.ZodNumber;
346
+ solver_fee: z.ZodString;
347
+ price_impact_bps: z.ZodNumber;
348
+ price_impact: z.ZodString;
349
+ venue_fee_bps: z.ZodNumber;
350
+ venue_fee: z.ZodString;
351
+ routing_fee_bps: z.ZodNumber;
352
+ routing_fee: z.ZodString;
353
+ total_bps: z.ZodNumber;
354
+ total_fee: z.ZodString;
355
+ total_usd: z.ZodString;
356
+ surplus_share_pct: z.ZodNumber;
357
+ discount: z.ZodOptional<z.ZodObject<{
358
+ source: z.ZodEnum<["tier", "promo"]>;
359
+ bps: z.ZodNumber;
360
+ amount: z.ZodString;
361
+ }, "strict", z.ZodTypeAny, {
362
+ amount: string;
363
+ source: "tier" | "promo";
364
+ bps: number;
365
+ }, {
366
+ amount: string;
367
+ source: "tier" | "promo";
368
+ bps: number;
369
+ }>>;
370
+ }, "strip", z.ZodTypeAny, {
371
+ tier: "standard" | "trusted" | "verified" | "premium" | "institutional";
372
+ asset_class: "stable" | "volatile";
373
+ gas_floor: {
374
+ amount: string;
375
+ usd: string;
376
+ };
377
+ solver_fee_bps: number;
378
+ solver_fee: string;
379
+ price_impact_bps: number;
380
+ price_impact: string;
381
+ venue_fee_bps: number;
382
+ venue_fee: string;
383
+ routing_fee_bps: number;
384
+ routing_fee: string;
385
+ total_bps: number;
386
+ total_fee: string;
387
+ total_usd: string;
388
+ surplus_share_pct: number;
389
+ discount?: {
390
+ amount: string;
391
+ source: "tier" | "promo";
392
+ bps: number;
393
+ } | undefined;
394
+ }, {
395
+ tier: "standard" | "trusted" | "verified" | "premium" | "institutional";
396
+ asset_class: "stable" | "volatile";
397
+ gas_floor: {
398
+ amount: string;
399
+ usd: string;
400
+ };
401
+ solver_fee_bps: number;
402
+ solver_fee: string;
403
+ price_impact_bps: number;
404
+ price_impact: string;
405
+ venue_fee_bps: number;
406
+ venue_fee: string;
407
+ routing_fee_bps: number;
408
+ routing_fee: string;
409
+ total_bps: number;
410
+ total_fee: string;
411
+ total_usd: string;
412
+ surplus_share_pct: number;
413
+ discount?: {
414
+ amount: string;
415
+ source: "tier" | "promo";
416
+ bps: number;
417
+ } | undefined;
418
+ }>>;
419
+ fee_denomination: z.ZodOptional<z.ZodEnum<["origin", "destination"]>>;
420
+ referral: z.ZodOptional<z.ZodUnion<[z.ZodObject<{
421
+ code: z.ZodString;
422
+ name: z.ZodString;
423
+ }, "strict", z.ZodTypeAny, {
424
+ code: string;
425
+ name: string;
426
+ }, {
427
+ code: string;
428
+ name: string;
429
+ }>, z.ZodObject<{
430
+ neutral: z.ZodLiteral<true>;
431
+ note: z.ZodLiteral<"A referrer may earn part of the routing fee on this trade.">;
432
+ }, "strict", z.ZodTypeAny, {
433
+ neutral: true;
434
+ note: "A referrer may earn part of the routing fee on this trade.";
435
+ }, {
436
+ neutral: true;
437
+ note: "A referrer may earn part of the routing fee on this trade.";
438
+ }>]>>;
439
+ referral_note: z.ZodOptional<z.ZodLiteral<"Referral code not applied.">>;
440
+ promo: z.ZodOptional<z.ZodObject<{
441
+ code: z.ZodString;
442
+ discount_bps: z.ZodNumber;
443
+ }, "strict", z.ZodTypeAny, {
444
+ code: string;
445
+ discount_bps: number;
446
+ }, {
447
+ code: string;
448
+ discount_bps: number;
449
+ }>>;
450
+ promo_note: z.ZodOptional<z.ZodEnum<["This code can't be applied.", "Your trust tier already gives you a fee at least as low as this code."]>>;
451
+ estimated_gas_cost: z.ZodOptional<z.ZodString>;
452
+ stream_topic: z.ZodOptional<z.ZodString>;
453
+ expiry: z.ZodString;
454
+ gasless: z.ZodOptional<z.ZodBoolean>;
455
+ gasless_fee: z.ZodOptional<z.ZodString>;
456
+ payment_method: z.ZodOptional<z.ZodEnum<["erc3009", "permit2", "pimlico", "x402", "mpp", "approval", "deposit"]>>;
457
+ route: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
458
+ eip712: z.ZodOptional<z.ZodObject<{
459
+ domain: z.ZodObject<{
460
+ name: z.ZodString;
461
+ version: z.ZodString;
462
+ chainId: z.ZodNumber;
463
+ verifyingContract: z.ZodOptional<z.ZodString>;
464
+ salt: z.ZodOptional<z.ZodString>;
465
+ }, "strip", z.ZodTypeAny, {
466
+ name: string;
467
+ version: string;
468
+ chainId: number;
469
+ verifyingContract?: string | undefined;
470
+ salt?: string | undefined;
471
+ }, {
472
+ name: string;
473
+ version: string;
474
+ chainId: number;
475
+ verifyingContract?: string | undefined;
476
+ salt?: string | undefined;
477
+ }>;
478
+ types: z.ZodRecord<z.ZodString, z.ZodArray<z.ZodObject<{
479
+ name: z.ZodString;
480
+ type: z.ZodString;
481
+ }, "strip", z.ZodTypeAny, {
482
+ type: string;
483
+ name: string;
484
+ }, {
485
+ type: string;
486
+ name: string;
487
+ }>, "many">>;
488
+ primaryType: z.ZodString;
489
+ message: z.ZodRecord<z.ZodString, z.ZodUnknown>;
490
+ }, "strip", z.ZodTypeAny, {
491
+ message: Record<string, unknown>;
492
+ domain: {
493
+ name: string;
494
+ version: string;
495
+ chainId: number;
496
+ verifyingContract?: string | undefined;
497
+ salt?: string | undefined;
498
+ };
499
+ types: Record<string, {
500
+ type: string;
501
+ name: string;
502
+ }[]>;
503
+ primaryType: string;
504
+ }, {
505
+ message: Record<string, unknown>;
506
+ domain: {
507
+ name: string;
508
+ version: string;
509
+ chainId: number;
510
+ verifyingContract?: string | undefined;
511
+ salt?: string | undefined;
512
+ };
513
+ types: Record<string, {
514
+ type: string;
515
+ name: string;
516
+ }[]>;
517
+ primaryType: string;
518
+ }>>;
519
+ pull_authorization: z.ZodOptional<z.ZodObject<{
520
+ domain: z.ZodObject<{
521
+ name: z.ZodString;
522
+ version: z.ZodString;
523
+ chainId: z.ZodNumber;
524
+ verifyingContract: z.ZodOptional<z.ZodString>;
525
+ salt: z.ZodOptional<z.ZodString>;
526
+ }, "strip", z.ZodTypeAny, {
527
+ name: string;
528
+ version: string;
529
+ chainId: number;
530
+ verifyingContract?: string | undefined;
531
+ salt?: string | undefined;
532
+ }, {
533
+ name: string;
534
+ version: string;
535
+ chainId: number;
536
+ verifyingContract?: string | undefined;
537
+ salt?: string | undefined;
538
+ }>;
539
+ types: z.ZodRecord<z.ZodString, z.ZodArray<z.ZodObject<{
540
+ name: z.ZodString;
541
+ type: z.ZodString;
542
+ }, "strip", z.ZodTypeAny, {
543
+ type: string;
544
+ name: string;
545
+ }, {
546
+ type: string;
547
+ name: string;
548
+ }>, "many">>;
549
+ primaryType: z.ZodString;
550
+ message: z.ZodRecord<z.ZodString, z.ZodUnknown>;
551
+ }, "strip", z.ZodTypeAny, {
552
+ message: Record<string, unknown>;
553
+ domain: {
554
+ name: string;
555
+ version: string;
556
+ chainId: number;
557
+ verifyingContract?: string | undefined;
558
+ salt?: string | undefined;
559
+ };
560
+ types: Record<string, {
561
+ type: string;
562
+ name: string;
563
+ }[]>;
564
+ primaryType: string;
565
+ }, {
566
+ message: Record<string, unknown>;
567
+ domain: {
568
+ name: string;
569
+ version: string;
570
+ chainId: number;
571
+ verifyingContract?: string | undefined;
572
+ salt?: string | undefined;
573
+ };
574
+ types: Record<string, {
575
+ type: string;
576
+ name: string;
577
+ }[]>;
578
+ primaryType: string;
579
+ }>>;
580
+ deposit_address: z.ZodOptional<z.ZodString>;
581
+ deposit_attestation: z.ZodOptional<z.ZodString>;
582
+ deposit_deadline: z.ZodOptional<z.ZodNumber>;
583
+ recipient_address: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodString]>>;
584
+ settlement_options: z.ZodOptional<z.ZodArray<z.ZodObject<{
585
+ type: z.ZodEnum<["public", "shielded", "stealth"]>;
586
+ available: z.ZodBoolean;
587
+ reason: z.ZodOptional<z.ZodString>;
588
+ }, "strip", z.ZodTypeAny, {
589
+ type: "public" | "shielded" | "stealth";
590
+ available: boolean;
591
+ reason?: string | undefined;
592
+ }, {
593
+ type: "public" | "shielded" | "stealth";
594
+ available: boolean;
595
+ reason?: string | undefined;
596
+ }>, "many">>;
597
+ claim_info: z.ZodOptional<z.ZodObject<{
598
+ factory_address: z.ZodString;
599
+ salt: z.ZodNumber;
600
+ }, "strip", z.ZodTypeAny, {
601
+ salt: number;
602
+ factory_address: string;
603
+ }, {
604
+ salt: number;
605
+ factory_address: string;
606
+ }>>;
607
+ nonce: z.ZodOptional<z.ZodNumber>;
608
+ error: z.ZodOptional<z.ZodString>;
609
+ error_category: z.ZodOptional<z.ZodString>;
610
+ detail: z.ZodOptional<z.ZodString>;
611
+ minimum_amount_usd: z.ZodOptional<z.ZodNumber>;
612
+ min_fillable_usd: z.ZodOptional<z.ZodNumber>;
613
+ max_order_usd: z.ZodOptional<z.ZodNumber>;
614
+ }, "strict", z.ZodTypeAny, {
615
+ success: boolean;
616
+ intent_id: string;
617
+ quote_id: string;
618
+ can_solve: boolean;
619
+ expiry: string;
620
+ promo?: {
621
+ code: string;
622
+ discount_bps: number;
623
+ } | undefined;
624
+ preview?: boolean | undefined;
625
+ to_amount?: string | undefined;
626
+ min_to_amount?: string | undefined;
627
+ xochi_fee?: string | undefined;
628
+ xochi_fee_rate?: string | undefined;
629
+ cost_bps?: number | undefined;
630
+ fee_breakdown?: {
631
+ tier: "standard" | "trusted" | "verified" | "premium" | "institutional";
632
+ asset_class: "stable" | "volatile";
633
+ gas_floor: {
634
+ amount: string;
635
+ usd: string;
636
+ };
637
+ solver_fee_bps: number;
638
+ solver_fee: string;
639
+ price_impact_bps: number;
640
+ price_impact: string;
641
+ venue_fee_bps: number;
642
+ venue_fee: string;
643
+ routing_fee_bps: number;
644
+ routing_fee: string;
645
+ total_bps: number;
646
+ total_fee: string;
647
+ total_usd: string;
648
+ surplus_share_pct: number;
649
+ discount?: {
650
+ amount: string;
651
+ source: "tier" | "promo";
652
+ bps: number;
653
+ } | undefined;
654
+ } | undefined;
655
+ fee_denomination?: "origin" | "destination" | undefined;
656
+ referral?: {
657
+ code: string;
658
+ name: string;
659
+ } | {
660
+ neutral: true;
661
+ note: "A referrer may earn part of the routing fee on this trade.";
662
+ } | undefined;
663
+ referral_note?: "Referral code not applied." | undefined;
664
+ promo_note?: "This code can't be applied." | "Your trust tier already gives you a fee at least as low as this code." | undefined;
665
+ estimated_gas_cost?: string | undefined;
666
+ stream_topic?: string | undefined;
667
+ gasless?: boolean | undefined;
668
+ gasless_fee?: string | undefined;
669
+ payment_method?: "erc3009" | "permit2" | "pimlico" | "x402" | "mpp" | "approval" | "deposit" | undefined;
670
+ route?: Record<string, unknown> | undefined;
671
+ eip712?: {
672
+ message: Record<string, unknown>;
673
+ domain: {
674
+ name: string;
675
+ version: string;
676
+ chainId: number;
677
+ verifyingContract?: string | undefined;
678
+ salt?: string | undefined;
679
+ };
680
+ types: Record<string, {
681
+ type: string;
682
+ name: string;
683
+ }[]>;
684
+ primaryType: string;
685
+ } | undefined;
686
+ pull_authorization?: {
687
+ message: Record<string, unknown>;
688
+ domain: {
689
+ name: string;
690
+ version: string;
691
+ chainId: number;
692
+ verifyingContract?: string | undefined;
693
+ salt?: string | undefined;
694
+ };
695
+ types: Record<string, {
696
+ type: string;
697
+ name: string;
698
+ }[]>;
699
+ primaryType: string;
700
+ } | undefined;
701
+ deposit_address?: string | undefined;
702
+ deposit_attestation?: string | undefined;
703
+ deposit_deadline?: number | undefined;
704
+ recipient_address?: string | undefined;
705
+ settlement_options?: {
706
+ type: "public" | "shielded" | "stealth";
707
+ available: boolean;
708
+ reason?: string | undefined;
709
+ }[] | undefined;
710
+ claim_info?: {
711
+ salt: number;
712
+ factory_address: string;
713
+ } | undefined;
714
+ nonce?: number | undefined;
715
+ error?: string | undefined;
716
+ error_category?: string | undefined;
717
+ detail?: string | undefined;
718
+ minimum_amount_usd?: number | undefined;
719
+ min_fillable_usd?: number | undefined;
720
+ max_order_usd?: number | undefined;
721
+ }, {
722
+ success: boolean;
723
+ intent_id: string;
724
+ quote_id: string;
725
+ can_solve: boolean;
726
+ expiry: string;
727
+ promo?: {
728
+ code: string;
729
+ discount_bps: number;
730
+ } | undefined;
731
+ preview?: boolean | undefined;
732
+ to_amount?: string | undefined;
733
+ min_to_amount?: string | undefined;
734
+ xochi_fee?: string | undefined;
735
+ xochi_fee_rate?: string | undefined;
736
+ cost_bps?: number | undefined;
737
+ fee_breakdown?: {
738
+ tier: "standard" | "trusted" | "verified" | "premium" | "institutional";
739
+ asset_class: "stable" | "volatile";
740
+ gas_floor: {
741
+ amount: string;
742
+ usd: string;
743
+ };
744
+ solver_fee_bps: number;
745
+ solver_fee: string;
746
+ price_impact_bps: number;
747
+ price_impact: string;
748
+ venue_fee_bps: number;
749
+ venue_fee: string;
750
+ routing_fee_bps: number;
751
+ routing_fee: string;
752
+ total_bps: number;
753
+ total_fee: string;
754
+ total_usd: string;
755
+ surplus_share_pct: number;
756
+ discount?: {
757
+ amount: string;
758
+ source: "tier" | "promo";
759
+ bps: number;
760
+ } | undefined;
761
+ } | undefined;
762
+ fee_denomination?: "origin" | "destination" | undefined;
763
+ referral?: {
764
+ code: string;
765
+ name: string;
766
+ } | {
767
+ neutral: true;
768
+ note: "A referrer may earn part of the routing fee on this trade.";
769
+ } | undefined;
770
+ referral_note?: "Referral code not applied." | undefined;
771
+ promo_note?: "This code can't be applied." | "Your trust tier already gives you a fee at least as low as this code." | undefined;
772
+ estimated_gas_cost?: string | undefined;
773
+ stream_topic?: string | undefined;
774
+ gasless?: boolean | undefined;
775
+ gasless_fee?: string | undefined;
776
+ payment_method?: "erc3009" | "permit2" | "pimlico" | "x402" | "mpp" | "approval" | "deposit" | undefined;
777
+ route?: Record<string, unknown> | undefined;
778
+ eip712?: {
779
+ message: Record<string, unknown>;
780
+ domain: {
781
+ name: string;
782
+ version: string;
783
+ chainId: number;
784
+ verifyingContract?: string | undefined;
785
+ salt?: string | undefined;
786
+ };
787
+ types: Record<string, {
788
+ type: string;
789
+ name: string;
790
+ }[]>;
791
+ primaryType: string;
792
+ } | undefined;
793
+ pull_authorization?: {
794
+ message: Record<string, unknown>;
795
+ domain: {
796
+ name: string;
797
+ version: string;
798
+ chainId: number;
799
+ verifyingContract?: string | undefined;
800
+ salt?: string | undefined;
801
+ };
802
+ types: Record<string, {
803
+ type: string;
804
+ name: string;
805
+ }[]>;
806
+ primaryType: string;
807
+ } | undefined;
808
+ deposit_address?: string | undefined;
809
+ deposit_attestation?: string | undefined;
810
+ deposit_deadline?: number | undefined;
811
+ recipient_address?: string | undefined;
812
+ settlement_options?: {
813
+ type: "public" | "shielded" | "stealth";
814
+ available: boolean;
815
+ reason?: string | undefined;
816
+ }[] | undefined;
817
+ claim_info?: {
818
+ salt: number;
819
+ factory_address: string;
820
+ } | undefined;
821
+ nonce?: number | undefined;
822
+ error?: string | undefined;
823
+ error_category?: string | undefined;
824
+ detail?: string | undefined;
825
+ minimum_amount_usd?: number | undefined;
826
+ min_fillable_usd?: number | undefined;
827
+ max_order_usd?: number | undefined;
828
+ }>;
829
+ /**
830
+ * Length of an intent read capability (`read_token` on the execute response,
831
+ * xochi#563): 32 random bytes as unpadded base64url.
832
+ */
833
+ export declare const READ_TOKEN_LENGTH = 43;
834
+ /** Shape of an intent read capability: exactly `READ_TOKEN_LENGTH` base64url characters. */
835
+ export declare const READ_TOKEN_PATTERN: RegExp;
836
+ /**
837
+ * The request header that carries a `read_token` on `GET /api/intent/:id` and
838
+ * `GET /api/intent/:id/status`. A header and never a query parameter: the token
839
+ * must not land in URLs, logs or referrers.
840
+ */
841
+ export declare const READ_TOKEN_HEADER = "X-Xochi-Read-Token";
842
+ /** Mirrors `ExecuteResponse` in public/openapi.yaml. */
843
+ export declare const ExecuteResponseSchema: z.ZodObject<{
844
+ success: z.ZodBoolean;
845
+ intent_id: z.ZodString;
846
+ status: z.ZodString;
847
+ tx_hash: z.ZodOptional<z.ZodString>;
848
+ bridge_tx_hash: z.ZodOptional<z.ZodString>;
849
+ receiving_tx_hash: z.ZodOptional<z.ZodString>;
850
+ settlement_tx_hash: z.ZodOptional<z.ZodString>;
851
+ settlement_chain_id: z.ZodOptional<z.ZodNumber>;
852
+ reconciling: z.ZodOptional<z.ZodBoolean>;
853
+ note_commitment: z.ZodOptional<z.ZodString>;
854
+ stealth_address: z.ZodOptional<z.ZodString>;
855
+ ephemeral_pub_key: z.ZodOptional<z.ZodString>;
856
+ view_tag: z.ZodOptional<z.ZodNumber>;
857
+ error: z.ZodOptional<z.ZodString>;
858
+ substatus: z.ZodOptional<z.ZodLiteral<"not_executed">>;
859
+ read_token: z.ZodCatch<z.ZodOptional<z.ZodString>>;
860
+ }, "strict", z.ZodTypeAny, {
861
+ status: string;
862
+ success: boolean;
863
+ intent_id: string;
864
+ error?: string | undefined;
865
+ tx_hash?: string | undefined;
866
+ bridge_tx_hash?: string | undefined;
867
+ receiving_tx_hash?: string | undefined;
868
+ settlement_tx_hash?: string | undefined;
869
+ settlement_chain_id?: number | undefined;
870
+ reconciling?: boolean | undefined;
871
+ note_commitment?: string | undefined;
872
+ stealth_address?: string | undefined;
873
+ ephemeral_pub_key?: string | undefined;
874
+ view_tag?: number | undefined;
875
+ substatus?: "not_executed" | undefined;
876
+ read_token?: string | undefined;
877
+ }, {
878
+ status: string;
879
+ success: boolean;
880
+ intent_id: string;
881
+ error?: string | undefined;
882
+ tx_hash?: string | undefined;
883
+ bridge_tx_hash?: string | undefined;
884
+ receiving_tx_hash?: string | undefined;
885
+ settlement_tx_hash?: string | undefined;
886
+ settlement_chain_id?: number | undefined;
887
+ reconciling?: boolean | undefined;
888
+ note_commitment?: string | undefined;
889
+ stealth_address?: string | undefined;
890
+ ephemeral_pub_key?: string | undefined;
891
+ view_tag?: number | undefined;
892
+ substatus?: "not_executed" | undefined;
893
+ read_token?: unknown;
894
+ }>;
895
+ /**
896
+ * Automatic resends of one execute after its not-accepted answer. Mirrors
897
+ * `MAX_EXECUTE_RESENDS` in xochi's `@xochi/shared` `schemas.ts`, the budget
898
+ * the Worker enforces too: the refusal that follows this many un-claims
899
+ * finishes the intent `failed` instead.
900
+ */
901
+ export declare const MAX_EXECUTE_RESENDS = 3;
902
+ /**
903
+ * A resend must reach the Worker at least this many seconds before the
904
+ * earliest deadline the signed request carries. Mirrors
905
+ * `EXECUTE_RESEND_MARGIN_SECS` in xochi's `@xochi/shared` `schemas.ts`, the
906
+ * margin the Worker applies before it un-claims.
907
+ */
908
+ export declare const EXECUTE_RESEND_MARGIN_SECS = 5;
909
+ /**
910
+ * Seconds past an unexecuted intent's signed deadline before the Worker ends
911
+ * it: a `quoted` market row (never claimed, or every claim undone) that an
912
+ * intent read (`GET /api/intent/:id` or the status poll, never the stream)
913
+ * finds this far past the `deadline` the user signed is finished `failed`
914
+ * with `NOT_EXECUTED_SUBSTATUS`, and the read serves that. Slack for clock
915
+ * skew between the Worker, the database (whose clock the claim's deadline
916
+ * check uses), the solver and the client. Measured from the signed deadline;
917
+ * the quote sweep's own 60 s is measured from the Worker's 30 s quote expiry
918
+ * and usually ends a touched row first (README "Fund safety"). Mirrors
919
+ * `QUOTED_EXPIRY_GRACE_SECS` in xochi's `@xochi/shared` `schemas.ts`. The
920
+ * machine polls an execute at least this long past the quote's deadline
921
+ * (`unexecutedFinishAt`).
922
+ */
923
+ export declare const QUOTED_EXPIRY_GRACE_SECS = 60;
924
+ export type Eip712TypedDataWire = z.infer<typeof Eip712TypedDataSchema>;
925
+ export type SettlementOptionWire = z.infer<typeof SettlementOptionSchema>;
926
+ export type ClaimInfoWire = z.infer<typeof ClaimInfoSchema>;
927
+ export type QuoteResponseWire = z.infer<typeof QuoteResponseSchema>;
928
+ export type ExecuteResponseWire = z.infer<typeof ExecuteResponseSchema>;