@imtbl/dex-sdk 2.0.0-alpha.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 (74) hide show
  1. package/LICENSE.md +176 -0
  2. package/README.md +3 -0
  3. package/dist/browser/index.js +2 -0
  4. package/dist/node/index.cjs +2 -0
  5. package/dist/node/index.js +2 -0
  6. package/dist/types/config/config.test.d.ts +1 -0
  7. package/dist/types/config/index.d.ts +18 -0
  8. package/dist/types/constants/chains/immutable-mainnet.d.ts +2 -0
  9. package/dist/types/constants/chains/immutable-testnet.d.ts +2 -0
  10. package/dist/types/constants/chains/index.d.ts +2 -0
  11. package/dist/types/constants/index.d.ts +3 -0
  12. package/dist/types/constants/router.d.ts +8 -0
  13. package/dist/types/constants/tokens/immutable-mainnet.d.ts +5 -0
  14. package/dist/types/constants/tokens/immutable-testnet.d.ts +4 -0
  15. package/dist/types/constants/tokens/index.d.ts +2 -0
  16. package/dist/types/constants/wrapping.d.ts +2 -0
  17. package/dist/types/contracts/types/ERC20.d.ts +141 -0
  18. package/dist/types/contracts/types/ImmutableSwapProxy.d.ts +469 -0
  19. package/dist/types/contracts/types/Multicall.d.ts +83 -0
  20. package/dist/types/contracts/types/QuoterV2.d.ts +219 -0
  21. package/dist/types/contracts/types/UniswapV3Pool.d.ts +732 -0
  22. package/dist/types/contracts/types/WIMX.d.ts +179 -0
  23. package/dist/types/contracts/types/common.d.ts +50 -0
  24. package/dist/types/contracts/types/factories/ERC20__factory.d.ts +174 -0
  25. package/dist/types/contracts/types/factories/ImmutableSwapProxy__factory.d.ts +612 -0
  26. package/dist/types/contracts/types/factories/Multicall__factory.d.ts +90 -0
  27. package/dist/types/contracts/types/factories/QuoterV2__factory.d.ts +226 -0
  28. package/dist/types/contracts/types/factories/UniswapV3Pool__factory.d.ts +795 -0
  29. package/dist/types/contracts/types/factories/WIMX__factory.d.ts +219 -0
  30. package/dist/types/contracts/types/factories/index.d.ts +6 -0
  31. package/dist/types/contracts/types/index.d.ts +13 -0
  32. package/dist/types/errors/exchangeError.d.ts +61 -0
  33. package/dist/types/errors/index.d.ts +1 -0
  34. package/dist/types/exchange.d.ts +50 -0
  35. package/dist/types/exchange.getUnsignedSwapTxFromAmountIn.test.d.ts +1 -0
  36. package/dist/types/exchange.getUnsignedSwapTxFromAmountOut.test.d.ts +1 -0
  37. package/dist/types/exchange.test.d.ts +1 -0
  38. package/dist/types/index.d.ts +4 -0
  39. package/dist/types/lib/fees.d.ts +16 -0
  40. package/dist/types/lib/fees.test.d.ts +1 -0
  41. package/dist/types/lib/getQuotesForRoutes.d.ts +14 -0
  42. package/dist/types/lib/getQuotesForRoutes.test.d.ts +1 -0
  43. package/dist/types/lib/index.d.ts +3 -0
  44. package/dist/types/lib/multicall.d.ts +12 -0
  45. package/dist/types/lib/multicall.test.d.ts +1 -0
  46. package/dist/types/lib/nativeTokenService.d.ts +13 -0
  47. package/dist/types/lib/nativeTokenService.test.d.ts +1 -0
  48. package/dist/types/lib/poolUtils/computePoolAddress.d.ts +9 -0
  49. package/dist/types/lib/poolUtils/ensureCorrectERC20AddressOrder.test.d.ts +1 -0
  50. package/dist/types/lib/poolUtils/fetchValidPools.d.ts +14 -0
  51. package/dist/types/lib/poolUtils/fetchValidPools.test.d.ts +1 -0
  52. package/dist/types/lib/poolUtils/generateAllAcyclicPaths.test.d.ts +1 -0
  53. package/dist/types/lib/poolUtils/generateERC20Pairs.d.ts +7 -0
  54. package/dist/types/lib/poolUtils/generateERC20Pairs.test.d.ts +1 -0
  55. package/dist/types/lib/poolUtils/generatePossiblePoolsFromERC20Pairs.d.ts +11 -0
  56. package/dist/types/lib/poolUtils/generatePossiblePoolsFromERC20Pairs.test.d.ts +1 -0
  57. package/dist/types/lib/router.d.ts +24 -0
  58. package/dist/types/lib/router.test.d.ts +1 -0
  59. package/dist/types/lib/transactionUtils/approval.d.ts +25 -0
  60. package/dist/types/lib/transactionUtils/approval.test.d.ts +1 -0
  61. package/dist/types/lib/transactionUtils/gas.d.ts +18 -0
  62. package/dist/types/lib/transactionUtils/gas.test.d.ts +1 -0
  63. package/dist/types/lib/transactionUtils/getQuote.d.ts +13 -0
  64. package/dist/types/lib/transactionUtils/getQuote.test.d.ts +1 -0
  65. package/dist/types/lib/transactionUtils/slippage.d.ts +2 -0
  66. package/dist/types/lib/transactionUtils/slippage.test.d.ts +1 -0
  67. package/dist/types/lib/transactionUtils/swap.d.ts +16 -0
  68. package/dist/types/lib/transactionUtils/swap.test.d.ts +1 -0
  69. package/dist/types/lib/utils.d.ts +60 -0
  70. package/dist/types/lib/utils.test.d.ts +1 -0
  71. package/dist/types/test/utils.d.ts +134 -0
  72. package/dist/types/test/utils.test.d.ts +1 -0
  73. package/dist/types/types/index.d.ts +174 -0
  74. package/package.json +74 -0
