@lifi/sdk 2.2.3 → 3.0.0-alpha.2

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 (183) hide show
  1. package/dist/LiFi.d.ts +69 -62
  2. package/dist/LiFi.js +71 -60
  3. package/dist/allowance/getAllowance.d.ts +6 -0
  4. package/dist/allowance/getAllowance.js +78 -0
  5. package/dist/allowance/index.d.ts +3 -2
  6. package/dist/allowance/index.js +3 -2
  7. package/dist/allowance/setAllowance.d.ts +5 -0
  8. package/dist/allowance/setAllowance.js +50 -0
  9. package/dist/allowance/types.d.ts +27 -0
  10. package/dist/allowance/types.js +1 -0
  11. package/dist/balance/getBalance.d.ts +2 -0
  12. package/dist/balance/getBalance.js +93 -0
  13. package/dist/balance/getTokenBalance.d.ts +2 -2
  14. package/dist/balance/getTokenBalance.js +4 -4
  15. package/dist/balance/index.d.ts +1 -12
  16. package/dist/balance/index.js +1 -9
  17. package/dist/cjs/LiFi.d.ts +69 -62
  18. package/dist/cjs/LiFi.js +69 -58
  19. package/dist/cjs/allowance/getAllowance.d.ts +6 -0
  20. package/dist/cjs/allowance/getAllowance.js +85 -0
  21. package/dist/cjs/allowance/index.d.ts +3 -2
  22. package/dist/cjs/allowance/index.js +3 -2
  23. package/dist/cjs/allowance/setAllowance.d.ts +5 -0
  24. package/dist/cjs/allowance/setAllowance.js +56 -0
  25. package/dist/cjs/allowance/types.d.ts +27 -0
  26. package/dist/cjs/allowance/types.js +2 -0
  27. package/dist/cjs/balance/getBalance.d.ts +2 -0
  28. package/dist/cjs/balance/getBalance.js +97 -0
  29. package/dist/cjs/balance/getTokenBalance.d.ts +2 -2
  30. package/dist/cjs/balance/getTokenBalance.js +6 -9
  31. package/dist/cjs/balance/index.d.ts +1 -12
  32. package/dist/cjs/balance/index.js +1 -9
  33. package/dist/cjs/connectors.d.ts +7 -5
  34. package/dist/cjs/connectors.js +45 -37
  35. package/dist/cjs/constants.d.ts +6 -0
  36. package/dist/cjs/constants.js +9 -0
  37. package/dist/cjs/execution/RouteExecutionManager.d.ts +24 -30
  38. package/dist/cjs/execution/RouteExecutionManager.js +27 -45
  39. package/dist/cjs/execution/StatusManager.d.ts +22 -23
  40. package/dist/cjs/execution/StatusManager.js +21 -22
  41. package/dist/cjs/execution/StepExecutionManager.d.ts +3 -3
  42. package/dist/cjs/execution/StepExecutionManager.js +118 -125
  43. package/dist/cjs/execution/StepExecutor.d.ts +4 -4
  44. package/dist/cjs/execution/StepExecutor.js +6 -6
  45. package/dist/cjs/execution/checkAllowance.d.ts +4 -0
  46. package/dist/cjs/execution/checkAllowance.js +77 -0
  47. package/dist/cjs/execution/checkBalance.d.ts +2 -0
  48. package/dist/cjs/execution/checkBalance.js +42 -0
  49. package/dist/cjs/execution/multisig.d.ts +4 -3
  50. package/dist/cjs/execution/multisig.js +9 -11
  51. package/dist/cjs/execution/prepareRestart.d.ts +3 -0
  52. package/dist/cjs/execution/prepareRestart.js +65 -0
  53. package/dist/cjs/execution/stepComparison.d.ts +3 -3
  54. package/dist/cjs/execution/stepComparison.js +2 -2
  55. package/dist/cjs/execution/switchChain.d.ts +13 -8
  56. package/dist/cjs/execution/switchChain.js +16 -11
  57. package/dist/cjs/execution/utils.d.ts +9 -3
  58. package/dist/cjs/execution/utils.js +19 -66
  59. package/dist/cjs/execution/waitForReceivingTransaction.d.ts +3 -0
  60. package/dist/cjs/execution/waitForReceivingTransaction.js +58 -0
  61. package/dist/cjs/helpers.d.ts +7 -17
  62. package/dist/cjs/helpers.js +6 -38
  63. package/dist/cjs/request.js +1 -1
  64. package/dist/cjs/services/ApiService.d.ts +2 -2
  65. package/dist/cjs/services/ApiService.js +4 -2
  66. package/dist/cjs/services/ChainsService.d.ts +1 -1
  67. package/dist/cjs/services/ConfigService.d.ts +1 -1
  68. package/dist/cjs/services/ConfigService.js +1 -2
  69. package/dist/cjs/typeguards.d.ts +1 -1
  70. package/dist/cjs/types/abi.d.ts +5 -0
  71. package/dist/cjs/types/abi.js +45 -0
  72. package/dist/cjs/types/index.d.ts +2 -2
  73. package/dist/cjs/types/index.js +3 -3
  74. package/dist/cjs/types/internal.types.d.ts +24 -31
  75. package/dist/cjs/utils/errors.d.ts +15 -14
  76. package/dist/cjs/utils/errors.js +38 -37
  77. package/dist/cjs/utils/getMaxPriorityFeePerGas.d.ts +2 -0
  78. package/dist/cjs/utils/getMaxPriorityFeePerGas.js +22 -0
  79. package/dist/cjs/utils/index.d.ts +5 -0
  80. package/dist/cjs/utils/index.js +21 -0
  81. package/dist/cjs/utils/median.d.ts +1 -0
  82. package/dist/cjs/utils/median.js +15 -0
  83. package/dist/cjs/utils/parseError.d.ts +4 -4
  84. package/dist/cjs/utils/parseError.js +41 -38
  85. package/dist/cjs/utils/utils.d.ts +1 -16
  86. package/dist/cjs/utils/utils.js +9 -78
  87. package/dist/cjs/version.d.ts +1 -1
  88. package/dist/cjs/version.js +1 -1
  89. package/dist/connectors.d.ts +7 -5
  90. package/dist/connectors.js +19 -35
  91. package/dist/constants.d.ts +6 -0
  92. package/dist/constants.js +6 -0
  93. package/dist/execution/RouteExecutionManager.d.ts +24 -30
  94. package/dist/execution/RouteExecutionManager.js +27 -45
  95. package/dist/execution/StatusManager.d.ts +22 -23
  96. package/dist/execution/StatusManager.js +22 -23
  97. package/dist/execution/StepExecutionManager.d.ts +3 -3
  98. package/dist/execution/StepExecutionManager.js +116 -123
  99. package/dist/execution/StepExecutor.d.ts +4 -4
  100. package/dist/execution/StepExecutor.js +6 -6
  101. package/dist/execution/checkAllowance.d.ts +4 -0
  102. package/dist/execution/checkAllowance.js +73 -0
  103. package/dist/execution/checkBalance.d.ts +2 -0
  104. package/dist/execution/checkBalance.js +38 -0
  105. package/dist/execution/multisig.d.ts +4 -3
  106. package/dist/execution/multisig.js +10 -12
  107. package/dist/execution/prepareRestart.d.ts +3 -0
  108. package/dist/execution/prepareRestart.js +61 -0
  109. package/dist/execution/stepComparison.d.ts +3 -3
  110. package/dist/execution/stepComparison.js +3 -3
  111. package/dist/execution/switchChain.d.ts +13 -8
  112. package/dist/execution/switchChain.js +17 -12
  113. package/dist/execution/utils.d.ts +9 -3
  114. package/dist/execution/utils.js +18 -61
  115. package/dist/execution/waitForReceivingTransaction.d.ts +3 -0
  116. package/dist/execution/waitForReceivingTransaction.js +51 -0
  117. package/dist/helpers.d.ts +7 -17
  118. package/dist/helpers.js +5 -34
  119. package/dist/request.js +2 -2
  120. package/dist/services/ApiService.d.ts +2 -2
  121. package/dist/services/ApiService.js +4 -2
  122. package/dist/services/ChainsService.d.ts +1 -1
  123. package/dist/services/ConfigService.d.ts +1 -1
  124. package/dist/services/ConfigService.js +2 -3
  125. package/dist/typeguards.d.ts +1 -1
  126. package/dist/types/abi.d.ts +5 -0
  127. package/dist/types/abi.js +42 -0
  128. package/dist/types/index.d.ts +2 -2
  129. package/dist/types/index.js +2 -2
  130. package/dist/types/internal.types.d.ts +24 -31
  131. package/dist/utils/errors.d.ts +15 -14
  132. package/dist/utils/errors.js +36 -35
  133. package/dist/utils/getMaxPriorityFeePerGas.d.ts +2 -0
  134. package/dist/utils/getMaxPriorityFeePerGas.js +18 -0
  135. package/dist/utils/index.d.ts +5 -0
  136. package/dist/utils/index.js +5 -0
  137. package/dist/utils/median.d.ts +1 -0
  138. package/dist/utils/median.js +11 -0
  139. package/dist/utils/parseError.d.ts +4 -4
  140. package/dist/utils/parseError.js +42 -39
  141. package/dist/utils/utils.d.ts +1 -16
  142. package/dist/utils/utils.js +7 -69
  143. package/dist/version.d.ts +1 -1
  144. package/dist/version.js +1 -1
  145. package/package.json +43 -40
  146. package/dist/allowance/checkAllowance.d.ts +0 -4
  147. package/dist/allowance/checkAllowance.js +0 -96
  148. package/dist/allowance/tokenApproval.d.ts +0 -22
  149. package/dist/allowance/tokenApproval.js +0 -59
  150. package/dist/allowance/utils.d.ts +0 -15
  151. package/dist/allowance/utils.js +0 -77
  152. package/dist/balance/checkBalance.d.ts +0 -3
  153. package/dist/balance/checkBalance.js +0 -38
  154. package/dist/balance/utils.d.ts +0 -6
  155. package/dist/balance/utils.js +0 -143
  156. package/dist/cjs/allowance/checkAllowance.d.ts +0 -4
  157. package/dist/cjs/allowance/checkAllowance.js +0 -103
  158. package/dist/cjs/allowance/tokenApproval.d.ts +0 -22
  159. package/dist/cjs/allowance/tokenApproval.js +0 -69
  160. package/dist/cjs/allowance/utils.d.ts +0 -15
  161. package/dist/cjs/allowance/utils.js +0 -87
  162. package/dist/cjs/balance/checkBalance.d.ts +0 -3
  163. package/dist/cjs/balance/checkBalance.js +0 -45
  164. package/dist/cjs/balance/utils.d.ts +0 -6
  165. package/dist/cjs/balance/utils.js +0 -150
  166. package/dist/cjs/types/ERC20.d.ts +0 -22
  167. package/dist/cjs/types/ERC20.js +0 -53
  168. package/dist/cjs/utils/getProvider.d.ts +0 -3
  169. package/dist/cjs/utils/getProvider.js +0 -11
  170. package/dist/cjs/utils/multicall.d.ts +0 -10
  171. package/dist/cjs/utils/multicall.js +0 -68
  172. package/dist/cjs/utils/multicallAbi.json +0 -313
  173. package/dist/cjs/utils/preRestart.d.ts +0 -3
  174. package/dist/cjs/utils/preRestart.js +0 -56
  175. package/dist/types/ERC20.d.ts +0 -22
  176. package/dist/types/ERC20.js +0 -50
  177. package/dist/utils/getProvider.d.ts +0 -3
  178. package/dist/utils/getProvider.js +0 -7
  179. package/dist/utils/multicall.d.ts +0 -10
  180. package/dist/utils/multicall.js +0 -61
  181. package/dist/utils/multicallAbi.json +0 -313
  182. package/dist/utils/preRestart.d.ts +0 -3
  183. package/dist/utils/preRestart.js +0 -52
