@0xsequence/hooks 5.2.1 → 5.2.3

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 (58) hide show
  1. package/README.md +0 -15
  2. package/dist/cjs/constants.d.ts +1 -1
  3. package/dist/cjs/constants.js +2 -2
  4. package/dist/cjs/constants.js.map +1 -1
  5. package/dist/cjs/hooks/Combination/useGetSwapQuote.d.ts +32 -22
  6. package/dist/cjs/hooks/Combination/useGetSwapQuote.d.ts.map +1 -1
  7. package/dist/cjs/hooks/Combination/useGetSwapQuote.js +46 -38
  8. package/dist/cjs/hooks/Combination/useGetSwapQuote.js.map +1 -1
  9. package/dist/cjs/hooks/Combination/useGetSwapRoutes.d.ts +61 -0
  10. package/dist/cjs/hooks/Combination/useGetSwapRoutes.d.ts.map +1 -0
  11. package/dist/cjs/hooks/Combination/useGetSwapRoutes.js +79 -0
  12. package/dist/cjs/hooks/Combination/useGetSwapRoutes.js.map +1 -0
  13. package/dist/cjs/index.d.ts +1 -1
  14. package/dist/cjs/index.d.ts.map +1 -1
  15. package/dist/cjs/index.js +3 -4
  16. package/dist/cjs/index.js.map +1 -1
  17. package/dist/cjs/tests/Combination/useGetSwapQuote.test.js +32 -13
  18. package/dist/cjs/tests/Combination/useGetSwapQuote.test.js.map +1 -1
  19. package/dist/cjs/tests/handlers.d.ts.map +1 -1
  20. package/dist/cjs/tests/handlers.js +9 -45
  21. package/dist/cjs/tests/handlers.js.map +1 -1
  22. package/dist/esm/constants.d.ts +1 -1
  23. package/dist/esm/constants.js +2 -2
  24. package/dist/esm/constants.js.map +1 -1
  25. package/dist/esm/hooks/Combination/useGetSwapQuote.d.ts +32 -22
  26. package/dist/esm/hooks/Combination/useGetSwapQuote.d.ts.map +1 -1
  27. package/dist/esm/hooks/Combination/useGetSwapQuote.js +46 -38
  28. package/dist/esm/hooks/Combination/useGetSwapQuote.js.map +1 -1
  29. package/dist/esm/hooks/Combination/useGetSwapRoutes.d.ts +61 -0
  30. package/dist/esm/hooks/Combination/useGetSwapRoutes.d.ts.map +1 -0
  31. package/dist/esm/hooks/Combination/useGetSwapRoutes.js +75 -0
  32. package/dist/esm/hooks/Combination/useGetSwapRoutes.js.map +1 -0
  33. package/dist/esm/index.d.ts +1 -1
  34. package/dist/esm/index.d.ts.map +1 -1
  35. package/dist/esm/index.js +1 -2
  36. package/dist/esm/index.js.map +1 -1
  37. package/dist/esm/tests/Combination/useGetSwapQuote.test.js +32 -13
  38. package/dist/esm/tests/Combination/useGetSwapQuote.test.js.map +1 -1
  39. package/dist/esm/tests/handlers.d.ts.map +1 -1
  40. package/dist/esm/tests/handlers.js +9 -45
  41. package/dist/esm/tests/handlers.js.map +1 -1
  42. package/package.json +17 -17
  43. package/dist/cjs/hooks/Combination/useGetSwapPrices.d.ts +0 -92
  44. package/dist/cjs/hooks/Combination/useGetSwapPrices.d.ts.map +0 -1
  45. package/dist/cjs/hooks/Combination/useGetSwapPrices.js +0 -177
  46. package/dist/cjs/hooks/Combination/useGetSwapPrices.js.map +0 -1
  47. package/dist/cjs/tests/Combination/useGetSwapPrices.test.d.ts +0 -2
  48. package/dist/cjs/tests/Combination/useGetSwapPrices.test.d.ts.map +0 -1
  49. package/dist/cjs/tests/Combination/useGetSwapPrices.test.js +0 -37
  50. package/dist/cjs/tests/Combination/useGetSwapPrices.test.js.map +0 -1
  51. package/dist/esm/hooks/Combination/useGetSwapPrices.d.ts +0 -92
  52. package/dist/esm/hooks/Combination/useGetSwapPrices.d.ts.map +0 -1
  53. package/dist/esm/hooks/Combination/useGetSwapPrices.js +0 -173
  54. package/dist/esm/hooks/Combination/useGetSwapPrices.js.map +0 -1
  55. package/dist/esm/tests/Combination/useGetSwapPrices.test.d.ts +0 -2
  56. package/dist/esm/tests/Combination/useGetSwapPrices.test.d.ts.map +0 -1
  57. package/dist/esm/tests/Combination/useGetSwapPrices.test.js +0 -35
  58. package/dist/esm/tests/Combination/useGetSwapPrices.test.js.map +0 -1
package/README.md CHANGED
@@ -52,7 +52,6 @@ Sequence hooks are grouped into 5 categories, based on the sequence service they
52
52
 
53
53
  ### Combination
54
54
 
55
- - useGetSwapPrices
56
55
  - useGetSwapQuote
57
56
 
58
57
  ## Usage
@@ -328,20 +327,6 @@ const { data, isLoading, error } = useGetTokenMetadata(
328
327
  )
329
328
  ```
330
329
 
331
- ### useGetSwapPrices
332
-
333
- ```tsx
334
- import { useGetSwapPrices } from '@0xsequence/hooks'
335
-
336
- const { data, isLoading, error } = useGetSwapPrices({
337
- userAddress: '0x0123456789012345678901234567890123456789',
338
- buyCurrencyAddress: '0x0123456789012345678901234567890123456789',
339
- buyAmount: '1',
340
- chainId: 1,
341
- withContractInfo: true // optional
342
- })
343
- ```
344
-
345
330
  ### useGetSwapQuote
346
331
 
347
332
  ```tsx
