uniport-sdk 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,319 @@
1
+ export { ApiError, OneClickService, OpenAPI } from '@defuse-protocol/one-click-sdk-typescript';
2
+
3
+ /**
4
+ * Uniport Token Definitions
5
+ *
6
+ * Importable token constants for the Uniport SDK.
7
+ * Usage: import { arbitrumUSDC, suiSUI, CHAINS } from 'uniport/tokens'
8
+ *
9
+ * Token naming convention: {chain}{Symbol}
10
+ * Example: arbitrumUSDC, ethereumETH, suiSUI
11
+ */
12
+ declare const TOKEN_ICONS: {
13
+ readonly USDC: "https://raw.githubusercontent.com/trustwallet/assets/master/blockchains/ethereum/assets/0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48/logo.png";
14
+ readonly USDT: "https://raw.githubusercontent.com/trustwallet/assets/master/blockchains/ethereum/assets/0xdAC17F958D2ee523a2206206994597C13D831ec7/logo.png";
15
+ readonly DAI: "https://raw.githubusercontent.com/trustwallet/assets/master/blockchains/ethereum/assets/0x6B175474E89094C44Da98b954EesdfdsfdC495271d0F/logo.png";
16
+ readonly ETH: "https://raw.githubusercontent.com/trustwallet/assets/master/blockchains/ethereum/info/logo.png";
17
+ readonly WETH: "https://raw.githubusercontent.com/trustwallet/assets/master/blockchains/ethereum/assets/0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2/logo.png";
18
+ readonly BTC: "https://raw.githubusercontent.com/trustwallet/assets/master/blockchains/bitcoin/info/logo.png";
19
+ readonly WBTC: "https://raw.githubusercontent.com/trustwallet/assets/master/blockchains/ethereum/assets/0x2260FAC5E5542a773Aa44fBCfeDf7C193bc2C599/logo.png";
20
+ readonly SUI: "https://raw.githubusercontent.com/trustwallet/assets/master/blockchains/sui/info/logo.png";
21
+ readonly SOL: "https://raw.githubusercontent.com/trustwallet/assets/master/blockchains/solana/info/logo.png";
22
+ readonly NEAR: "https://raw.githubusercontent.com/trustwallet/assets/master/blockchains/near/info/logo.png";
23
+ readonly ARB: "https://raw.githubusercontent.com/trustwallet/assets/master/blockchains/arbitrum/info/logo.png";
24
+ readonly OP: "https://raw.githubusercontent.com/trustwallet/assets/master/blockchains/optimism/info/logo.png";
25
+ readonly POL: "https://raw.githubusercontent.com/trustwallet/assets/master/blockchains/polygon/info/logo.png";
26
+ readonly AVAX: "https://raw.githubusercontent.com/trustwallet/assets/master/blockchains/avalanchec/info/logo.png";
27
+ readonly BNB: "https://raw.githubusercontent.com/trustwallet/assets/master/blockchains/binance/info/logo.png";
28
+ readonly BASE: "https://raw.githubusercontent.com/trustwallet/assets/master/blockchains/base/info/logo.png";
29
+ readonly ADA: "https://raw.githubusercontent.com/trustwallet/assets/master/blockchains/cardano/info/logo.png";
30
+ readonly XRP: "https://raw.githubusercontent.com/trustwallet/assets/master/blockchains/ripple/info/logo.png";
31
+ readonly DOGE: "https://raw.githubusercontent.com/trustwallet/assets/master/blockchains/doge/info/logo.png";
32
+ readonly LTC: "https://raw.githubusercontent.com/trustwallet/assets/master/blockchains/litecoin/info/logo.png";
33
+ readonly BCH: "https://raw.githubusercontent.com/trustwallet/assets/master/blockchains/bitcoincash/info/logo.png";
34
+ readonly TON: "https://raw.githubusercontent.com/trustwallet/assets/master/blockchains/ton/info/logo.png";
35
+ readonly TRX: "https://raw.githubusercontent.com/trustwallet/assets/master/blockchains/tron/info/logo.png";
36
+ readonly XLM: "https://raw.githubusercontent.com/trustwallet/assets/master/blockchains/stellar/info/logo.png";
37
+ readonly APT: "https://raw.githubusercontent.com/trustwallet/assets/master/blockchains/aptos/info/logo.png";
38
+ readonly AAVE: "https://raw.githubusercontent.com/trustwallet/assets/master/blockchains/ethereum/assets/0x7Fc66500c84A76Ad7e9c93437BFc5Ac33E2DDaE9/logo.png";
39
+ readonly UNI: "https://raw.githubusercontent.com/trustwallet/assets/master/blockchains/ethereum/assets/0x1f9840a85d5aF5bf1D1762F925BDADdC4201F984/logo.png";
40
+ readonly LINK: "https://raw.githubusercontent.com/trustwallet/assets/master/blockchains/ethereum/assets/0x514910771AF9Ca656af840dff83E8264EcF986CA/logo.png";
41
+ readonly SHIB: "https://raw.githubusercontent.com/trustwallet/assets/master/blockchains/ethereum/assets/0x95aD61b0a150d79219dCF64E1E6Cc01f0B64C4cE/logo.png";
42
+ readonly PEPE: "https://raw.githubusercontent.com/trustwallet/assets/master/blockchains/ethereum/assets/0x6982508145454Ce325dDbE47a25d4ec3d2311933/logo.png";
43
+ readonly STRK: "https://assets.coingecko.com/coins/images/26433/standard/starknet.png";
44
+ readonly BERA: "https://assets.coingecko.com/coins/images/34286/standard/bera.png";
45
+ readonly GNO: "https://raw.githubusercontent.com/trustwallet/assets/master/blockchains/ethereum/assets/0x6810e776880C02933D47DB1b9fc05908e5386b96/logo.png";
46
+ readonly MON: "https://assets.coingecko.com/coins/images/35887/standard/monad.png";
47
+ readonly ZEC: "https://raw.githubusercontent.com/trustwallet/assets/master/blockchains/zcash/info/logo.png";
48
+ readonly TRUMP: "https://assets.coingecko.com/coins/images/53746/standard/trump.jpg";
49
+ readonly WIF: "https://assets.coingecko.com/coins/images/33566/standard/dogwifhat.jpg";
50
+ readonly BRETT: "https://assets.coingecko.com/coins/images/35529/standard/brett.png";
51
+ readonly TURBO: "https://assets.coingecko.com/coins/images/30116/standard/turbo.png";
52
+ readonly DEFAULT: "https://raw.githubusercontent.com/trustwallet/assets/master/blockchains/ethereum/info/logo.png";
53
+ };
54
+ declare const CHAIN_ICONS: {
55
+ readonly sui: "https://raw.githubusercontent.com/trustwallet/assets/master/blockchains/sui/info/logo.png";
56
+ readonly eth: "https://raw.githubusercontent.com/trustwallet/assets/master/blockchains/ethereum/info/logo.png";
57
+ readonly arb: "https://raw.githubusercontent.com/trustwallet/assets/master/blockchains/arbitrum/info/logo.png";
58
+ readonly base: "https://raw.githubusercontent.com/trustwallet/assets/master/blockchains/base/info/logo.png";
59
+ readonly op: "https://raw.githubusercontent.com/trustwallet/assets/master/blockchains/optimism/info/logo.png";
60
+ readonly sol: "https://raw.githubusercontent.com/trustwallet/assets/master/blockchains/solana/info/logo.png";
61
+ readonly btc: "https://raw.githubusercontent.com/trustwallet/assets/master/blockchains/bitcoin/info/logo.png";
62
+ readonly near: "https://raw.githubusercontent.com/trustwallet/assets/master/blockchains/near/info/logo.png";
63
+ readonly pol: "https://raw.githubusercontent.com/trustwallet/assets/master/blockchains/polygon/info/logo.png";
64
+ readonly avax: "https://raw.githubusercontent.com/trustwallet/assets/master/blockchains/avalanchec/info/logo.png";
65
+ readonly bsc: "https://raw.githubusercontent.com/trustwallet/assets/master/blockchains/binance/info/logo.png";
66
+ readonly ton: "https://raw.githubusercontent.com/trustwallet/assets/master/blockchains/ton/info/logo.png";
67
+ readonly tron: "https://raw.githubusercontent.com/trustwallet/assets/master/blockchains/tron/info/logo.png";
68
+ readonly stellar: "https://raw.githubusercontent.com/trustwallet/assets/master/blockchains/stellar/info/logo.png";
69
+ readonly cardano: "https://raw.githubusercontent.com/trustwallet/assets/master/blockchains/cardano/info/logo.png";
70
+ readonly aptos: "https://raw.githubusercontent.com/trustwallet/assets/master/blockchains/aptos/info/logo.png";
71
+ readonly gnosis: "https://raw.githubusercontent.com/trustwallet/assets/master/blockchains/xdai/info/logo.png";
72
+ readonly starknet: "https://assets.coingecko.com/coins/images/26433/standard/starknet.png";
73
+ readonly bera: "https://assets.coingecko.com/coins/images/34286/standard/bera.png";
74
+ readonly monad: "https://assets.coingecko.com/coins/images/35887/standard/monad.png";
75
+ readonly doge: "https://raw.githubusercontent.com/trustwallet/assets/master/blockchains/doge/info/logo.png";
76
+ readonly ltc: "https://raw.githubusercontent.com/trustwallet/assets/master/blockchains/litecoin/info/logo.png";
77
+ readonly bch: "https://raw.githubusercontent.com/trustwallet/assets/master/blockchains/bitcoincash/info/logo.png";
78
+ readonly xrp: "https://raw.githubusercontent.com/trustwallet/assets/master/blockchains/ripple/info/logo.png";
79
+ readonly zec: "https://raw.githubusercontent.com/trustwallet/assets/master/blockchains/zcash/info/logo.png";
80
+ };
81
+ type ChainId = keyof typeof CHAIN_ICONS;
82
+ interface Token {
83
+ /** Readable name: arbitrumUSDC, suiSUI */
84
+ name: string;
85
+ /** Display symbol: USDC, SUI, ETH */
86
+ symbol: string;
87
+ /** 1Click API asset ID */
88
+ assetId: string;
89
+ /** Chain identifier */
90
+ chain: ChainId;
91
+ /** Token decimals */
92
+ decimals: number;
93
+ /** Token icon URL */
94
+ icon: string;
95
+ /** Chain icon URL */
96
+ chainIcon: string;
97
+ /** Contract address on the chain (if applicable) */
98
+ contractAddress?: string;
99
+ }
100
+ interface Chain {
101
+ id: ChainId;
102
+ name: string;
103
+ icon: string;
104
+ tokens: Token[];
105
+ }
106
+ declare const suiSUI: Token;
107
+ declare const suiUSDC: Token;
108
+ declare const ethereumETH: Token;
109
+ declare const ethereumUSDC: Token;
110
+ declare const ethereumUSDT: Token;
111
+ declare const ethereumWBTC: Token;
112
+ declare const ethereumDAI: Token;
113
+ declare const ethereumAAVE: Token;
114
+ declare const ethereumUNI: Token;
115
+ declare const ethereumLINK: Token;
116
+ declare const ethereumSHIB: Token;
117
+ declare const ethereumPEPE: Token;
118
+ declare const ethereumTURBO: Token;
119
+ declare const ethereumSAFE: Token;
120
+ declare const arbitrumETH: Token;
121
+ declare const arbitrumUSDC: Token;
122
+ declare const arbitrumUSDT: Token;
123
+ declare const arbitrumARB: Token;
124
+ declare const arbitrumGMX: Token;
125
+ declare const baseETH: Token;
126
+ declare const baseUSDC: Token;
127
+ declare const baseCbBTC: Token;
128
+ declare const baseBRETT: Token;
129
+ declare const optimismETH: Token;
130
+ declare const optimismUSDC: Token;
131
+ declare const optimismUSDT: Token;
132
+ declare const optimismOP: Token;
133
+ declare const solanaSOL: Token;
134
+ declare const solanaUSDC: Token;
135
+ declare const solanaUSDT: Token;
136
+ declare const solanaTRUMP: Token;
137
+ declare const solanaWIF: Token;
138
+ declare const solanaMELANIA: Token;
139
+ declare const bitcoinBTC: Token;
140
+ declare const polygonPOL: Token;
141
+ declare const polygonUSDC: Token;
142
+ declare const polygonUSDT: Token;
143
+ declare const avalancheAVAX: Token;
144
+ declare const avalancheUSDC: Token;
145
+ declare const avalancheUSDT: Token;
146
+ declare const bscBNB: Token;
147
+ declare const bscUSDC: Token;
148
+ declare const bscUSDT: Token;
149
+ declare const tonTON: Token;
150
+ declare const tonUSDT: Token;
151
+ declare const tronTRX: Token;
152
+ declare const tronUSDT: Token;
153
+ declare const cardanoADA: Token;
154
+ declare const rippleXRP: Token;
155
+ declare const dogecoinDOGE: Token;
156
+ declare const litecoinLTC: Token;
157
+ declare const bitcoinCashBCH: Token;
158
+ declare const aptosAPT: Token;
159
+ declare const starknetSTRK: Token;
160
+ declare const berachainBERA: Token;
161
+ declare const zcashZEC: Token;
162
+ declare const nearNEAR: Token;
163
+ declare const nearUSDC: Token;
164
+ declare const nearUSDT: Token;
165
+ declare const CHAINS: Record<ChainId, Chain>;
166
+ declare const ALL_TOKENS: Token[];
167
+ /** Get token by name, e.g. getToken('arbitrumUSDC') */
168
+ declare function getToken(name: string): Token | undefined;
169
+ /** Get all tokens for a specific chain */
170
+ declare function getTokensByChain(chainId: ChainId): Token[];
171
+ /** Get token by asset ID */
172
+ declare function getTokenByAssetId(assetId: string): Token | undefined;
173
+ /** Get all supported chains */
174
+ declare function getSupportedChains(): Chain[];
175
+ /** Get SUI destination tokens (for Uniport) */
176
+ declare function getSuiDestinationTokens(): Token[];
177
+
178
+ /**
179
+ * Uniport Intents Service
180
+ *
181
+ * Core functions for cross-chain swaps via 1Click SDK
182
+ */
183
+
184
+ /** Swap type options */
185
+ type SwapType = 'EXACT_INPUT' | 'EXACT_OUTPUT' | 'FLEX_INPUT' | 'ANY_INPUT';
186
+ /** Quote request options */
187
+ interface QuoteOptions {
188
+ /** Origin token (source chain) */
189
+ originToken: Token;
190
+ /** Destination token (target chain) */
191
+ destinationToken: Token;
192
+ /** Amount in human-readable format (e.g., "1.5" for 1.5 USDC) */
193
+ amount: string;
194
+ /** Recipient address on destination chain */
195
+ recipient: string;
196
+ /** Refund address on origin chain (if swap fails) */
197
+ refundTo: string;
198
+ /** Slippage tolerance in basis points (100 = 1%) */
199
+ slippageTolerance?: number;
200
+ /** Swap type (default: EXACT_INPUT) */
201
+ swapType?: SwapType;
202
+ /** Deadline for the swap (default: 1 hour from now) */
203
+ deadline?: Date;
204
+ /** Dry run - get quote without creating deposit address */
205
+ dry?: boolean;
206
+ /** Referral identifier for tracking */
207
+ referral?: string;
208
+ }
209
+ /** Quote result with deposit info */
210
+ interface QuoteResult {
211
+ /** Unique deposit address to send funds */
212
+ depositAddress: string;
213
+ /** Memo (required for some chains like Stellar) */
214
+ memo?: string;
215
+ /** Expected input amount (smallest units) */
216
+ amountIn: string;
217
+ /** Expected output amount (smallest units) */
218
+ amountOut: string;
219
+ /** Human-readable output amount */
220
+ amountOutFormatted: string;
221
+ /** Estimated USD value of output */
222
+ amountOutUsd?: string;
223
+ /** Deadline for the swap */
224
+ deadline?: string;
225
+ /** When the quote becomes inactive */
226
+ timeWhenInactive?: string;
227
+ /** Correlation ID for tracking */
228
+ correlationId: string;
229
+ }
230
+ /** Execution status */
231
+ type ExecutionStatus = 'PENDING_DEPOSIT' | 'KNOWN_DEPOSIT_TX' | 'PROCESSING' | 'SUCCESS' | 'INCOMPLETE_DEPOSIT' | 'REFUNDED' | 'FAILED';
232
+ /** Status result */
233
+ interface StatusResult {
234
+ /** Current status */
235
+ status: ExecutionStatus;
236
+ /** Whether the swap is complete (success or failed) */
237
+ isComplete: boolean;
238
+ /** Whether the swap succeeded */
239
+ isSuccess: boolean;
240
+ /** Correlation ID for tracking */
241
+ correlationId: string;
242
+ /** Destination chain transaction hashes (if available) */
243
+ destinationTxHashes?: string[];
244
+ /** Origin chain transaction hashes (if available) */
245
+ originTxHashes?: string[];
246
+ }
247
+ /**
248
+ * Convert human-readable amount to smallest units
249
+ */
250
+ declare function toSmallestUnits(amount: string, decimals: number): string;
251
+ /**
252
+ * Convert smallest units to human-readable amount
253
+ */
254
+ declare function fromSmallestUnits(amount: string, decimals: number): string;
255
+ /**
256
+ * Generate a deadline timestamp
257
+ */
258
+ declare function generateDeadline(hoursFromNow?: number): string;
259
+ /**
260
+ * Get a quote for a cross-chain swap
261
+ */
262
+ declare function getQuote(options: QuoteOptions): Promise<QuoteResult>;
263
+ /**
264
+ * Submit a deposit transaction hash to speed up processing
265
+ */
266
+ declare function submitDepositTx(params: {
267
+ txHash: string;
268
+ depositAddress: string;
269
+ memo?: string;
270
+ nearSenderAccount?: string;
271
+ }): Promise<void>;
272
+ /**
273
+ * Get the execution status of a swap
274
+ */
275
+ declare function getExecutionStatus(depositAddress: string, memo?: string): Promise<StatusResult>;
276
+ /**
277
+ * Poll execution status until complete
278
+ */
279
+ declare function pollExecutionStatus(depositAddress: string, options?: {
280
+ memo?: string;
281
+ interval?: number;
282
+ timeout?: number;
283
+ onStatusChange?: (status: StatusResult) => void;
284
+ }): Promise<StatusResult>;
285
+
286
+ /**
287
+ * Uniport SDK Configuration
288
+ */
289
+ interface UniportConfig {
290
+ /** NEAR API key for 1Click service */
291
+ apiKey: string;
292
+ /** API base URL (default: production) */
293
+ baseUrl?: string;
294
+ /** Default referral ID */
295
+ referral?: string;
296
+ }
297
+ /**
298
+ * Initialize the Uniport SDK
299
+ *
300
+ * @example
301
+ * ```ts
302
+ * import { initUniport } from 'uniport'
303
+ *
304
+ * initUniport({
305
+ * apiKey: 'your-near-api-key',
306
+ * })
307
+ * ```
308
+ */
309
+ declare function initUniport(config: UniportConfig): void;
310
+ /**
311
+ * Get the current SDK configuration
312
+ */
313
+ declare function getConfig(): UniportConfig;
314
+ /**
315
+ * Check if SDK is initialized
316
+ */
317
+ declare function isInitialized(): boolean;
318
+
319
+ export { ALL_TOKENS, CHAINS, CHAIN_ICONS, type Chain, type ChainId, type ExecutionStatus, type QuoteOptions, type QuoteResult, type StatusResult, type SwapType, TOKEN_ICONS, type Token, type UniportConfig, aptosAPT, arbitrumARB, arbitrumETH, arbitrumGMX, arbitrumUSDC, arbitrumUSDT, avalancheAVAX, avalancheUSDC, avalancheUSDT, baseBRETT, baseCbBTC, baseETH, baseUSDC, berachainBERA, bitcoinBTC, bitcoinCashBCH, bscBNB, bscUSDC, bscUSDT, cardanoADA, dogecoinDOGE, ethereumAAVE, ethereumDAI, ethereumETH, ethereumLINK, ethereumPEPE, ethereumSAFE, ethereumSHIB, ethereumTURBO, ethereumUNI, ethereumUSDC, ethereumUSDT, ethereumWBTC, fromSmallestUnits, generateDeadline, getConfig, getExecutionStatus, getQuote, getSuiDestinationTokens, getSupportedChains, getToken, getTokenByAssetId, getTokensByChain, initUniport, isInitialized, litecoinLTC, nearNEAR, nearUSDC, nearUSDT, optimismETH, optimismOP, optimismUSDC, optimismUSDT, pollExecutionStatus, polygonPOL, polygonUSDC, polygonUSDT, rippleXRP, solanaMELANIA, solanaSOL, solanaTRUMP, solanaUSDC, solanaUSDT, solanaWIF, starknetSTRK, submitDepositTx, suiSUI, suiUSDC, toSmallestUnits, tonTON, tonUSDT, tronTRX, tronUSDT, zcashZEC };