@@ -0,0 +1,50 @@
1
+ import { encodeFunctionData, maxUint256, publicActions } from 'viem';
2
+ import { approveAbi } from '../types';
3
+ import { getMaxPriorityFeePerGas } from '../utils';
4
+ import { isNativeTokenAddress } from '../utils/utils';
5
+ import { getAllowance } from './getAllowance';
6
+ export const setAllowance = async (walletClient, tokenAddress, contractAddress, amount, returnPopulatedTransaction) => {
7
+ const data = encodeFunctionData({
8
+ abi: approveAbi,
9
+ functionName: 'approve',
10
+ args: [contractAddress, amount],
11
+ });
12
+ if (returnPopulatedTransaction) {
13
+ return data;
14
+ }
15
+ const client = walletClient.extend(publicActions);
16
+ let maxPriorityFeePerGas;
17
+ if (walletClient.account?.type === 'local') {
18
+ maxPriorityFeePerGas = await getMaxPriorityFeePerGas(client);
19
+ }
20
+ return client.sendTransaction({
21
+ to: tokenAddress,
22
+ account: walletClient.account,
23
+ data,
24
+ maxPriorityFeePerGas,
25
+ chain: null,
26
+ });
27
+ };
28
+ export const setTokenAllowance = async ({ walletClient, token, spenderAddress, amount, infiniteApproval = false, }) => {
29
+ // native token don't need approval
30
+ if (isNativeTokenAddress(token.address)) {
31
+ return;
32
+ }
33
+ const approvedAmount = await getAllowance(token.chainId, token.address, walletClient.account.address, spenderAddress);
34
+ if (amount > approvedAmount) {
35
+ const approvalAmount = infiniteApproval ? maxUint256 : amount;
36
+ const approveTx = await setAllowance(walletClient, token.address, spenderAddress, approvalAmount);
37
+ return approveTx;
38
+ }
39
+ };
40
+ export const revokeTokenApproval = async ({ walletClient, token, spenderAddress, }) => {
41
+ // native token don't need approval
42
+ if (isNativeTokenAddress(token.address)) {
43
+ return;
44
+ }
45
+ const approvedAmount = await getAllowance(token.chainId, token.address, walletClient.account.address, spenderAddress);
46
+ if (approvedAmount > 0) {
47
+ const approveTx = await setAllowance(walletClient, token.address, spenderAddress, 0n);
48
+ return approveTx;
49
+ }
50
+ };
@@ -0,0 +1,27 @@
1
+ import type { Token } from '@lifi/types';
2
+ import type { WalletClient } from 'viem';
3
+ export type TokenSpender = {
4
+ token: Token;
5
+ spenderAddress: string;
6
+ };
7
+ export type TokenAllowance = {
8
+ token: Token;
9
+ allowance?: bigint;
10
+ };
11
+ export type TokenSpenderAllowance = {
12
+ token: Token;
13
+ spenderAddress: string;
14
+ allowance?: bigint;
15
+ };
16
+ export interface ApproveTokenRequest {
17
+ walletClient: WalletClient;
18
+ token: Token;
19
+ spenderAddress: string;
20
+ amount: bigint;
21
+ infiniteApproval?: boolean;
22
+ }
23
+ export interface RevokeApprovalRequest {
24
+ walletClient: WalletClient;
25
+ token: Token;
26
+ spenderAddress: string;
27
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,2 @@
1
+ import type { Token, TokenAmount } from '@lifi/types';
2
+ export declare const getBalance: (walletAddress: string, tokens: Token[]) => Promise<TokenAmount[]>;
@@ -0,0 +1,93 @@
1
+ import { getMulticallAddress, getPublicClient } from '../connectors';
2
+ import { MulticallBatchSize } from '../constants';
3
+ import { balanceOfAbi, getEthBalanceAbi } from '../types';
4
+ import { isZeroAddress } from '../utils/utils';
5
+ export const getBalance = async (walletAddress, tokens) => {
6
+ if (tokens.length === 0) {
7
+ return [];
8
+ }
9
+ const { chainId } = tokens[0];
10
+ tokens.forEach((token) => {
11
+ if (token.chainId !== chainId) {
12
+ console.warn(`Requested tokens have to be on the same chain.`);
13
+ return [];
14
+ }
15
+ });
16
+ const multicallAddress = await getMulticallAddress(chainId);
17
+ if (multicallAddress && tokens.length > 1) {
18
+ return getBalanceMulticall(chainId, tokens, walletAddress, multicallAddress);
19
+ }
20
+ else {
21
+ return getBalanceDefault(chainId, tokens, walletAddress);
22
+ }
23
+ };
24
+ const getBalanceMulticall = async (chainId, tokens, walletAddress, multicallAddress) => {
25
+ const client = await getPublicClient(chainId);
26
+ const contracts = tokens.map((token) => {
27
+ if (isZeroAddress(token.address)) {
28
+ return {
29
+ address: multicallAddress,
30
+ abi: getEthBalanceAbi,
31
+ functionName: 'getEthBalance',
32
+ args: [walletAddress],
33
+ };
34
+ }
35
+ return {
36
+ address: token.address,
37
+ abi: balanceOfAbi,
38
+ functionName: 'balanceOf',
39
+ args: [walletAddress],
40
+ };
41
+ });
42
+ const blockNumber = await client.getBlockNumber();
43
+ const results = await client.multicall({
44
+ contracts,
45
+ multicallAddress: multicallAddress,
46
+ blockNumber,
47
+ batchSize: MulticallBatchSize,
48
+ });
49
+ if (!results.length) {
50
+ return [];
51
+ }
52
+ return tokens.map((token, i) => {
53
+ return {
54
+ ...token,
55
+ amount: results[i].result,
56
+ blockNumber,
57
+ };
58
+ });
59
+ };
60
+ const getBalanceDefault = async (chainId, tokens, walletAddress) => {
61
+ const client = await getPublicClient(chainId);
62
+ const blockNumber = await client.getBlockNumber();
63
+ const queue = tokens.map((token) => {
64
+ if (isZeroAddress(token.address)) {
65
+ return client.getBalance({
66
+ address: walletAddress,
67
+ });
68
+ }
69
+ return client.readContract({
70
+ address: token.address,
71
+ abi: balanceOfAbi,
72
+ functionName: 'balanceOf',
73
+ args: [walletAddress],
74
+ });
75
+ });
76
+ const results = await Promise.allSettled(queue);
77
+ const tokenAmounts = tokens.map((token, index) => {
78
+ const result = results[index];
79
+ if (result.status === 'rejected') {
80
+ console.warn(result.reason);
81
+ return {
82
+ ...token,
83
+ blockNumber,
84
+ };
85
+ }
86
+ return {
87
+ ...token,
88
+ amount: result.value,
89
+ blockNumber,
90
+ };
91
+ });
92
+ return tokenAmounts;
93
+ };
@@ -1,7 +1,7 @@
1
- import { Token, TokenAmount } from '@lifi/types';
1
+ import type { Token, TokenAmount } from '@lifi/types';
2
2
  export declare const getTokenBalance: (walletAddress: string, token: Token) => Promise<TokenAmount | null>;
3
3
  export declare const getTokenBalances: (walletAddress: string, tokens: Token[]) => Promise<TokenAmount[]>;
4
- export declare const getTokenBalancesForChains: (walletAddress: string, tokensByChain: {
4
+ export declare const getTokenBalancesByChain: (walletAddress: string, tokensByChain: {
5
5
  [chainId: number]: Token[];
6
6
  }) => Promise<{
7
7
  [chainId: number]: TokenAmount[];
@@ -1,4 +1,4 @@
1
- import utils from './utils';
1
+ import { getBalance } from './getBalance';
2
2
  export const getTokenBalance = async (walletAddress, token) => {
3
3
  const tokenAmounts = await getTokenBalances(walletAddress, [token]);
4
4
  return tokenAmounts.length ? tokenAmounts[0] : null;
@@ -12,14 +12,14 @@ export const getTokenBalances = async (walletAddress, tokens) => {
12
12
  }
13
13
  tokensByChain[token.chainId].push(token);
14
14
  });
15
- const tokenAmountsByChain = await getTokenBalancesForChains(walletAddress, tokensByChain);
15
+ const tokenAmountsByChain = await getTokenBalancesByChain(walletAddress, tokensByChain);
16
16
  return Object.values(tokenAmountsByChain).flat();
17
17
  };
18
- export const getTokenBalancesForChains = async (walletAddress, tokensByChain) => {
18
+ export const getTokenBalancesByChain = async (walletAddress, tokensByChain) => {
19
19
  const tokenAmountsByChain = {};
20
20
  const promises = Object.keys(tokensByChain).map(async (chainIdStr) => {
21
21
  const chainId = parseInt(chainIdStr);
22
- const tokenAmounts = await utils.getBalances(walletAddress, tokensByChain[chainId]);
22
+ const tokenAmounts = await getBalance(walletAddress, tokensByChain[chainId]);
23
23
  tokenAmountsByChain[chainId] = tokenAmounts;
24
24
  });
25
25
  await Promise.allSettled(promises);
@@ -1,13 +1,2 @@
1
- export * from './checkBalance';
1
+ export * from './getBalance';
2
2
  export * from './getTokenBalance';
3
- declare const _default: {
4
- checkBalance: (signer: import("ethers").Signer, step: import("@lifi/types").LifiStep, depth?: number) => Promise<void>;
5
- getTokenBalance: (walletAddress: string, token: import("@lifi/types").Token) => Promise<import("@lifi/types").TokenAmount | null>;
6
- getTokenBalances: (walletAddress: string, tokens: import("@lifi/types").Token[]) => Promise<import("@lifi/types").TokenAmount[]>;
7
- getTokenBalancesForChains: (walletAddress: string, tokensByChain: {
8
- [chainId: number]: import("@lifi/types").Token[];
9
- }) => Promise<{
10
- [chainId: number]: import("@lifi/types").TokenAmount[];
11
- }>;
12
- };
13
- export default _default;
@@ -1,10 +1,2 @@
1
- export * from './checkBalance';
1
+ export * from './getBalance';
2
2
  export * from './getTokenBalance';
3
- import { checkBalance } from './checkBalance';
4
- import { getTokenBalance, getTokenBalances, getTokenBalancesForChains, } from './getTokenBalance';
5
- export default {
6
- checkBalance,
7
- getTokenBalance,
8
- getTokenBalances,
9
- getTokenBalancesForChains,
10
- };
@@ -1,160 +1,167 @@
1
- import { FallbackProvider } from '@ethersproject/providers';
2
- import { ChainId, ChainKey, ConnectionsRequest, ConnectionsResponse, ContractCallQuoteRequest, ExtendedChain, GasRecommendationRequest, GasRecommendationResponse, GetStatusRequest, LifiStep, PossibilitiesRequest, PossibilitiesResponse, QuoteRequest, RequestOptions, RoutesRequest, RoutesResponse, StatusResponse, Token, TokenAmount, TokensRequest, TokensResponse, ToolsRequest, ToolsResponse } from '@lifi/types';
3
- import { Signer } from 'ethers';
4
- import { ApproveTokenRequest, RevokeApprovalRequest } from './allowance';
1
+ import type { ChainId, ChainKey, ConnectionsRequest, ConnectionsResponse, ContractCallQuoteRequest, ExtendedChain, GasRecommendationRequest, GasRecommendationResponse, GetStatusRequest, LifiStep, PossibilitiesRequest, PossibilitiesResponse, QuoteRequest, RequestOptions, RoutesRequest, RoutesResponse, StatusResponse, Token, TokenAmount, TokensRequest, TokensResponse, ToolsRequest, ToolsResponse } from '@lifi/types';
2
+ import type { Hash, PublicClient } from 'viem';
3
+ import type { ApproveTokenRequest, RevokeApprovalRequest, TokenAllowance, TokenSpender } from './allowance';
5
4
  import { RouteExecutionManager } from './execution/RouteExecutionManager';
6
- import { Config, ConfigUpdate, RevokeTokenData } from './types';
5
+ import type { Config, ConfigUpdate } from './types';
7
6
  export declare class LiFi extends RouteExecutionManager {
8
7
  private chainsService;
9
8
  constructor(configUpdate: ConfigUpdate);
10
9
  /**
11
10
  * Get the current configuration of the SDK
12
- * @return {Config} - The config object
11
+ * @returns - The config object
13
12
  */
14
13
  getConfig: () => Config;
15
14
  /**
16
15
  * Get the SDK configuration after all setup calls are finished
17
- * @return {Promise<Config>} - The config object
16
+ * @returns - The config object
18
17
  */
19
18
  getConfigAsync: () => Promise<Config>;
20
19
  /**
21
20
  * Get an instance of a provider for a specific chain
22
- * @param {number} chainId - Id of the chain the provider is for
23
- * @param {boolean} archive - Whether to use an archive provider that is based on a default rpc or not. defaults to false
24
- * @return {FallbackProvider} The provider for the given chain
21
+ * @param chainId - Id of the chain the provider is for
22
+ * @returns The public client for the given chain
25
23
  */
26
- getRpcProvider: (chainId: number, archive?: boolean) => Promise<FallbackProvider>;
24
+ getPublicClient: (chainId: number) => Promise<PublicClient>;
27
25
  /**
28
26
  * Set a new confuration for the SDK
29
- * @param {ConfigUpdate} configUpdate - An object containing the configuration fields that should be updated.
30
- * @return {Config} The renewed config object
27
+ * @param configUpdate - An object containing the configuration fields that should be updated.
28
+ * @returns The renewed config object
31
29
  */
32
30
  setConfig: (configUpdate: Partial<ConfigUpdate>) => Config;
33
31
  /**
34
32
  * Get a set of current possibilities based on a request that specifies which chains, exchanges and bridges are preferred or unwanted.
35
- * @param {PossibilitiesRequest} request - Object defining preferences regarding chain, exchanges and bridges
36
- * @return {Promise<PossibilitiesResponse>} Object listing current possibilities for any-to-any cross-chain-swaps based on the provided preferences.
37
- * @throws {LifiError} Throws a LifiError if request fails.
33
+ * @param request - Object defining preferences regarding chain, exchanges and bridges
34
+ * @param options
35
+ * @returns Object listing current possibilities for any-to-any cross-chain-swaps based on the provided preferences.
36
+ * @throws {LiFiError} Throws a LiFiError if request fails.
38
37
  * @deprecated We don't want to support this endpoint anymore in the future. /chains, /tools, /connections, and /tokens should be used instead
39
38
  */
40
39
  getPossibilities: (request?: PossibilitiesRequest, options?: RequestOptions) => Promise<PossibilitiesResponse>;
41
40
  /**
42
41
  * Fetch information about a Token
43
- * @param {ChainKey | ChainId} chain - Id or key of the chain that contains the token
44
- * @param {string} token - Address or symbol of the token on the requested chain
45
- * @throws {LifiError} - Throws a LifiError if request fails
42
+ * @param chain - Id or key of the chain that contains the token
43
+ * @param token - Address or symbol of the token on the requested chain
44
+ * @param options
45
+ * @throws {LiFiError} - Throws a LiFiError if request fails
46
46
  */
47
47
  getToken: (chain: ChainKey | ChainId, token: string, options?: RequestOptions) => Promise<Token>;
48
48
  /**
49
49
  * Get a quote for a token transfer
50
- * @param {QuoteRequest} request - The configuration of the requested quote
51
- * @throws {LifiError} - Throws a LifiError if request fails
50
+ * @param request - The configuration of the requested quote
51
+ * @param options
52
+ * @throws {LiFiError} - Throws a LiFiError if request fails
52
53
  */
53
54
  getQuote: (request: QuoteRequest, options?: RequestOptions) => Promise<LifiStep>;
54
55
  /**
55
56
  * Get a quote for a destination contract call
56
- * @param {ContractCallQuoteRequest} request - The configuration of the requested destination call
57
- * @throws {LifiError} - Throws a LifiError if request fails
57
+ * @param request - The configuration of the requested destination call
58
+ * @param options
59
+ * @throws {LiFiError} - Throws a LiFiError if request fails
60
+ * @returns - Returns step.
58
61
  */
59
62
  getContractCallQuote: (request: ContractCallQuoteRequest, options?: RequestOptions) => Promise<LifiStep>;
60
63
  /**
61
64
  * Check the status of a transfer. For cross chain transfers, the "bridge" parameter is required.
62
- * @param {GetStatusRequest} request - Configuration of the requested status
63
- * @throws {LifiError} - Throws a LifiError if request fails
65
+ * @param request - Configuration of the requested status
66
+ * @param options - Rrquest options.
67
+ * @throws {LiFiError} - Throws a LiFiError if request fails
68
+ * @returns Returns status response.
64
69
  */
65
70
  getStatus: (request: GetStatusRequest, options?: RequestOptions) => Promise<StatusResponse>;
66
71
  /**
67
72
  * Get the available tools to bridge and swap tokens.
68
- * @param {ToolsRequest?} request - The configuration of the requested tools
73
+ * @param request - The configuration of the requested tools
74
+ * @param options
69
75
  * @returns The tools that are available on the requested chains
70
76
  */
71
77
  getTools: (request?: ToolsRequest, options?: RequestOptions) => Promise<ToolsResponse>;
72
78
  /**
73
79
  * Get all known tokens.
74
- * @param {TokensRequest?} request - The configuration of the requested tokens
80
+ * @param request - The configuration of the requested tokens
81
+ * @param options
75
82
  * @returns The tokens that are available on the requested chains
76
83
  */
77
84
  getTokens: (request?: TokensRequest, options?: RequestOptions) => Promise<TokensResponse>;
78
85
  /**
79
86
  * Get all available chains
80
- * @return {Promise<Chain[]>} A list of all available chains
81
- * @throws {LifiError} Throws a LifiError if request fails.
87
+ * @returns A list of all available chains
88
+ * @throws {LiFiError} Throws a LiFiError if request fails.
82
89
  */
83
90
  getChains: () => Promise<ExtendedChain[]>;
84
91
  /**
85
92
  * Get a set of routes for a request that describes a transfer of tokens.
86
- * @param {RoutesRequest} request - A description of the transfer.
87
- * @return {Promise<RoutesResponse>} The resulting routes that can be used to realize the described transfer of tokens.
88
- * @throws {LifiError} Throws a LifiError if request fails.
93
+ * @param request - A description of the transfer.
94
+ * @param options
95
+ * @returns The resulting routes that can be used to realize the described transfer of tokens.
96
+ * @throws {LiFiError} Throws a LiFiError if request fails.
89
97
  */
90
98
  getRoutes: (request: RoutesRequest, options?: RequestOptions) => Promise<RoutesResponse>;
91
99
  /**
92
100
  * Get the transaction data for a single step of a route
93
- * @param {LifiStep} step - The step object.
94
- * @return {Promise<LifiStep>} The step populated with the transaction data.
95
- * @throws {LifiError} Throws a LifiError if request fails.
101
+ * @param step - The step object.
102
+ * @param options
103
+ * @returns The step populated with the transaction data.
104
+ * @throws {LiFiError} Throws a LiFiError if request fails.
96
105
  */
97
106
  getStepTransaction: (step: LifiStep, options?: RequestOptions) => Promise<LifiStep>;
98
107
  /**
99
108
  * Get gas recommendation for a certain chain
100
- * @param {GasRecommendationRequest} request - Configuration of the requested recommendation.
101
- * @throws {LifiError} Throws a LifiError if request fails.
109
+ * @param request - Configuration of the requested recommendation.
110
+ * @param options
111
+ * @throws {LiFiError} Throws a LiFiError if request fails.
102
112
  */
103
113
  getGasRecommendation: (request: GasRecommendationRequest, options?: RequestOptions) => Promise<GasRecommendationResponse>;
104
114
  /**
105
115
  * Returns the balances of a specific token a wallet holds across all aggregated chains.
106
- * @param {string} walletAddress - A wallet address.
107
- * @param {Token} token - A Token object.
108
- * @return {Promise<TokenAmount | null>} An object containing the token and the amounts on different chains.
116
+ * @param walletAddress - A wallet address.
117
+ * @param token - A Token object.
118
+ * @returns An object containing the token and the amounts on different chains.
109
119
  * @throws {ValidationError} Throws a ValidationError if parameters are invalid.
110
120
  */
111
121
  getTokenBalance: (walletAddress: string, token: Token) => Promise<TokenAmount | null>;
112
122
  /**
113
123
  * Returns the balances for a list tokens a wallet holds across all aggregated chains.
114
- * @param {string} walletAddress - A wallet address.
115
- * @param {Token[]} tokens - A list of Token objects.
116
- * @return {Promise<TokenAmount[]>} A list of objects containing the tokens and the amounts on different chains.
124
+ * @param walletAddress - A wallet address.
125
+ * @param tokens - A list of Token objects.
126
+ * @returns A list of objects containing the tokens and the amounts on different chains.
117
127
  * @throws {ValidationError} Throws a ValidationError if parameters are invalid.
118
128
  */
119
129
  getTokenBalances: (walletAddress: string, tokens: Token[]) => Promise<TokenAmount[]>;
120
130
  /**
121
131
  * This method queries the balances of tokens for a specific list of chains for a given wallet.
122
- * @param {string} walletAddress - A walletaddress.
123
- * @param {{ [chainId: number]: Token[] }} tokensByChain - A list of Token objects organized by chain ids.
124
- * @return {Promise<{ [chainId: number]: TokenAmount[] }>} A list of objects containing the tokens and the amounts on different chains organized by the chosen chains.
132
+ * @param walletAddress - A walletaddress.
133
+ * @param tokensByChain - A list of Token objects organized by chain ids.
134
+ * @returns A list of objects containing the tokens and the amounts on different chains organized by the chosen chains.
125
135
  * @throws {ValidationError} Throws a ValidationError if parameters are invalid.
126
136
  */
127
- getTokenBalancesForChains: (walletAddress: string, tokensByChain: {
137
+ getTokenBalancesByChain: (walletAddress: string, tokensByChain: {
128
138
  [chainId: number]: Token[];
129
139
  }) => Promise<{
130
140
  [chainId: number]: TokenAmount[];
131
141
  }>;
132
142
  /**
133
- * Get the current approval for a certain token.
134
- * @param signer - The signer owning the token
143
+ * Get the current allowance for a certain token.
135
144
  * @param token - The token that should be checked
136
- * @param approvalAddress - The address that has be approved
145
+ * @param ownerAddress - The owner of the token
146
+ * @param spenderAddress - The spender address that has to be approved
137
147
  */
138
- getTokenApproval: (signer: Signer, token: Token, approvalAddress: string) => Promise<string | undefined>;
148
+ getTokenAllowance: (token: Token, ownerAddress: string, spenderAddress: string) => Promise<bigint | undefined>;
139
149
  /**
140
- * Get the current approval for a list of token / approval address pairs.
141
- * @param signer - The signer owning the tokens
142
- * @param tokenData - A list of token and approval address pairs
150
+ * Get the current allowance for a list of token / spender address pairs.
151
+ * @param ownerAddress - The owner of the tokens
152
+ * @param tokens - A list of token and spender address pairs
143
153
  */
144
- bulkGetTokenApproval: (signer: Signer, tokenData: RevokeTokenData[]) => Promise<{
145
- token: Token;
146
- approval: string | undefined;
147
- }[]>;
154
+ getTokenAllowanceMulticall: (ownerAddress: string, tokens: TokenSpender[]) => Promise<TokenAllowance[]>;
148
155
  /**
149
156
  * Set approval for a certain token and amount.
150
- * @param { ApproveTokenRequest } request - The approval request
157
+ * @param request - The approval request
151
158
  */
152
- approveToken: (request: ApproveTokenRequest) => Promise<void>;
159
+ setTokenApproval: (request: ApproveTokenRequest) => Promise<Hash | void>;
153
160
  /**
154
161
  * Revoke approval for a certain token.
155
- * @param { RevokeApprovalRequest } request - The revoke request
162
+ * @param request - The revoke request
156
163
  */
157
- revokeTokenApproval: (request: RevokeApprovalRequest) => Promise<void>;
164
+ revokeTokenApproval: (request: RevokeApprovalRequest) => Promise<Hash | void>;
158
165
  /**
159
166
  * Get all the available connections for swap/bridging tokens
160
167
  * @param connectionRequest ConnectionsRequest