@anywalletkit/protocol-swap2-omniston 0.2.8 → 0.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.
@@ -0,0 +1,772 @@
1
+ import { RemotePins, CrossChainProvider, Quote, UnsignedTx, QuoteParams } from '@anywalletkit/protocol-swap2-core/types';
2
+
3
+ /** Audited from the active mainnet Escrow builder on 2026-08-13. These are
4
+ * immutable TVM code cells, not resolver-controlled addresses. A contract
5
+ * upgrade must deliberately update these hashes after reviewing its schema.
6
+ *
7
+ * `authorityKeys` is the optional 256-bit public key in the escrow config: the
8
+ * escrow code checks `CHKSIGNU` against it for its signature-gated operations
9
+ * (disassembly of code 9e77cb9e…, 2026-10-11). It has been the same key since
10
+ * the August audit, so it stays pinned. */
11
+ declare const DEFAULT_OMNISTON_TON_CODE_HASHES: {
12
+ readonly escrow: readonly ["9e77cb9e8fd7406d4e85e5f57378eb51e51b862424cf988306c783d50ade697a"];
13
+ readonly execution: readonly ["f6edbc76e6fbcd6bac573cb942401a3d9198ee9605f9403b0f5c8081259210e5"];
14
+ readonly authorityKeys: readonly ["ed210da12aa96ea42de4f2f61dc172bbaa3da86051a1b2a6f342f69a777d2770"];
15
+ /** EVM→TON output position: the contract the factory deploys for the
16
+ * resolver's jetton lock (observed on every resolver-created position,
17
+ * 2026-10-15/16), and the escrow code cell it carries in its state. */
18
+ readonly position: readonly ["e4d5115a321ade7b827e38fb522c20d2f2cd46e4c6b0b5f7dd8b6b096792d77b"];
19
+ readonly outputEscrow: readonly ["d30423575384773abaad8d3c6f763898afa3d57a5693005904b7c61e95cee630"];
20
+ };
21
+ /** Upper bound on the exclusivity window the escrow config may carry. It is
22
+ * how long the trader's input stays locked when no resolver reserves the
23
+ * position (SDK: "at the end of this period trader's position becomes
24
+ * available for manual withdrawal"); the live value is 300 s. */
25
+ declare const MAX_OMNISTON_EXCLUSIVITY_SECONDS = 3600;
26
+ type PayloadInput = Omit<Parameters<NonNullable<OmnistonProviderOptions["validateTonEscrowPayload"]>>[0], "exclusivityTimeout"> & {
27
+ exclusivityTimeout?: number;
28
+ };
29
+ /** Code interfaces (tonapi's by-code-hash labels) a same-chain swap message
30
+ * may pay into. The resolver picks the pool/vault per route, so the check is
31
+ * "a STON.fi or DeDust contract by code", not a fixed address list — seen
32
+ * live: native GRAM → DeDust CPMM v2 pool, jettons → STON.fi router v2. */
33
+ declare const DEFAULT_OMNISTON_TON_SWAP_INTERFACES: readonly ["stonfi_router", "stonfi_router_v2", "stonfi_pool", "stonfi_pool_v2", "dedust_vault", "dedust_v2_cpmm", "dedust_pool"];
34
+ /** Proxy-TON (pTON) jetton masters STON.fi routes native TON through. A
35
+ * native-input swap pays the ROUTER'S pTON wallet — a plain `jetton_wallet`
36
+ * to tonapi, no DEX code interface — so such a target is accepted only when
37
+ * its jetton master is pTON AND its owner carries a DEX router interface.
38
+ * Seen live 2026-09-05: GRAM → USDT on StonFiV2 targeted the router's pTON
39
+ * v2 wallet and the code-interface check alone refused it. */
40
+ declare const DEFAULT_OMNISTON_TON_PROXY_TON_MASTERS: readonly ["EQCM3B12QK1e4yZSf8GtBRT0aLMNyEsBc_DhVfRRtOEffLez", "EQBnGWMCf3-FZZq1W4IWcWiGAc3PHuZ0_H-7sad2oY00o83S"];
41
+ interface OmnistonTonValidationOptions {
42
+ fetch?: typeof fetch;
43
+ /** Diagnostics hook: every refusal of validateTonOutputPosition names its check (never a secret). */
44
+ onRefusal?: (reason: string, details?: Record<string, unknown>) => void;
45
+ tonApiUrl?: string;
46
+ tonApiKey?: string;
47
+ /** Code interfaces accepted as swap targets (default: the STON.fi / DeDust set above). */
48
+ swapTargetInterfaces?: readonly string[];
49
+ /** Proxy-TON masters whose router-owned wallets may receive native input (default: pTON v1/v2). */
50
+ proxyTonMasters?: readonly string[];
51
+ escrowCodeHashes?: readonly string[];
52
+ executionCodeHashes?: readonly string[];
53
+ /** Pinned escrow authority public keys (hex, 32 bytes). */
54
+ authorityKeys?: readonly string[];
55
+ /** EVM→TON output position code hashes (default: the observed factory position). */
56
+ positionCodeHashes?: readonly string[];
57
+ /** Escrow code cells an output position may carry (default: the observed one). */
58
+ outputEscrowCodeHashes?: readonly string[];
59
+ /**
60
+ * The Omniston protocol contracts a TON → EVM escrow transfer may pay (`verifyTonEscrowBuild`). Default: the audited
61
+ * `AUDITED_OMNISTON_SETTLEMENT_CONTRACTS["ton:-239"]`.
62
+ */
63
+ trustedProtocolAddresses?: readonly string[];
64
+ now?: () => number;
65
+ }
66
+ type TonOutputPositionInput = Parameters<NonNullable<OmnistonProviderOptions["validateTonOutputPosition"]>>[0];
67
+ /** What a TON → EVM escrow build must carry, as the app knows it (`verifyTonEscrowBuild`). */
68
+ interface TonEscrowBuildExpectation {
69
+ /** The message body: the jetton transfer that funds the escrow, hex. */
70
+ payloadBocHex: string;
71
+ /** The trader's TON address: the jetton transfer's excess and the escrow's owner (refunds go there). */
72
+ ownerAddress: string;
73
+ /** The exact jetton amount the swap sells. */
74
+ inputUnits: string;
75
+ /** The destination chain, CAIP-2 (`eip155:8453`) or Omniston's name (`base`). */
76
+ destinationChain: string;
77
+ /** The trader's address on the destination chain. */
78
+ destinationAddress: string;
79
+ /** The ERC-20 the trader receives there. */
80
+ outputTokenAddress: string;
81
+ /** The least the resolver may be bound to deliver: the quote's minimum (and the app's own floor). */
82
+ minResolverSendsUnits: string;
83
+ }
84
+ declare function createOmnistonTonValidators(options?: OmnistonTonValidationOptions): Required<Pick<OmnistonProviderOptions, "validateTonJettonWallet" | "validateTonSwapTarget" | "validateTonOutputPosition" | "validateTonSwapLeg">> & {
85
+ validateTonEscrowPayload: (input: PayloadInput) => boolean | Promise<boolean>;
86
+ verifyTonEscrowBuild: (input: TonEscrowBuildExpectation) => string | null;
87
+ };
88
+ interface OmnistonTonDeliveryLocatorOptions {
89
+ fetch?: typeof fetch;
90
+ tonApiUrl?: string;
91
+ tonApiKey?: string;
92
+ /** Recipient events scanned per call (newest first; the delivery is recent by construction). */
93
+ limit?: number;
94
+ }
95
+ interface OmnistonTonDeliveryInput {
96
+ /** The output position that paid out; when absent any sender of a matching transfer counts (backfills). */
97
+ positionAddress?: string;
98
+ recipientAddress: string;
99
+ jettonMasterAddress: string;
100
+ minUnits: string;
101
+ /** Unix seconds; events before it are not this delivery (backfills). With it set, the EARLIEST match wins — the one closest to the order, not a later swap's payout. */
102
+ afterTimestamp?: number;
103
+ /** Unix seconds; events after it are not this delivery (backfills: the row's completion time plus slack). */
104
+ beforeTimestamp?: number;
105
+ }
106
+ /**
107
+ * Finds an Omniston TON delivery: the jetton transfer from the output position
108
+ * to the recipient of at least `minUnits`, in the recipient's tonapi events.
109
+ * Returns tonapi's `event_id` — the hash `@anywalletkit/wallet-ton`'s history
110
+ * source gives the same event as a row, so a wallet can pair the TON receive
111
+ * with the swap. Feeds `omnistonProvider({locateTonDelivery})`; a server may
112
+ * also call it with no position to backfill rows completed before the locator
113
+ * existed. Never throws: null when nothing matched or tonapi did not answer.
114
+ */
115
+ declare function createOmnistonTonDeliveryLocator(options?: OmnistonTonDeliveryLocatorOptions): (input: OmnistonTonDeliveryInput) => Promise<string | null>;
116
+
117
+ /** Omniston's `SwapChunk.protocol` names and the layout each one builds. */
118
+ declare const TON_SWAP_PROTOCOL_LAYOUTS: Readonly<Record<string, "stonfi-v1" | "stonfi-v2" | "dedust-v1" | "dedust-v2">>;
119
+ /** A chain fact the payload depends on; checked by `validateTonSwapLeg`. A
120
+ * jetton is named by its master address; `null` is native GRAM. */
121
+ type TonSwapLeg = {
122
+ kind: "stonfi-router";
123
+ version: 1 | 2;
124
+ /** The router that executes this hop; null = the owner of `proxyTonWallet`. */
125
+ router: string | null;
126
+ /** Native input: the router's proxy-TON wallet the message pays into. */
127
+ proxyTonWallet?: string;
128
+ /** The router's wallet the hop asks for — must be the router's wallet of `outputJetton`
129
+ * (of a proxy-TON master when the output is native). */
130
+ askWallet: string;
131
+ inputJetton: string | null;
132
+ outputJetton: string | null;
133
+ } | {
134
+ kind: "dedust-pool";
135
+ version: 1 | 2;
136
+ pool: string;
137
+ inputJetton: string | null;
138
+ outputJetton: string | null;
139
+ };
140
+ interface TonSwapCheckInput {
141
+ /** The built message's body (BoC hex) and destination. */
142
+ payloadHex: string;
143
+ targetAddress: string;
144
+ /** Value attached to the message, nanoTON. */
145
+ sendAmount: bigint;
146
+ /** The trader's wallet (signs; refunds and excesses return to it). */
147
+ trader: string;
148
+ /** Where the output must land. */
149
+ dest: string;
150
+ /** Quote fields the body must honour. */
151
+ inputUnits: string;
152
+ minOutputAmount: string;
153
+ inputJetton: string | null;
154
+ outputJetton: string | null;
155
+ steps: readonly {
156
+ protocol: string;
157
+ inputJetton: string | null | undefined;
158
+ outputJetton: string | null | undefined;
159
+ }[];
160
+ /** The integrator the quote was requested with: the only referral a body may name. */
161
+ integratorAddress?: string | null;
162
+ }
163
+ interface TonSwapCheckResult {
164
+ layout: "stonfi-v1" | "stonfi-v2" | "dedust-v1" | "dedust-v2";
165
+ /** On-chain minimum of the final hop. */
166
+ minOut: bigint;
167
+ legs: TonSwapLeg[];
168
+ }
169
+ /** A refusal with a stable, loggable reason code (never carries secrets). */
170
+ declare class TonSwapPayloadError extends Error {
171
+ readonly reason: string;
172
+ constructor(reason: string, detail?: string);
173
+ }
174
+ /**
175
+ * Decode and check a built TON same-chain swap message. Throws
176
+ * `TonSwapPayloadError` with a reason code on the first violated rule; returns
177
+ * the chain facts (`legs`) still to be confirmed by `validateTonSwapLeg`.
178
+ *
179
+ * Rules (all protocols): one route of single-protocol steps; the body's
180
+ * layout is the one the quoted protocol builds; the DEX call moves exactly the
181
+ * quoted input; the final receiver is the destination; refunds / excesses go
182
+ * to the trader; the final on-chain minimum is ≥ the quote's minOutputAmount;
183
+ * no referral other than the configured integrator; no trailing data.
184
+ */
185
+ declare function checkTonSwapPayload(ctx: TonSwapCheckInput): TonSwapCheckResult;
186
+
187
+ /**
188
+ * Persists HTLC secret preimages by quoteId between buildDeposit and the
189
+ * trackIntent poll that discloses them. Losing a secret does NOT lose funds —
190
+ * the escrow refunds after the HTLC timeout — but it does fail the swap.
191
+ */
192
+ interface HtlcSecretStore {
193
+ save(quoteId: string, secretsHex: string[]): void | Promise<void>;
194
+ load(quoteId: string): string[] | undefined | Promise<string[] | undefined>;
195
+ clear(quoteId: string): void | Promise<void>;
196
+ }
197
+ /**
198
+ * Persists the quote/build context between getQuote, buildDeposit and
199
+ * registerSignedOrder. On SERVERLESS these run on different instances, so the
200
+ * default in-memory map strands executions ("quote expired") — inject a
201
+ * durable store there. Values are JSON-safe (byte fields base64-encoded).
202
+ */
203
+ interface OmnistonQuoteStore {
204
+ save(quoteId: string, valueJson: string): void | Promise<void>;
205
+ load(quoteId: string): string | undefined | Promise<string | undefined>;
206
+ clear(quoteId: string): void | Promise<void>;
207
+ /**
208
+ * Save only if nothing is stored under `quoteId` yet, atomically (Redis `SET NX`, a KV conditional put): true when
209
+ * this call wrote it. A quote id is the platform's choice, so a context must never be overwritten by another user's
210
+ * quote under the same id (scan 2026-10-27 modules, F27). Without it the provider checks then saves — fine for one
211
+ * process, racy across instances.
212
+ */
213
+ claim?(quoteId: string, valueJson: string): boolean | Promise<boolean>;
214
+ }
215
+ /** Default quote store — long-lived processes and tests only. */
216
+ declare function inMemoryQuoteStore(): OmnistonQuoteStore;
217
+ /** Default store — suitable for long-lived processes and tests only. */
218
+ declare function inMemorySecretStore(): HtlcSecretStore;
219
+ interface ObservableLike<T> {
220
+ subscribe(observer: {
221
+ next?: (value: T) => void;
222
+ error?: (err: unknown) => void;
223
+ complete?: () => void;
224
+ }): {
225
+ unsubscribe(): void;
226
+ };
227
+ }
228
+ /** Self-contained structural SDK types. Keeping these local prevents the
229
+ * optional Omniston peer from leaking into every consumer's declaration graph. */
230
+ interface AssetId {
231
+ chain: {
232
+ $case: string;
233
+ value: string | {
234
+ kind?: {
235
+ $case: string;
236
+ value?: unknown;
237
+ };
238
+ };
239
+ };
240
+ }
241
+ interface ChainAddress {
242
+ chain: {
243
+ $case: string;
244
+ value: string;
245
+ };
246
+ }
247
+ interface QuoteRequest {
248
+ inputAsset: AssetId;
249
+ outputAsset: AssetId;
250
+ amount: {
251
+ $case: string;
252
+ value: string;
253
+ };
254
+ settlementParams: {
255
+ params: {
256
+ $case: string;
257
+ value: Record<string, unknown>;
258
+ };
259
+ }[];
260
+ integratorAddress?: ChainAddress;
261
+ integratorFeePips?: number;
262
+ }
263
+ interface OmnistonQuote {
264
+ rfqId: string;
265
+ quoteId: string;
266
+ inputAsset: AssetId;
267
+ outputAsset: AssetId;
268
+ inputUnits: string;
269
+ outputUnits: string;
270
+ protocolFeeUnits?: string;
271
+ integratorFeeUnits?: string;
272
+ integratorAddress?: ChainAddress;
273
+ quoteTimestamp: number;
274
+ /** Total TON the trade needs on top of the input (swap settlement); omitted for gasless quotes. */
275
+ gasBudget?: string | undefined;
276
+ /** Omniston's estimate of the gas the route actually burns (swap settlement); the rest of the budget returns. */
277
+ estimatedGasConsumption?: string | undefined;
278
+ settlementData: {
279
+ $case: "order";
280
+ value: OrderSettlement;
281
+ } | {
282
+ $case: "swap";
283
+ value: SwapSettlement;
284
+ };
285
+ }
286
+ /** Order settlement (HTLC / escrow) — the cross-chain branch. */
287
+ interface OrderSettlement {
288
+ srcProtocolContractAddress: ChainAddress;
289
+ dstProtocolContractAddress?: ChainAddress;
290
+ srcInitialResolverAddress?: ChainAddress;
291
+ resolverSendsUnits: string;
292
+ srcHtlcSecurityDepositUnits?: string;
293
+ dstSecurityDepositUnits?: string;
294
+ tradeStartDeadline: number;
295
+ /**
296
+ * Seconds after the trader creates the position before a resolver must
297
+ * reserve it; after that the position is withdrawable by the trader (SDK
298
+ * docs). The TON escrow config carries it, so the payload validator binds
299
+ * the built escrow to the quoted value.
300
+ */
301
+ exclusivityTimeout?: number;
302
+ htlcHashingFunction?: string;
303
+ /** Fee profile the EVM order extension must mirror (EVM-source orders). */
304
+ protocolFeePips?: number;
305
+ integratorFeePips?: number;
306
+ /** Destination-chain wallet the protocol fee must be paid to (EVM-destination
307
+ * orders); the EVM output validator binds the escrow's fee split to it. */
308
+ protocolFeeRecipientAddress?: ChainAddress;
309
+ }
310
+ /** Swap settlement — immediate DEX routes, the TON same-chain branch. */
311
+ interface SwapSettlement {
312
+ routes: {
313
+ steps: {
314
+ inputAsset?: AssetId;
315
+ outputAsset?: AssetId;
316
+ chunks: {
317
+ protocol: string;
318
+ inputUnits: string;
319
+ outputUnits: string;
320
+ }[];
321
+ }[];
322
+ }[];
323
+ minOutputAmount: string;
324
+ recommendedMinOutputAmount?: string;
325
+ recommendedSlippagePips?: number;
326
+ priceImpactPips?: number | undefined;
327
+ }
328
+ type RfqEvent = {
329
+ $case: "ack";
330
+ value: {
331
+ rfqId: string;
332
+ };
333
+ } | {
334
+ $case: "quoteUpdated";
335
+ rfqId?: string;
336
+ value: OmnistonQuote;
337
+ } | {
338
+ $case: "noQuote";
339
+ rfqId?: string;
340
+ value: unknown;
341
+ } | {
342
+ $case: string;
343
+ value?: unknown;
344
+ };
345
+ interface EscrowMessage {
346
+ targetAddress: string;
347
+ sendAmount: string;
348
+ payload: string;
349
+ jettonWalletStateInit?: string | undefined;
350
+ }
351
+ interface OrderExecution {
352
+ index: number;
353
+ inputUnits: string;
354
+ outputUnits: string;
355
+ resolverSendsUnits: string;
356
+ secretHash?: Uint8Array | undefined;
357
+ inputPositionPhase?: string | undefined;
358
+ inputPositionAddress?: ChainAddress | undefined;
359
+ outputPositionPhase?: string | undefined;
360
+ outputPositionAddress?: ChainAddress | undefined;
361
+ }
362
+ interface OrderSnapshot {
363
+ status: string;
364
+ executions: OrderExecution[];
365
+ }
366
+ type OrderEvent = {
367
+ $case: "order";
368
+ value: OrderSnapshot;
369
+ } | {
370
+ $case: string;
371
+ value?: unknown;
372
+ };
373
+ type SwapTrackEvent = {
374
+ $case: "awaitingTransfer";
375
+ value?: unknown;
376
+ } | {
377
+ $case: "progress";
378
+ value: {
379
+ status: string;
380
+ outgoingTxHash?: string;
381
+ };
382
+ } | {
383
+ $case: string;
384
+ value?: unknown;
385
+ };
386
+ /** The slice of `Omniston` this provider uses — a real instance satisfies it. */
387
+ interface OmnistonClientLike {
388
+ requestForQuote(request: QuoteRequest): ObservableLike<RfqEvent>;
389
+ tonBuildEscrowTransfer(request: {
390
+ quoteId: string;
391
+ ownerSrcAddress: ChainAddress;
392
+ transferSrcAddress: ChainAddress;
393
+ refundSrcAddress: ChainAddress;
394
+ gasExcessAddress: ChainAddress;
395
+ traderDstAddress: ChainAddress;
396
+ htlcSecrets: {
397
+ secretMode: {
398
+ $case: "provided";
399
+ value: {
400
+ hashes: Uint8Array[];
401
+ };
402
+ };
403
+ };
404
+ }): Promise<{
405
+ messages: EscrowMessage[];
406
+ }>;
407
+ evmBuildOrderPayload(request: {
408
+ quoteId: string;
409
+ ownerSrcAddress: ChainAddress;
410
+ traderDstAddress?: ChainAddress;
411
+ htlcSecrets?: {
412
+ secretMode: {
413
+ $case: "provided";
414
+ value: {
415
+ hashes: Uint8Array[];
416
+ };
417
+ };
418
+ };
419
+ }): Promise<{
420
+ typedData: string;
421
+ orderExtension: Uint8Array;
422
+ serializedOrderDetails?: Uint8Array | undefined;
423
+ }>;
424
+ orderRegisterSignedOrder(request: {
425
+ quoteId: string;
426
+ ownerSrcAddress: ChainAddress;
427
+ signedOrder: {
428
+ order: {
429
+ $case: "evmV1";
430
+ value: {
431
+ encodedOrder: Uint8Array;
432
+ signature: Uint8Array;
433
+ orderExtension: Uint8Array;
434
+ };
435
+ };
436
+ };
437
+ serializedOrderDetails?: Uint8Array | undefined;
438
+ }): Promise<void>;
439
+ /** Swap settlement (TON↔TON). Optional so older injected clients keep working; without them same-chain swaps fail closed. */
440
+ tonBuildSwap?(request: {
441
+ quoteId: string;
442
+ transferSrcAddress: ChainAddress;
443
+ refundSrcAddress: ChainAddress;
444
+ gasExcessAddress: ChainAddress;
445
+ traderDstAddress: ChainAddress;
446
+ useRecommendedSlippage?: boolean;
447
+ }): Promise<{
448
+ messages: EscrowMessage[];
449
+ }>;
450
+ swapTrack?(request: {
451
+ quoteId: string;
452
+ traderAddress: ChainAddress;
453
+ outgoingTxQuery: string;
454
+ }): ObservableLike<SwapTrackEvent>;
455
+ orderTrack(request: {
456
+ quoteId: string;
457
+ traderAddress: ChainAddress;
458
+ }): ObservableLike<OrderEvent>;
459
+ orderDiscloseHtlcSecret(request: {
460
+ quoteId: string;
461
+ executionIndex: number;
462
+ secret: Uint8Array;
463
+ }): Promise<void>;
464
+ close?: () => void;
465
+ transport?: {
466
+ close(): void;
467
+ };
468
+ }
469
+ interface OmnistonProviderOptions {
470
+ /** Injected SDK client (tests); defaults to a lazy `new Omniston({apiUrl})`. */
471
+ client?: OmnistonClientLike;
472
+ /** WebSocket API URL; defaults to the public ston.fi endpoint. */
473
+ apiUrl?: string;
474
+ /** HTLC preimage persistence; defaults to in-memory (NOT serverless-safe). */
475
+ secretStore?: HtlcSecretStore;
476
+ /** Quote/build context persistence; defaults to in-memory (NOT serverless-safe). */
477
+ quoteStore?: OmnistonQuoteStore;
478
+ /** Maximum number of HTLC execution attempts covered by generated secrets. */
479
+ maxHtlcExecutions?: number;
480
+ /** Hard cap for resolver-requested TON gas/forward value (default: 2 TON). */
481
+ maxTonExecutionNano?: string;
482
+ /** Resolver competition window; primarily useful for deterministic tests. */
483
+ quoteSettleMs?: number;
484
+ /** Explicit constructor configuration; no deployment environment is read. */
485
+ enabled?: boolean;
486
+ /** Exact decimal USD cap; string form avoids binary-float rounding. */
487
+ maxUsd?: number | string;
488
+ integratorAddress?: string;
489
+ integratorFeePips?: number;
490
+ /** Independently trusted settlement contracts, keyed by CAIP-2 chain. */
491
+ trustedSettlementContracts?: Readonly<Record<string, readonly string[]>>;
492
+ /**
493
+ * Independently trusted EVM order protocols — the Omniston fork of the 1inch
494
+ * Limit Order Protocol an EVM-source order is signed against and that moves
495
+ * the input token on fill — keyed by CAIP-2 chain. Kept apart from
496
+ * `trustedSettlementContracts` because one address plays different roles on
497
+ * different chains (0xafCF… is the escrow factory on Ethereum and the order
498
+ * protocol on Polygon). EVM→TON is advertised only for chains listed here.
499
+ */
500
+ trustedEvmOrderProtocols?: Readonly<Record<string, readonly string[]>>;
501
+ /**
502
+ * RPC-backed TON jetton-wallet verification. A TON-source order is rejected
503
+ * when this hook is absent or does not prove that `walletAddress` belongs to
504
+ * the quoted jetton master for `ownerAddress`.
505
+ */
506
+ validateTonJettonWallet?: (input: {
507
+ ownerAddress: string;
508
+ jettonMasterAddress: string;
509
+ walletAddress: string;
510
+ }) => boolean | Promise<boolean>;
511
+ /**
512
+ * Independent semantic verifier for the Omniston TON escrow forward cell.
513
+ * The resolver-built BoC is never accepted through byte-search heuristics.
514
+ * A TON-source route is disabled unless this hook parses the documented
515
+ * contract schema and proves every expected field below in its exact slot.
516
+ */
517
+ /**
518
+ * TON↔TON swap settlement: independently confirm that the contract a swap
519
+ * message pays into — directly for native GRAM, as the jetton-transfer
520
+ * destination for jettons — is a DEX contract of a protocol the quote named
521
+ * (e.g. by its code interface on an indexer). Without it, same-chain TON
522
+ * swaps are not advertised.
523
+ */
524
+ validateTonSwapTarget?: (input: {
525
+ address: string;
526
+ protocols: readonly string[];
527
+ }) => Promise<boolean> | boolean;
528
+ /**
529
+ * TON↔TON swap settlement (scan F11): confirm one chain fact the decoded
530
+ * swap body depends on — that a STON.fi hop's ask wallet is its router's
531
+ * wallet of the quoted output (and, for native input, that the pTON wallet
532
+ * the message pays belongs to that router), or that a DeDust pool trades the
533
+ * quoted pair. `createOmnistonTonValidators` supplies it. When absent the
534
+ * decoded-body rules still apply and each skipped leg is traced as
535
+ * `ton-swap-payload legs-unverified`; STON.fi v1 native input (pTON v1) is
536
+ * refused without it.
537
+ */
538
+ validateTonSwapLeg?: (leg: TonSwapLeg) => Promise<boolean> | boolean;
539
+ /**
540
+ * TON↔TON swap settlement (scan F11): what a built swap body that fails the
541
+ * decoder (receiver ≠ destination, refund/excess ≠ trader, on-chain minimum
542
+ * below the quote, unknown layout, unverifiable leg) does. "enforce"
543
+ * (default) refuses the build; "report" traces `ton-swap-payload <reason>`
544
+ * and still builds — a rollout escape hatch, not a steady state.
545
+ */
546
+ tonSwapPayloadCheck?: "report" | "enforce";
547
+ validateTonEscrowPayload?: (input: {
548
+ payloadBocHex: string;
549
+ forwardPayloadBocHex: string;
550
+ quoteId: string;
551
+ inputUnits: string;
552
+ resolverSendsUnits: string;
553
+ srcHtlcSecurityDepositUnits: string;
554
+ protocolAddress: string;
555
+ ownerAddress: string;
556
+ destinationChain: string;
557
+ destinationAddress: string;
558
+ outputTokenAddress: string;
559
+ initialResolverAddress: string;
560
+ secretHashes: readonly Uint8Array[];
561
+ hashingFunction?: string;
562
+ /** The quote's `exclusivityTimeout` (seconds) the escrow config must carry. */
563
+ exclusivityTimeout: number;
564
+ }) => boolean | Promise<boolean>;
565
+ /**
566
+ * RPC-backed proof of the destination EVM escrow. The tracking feed is only
567
+ * a discovery hint: no HTLC preimage is disclosed until this hook proves the
568
+ * independently finalized on-chain position matches the signed quote.
569
+ */
570
+ validateEvmOutputPosition?: (input: {
571
+ chain: string;
572
+ positionAddress: string;
573
+ factoryAddress: string;
574
+ quoteTimestamp: number;
575
+ executionIndex: number;
576
+ recipientAddress: string;
577
+ outputTokenAddress: string;
578
+ inputUnits: string;
579
+ outputUnits: string;
580
+ resolverSendsUnits: string;
581
+ srcHtlcSecurityDepositUnits: string;
582
+ dstSecurityDepositUnits: string;
583
+ protocolFeeUnits: string;
584
+ integratorFeeUnits: string;
585
+ integratorAddress?: string;
586
+ /** The quote's `settlementData.protocolFeeRecipientAddress` (destination chain). */
587
+ protocolFeeRecipientAddress?: string;
588
+ secretHash: Uint8Array;
589
+ }) => boolean | Promise<boolean>;
590
+ /**
591
+ * RPC-backed proof of the finalized EVM source position (EVM→TON). The
592
+ * tracking feed only hints at the address; no secret is disclosed until this
593
+ * hook proves — from the trusted factory's own `SrcEscrowCreated` event, the
594
+ * deterministic escrow address and the escrow's balances — that the
595
+ * trader's FULL input is locked for this hashlock under the quoted terms
596
+ * (owner, token, amount, resolver, deposit, timelocks, TON output amount).
597
+ */
598
+ validateEvmInputPosition?: (input: {
599
+ chain: string;
600
+ positionAddress: string;
601
+ factoryAddress: string;
602
+ orderProtocolAddress: string;
603
+ ownerAddress: string;
604
+ resolverAddress: string;
605
+ inputTokenAddress: string;
606
+ inputUnits: string;
607
+ resolverSendsUnits: string;
608
+ srcHtlcSecurityDepositUnits: string;
609
+ quoteTimestamp: number;
610
+ secretHash: Uint8Array;
611
+ /** EVM destination only: the escrow event's destination complement must name this chain, token and deposit. */
612
+ destinationChainId?: number;
613
+ destinationTokenAddress?: string;
614
+ dstSecurityDepositUnits?: string;
615
+ }) => boolean | Promise<boolean>;
616
+ /**
617
+ * Indexer/RPC-backed proof of the TON output position (EVM→TON): deployed by
618
+ * the trusted factory for THIS quote, pinned position/escrow code, hashlock,
619
+ * recipient, amount, security deposit, and a cancellation boundary still far
620
+ * enough away to complete. The tracking feed is only a discovery hint.
621
+ */
622
+ validateTonOutputPosition?: (input: {
623
+ positionAddress: string;
624
+ protocolAddress: string;
625
+ outputJettonMasterAddress: string;
626
+ recipientAddress: string;
627
+ quoteId: string;
628
+ quoteTimestamp: number;
629
+ inputUnits: string;
630
+ outputUnits: string;
631
+ resolverSendsUnits: string;
632
+ dstSecurityDepositUnits: string;
633
+ secretHash: Uint8Array;
634
+ }) => boolean | Promise<boolean>;
635
+ /**
636
+ * EVM destination: find the delivery transaction — the destination escrow's
637
+ * payout to the recipient — so a completed order carries `destTxHash`.
638
+ * Omniston's tracking feed names the escrow but not that transaction.
639
+ */
640
+ locateEvmDelivery?: (input: {
641
+ chain: string;
642
+ positionAddress: string;
643
+ recipientAddress: string;
644
+ tokenAddress: string;
645
+ minUnits: string;
646
+ }) => Promise<string | null>;
647
+ /**
648
+ * TON destination: find the delivery — the output position's jetton transfer
649
+ * to the recipient — so a completed EVM → TON order carries `destTxHash` in
650
+ * the form the TON history source uses (tonapi event id). Without it the
651
+ * wallet's feed cannot pair the TON receive with the swap.
652
+ */
653
+ locateTonDelivery?: (input: {
654
+ positionAddress: string;
655
+ recipientAddress: string;
656
+ jettonMasterAddress: string;
657
+ minUnits: string;
658
+ }) => Promise<string | null>;
659
+ /** Close an injected client when the provider closes (default: caller owns it). */
660
+ closeInjectedClient?: boolean;
661
+ /**
662
+ * Diagnostics: why a poll did not disclose (`disclosure-skipped` with the gate
663
+ * and its fields, `validator-refused`, `validator-threw`) and when it did
664
+ * (`secret-disclosed`). Never carries secrets. Wire it to your logger: a
665
+ * silent "pending" cost a live order its 2-minute window (2026-10-20).
666
+ */
667
+ trace?: (event: string, details?: Record<string, unknown>) => void;
668
+ }
669
+ /** EIP-712 typed data → the ABI-encoded order struct `SignedOrderEvmV1` wants.
670
+ * Structs referenced in `types` become tuples, recursively. */
671
+ declare function encodeTypedMessage(td: {
672
+ types: Record<string, {
673
+ name: string;
674
+ type: string;
675
+ }[]>;
676
+ primaryType: string;
677
+ message: unknown;
678
+ }): Uint8Array;
679
+ /**
680
+ * Strict decoder for the currently observed Omniston v1beta8 EVM→TON 1inch
681
+ * extension profile. It deliberately rejects unknown auction/fee/timelock
682
+ * profiles: signing a merely well-formed extension is not enough because the
683
+ * resolver-controlled tail contains the actual on-chain HTLC terms.
684
+ *
685
+ * This binds what the wallet signs to the quote; it does not by itself make
686
+ * the swap complete. Secret disclosure additionally needs the independently
687
+ * finalized EVM source-fill and TON output-position proofs (trackIntent).
688
+ * `dstSecurityDepositUnits` is the value the EVM deposits word carries — for a
689
+ * TON destination that word is 0 (the TON deposit is bound in the TON position).
690
+ */
691
+ declare function validateEvmToTonOrderExtension(extension: Uint8Array, expected: {
692
+ quoteId: string;
693
+ quoteTimestamp: number;
694
+ tradeStartDeadline: number;
695
+ protocolFeePips: number;
696
+ integratorFeePips: number;
697
+ initialResolverAddress: string;
698
+ outputTokenAddress: string;
699
+ traderDstAddress: string;
700
+ takerAsset: string;
701
+ srcSecurityDepositUnits: string;
702
+ dstSecurityDepositUnits: string;
703
+ secretHash: Uint8Array;
704
+ trustedTarget: (address: string) => boolean;
705
+ /** EVM destination (EIP-155 id): ExtraDataArgs carry it and the destination
706
+ * ERC-20 (`outputTokenAddress`, `traderDstAddress` are EVM then). Absent = TON. */
707
+ dstChainId?: number;
708
+ }): Promise<void>;
709
+ /**
710
+ * The EVM order checks the provider runs on every build, exported so an app that holds the quote's settlement data
711
+ * can run them itself (scan 2026-10-27 modules, F4): the 1inch Limit Order Protocol v4 domain on the settlement
712
+ * contract and chain, the exact Order schema, this owner as maker, the resolver as receiver, the input asset and
713
+ * amount, single-fill traits, the salt committing the order extension and the expiry at the trade-start deadline.
714
+ * Throws when any of it does not hold.
715
+ */
716
+ declare function validateEvmTypedOrder(td: unknown, expected: {
717
+ chainId: number;
718
+ settlementContract: string;
719
+ owner: string;
720
+ receiver: string;
721
+ makerAsset: string;
722
+ makingAmount: string;
723
+ takingAmount: string;
724
+ orderExtension: Uint8Array;
725
+ quoteTimestamp: number;
726
+ tradeStartDeadline: number;
727
+ }): asserts td is {
728
+ domain: {
729
+ verifyingContract: string;
730
+ chainId: string | number;
731
+ };
732
+ types: Record<string, {
733
+ name: string;
734
+ type: string;
735
+ }[]>;
736
+ primaryType: string;
737
+ message: Record<string, unknown>;
738
+ };
739
+ /**
740
+ * The app's side of `remoteProvider({name: "omniston", baseUrl, ...omnistonPins(trustedEvmOrderProtocols)})`: the
741
+ * audited order-protocol contracts per EVM chain — the list the provider's `trustedEvmOrderProtocols` takes — are the
742
+ * only spenders, and so the only EIP-712 verifying contracts, a remote typed order may name (scan 2026-10-27 modules,
743
+ * F4). Omniston's EVM orders call no contract from the wallet: there are no call targets.
744
+ */
745
+ declare function omnistonPins(trustedEvmOrderProtocols: Readonly<Record<string, readonly string[]>>): RemotePins;
746
+ /**
747
+ * The app's check of a remote Omniston TON build, for `remoteProvider({name: "omniston", baseUrl, verifyBuild:
748
+ * omnistonVerifyBuild({...createOmnistonTonValidators()})})` (scan 2026-10-27 modules, F7/F13/F18/F19):
749
+ * - a TON → TON swap body is opened with `checkTonSwapPayload` against the app's own request — receiver, refund /
750
+ * excess to the trader, the on-chain minimum, the input — and the DEX it pays is confirmed with the app's
751
+ * validators (`validateTonSwapTarget`, `validateTonSwapLeg`);
752
+ * - a TON → EVM escrow body (an Omniston order from TON) goes to `verifyTonEscrowBuild` with what the app knows: the
753
+ * input, the trader's TON address, the destination chain, address and token, and the quote's minimum delivery.
754
+ * EVM typed orders pass through to the engine's own order checks. The reason it fails, or null.
755
+ */
756
+ declare function omnistonVerifyBuild(hooks: {
757
+ validateTonSwapTarget: (input: {
758
+ address: string;
759
+ protocols: readonly string[];
760
+ }) => Promise<boolean> | boolean;
761
+ validateTonSwapLeg?: (leg: TonSwapLeg) => Promise<boolean> | boolean;
762
+ /**
763
+ * The app's check of a TON → EVM escrow body (`createOmnistonTonValidators().verifyTonEscrowBuild`). Without it a
764
+ * TON → EVM build is refused.
765
+ */
766
+ verifyTonEscrowBuild?: (input: TonEscrowBuildExpectation) => string | null | Promise<string | null>;
767
+ /** The integrator your backend's Omniston provider uses: the only referral a body may name. */
768
+ integratorAddress?: string | null;
769
+ }): (quote: Quote, tx: UnsignedTx, params?: QuoteParams) => Promise<string | null>;
770
+ declare function omnistonProvider(opts?: OmnistonProviderOptions): CrossChainProvider;
771
+
772
+ export { type AssetId as A, type OmnistonTonValidationOptions as B, type ChainAddress as C, DEFAULT_OMNISTON_TON_CODE_HASHES as D, type EscrowMessage as E, type TonEscrowBuildExpectation as F, type TonOutputPositionInput as G, type HtlcSecretStore as H, createOmnistonTonDeliveryLocator as I, createOmnistonTonValidators as J, MAX_OMNISTON_EXCLUSIVITY_SECONDS as M, type ObservableLike as O, type QuoteRequest as Q, type RfqEvent as R, type SwapSettlement as S, TON_SWAP_PROTOCOL_LAYOUTS as T, type OmnistonClientLike as a, type OmnistonProviderOptions as b, type OmnistonQuote as c, type OmnistonQuoteStore as d, type OrderEvent as e, type OrderExecution as f, type OrderSettlement as g, type OrderSnapshot as h, type SwapTrackEvent as i, type TonSwapCheckInput as j, type TonSwapCheckResult as k, type TonSwapLeg as l, TonSwapPayloadError as m, checkTonSwapPayload as n, encodeTypedMessage as o, inMemoryQuoteStore as p, inMemorySecretStore as q, omnistonPins as r, omnistonProvider as s, omnistonVerifyBuild as t, validateEvmTypedOrder as u, validateEvmToTonOrderExtension as v, DEFAULT_OMNISTON_TON_PROXY_TON_MASTERS as w, DEFAULT_OMNISTON_TON_SWAP_INTERFACES as x, type OmnistonTonDeliveryInput as y, type OmnistonTonDeliveryLocatorOptions as z };