stableflow-ai-sdk 1.0.0 → 2.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.ts CHANGED
@@ -1,3 +1,7 @@
1
+ import * as _solana_web3_js from '@solana/web3.js';
2
+ import { Connection, PublicKey } from '@solana/web3.js';
3
+ import { ethers } from 'ethers';
4
+
1
5
  type ApiRequestOptions = {
2
6
  readonly method: 'GET' | 'PUT' | 'POST' | 'DELETE' | 'OPTIONS' | 'HEAD' | 'PATCH';
3
7
  readonly url: string;
@@ -495,6 +499,101 @@ declare namespace TokenResponse {
495
499
  }
496
500
  }
497
501
 
502
+ type ServiceType = "oneclick" | "usdt0" | "cctp";
503
+ declare const Service: {
504
+ readonly OneClick: "oneclick";
505
+ readonly Usdt0: "usdt0";
506
+ readonly CCTP: "cctp";
507
+ };
508
+
509
+ type ChainType = "near" | "sol" | "evm" | "tron" | "aptos";
510
+
511
+ interface ChainConfig {
512
+ chainName: string;
513
+ chainIcon: string;
514
+ chainIconGray: string;
515
+ chainType: ChainType;
516
+ chainId?: number;
517
+ blockExplorerUrl: string;
518
+ primaryColor: string;
519
+ nativeToken: {
520
+ symbol: string;
521
+ decimals: number;
522
+ };
523
+ rpcUrl: string;
524
+ }
525
+
526
+ interface TokenConfig extends ChainConfig {
527
+ symbol: string;
528
+ decimals: number;
529
+ icon: string;
530
+ assetId: string;
531
+ contractAddress: string;
532
+ services: ServiceType[];
533
+ }
534
+
535
+ declare enum SendType {
536
+ SEND = "SEND",
537
+ TRANSFER = "TRANSFER"
538
+ }
539
+
540
+ interface WalletConfig {
541
+ transfer(params: {
542
+ originAsset: string;
543
+ depositAddress: string;
544
+ amount: string;
545
+ }): Promise<string>;
546
+ getBalance(token: TokenConfig, account: string): Promise<string>;
547
+ balanceOf(token: TokenConfig, account: string): Promise<string>;
548
+ allowance?(params: {
549
+ contractAddress: string;
550
+ spender: string;
551
+ address: string;
552
+ amountWei: string | number | BigInt;
553
+ }): Promise<{
554
+ allowance: string;
555
+ needApprove: boolean;
556
+ }>;
557
+ approve?(params: {
558
+ contractAddress: string;
559
+ spender: string;
560
+ amountWei: string | number | BigInt;
561
+ isApproveMax?: boolean;
562
+ }): Promise<boolean>;
563
+ quote(type: ServiceType, params: {}): Promise<{
564
+ needApprove?: boolean;
565
+ approveSpender?: string;
566
+ sendParam?: any;
567
+ quoteParam: any;
568
+ fees?: Record<string, string>;
569
+ totalFeesUsd?: string;
570
+ estimateSourceGas?: BigInt;
571
+ estimateSourceGasUsd?: string;
572
+ estimateTime?: number;
573
+ outputAmount?: string;
574
+ }>;
575
+ send(type: SendType, params: any): Promise<string>;
576
+ }
577
+
578
+ declare enum TransactionStatus {
579
+ Pending = "pending",
580
+ Success = "success",
581
+ Failed = "failed"
582
+ }
583
+
584
+ interface GetAllQuoteParams {
585
+ singleService?: ServiceType;
586
+ dry?: boolean;
587
+ prices: Record<string, string>;
588
+ fromToken: TokenConfig;
589
+ toToken: TokenConfig;
590
+ wallet: WalletConfig;
591
+ recipient: string;
592
+ refundTo: string;
593
+ amountWei: string;
594
+ slippageTolerance: number;
595
+ minInputAmount?: string;
596
+ }
498
597
  /**
499
598
  * StableFlow AI Service
500
599
  * Main service class for interacting with the StableFlow AI API
@@ -507,6 +606,7 @@ declare class SFA {
507
606
  * Each token entry includes its blockchain, contract address (if available), price in USD, and other metadata such as symbol and decimals.
508
607
  * @returns TokenResponse
509
608
  * @throws ApiError
609
+ * @deprecated Please use the import { tokens } from 'stableflow-ai-sdk';
510
610
  */