@@ -0,0 +1,219 @@
1
+ import { type ContractRunner } from "ethers";
2
+ import type { WIMX, WIMXInterface } from "../WIMX";
3
+ export declare class WIMX__factory {
4
+ static readonly abi: readonly [{
5
+ readonly constant: true;
6
+ readonly inputs: readonly [];
7
+ readonly name: "name";
8
+ readonly outputs: readonly [{
9
+ readonly name: "";
10
+ readonly type: "string";
11
+ }];
12
+ readonly payable: false;
13
+ readonly stateMutability: "view";
14
+ readonly type: "function";
15
+ }, {
16
+ readonly constant: false;
17
+ readonly inputs: readonly [{
18
+ readonly name: "guy";
19
+ readonly type: "address";
20
+ }, {
21
+ readonly name: "wad";
22
+ readonly type: "uint256";
23
+ }];
24
+ readonly name: "approve";
25
+ readonly outputs: readonly [{
26
+ readonly name: "";
27
+ readonly type: "bool";
28
+ }];
29
+ readonly payable: false;
30
+ readonly stateMutability: "nonpayable";
31
+ readonly type: "function";
32
+ }, {
33
+ readonly constant: true;
34
+ readonly inputs: readonly [];
35
+ readonly name: "totalSupply";
36
+ readonly outputs: readonly [{
37
+ readonly name: "";
38
+ readonly type: "uint256";
39
+ }];
40
+ readonly payable: false;
41
+ readonly stateMutability: "view";
42
+ readonly type: "function";
43
+ }, {
44
+ readonly constant: false;
45
+ readonly inputs: readonly [{
46
+ readonly name: "src";
47
+ readonly type: "address";
48
+ }, {
49
+ readonly name: "dst";
50
+ readonly type: "address";
51
+ }, {
52
+ readonly name: "wad";
53
+ readonly type: "uint256";
54
+ }];
55
+ readonly name: "transferFrom";
56
+ readonly outputs: readonly [{
57
+ readonly name: "";
58
+ readonly type: "bool";
59
+ }];
60
+ readonly payable: false;
61
+ readonly stateMutability: "nonpayable";
62
+ readonly type: "function";
63
+ }, {
64
+ readonly constant: false;
65
+ readonly inputs: readonly [{
66
+ readonly name: "wad";
67
+ readonly type: "uint256";
68
+ }];
69
+ readonly name: "withdraw";
70
+ readonly outputs: readonly [];
71
+ readonly payable: false;
72
+ readonly stateMutability: "nonpayable";
73
+ readonly type: "function";
74
+ }, {
75
+ readonly constant: true;
76
+ readonly inputs: readonly [];
77
+ readonly name: "decimals";
78
+ readonly outputs: readonly [{
79
+ readonly name: "";
80
+ readonly type: "uint8";
81
+ }];
82
+ readonly payable: false;
83
+ readonly stateMutability: "view";
84
+ readonly type: "function";
85
+ }, {
86
+ readonly constant: true;
87
+ readonly inputs: readonly [{
88
+ readonly name: "";
89
+ readonly type: "address";
90
+ }];
91
+ readonly name: "balanceOf";
92
+ readonly outputs: readonly [{
93
+ readonly name: "";
94
+ readonly type: "uint256";
95
+ }];
96
+ readonly payable: false;
97
+ readonly stateMutability: "view";
98
+ readonly type: "function";
99
+ }, {
100
+ readonly constant: true;
101
+ readonly inputs: readonly [];
102
+ readonly name: "symbol";
103
+ readonly outputs: readonly [{
104
+ readonly name: "";
105
+ readonly type: "string";
106
+ }];
107
+ readonly payable: false;
108
+ readonly stateMutability: "view";
109
+ readonly type: "function";
110
+ }, {
111
+ readonly constant: false;
112
+ readonly inputs: readonly [{
113
+ readonly name: "dst";
114
+ readonly type: "address";
115
+ }, {
116
+ readonly name: "wad";
117
+ readonly type: "uint256";
118
+ }];
119
+ readonly name: "transfer";
120
+ readonly outputs: readonly [{
121
+ readonly name: "";
122
+ readonly type: "bool";
123
+ }];
124
+ readonly payable: false;
125
+ readonly stateMutability: "nonpayable";
126
+ readonly type: "function";
127
+ }, {
128
+ readonly constant: false;
129
+ readonly inputs: readonly [];
130
+ readonly name: "deposit";
131
+ readonly outputs: readonly [];
132
+ readonly payable: true;
133
+ readonly stateMutability: "payable";
134
+ readonly type: "function";
135
+ }, {
136
+ readonly constant: true;
137
+ readonly inputs: readonly [{
138
+ readonly name: "";
139
+ readonly type: "address";
140
+ }, {
141
+ readonly name: "";
142
+ readonly type: "address";
143
+ }];
144
+ readonly name: "allowance";
145
+ readonly outputs: readonly [{
146
+ readonly name: "";
147
+ readonly type: "uint256";
148
+ }];
149
+ readonly payable: false;
150
+ readonly stateMutability: "view";
151
+ readonly type: "function";
152
+ }, {
153
+ readonly payable: true;
154
+ readonly stateMutability: "payable";
155
+ readonly type: "fallback";
156
+ }, {
157
+ readonly anonymous: false;
158
+ readonly inputs: readonly [{
159
+ readonly indexed: true;
160
+ readonly name: "src";
161
+ readonly type: "address";
162
+ }, {
163
+ readonly indexed: true;
164
+ readonly name: "guy";
165
+ readonly type: "address";
166
+ }, {
167
+ readonly indexed: false;
168
+ readonly name: "wad";
169
+ readonly type: "uint256";
170
+ }];
171
+ readonly name: "Approval";
172
+ readonly type: "event";
173
+ }, {
174
+ readonly anonymous: false;
175
+ readonly inputs: readonly [{
176
+ readonly indexed: true;
177
+ readonly name: "src";
178
+ readonly type: "address";
179
+ }, {
180
+ readonly indexed: true;
181
+ readonly name: "dst";
182
+ readonly type: "address";
183
+ }, {
184
+ readonly indexed: false;
185
+ readonly name: "wad";
186
+ readonly type: "uint256";
187
+ }];
188
+ readonly name: "Transfer";
189
+ readonly type: "event";
190
+ }, {
191
+ readonly anonymous: false;
192
+ readonly inputs: readonly [{
193
+ readonly indexed: true;
194
+ readonly name: "dst";
195
+ readonly type: "address";
196
+ }, {
197
+ readonly indexed: false;
198
+ readonly name: "wad";
199
+ readonly type: "uint256";
200
+ }];
201
+ readonly name: "Deposit";
202
+ readonly type: "event";
203
+ }, {
204
+ readonly anonymous: false;
205
+ readonly inputs: readonly [{
206
+ readonly indexed: true;
207
+ readonly name: "src";
208
+ readonly type: "address";
209
+ }, {
210
+ readonly indexed: false;
211
+ readonly name: "wad";
212
+ readonly type: "uint256";
213
+ }];
214
+ readonly name: "Withdrawal";
215
+ readonly type: "event";
216
+ }];
217
+ static createInterface(): WIMXInterface;
218
+ static connect(address: string, runner?: ContractRunner | null): WIMX;
219
+ }
@@ -0,0 +1,6 @@
1
+ export { ERC20__factory } from "./ERC20__factory";
2
+ export { ImmutableSwapProxy__factory } from "./ImmutableSwapProxy__factory";
3
+ export { Multicall__factory } from "./Multicall__factory";
4
+ export { QuoterV2__factory } from "./QuoterV2__factory";
5
+ export { UniswapV3Pool__factory } from "./UniswapV3Pool__factory";
6
+ export { WIMX__factory } from "./WIMX__factory";
@@ -0,0 +1,13 @@
1
+ export type { ERC20 } from "./ERC20";
2
+ export type { ImmutableSwapProxy } from "./ImmutableSwapProxy";
3
+ export type { Multicall } from "./Multicall";
4
+ export type { QuoterV2 } from "./QuoterV2";
5
+ export type { UniswapV3Pool } from "./UniswapV3Pool";
6
+ export type { WIMX } from "./WIMX";
7
+ export * as factories from "./factories";
8
+ export { ERC20__factory } from "./factories/ERC20__factory";
9
+ export { ImmutableSwapProxy__factory } from "./factories/ImmutableSwapProxy__factory";
10
+ export { Multicall__factory } from "./factories/Multicall__factory";
11
+ export { QuoterV2__factory } from "./factories/QuoterV2__factory";
12
+ export { UniswapV3Pool__factory } from "./factories/UniswapV3Pool__factory";
13
+ export { WIMX__factory } from "./factories/WIMX__factory";
@@ -0,0 +1,61 @@
1
+ import { Environment } from '@imtbl/config';
2
+ /**
3
+ * @enum {string} Errors that can be returned by the Exchange.
4
+ */
5
+ export declare enum ExchangeErrorCode {
6
+ INVALID_CONFIGURATION = "INVALID_CONFIGURATION",
7
+ INVALID_SLIPPAGE = "INVALID_SLIPPAGE",
8
+ INVALID_MAX_HOPS = "INVALID_MAX_HOPS",
9
+ INVALID_ADDRESS = "INVALID_ADDRESS",
10
+ DUPLICATE_ADDRESSES = "DUPLICATE_ADDRESSES",
11
+ CHAIN_NOT_SUPPORTED = "CHAIN_NOT_SUPPORTED",
12
+ NO_ROUTES_AVAILABLE = "NO_ROUTES_AVAILABLE",
13
+ PROVIDER_CALL_ERROR = "PROVIDER_CALL_ERROR",
14
+ APPROVE_ERROR = "APPROVE_ERROR",
15
+ ALREADY_APPROVED_ERROR = "ALREADY_APPROVED_ERROR"
16
+ }
17
+ /**
18
+ * The type signature for an error.
19
+ * Contains a type that corresponds to a {@link ExchangeError} and an optional message string.
20
+ */
21
+ export type ExchangeErrorType = {
22
+ type: ExchangeError;
23
+ message: string;
24
+ };
25
+ /**
26
+ * The {@link ExchangeError} error class that extends the {@link Error} class.
27
+ * Contains a message string and a type that corresponds to an {@link ExchangeErrorCode}.
28
+ * It has a constructor that takes in a message string and a type.
29
+ */
30
+ export declare class ExchangeError extends Error {
31
+ message: string;
32
+ code: ExchangeErrorCode;
33
+ constructor(message: string, code: ExchangeErrorCode);
34
+ }
35
+ export declare class InvalidConfigurationError extends ExchangeError {
36
+ constructor(message?: string);
37
+ }
38
+ export declare class ChainNotSupportedError extends ExchangeError {
39
+ constructor(chain: number, environment: Environment);
40
+ }
41
+ export declare class InvalidSlippageError extends ExchangeError {
42
+ constructor(message: string);
43
+ }
44
+ export declare class InvalidMaxHopsError extends ExchangeError {
45
+ constructor(message: string);
46
+ }
47
+ export declare class InvalidAddressError extends ExchangeError {
48
+ constructor(message: string);
49
+ }
50
+ export declare class DuplicateAddressesError extends ExchangeError {
51
+ constructor();
52
+ }
53
+ export declare class NoRoutesAvailableError extends ExchangeError {
54
+ constructor();
55
+ }
56
+ export declare class ProviderCallError extends ExchangeError {
57
+ constructor(message: string);
58
+ }
59
+ export declare class ApproveError extends ExchangeError {
60
+ constructor(message: string);
61
+ }
@@ -0,0 +1 @@
1
+ export * from './exchangeError';
@@ -0,0 +1,50 @@
1
+ import { BigNumberish } from 'ethers';
2
+ import { ExchangeModuleConfiguration, TransactionResponse } from './types';
3
+ export declare class Exchange {
4
+ private provider;
5
+ private batchProvider;
6
+ private router;
7
+ private chainId;
8
+ private nativeToken;
9
+ private wrappedNativeToken;
10
+ private secondaryFees;
11
+ private nativeTokenService;
12
+ private swapProxyContractAddress;
13
+ private routerContractAddress;
14
+ constructor(configuration: ExchangeModuleConfiguration);
15
+ private static validate;
16
+ private getSecondaryFees;
17
+ private parseTokenLiteral;
18
+ private getUnwrapTransaction;
19
+ private getWrapTransaction;
20
+ private getUnsignedWrapUnwrapTx;
21
+ private getUnsignedSwapTx;
22
+ /**
23
+ * Get the unsigned swap transaction given the amount to sell.
24
+ * Includes quote details for the swap.
25
+ *
26
+ * @param {string} fromAddress The public address that will sign and submit the transaction
27
+ * @param {string} tokenInAddress Token address or 'native' to sell
28
+ * @param {string} tokenOutAddress Token address or 'native' to buy
29
+ * @param {ethers.BigNumberish} amountIn Amount to sell in the smallest unit of the token-in
30
+ * @param {number} slippagePercent (optional) The percentage of slippage tolerance. Default = 0.1. Max = 50. Min = 0
31
+ * @param {number} maxHops (optional) Maximum hops allowed in optimal route. Default is 2
32
+ * @param {number} deadline (optional) Latest time swap can execute. Default is 15 minutes
33
+ * @return {TransactionResponse} The result containing the unsigned transaction and details of the swap
34
+ */
35
+ getUnsignedSwapTxFromAmountIn(fromAddress: string, tokenInAddress: string, tokenOutAddress: string, amountIn: BigNumberish, slippagePercent?: number, maxHops?: number, deadline?: number): Promise<TransactionResponse>;
36
+ /**
37
+ * Get the unsigned swap transaction given the amount to buy.
38
+ * Includes quote details for the swap.
39
+ *
40
+ * @param {string} fromAddress The public address that will sign and submit the transaction
41
+ * @param {string} tokenInAddress ERC20 contract address or 'native' to sell
42
+ * @param {string} tokenOutAddress ERC20 contract address or 'native' to buy
43
+ * @param {ethers.BigNumberish} amountOut Amount to buy in the smallest unit of the token-out
44
+ * @param {number} slippagePercent (optional) The percentage of slippage tolerance. Default = 0.1. Max = 50. Min = 0
45
+ * @param {number} maxHops (optional) Maximum hops allowed in optimal route. Default is 2
46
+ * @param {number} deadline (optional) Latest time swap can execute. Default is 15 minutes
47
+ * @return {TransactionResponse} The result containing the unsigned transaction and details of the swap
48
+ */
49
+ getUnsignedSwapTxFromAmountOut(fromAddress: string, tokenInAddress: string, tokenOutAddress: string, amountOut: BigNumberish, slippagePercent?: number, maxHops?: number, deadline?: number): Promise<TransactionResponse>;
50
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,4 @@
1
+ export * from './exchange';
2
+ export * from './types';
3
+ export * from './constants';
4
+ export * from './config';
@@ -0,0 +1,16 @@
1
+ import { Coin, CoinAmount, SecondaryFee } from '../types';
2
+ export declare class Fees {
3
+ private secondaryFees;
4
+ private amount;
5
+ constructor(secondaryFees: SecondaryFee[], token: Coin);
6
+ get token(): Coin;
7
+ addAmount(amount: CoinAmount<Coin>): void;
8
+ amountWithFeesApplied(): CoinAmount<Coin>;
9
+ amountLessFees(): CoinAmount<Coin>;
10
+ withAmounts(): {
11
+ amount: CoinAmount<Coin>;
12
+ recipient: string;
13
+ basisPoints: number;
14
+ }[];
15
+ private total;
16
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,14 @@
1
+ import { Route } from '@uniswap/v3-sdk';
2
+ import { TradeType, Token } from '@uniswap/sdk-core';
3
+ import { CoinAmount, ERC20 } from '../types';
4
+ export interface Provider {
5
+ send: (method: string, params: any[]) => Promise<string>;
6
+ }
7
+ export type QuoteResult = {
8
+ route: Route<Token, Token>;
9
+ gasEstimate: bigint;
10
+ amountIn: CoinAmount<ERC20>;
11
+ amountOut: CoinAmount<ERC20>;
12
+ tradeType: TradeType;
13
+ };
14
+ export declare function getQuotesForRoutes(provider: Provider, quoterContractAddress: string, routes: Route<Token, Token>[], amountSpecified: CoinAmount<ERC20>, tradeType: TradeType): Promise<QuoteResult[]>;
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,3 @@
1
+ export * from './multicall';
2
+ export * from './router';
3
+ export * from './utils';
@@ -0,0 +1,12 @@
1
+ import { Multicall, UniswapInterfaceMulticall } from '../contracts/types/Multicall';
2
+ type Address = string;
3
+ export type SingleContractCallOptions = {
4
+ gasRequired: number;
5
+ };
6
+ export type MulticallResponse = {
7
+ blockNumber: bigint;
8
+ returnData: UniswapInterfaceMulticall.ResultStructOutput[];
9
+ };
10
+ export declare function multicallSingleCallDataMultipleContracts(multicallContract: Multicall, functionName: string, addresses: Address[]): Promise<MulticallResponse>;
11
+ export declare function multicallMultipleCallDataSingContract(multicallContract: Multicall, calldata: string[], address: Address, options?: SingleContractCallOptions): Promise<MulticallResponse>;
12
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,13 @@
1
+ import { Coin, CoinAmount, ERC20, Native } from '../types';
2
+ export declare const canUnwrapToken: (token: Coin) => token is Native;
3
+ export declare class NativeTokenService {
4
+ readonly nativeToken: Native;
5
+ readonly wrappedToken: ERC20;
6
+ constructor(nativeToken: Native, wrappedToken: ERC20);
7
+ wrapAmount(amount: CoinAmount<Native>): CoinAmount<ERC20>;
8
+ unwrapAmount(amount: CoinAmount<ERC20>): CoinAmount<Coin>;
9
+ maybeWrapToken(token: Coin): ERC20;
10
+ maybeWrapAmount(amount: CoinAmount<Coin>): CoinAmount<ERC20>;
11
+ private isWrappedNative;
12
+ isWrapOrUnwrap(tokenIn: Coin, tokenOut: Coin): boolean;
13
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,9 @@
1
+ import { FeeAmount } from '@uniswap/v3-sdk';
2
+ import { ERC20Pair } from './generateERC20Pairs';
3
+ export declare function computePoolAddress({ factoryAddress, erc20Pair, fee, initCodeHashManualOverride, }: {
4
+ factoryAddress: string;
5
+ erc20Pair: ERC20Pair;
6
+ fee: FeeAmount;
7
+ initCodeHashManualOverride?: string;
8
+ }): string;
9
+ export declare const ensureCorrectERC20AddressOrder: (erc20Pair: ERC20Pair) => ERC20Pair;
@@ -0,0 +1,14 @@
1
+ import { Pool } from '@uniswap/v3-sdk';
2
+ import { ERC20 } from '../../types';
3
+ import { ERC20Pair } from './generateERC20Pairs';
4
+ import { Multicall } from '../../contracts/types';
5
+ export type Slot0 = {
6
+ sqrtPriceX96: bigint;
7
+ tick: number;
8
+ observationIndex: number;
9
+ observationCardinality: number;
10
+ observationCardinalityNext: number;
11
+ feeProtocol: number;
12
+ unlocked: boolean;
13
+ };
14
+ export declare const fetchValidPools: (multicallContract: Multicall, erc20Pair: ERC20Pair, commonRoutingERC20s: ERC20[], factoryAddress: string) => Promise<Pool[]>;
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,7 @@
1
+ import { ERC20 } from '../../types';
2
+ export type Provider = {
3
+ chainId: number;
4
+ };
5
+ export type ERC20Pairs = ERC20Pair[];
6
+ export type ERC20Pair = [ERC20, ERC20];
7
+ export declare const generateERC20Pairs: (erc20Pair: ERC20Pair, commonRoutingERC20s: ERC20[]) => ERC20Pairs;
@@ -0,0 +1,11 @@
1
+ import { FeeAmount } from '@uniswap/v3-sdk';
2
+ import { ERC20 } from '../../types';
3
+ import { ERC20Pair } from './generateERC20Pairs';
4
+ type PoolIDs = PoolID[];
5
+ type PoolID = {
6
+ erc20Pair: ERC20Pair;
7
+ fee: FeeAmount;
8
+ poolAddress: string;
9
+ };
10
+ export declare const generatePossiblePoolsFromERC20Pair: (erc20Pair: ERC20Pair, commonRoutingERC20s: ERC20[], factoryAddress: string) => PoolIDs;
11
+ export {};
@@ -0,0 +1,24 @@
1
+ import { Token, TradeType } from '@uniswap/sdk-core';
2
+ import { Pool, Route } from '@uniswap/v3-sdk';
3
+ import { JsonRpcProvider } from 'ethers';
4
+ import { CoinAmount, ERC20 } from '../types';
5
+ import { QuoteResult } from './getQuotesForRoutes';
6
+ import type { Multicall } from '../contracts/types';
7
+ export type RoutingContracts = {
8
+ multicall: string;
9
+ coreFactory: string;
10
+ quoter: string;
11
+ };
12
+ export declare class Router {
13
+ provider: JsonRpcProvider;
14
+ multicallContract: Multicall;
15
+ routingTokens: ERC20[];
16
+ routingContracts: RoutingContracts;
17
+ constructor(provider: JsonRpcProvider, multicallContract: Multicall, routingTokens: ERC20[], routingContracts: RoutingContracts);
18
+ findOptimalRoute(amountSpecified: CoinAmount<ERC20>, otherToken: ERC20, tradeType: TradeType, maxHops?: number): Promise<QuoteResult>;
19
+ private getBestQuoteFromRoutes;
20
+ private bestQuoteForAmountIn;
21
+ private bestQuoteForAmountOut;
22
+ private determineERC20InAndERC20Out;
23
+ }
24
+ export declare const generateAllAcyclicPaths: (tokenIn: ERC20, tokenOut: ERC20, pools: Pool[], maxHops: number, currentRoute?: Pool[], routes?: Route<Token, Token>[], startTokenIn?: ERC20) => Route<Token, Token>[];
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,25 @@
1
+ import { TradeType } from '@uniswap/sdk-core';
2
+ import { JsonRpcProvider, TransactionRequest } from 'ethers';
3
+ import { CoinAmount, Coin, ERC20, Native, SecondaryFee, TransactionDetails } from '../../types';
4
+ type PreparedApproval = {
5
+ spender: string;
6
+ amount: CoinAmount<ERC20>;
7
+ };
8
+ export declare const prepareApproval: (tradeType: TradeType, userSpecifiedAmount: CoinAmount<Coin>, quotedAmountWithSlippage: CoinAmount<Coin>, contracts: {
9
+ routerAddress: string;
10
+ secondaryFeeAddress: string;
11
+ }, secondaryFees: SecondaryFee[]) => PreparedApproval | null;
12
+ /**
13
+ * Get an unsigned approval transaction if needed
14
+ *
15
+ * @param provider The provider to use for the call
16
+ * @param ownerAddress The address of the owner of the token
17
+ * @param tokenAddress The address of the token to approve
18
+ * @param tokenAmount The amount of the token to approve
19
+ * @param spenderAddress The address of the spender
20
+ * @returns The unsigned ERC20 approve transaction, or null if no approval is needed
21
+ */
22
+ export declare const getApproveTransaction: (provider: JsonRpcProvider, ownerAddress: string, tokenAmount: CoinAmount<ERC20>, spenderAddress: string) => Promise<TransactionRequest | null>;
23
+ export declare function getApproveGasEstimate(provider: JsonRpcProvider, ownerAddress: string, spenderAddress: string, tokenAddress: string): Promise<bigint>;
24
+ export declare const getApproval: (provider: JsonRpcProvider, ownerAddress: string, preparedApproval: PreparedApproval, gasPrice: CoinAmount<Native> | null) => Promise<TransactionDetails | null>;
25
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,18 @@
1
+ import { JsonRpcProvider } from 'ethers';
2
+ import { CoinAmount, Native } from '../../types';
3
+ /**
4
+ * Fetch the current gas price estimate. Supports both EIP-1559 and non-EIP1559 chains
5
+ * @param {JsonRpcProvider} provider - The JSON RPC provider used to fetch fee data
6
+ * @param {Native} nativeToken - The native token of the chain. Gas prices will be denominated in this token
7
+ * @returns {CoinAmount<Native> | null} - The gas price in the smallest denomination of the chain's currency,
8
+ * or null if no gas price is available
9
+ */
10
+ export declare const fetchGasPrice: (provider: JsonRpcProvider, nativeToken: Native) => Promise<CoinAmount<Native> | null>;
11
+ /**
12
+ * Calculate the gas fee from the gas price and gas units used for the transaction
13
+ *
14
+ * @param {CoinAmount<Native>} gasPrice - The price of gas
15
+ * @param {BigNumber} gasEstimate - The total gas units that will be used for the transaction
16
+ * @returns - The cost of the transaction in the gas token's smallest denomination (e.g. WEI)
17
+ */
18
+ export declare const calculateGasFee: (hasSecondaryFees: boolean, gasPrice: CoinAmount<Native>, gasEstimate: bigint) => CoinAmount<Native>;
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,13 @@
1
+ import { TradeType } from '@uniswap/sdk-core';
2
+ import { Fees } from '../fees';
3
+ import { QuoteResult } from '../getQuotesForRoutes';
4
+ import { NativeTokenService } from '../nativeTokenService';
5
+ import { Coin, CoinAmount, ERC20 } from '../../types';
6
+ export declare function getQuoteAmountFromTradeType(routerQuote: QuoteResult): CoinAmount<ERC20>;
7
+ export declare function applySlippage(tradeType: TradeType, amount: bigint, slippage: number): bigint;
8
+ export declare const prepareUserQuote: (nativeTokenService: NativeTokenService, routerQuote: QuoteResult, slippage: number, tokenOfQuotedAmount: Coin) => {
9
+ quotedAmount: CoinAmount<Coin>;
10
+ quotedAmountWithMaxSlippage: CoinAmount<Coin>;
11
+ };
12
+ export declare function getOurQuoteReqAmount(amountSpecified: CoinAmount<Coin>, // the amount specified by the user, either exactIn or exactOut
13
+ fees: Fees, tradeType: TradeType, nativeTokenService: NativeTokenService): CoinAmount<ERC20>;
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,2 @@
1
+ import { Percent } from '@uniswap/sdk-core';
2
+ export declare const slippageToFraction: (slippage: number) => Percent;
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,16 @@
1
+ import { Fees } from '../fees';
2
+ import { QuoteResult } from '../getQuotesForRoutes';
3
+ import { NativeTokenService } from '../nativeTokenService';
4
+ import { Coin, CoinAmount, Native, SecondaryFee, TransactionDetails } from '../../types';
5
+ export declare function getSwap(tokenIn: Coin, tokenOut: Coin, adjustedQuote: QuoteResult, fromAddress: string, slippage: number, deadline: number, routerContractAddress: string, secondaryFeesContractAddress: string, gasPrice: CoinAmount<Native> | null, secondaryFees: SecondaryFee[]): TransactionDetails;
6
+ /**
7
+ * adjustQuoteWithFees adjusts the amountIn of the quote to account for fees
8
+ * EXACT_OUTPUT swaps will have the fees added to the amountIn if there are fees specified
9
+ * EXACT_INPUT swaps will have amountIn set to the user-specified amount
10
+ * @param ourQuote The quote from calling the Quoter contract
11
+ * @param amountSpecified The user-specified amount for the swap (EXACT...)
12
+ * @param fees The fees applied to the swap
13
+ * @param tokenWrapper Helper class for the native token and associated ERC20
14
+ * @returns {QuoteResult} The adjusted quote
15
+ */
16
+ export declare function adjustQuoteWithFees(ourQuote: QuoteResult, amountSpecified: CoinAmount<Coin>, fees: Fees, nativeTokenService: NativeTokenService): QuoteResult;
@@ -0,0 +1 @@
1
+ export {};