@xswap-link/sdk 0.0.12 → 0.1.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.
Files changed (81) hide show
  1. package/.github/workflows/main.yml +1 -1
  2. package/.github/workflows/publish.yml +1 -1
  3. package/.prettierrc +7 -0
  4. package/CHANGELOG.md +17 -0
  5. package/README.md +23 -14
  6. package/dist/index.css +1012 -0
  7. package/dist/index.d.mts +209 -52
  8. package/dist/index.d.ts +209 -52
  9. package/dist/index.js +33963 -88
  10. package/dist/index.mjs +33949 -76
  11. package/package.json +8 -2
  12. package/postcss.config.js +3 -0
  13. package/src/components/Alert/index.tsx +9 -0
  14. package/src/components/Skeleton/index.tsx +10 -0
  15. package/src/components/TxConfigForm/Form.tsx +567 -0
  16. package/src/components/TxConfigForm/History.tsx +159 -0
  17. package/src/components/TxConfigForm/HistoryCard.tsx +209 -0
  18. package/src/components/TxConfigForm/TokenPicker.tsx +165 -0
  19. package/src/components/TxConfigForm/index.jsx +100 -0
  20. package/src/components/global.css +34 -0
  21. package/src/components/global.d.ts +6 -0
  22. package/src/components/icons/ArrowRightIcon.tsx +11 -0
  23. package/src/components/icons/ArrowUpRightIcon.tsx +11 -0
  24. package/src/components/icons/CheckIcon.tsx +11 -0
  25. package/src/components/icons/ChevronDownIcon.tsx +15 -0
  26. package/src/components/icons/ChevronUpIcon.tsx +15 -0
  27. package/src/components/icons/CircularProgressIcon.tsx +24 -0
  28. package/src/components/icons/CloseIcon.tsx +15 -0
  29. package/src/components/icons/CoinsIcon.tsx +15 -0
  30. package/src/components/icons/DownArrorIcon.tsx +17 -0
  31. package/src/components/icons/HistoryIcon.tsx +13 -0
  32. package/src/components/icons/HourGlassIcon.tsx +11 -0
  33. package/src/components/icons/PercentageIcon.tsx +29 -0
  34. package/src/components/icons/SearchIcon.tsx +15 -0
  35. package/src/components/icons/XMarkIcon.tsx +11 -0
  36. package/src/components/icons/index.ts +14 -0
  37. package/src/components/index.ts +3 -0
  38. package/src/constants/index.ts +6 -5
  39. package/src/contracts/abi/BatchQuery.json +52 -0
  40. package/src/contracts/abi/index.ts +2 -0
  41. package/src/contracts/addresses.ts +34 -0
  42. package/src/contracts/index.ts +1 -0
  43. package/src/hooks/index.ts +1 -0
  44. package/src/hooks/useDebounce.tsx +21 -0
  45. package/src/index.ts +6 -0
  46. package/src/models/Addresses.ts +12 -0
  47. package/src/models/Route.ts +17 -5
  48. package/src/models/TokenData.ts +45 -0
  49. package/src/models/TransactionHistory.ts +48 -0
  50. package/src/models/XSwapConfig.ts +3 -0
  51. package/src/models/forms/TxConfigFormData.ts +8 -0
  52. package/src/models/forms/index.ts +1 -0
  53. package/src/models/index.ts +6 -6
  54. package/src/models/integrations/GenerateStakingCallsParams.ts +8 -0
  55. package/src/models/integrations/index.ts +1 -0
  56. package/src/models/payloads/GetPricesPayload.ts +4 -0
  57. package/src/models/payloads/GetRoutePayload.ts +1 -3
  58. package/src/models/payloads/GetSwapTxPayload.ts +8 -0
  59. package/src/models/payloads/index.ts +2 -0
  60. package/src/services/api.ts +46 -64
  61. package/src/services/index.ts +1 -0
  62. package/src/services/integrations/customCalls/index.ts +1 -0
  63. package/src/services/integrations/customCalls/staking.ts +83 -0
  64. package/src/services/integrations/index.ts +2 -0
  65. package/src/services/integrations/transactions.ts +30 -0
  66. package/src/utils/contracts.ts +153 -11
  67. package/src/utils/index.ts +49 -1
  68. package/src/utils/numbers.ts +47 -0
  69. package/src/utils/strings.ts +6 -0
  70. package/tailwind.config.js +14 -0
  71. package/test/api.test.ts +1 -1
  72. package/tsconfig.json +10 -1
  73. package/xswap.config.ts +18 -0
  74. package/index.ts +0 -5
  75. package/src/models/ApiOverrides.ts +0 -3
  76. package/src/models/Chain.ts +0 -20
  77. package/src/models/Prices.ts +0 -9
  78. package/src/models/Token.ts +0 -10
  79. package/src/models/XSwapFee.ts +0 -4
  80. package/src/models/XSwapFees.ts +0 -7
  81. package/src/utils/bigNumbers.ts +0 -7