511
611
  static getTokens(): CancelablePromise<Array<TokenResponse>>;
512
612
  /**
@@ -521,6 +621,7 @@ declare class SFA {
521
621
  * @param requestBody
522
622
  * @returns QuoteResponse
523
623
  * @throws ApiError
624
+ * @deprecated Please use the getAllQuote
524
625
  */
525
626
  static getQuote(requestBody: QuoteRequest): CancelablePromise<QuoteResponse>;
526
627
  /**
@@ -532,18 +633,340 @@ declare class SFA {
532
633
  * @param depositMemo
533
634
  * @returns GetExecutionStatusResponse
534
635
  * @throws ApiError
636
+ * @deprecated Please use the getStatus
535
637
  */
536
638
  static getExecutionStatus(depositAddress: string, depositMemo?: string): CancelablePromise<GetExecutionStatusResponse>;
537
639
  /**
538
640
  * Submit deposit transaction hash
539
641
  * Optionally notifies the StableFlow AI service that a deposit has been sent to the specified address, using the blockchain transaction hash.
642
+ * Only for Oneclick project
540
643
  *
541
644
  * This step can speed up swap processing by allowing the system to preemptively verify the deposit.
542
645
  * @param requestBody
543
646
  * @returns SubmitDepositTxResponse
544
647
  * @throws ApiError
648
+ * @deprecated the send method will submit the tx hash automatically
545
649
  */
546
- static submitDepositTx(requestBody: SubmitDepositTxRequest): CancelablePromise<SubmitDepositTxResponse>;
650
+ static submitDepositTx: (requestBody: SubmitDepositTxRequest) => CancelablePromise<SubmitDepositTxResponse>;
651
+ /**
652
+ * Get quotes from all available bridge services
653
+ * Retrieves quotes from all supported bridge services (OneClick, CCTP, USDT0) in parallel.
654
+ * Returns an array of quotes with their corresponding service types, allowing users to compare and select the best route.
655
+ *
656
+ * @param params Parameters for quote request including wallet, tokens, amount, etc.
657
+ * @returns Promise resolving to an array of quote results with service type information
658
+ * @throws Error if all bridge services fail or if required parameters are missing
659
+ */
660
+ static getAllQuote(params: GetAllQuoteParams): Promise<Array<{
661
+ serviceType: ServiceType;
662
+ quote?: any;
663
+ error?: string;
664
+ }>>;
665
+ /**
666
+ * Send transaction for the selected bridge route
667
+ * Executes the transaction using the specified bridge service based on the service type.
668
+ *
669
+ * @param serviceType The type of bridge service to use (oneclick, cctp, or usdt0)
670
+ * @param params Parameters for sending the transaction including wallet, tokens, deposit address, etc.
671
+ * @returns Promise resolving to the transaction hash or signature
672
+ * @throws Error if the service type is invalid or if the transaction fails
673
+ */
674
+ static send(serviceType: ServiceType, params: {
675
+ wallet: any;
676
+ quote: any;
677
+ }): Promise<string>;
678
+ /**
679
+ * Get transaction status for the selected bridge route
680
+ * Queries the transaction status from the specified bridge service.
681
+ *
682
+ * @param serviceType The type of bridge service used (oneclick, cctp, or usdt0)
683
+ * @param params Parameters for querying status including deposit address, transaction hash, etc.
684
+ * @returns Promise resolving to the transaction status response
685
+ * @throws Error if the service type is invalid or if the status query fails
686
+ */
687
+ static getStatus(serviceType: ServiceType, params: {
688
+ depositAddress?: string;
689
+ hash?: string;
690
+ }): Promise<{
691
+ status: TransactionStatus;
692
+ toChainTxHash?: string;
693
+ }>;
694
+ }
695
+
696
+ declare const tokens: TokenConfig[];
697
+ declare const usdtTokens: TokenConfig[];
698
+ declare const usdcTokens: TokenConfig[];
699
+
700
+ declare const usdtChains: Record<string, TokenConfig>;
701
+
702
+ declare const usdcChains: Record<string, TokenConfig>;
703
+
704
+ declare class NearWallet {
705
+ private selector;
706
+ private rpcUrl;
707
+ constructor(_selector: any);
708
+ private query;
709
+ transfer(data: {
710
+ originAsset: string;
711
+ depositAddress: string;
712
+ amount: string;
713
+ }): Promise<any>;
714
+ getBalance(token: any, _account: string): Promise<any>;
715
+ balanceOf(token: any, account: string): Promise<any>;
716
+ /**
717
+ * Get native NEAR balance
718
+ * @param account Account ID
719
+ * @returns NEAR balance in yoctoNEAR (smallest unit)
720
+ */
721
+ getNearBalance(account: string): Promise<string>;
722
+ /**
723
+ * Estimate gas limit for transfer transaction
724
+ * @param data Transfer data
725
+ * @returns Gas limit estimate, gas price, and estimated gas cost
726
+ */
727
+ estimateTransferGas(data: {
728
+ originAsset: string;
729
+ depositAddress: string;
730
+ amount: string;
731
+ }): Promise<{
732
+ gasLimit: bigint;
733
+ gasPrice: bigint;
734
+ estimateGas: bigint;
735
+ }>;
736
+ checkTransactionStatus(txHash: string): Promise<void>;
737
+ quoteOneClickProxy(params: any): Promise<any>;
738
+ sendTransaction(params: any): Promise<any>;
739
+ /**
740
+ * Unified quote method that routes to specific quote methods based on type
741
+ * @param type Service type from ServiceType
742
+ * @param params Parameters for the quote
743
+ */
744
+ quote(type: ServiceType, params: any): Promise<any>;
745
+ /**
746
+ * Unified send method that routes to specific send methods based on type
747
+ * @param type Send type from SendType enum
748
+ * @param params Parameters for the send transaction
749
+ */
750
+ send(type: SendType, params: any): Promise<any>;
547
751
  }
