@shogun-sdk/swap 0.0.2-test

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,147 @@
1
+ import { ChainID, QuoteResponse, TokenSearchResponse as TokenSearchResponse$1, TokenInfo as TokenInfo$1 } from '@shogun-sdk/intents-sdk';
2
+ import { WalletClient } from 'viem';
3
+ import { A as AdaptedWallet } from './wallet-MmUIz8GE.cjs';
4
+
5
+ /**
6
+ * Token metadata used in quotes.
7
+ * Provides address, decimals, and optional symbol.
8
+ */
9
+ type QuoteTokenInfo = {
10
+ /** Token contract or mint address (EVM/Solana/Sui) */
11
+ address: string;
12
+ /** Number of decimals for precise conversion */
13
+ decimals: number;
14
+ /** Optional symbol (for display purposes only) */
15
+ symbol?: string;
16
+ chainId: number;
17
+ };
18
+ /**
19
+ * 🔧 SwapQuoteParams — input shape for requesting a swap quote.
20
+ *
21
+ * Works for both EVM and non-EVM chains (Solana, Sui, etc.).
22
+ */
23
+ type SwapQuoteParams = {
24
+ /** Token you’re swapping *from* */
25
+ tokenIn: QuoteTokenInfo;
26
+ /** Token you’re swapping *to* */
27
+ tokenOut: QuoteTokenInfo;
28
+ /** The source chain ID — where the swap starts */
29
+ sourceChainId: ChainID;
30
+ /** The destination chain ID — where the swap ends */
31
+ destChainId: ChainID;
32
+ /** Input amount (smallest unit — wei, lamports, etc.) */
33
+ amount: bigint;
34
+ slippage?: number;
35
+ };
36
+ /**
37
+ * 💱 SwapQuoteResponse — output returned by `getQuote()`.
38
+ */
39
+ type SwapQuoteResponse = {
40
+ /** Input token amount (smallest units, e.g. wei, lamports, etc.) */
41
+ amountIn: bigint;
42
+ /** Output token amount after routing/slippage (smallest units) */
43
+ amountOut: bigint;
44
+ /** Estimated USD value of output tokens */
45
+ amountOutUsd: number;
46
+ /** Estimated USD value of input tokens */
47
+ amountInUsd: number;
48
+ /** Minimum stablecoin equivalent for guaranteed slippage bounds */
49
+ minStablecoinsAmount: bigint;
50
+ /** Metadata for input token (includes decimals & chain ID) */
51
+ tokenIn: QuoteTokenInfo & {
52
+ chainId: ChainID;
53
+ };
54
+ /** Metadata for output token (includes decimals & chain ID) */
55
+ tokenOut: QuoteTokenInfo & {
56
+ chainId: ChainID;
57
+ };
58
+ /**
59
+ * Derived: how many tokenOut for 1 tokenIn (raw, 1e18 scaled bigint)
60
+ * Formula: (amountOut * 1e18) / amountIn
61
+ */
62
+ pricePerInputToken: bigint;
63
+ internal: QuoteResponse;
64
+ slippage: number;
65
+ warning?: string;
66
+ };
67
+
68
+ type Stage = 'processing' | 'approving' | 'approved' | 'signing' | 'submitting' | 'success' | 'error';
69
+ type PlaceOrderResult = {
70
+ status: boolean;
71
+ txHash?: string;
72
+ chainId?: number;
73
+ message?: string;
74
+ stage: Stage;
75
+ };
76
+
77
+ interface BalanceRequestParams {
78
+ /** Object containing wallet addresses for supported chains. */
79
+ addresses: {
80
+ /** EVM-compatible wallet address (optional). */
81
+ evm?: string;
82
+ /** Solana wallet address (optional). */
83
+ svm?: string;
84
+ };
85
+ /** Optional pagination cursor for EVM balances. */
86
+ cursorEvm?: string;
87
+ /** Optional pagination cursor for Solana balances. */
88
+ cursorSvm?: string;
89
+ }
90
+ interface TokenBalance {
91
+ name: string;
92
+ symbol: string;
93
+ chainId: ChainID;
94
+ address: string;
95
+ balance: string;
96
+ balanceUsd: number;
97
+ decimals: number;
98
+ image?: string;
99
+ isNative: boolean;
100
+ }
101
+ interface BalanceResponse {
102
+ /** List of balances across networks. */
103
+ results: TokenBalance[];
104
+ /** Optional pagination cursors */
105
+ nextCursorEvm?: string;
106
+ nextCursorSvm?: string;
107
+ }
108
+
109
+ type TokenSearchResponse = TokenSearchResponse$1;
110
+ type TokenInfo = TokenInfo$1;
111
+
112
+ /**
113
+ * Executes a swap order on the correct chain (EVM or Solana).
114
+ *
115
+ * @param quote - The quote object returned from the quote API.
116
+ * @param accountAddress - The wallet address initiating the swap.
117
+ * @param recipientAddress - recipient for output tokens.
118
+ * @param wallet - Adapted wallet (EVM or Solana).
119
+ * @param onStatus - Optional callback for UI updates.
120
+ * @param options - Optional execution settings.
121
+ * - deadline: UNIX timestamp (seconds)
122
+ * Default = now + 20 minutes
123
+ *
124
+ * @returns Execution result { status, message, stage }
125
+ */
126
+ declare function executeOrder({ quote, accountAddress, recipientAddress, wallet, onStatus, options, }: {
127
+ quote: SwapQuoteResponse;
128
+ accountAddress: string;
129
+ recipientAddress?: string;
130
+ wallet: AdaptedWallet | WalletClient;
131
+ onStatus?: (stage: Stage, message?: string) => void;
132
+ options?: {
133
+ /** Optional swap deadline (UNIX seconds). Default: now + 20 minutes */
134
+ deadline?: number;
135
+ };
136
+ }): Promise<{
137
+ status: boolean;
138
+ txHash: string;
139
+ chainId: number;
140
+ stage: string;
141
+ } | {
142
+ status: boolean;
143
+ message: string;
144
+ stage: string;
145
+ }>;
146
+
147
+ export { type BalanceRequestParams as B, type PlaceOrderResult as P, type QuoteTokenInfo as Q, type SwapQuoteParams as S, type TokenBalance as T, type SwapQuoteResponse as a, type Stage as b, type BalanceResponse as c, type TokenSearchResponse as d, executeOrder as e, type TokenInfo as f };
@@ -0,0 +1,147 @@
1
+ import { ChainID, QuoteResponse, TokenSearchResponse as TokenSearchResponse$1, TokenInfo as TokenInfo$1 } from '@shogun-sdk/intents-sdk';
2
+ import { WalletClient } from 'viem';
3
+ import { A as AdaptedWallet } from './wallet-MmUIz8GE.js';
4
+
5
+ /**
6
+ * Token metadata used in quotes.
7
+ * Provides address, decimals, and optional symbol.
8
+ */
9
+ type QuoteTokenInfo = {
10
+ /** Token contract or mint address (EVM/Solana/Sui) */
11
+ address: string;
12
+ /** Number of decimals for precise conversion */
13
+ decimals: number;
14
+ /** Optional symbol (for display purposes only) */
15
+ symbol?: string;
16
+ chainId: number;
17
+ };
18
+ /**
19
+ * 🔧 SwapQuoteParams — input shape for requesting a swap quote.
20
+ *
21
+ * Works for both EVM and non-EVM chains (Solana, Sui, etc.).
22
+ */
23
+ type SwapQuoteParams = {
24
+ /** Token you’re swapping *from* */
25
+ tokenIn: QuoteTokenInfo;
26
+ /** Token you’re swapping *to* */
27
+ tokenOut: QuoteTokenInfo;
28
+ /** The source chain ID — where the swap starts */
29
+ sourceChainId: ChainID;
30
+ /** The destination chain ID — where the swap ends */
31
+ destChainId: ChainID;
32
+ /** Input amount (smallest unit — wei, lamports, etc.) */
33
+ amount: bigint;
34
+ slippage?: number;
35
+ };
36
+ /**
37
+ * 💱 SwapQuoteResponse — output returned by `getQuote()`.
38
+ */
39
+ type SwapQuoteResponse = {
40
+ /** Input token amount (smallest units, e.g. wei, lamports, etc.) */
41
+ amountIn: bigint;
42
+ /** Output token amount after routing/slippage (smallest units) */
43
+ amountOut: bigint;
44
+ /** Estimated USD value of output tokens */
45
+ amountOutUsd: number;
46
+ /** Estimated USD value of input tokens */
47
+ amountInUsd: number;
48
+ /** Minimum stablecoin equivalent for guaranteed slippage bounds */
49
+ minStablecoinsAmount: bigint;
50
+ /** Metadata for input token (includes decimals & chain ID) */
51
+ tokenIn: QuoteTokenInfo & {
52
+ chainId: ChainID;
53
+ };
54
+ /** Metadata for output token (includes decimals & chain ID) */
55
+ tokenOut: QuoteTokenInfo & {
56
+ chainId: ChainID;
57
+ };
58
+ /**
59
+ * Derived: how many tokenOut for 1 tokenIn (raw, 1e18 scaled bigint)
60
+ * Formula: (amountOut * 1e18) / amountIn
61
+ */
62
+ pricePerInputToken: bigint;
63
+ internal: QuoteResponse;
64
+ slippage: number;
65
+ warning?: string;
66
+ };
67
+
68
+ type Stage = 'processing' | 'approving' | 'approved' | 'signing' | 'submitting' | 'success' | 'error';
69
+ type PlaceOrderResult = {
70
+ status: boolean;
71
+ txHash?: string;
72
+ chainId?: number;
73
+ message?: string;
74
+ stage: Stage;
75
+ };
76
+
77
+ interface BalanceRequestParams {
78
+ /** Object containing wallet addresses for supported chains. */
79
+ addresses: {
80
+ /** EVM-compatible wallet address (optional). */
81
+ evm?: string;
82
+ /** Solana wallet address (optional). */
83
+ svm?: string;
84
+ };
85
+ /** Optional pagination cursor for EVM balances. */
86
+ cursorEvm?: string;
87
+ /** Optional pagination cursor for Solana balances. */
88
+ cursorSvm?: string;
89
+ }
90
+ interface TokenBalance {
91
+ name: string;
92
+ symbol: string;
93
+ chainId: ChainID;
94
+ address: string;
95
+ balance: string;
96
+ balanceUsd: number;
97
+ decimals: number;
98
+ image?: string;
99
+ isNative: boolean;
100
+ }
101
+ interface BalanceResponse {
102
+ /** List of balances across networks. */
103
+ results: TokenBalance[];
104
+ /** Optional pagination cursors */
105
+ nextCursorEvm?: string;
106
+ nextCursorSvm?: string;
107
+ }
108
+
109
+ type TokenSearchResponse = TokenSearchResponse$1;
110
+ type TokenInfo = TokenInfo$1;
111
+
112
+ /**
113
+ * Executes a swap order on the correct chain (EVM or Solana).
114
+ *
115
+ * @param quote - The quote object returned from the quote API.
116
+ * @param accountAddress - The wallet address initiating the swap.
117
+ * @param recipientAddress - recipient for output tokens.
118
+ * @param wallet - Adapted wallet (EVM or Solana).
119
+ * @param onStatus - Optional callback for UI updates.
120
+ * @param options - Optional execution settings.
121
+ * - deadline: UNIX timestamp (seconds)
122
+ * Default = now + 20 minutes
123
+ *
124
+ * @returns Execution result { status, message, stage }
125
+ */
126
+ declare function executeOrder({ quote, accountAddress, recipientAddress, wallet, onStatus, options, }: {
127
+ quote: SwapQuoteResponse;
128
+ accountAddress: string;
129
+ recipientAddress?: string;
130
+ wallet: AdaptedWallet | WalletClient;
131
+ onStatus?: (stage: Stage, message?: string) => void;
132
+ options?: {
133
+ /** Optional swap deadline (UNIX seconds). Default: now + 20 minutes */
134
+ deadline?: number;
135
+ };
136
+ }): Promise<{
137
+ status: boolean;
138
+ txHash: string;
139
+ chainId: number;
140
+ stage: string;
141
+ } | {
142
+ status: boolean;
143
+ message: string;
144
+ stage: string;
145
+ }>;
146
+
147
+ export { type BalanceRequestParams as B, type PlaceOrderResult as P, type QuoteTokenInfo as Q, type SwapQuoteParams as S, type TokenBalance as T, type SwapQuoteResponse as a, type Stage as b, type BalanceResponse as c, type TokenSearchResponse as d, executeOrder as e, type TokenInfo as f };