@riftresearch/sdk 0.7.0 → 0.7.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.ts CHANGED
@@ -233,2445 +233,12 @@ declare const Currencies: {
233
233
  CBBTC: Currency;
234
234
  };
235
235
  };
236
- import { Treaty } from "@elysiajs/eden";
237
- import { Elysia } from "elysia";
238
- import { Static } from "elysia";
239
- import { TString as TString_4i3c6z } from "@sinclair/typebox";
240
- import { TObject as TObject_6obbkd } from "@sinclair/typebox";
241
- import { TLiteral as TLiteral_yes1tx } from "@sinclair/typebox";
242
- import { TNumber as TNumber_6uuzwj } from "@sinclair/typebox";
243
- import { TUnion as TUnion_twkt9h } from "@sinclair/typebox";
244
- import { TOptional as TOptional_p2zzfw } from "@sinclair/typebox";
245
- declare const QuoteRequestSchema: TObject_6obbkd<{
246
- type: TString_4i3c6z;
247
- from: TObject_6obbkd<{
248
- chain: TUnion_twkt9h<[TObject_6obbkd<{
249
- kind: TLiteral_yes1tx<"BITCOIN">;
250
- }>, TObject_6obbkd<{
251
- kind: TLiteral_yes1tx<"EVM">;
252
- chainId: TNumber_6uuzwj;
253
- }>]>;
254
- token: TUnion_twkt9h<[TObject_6obbkd<{
255
- kind: TLiteral_yes1tx<"NATIVE">;
256
- decimals: TNumber_6uuzwj;
257
- }>, TObject_6obbkd<{
258
- kind: TLiteral_yes1tx<"TOKEN">;
259
- address: TString_4i3c6z;
260
- decimals: TNumber_6uuzwj;
261
- }>]>;
262
- }>;
263
- to: TObject_6obbkd<{
264
- chain: TUnion_twkt9h<[TObject_6obbkd<{
265
- kind: TLiteral_yes1tx<"BITCOIN">;
266
- }>, TObject_6obbkd<{
267
- kind: TLiteral_yes1tx<"EVM">;
268
- chainId: TNumber_6uuzwj;
269
- }>]>;
270
- token: TUnion_twkt9h<[TObject_6obbkd<{
271
- kind: TLiteral_yes1tx<"NATIVE">;
272
- decimals: TNumber_6uuzwj;
273
- }>, TObject_6obbkd<{
274
- kind: TLiteral_yes1tx<"TOKEN">;
275
- address: TString_4i3c6z;
276
- decimals: TNumber_6uuzwj;
277
- }>]>;
278
- }>;
279
- amount: TString_4i3c6z;
280
- slippageBps: TNumber_6uuzwj;
281
- quoteQuality: TOptional_p2zzfw<TString_4i3c6z>;
282
- }>;
283
- /**
284
- * Discriminated union of quote responses.
285
- */
286
- declare const QuoteResponseSchema: TUnion_twkt9h<[TObject_6obbkd<{
287
- from: TObject_6obbkd<{
288
- currency: TObject_6obbkd<{
289
- chain: TUnion_twkt9h<[TObject_6obbkd<{
290
- kind: TLiteral_yes1tx<"BITCOIN">;
291
- }>, TObject_6obbkd<{
292
- kind: TLiteral_yes1tx<"EVM">;
293
- chainId: TNumber_6uuzwj;
294
- }>]>;
295
- token: TUnion_twkt9h<[TObject_6obbkd<{
296
- kind: TLiteral_yes1tx<"NATIVE">;
297
- decimals: TNumber_6uuzwj;
298
- }>, TObject_6obbkd<{
299
- kind: TLiteral_yes1tx<"TOKEN">;
300
- address: TString_4i3c6z;
301
- decimals: TNumber_6uuzwj;
302
- }>]>;
303
- }>;
304
- expected: TString_4i3c6z;
305
- }>;
306
- to: TObject_6obbkd<{
307
- currency: TObject_6obbkd<{
308
- chain: TUnion_twkt9h<[TObject_6obbkd<{
309
- kind: TLiteral_yes1tx<"BITCOIN">;
310
- }>, TObject_6obbkd<{
311
- kind: TLiteral_yes1tx<"EVM">;
312
- chainId: TNumber_6uuzwj;
313
- }>]>;
314
- token: TUnion_twkt9h<[TObject_6obbkd<{
315
- kind: TLiteral_yes1tx<"NATIVE">;
316
- decimals: TNumber_6uuzwj;
317
- }>, TObject_6obbkd<{
318
- kind: TLiteral_yes1tx<"TOKEN">;
319
- address: TString_4i3c6z;
320
- decimals: TNumber_6uuzwj;
321
- }>]>;
322
- }>;
323
- expected: TString_4i3c6z;
324
- minimum: TOptional_p2zzfw<TString_4i3c6z>;
325
- }>;
326
- id: TString_4i3c6z;
327
- fees: TObject_6obbkd<{
328
- preswap: TOptional_p2zzfw<TObject_6obbkd<{
329
- amount: TString_4i3c6z;
330
- currency: TObject_6obbkd<{
331
- chain: TUnion_twkt9h<[TObject_6obbkd<{
332
- kind: TLiteral_yes1tx<"BITCOIN">;
333
- }>, TObject_6obbkd<{
334
- kind: TLiteral_yes1tx<"EVM">;
335
- chainId: TNumber_6uuzwj;
336
- }>]>;
337
- token: TUnion_twkt9h<[TObject_6obbkd<{
338
- kind: TLiteral_yes1tx<"NATIVE">;
339
- decimals: TNumber_6uuzwj;
340
- }>, TObject_6obbkd<{
341
- kind: TLiteral_yes1tx<"TOKEN">;
342
- address: TString_4i3c6z;
343
- decimals: TNumber_6uuzwj;
344
- }>]>;
345
- }>;
346
- usd: TNumber_6uuzwj;
347
- }>>;
348
- rift: TOptional_p2zzfw<TObject_6obbkd<{
349
- network: TObject_6obbkd<{
350
- amount: TString_4i3c6z;
351
- currency: TObject_6obbkd<{
352
- chain: TUnion_twkt9h<[TObject_6obbkd<{
353
- kind: TLiteral_yes1tx<"BITCOIN">;
354
- }>, TObject_6obbkd<{
355
- kind: TLiteral_yes1tx<"EVM">;
356
- chainId: TNumber_6uuzwj;
357
- }>]>;
358
- token: TUnion_twkt9h<[TObject_6obbkd<{
359
- kind: TLiteral_yes1tx<"NATIVE">;
360
- decimals: TNumber_6uuzwj;
361
- }>, TObject_6obbkd<{
362
- kind: TLiteral_yes1tx<"TOKEN">;
363
- address: TString_4i3c6z;
364
- decimals: TNumber_6uuzwj;
365
- }>]>;
366
- }>;
367
- usd: TNumber_6uuzwj;
368
- }>;
369
- liquidity: TObject_6obbkd<{
370
- amount: TString_4i3c6z;
371
- currency: TObject_6obbkd<{
372
- chain: TUnion_twkt9h<[TObject_6obbkd<{
373
- kind: TLiteral_yes1tx<"BITCOIN">;
374
- }>, TObject_6obbkd<{
375
- kind: TLiteral_yes1tx<"EVM">;
376
- chainId: TNumber_6uuzwj;
377
- }>]>;
378
- token: TUnion_twkt9h<[TObject_6obbkd<{
379
- kind: TLiteral_yes1tx<"NATIVE">;
380
- decimals: TNumber_6uuzwj;
381
- }>, TObject_6obbkd<{
382
- kind: TLiteral_yes1tx<"TOKEN">;
383
- address: TString_4i3c6z;
384
- decimals: TNumber_6uuzwj;
385
- }>]>;
386
- }>;
387
- usd: TNumber_6uuzwj;
388
- }>;
389
- protocol: TObject_6obbkd<{
390
- amount: TString_4i3c6z;
391
- currency: TObject_6obbkd<{
392
- chain: TUnion_twkt9h<[TObject_6obbkd<{
393
- kind: TLiteral_yes1tx<"BITCOIN">;
394
- }>, TObject_6obbkd<{
395
- kind: TLiteral_yes1tx<"EVM">;
396
- chainId: TNumber_6uuzwj;
397
- }>]>;
398
- token: TUnion_twkt9h<[TObject_6obbkd<{
399
- kind: TLiteral_yes1tx<"NATIVE">;
400
- decimals: TNumber_6uuzwj;
401
- }>, TObject_6obbkd<{
402
- kind: TLiteral_yes1tx<"TOKEN">;
403
- address: TString_4i3c6z;
404
- decimals: TNumber_6uuzwj;
405
- }>]>;
406
- }>;
407
- usd: TNumber_6uuzwj;
408
- }>;
409
- }>>;
410
- postswap: TOptional_p2zzfw<TObject_6obbkd<{
411
- amount: TString_4i3c6z;
412
- currency: TObject_6obbkd<{
413
- chain: TUnion_twkt9h<[TObject_6obbkd<{
414
- kind: TLiteral_yes1tx<"BITCOIN">;
415
- }>, TObject_6obbkd<{
416
- kind: TLiteral_yes1tx<"EVM">;
417
- chainId: TNumber_6uuzwj;
418
- }>]>;
419
- token: TUnion_twkt9h<[TObject_6obbkd<{
420
- kind: TLiteral_yes1tx<"NATIVE">;
421
- decimals: TNumber_6uuzwj;
422
- }>, TObject_6obbkd<{
423
- kind: TLiteral_yes1tx<"TOKEN">;
424
- address: TString_4i3c6z;
425
- decimals: TNumber_6uuzwj;
426
- }>]>;
427
- }>;
428
- usd: TNumber_6uuzwj;
429
- }>>;
430
- totalUsd: TNumber_6uuzwj;
431
- }>;
432
- expiresAt: TString_4i3c6z;
433
- mode: TLiteral_yes1tx<"exact_input">;
434
- }>, TObject_6obbkd<{
435
- from: TObject_6obbkd<{
436
- currency: TObject_6obbkd<{
437
- chain: TUnion_twkt9h<[TObject_6obbkd<{
438
- kind: TLiteral_yes1tx<"BITCOIN">;
439
- }>, TObject_6obbkd<{
440
- kind: TLiteral_yes1tx<"EVM">;
441
- chainId: TNumber_6uuzwj;
442
- }>]>;
443
- token: TUnion_twkt9h<[TObject_6obbkd<{
444
- kind: TLiteral_yes1tx<"NATIVE">;
445
- decimals: TNumber_6uuzwj;
446
- }>, TObject_6obbkd<{
447
- kind: TLiteral_yes1tx<"TOKEN">;
448
- address: TString_4i3c6z;
449
- decimals: TNumber_6uuzwj;
450
- }>]>;
451
- }>;
452
- expected: TString_4i3c6z;
453
- maximum: TOptional_p2zzfw<TString_4i3c6z>;
454
- }>;
455
- to: TObject_6obbkd<{
456
- currency: TObject_6obbkd<{
457
- chain: TUnion_twkt9h<[TObject_6obbkd<{
458
- kind: TLiteral_yes1tx<"BITCOIN">;
459
- }>, TObject_6obbkd<{
460
- kind: TLiteral_yes1tx<"EVM">;
461
- chainId: TNumber_6uuzwj;
462
- }>]>;
463
- token: TUnion_twkt9h<[TObject_6obbkd<{
464
- kind: TLiteral_yes1tx<"NATIVE">;
465
- decimals: TNumber_6uuzwj;
466
- }>, TObject_6obbkd<{
467
- kind: TLiteral_yes1tx<"TOKEN">;
468
- address: TString_4i3c6z;
469
- decimals: TNumber_6uuzwj;
470
- }>]>;
471
- }>;
472
- expected: TString_4i3c6z;
473
- }>;
474
- id: TString_4i3c6z;
475
- fees: TObject_6obbkd<{
476
- preswap: TOptional_p2zzfw<TObject_6obbkd<{
477
- amount: TString_4i3c6z;
478
- currency: TObject_6obbkd<{
479
- chain: TUnion_twkt9h<[TObject_6obbkd<{
480
- kind: TLiteral_yes1tx<"BITCOIN">;
481
- }>, TObject_6obbkd<{
482
- kind: TLiteral_yes1tx<"EVM">;
483
- chainId: TNumber_6uuzwj;
484
- }>]>;
485
- token: TUnion_twkt9h<[TObject_6obbkd<{
486
- kind: TLiteral_yes1tx<"NATIVE">;
487
- decimals: TNumber_6uuzwj;
488
- }>, TObject_6obbkd<{
489
- kind: TLiteral_yes1tx<"TOKEN">;
490
- address: TString_4i3c6z;
491
- decimals: TNumber_6uuzwj;
492
- }>]>;
493
- }>;
494
- usd: TNumber_6uuzwj;
495
- }>>;
496
- rift: TOptional_p2zzfw<TObject_6obbkd<{
497
- network: TObject_6obbkd<{
498
- amount: TString_4i3c6z;
499
- currency: TObject_6obbkd<{
500
- chain: TUnion_twkt9h<[TObject_6obbkd<{
501
- kind: TLiteral_yes1tx<"BITCOIN">;
502
- }>, TObject_6obbkd<{
503
- kind: TLiteral_yes1tx<"EVM">;
504
- chainId: TNumber_6uuzwj;
505
- }>]>;
506
- token: TUnion_twkt9h<[TObject_6obbkd<{
507
- kind: TLiteral_yes1tx<"NATIVE">;
508
- decimals: TNumber_6uuzwj;
509
- }>, TObject_6obbkd<{
510
- kind: TLiteral_yes1tx<"TOKEN">;
511
- address: TString_4i3c6z;
512
- decimals: TNumber_6uuzwj;
513
- }>]>;
514
- }>;
515
- usd: TNumber_6uuzwj;
516
- }>;
517
- liquidity: TObject_6obbkd<{
518
- amount: TString_4i3c6z;
519
- currency: TObject_6obbkd<{
520
- chain: TUnion_twkt9h<[TObject_6obbkd<{
521
- kind: TLiteral_yes1tx<"BITCOIN">;
522
- }>, TObject_6obbkd<{
523
- kind: TLiteral_yes1tx<"EVM">;
524
- chainId: TNumber_6uuzwj;
525
- }>]>;
526
- token: TUnion_twkt9h<[TObject_6obbkd<{
527
- kind: TLiteral_yes1tx<"NATIVE">;
528
- decimals: TNumber_6uuzwj;
529
- }>, TObject_6obbkd<{
530
- kind: TLiteral_yes1tx<"TOKEN">;
531
- address: TString_4i3c6z;
532
- decimals: TNumber_6uuzwj;
533
- }>]>;
534
- }>;
535
- usd: TNumber_6uuzwj;
536
- }>;
537
- protocol: TObject_6obbkd<{
538
- amount: TString_4i3c6z;
539
- currency: TObject_6obbkd<{
540
- chain: TUnion_twkt9h<[TObject_6obbkd<{
541
- kind: TLiteral_yes1tx<"BITCOIN">;
542
- }>, TObject_6obbkd<{
543
- kind: TLiteral_yes1tx<"EVM">;
544
- chainId: TNumber_6uuzwj;
545
- }>]>;
546
- token: TUnion_twkt9h<[TObject_6obbkd<{
547
- kind: TLiteral_yes1tx<"NATIVE">;
548
- decimals: TNumber_6uuzwj;
549
- }>, TObject_6obbkd<{
550
- kind: TLiteral_yes1tx<"TOKEN">;
551
- address: TString_4i3c6z;
552
- decimals: TNumber_6uuzwj;
553
- }>]>;
554
- }>;
555
- usd: TNumber_6uuzwj;
556
- }>;
557
- }>>;
558
- postswap: TOptional_p2zzfw<TObject_6obbkd<{
559
- amount: TString_4i3c6z;
560
- currency: TObject_6obbkd<{
561
- chain: TUnion_twkt9h<[TObject_6obbkd<{
562
- kind: TLiteral_yes1tx<"BITCOIN">;
563
- }>, TObject_6obbkd<{
564
- kind: TLiteral_yes1tx<"EVM">;
565
- chainId: TNumber_6uuzwj;
566
- }>]>;
567
- token: TUnion_twkt9h<[TObject_6obbkd<{
568
- kind: TLiteral_yes1tx<"NATIVE">;
569
- decimals: TNumber_6uuzwj;
570
- }>, TObject_6obbkd<{
571
- kind: TLiteral_yes1tx<"TOKEN">;
572
- address: TString_4i3c6z;
573
- decimals: TNumber_6uuzwj;
574
- }>]>;
575
- }>;
576
- usd: TNumber_6uuzwj;
577
- }>>;
578
- totalUsd: TNumber_6uuzwj;
579
- }>;
580
- expiresAt: TString_4i3c6z;
581
- mode: TLiteral_yes1tx<"exact_output">;
582
- }>]>;
583
- declare const SwapRequestSchema: TObject_6obbkd<{
584
- id: TString_4i3c6z;
585
- destinationAddress: TString_4i3c6z;
586
- refundAddress: TString_4i3c6z;
587
- integratorName: TOptional_p2zzfw<TString_4i3c6z>;
588
- approvalMode: TOptional_p2zzfw<TString_4i3c6z>;
589
- }>;
590
- type QuoteRequest2 = Static<typeof QuoteRequestSchema>;
591
- type QuoteResponse2 = Static<typeof QuoteResponseSchema>;
592
- type SwapRequest2 = Static<typeof SwapRequestSchema>;
593
- /** Supported DEX provider identifiers */
594
- type DexProviderId = "oneinch" | "spandex" | "fabric" | "kyberswap" | "lifi" | "relay";
595
- /** Routing preference for quote requests */
596
- type RoutingPreference = "BEST_PRICE" | "FASTEST";
597
- /**
598
- * Shared types between RFQ and OTC APIs.
599
- * These types match the Rust definitions in otc-models crate.
600
- */
601
- type ChainType = "bitcoin" | "ethereum" | "base";
602
- /**
603
- * Token identifier - either native chain token or contract address.
604
- * Uses serde's adjacently tagged representation: { type, data? }
605
- */
606
- type TokenIdentifier2 = {
607
- type: "Native";
608
- } | {
609
- type: "Address";
610
- data: string;
611
- };
612
- interface Currency3 {
613
- chain: ChainType;
614
- token: TokenIdentifier2;
615
- decimals: number;
616
- }
617
- interface Lot2 {
618
- currency: Currency3;
619
- amount: string;
620
- }
621
- /**
622
- * Swap computation mode - determines whether input or output is the fixed value.
623
- * Uses serde's internally tagged representation with amount.
624
- */
625
- type SwapMode = {
626
- type: "exact_input";
627
- amount: number;
628
- } | {
629
- type: "exact_output";
630
- amount: number;
631
- };
632
- /**
633
- * Rate parameters for computing swap fees.
634
- * Basis point fees are additive and applied to the gross input amount.
635
- */
636
- interface SwapRates2 {
637
- /** MM liquidity fee spread in bps (e.g., 13 = 0.13%) */
638
- liquidity_fee_bps: number;
639
- /** Protocol fee spread in bps (e.g., 10 = 0.10%) */
640
- protocol_fee_bps: number;
641
- /** Base gas/network fee in sats*/
642
- network_fee_sats: number;
643
- }
644
- /**
645
- * Fee amounts for a quote (exact quoted amount).
646
- * All values are U256 as decimal strings.
647
- */
648
- interface Fees {
649
- liquidity_fee: string;
650
- protocol_fee: string;
651
- network_fee: string;
652
- }
653
- /**
654
- * A quote that defines the terms for a swap.
655
- *
656
- * Contains:
657
- * - Exact quoted amounts (`from`/`to` lots) for the requested input/output
658
- * - Valid deposit bounds (`min_input`/`max_input`) - user can deposit any amount within
659
- * - Rate parameters (`rates`) to compute realized amounts for any deposit
660
- * - Fee breakdown (`fees`) for the exact quoted amount
661
- */
662
- interface Quote {
663
- id: string;
664
- market_maker_id: string;
665
- /** What the user sends (currency + exact quoted amount) */
666
- from: Lot2;
667
- /** What the user receives (currency + exact quoted amount) */
668
- to: Lot2;
669
- /** Rate parameters used for computation */
670
- rates: SwapRates2;
671
- /** Fee breakdown for the exact quoted amount */
672
- fees: Fees;
673
- /** Minimum input amount allowed (in from currency smallest unit) */
674
- min_input: string;
675
- /** Maximum input amount allowed (in from currency smallest unit) */
676
- max_input: string;
677
- /** Optional affiliate identifier that determined the protocol fee rate */
678
- affiliate?: string;
679
- expires_at: string;
680
- created_at: string;
681
- }
682
- interface QuoteRequest3 {
683
- from: Currency3;
684
- to: Currency3;
685
- /** Swap mode: exact_input or exact_output with the specified amount */
686
- mode: SwapMode;
687
- /** Optional affiliate identifier for custom protocol fee rates */
688
- affiliate?: string;
689
- }
690
- type SwapStatus2 = "waiting_user_deposit_initiated" | "waiting_user_deposit_confirmed" | "waiting_mm_deposit_initiated" | "waiting_mm_deposit_confirmed" | "settled" | "refunding_user" | "failed";
691
- type RefundSwapReason = "UserInitiatedEarlyRefund" | "MarketMakerNeverInitiatedDeposit" | "MarketMakerDepositNeverConfirmed" | "UserInitiatedRefundAgain";
692
- /** Computed amounts when user deposit is detected and validated */
693
- interface RealizedSwap2 {
694
- /** Actual amount the user deposited */
695
- user_input: string;
696
- /** Amount the MM must send to the user */
697
- mm_output: string;
698
- /** Protocol's cut (collected during settlement) */
699
- protocol_fee: string;
700
- /** MM's spread/profit */
701
- liquidity_fee: string;
702
- /** Fixed gas/network costs */
703
- network_fee: string;
704
- }
705
- /** Status of user's deposit */
706
- interface UserDepositStatus2 {
707
- tx_hash: string;
708
- amount: string;
709
- deposit_detected_at: string;
710
- confirmations: number;
711
- last_checked: string;
712
- confirmed_at?: string;
713
- }
714
- /** Status of market maker's deposit */
715
- interface MMDepositStatus2 {
716
- tx_hash: string;
717
- amount: string;
718
- deposit_detected_at: string;
719
- confirmations: number;
720
- last_checked: string;
721
- }
722
- /** Status of settlement */
723
- interface SettlementStatus2 {
724
- tx_hash: string;
725
- broadcast_at: string;
726
- confirmations: number;
727
- completed_at?: string;
728
- fee?: string;
729
- }
730
- /** Latest refund information */
731
- interface LatestRefund2 {
732
- timestamp: string;
733
- recipient_address: string;
734
- }
735
- /** Full swap object returned by the API */
736
- interface Swap2 {
737
- id: string;
738
- market_maker_id: string;
739
- /** The rate-based quote for this swap */
740
- quote: Quote;
741
- metadata: Metadata;
742
- /** Realized amounts computed when user deposit is detected */
743
- realized?: RealizedSwap2;
744
- /** Salt for deterministic wallet generation (64 hex characters, no 0x prefix) */
745
- deposit_vault_salt: string;
746
- /** Cached deposit vault address */
747
- deposit_vault_address: string;
748
- /** Nonce for the market maker to embed in their payment address (32 hex characters, no 0x prefix) */
749
- mm_nonce: string;
750
- /** Destination address for receiving funds */
751
- destination_address: string;
752
- /** Refund address */
753
- refund_address: string;
754
- /** Core status */
755
- status: SwapStatus2;
756
- /** Deposit tracking */
757
- user_deposit_status?: UserDepositStatus2;
758
- mm_deposit_status?: MMDepositStatus2;
759
- /** Settlement tracking */
760
- settlement_status?: SettlementStatus2;
761
- /** Refund tracking */
762
- latest_refund?: LatestRefund2;
763
- /** Failure/timeout tracking */
764
- failure_reason?: string;
765
- failure_at?: string;
766
- /** MM coordination */
767
- mm_notified_at?: string;
768
- mm_private_key_sent_at?: string;
769
- created_at: string;
770
- updated_at: string;
771
- }
772
- interface Metadata {
773
- start_asset?: string;
774
- end_asset?: string;
775
- integrator_name?: string;
776
- }
777
- interface BaseClientConfig {
778
- baseUrl: string;
779
- timeout?: number;
780
- /** Optional headers to include with every request */
781
- defaultHeaders?: Record<string, string>;
782
- }
783
- /** Unwrapped quote response for convenience (quote is extracted from Result) */
784
- interface QuoteResponse3 {
785
- request_id: string;
786
- quote: Quote;
787
- /** Raw JSON string of the quote, preserved for hash-sensitive operations */
788
- quoteRawJson: string;
789
- total_quotes_received: number;
790
- market_makers_contacted: number;
791
- }
792
- interface RfqStatus2 {
793
- status: string;
794
- version: string;
795
- connected_market_makers: string[];
796
- }
797
- /**
798
- * Liquidity information for a specific trading pair
799
- */
800
- interface TradingPairLiquidity {
801
- from: Currency3;
802
- to: Currency3;
803
- /** Maximum from_amount the MM can handle */
804
- max_amount: string;
805
- }
806
- interface MarketMakerLiquidity {
807
- market_maker_id: string;
808
- trading_pairs: TradingPairLiquidity[];
809
- }
810
- interface LiquidityResponse {
811
- market_makers: MarketMakerLiquidity[];
812
- timestamp: string;
813
- }
814
- /** Optional screening headers for address risk checks */
815
- interface ScreeningHeaders {
816
- userAddress?: string;
817
- destinationAddress?: string;
818
- }
819
- /**
820
- * TypeScript client for the RFQ server API (v2)
821
- * Provides access to quote aggregation and market maker information
822
- */
823
- declare class RfqClient2 {
824
- private readonly baseUrl;
825
- private readonly timeout;
826
- private readonly headers;
827
- constructor(config: BaseClientConfig);
828
- private fetchAttempt;
829
- private fetchWithRetry;
830
- /** Get server status and version information */
831
- getStatus(): Promise<RfqStatus2>;
832
- /**
833
- * Request quotes from connected market makers.
834
- * Unwraps the RFQResult and throws on non-success responses.
835
- * Preserves the raw quote JSON to avoid hash mismatches when forwarding to OTC.
836
- */
837
- requestQuote(request: QuoteRequest3, screeningHeaders?: ScreeningHeaders): Promise<QuoteResponse3>;
838
- /**
839
- * Extract the exact raw quote JSON substring from the response text.
840
- * Preserves the original formatting/ordering to maintain hash consistency.
841
- */
842
- private extractQuoteJson;
843
- /** Get liquidity information from all market makers */
844
- getLiquidity(): Promise<LiquidityResponse>;
845
- /** Health check endpoint */
846
- healthCheck(): Promise<boolean>;
847
- /** Get count of connected market makers */
848
- getConnectedMarketMakersCount(): Promise<number>;
849
- }
850
- /** Request to create a new swap from a quote */
851
- interface CreateSwapRequest {
852
- /** The quote to create a swap from */
853
- quote: Quote;
854
- /** Destination address for receiving funds */
855
- destination_address: string;
856
- /** Legacy field name expected by OTC (kept for compatibility) */
857
- user_destination_address?: string;
858
- /** Refund address for receiving their "from" currency if the swap fails */
859
- refund_address: string;
860
- /** Optional metadata describing the swap source */
861
- metadata?: Metadata;
862
- }
863
- /** Request to create a new swap using raw quote JSON (preserves hash) */
864
- interface CreateSwapRequestRaw {
865
- /** Raw JSON string of the quote, exactly as received from RFQ */
866
- quoteRawJson: string;
867
- /** Destination address for receiving funds */
868
- destination_address: string;
869
- /** Legacy field name expected by OTC (kept for compatibility) */
870
- user_destination_address?: string;
871
- /** Refund address for receiving their "from" currency if the swap fails */
872
- refund_address: string;
873
- /** Optional metadata describing the swap source */
874
- metadata?: Metadata;
875
- }
876
- /** Response after refunding a swap */
877
- interface RefundSwapResponse {
878
- /** The refunded swap ID */
879
- swap_id: string;
880
- /** The reason the refund was allowed */
881
- reason: RefundSwapReason;
882
- /** The "ready to be broadcast" signed transaction data as a hex string */
883
- tx_data: string;
884
- /** The chain the transaction needs to be broadcast on */
885
- tx_chain: ChainType;
886
- }
887
- /** Response for chain tip block hash */
888
- interface BlockHashResponse {
889
- block_hash: string;
890
- }
891
- /** List of suspended market makers */
892
- interface SuspendedMarketMakersResponse {
893
- suspended_market_makers: string[];
894
- }
895
- /** OTC server status */
896
- interface OtcStatus2 {
897
- status: string;
898
- version: string;
899
- connected_market_makers: string[];
900
- }
901
- /** TDX quote response from dstack */
902
- interface TdxQuoteResponse {
903
- quote: string;
904
- }
905
- /** TDX info response from dstack */
906
- interface TdxInfoResponse {
907
- version: string;
908
- attestation_enabled: boolean;
909
- }
910
- /**
911
- * TypeScript client for the OTC server API (v2)
912
- * Provides access to swap creation, monitoring, and chain information
913
- */
914
- declare class OtcClient2 {
915
- private readonly baseUrl;
916
- private readonly timeout;
917
- private readonly headers;
918
- constructor(config: BaseClientConfig);
919
- private fetchAttempt;
920
- private fetchWithRetry;
921
- /** Get server status and version information */
922
- getStatus(): Promise<OtcStatus2>;
923
- /** Create a new swap from a quote */
924
- createSwap(request: CreateSwapRequest): Promise<Swap2>;
925
- /**
926
- * Create a new swap using raw quote JSON.
927
- * Parses the raw quote JSON into a structured body for the OTC API.
928
- */
929
- createSwapWithRawQuote(request: CreateSwapRequestRaw): Promise<Swap2>;
930
- /** Get swap status and details */
931
- getSwap(swapId: string): Promise<Swap2>;
932
- /** Request a refund for a swap */
933
- refundSwap(swapId: string): Promise<RefundSwapResponse>;
934
- /** Get the latest Bitcoin block hash */
935
- getBitcoinTip(): Promise<BlockHashResponse>;
936
- /** Get the latest Ethereum block hash */
937
- getEthereumTip(): Promise<BlockHashResponse>;
938
- /** Get the latest Base block hash */
939
- getBaseTip(): Promise<BlockHashResponse>;
940
- /** Get block hash for a specific chain */
941
- getChainTip(chain: ChainType): Promise<BlockHashResponse>;
942
- /** Get list of suspended market makers */
943
- getSuspendedMarketMakers(): Promise<SuspendedMarketMakersResponse>;
944
- /** Get TDX attestation quote */
945
- getTdxQuote(challengeHex: string): Promise<TdxQuoteResponse>;
946
- /** Get TDX info */
947
- getTdxInfo(): Promise<TdxInfoResponse>;
948
- /** Health check endpoint */
949
- healthCheck(): Promise<boolean>;
950
- /**
951
- * Poll a swap until it reaches a terminal state or timeout.
952
- * Returns the final swap.
953
- */
954
- pollSwapUntilComplete(swapId: string, options?: {
955
- pollIntervalMs?: number;
956
- maxWaitMs?: number;
957
- onStatusChange?: (status: SwapStatus2) => void;
958
- }): Promise<Swap2>;
959
- }
960
- /**
961
- * Swapper API Client
962
- * Single-file, zero-dependency TypeScript client for the TEE Swapper API
963
- */
964
- type SupportedChainId = 1 | 8453;
965
- type TokenAddress = `0x${string}`;
966
- type Token = {
967
- type: "erc20";
968
- address: TokenAddress;
969
- } | {
970
- type: "ether";
971
- };
972
- type SwapStatus3 = "pending_deposit" | "executing" | "complete" | "failed" | "expired" | "refund_pending" | "refunded";
973
- interface QuoteRequest4 {
974
- chainId: SupportedChainId;
975
- buyToken: Token;
976
- sellAmount: string;
977
- }
978
- interface CreateSwapRequest2 {
979
- chainId: SupportedChainId;
980
- buyToken: Token;
981
- recipientAddress: TokenAddress;
982
- refundAddress: TokenAddress;
983
- }
984
- interface HealthResponse2 {
985
- status: "ok";
986
- timestamp: number;
987
- }
988
- interface QuoteResponse4 {
989
- quoteId: string;
990
- chainId: SupportedChainId;
991
- buyToken: Token;
992
- sellAmount: string;
993
- buyAmountEstimate: string;
994
- expiresAt: number;
995
- canFill: boolean;
996
- }
997
- interface QuoteErrorResponse {
998
- error: string;
999
- canFill: false;
1000
- }
1001
- interface CreateSwapResponse {
1002
- swapId: string;
1003
- vaultAddress: TokenAddress;
1004
- chainId: SupportedChainId;
1005
- buyToken: Token;
1006
- recipientAddress: TokenAddress;
1007
- refundAddress: TokenAddress;
1008
- expiresAt: number;
1009
- status: SwapStatus3;
1010
- }
1011
- interface SwapStatusResponse2 {
1012
- swapId: string;
1013
- chainId: SupportedChainId;
1014
- vaultAddress: TokenAddress;
1015
- buyToken: Token;
1016
- recipientAddress: TokenAddress;
1017
- refundAddress: TokenAddress;
1018
- status: SwapStatus3;
1019
- createdAt: number;
1020
- expiresAt: number;
1021
- depositTxHash?: string;
1022
- depositAmount?: string;
1023
- settlementTxHash?: string;
1024
- actualBuyAmount?: string;
1025
- failureReason?: string;
1026
- refundTxHash?: string;
1027
- refundAmount?: string;
1028
- }
1029
- interface SwapperClientOptions {
1030
- /** Base URL of the swapper API (e.g., "https://swapper.example.com") */
1031
- baseUrl: string;
1032
- /** Optional fetch implementation (defaults to global fetch) */
1033
- fetch?: typeof fetch;
1034
- /** Optional headers to include with every request */
1035
- headers?: Record<string, string>;
1036
- }
1037
- declare class SwapperClient {
1038
- private readonly baseUrl;
1039
- private readonly fetch;
1040
- private readonly headers;
1041
- constructor(options: SwapperClientOptions);
1042
- private request;
1043
- /**
1044
- * Check API health status
1045
- */
1046
- health(): Promise<HealthResponse2>;
1047
- /**
1048
- * Get a quote for swapping CBBTC to another token
1049
- *
1050
- * @param request - Quote parameters
1051
- * @returns Quote with estimated output amount, or error if quote unavailable
1052
- */
1053
- quote(request: QuoteRequest4): Promise<QuoteResponse4 | QuoteErrorResponse>;
1054
- /**
1055
- * Create a new swap
1056
- *
1057
- * @param request - Swap parameters including chain, token, and addresses
1058
- * @returns Swap details including the vault address to deposit CBBTC to
1059
- */
1060
- createSwap(request: CreateSwapRequest2): Promise<CreateSwapResponse>;
1061
- /**
1062
- * Get the current status of a swap
1063
- *
1064
- * @param swapId - The swap ID returned from createSwap
1065
- * @returns Current swap status and details
1066
- * @throws SwapperClientError with status 404 if swap not found
1067
- */
1068
- getSwapStatus(swapId: string): Promise<SwapStatusResponse2>;
1069
- /**
1070
- * Poll for swap completion
1071
- *
1072
- * @param swapId - The swap ID to poll
1073
- * @param options - Polling options
1074
- * @returns Final swap status when complete, failed, expired, or refunded
1075
- */
1076
- waitForSwap(swapId: string, options?: {
1077
- /** Polling interval in milliseconds (default: 5000) */
1078
- intervalMs?: number;
1079
- /** Maximum time to wait in milliseconds (default: 600000 / 10 minutes) */
1080
- timeoutMs?: number;
1081
- /** Callback on each poll */
1082
- onPoll?: (status: SwapStatusResponse2) => void;
1083
- }): Promise<SwapStatusResponse2>;
1084
- }
1085
- /**
1086
- * Data needed to create a Swapper swap from a cached chained quote.
1087
- */
1088
- interface ChainedSwapQuoteData {
1089
- chainId: SupportedChainId;
1090
- buyToken: Token;
1091
- buyTokenDecimals: number;
1092
- sellAmount: string;
1093
- buyAmountEstimate: string;
1094
- expiresAt: number;
1095
- }
1096
- /**
1097
- * Data needed to create a DEX preswap for ERC20 → BTC.
1098
- */
1099
- interface DexPreswapQuoteData {
1100
- provider: DexProviderId;
1101
- /** Underlying spanDEX provider (e.g. kyberswap) when provider is spandex */
1102
- subprovider?: string;
1103
- /** Analytics-friendly label (e.g. spandex.kyberswap) */
1104
- providerLabel?: string;
1105
- chainId: number;
1106
- sellToken: string;
1107
- buyToken: string;
1108
- sellAmount: string;
1109
- buyAmountMin: string;
1110
- buyAmountEstimate: string;
1111
- slippageBps: number;
1112
- routingPreference?: RoutingPreference;
1113
- }
1114
- /**
1115
- * Data needed to create a mono-chain DEX swap for EVM → EVM swaps.
1116
- */
1117
- interface DexMonochainQuoteData {
1118
- provider: DexProviderId;
1119
- /** Underlying spanDEX provider (e.g. kyberswap) when provider is spandex */
1120
- subprovider?: string;
1121
- /** Analytics-friendly label (e.g. spandex.kyberswap) */
1122
- providerLabel?: string;
1123
- chainId: number;
1124
- sellToken: string;
1125
- buyToken: string;
1126
- sellAmount: string;
1127
- buyAmountMin: string;
1128
- buyAmountEstimate: string;
1129
- slippageBps: number;
1130
- routingPreference?: RoutingPreference;
1131
- }
1132
- /**
1133
- * Cached quote entry containing both the parsed object and raw JSON.
1134
- * The raw JSON is preserved to avoid hash mismatches when forwarding to OTC.
1135
- * For mono-chain swaps, quote and rawJson are empty placeholders since there's no OTC involved.
1136
- */
1137
- interface CachedQuote {
1138
- /** Parsed quote object for inspection (empty for mono-chain swaps) */
1139
- quote: Quote;
1140
- /** Raw JSON string exactly as received from RFQ server (empty for mono-chain swaps) */
1141
- rawJson: string;
1142
- /** Normalized quote response matching /quote output */
1143
- normalizedQuote?: QuoteResponse;
1144
- /** Swapper quote data for chained swaps (BTC → non-cbBTC ERC-20) */
1145
- chainedSwap?: ChainedSwapQuoteData;
1146
- /** DEX preswap data for ERC20 → BTC swaps */
1147
- dexPreswap?: DexPreswapQuoteData;
1148
- /** DEX swap data for mono-chain EVM → EVM swaps */
1149
- dexMonochain?: DexMonochainQuoteData;
1150
- /** Legacy field kept for backward compatibility */
1151
- oneinchSwap?: DexMonochainQuoteData;
1152
- }
1153
- /**
1154
- * Metadata for chained swaps needed to transform responses.
1155
- */
1156
- interface ChainedSwapMetadata {
1157
- swapperSwapId: string;
1158
- /** Actual ERC-20 destination (not the Swapper vault) */
1159
- destination: string;
1160
- /** Final token the user receives */
1161
- finalToken: {
1162
- chainId: number;
1163
- address: string;
1164
- decimals: number;
1165
- };
1166
- /** Estimated amount of final token */
1167
- buyAmountEstimate: string;
1168
- }
1169
- /**
1170
- * Metadata for DEX preswap swaps (ERC20 → BTC).
1171
- */
1172
- interface DexPreswapMetadata {
1173
- /** Chosen DEX provider */
1174
- provider: DexProviderId;
1175
- /** Underlying spanDEX provider selected at quote time */
1176
- subprovider?: string;
1177
- /** Analytics-friendly label selected at quote time */
1178
- providerLabel?: string;
1179
- /** The sell token address */
1180
- sellToken: string;
1181
- /** Chain ID for the preswap */
1182
- chainId: number;
1183
- /** Optional DEX swap tx hash (best-effort analytics) */
1184
- swapTxHash?: string;
1185
- /** Expected DEX swap transaction (for callback validation) */
1186
- expectedSwapTx?: OneInchExpectedSwapTx;
1187
- /** Underlying spanDEX provider selected at execution time */
1188
- executionSubprovider?: string;
1189
- /** Analytics-friendly execution label (e.g. spandex.kyberswap) */
1190
- executionProviderLabel?: string;
1191
- }
1192
- /**
1193
- * Metadata for DEX mono-chain swaps (EVM → EVM).
1194
- */
1195
- interface DexMonochainMetadata {
1196
- /** Chosen DEX provider */
1197
- provider: DexProviderId;
1198
- /** Underlying spanDEX provider selected at quote time */
1199
- subprovider?: string;
1200
- /** Analytics-friendly label selected at quote time */
1201
- providerLabel?: string;
1202
- /** The sell token address */
1203
- sellToken: string;
1204
- /** Chain ID for the swap */
1205
- chainId: number;
1206
- /** Optional DEX swap tx hash (best-effort analytics) */
1207
- swapTxHash?: string;
1208
- /** Expected DEX swap transaction (for callback validation) */
1209
- expectedSwapTx?: OneInchExpectedSwapTx;
1210
- /** Timestamp when swap transaction was confirmed on-chain */
1211
- swapConfirmedAt?: string;
1212
- /** Timestamp when swap transaction was confirmed failed */
1213
- swapFailedAt?: string;
1214
- /** Underlying spanDEX provider selected at execution time */
1215
- executionSubprovider?: string;
1216
- /** Analytics-friendly execution label (e.g. spandex.kyberswap) */
1217
- executionProviderLabel?: string;
1218
- }
1219
- /**
1220
- * Legacy metadata shape for oneinch_monochain records created before provider was persisted.
1221
- */
1222
- type LegacyOneInchMonochainMetadata = Omit<DexMonochainMetadata, "provider"> & Partial<Pick<DexMonochainMetadata, "provider">>;
1223
- interface OneInchExpectedSwapTx {
1224
- chainId: number;
1225
- from: string;
1226
- to: string;
1227
- data: string;
1228
- value: string;
1229
- }
1230
- interface OrderStatusMetadata {
1231
- destinationAddress: string;
1232
- quote: QuoteResponse;
1233
- }
1234
- /**
1235
- * Mapping stored for each swap to track its type and related data.
1236
- */
1237
- type SwapMapping = ({
1238
- type: "direct";
1239
- } & OrderStatusMetadata) | ({
1240
- type: "chained";
1241
- } & ChainedSwapMetadata & OrderStatusMetadata) | ({
1242
- type: "dex_preswap";
1243
- } & DexPreswapMetadata & OrderStatusMetadata) | ({
1244
- type: "oneinch_preswap";
1245
- } & DexPreswapMetadata & OrderStatusMetadata) | ({
1246
- type: "dex_monochain";
1247
- } & DexMonochainMetadata & OrderStatusMetadata) | ({
1248
- type: "oneinch_monochain";
1249
- } & LegacyOneInchMonochainMetadata & OrderStatusMetadata);
1250
- /**
1251
- * Store for swap mappings (OTC swap ID → swap type + Swapper swap ID).
1252
- */
1253
- interface ISwapMappingStore {
1254
- get(otcSwapId: string): Promise<SwapMapping | null>;
1255
- set(otcSwapId: string, mapping: SwapMapping): Promise<void>;
1256
- delete(otcSwapId: string): Promise<void>;
1257
- }
1258
- interface IQuoteCache {
1259
- get(id: string): Promise<CachedQuote | null>;
1260
- /** Atomically fetch and delete a quote to prevent reuse */
1261
- consume(id: string): Promise<CachedQuote | null>;
1262
- /** Store quote with its raw JSON representation and optional extension data */
1263
- set(id: string, quote: Quote, rawJson: string, options?: {
1264
- normalizedQuote?: QuoteResponse;
1265
- chainedSwap?: ChainedSwapQuoteData;
1266
- dexPreswap?: DexPreswapQuoteData;
1267
- dexMonochain?: DexMonochainQuoteData;
1268
- oneinchSwap?: DexMonochainQuoteData;
1269
- }): Promise<void>;
1270
- delete(id: string): Promise<void>;
1271
- /** Graceful shutdown - close underlying connections */
1272
- close(): Promise<void>;
1273
- /** Health check for readiness probes */
1274
- ping(): Promise<boolean>;
1275
- }
1276
- /**
1277
- * Pure order service - no framework dependencies.
1278
- * Handles order creation and retrieval via OTC client.
1279
- * Returns execution steps that the client must execute.
1280
- */
1281
- declare class OrderService {
1282
- private readonly otcClient;
1283
- private readonly swapperClient;
1284
- private readonly swapMappingStore;
1285
- private readonly spandexProvider;
1286
- private readonly dexRouter;
1287
- constructor(otcClient: OtcClient2, swapperClient: SwapperClient | null, swapMappingStore: ISwapMappingStore);
1288
- /**
1289
- * Create a swap using the cached quote with raw JSON.
1290
- * Returns SwapResponse with execution steps the client must execute.
1291
- */
1292
- createSwap(request: SwapRequest2, cachedQuote: CachedQuote): Promise<SwapResponse>;
1293
- /**
1294
- * Create a direct cbBTC ↔ BTC swap order.
1295
- * Returns execution steps: either DepositBtc (for BTC → cbBTC) or Approval + DepositEvm (for cbBTC → BTC)
1296
- */
1297
- private createDirectSwapOrder;
1298
- /**
1299
- * Create a chained swap order: BTC → cbBTC → ERC20.
1300
- * Returns execution steps: DepositBtc (server handles the rest)
1301
- */
1302
- private createChainedSwapOrder;
1303
- /**
1304
- * Create a DEX preswap order: ERC20 → cbBTC → BTC.
1305
- * Returns execution steps: Approval + DEX swap tx.
1306
- */
1307
- private createDexPreswapOrder;
1308
- /**
1309
- * Create a mono-chain swap order: EVM → EVM via selected DEX provider.
1310
- * Returns execution steps: Approval (if needed) + DEX swap tx.
1311
- */
1312
- private createDexMonochainOrder;
1313
- /**
1314
- * Build steps for BTC transfer (BTC → cbBTC or BTC → ERC20).
1315
- */
1316
- private buildBtcTransferSteps;
1317
- /**
1318
- * Build steps for cbBTC transfer (cbBTC → BTC).
1319
- * No approval needed - just a direct ERC20 transfer.
1320
- */
1321
- private buildCbbtcTransferSteps;
1322
- private buildDexSwapStep;
1323
- /**
1324
- * Legacy provider IDs now route through spanDEX.
1325
- * Keeps older cached quotes executable after migration.
1326
- */
1327
- private resolveExecutionProvider;
1328
- private resolveExecutionSubprovider;
1329
- /**
1330
- * Select the first swap candidate that passes on-chain simulation.
1331
- * This runs in /swap flow only (never in /quote).
1332
- */
1333
- private selectSimulatedSwapTxCandidate;
1334
- private simulateSwapTx;
1335
- private buildAllowanceStateOverride;
1336
- private computeAllowanceStateSlots;
1337
- private isStateOverrideUnsupported;
1338
- private formatSimulationError;
1339
- private describeSwapCandidate;
1340
- /**
1341
- * Build steps for DEX preswap (ERC20/ETH → cbBTC → BTC).
1342
- */
1343
- private buildDexPreswapSteps;
1344
- /**
1345
- * Build steps for mono-chain DEX swap (EVM → EVM).
1346
- */
1347
- private buildDexMonochainSteps;
1348
- private resolveEvmSenderAddress;
1349
- private isEvmAddress;
1350
- private extractExpectedDexSwap;
1351
- private isNativeToken;
1352
- private getTxConfirmationStatus;
1353
- /**
1354
- * Update a swap with step execution result (best-effort tx hash tracking).
1355
- */
1356
- updateStepResult(swapId: string, _stepId: string, result: {
1357
- txHash?: string;
1358
- }): Promise<void>;
1359
- /**
1360
- * Get user-facing order status without exposing internal swap details.
1361
- */
1362
- getSwapStatus(swapId: string): Promise<SwapStatusResponse>;
1363
- private resolveOrderStatusMetadata;
1364
- private getOtcDepositTx;
1365
- private getOtcSettlementTx;
1366
- private getOtcPayoutTx;
1367
- private normalizeTxHash;
1368
- private isEvmChain;
1369
- }
1370
- /**
1371
- * Pure quote service - no framework dependencies.
1372
- * Handles quote generation and caching.
1373
- */
1374
- declare class QuoteService {
1375
- private readonly quoteCache;
1376
- private readonly rfqClient;
1377
- private readonly swapperClient;
1378
- private readonly priceOracle;
1379
- private readonly dexPreswapRouter;
1380
- constructor(quoteCache: IQuoteCache, rfqClient: RfqClient2, swapperClient: SwapperClient | null);
1381
- getQuote(request: QuoteRequest2): Promise<QuoteResponse2>;
1382
- /** Get the cached quote with raw JSON for order creation */
1383
- getCachedQuoteById(id: string): Promise<CachedQuote | null>;
1384
- /** Atomically consume a cached quote to prevent reuse */
1385
- consumeCachedQuoteById(id: string): Promise<CachedQuote | null>;
1386
- private generateQuote;
1387
- /**
1388
- * Quote a direct BTC <-> cbBTC swap via Rift OTC.
1389
- */
1390
- private quoteDirectOtcSwap;
1391
- /**
1392
- * Quote a chained swap: BTC -> cbBTC (OTC) -> target ERC-20 (Swapper).
1393
- *
1394
- * 1. Get OTC quote for BTC -> cbBTC on target chain
1395
- * 2. Get Swapper quote for cbBTC -> target token
1396
- * 3. Cache both quotes linked together
1397
- * 4. Return combined quote showing BTC -> target token
1398
- */
1399
- private quoteChainedSwap;
1400
- /**
1401
- * Quote a mono-chain EVM → EVM swap via DEX router.
1402
- */
1403
- private quoteDexMonochain;
1404
- /**
1405
- * Quote a DEX preswap: non-cbBTC ERC20 -> cbBTC (DEX) -> BTC (Rift OTC).
1406
- *
1407
- * 1. Get best DEX quote for ERC20 -> cbBTC
1408
- * 2. Get OTC quote for cbBTC -> BTC
1409
- * 3. Cache both quotes linked together
1410
- * 4. Return combined quote showing ERC20 -> BTC
1411
- */
1412
- private quoteDexPreswapThenRift;
1413
- /**
1414
- * exact_input: ERC20 (known) -> cbBTC -> BTC (calculated)
1415
- */
1416
- private quoteDexPreswapThenRiftExactInput;
1417
- /**
1418
- * exact_output: ERC20 (calculated) -> cbBTC -> BTC (known)
1419
- */
1420
- private quoteDexPreswapThenRiftExactOutput;
1421
- }
1422
- import { TModule as TModule_7fcqhs } from "@sinclair/typebox";
1423
- declare const app: Elysia<"", {
1424
- decorator: {
1425
- quoteService: QuoteService;
1426
- } & {
1427
- orderService: OrderService;
1428
- } & {
1429
- rfqClient: exports_index_d.RfqClient;
1430
- } & {
1431
- otcClient: exports_index_d.OtcClient;
1432
- };
1433
- store: {};
1434
- derive: {};
1435
- resolve: {};
1436
- }, {
1437
- typebox: {};
1438
- error: {};
1439
- } & {
1440
- typebox: {};
1441
- error: {};
1442
- } & {
1443
- error: {};
1444
- typebox: TModule_7fcqhs<{}, {}>;
1445
- } & {
1446
- typebox: {};
1447
- error: {};
1448
- }, {
1449
- schema: {};
1450
- standaloneSchema: {};
1451
- macro: {};
1452
- macroFn: {};
1453
- parser: {};
1454
- response: {};
1455
- } & {
1456
- schema: {};
1457
- standaloneSchema: {};
1458
- macro: {};
1459
- macroFn: {};
1460
- parser: {};
1461
- response: {};
1462
- } & {
1463
- schema: {};
1464
- macro: {};
1465
- macroFn: {};
1466
- parser: {};
1467
- } & {
1468
- schema: {};
1469
- standaloneSchema: {};
1470
- macro: {};
1471
- macroFn: {};
1472
- parser: {};
1473
- }, {
1474
- health: {
1475
- get: {
1476
- body: unknown;
1477
- params: {};
1478
- query: unknown;
1479
- headers: unknown;
1480
- response: {
1481
- 200: {
1482
- status: "ok";
1483
- timestamp: string;
1484
- };
1485
- 422: {
1486
- type: "validation";
1487
- on: string;
1488
- summary?: string;
1489
- message?: string;
1490
- found?: unknown;
1491
- property?: string;
1492
- expected?: string;
1493
- };
1494
- };
1495
- };
1496
- };
1497
- } & {
1498
- status: {
1499
- get: {
1500
- body: unknown;
1501
- params: {};
1502
- query: unknown;
1503
- headers: unknown;
1504
- response: {
1505
- 200: {
1506
- status: "ok" | "offline" | "degraded";
1507
- timestamp: string;
1508
- services: {
1509
- rfq: {
1510
- error?: string | undefined;
1511
- version?: string | undefined;
1512
- status: "ok" | "offline" | "degraded";
1513
- connectedMarketMakers: number;
1514
- };
1515
- otc: {
1516
- error?: string | undefined;
1517
- version?: string | undefined;
1518
- status: "ok" | "offline" | "degraded";
1519
- connectedMarketMakers: number;
1520
- };
1521
- };
1522
- };
1523
- 422: {
1524
- type: "validation";
1525
- on: string;
1526
- summary?: string;
1527
- message?: string;
1528
- found?: unknown;
1529
- property?: string;
1530
- expected?: string;
1531
- };
1532
- };
1533
- };
1534
- };
1535
- } & {
1536
- quote: {
1537
- post: {
1538
- body: {
1539
- quoteQuality?: string | undefined;
1540
- amount: string;
1541
- type: string;
1542
- from: {
1543
- chain: {
1544
- kind: "BITCOIN";
1545
- } | {
1546
- kind: "EVM";
1547
- chainId: number;
1548
- };
1549
- token: {
1550
- kind: "NATIVE";
1551
- decimals: number;
1552
- } | {
1553
- kind: "TOKEN";
1554
- decimals: number;
1555
- address: string;
1556
- };
1557
- };
1558
- to: {
1559
- chain: {
1560
- kind: "BITCOIN";
1561
- } | {
1562
- kind: "EVM";
1563
- chainId: number;
1564
- };
1565
- token: {
1566
- kind: "NATIVE";
1567
- decimals: number;
1568
- } | {
1569
- kind: "TOKEN";
1570
- decimals: number;
1571
- address: string;
1572
- };
1573
- };
1574
- slippageBps: number;
1575
- };
1576
- params: {};
1577
- query: unknown;
1578
- headers: unknown;
1579
- response: {
1580
- 200: {
1581
- from: {
1582
- currency: {
1583
- chain: {
1584
- kind: "BITCOIN";
1585
- } | {
1586
- kind: "EVM";
1587
- chainId: number;
1588
- };
1589
- token: {
1590
- kind: "NATIVE";
1591
- decimals: number;
1592
- } | {
1593
- kind: "TOKEN";
1594
- decimals: number;
1595
- address: string;
1596
- };
1597
- };
1598
- expected: string;
1599
- };
1600
- to: {
1601
- minimum?: string | undefined;
1602
- currency: {
1603
- chain: {
1604
- kind: "BITCOIN";
1605
- } | {
1606
- kind: "EVM";
1607
- chainId: number;
1608
- };
1609
- token: {
1610
- kind: "NATIVE";
1611
- decimals: number;
1612
- } | {
1613
- kind: "TOKEN";
1614
- decimals: number;
1615
- address: string;
1616
- };
1617
- };
1618
- expected: string;
1619
- };
1620
- mode: "exact_input";
1621
- id: string;
1622
- fees: {
1623
- preswap?: {
1624
- currency: {
1625
- chain: {
1626
- kind: "BITCOIN";
1627
- } | {
1628
- kind: "EVM";
1629
- chainId: number;
1630
- };
1631
- token: {
1632
- kind: "NATIVE";
1633
- decimals: number;
1634
- } | {
1635
- kind: "TOKEN";
1636
- decimals: number;
1637
- address: string;
1638
- };
1639
- };
1640
- amount: string;
1641
- usd: number;
1642
- } | undefined;
1643
- rift?: {
1644
- network: {
1645
- currency: {
1646
- chain: {
1647
- kind: "BITCOIN";
1648
- } | {
1649
- kind: "EVM";
1650
- chainId: number;
1651
- };
1652
- token: {
1653
- kind: "NATIVE";
1654
- decimals: number;
1655
- } | {
1656
- kind: "TOKEN";
1657
- decimals: number;
1658
- address: string;
1659
- };
1660
- };
1661
- amount: string;
1662
- usd: number;
1663
- };
1664
- liquidity: {
1665
- currency: {
1666
- chain: {
1667
- kind: "BITCOIN";
1668
- } | {
1669
- kind: "EVM";
1670
- chainId: number;
1671
- };
1672
- token: {
1673
- kind: "NATIVE";
1674
- decimals: number;
1675
- } | {
1676
- kind: "TOKEN";
1677
- decimals: number;
1678
- address: string;
1679
- };
1680
- };
1681
- amount: string;
1682
- usd: number;
1683
- };
1684
- protocol: {
1685
- currency: {
1686
- chain: {
1687
- kind: "BITCOIN";
1688
- } | {
1689
- kind: "EVM";
1690
- chainId: number;
1691
- };
1692
- token: {
1693
- kind: "NATIVE";
1694
- decimals: number;
1695
- } | {
1696
- kind: "TOKEN";
1697
- decimals: number;
1698
- address: string;
1699
- };
1700
- };
1701
- amount: string;
1702
- usd: number;
1703
- };
1704
- } | undefined;
1705
- postswap?: {
1706
- currency: {
1707
- chain: {
1708
- kind: "BITCOIN";
1709
- } | {
1710
- kind: "EVM";
1711
- chainId: number;
1712
- };
1713
- token: {
1714
- kind: "NATIVE";
1715
- decimals: number;
1716
- } | {
1717
- kind: "TOKEN";
1718
- decimals: number;
1719
- address: string;
1720
- };
1721
- };
1722
- amount: string;
1723
- usd: number;
1724
- } | undefined;
1725
- totalUsd: number;
1726
- };
1727
- expiresAt: string;
1728
- } | {
1729
- from: {
1730
- maximum?: string | undefined;
1731
- currency: {
1732
- chain: {
1733
- kind: "BITCOIN";
1734
- } | {
1735
- kind: "EVM";
1736
- chainId: number;
1737
- };
1738
- token: {
1739
- kind: "NATIVE";
1740
- decimals: number;
1741
- } | {
1742
- kind: "TOKEN";
1743
- decimals: number;
1744
- address: string;
1745
- };
1746
- };
1747
- expected: string;
1748
- };
1749
- to: {
1750
- currency: {
1751
- chain: {
1752
- kind: "BITCOIN";
1753
- } | {
1754
- kind: "EVM";
1755
- chainId: number;
1756
- };
1757
- token: {
1758
- kind: "NATIVE";
1759
- decimals: number;
1760
- } | {
1761
- kind: "TOKEN";
1762
- decimals: number;
1763
- address: string;
1764
- };
1765
- };
1766
- expected: string;
1767
- };
1768
- mode: "exact_output";
1769
- id: string;
1770
- fees: {
1771
- preswap?: {
1772
- currency: {
1773
- chain: {
1774
- kind: "BITCOIN";
1775
- } | {
1776
- kind: "EVM";
1777
- chainId: number;
1778
- };
1779
- token: {
1780
- kind: "NATIVE";
1781
- decimals: number;
1782
- } | {
1783
- kind: "TOKEN";
1784
- decimals: number;
1785
- address: string;
1786
- };
1787
- };
1788
- amount: string;
1789
- usd: number;
1790
- } | undefined;
1791
- rift?: {
1792
- network: {
1793
- currency: {
1794
- chain: {
1795
- kind: "BITCOIN";
1796
- } | {
1797
- kind: "EVM";
1798
- chainId: number;
1799
- };
1800
- token: {
1801
- kind: "NATIVE";
1802
- decimals: number;
1803
- } | {
1804
- kind: "TOKEN";
1805
- decimals: number;
1806
- address: string;
1807
- };
1808
- };
1809
- amount: string;
1810
- usd: number;
1811
- };
1812
- liquidity: {
1813
- currency: {
1814
- chain: {
1815
- kind: "BITCOIN";
1816
- } | {
1817
- kind: "EVM";
1818
- chainId: number;
1819
- };
1820
- token: {
1821
- kind: "NATIVE";
1822
- decimals: number;
1823
- } | {
1824
- kind: "TOKEN";
1825
- decimals: number;
1826
- address: string;
1827
- };
1828
- };
1829
- amount: string;
1830
- usd: number;
1831
- };
1832
- protocol: {
1833
- currency: {
1834
- chain: {
1835
- kind: "BITCOIN";
1836
- } | {
1837
- kind: "EVM";
1838
- chainId: number;
1839
- };
1840
- token: {
1841
- kind: "NATIVE";
1842
- decimals: number;
1843
- } | {
1844
- kind: "TOKEN";
1845
- decimals: number;
1846
- address: string;
1847
- };
1848
- };
1849
- amount: string;
1850
- usd: number;
1851
- };
1852
- } | undefined;
1853
- postswap?: {
1854
- currency: {
1855
- chain: {
1856
- kind: "BITCOIN";
1857
- } | {
1858
- kind: "EVM";
1859
- chainId: number;
1860
- };
1861
- token: {
1862
- kind: "NATIVE";
1863
- decimals: number;
1864
- } | {
1865
- kind: "TOKEN";
1866
- decimals: number;
1867
- address: string;
1868
- };
1869
- };
1870
- amount: string;
1871
- usd: number;
1872
- } | undefined;
1873
- totalUsd: number;
1874
- };
1875
- expiresAt: string;
1876
- };
1877
- 422: {
1878
- type: "validation";
1879
- on: string;
1880
- summary?: string;
1881
- message?: string;
1882
- found?: unknown;
1883
- property?: string;
1884
- expected?: string;
1885
- };
1886
- };
1887
- };
1888
- };
1889
- } & {
1890
- swap: {
1891
- post: {
1892
- body: {
1893
- integratorName?: string | undefined;
1894
- approvalMode?: string | undefined;
1895
- id: string;
1896
- destinationAddress: string;
1897
- refundAddress: string;
1898
- };
1899
- params: {};
1900
- query: unknown;
1901
- headers: unknown;
1902
- response: {
1903
- 200: {
1904
- quote: {
1905
- from: {
1906
- currency: {
1907
- chain: {
1908
- kind: "BITCOIN";
1909
- } | {
1910
- kind: "EVM";
1911
- chainId: number;
1912
- };
1913
- token: {
1914
- kind: "NATIVE";
1915
- decimals: number;
1916
- } | {
1917
- kind: "TOKEN";
1918
- decimals: number;
1919
- address: string;
1920
- };
1921
- };
1922
- expected: string;
1923
- };
1924
- to: {
1925
- minimum?: string | undefined;
1926
- currency: {
1927
- chain: {
1928
- kind: "BITCOIN";
1929
- } | {
1930
- kind: "EVM";
1931
- chainId: number;
1932
- };
1933
- token: {
1934
- kind: "NATIVE";
1935
- decimals: number;
1936
- } | {
1937
- kind: "TOKEN";
1938
- decimals: number;
1939
- address: string;
1940
- };
1941
- };
1942
- expected: string;
1943
- };
1944
- mode: "exact_input";
1945
- id: string;
1946
- fees: {
1947
- preswap?: {
1948
- currency: {
1949
- chain: {
1950
- kind: "BITCOIN";
1951
- } | {
1952
- kind: "EVM";
1953
- chainId: number;
1954
- };
1955
- token: {
1956
- kind: "NATIVE";
1957
- decimals: number;
1958
- } | {
1959
- kind: "TOKEN";
1960
- decimals: number;
1961
- address: string;
1962
- };
1963
- };
1964
- amount: string;
1965
- usd: number;
1966
- } | undefined;
1967
- rift?: {
1968
- network: {
1969
- currency: {
1970
- chain: {
1971
- kind: "BITCOIN";
1972
- } | {
1973
- kind: "EVM";
1974
- chainId: number;
1975
- };
1976
- token: {
1977
- kind: "NATIVE";
1978
- decimals: number;
1979
- } | {
1980
- kind: "TOKEN";
1981
- decimals: number;
1982
- address: string;
1983
- };
1984
- };
1985
- amount: string;
1986
- usd: number;
1987
- };
1988
- liquidity: {
1989
- currency: {
1990
- chain: {
1991
- kind: "BITCOIN";
1992
- } | {
1993
- kind: "EVM";
1994
- chainId: number;
1995
- };
1996
- token: {
1997
- kind: "NATIVE";
1998
- decimals: number;
1999
- } | {
2000
- kind: "TOKEN";
2001
- decimals: number;
2002
- address: string;
2003
- };
2004
- };
2005
- amount: string;
2006
- usd: number;
2007
- };
2008
- protocol: {
2009
- currency: {
2010
- chain: {
2011
- kind: "BITCOIN";
2012
- } | {
2013
- kind: "EVM";
2014
- chainId: number;
2015
- };
2016
- token: {
2017
- kind: "NATIVE";
2018
- decimals: number;
2019
- } | {
2020
- kind: "TOKEN";
2021
- decimals: number;
2022
- address: string;
2023
- };
2024
- };
2025
- amount: string;
2026
- usd: number;
2027
- };
2028
- } | undefined;
2029
- postswap?: {
2030
- currency: {
2031
- chain: {
2032
- kind: "BITCOIN";
2033
- } | {
2034
- kind: "EVM";
2035
- chainId: number;
2036
- };
2037
- token: {
2038
- kind: "NATIVE";
2039
- decimals: number;
2040
- } | {
2041
- kind: "TOKEN";
2042
- decimals: number;
2043
- address: string;
2044
- };
2045
- };
2046
- amount: string;
2047
- usd: number;
2048
- } | undefined;
2049
- totalUsd: number;
2050
- };
2051
- expiresAt: string;
2052
- } | {
2053
- from: {
2054
- maximum?: string | undefined;
2055
- currency: {
2056
- chain: {
2057
- kind: "BITCOIN";
2058
- } | {
2059
- kind: "EVM";
2060
- chainId: number;
2061
- };
2062
- token: {
2063
- kind: "NATIVE";
2064
- decimals: number;
2065
- } | {
2066
- kind: "TOKEN";
2067
- decimals: number;
2068
- address: string;
2069
- };
2070
- };
2071
- expected: string;
2072
- };
2073
- to: {
2074
- currency: {
2075
- chain: {
2076
- kind: "BITCOIN";
2077
- } | {
2078
- kind: "EVM";
2079
- chainId: number;
2080
- };
2081
- token: {
2082
- kind: "NATIVE";
2083
- decimals: number;
2084
- } | {
2085
- kind: "TOKEN";
2086
- decimals: number;
2087
- address: string;
2088
- };
2089
- };
2090
- expected: string;
2091
- };
2092
- mode: "exact_output";
2093
- id: string;
2094
- fees: {
2095
- preswap?: {
2096
- currency: {
2097
- chain: {
2098
- kind: "BITCOIN";
2099
- } | {
2100
- kind: "EVM";
2101
- chainId: number;
2102
- };
2103
- token: {
2104
- kind: "NATIVE";
2105
- decimals: number;
2106
- } | {
2107
- kind: "TOKEN";
2108
- decimals: number;
2109
- address: string;
2110
- };
2111
- };
2112
- amount: string;
2113
- usd: number;
2114
- } | undefined;
2115
- rift?: {
2116
- network: {
2117
- currency: {
2118
- chain: {
2119
- kind: "BITCOIN";
2120
- } | {
2121
- kind: "EVM";
2122
- chainId: number;
2123
- };
2124
- token: {
2125
- kind: "NATIVE";
2126
- decimals: number;
2127
- } | {
2128
- kind: "TOKEN";
2129
- decimals: number;
2130
- address: string;
2131
- };
2132
- };
2133
- amount: string;
2134
- usd: number;
2135
- };
2136
- liquidity: {
2137
- currency: {
2138
- chain: {
2139
- kind: "BITCOIN";
2140
- } | {
2141
- kind: "EVM";
2142
- chainId: number;
2143
- };
2144
- token: {
2145
- kind: "NATIVE";
2146
- decimals: number;
2147
- } | {
2148
- kind: "TOKEN";
2149
- decimals: number;
2150
- address: string;
2151
- };
2152
- };
2153
- amount: string;
2154
- usd: number;
2155
- };
2156
- protocol: {
2157
- currency: {
2158
- chain: {
2159
- kind: "BITCOIN";
2160
- } | {
2161
- kind: "EVM";
2162
- chainId: number;
2163
- };
2164
- token: {
2165
- kind: "NATIVE";
2166
- decimals: number;
2167
- } | {
2168
- kind: "TOKEN";
2169
- decimals: number;
2170
- address: string;
2171
- };
2172
- };
2173
- amount: string;
2174
- usd: number;
2175
- };
2176
- } | undefined;
2177
- postswap?: {
2178
- currency: {
2179
- chain: {
2180
- kind: "BITCOIN";
2181
- } | {
2182
- kind: "EVM";
2183
- chainId: number;
2184
- };
2185
- token: {
2186
- kind: "NATIVE";
2187
- decimals: number;
2188
- } | {
2189
- kind: "TOKEN";
2190
- decimals: number;
2191
- address: string;
2192
- };
2193
- };
2194
- amount: string;
2195
- usd: number;
2196
- } | undefined;
2197
- totalUsd: number;
2198
- };
2199
- expiresAt: string;
2200
- };
2201
- swapId: string;
2202
- executionSteps: ({
2203
- amount?: string | undefined;
2204
- value?: string | undefined;
2205
- tokenAddress?: string | undefined;
2206
- spenderAddress?: string | undefined;
2207
- kind: "approval" | "transfer_erc20" | "oneinch_swap" | "dex_swap";
2208
- chainId: number;
2209
- to: string;
2210
- id: string;
2211
- action: "evm_call";
2212
- calldata: string;
2213
- } | {
2214
- kind: "transfer_btc";
2215
- id: string;
2216
- action: "btc_transfer";
2217
- toAddress: string;
2218
- amountSats: string;
2219
- })[];
2220
- };
2221
- 404: {
2222
- error: string;
2223
- };
2224
- 410: {
2225
- error: string;
2226
- };
2227
- 422: {
2228
- type: "validation";
2229
- on: string;
2230
- summary?: string;
2231
- message?: string;
2232
- found?: unknown;
2233
- property?: string;
2234
- expected?: string;
2235
- };
2236
- };
2237
- };
2238
- };
2239
- } & {
2240
- swap: {
2241
- ":swapId": {
2242
- get: {
2243
- body: unknown;
2244
- params: {
2245
- swapId: string;
2246
- };
2247
- query: unknown;
2248
- headers: unknown;
2249
- response: {
2250
- 200: {
2251
- payoutTransaction?: string | undefined;
2252
- depositTransaction?: string | undefined;
2253
- destinationAddress: string;
2254
- status: string;
2255
- quote: {
2256
- from: {
2257
- currency: {
2258
- chain: {
2259
- kind: "BITCOIN";
2260
- } | {
2261
- kind: "EVM";
2262
- chainId: number;
2263
- };
2264
- token: {
2265
- kind: "NATIVE";
2266
- decimals: number;
2267
- } | {
2268
- kind: "TOKEN";
2269
- decimals: number;
2270
- address: string;
2271
- };
2272
- };
2273
- expected: string;
2274
- };
2275
- to: {
2276
- minimum?: string | undefined;
2277
- currency: {
2278
- chain: {
2279
- kind: "BITCOIN";
2280
- } | {
2281
- kind: "EVM";
2282
- chainId: number;
2283
- };
2284
- token: {
2285
- kind: "NATIVE";
2286
- decimals: number;
2287
- } | {
2288
- kind: "TOKEN";
2289
- decimals: number;
2290
- address: string;
2291
- };
2292
- };
2293
- expected: string;
2294
- };
2295
- mode: "exact_input";
2296
- id: string;
2297
- fees: {
2298
- preswap?: {
2299
- currency: {
2300
- chain: {
2301
- kind: "BITCOIN";
2302
- } | {
2303
- kind: "EVM";
2304
- chainId: number;
2305
- };
2306
- token: {
2307
- kind: "NATIVE";
2308
- decimals: number;
2309
- } | {
2310
- kind: "TOKEN";
2311
- decimals: number;
2312
- address: string;
2313
- };
2314
- };
2315
- amount: string;
2316
- usd: number;
2317
- } | undefined;
2318
- rift?: {
2319
- network: {
2320
- currency: {
2321
- chain: {
2322
- kind: "BITCOIN";
2323
- } | {
2324
- kind: "EVM";
2325
- chainId: number;
2326
- };
2327
- token: {
2328
- kind: "NATIVE";
2329
- decimals: number;
2330
- } | {
2331
- kind: "TOKEN";
2332
- decimals: number;
2333
- address: string;
2334
- };
2335
- };
2336
- amount: string;
2337
- usd: number;
2338
- };
2339
- liquidity: {
2340
- currency: {
2341
- chain: {
2342
- kind: "BITCOIN";
2343
- } | {
2344
- kind: "EVM";
2345
- chainId: number;
2346
- };
2347
- token: {
2348
- kind: "NATIVE";
2349
- decimals: number;
2350
- } | {
2351
- kind: "TOKEN";
2352
- decimals: number;
2353
- address: string;
2354
- };
2355
- };
2356
- amount: string;
2357
- usd: number;
2358
- };
2359
- protocol: {
2360
- currency: {
2361
- chain: {
2362
- kind: "BITCOIN";
2363
- } | {
2364
- kind: "EVM";
2365
- chainId: number;
2366
- };
2367
- token: {
2368
- kind: "NATIVE";
2369
- decimals: number;
2370
- } | {
2371
- kind: "TOKEN";
2372
- decimals: number;
2373
- address: string;
2374
- };
2375
- };
2376
- amount: string;
2377
- usd: number;
2378
- };
2379
- } | undefined;
2380
- postswap?: {
2381
- currency: {
2382
- chain: {
2383
- kind: "BITCOIN";
2384
- } | {
2385
- kind: "EVM";
2386
- chainId: number;
2387
- };
2388
- token: {
2389
- kind: "NATIVE";
2390
- decimals: number;
2391
- } | {
2392
- kind: "TOKEN";
2393
- decimals: number;
2394
- address: string;
2395
- };
2396
- };
2397
- amount: string;
2398
- usd: number;
2399
- } | undefined;
2400
- totalUsd: number;
2401
- };
2402
- expiresAt: string;
2403
- } | {
2404
- from: {
2405
- maximum?: string | undefined;
2406
- currency: {
2407
- chain: {
2408
- kind: "BITCOIN";
2409
- } | {
2410
- kind: "EVM";
2411
- chainId: number;
2412
- };
2413
- token: {
2414
- kind: "NATIVE";
2415
- decimals: number;
2416
- } | {
2417
- kind: "TOKEN";
2418
- decimals: number;
2419
- address: string;
2420
- };
2421
- };
2422
- expected: string;
2423
- };
2424
- to: {
2425
- currency: {
2426
- chain: {
2427
- kind: "BITCOIN";
2428
- } | {
2429
- kind: "EVM";
2430
- chainId: number;
2431
- };
2432
- token: {
2433
- kind: "NATIVE";
2434
- decimals: number;
2435
- } | {
2436
- kind: "TOKEN";
2437
- decimals: number;
2438
- address: string;
2439
- };
2440
- };
2441
- expected: string;
2442
- };
2443
- mode: "exact_output";
2444
- id: string;
2445
- fees: {
2446
- preswap?: {
2447
- currency: {
2448
- chain: {
2449
- kind: "BITCOIN";
2450
- } | {
2451
- kind: "EVM";
2452
- chainId: number;
2453
- };
2454
- token: {
2455
- kind: "NATIVE";
2456
- decimals: number;
2457
- } | {
2458
- kind: "TOKEN";
2459
- decimals: number;
2460
- address: string;
2461
- };
2462
- };
2463
- amount: string;
2464
- usd: number;
2465
- } | undefined;
2466
- rift?: {
2467
- network: {
2468
- currency: {
2469
- chain: {
2470
- kind: "BITCOIN";
2471
- } | {
2472
- kind: "EVM";
2473
- chainId: number;
2474
- };
2475
- token: {
2476
- kind: "NATIVE";
2477
- decimals: number;
2478
- } | {
2479
- kind: "TOKEN";
2480
- decimals: number;
2481
- address: string;
2482
- };
2483
- };
2484
- amount: string;
2485
- usd: number;
2486
- };
2487
- liquidity: {
2488
- currency: {
2489
- chain: {
2490
- kind: "BITCOIN";
2491
- } | {
2492
- kind: "EVM";
2493
- chainId: number;
2494
- };
2495
- token: {
2496
- kind: "NATIVE";
2497
- decimals: number;
2498
- } | {
2499
- kind: "TOKEN";
2500
- decimals: number;
2501
- address: string;
2502
- };
2503
- };
2504
- amount: string;
2505
- usd: number;
2506
- };
2507
- protocol: {
2508
- currency: {
2509
- chain: {
2510
- kind: "BITCOIN";
2511
- } | {
2512
- kind: "EVM";
2513
- chainId: number;
2514
- };
2515
- token: {
2516
- kind: "NATIVE";
2517
- decimals: number;
2518
- } | {
2519
- kind: "TOKEN";
2520
- decimals: number;
2521
- address: string;
2522
- };
2523
- };
2524
- amount: string;
2525
- usd: number;
2526
- };
2527
- } | undefined;
2528
- postswap?: {
2529
- currency: {
2530
- chain: {
2531
- kind: "BITCOIN";
2532
- } | {
2533
- kind: "EVM";
2534
- chainId: number;
2535
- };
2536
- token: {
2537
- kind: "NATIVE";
2538
- decimals: number;
2539
- } | {
2540
- kind: "TOKEN";
2541
- decimals: number;
2542
- address: string;
2543
- };
2544
- };
2545
- amount: string;
2546
- usd: number;
2547
- } | undefined;
2548
- totalUsd: number;
2549
- };
2550
- expiresAt: string;
2551
- };
2552
- };
2553
- 422: {
2554
- type: "validation";
2555
- on: string;
2556
- summary?: string;
2557
- message?: string;
2558
- found?: unknown;
2559
- property?: string;
2560
- expected?: string;
2561
- };
2562
- };
2563
- };
2564
- };
2565
- };
2566
- } & {
2567
- swap: {
2568
- ":swapId": {
2569
- tx: {
2570
- post: {
2571
- body: {
2572
- txHash?: string | undefined;
2573
- stepId: string;
2574
- };
2575
- params: {
2576
- swapId: string;
2577
- };
2578
- query: unknown;
2579
- headers: unknown;
2580
- response: {
2581
- 200: {
2582
- success: boolean;
2583
- };
2584
- 422: {
2585
- type: "validation";
2586
- on: string;
2587
- summary?: string;
2588
- message?: string;
2589
- found?: unknown;
2590
- property?: string;
2591
- expected?: string;
2592
- };
2593
- };
2594
- };
2595
- };
2596
- };
2597
- };
2598
- }, {
2599
- derive: {};
2600
- resolve: {};
2601
- schema: {};
2602
- standaloneSchema: {};
2603
- response: {};
2604
- } & {
2605
- derive: {};
2606
- resolve: {};
2607
- schema: {};
2608
- }, {
2609
- derive: {};
2610
- resolve: {};
2611
- schema: {};
2612
- standaloneSchema: {};
2613
- response: {};
2614
- }>;
2615
- type App = typeof app;
2616
236
  declare class SwapRouterApiError extends Error {
2617
237
  status: number;
2618
238
  body: ErrorResponse | undefined;
2619
239
  constructor(message: string, status: number, body?: ErrorResponse);
2620
240
  }