@@ -12,8 +12,8 @@ export declare const QUERY_KEYS: {
12
12
  useGetExchangeRate: string;
13
13
  useGetCoinPrices: string;
14
14
  useGetCollectiblePrices: string;
15
- useGetSwapPrices: string;
16
15
  useGetSwapQuote: string;
16
+ useGetSwapRoutes: string;
17
17
  };
18
18
  export declare const time: {
19
19
  oneSecond: number;
@@ -15,8 +15,8 @@ exports.QUERY_KEYS = {
15
15
  useGetExchangeRate: 'useGetExchangeRate',
16
16
  useGetCoinPrices: 'useGetCoinPrices',
17
17
  useGetCollectiblePrices: 'useGetCollectiblePrices',
18
- useGetSwapPrices: 'useGetSwapPrices',
19
- useGetSwapQuote: 'useGetSwapQuote'
18
+ useGetSwapQuote: 'useGetSwapQuote',
19
+ useGetSwapRoutes: 'useGetSwapRoutes'
20
20
  };
21
21
  exports.time = {
22
22
  oneSecond: 1 * 1000,
@@ -1 +1 @@
1
- {"version":3,"file":"constants.js","sourceRoot":"","sources":["../../src/constants.ts"],"names":[],"mappings":";;;AAAa,QAAA,UAAU,GAAG;IACxB,wBAAwB,EAAE,0BAA0B;IACpD,0BAA0B,EAAE,4BAA4B;IACxD,0BAA0B,EAAE,4BAA4B;IACxD,6BAA6B,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;IACnB,SAAS,EAAE,EAAE,GAAG,IAAI;IACpB,OAAO,EAAE,EAAE,GAAG,EAAE,GAAG,IAAI;CACxB,CAAA;AAEY,QAAA,YAAY,GAAG,4CAA4C,CAAA;AAExE,sDAAsD;AACzC,QAAA,4BAA4B,GAAG,4CAA4C,CAAA;AAE3E,QAAA,eAAe,GAAG,4CAA4C,CAAA"}
@@ -1,4 +1,4 @@
1
- import { GetSwapQuoteV2Args } from '@0xsequence/api';
1
+ import { GetLifiSwapQuoteArgs } from '@0xsequence/api';
2
2
  import { HooksOptions } from '../../types';
3
3
  /**
4
4
  * Hook to fetch a swap quote for exchanging between two currencies.
@@ -17,12 +17,14 @@ import { HooksOptions } from '../../types';
17
17
  * Go to {@link https://docs.sequence.xyz/sdk/web/hooks/useGetSwapQuote} for more detailed documentation.
18
18
  *
19
19
  * @param getSwapQuoteArgs - Configuration object for the swap quote query:
20
- * - userAddress: The address of the user's wallet
21
- * - buyCurrencyAddress: The address of the currency to buy
22
- * - sellCurrencyAddress: The address of the currency to sell
23
- * - buyAmount: The amount of currency to buy (in base units)
24
- * - chainId: The chain ID where the swap will occur
25
- * - includeApprove: Whether to include approval data for ERC20 tokens
20
+ * - params: The parameters for the swap quote query
21
+ * - walletAddress: The address of the user's wallet
22
+ * - fromTokenAddress: The address of the currency to sell
23
+ * - toTokenAddress: The address of the currency to buy
24
+ * - fromTokenAmount?: The amount of currency to sell (optional)
25
+ * - toTokenAmount?: The amount of currency to buy (optional)
26
+ * - includeApprove: Whether to include approval data for ERC20 tokens
27
+ * - slippageBps: The slippage percentage for the swap
26
28
  *
27
29
  * @param options - Optional configuration for the hook behavior:
28
30
  * - disabled: Whether to disable the query
@@ -31,14 +33,17 @@ import { HooksOptions } from '../../types';
31
33
  *
32
34
  * @returns A React Query result object containing:
33
35
  * - data: The swap quote data including:
34
- * - currencyAddress: The address of the currency being swapped
35
- * - currencyBalance: The user's balance of the currency
36
- * - price: The price for the swap
37
- * - maxPrice: The maximum price (including slippage)
38
- * - to: The target contract address for the swap
39
- * - transactionData: The calldata for the swap transaction
40
- * - transactionValue: The value to send with the transaction (for native tokens)
41
- * - approveData: The approval transaction data (if needed)
36
+ * - quote: The swap quote data including:
37
+ * - currencyAddress: The address of the currency being swapped
38
+ * - currencyBalance: The user's balance of the currency
39
+ * - price: The price for the swap
40
+ * - maxPrice: The maximum price (including slippage)
41
+ * - to: The target contract address for the swap
42
+ * - transactionData: The calldata for the swap transaction
43
+ * - transactionValue: The value to send with the transaction (for native tokens)
44
+ * - approveData: The approval transaction data (if needed)
45
+ * - amount: The amount of currency to buy
46
+ * - amountMin: The minimum amount of currency to buy
42
47
  * - isLoading: Whether the query is in progress
43
48
  * - isError: Whether an error occurred
44
49
  * - error: Any error that occurred
@@ -52,12 +57,15 @@ import { HooksOptions } from '../../types';
52
57
  *
53
58
  * function SwapComponent() {
54
59
  * const { data: swapQuote, isLoading } = useGetSwapQuote({
55
- * userAddress: '0x123...',
56
- * buyCurrencyAddress: '0x456...',
57
- * sellCurrencyAddress: '0x789...',
58
- * buyAmount: '1000000000000000000', // 1 token in base units
59
- * chainId: 1,
60
- * includeApprove: true
60
+ * params: {
61
+ * walletAddress: '0x123...',
62
+ * fromTokenAddress: '0x456...',
63
+ * toTokenAddress: '0x789...',
64
+ * fromTokenAmount: '1000000000000000000', // 1 token in base units
65
+ * includeApprove: true,
66
+ * slippageBps: 100,
67
+ * chainId: 1
68
+ * }
61
69
  * })
62
70
  *
63
71
  * if (isLoading) return <div>Loading...</div>
@@ -74,7 +82,7 @@ import { HooksOptions } from '../../types';
74
82
  * }
75
83
  * ```
76
84
  */
77
- export declare const useGetSwapQuote: (getSwapQuoteArgs: GetSwapQuoteV2Args, options?: HooksOptions) => import("@tanstack/react-query").UseQueryResult<{
85
+ export declare const useGetSwapQuote: (getSwapQuoteArgs: GetLifiSwapQuoteArgs, options?: HooksOptions) => import("@tanstack/react-query").UseQueryResult<{
78
86
  currencyAddress: string;
79
87
  currencyBalance: string;
80
88
  price: string;
@@ -83,5 +91,7 @@ export declare const useGetSwapQuote: (getSwapQuoteArgs: GetSwapQuoteV2Args, opt
83
91
  transactionData: string;
84
92
  transactionValue: string;
85
93
  approveData: string;
94
+ amount: string;
95
+ amountMin: string;
86
96
  }, Error>;
87
97
  //# sourceMappingURL=useGetSwapQuote.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"useGetSwapQuote.d.ts","sourceRoot":"","sources":["../../../../src/hooks/Combination/useGetSwapQuote.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAA;AAIpD,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAA;AAI1C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAyEG;AACH,eAAO,MAAM,eAAe,GAAI,kBAAkB,kBAAkB,EAAE,UAAU,YAAY;;;;;;;;;SAkC3F,CAAA"}
1
+ {"version":3,"file":"useGetSwapQuote.d.ts","sourceRoot":"","sources":["../../../../src/hooks/Combination/useGetSwapQuote.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,MAAM,iBAAiB,CAAA;AAItD,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAA;AAI1C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiFG;AACH,eAAO,MAAM,eAAe,GAAI,kBAAkB,oBAAoB,EAAE,UAAU,YAAY;;;;;;;;;;;SAkC7F,CAAA"}
@@ -22,12 +22,14 @@ const useAPIClient_1 = require("../API/useAPIClient");
22
22
  * Go to {@link https://docs.sequence.xyz/sdk/web/hooks/useGetSwapQuote} for more detailed documentation.
23
23
  *
24
24
  * @param getSwapQuoteArgs - Configuration object for the swap quote query:
25
- * - userAddress: The address of the user's wallet
26
- * - buyCurrencyAddress: The address of the currency to buy
27
- * - sellCurrencyAddress: The address of the currency to sell
28
- * - buyAmount: The amount of currency to buy (in base units)
29
- * - chainId: The chain ID where the swap will occur
30
- * - includeApprove: Whether to include approval data for ERC20 tokens
25
+ * - params: The parameters for the swap quote query
26
+ * - walletAddress: The address of the user's wallet
27
+ * - fromTokenAddress: The address of the currency to sell
28
+ * - toTokenAddress: The address of the currency to buy
29
+ * - fromTokenAmount?: The amount of currency to sell (optional)
30
+ * - toTokenAmount?: The amount of currency to buy (optional)
31
+ * - includeApprove: Whether to include approval data for ERC20 tokens
32
+ * - slippageBps: The slippage percentage for the swap
31
33
  *
32
34
  * @param options - Optional configuration for the hook behavior:
33
35
  * - disabled: Whether to disable the query
@@ -36,14 +38,17 @@ const useAPIClient_1 = require("../API/useAPIClient");
36
38
  *
37
39
  * @returns A React Query result object containing:
38
40
  * - data: The swap quote data including:
39
- * - currencyAddress: The address of the currency being swapped
40
- * - currencyBalance: The user's balance of the currency
41
- * - price: The price for the swap
42
- * - maxPrice: The maximum price (including slippage)
43
- * - to: The target contract address for the swap
44
- * - transactionData: The calldata for the swap transaction
45
- * - transactionValue: The value to send with the transaction (for native tokens)
46
- * - approveData: The approval transaction data (if needed)
41
+ * - quote: The swap quote data including:
42
+ * - currencyAddress: The address of the currency being swapped
43
+ * - currencyBalance: The user's balance of the currency
44
+ * - price: The price for the swap
45
+ * - maxPrice: The maximum price (including slippage)
46
+ * - to: The target contract address for the swap
47
+ * - transactionData: The calldata for the swap transaction
48
+ * - transactionValue: The value to send with the transaction (for native tokens)
49
+ * - approveData: The approval transaction data (if needed)
50
+ * - amount: The amount of currency to buy
51
+ * - amountMin: The minimum amount of currency to buy
47
52
  * - isLoading: Whether the query is in progress
48
53
  * - isError: Whether an error occurred
49
54
  * - error: Any error that occurred
@@ -57,12 +62,15 @@ const useAPIClient_1 = require("../API/useAPIClient");
57
62
  *
58
63
  * function SwapComponent() {
59
64
  * const { data: swapQuote, isLoading } = useGetSwapQuote({
60
- * userAddress: '0x123...',
61
- * buyCurrencyAddress: '0x456...',
62
- * sellCurrencyAddress: '0x789...',
63
- * buyAmount: '1000000000000000000', // 1 token in base units
64
- * chainId: 1,
65
- * includeApprove: true
65
+ * params: {
66
+ * walletAddress: '0x123...',
67
+ * fromTokenAddress: '0x456...',
68
+ * toTokenAddress: '0x789...',
69
+ * fromTokenAmount: '1000000000000000000', // 1 token in base units
70
+ * includeApprove: true,
71
+ * slippageBps: 100,
72
+ * chainId: 1
73
+ * }
66
74
  * })
67
75
  *
68
76
  * if (isLoading) return <div>Loading...</div>
@@ -84,31 +92,31 @@ const useGetSwapQuote = (getSwapQuoteArgs, options) => {
84
92
  return (0, react_query_1.useQuery)({
85
93
  queryKey: [constants_1.QUERY_KEYS.useGetSwapQuote, getSwapQuoteArgs, options],
86
94
  queryFn: async () => {
87
- const res = await apiClient.getSwapQuoteV2({
88
- ...getSwapQuoteArgs,
89
- buyCurrencyAddress: (0, helpers_1.compareAddress)(getSwapQuoteArgs.buyCurrencyAddress, constants_1.ZERO_ADDRESS)
90
- ? constants_1.ZERO_ADDRESS
91
- : getSwapQuoteArgs.buyCurrencyAddress,
92
- sellCurrencyAddress: (0, helpers_1.compareAddress)(getSwapQuoteArgs.sellCurrencyAddress, constants_1.ZERO_ADDRESS)
93
- ? constants_1.ZERO_ADDRESS
94
- : getSwapQuoteArgs.sellCurrencyAddress
95
+ const res = await apiClient.getLifiSwapQuote({
96
+ params: {
97
+ ...getSwapQuoteArgs.params,
98
+ toTokenAddress: (0, helpers_1.compareAddress)(getSwapQuoteArgs.params.toTokenAddress, constants_1.ZERO_ADDRESS)
99
+ ? constants_1.ZERO_ADDRESS
100
+ : getSwapQuoteArgs.params.toTokenAddress,
101
+ fromTokenAddress: (0, helpers_1.compareAddress)(getSwapQuoteArgs.params.fromTokenAddress, constants_1.ZERO_ADDRESS)
102
+ ? constants_1.ZERO_ADDRESS
103
+ : getSwapQuoteArgs.params.fromTokenAddress
104
+ }
95
105
  });
96
106
  return {
97
- ...res.swapQuote,
98
- currencyAddress: (0, helpers_1.compareAddress)(res.swapQuote.currencyAddress, constants_1.ZERO_ADDRESS)
99
- ? constants_1.ZERO_ADDRESS
100
- : res.swapQuote.currencyAddress
107
+ ...res.quote,
108
+ currencyAddress: (0, helpers_1.compareAddress)(res.quote.currencyAddress, constants_1.ZERO_ADDRESS) ? constants_1.ZERO_ADDRESS : res.quote.currencyAddress
101
109
  };
102
110
  },
103
111
  retry: options?.retry ?? true,
104
112
  staleTime: constants_1.time.oneMinute * 1,
105
113
  enabled: !options?.disabled &&
106
- !!getSwapQuoteArgs.userAddress &&
107
- !!getSwapQuoteArgs.buyCurrencyAddress &&
108
- !!getSwapQuoteArgs.sellCurrencyAddress &&
109
- getSwapQuoteArgs.buyAmount !== '0' &&
110
- !!getSwapQuoteArgs.chainId &&
111
- !!getSwapQuoteArgs.includeApprove
114
+ !!getSwapQuoteArgs.params.walletAddress &&
115
+ !!getSwapQuoteArgs.params.fromTokenAddress &&
116
+ !!getSwapQuoteArgs.params.toTokenAddress &&
117
+ getSwapQuoteArgs.params.fromTokenAmount !== '0' &&
118
+ !!getSwapQuoteArgs.params.chainId &&
119
+ !!getSwapQuoteArgs.params.includeApprove
112
120
  });
113
121
  };
114
122
  exports.useGetSwapQuote = useGetSwapQuote;
@@ -1 +1 @@
1
- {"version":3,"file":"useGetSwapQuote.js","sourceRoot":"","sources":["../../../../src/hooks/Combination/useGetSwapQuote.ts"],"names":[],"mappings":";;;AACA,uDAAgD;AAEhD,+CAAgE;AAEhE,iDAAoD;AACpD,sDAAkD;AAElD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAyEG;AACI,MAAM,eAAe,GAAG,CAAC,gBAAoC,EAAE,OAAsB,EAAE,EAAE;IAC9F,MAAM,SAAS,GAAG,IAAA,2BAAY,GAAE,CAAA;IAEhC,OAAO,IAAA,sBAAQ,EAAC;QACd,QAAQ,EAAE,CAAC,s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AAS,GAAG,CAAC;QAC7B,OAAO,EACL,CAAC,OAAO,EAAE,QAAQ;YAClB,CAAC,CAAC,gBAAgB,CAAC,MAAM,CAAC,aAAa;YACvC,CAAC,CAAC,gBAAgB,CAAC,MAAM,CAAC,gBAAgB;YAC1C,CAAC,CAAC,gBAAgB,CAAC,MAAM,CAAC,cAAc;YACxC,gBAAgB,CAAC,MAAM,CAAC,eAAe,KAAK,GAAG;YAC/C,CAAC,CAAC,gBAAgB,CAAC,MAAM,CAAC,OAAO;YACjC,CAAC,CAAC,gBAAgB,CAAC,MAAM,CAAC,cAAc;KAC3C,CAAC,CAAA;AACJ,CAAC,CAAA;AAlCY,QAAA,eAAe,mBAkC3B"}
@@ -0,0 +1,61 @@
1
+ import { type LifiSwapRoute } from '@0xsequence/api';
2
+ import { HooksOptions } from '../../types';
3
+ /**
4
+ * Arguments for the useGetSwapRoutes hook
5
+ *
6
+ * @property walletAddress - The address of the user's wallet
7
+ * @property toTokenAddress - The address of the currency to buy
8
+ * @property chainId - The chain ID where the swap will occur
9
+ * @property toTokenAmount - The amount of the currency to buy
10
+ */
11
+ export interface UseGetSwapRoutesArgs {
12
+ walletAddress: string;
13
+ toTokenAddress: string;
14
+ chainId: number;
15
+ toTokenAmount: string;
16
+ }
17
+ /**
18
+ * Hook to fetch available swap routes for a given token.
19
+ *
20
+ * This hook uses React Query to fetch and cache swap routes from the Sequence API.
21
+ * Stale time is set to one hour by default
22
+ *
23
+ * @see {@link https://docs.sequence.xyz/sdk/web/hooks/useGetSwapRoutes} for more detailed documentation.
24
+ *
25
+ * @param args - Arguments for fetching swap routes:
26
+ * - walletAddress: The address of the user's wallet
27
+ * - toTokenAddress: The address of the token to buy
28
+ * - chainId: The chain ID where the swap will occur
29
+ * - toTokenAmount: The amount of the token to buy
30
+ *
31
+ * @param options - Optional configuration options:
32
+ * - retry: Whether to retry failed requests (defaults to true)
33
+ * - disabled: Whether to disable the query
34
+ *
35
+ * @returns React Query result object containing:
36
+ * - data: Array of available swap routes when available
37
+ * - isLoading: Whether the initial request is in progress
38
+ * - error: Any error that occurred
39
+ * - isError: Whether an error occurred
40
+ * - isSuccess: Whether the request was successful
41
+ *
42
+ * @example
43
+ * ```tsx
44
+ * const { data: routes, isLoading, error } = useGetSwapRoutes({
45
+ * walletAddress: '0x123...',
46
+ * toTokenAddress: '0x456...',
47
+ * chainId: 1,
48
+ * toTokenAmount: '1000000000000000000' // 1 ETH in wei
49
+ * })
50
+ *
51
+ * if (isLoading) {
52
+ * return <div>Loading swap routes...</div>
53
+ * }
54
+ *
55
+ * if (routes?.length) {
56
+ * console.log('Best route:', routes[0])
57
+ * }
58
+ * ```
59
+ */
60
+ export declare const useGetSwapRoutes: (args: UseGetSwapRoutesArgs, options?: HooksOptions) => import("@tanstack/react-query").UseQueryResult<LifiSwapRoute[], Error>;
61
+ //# sourceMappingURL=useGetSwapRoutes.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useGetSwapRoutes.d.ts","sourceRoot":"","sources":["../../../../src/hooks/Combination/useGetSwapRoutes.ts"],"names":[],"mappings":"AAAA,OAAO,EAAyB,KAAK,aAAa,EAAqB,MAAM,iBAAiB,CAAA;AAI9F,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAA;AAG1C;;;;;;;GAOG;AACH,MAAM,WAAW,oBAAoB;IACnC,aAAa,EAAE,MAAM,CAAA;IACrB,cAAc,EAAE,MAAM,CAAA;IACtB,OAAO,EAAE,MAAM,CAAA;IACf,aAAa,EAAE,MAAM,CAAA;CACtB;AAwBD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA0CG;AACH,eAAO,MAAM,gBAAgB,GAAI,MAAM,oBAAoB,EAAE,UAAU,YAAY,2EAclF,CAAA"}
@@ -0,0 +1,79 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.useGetSwapRoutes = void 0;
4
+ const react_query_1 = require("@tanstack/react-query");
5
+ const constants_1 = require("../../constants");
6
+ const useAPIClient_1 = require("../API/useAPIClient");
7
+ const getSwapRoutes = async (apiClient, args) => {
8
+ if (!args.chainId || !args.toTokenAddress) {
9
+ return [];
10
+ }
11
+ const res = await apiClient.getLifiSwapRoutes({
12
+ chainId: args.chainId,
13
+ walletAddress: args.walletAddress,
14
+ toTokenAddress: args.toTokenAddress,
15
+ toTokenAmount: args.toTokenAmount
16
+ });
17
+ if (res.routes.length === 0) {
18
+ return [];
19
+ }
20
+ return res.routes;
21
+ };
22
+ /**
23
+ * Hook to fetch available swap routes for a given token.
24
+ *
25
+ * This hook uses React Query to fetch and cache swap routes from the Sequence API.
26
+ * Stale time is set to one hour by default
27
+ *
28
+ * @see {@link https://docs.sequence.xyz/sdk/web/hooks/useGetSwapRoutes} for more detailed documentation.
29
+ *
30
+ * @param args - Arguments for fetching swap routes:
31
+ * - walletAddress: The address of the user's wallet
32
+ * - toTokenAddress: The address of the token to buy
33
+ * - chainId: The chain ID where the swap will occur
34
+ * - toTokenAmount: The amount of the token to buy
35
+ *
36
+ * @param options - Optional configuration options:
37
+ * - retry: Whether to retry failed requests (defaults to true)
38
+ * - disabled: Whether to disable the query
39
+ *
40
+ * @returns React Query result object containing:
41
+ * - data: Array of available swap routes when available
42
+ * - isLoading: Whether the initial request is in progress
43
+ * - error: Any error that occurred
44
+ * - isError: Whether an error occurred
45
+ * - isSuccess: Whether the request was successful
46
+ *
47
+ * @example
48
+ * ```tsx
49
+ * const { data: routes, isLoading, error } = useGetSwapRoutes({
50
+ * walletAddress: '0x123...',
51
+ * toTokenAddress: '0x456...',
52
+ * chainId: 1,
53
+ * toTokenAmount: '1000000000000000000' // 1 ETH in wei
54
+ * })
55
+ *
56
+ * if (isLoading) {
57
+ * return <div>Loading swap routes...</div>
58
+ * }
59
+ *
60
+ * if (routes?.length) {
61
+ * console.log('Best route:', routes[0])
62
+ * }
63
+ * ```
64
+ */
65
+ const useGetSwapRoutes = (args, options) => {
66
+ const apiClient = (0, useAPIClient_1.useAPIClient)();
67
+ const enabled = !!args.chainId && !!args.toTokenAddress && !options?.disabled;
68
+ return (0, react_query_1.useQuery)({
69
+ queryKey: [constants_1.QUERY_KEYS.useGetSwapRoutes, args, options],
70
+ queryFn: () => getSwapRoutes(apiClient, args),
71
+ retry: options?.retry ?? true,
72
+ // We must keep a long staletime to avoid the list of quotes being refreshed while the user is doing the transactions
73
+ // Instead, we will invalidate the query manually
74
+ staleTime: constants_1.time.oneHour,
75
+ enabled
76
+ });
77
+ };
78
+ exports.useGetSwapRoutes = useGetSwapRoutes;
79
+ //# sourceMappingURL=useGetSwapRoutes.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useGetSwapRoutes.js","sourceRoot":"","sources":["../../../../src/hooks/Combination/useGetSwapRoutes.ts"],"names":[],"mappings":";;;AACA,uDAAgD;AAEhD,+CAAkD;AAElD,sDAAkD;AAiBlD,MAAM,aAAa,GAAG,KAAK,EACzB,SAA4B,EAC5B,IAAuD,EAC7B,EAAE;IAC5B,IAAI,CAAC,IAAI,CAAC,OAAO,IAAI,CAAC,IAAI,CAAC,cAAc,EAAE,CAAC;QAC1C,OAAO,EAAE,CAAA;IACX,CAAC;IAED,MAAM,GAAG,GAAG,MAAM,SAAS,CAAC,iBAAiB,CAAC;QAC5C,OAAO,EAAE,IAAI,CAAC,OAAO;QACrB,aAAa,EAAE,IAAI,CAAC,aAAa;QACjC,cAAc,EAAE,IAAI,CAAC,cAAc;QACnC,aAAa,EAAE,IAAI,CAAC,aAAa;KAClC,CAAC,CAAA;IAEF,IAAI,GAAG,CAAC,MAAM,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QAC5B,OAAO,EAAE,CAAA;IACX,CAAC;IAED,OAAO,GAAG,CAAC,MAAM,CAAA;AACnB,CAAC,CAAA;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA0CG;AACI,MAAM,gBAAgB,GAAG,CAAC,IAA0B,EAAE,OAAsB,EAAE,EAAE;IACrF,MAAM,SAAS,GAAG,IAAA,2BAAY,GAAE,CAAA;IAEhC,MAAM,OAAO,GAAG,CAAC,CAAC,IAAI,CAAC,OAAO,IAAI,CAAC,CAAC,IAAI,CAAC,cAAc,IAAI,CAAC,OAAO,EAAE,QAAQ,CAAA;IAE7E,OAAO,IAAA,sBAAQ,EAAC;QACd,QAAQ,EAAE,CAAC,sBAAU,CAAC,gBAAgB,EAAE,IAAI,EAAE,OAAO,CAAC;QACtD,OAAO,EAAE,GAAG,EAAE,CAAC,aAAa,CAAC,SAAS,EAAE,IAAI,CAAC;QAC7C,KAAK,EAAE,OAAO,EAAE,KAAK,IAAI,IAAI;QAC7B,qHAAqH;QACrH,iDAAiD;QACjD,SAAS,EAAE,gBAAI,CAAC,OAAO;QACvB,OAAO;KACR,CAAC,CAAA;AACJ,CAAC,CAAA;AAdY,QAAA,gBAAgB,oBAc5B"}
@@ -18,7 +18,7 @@ export { useMetadataClient } from './hooks/Metadata/useMetadataClient';
18
18
  export { useGetContractInfo } from './hooks/Metadata/useGetContractInfo';
19
19
  export { useGetMultipleContractsInfo } from './hooks/Metadata/useGetMultipleContractsInfo';
20
20
  export { useGetTokenMetadata } from './hooks/Metadata/useGetTokenMetadata';
21
- export { useGetSwapPrices, type SwapPricesWithCurrencyInfo, type UseGetSwapPricesArgs } from './hooks/Combination/useGetSwapPrices';
22
21
  export { useGetSwapQuote } from './hooks/Combination/useGetSwapQuote';
22
+ export { useGetSwapRoutes } from './hooks/Combination/useGetSwapRoutes';
23
23
  export { useClearCachedBalances } from './hooks/useClearCachedBalances';
24
24
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAA;AAGxC,OAAO,EACL,oBAAoB,EACpB,qBAAqB,EACrB,KAAK,mBAAmB,EACxB,KAAK,gBAAgB,EACtB,MAAM,0BAA0B,CA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1E,OAAO,EAAE,eAAe,EAAE,MAAM,qCAAqC,CAAA;AACrE,OAAO,EAAE,gBAAgB,EAAE,MAAM,sCAAsC,CAAA;AAGvE,OAAO,EAAE,sBAAsB,EAAE,MAAM,gCAAgC,CAAA"}
package/dist/cjs/index.js CHANGED
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.useClearCachedBalances = exports.useGetSwapQuote = exports.useGetSwapPrices = exports.useGetTokenMetadata = exports.useGetMultipleContractsInfo = exports.useGetContractInfo = exports.useMetadataClient = exports.useGetTokenBalancesSummary = exports.useGetTokenBalancesDetails = exports.useGetTokenBalancesByContract = exports.useGetSingleTokenBalance = exports.useGetNativeTokenBalance = exports.useIndexerGatewayClient = exports.useGetTransactionHistorySummary = exports.useGetTransactionHistory = exports.useIndexerClients = exports.useIndexerClient = exports.useGetExchangeRate = exports.useGetCollectiblePrices = exports.useGetCoinPrices = exports.useAPIClient = exports.useConfig = exports.SequenceHooksProvider = exports.SequenceHooksContext = exports.QUERY_KEYS = void 0;
3
+ exports.useClearCachedBalances = exports.useGetSwapRoutes = exports.useGetSwapQuote = exports.useGetTokenMetadata = exports.useGetMultipleContractsInfo = exports.useGetContractInfo = exports.useMetadataClient = exports.useGetTokenBalancesSummary = exports.useGetTokenBalancesDetails = exports.useGetTokenBalancesByContract = exports.useGetSingleTokenBalance = exports.useGetNativeTokenBalance = exports.useIndexerGatewayClient = exports.useGetTransactionHistorySummary = exports.useGetTransactionHistory = exports.useIndexerClients = exports.useIndexerClient = exports.useGetExchangeRate = exports.useGetCollectiblePrices = exports.useGetCoinPrices = exports.useAPIClient = exports.useConfig = exports.SequenceHooksProvider = exports.SequenceHooksContext = exports.QUERY_KEYS = void 0;
4
4
  // Constants
5
5
  var constants_1 = require("./constants");
6
6
  Object.defineProperty(exports, "QUERY_KEYS", { enumerable: true, get: function () { return constants_1.QUERY_KEYS; } });
@@ -49,11 +49,10 @@ var useGetMultipleContractsInfo_1 = require("./hooks/Metadata/useGetMultipleCont
49
49
  Object.defineProperty(exports, "useGetMultipleContractsInfo", { enumerable: true, get: function () { return useGetMultipleContractsInfo_1.useGetMultipleContractsInfo; } });
50
50
  var useGetTokenMetadata_1 = require("./hooks/Metadata/useGetTokenMetadata");
51
51
  Object.defineProperty(exports, "useGetTokenMetadata", { enumerable: true, get: function () { return useGetTokenMetadata_1.useGetTokenMetadata; } });
52
- // Combination
53
- var useGetSwapPrices_1 = require("./hooks/Combination/useGetSwapPrices");
54
- Object.defineProperty(exports, "useGetSwapPrices", { enumerable: true, get: function () { return useGetSwapPrices_1.useGetSwapPrices; } });
55
52
  var useGetSwapQuote_1 = require("./hooks/Combination/useGetSwapQuote");
56
53
  Object.defineProperty(exports, "useGetSwapQuote", { enumerable: true, get: function () { return useGetSwapQuote_1.useGetSwapQuote; } });
54
+ var useGetSwapRoutes_1 = require("./hooks/Combination/useGetSwapRoutes");
55
+ Object.defineProperty(exports, "useGetSwapRoutes", { enumerable: true, get: function () { return useGetSwapRoutes_1.useGetSwapRoutes; } });
57
56
  // Etc
58
57
  var useClearCachedBalances_1 = require("./hooks/useClearCachedBalances");
59
58
  Object.defineProperty(exports, "useClearCachedBalances", { enumerable: true, get: function () { return useClearCachedBalances_1.useClearCachedBalances; } });
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;AAAA,YAAY;AACZ,yCAAwC;AAA/B,uGAAA,UAAU,OAAA;AAEnB,WAAW;AACX,0DAKiC;AAJ/B,qHAAA,oBAAoB,OAAA;AACpB,sHAAA,qBAAqB,OAAA;AAIvB,+CAA6C;AAApC,sGAAA,SAAS,OAAA;AAElB,MAAM;AACN,yDAAuD;AAA9C,4GAAA,YAAY,OAAA;AACrB,iEAA+D;AAAtD,oHAAA,gBAAgB,OAAA;AACzB,+EAA6E;AAApE,kIAAA,uBAAuB,OAAA;AAChC,qEAAmE;AAA1D,wHAAA,kBAAk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ACV,qEAAsF;AAA7E,oHAAA,gBAAgB,OAAA;AAAE,qHAAA,iBAAiB,OAAA;AAC5C,qFAAmF;AAA1E,oIAAA,wBAAwB,OAAA;AACjC,mGAGwD;AAFtD,kJAAA,+BAA+B,OAAA;AAIjC,iBAAiB;AACjB,0FAAwF;AAA/E,kIAAA,uBAAuB,OAAA;AAChC,4FAA0F;AAAjF,oIAAA,wBAAwB,OAAA;AACjC,4FAA0H;AAAjH,oIAAA,wBAAwB,OAAA;AACjC,sGAAoG;AAA3F,8IAAA,6BAA6B,OAAA;AACtC,gGAA8F;AAArF,wIAAA,0BAA0B,OAAA;AACnC,gGAA8F;AAArF,wIAAA,0BAA0B,OAAA;AAEnC,WAAW;AACX,wEAAsE;AAA7D,sHAAA,iBAAiB,OAAA;AAC1B,0EAAwE;AAA/D,wHAAA,kBAAkB,OAAA;AAC3B,4FAA0F;AAAjF,0IAAA,2BAA2B,OAAA;AACpC,4EAA0E;AAAjE,0HAAA,mBAAmB,OAAA;AAE5B,uEAAqE;AAA5D,kHAAA,eAAe,OAAA;AACxB,yEAAuE;AAA9D,oHAAA,gBAAgB,OAAA;AAEzB,MAAM;AACN,yEAAuE;AAA9D,gIAAA,sBAAsB,OAAA"}
@@ -7,32 +7,51 @@ const constants_1 = require("../../constants");
7
7
  const useGetSwapQuote_1 = require("../../hooks/Combination/useGetSwapQuote");
8
8
  const createWrapper_1 = require("../createWrapper");
9
9
  const setup_1 = require("../setup");
10
- const getSwapQuoteArgs = {
11
- userAddress: constants_1.ACCOUNT_ADDRESS,
12
- buyCurrencyAddress: constants_1.ZERO_ADDRESS,
13
- sellCurrencyAddress: constants_1.ZERO_ADDRESS,
14
- buyAmount: '20000',
15
- chainId: 1,
16
- includeApprove: true
10
+ const swapQuoteArgs = {
11
+ params: {
12
+ walletAddress: constants_1.ACCOUNT_ADDRESS,
13
+ toTokenAddress: '0x7ceb23fd6bc0add59e62ac25578270cff1b9f619',
14
+ fromTokenAddress: constants_1.ZERO_ADDRESS,
15
+ toTokenAmount: '10000',
16
+ chainId: 137,
17
+ includeApprove: true,
18
+ slippageBps: 100
19
+ }
17
20
  };
18
- (0, vitest_1.describe)('useGetSwapQuoteV2', () => {
21
+ (0, vitest_1.describe)('useGetSwapQuote', () => {
19
22
  (0, vitest_1.it)('should return data with a balance', async () => {
20
- const { result } = (0, react_1.renderHook)(() => (0, useGetSwapQuote_1.useGetSwapQuote)(getSwapQuoteArgs), {
23
+ setup_1.server.use(msw_1.http.post('*/getLifiSwapQuote', async () => {
24
+ return msw_1.HttpResponse.json({
25
+ quote: {
26
+ currencyAddress: constants_1.ZERO_ADDRESS,
27
+ currencyBalance: '180000000000000',
28
+ price: '7351402238115',
29
+ maxPrice: '7718972350021',
30
+ to: '0x0000000000000000000000000000000000000000',
31
+ transactionData: '0x0000000000000000000000000000000000000000000000000000000000000000',
32
+ transactionValue: '0',
33
+ approveData: '0x0000000000000000000000000000000000000000000000000000000000000000',
34
+ amount: '10000000000000000',
35
+ amountMin: '9500000000000000'
36
+ }
37
+ }, { status: 200 });
38
+ }));
39
+ const { result } = (0, react_1.renderHook)(() => (0, useGetSwapQuote_1.useGetSwapQuote)({ params: swapQuoteArgs.params }), {
21
40
  wrapper: (0, createWrapper_1.createWrapper)()
22
41
  });
23
- await (0, react_1.waitFor)(() => (0, vitest_1.expect)(result.current.isSuccess).toBe(true));
42
+ await (0, react_1.waitFor)(() => (0, vitest_1.expect)(result.current.isSuccess).toBe(true), { timeout: 3000 });
24
43
  (0, vitest_1.expect)(result.current.data).toBeDefined();
25
44
  const value = BigInt(result.current.data.currencyBalance || 0);
26
45
  (0, vitest_1.expect)(value).toBeGreaterThan(0);
27
46
  });
28
47
  (0, vitest_1.it)('should return error when fetching data fails', async () => {
29
- setup_1.server.use(msw_1.http.post('*', () => {
48
+ setup_1.server.use(msw_1.http.post('*/getLifiSwapQuote', () => {
30
49
  return msw_1.HttpResponse.error();
31
50
  }));
32
- const { result } = (0, react_1.renderHook)(() => (0, useGetSwapQuote_1.useGetSwapQuote)(getSwapQuoteArgs, { retry: false }), {
51
+ const { result } = (0, react_1.renderHook)(() => (0, useGetSwapQuote_1.useGetSwapQuote)({ params: swapQuoteArgs.params }, { retry: false }), {
33
52
  wrapper: (0, createWrapper_1.createWrapper)()
34
53
  });
35
- await (0, react_1.waitFor)(() => (0, vitest_1.expect)(result.current.isError).toBe(true));
54
+ await (0, react_1.waitFor)(() => (0, vitest_1.expect)(result.current.isError).toBe(true), { timeout: 3000 });
36
55
  });
37
56
  });
38
57
  //# sourceMappingURL=useGetSwapQuote.test.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"useGetSwapQuote.test.js","sourceRoot":"","sources":["../../../../src/tests/Combination/useGetSwapQuote.test.ts"],"names":[],"mappings":";;AAAA,kDAA4D;AAC5D,6BAAwC;AACxC,mCAA6C;AAE7C,+CAA+D;AAC/D,6EAAyE;AACzE,oDAAgD;AAChD,oCAAiC;AAEjC,MAAM,gBAAgB,GAAG;IACvB,WAAW,EAAE,2BAAe;IAC5B,kBAAkB,EAAE,wBAAY;IAChC,mBAAmB,EAAE,wBAAY;IACjC,SAAS,EAAE,OAAO;IAClB,OAAO,EAAE,CAAC;IACV,cAAc,EAAE,IAAI;CACrB,CAAA;AAED,IAAA,iBAAQ,EAAC,mBAAmB,EAAE,GAAG,EAAE;IACjC,IAAA,WAAE,EAAC,mCAAmC,EAAE,KAAK,IAAI,EAAE;QACjD,MAAM,EAAE,MAAM,EAAE,GAAG,IAAA,kBAAU,EAAC,GAAG,EAAE,CAAC,IAAA,iCAAe,EAAC,gBAAgB,CAAC,EAAE;YACrE,OAAO,EAAE,IAAA,6BAAa,GAAE;SACzB,CAAC,CAAA;QAEF,MAAM,IAAA,eAAO,EAAC,GAAG,EAAE,CAAC,IAAA,eAAM,EAAC,MAAM,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAA;QAEhE,IAAA,eAAM,EAAC,MAAM,CAAC,OAAO,C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CAAA;QAC/D,IAAA,eAAM,EAAC,KAAK,CAAC,CAAC,eAAe,CAAC,CAAC,CAAC,CAAA;IAClC,CAAC,CAAC,CAAA;IAEF,IAAA,WAAE,EAAC,8CAA8C,EAAE,KAAK,IAAI,EAAE;QAC5D,cAAM,CAAC,GAAG,CACR,UAAI,CAAC,IAAI,CAAC,oBAAoB,EAAE,GAAG,EAAE;YACnC,OAAO,kBAAY,CAAC,KAAK,EAAE,CAAA;QAC7B,CAAC,CAAC,CACH,CAAA;QAED,MAAM,EAAE,MAAM,EAAE,GAAG,IAAA,kBAAU,EAAC,GAAG,EAAE,CAAC,IAAA,iCAAe,EAAC,EAAE,MAAM,EAAE,aAAa,CAAC,MAAM,EAAE,EAAE,EAAE,KAAK,EAAE,KAAK,EAAE,CAAC,EAAE;YACvG,OAAO,EAAE,IAAA,6BAAa,GAAE;SACzB,CAAC,CAAA;QAEF,MAAM,IAAA,eAAO,EAAC,GAAG,EAAE,CAAC,IAAA,eAAM,EAAC,MAAM,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC,CAAA;IACnF,CAAC,CAAC,CAAA;AACJ,CAAC,CAAC,CAAA"}
@@ -1 +1 @@
1
- {"version":3,"file":"handlers.d.ts","sourceRoot":"","sources":["../../../src/tests/handlers.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,QAAQ,6BAuWpB,CAAA"}
1
+ {"version":3,"file":"handlers.d.ts","sourceRoot":"","sources":["../../../src/tests/handlers.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,QAAQ,6BA2TpB,CAAA"}