package/dist/index.d.mts CHANGED
@@ -1,8 +1,38 @@
1
+ import * as react_jsx_runtime from 'react/jsx-runtime';
2
+ import { BigNumber, ethers, BigNumberish } from 'ethers';
1
3
  import { TransactionRequest } from '@ethersproject/providers';
2
- import { BigNumber, BigNumberish, ethers } from 'ethers';
3
4
 
4
- type ApiOverrides = {
5
- apiUrl?: string;
5
+ declare const Alert: ({ desc }: {
6
+ desc: string;
7
+ }) => react_jsx_runtime.JSX.Element;
8
+
9
+ declare function openTxConfigForm({ dstChainId, dstTokenAddr, customContractCalls, desc, supportedChains, }: {
10
+ dstChainId: any;
11
+ dstTokenAddr: any;
12
+ customContractCalls: any;
13
+ desc: any;
14
+ supportedChains: any;
15
+ }): Promise<any>;
16
+
17
+ declare const Skeleton: ({ w, h }: Style) => react_jsx_runtime.JSX.Element;
18
+ type Style = {
19
+ w: string;
20
+ h: string;
21
+ };
22
+
23
+ type Addresses = {
24
+ [chainId: string]: Contracts;
25
+ };
26
+ type Contracts = {
27
+ [contractName in ContractName]: string;
28
+ };
29
+ declare enum ContractName {
30
+ BatchQuery = "BatchQuery",
31
+ FeeCollector = "FeeCollector"
32
+ }
33
+
34
+ type XSwapConfig = {
35
+ apiUrl: string;
6
36
  };
7
37
 
8
38
  type BridgeToken = {
@@ -15,17 +45,6 @@ declare enum Web3Environment {
15
45
  MAINNET = "mainnet"
16
46
  }
17
47
 
18
- type Token = {
19
- address: string;
20
- name: string;
21
- symbol: string;
22
- decimals: number;
23
- image: string;
24
- priority: number;
25
- quickPick?: boolean;
26
- supported?: boolean;
27
- };
28
-
29
48
  type Chain = {
30
49
  ecosystem: string;
31
50
  chainId: string;
@@ -43,6 +62,27 @@ type Chain = {
43
62
  privateRpcUrls?: string[];
44
63
  scanApiURL?: string;
45
64
  };
65
+ type Token = {
66
+ address: string;
67
+ name: string;
68
+ symbol: string;
69
+ decimals: number;
70
+ image: string;
71
+ priority: number;
72
+ quickPick?: boolean;
73
+ supported?: boolean;
74
+ };
75
+ type Prices = {
76
+ blockchainId: string;
77
+ updatedAt: Date;
78
+ prices: TokenPrices;
79
+ };
80
+ type TokenPrices = {
81
+ [tokenAddress: string]: string;
82
+ };
83
+ type TokenBalances = {
84
+ [tokenAddress: string]: BigNumber | undefined;
85
+ };
46
86
 
47
87
  type CoinTypeAddress = {
48
88
  coinType: number;
@@ -80,6 +120,23 @@ declare enum Environment {
80
120
  LOCAL = "local"
81
121
  }
82
122
 
123
+ type TxConfigFormData = {
124
+ srcChain: string;
125
+ srcToken: string;
126
+ amountIn: string;
127
+ paymentToken: string;
128
+ slippage: number;
129
+ expressDelivery: boolean;
130
+ };
131
+
132
+ type GenerateStakingCallsParams = {
133
+ token: string;
134
+ staking: string;
135
+ stakingAbi: string;
136
+ stakingFunName: string;
137
+ stakingFunParams: any[];
138
+ };
139
+
83
140
  type GetRoutePayload = {
84
141
  fromChain: string;
85
142
  toChain: string;
@@ -106,6 +163,18 @@ type AddReferralPayload = {
106
163
  address: string;
107
164
  };
108
165
 
166
+ type GetSwapTxPayload = {
167
+ dstChain: string;
168
+ dstToken: string;
169
+ customContractCalls?: ContractCall[];
170
+ desc?: string;
171
+ };
172
+
173
+ type GetPricesPayload = {
174
+ chainId: string;
175
+ currency?: string;
176
+ };
177
+
109
178
  type Protocol = {
110
179
  name: string;
111
180
  part: number;
@@ -113,26 +182,25 @@ type Protocol = {
113
182
  toTokenAddress: string;
114
183
  };
115
184
 
116
- type XSwapFee = {
117
- tokenFee: string;
118
- nativeFee: string;
185
+ type Route = {
186
+ estAmountOut: string;
187
+ minAmountOut: string;
188
+ transactions: Transactions;
189
+ xSwapFees: XSwapFees;
190
+ message?: string;
191
+ };
192
+ type Transactions = {
193
+ approve?: TransactionRequest;
194
+ swap: TransactionRequest;
119
195
  };
120
-
121
196
  type XSwapFees = {
122
197
  ccipFee?: string;
123
198
  xSwapFee: XSwapFee;
124
199
  expressDeliveryFee?: string;
125
200
  };
126
-
127
- type Route = {
128
- estAmountOut: string;
129
- minAmountOut: string;
130
- transactions: {
131
- approve: TransactionRequest;
132
- swap: TransactionRequest;
133
- };
134
- xSwapFees: XSwapFees;
135
- message?: string;
201
+ type XSwapFee = {
202
+ tokenFee: string;
203
+ nativeFee: string;
136
204
  };
137
205
 
138
206
  type Referral = {
@@ -145,21 +213,81 @@ type ReferralInfo = {
145
213
  ipAddress: string;
146
214
  };
147
215
 
148
- type Prices = {
149
- blockchainId: string;
150
- updatedAt: Date;
151
- prices: TokenPrice;
216
+ type TransferType = "CROSS_CHAIN" | "SINGLE_CHAIN";
217
+ type TransactionHistory = {
218
+ history: {
219
+ transferId: string;
220
+ transferType: TransferType;
221
+ walletAddress: string;
222
+ failed: boolean;
223
+ source: {
224
+ blockchainId: string;
225
+ transactionHash: string;
226
+ blockTime: Date;
227
+ tokenAmount: string;
228
+ tokenAddress: string;
229
+ transferredTokenAddress: string;
230
+ transferredTokenAmount: string;
231
+ valueForInstantCcipRecieve: string;
232
+ tokenOutAddress: string;
233
+ estimatedAmountOut: string;
234
+ targetBlockchainId: string;
235
+ } | null;
236
+ target: {
237
+ blockchainId: string;
238
+ transactionHash: string;
239
+ blockTime: Date;
240
+ tokenAmount: string;
241
+ tokenAddress: string;
242
+ } | null;
243
+ }[];
152
244
  };
153
- type TokenPrice = {
154
- [tokenAddress: string]: string;
245
+ type TransactionStatus = "IN_PROGRESS" | "DONE" | "REVERTED";
246
+ type Transaction = {
247
+ hash: string;
248
+ timestamp: number;
249
+ sourceChainId: string;
250
+ targetChainId: string;
251
+ amountWei: string;
252
+ tokenAddress: string;
253
+ tokenOutAddress: string | undefined;
254
+ tokenOutAmount: string | undefined;
255
+ estimatedDeliveryTimestamp: number;
256
+ status: TransactionStatus;
155
257
  };
156
258
 
157
- declare const DEFAULT_API_URL = "https://xswap.link/api";
158
- declare const DEFAULT_DB_ERROR = "No data for provided parameters";
159
259
  declare const DEFAULT_ECOSYSTEM = Ecosystem.EVM;
160
- declare const DEFAULT_NATIVE_FEE_MULTIPLIER_PERCENTAGE = 105;
161
- declare const DEFAULT_GAS_LIMIT_MULTIPLIER = 1.2;
260
+ declare const NUMBER_INPUT_REGEX: RegExp;
261
+ declare const SLIPPAGE_PRESETS: number[];
262
+ declare const FALLBACK_CROSSCHAIN_ESTIMATION_TIME: number;
263
+ declare const BALANCES_CHUNK_SIZE = 500;
264
+ declare const BALANCE_DISPLAY_MIN_LIMIT = 0.0001;
162
265
 
266
+ declare const BatchQueryAbi: ({
267
+ inputs: {
268
+ internalType: string;
269
+ name: string;
270
+ type: string;
271
+ }[];
272
+ name: string;
273
+ type: string;
274
+ outputs?: undefined;
275
+ stateMutability?: undefined;
276
+ } | {
277
+ inputs: {
278
+ internalType: string;
279
+ name: string;
280
+ type: string;
281
+ }[];
282
+ name: string;
283
+ outputs: {
284
+ internalType: string;
285
+ name: string;
286
+ type: string;
287
+ }[];
288
+ stateMutability: string;
289
+ type: string;
290
+ })[];
163
291
  declare const ERC20Abi: ({
164
292
  constant: boolean;
165
293
  inputs: {
@@ -322,41 +450,70 @@ declare const XSwapRouterAbi: ({
322
450
  outputs?: undefined;
323
451
  })[];
324
452
 
453
+ declare const ADDRESSES: Addresses;
454
+
325
455
  /**
326
456
  * Get swap route based on provided criteria.
327
457
  * @param payload required
328
- * @param overrides optional - e.g. {apiUrl}
329
458
  */
330
- declare function getRoute(payload: GetRoutePayload, overrides?: ApiOverrides): Promise<Route>;
459
+ declare function getRoute(payload: GetRoutePayload): Promise<Route>;
331
460
  /**
332
461
  * GET chains based on provided criteria.
333
462
  * @param ecosystem optional
334
- * @param overrides optional - e.g. {apiUrl}
335
463
  */
336
- declare function getChains(ecosystem?: Ecosystem, overrides?: ApiOverrides): Promise<Chain[]>;
464
+ declare function getChains(ecosystem?: Ecosystem): Promise<Chain[]>;
337
465
  /**
338
466
  * GET chain data based on provided criteria.
339
467
  * @param chainId
340
468
  * @param ecosystem optional - Default: {@link DEFAULT_ECOSYSTEM}
341
- * @param overrides optional - e.g. {apiUrl}
342
469
  */
343
- declare function getChainData(chainId?: string, ecosystem?: Ecosystem, overrides?: ApiOverrides): Promise<Chain>;
470
+ declare function getChainData(chainId?: string, ecosystem?: Ecosystem): Promise<Chain>;
344
471
  /**
345
472
  * GET Tokens based on provided criteria
346
473
  * @param chainId required
347
474
  * @param address optional
348
475
  * @param ecosystem optional but {@link DEFAULT_ECOSYSTEM} will be considered
349
- * @param overrides optional - e.g. {apiUrl}
350
476
  */
351
- declare function getTokens(chainId: string, address?: string, ecosystem?: Ecosystem, overrides?: ApiOverrides): Promise<Token[]>;
352
- declare function getBridgeTokens(overrides?: ApiOverrides): Promise<BridgeToken[]>;
477
+ declare function getTokens(chainId: string, address?: string, ecosystem?: Ecosystem): Promise<Token[]>;
478
+ declare function getBridgeTokens(): Promise<BridgeToken[]>;
479
+ declare function getHistory(payload: {
480
+ walletAddress: string;
481
+ }): Promise<TransactionHistory>;
482
+ declare function getPrices(payload: GetPricesPayload): Promise<TokenPrices>;
483
+
484
+ declare const generateStakingCalls: ({ token, staking, stakingAbi, stakingFunName, stakingFunParams, }: GenerateStakingCallsParams) => ContractCall[];
485
+
486
+ declare const getSwapTx: ({ dstChain, dstToken, customContractCalls, desc, }: GetSwapTxPayload) => Promise<Transactions>;
487
+
488
+ declare const IERC20: ethers.utils.Interface;
489
+ declare const getBalanceOf: (wallet: string, token: string, rpcUrl: string) => Promise<string>;
490
+ declare const getBalances: (chain: Chain, wallet: string) => Promise<TokenBalances>;
491
+ declare const generateApproveTxData: (tokenAddress: string, spender: string, amount: BigNumberish) => TransactionRequest | undefined;
492
+ /**
493
+ * Calculate param's value offset within the encoded function's bytecode.
494
+ * @param abi
495
+ * @param funName
496
+ * @param funParams
497
+ * @param placeholderValue
498
+ */
499
+ declare const findPlaceholderIndex: (abi: string, funName: string, funParams: any[], placeholderValue: BigNumber) => number;
353
500
 
354
501
  declare const safeBigNumberFrom: (value: string) => BigNumber;
502
+ declare const weiToHumanReadable: ({ amount, decimals, precisionFractionalPlaces, prettifySmallNumber, }: {
503
+ amount: string;
504
+ decimals: number;
505
+ precisionFractionalPlaces: number;
506
+ prettifySmallNumber?: boolean;
507
+ }) => string;
508
+ declare const generateRandomBigNumber: (length: number) => BigNumber;
509
+ declare const generateUniqueRandomBigNumber: (length: number, existingValues: any[]) => BigNumber;
510
+
511
+ declare const shortAddress: (address: string) => string;
355
512
 
356
- declare const generateApproveTxData: (tokenAddress: string, spender: string, amount: BigNumberish) => {
357
- to: string;
358
- value: ethers.BigNumber;
359
- data: string;
513
+ declare const replaceNull: (values: any[], newValue: any) => any[];
514
+ declare const deepMergeObjects: (obj1: Record<string, any>, obj2: Record<string, any>) => {
515
+ [x: string]: any;
360
516
  };
517
+ declare const chunkArray: (array: any[], chunkSize: number) => any[][];
361
518
 
362
- export { type AddReferralPayload, type ApiOverrides, type BridgeToken, type Chain, type CoinTypeAddress, type CollectFees, type ContractCall, DEFAULT_API_URL, DEFAULT_DB_ERROR, DEFAULT_ECOSYSTEM, DEFAULT_GAS_LIMIT_MULTIPLIER, DEFAULT_NATIVE_FEE_MULTIPLIER_PERCENTAGE, ERC20Abi, Ecosystem, Environment, type GetRoutePayload, type Prices, type Protocol, type Referral, type ReferralInfo, type Route, type Token, type TokenPrice, Web3Environment, XSwapCallType, type XSwapFee, type XSwapFees, XSwapRouterAbi, generateApproveTxData, getBridgeTokens, getChainData, getChains, getRoute, getTokens, safeBigNumberFrom };
519
+ export { ADDRESSES, type AddReferralPayload, type Addresses, Alert, BALANCES_CHUNK_SIZE, BALANCE_DISPLAY_MIN_LIMIT, BatchQueryAbi, type BridgeToken, type Chain, type CoinTypeAddress, type CollectFees, type ContractCall, ContractName, type Contracts, DEFAULT_ECOSYSTEM, ERC20Abi, Ecosystem, Environment, FALLBACK_CROSSCHAIN_ESTIMATION_TIME, type GenerateStakingCallsParams, type GetPricesPayload, type GetRoutePayload, type GetSwapTxPayload, IERC20, NUMBER_INPUT_REGEX, type Prices, type Protocol, type Referral, type ReferralInfo, type Route, SLIPPAGE_PRESETS, Skeleton, type Token, type TokenBalances, type TokenPrices, type Transaction, type TransactionHistory, type TransactionStatus, type Transactions, type TxConfigFormData, Web3Environment, XSwapCallType, type XSwapConfig, type XSwapFee, type XSwapFees, XSwapRouterAbi, chunkArray, deepMergeObjects, findPlaceholderIndex, generateApproveTxData, generateRandomBigNumber, generateStakingCalls, generateUniqueRandomBigNumber, getBalanceOf, getBalances, getBridgeTokens, getChainData, getChains, getHistory, getPrices, getRoute, getSwapTx, getTokens, openTxConfigForm, replaceNull, safeBigNumberFrom, shortAddress, weiToHumanReadable };
package/dist/index.d.ts CHANGED
@@ -1,8 +1,38 @@
1
+ import * as react_jsx_runtime from 'react/jsx-runtime';
2
+ import { BigNumber, ethers, BigNumberish } from 'ethers';
1
3
  import { TransactionRequest } from '@ethersproject/providers';
2
- import { BigNumber, BigNumberish, ethers } from 'ethers';
3
4
 
4
- type ApiOverrides = {
5
- apiUrl?: string;
5
+ declare const Alert: ({ desc }: {
6
+ desc: string;
7
+ }) => react_jsx_runtime.JSX.Element;
8
+
9
+ declare function openTxConfigForm({ dstChainId, dstTokenAddr, customContractCalls, desc, supportedChains, }: {
10
+ dstChainId: any;
11
+ dstTokenAddr: any;
12
+ customContractCalls: any;
13
+ desc: any;
14
+ supportedChains: any;
15
+ }): Promise<any>;
16
+
17
+ declare const Skeleton: ({ w, h }: Style) => react_jsx_runtime.JSX.Element;
18
+ type Style = {
19
+ w: string;
20
+ h: string;
21
+ };
22
+
23
+ type Addresses = {
24
+ [chainId: string]: Contracts;
25
+ };
26
+ type Contracts = {
27
+ [contractName in ContractName]: string;
28
+ };
29
+ declare enum ContractName {
30
+ BatchQuery = "BatchQuery",
31
+ FeeCollector = "FeeCollector"
32
+ }
33
+
34
+ type XSwapConfig = {
35
+ apiUrl: string;
6
36
  };
7
37
 
8
38
  type BridgeToken = {
@@ -15,17 +45,6 @@ declare enum Web3Environment {
15
45
  MAINNET = "mainnet"
16
46
  }
17
47
 
18
- type Token = {
19
- address: string;
20
- name: string;
21
- symbol: string;
22
- decimals: number;
23
- image: string;
24
- priority: number;
25
- quickPick?: boolean;
26
- supported?: boolean;
27
- };
28
-
29
48
  type Chain = {
30
49
  ecosystem: string;
31
50
  chainId: string;
@@ -43,6 +62,27 @@ type Chain = {
43
62
  privateRpcUrls?: string[];
44
63
  scanApiURL?: string;
45
64
  };
65
+ type Token = {
66
+ address: string;
67
+ name: string;
68
+ symbol: string;
69
+ decimals: number;
70
+ image: string;
71
+ priority: number;
72
+ quickPick?: boolean;
73
+ supported?: boolean;
74
+ };
75
+ type Prices = {
76
+ blockchainId: string;
77
+ updatedAt: Date;
78
+ prices: TokenPrices;
79
+ };
80
+ type TokenPrices = {
81
+ [tokenAddress: string]: string;
82
+ };
83
+ type TokenBalances = {
84
+ [tokenAddress: string]: BigNumber | undefined;
85
+ };
46
86
 
47
87
  type CoinTypeAddress = {
48
88
  coinType: number;
@@ -80,6 +120,23 @@ declare enum Environment {
80
120
  LOCAL = "local"
81
121
  }
82
122
 
123
+ type TxConfigFormData = {
124
+ srcChain: string;
125
+ srcToken: string;
126
+ amountIn: string;
127
+ paymentToken: string;
128
+ slippage: number;
129
+ expressDelivery: boolean;
130
+ };
131
+
132
+ type GenerateStakingCallsParams = {
133
+ token: string;
134
+ staking: string;
135
+ stakingAbi: string;
136
+ stakingFunName: string;
137
+ stakingFunParams: any[];
138
+ };
139
+
83
140
  type GetRoutePayload = {
84
141
  fromChain: string;
85
142
  toChain: string;
@@ -106,6 +163,18 @@ type AddReferralPayload = {
106
163
  address: string;
107
164
  };
108
165
 
166
+ type GetSwapTxPayload = {
167
+ dstChain: string;
168
+ dstToken: string;
169
+ customContractCalls?: ContractCall[];
170
+ desc?: string;
171
+ };
172
+
173
+ type GetPricesPayload = {
174
+ chainId: string;
175
+ currency?: string;
176
+ };
177
+
109
178
  type Protocol = {
110
179
  name: string;
111
180
  part: number;
@@ -113,26 +182,25 @@ type Protocol = {
113
182
  toTokenAddress: string;
114
183
  };
115
184
 
116
- type XSwapFee = {
117
- tokenFee: string;
118
- nativeFee: string;
185
+ type Route = {
186
+ estAmountOut: string;
187
+ minAmountOut: string;
188
+ transactions: Transactions;
189
+ xSwapFees: XSwapFees;
190
+ message?: string;
191
+ };
192
+ type Transactions = {
193
+ approve?: TransactionRequest;
194
+ swap: TransactionRequest;
119
195
  };
120
-
121
196
  type XSwapFees = {
122
197
  ccipFee?: string;
123
198
  xSwapFee: XSwapFee;
124
199
  expressDeliveryFee?: string;
125
200
  };
126
-
127
- type Route = {
128
- estAmountOut: string;
129
- minAmountOut: string;
130
- transactions: {
131
- approve: TransactionRequest;
132
- swap: TransactionRequest;
133
- };
134
- xSwapFees: XSwapFees;
135
- message?: string;
201
+ type XSwapFee = {
202
+ tokenFee: string;
203
+ nativeFee: string;
136
204
  };
137
205
 
138
206
  type Referral = {
@@ -145,21 +213,81 @@ type ReferralInfo = {
145
213
  ipAddress: string;
146
214
  };
147
215
 
148
- type Prices = {
149
- blockchainId: string;
150
- updatedAt: Date;
151
- prices: TokenPrice;
216
+ type TransferType = "CROSS_CHAIN" | "SINGLE_CHAIN";
217
+ type TransactionHistory = {
218
+ history: {
219
+ transferId: string;
220
+ transferType: TransferType;
221
+ walletAddress: string;
222
+ failed: boolean;
223
+ source: {
224
+ blockchainId: string;
225
+ transactionHash: string;
226
+ blockTime: Date;
227
+ tokenAmount: string;
228
+ tokenAddress: string;
229
+ transferredTokenAddress: string;
230
+ transferredTokenAmount: string;
231
+ valueForInstantCcipRecieve: string;
232
+ tokenOutAddress: string;
233
+ estimatedAmountOut: string;
234
+ targetBlockchainId: string;
235
+ } | null;
236
+ target: {
237
+ blockchainId: string;
238
+ transactionHash: string;
239
+ blockTime: Date;
240
+ tokenAmount: string;
241
+ tokenAddress: string;
242
+ } | null;
243
+ }[];
152
244
  };
153
- type TokenPrice = {
154
- [tokenAddress: string]: string;
245
+ type TransactionStatus = "IN_PROGRESS" | "DONE" | "REVERTED";
246
+ type Transaction = {
247
+ hash: string;
248
+ timestamp: number;
249
+ sourceChainId: string;
250
+ targetChainId: string;
251
+ amountWei: string;
252
+ tokenAddress: string;
253
+ tokenOutAddress: string | undefined;
254
+ tokenOutAmount: string | undefined;
255
+ estimatedDeliveryTimestamp: number;
256
+ status: TransactionStatus;
155
257
  };
156
258
 
157
- declare const DEFAULT_API_URL = "https://xswap.link/api";
158
- declare const DEFAULT_DB_ERROR = "No data for provided parameters";
159
259
  declare const DEFAULT_ECOSYSTEM = Ecosystem.EVM;
160
- declare const DEFAULT_NATIVE_FEE_MULTIPLIER_PERCENTAGE = 105;
161
- declare const DEFAULT_GAS_LIMIT_MULTIPLIER = 1.2;
260
+ declare const NUMBER_INPUT_REGEX: RegExp;
261
+ declare const SLIPPAGE_PRESETS: number[];
262
+ declare const FALLBACK_CROSSCHAIN_ESTIMATION_TIME: number;
263
+ declare const BALANCES_CHUNK_SIZE = 500;
264
+ declare const BALANCE_DISPLAY_MIN_LIMIT = 0.0001;
162
265
 
266
+ declare const BatchQueryAbi: ({
267
+ inputs: {
268
+ internalType: string;
269
+ name: string;
270
+ type: string;
271
+ }[];
272
+ name: string;
273
+ type: string;
274
+ outputs?: undefined;
275
+ stateMutability?: undefined;
276
+ } | {
277
+ inputs: {
278
+ internalType: string;
279
+ name: string;
280
+ type: string;
281
+ }[];
282
+ name: string;
283
+ outputs: {
284
+ internalType: string;
285
+ name: string;
286
+ type: string;
287
+ }[];
288
+ stateMutability: string;
289
+ type: string;
290
+ })[];
163
291
  declare const ERC20Abi: ({
164
292
  constant: boolean;
165
293
  inputs: {
@@ -322,41 +450,70 @@ declare const XSwapRouterAbi: ({
322
450
  outputs?: undefined;
323
451
  })[];
324
452
 
453
+ declare const ADDRESSES: Addresses;
454
+
325
455
  /**
326
456
  * Get swap route based on provided criteria.
327
457
  * @param payload required
328
- * @param overrides optional - e.g. {apiUrl}
329
458
  */
330
- declare function getRoute(payload: GetRoutePayload, overrides?: ApiOverrides): Promise<Route>;
459
+ declare function getRoute(payload: GetRoutePayload): Promise<Route>;
331
460
  /**
332
461
  * GET chains based on provided criteria.
333
462
  * @param ecosystem optional
334
- * @param overrides optional - e.g. {apiUrl}
335
463
  */
336
- declare function getChains(ecosystem?: Ecosystem, overrides?: ApiOverrides): Promise<Chain[]>;
464
+ declare function getChains(ecosystem?: Ecosystem): Promise<Chain[]>;
337
465
  /**
338
466
  * GET chain data based on provided criteria.
339
467
  * @param chainId
340
468
  * @param ecosystem optional - Default: {@link DEFAULT_ECOSYSTEM}
341
- * @param overrides optional - e.g. {apiUrl}
342
469
  */
343
- declare function getChainData(chainId?: string, ecosystem?: Ecosystem, overrides?: ApiOverrides): Promise<Chain>;
470
+ declare function getChainData(chainId?: string, ecosystem?: Ecosystem): Promise<Chain>;
344
471
  /**
345
472
  * GET Tokens based on provided criteria
346
473
  * @param chainId required
347
474
  * @param address optional
348
475
  * @param ecosystem optional but {@link DEFAULT_ECOSYSTEM} will be considered
349
- * @param overrides optional - e.g. {apiUrl}
350
476
  */
351
- declare function getTokens(chainId: string, address?: string, ecosystem?: Ecosystem, overrides?: ApiOverrides): Promise<Token[]>;
352
- declare function getBridgeTokens(overrides?: ApiOverrides): Promise<BridgeToken[]>;
477
+ declare function getTokens(chainId: string, address?: string, ecosystem?: Ecosystem): Promise<Token[]>;
478
+ declare function getBridgeTokens(): Promise<BridgeToken[]>;
479
+ declare function getHistory(payload: {
480
+ walletAddress: string;
481
+ }): Promise<TransactionHistory>;
482
+ declare function getPrices(payload: GetPricesPayload): Promise<TokenPrices>;
483
+
484
+ declare const generateStakingCalls: ({ token, staking, stakingAbi, stakingFunName, stakingFunParams, }: GenerateStakingCallsParams) => ContractCall[];
485
+
486
+ declare const getSwapTx: ({ dstChain, dstToken, customContractCalls, desc, }: GetSwapTxPayload) => Promise<Transactions>;
487
+
488
+ declare const IERC20: ethers.utils.Interface;
489
+ declare const getBalanceOf: (wallet: string, token: string, rpcUrl: string) => Promise<string>;
490
+ declare const getBalances: (chain: Chain, wallet: string) => Promise<TokenBalances>;
491
+ declare const generateApproveTxData: (tokenAddress: string, spender: string, amount: BigNumberish) => TransactionRequest | undefined;
492
+ /**
493
+ * Calculate param's value offset within the encoded function's bytecode.
494
+ * @param abi
495
+ * @param funName
496
+ * @param funParams
497
+ * @param placeholderValue
498
+ */
499
+ declare const findPlaceholderIndex: (abi: string, funName: string, funParams: any[], placeholderValue: BigNumber) => number;
353
500
 
354
501
  declare const safeBigNumberFrom: (value: string) => BigNumber;
502
+ declare const weiToHumanReadable: ({ amount, decimals, precisionFractionalPlaces, prettifySmallNumber, }: {
503
+ amount: string;
504
+ decimals: number;
505
+ precisionFractionalPlaces: number;
506
+ prettifySmallNumber?: boolean;
507
+ }) => string;
508
+ declare const generateRandomBigNumber: (length: number) => BigNumber;
509
+ declare const generateUniqueRandomBigNumber: (length: number, existingValues: any[]) => BigNumber;
510
+
511
+ declare const shortAddress: (address: string) => string;
355
512
 
356
- declare const generateApproveTxData: (tokenAddress: string, spender: string, amount: BigNumberish) => {
357
- to: string;
358
- value: ethers.BigNumber;
359
- data: string;
513
+ declare const replaceNull: (values: any[], newValue: any) => any[];
514
+ declare const deepMergeObjects: (obj1: Record<string, any>, obj2: Record<string, any>) => {
515
+ [x: string]: any;
360
516
  };
517
+ declare const chunkArray: (array: any[], chunkSize: number) => any[][];
361
518
 
362
- export { type AddReferralPayload, type ApiOverrides, type BridgeToken, type Chain, type CoinTypeAddress, type CollectFees, type ContractCall, DEFAULT_API_URL, DEFAULT_DB_ERROR, DEFAULT_ECOSYSTEM, DEFAULT_GAS_LIMIT_MULTIPLIER, DEFAULT_NATIVE_FEE_MULTIPLIER_PERCENTAGE, ERC20Abi, Ecosystem, Environment, type GetRoutePayload, type Prices, type Protocol, type Referral, type ReferralInfo, type Route, type Token, type TokenPrice, Web3Environment, XSwapCallType, type XSwapFee, type XSwapFees, XSwapRouterAbi, generateApproveTxData, getBridgeTokens, getChainData, getChains, getRoute, getTokens, safeBigNumberFrom };
519
+ export { ADDRESSES, type AddReferralPayload, type Addresses, Alert, BALANCES_CHUNK_SIZE, BALANCE_DISPLAY_MIN_LIMIT, BatchQueryAbi, type BridgeToken, type Chain, type CoinTypeAddress, type CollectFees, type ContractCall, ContractName, type Contracts, DEFAULT_ECOSYSTEM, ERC20Abi, Ecosystem, Environment, FALLBACK_CROSSCHAIN_ESTIMATION_TIME, type GenerateStakingCallsParams, type GetPricesPayload, type GetRoutePayload, type GetSwapTxPayload, IERC20, NUMBER_INPUT_REGEX, type Prices, type Protocol, type Referral, type ReferralInfo, type Route, SLIPPAGE_PRESETS, Skeleton, type Token, type TokenBalances, type TokenPrices, type Transaction, type TransactionHistory, type TransactionStatus, type Transactions, type TxConfigFormData, Web3Environment, XSwapCallType, type XSwapConfig, type XSwapFee, type XSwapFees, XSwapRouterAbi, chunkArray, deepMergeObjects, findPlaceholderIndex, generateApproveTxData, generateRandomBigNumber, generateStakingCalls, generateUniqueRandomBigNumber, getBalanceOf, getBalances, getBridgeTokens, getChainData, getChains, getHistory, getPrices, getRoute, getSwapTx, getTokens, openTxConfigForm, replaceNull, safeBigNumberFrom, shortAddress, weiToHumanReadable };