2621
241
  /**
2622
- * Create a type-safe API client for the Rift Swap Router.
2623
- *
2624
- * @param baseUrl - The base URL of the swap router API (e.g., 'https://api.rift.trade')
2625
- * @returns A fully typed Eden Treaty client
2626
- *
2627
- * @example
2628
- * ```typescript
2629
- * import { createClient } from '@riftresearch/sdk'
2630
- *
2631
- * const api = createClient('https://api.rift.trade')
2632
- *
2633
- * // Get a quote - fully typed request and response
2634
- * const { data: quote, error } = await api.quote.post({
2635
- * type: 'EXACT_INPUT',
2636
- * from: {
2637
- * chain: { kind: 'BITCOIN' },
2638
- * token: { kind: 'NATIVE', decimals: 8 },
2639
- * },
2640
- * to: {
2641
- * chain: { kind: 'EVM', chainId: 8453 },
2642
- * token: { kind: 'TOKEN', address: '0xcbB7C0000aB88B473b1f5aFd9ef808440eed33Bf', decimals: 8 },
2643
- * },
2644
- * amount: '100000', // 0.001 BTC in sats
2645
- * slippageBps: 100, // 1%
2646
- * })
2647
- *
2648
- * if (error) {
2649
- * console.error('Failed to get quote:', error)
2650
- * return
2651
- * }
2652
- *
2653
- * console.log('Quote ID:', quote.id)
2654
- * console.log('You will receive:', quote.to.expected)
2655
- *
2656
- * // Create a swap from the quote
2657
- * const { data: swap, error: swapError } = await api.swap.post({
2658
- * id: quote.id,
2659
- * destinationAddress: '0x...',
2660
- * refundAddress: 'bc1q...',
2661
- * })
2662
- *
2663
- * if (swap) {
2664
- * console.log('Deposit to:', swap.deposit_vault_address)
2665
- * }
2666
- *
2667
- * // Check swap status
2668
- * const { data: status } = await api.swap({ swapId: swap.id }).get()
2669
- * ```
2670
- */
2671
- /** Type of the Rift API client */
2672
- type RiftClient = Treaty.Create<App>;
2673
- declare function createClient(baseUrl: string): RiftClient;
2674
- /**
2675
242
  * Discriminated union of all possible swap routes.
2676
243
  *
2677
244
  * - direct_rift: BTC <-> EVM token (Rift handles directly)
@@ -2780,10 +347,9 @@ interface GetQuoteResult {
2780
347
  }
2781
348
  interface SwapResult {
2782
349
  swapId: string;
2783
- status: SwapStatus4;
350
+ status: SwapStatus;
2784
351
  rift: RiftSwap;
2785
352
  }
2786
- type SwapStatus4 = SwapStatus;
2787
353
  /**
2788
354
  * Function type for sending Bitcoin.
2789
355
  * Implementers provide this function to handle BTC transactions in their app.
@@ -2896,4 +462,4 @@ declare class RiftSdk {
2896
462
  getSwapStatus(swapId: string): Promise<SwapStatusResponse>;
2897
463
  }
2898
464
  declare function createRiftSdk(options: RiftSdkOptions): RiftSdk;
2899
- export { getSupportedModes, detectRoute, createRiftSdk, createCurrency, createClient, TokenIdentifier, SwapStatus4 as SwapStatus, SwapRouterApiError, SwapRoute, SwapResult, SwapResponse, SupportedModes, SendBitcoinFn, RiftSwap, RiftSdkOptions, RiftSdk, RiftClient, QuoteResult, QuoteQuality, QuoteParameters, NativeToken, GetQuoteResult, ExecutionStep, ExecutionAction, ExecuteSwapOptions, EvmChain, EvmCallStep, EvmCallKind, Erc20Token, Currency, Currencies, Chain, BtcTransferStep, BtcTransferKind, BitcoinChain, App };
465
+ export { getSupportedModes, detectRoute, createRiftSdk, createCurrency, TokenIdentifier, SwapStatus, SwapRouterApiError, SwapRoute, SwapResult, SwapResponse, SupportedModes, SendBitcoinFn, RiftSwap, RiftSdkOptions, RiftSdk, QuoteResult, QuoteQuality, QuoteParameters, NativeToken, GetQuoteResult, ExecutionStep, ExecutionAction, ExecuteSwapOptions, EvmChain, EvmCallStep, EvmCallKind, Erc20Token, Currency, Currencies, Chain, BtcTransferStep, BtcTransferKind, BitcoinChain };