548
752
 
549
- export { ApiError, type AppFee, type BadRequestResponse, CancelError, CancelablePromise, GetExecutionStatusResponse, OpenAPI, type OpenAPIConfig, type Quote, QuoteRequest, type QuoteResponse, SFA, type SubmitDepositTxRequest, SubmitDepositTxResponse, type SwapDetails, TokenResponse, type TransactionDetails };
753
+ declare class SolanaWallet {
754
+ connection: Connection;
755
+ private publicKey;
756
+ private signTransaction;
757
+ private signer;
758
+ constructor(options: {
759
+ publicKey: PublicKey | null;
760
+ signer: any;
761
+ });
762
+ transferSOL(to: string, amount: string): Promise<string>;
763
+ transferToken(tokenMint: string, to: string, amount: string): Promise<string>;
764
+ transfer(data: {
765
+ originAsset: string;
766
+ depositAddress: string;
767
+ amount: string;
768
+ }): Promise<string>;
769
+ getSOLBalance(account: string): Promise<number>;
770
+ getTokenBalance(tokenMint: string, account: string): Promise<bigint | 0>;
771
+ getBalance(token: any, account: string): Promise<number | bigint>;
772
+ balanceOf(token: any, account: string): Promise<number | bigint>;
773
+ /**
774
+ * Estimate gas limit for transfer transaction
775
+ * @param data Transfer data
776
+ * @returns Gas limit estimate, gas price, and estimated gas cost
777
+ */
778
+ estimateTransferGas(data: {
779
+ originAsset: string;
780
+ depositAddress: string;
781
+ amount: string;
782
+ }): Promise<{
783
+ gasLimit: bigint;
784
+ gasPrice: bigint;
785
+ estimateGas: bigint;
786
+ }>;
787
+ checkTransactionStatus(signature: string): Promise<boolean>;
788
+ simulateIx(ix: any): Promise<_solana_web3_js.SimulatedTransactionResponse>;
789
+ sendTransaction(params: any): Promise<string>;
790
+ /**
791
+ * Unified quote method that routes to specific quote methods based on type
792
+ * @param type Service type from ServiceType
793
+ * @param params Parameters for the quote
794
+ */
795
+ quote(type: ServiceType, params: any): Promise<any>;
796
+ /**
797
+ * Unified send method that routes to specific send methods based on type
798
+ * @param type Send type from SendType enum
799
+ * @param params Parameters for the send transaction
800
+ */
801
+ send(type: SendType, params: any): Promise<string>;
802
+ quoteOneClickProxy(params: any): Promise<any>;
803
+ quoteCCTP(params: any): Promise<any>;
804
+ createAssociatedTokenAddress(params: any): Promise<PublicKey>;
805
+ }
806
+
807
+ declare class EVMWallet {
808
+ provider: any;
809
+ signer: any;
810
+ constructor(_provider: any, _signer?: any);
811
+ transfer(data: {
812
+ originAsset: string;
813
+ depositAddress: string;
814
+ amount: string;
815
+ }): Promise<any>;
816
+ getBalance(token: any, account: string): Promise<any>;
817
+ balanceOf(token: any, account: string): Promise<any>;
818
+ /**
819
+ * Estimate gas limit for transfer transaction
820
+ * @param data Transfer data
821
+ * @returns Gas limit estimate, gas price, and estimated gas cost
822
+ */
823
+ estimateTransferGas(data: {
824
+ originAsset: string;
825
+ depositAddress: string;
826
+ amount: string;
827
+ }): Promise<{
828
+ gasLimit: bigint;
829
+ gasPrice: bigint;
830
+ estimateGas: bigint;
831
+ }>;
832
+ getContract(params: any): ethers.Contract;
833
+ allowance(params: any): Promise<{
834
+ contract: ethers.Contract;
835
+ allowance: string;
836
+ needApprove: boolean;
837
+ }>;
838
+ approve(params: any): Promise<boolean>;
839
+ getEstimateGas(params: any): Promise<{
840
+ gasPrice: any;
841
+ usd: string;
842
+ wei: bigint;
843
+ amount: string;
844
+ }>;
845
+ quoteOFT(params: any): Promise<any>;
846
+ sendTransaction(params: any): Promise<any>;
847
+ /**
848
+ * Unified quote method that routes to specific quote methods based on type
849
+ * @param type Service type from ServiceType
850
+ * @param params Parameters for the quote
851
+ */
852
+ quote(type: ServiceType, params: any): Promise<any>;
853
+ /**
854
+ * Unified send method that routes to specific send methods based on type
855
+ * @param type Send type from SendType enum
856
+ * @param params Parameters for the send transaction
857
+ */
858
+ send(type: SendType, params: any): Promise<any>;
859
+ quoteCCTP(params: any): Promise<any>;
860
+ quoteOneClickProxy(params: any): Promise<any>;
861
+ }
862
+
863
+ declare class TronWallet {
864
+ private signAndSendTransaction;
865
+ private tronWeb;
866
+ constructor(options: any);
867
+ waitForTronWeb(): Promise<unknown>;
868
+ transfer(data: {
869
+ originAsset: string;
870
+ depositAddress: string;
871
+ amount: string;
872
+ }): Promise<any>;
873
+ transferTRX(to: string, amount: string): Promise<any>;
874
+ transferToken(contractAddress: string, to: string, amount: string): Promise<any>;
875
+ getBalance(token: any, account: string): Promise<any>;
876
+ getTRXBalance(account: string): Promise<any>;
877
+ getTokenBalance(contractAddress: string, account: string): Promise<any>;
878
+ balanceOf(token: any, account: string): Promise<any>;
879
+ /**
880
+ * Estimate gas limit for transfer transaction
881
+ * @param data Transfer data
882
+ * @returns Gas limit estimate (bandwidth or energy), gas price, and estimated gas cost
883
+ */
884
+ estimateTransferGas(data: {
885
+ originAsset: string;
886
+ depositAddress: string;
887
+ amount: string;
888
+ }): Promise<{
889
+ gasLimit: bigint;
890
+ gasPrice: bigint;
891
+ estimateGas: bigint;
892
+ }>;
893
+ checkTransactionStatus(txHash: string): Promise<boolean>;
894
+ allowance(params: any): Promise<{
895
+ contract: any;
896
+ allowance: string;
897
+ needApprove: boolean;
898
+ }>;
899
+ approve(params: any): Promise<any>;
900
+ getEnergyPrice(): Promise<any>;
901
+ toBytes32(addr: string): string;
902
+ quoteOFT(params: any): Promise<any>;
903
+ sendTransaction(params: any): Promise<any>;
904
+ /**
905
+ * Unified quote method that routes to specific quote methods based on type
906
+ * @param type Service type from ServiceType
907
+ * @param params Parameters for the quote
908
+ */
909
+ quote(type: ServiceType, params: any): Promise<any>;
910
+ /**
911
+ * Unified send method that routes to specific send methods based on type
912
+ * @param type Send type from SendType enum
913
+ * @param params Parameters for the send transaction
914
+ */
915
+ send(type: SendType, params: any): Promise<any>;
916
+ quoteOneClickProxy(params: any): Promise<any>;
917
+ }
918
+
919
+ declare class AptosWallet {
920
+ connection: any;
921
+ private account;
922
+ private aptos;
923
+ private signAndSubmitTransaction;
924
+ constructor(options: {
925
+ account: any | null;
926
+ signAndSubmitTransaction: any;
927
+ });
928
+ transferAPT(to: string, amount: string): Promise<string>;
929
+ transferToken(contractAddress: string, to: string, amount: string): Promise<string>;
930
+ transfer(data: {
931
+ originAsset: string;
932
+ depositAddress: string;
933
+ amount: string;
934
+ }): Promise<string>;
935
+ getAPTBalance(account: string): Promise<string>;
936
+ getTokenBalance(contractAddress: string, account: string): Promise<string>;
937
+ getBalance(token: any, account: string): Promise<string>;
938
+ balanceOf(token: any, account: string): Promise<string>;
939
+ /**
940
+ * Estimate gas limit for transfer transaction
941
+ * @param data Transfer data
942
+ * @returns Gas limit estimate, gas price, and estimated gas cost
943
+ */
944
+ estimateTransferGas(data: {
945
+ originAsset: string;
946
+ depositAddress: string;
947
+ amount: string;
948
+ }): Promise<{
949
+ gasLimit: bigint;
950
+ gasPrice: bigint;
951
+ estimateGas: bigint;
952
+ }>;
953
+ checkTransactionStatus(signature: string): Promise<boolean>;
954
+ quoteOneClickProxy(params: any): Promise<any>;
955
+ sendTransaction(params: any): Promise<any>;
956
+ /**
957
+ * Unified quote method that routes to specific quote methods based on type
958
+ * @param type Service type from ServiceType
959
+ * @param params Parameters for the quote
960
+ */
961
+ quote(type: ServiceType, params: any): Promise<any>;
962
+ /**
963
+ * Unified send method that routes to specific send methods based on type
964
+ * @param type Send type from SendTypeSENDm
965
+ * @param params Parameters for the send transaction
966
+ */
967
+ send(type: SendType, params: any): Promise<any>;
968
+ }
969
+
970
+ declare const chainsRpcUrls: Record<string, string>;
971
+
972
+ export { ApiError, type AppFee, AptosWallet, type BadRequestResponse, CancelError, CancelablePromise, EVMWallet, type GetAllQuoteParams, GetExecutionStatusResponse, NearWallet, OpenAPI, type OpenAPIConfig, type Quote, QuoteRequest, type QuoteResponse, SFA, Service, type ServiceType, SolanaWallet, type SubmitDepositTxRequest, SubmitDepositTxResponse, type SwapDetails, type TokenConfig, TokenResponse, type TransactionDetails, TransactionStatus, TronWallet, chainsRpcUrls, tokens, usdcChains, usdcTokens, usdtChains, usdtTokens };