@imtbl/dex-sdk 2.2.4-alpha.1 → 2.2.5-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.
- package/dist/browser/index.js +4 -4
- package/dist/node/index.cjs +25 -25
- package/dist/node/index.js +3 -3
- package/dist/types/lib/getQuotesForRoutes.d.ts +13 -2
- package/dist/types/lib/multicall.d.ts +6 -1
- package/dist/types/lib/poolUtils/fetchValidPools.d.ts +2 -1
- package/dist/types/lib/router.d.ts +2 -1
- package/dist/types/lib/router.spec.d.ts +1 -0
- package/dist/types/test/utils.d.ts +1 -0
- package/dist/types/types/index.d.ts +1 -0
- package/package.json +2 -2
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { Route } from '@uniswap/v3-sdk';
|
|
2
|
-
import { TradeType, Token } from '@uniswap/sdk-core';
|
|
2
|
+
import { TradeType, Token, Fraction } from '@uniswap/sdk-core';
|
|
3
|
+
import { Result } from 'ethers';
|
|
3
4
|
import { CoinAmount, ERC20 } from '../types';
|
|
5
|
+
import { BlockTag } from './multicall';
|
|
4
6
|
export interface Provider {
|
|
5
7
|
send: (method: string, params: any[]) => Promise<string>;
|
|
6
8
|
}
|
|
@@ -10,5 +12,14 @@ export type QuoteResult = {
|
|
|
10
12
|
amountIn: CoinAmount<ERC20>;
|
|
11
13
|
amountOut: CoinAmount<ERC20>;
|
|
12
14
|
tradeType: TradeType;
|
|
15
|
+
priceImpact: Fraction;
|
|
13
16
|
};
|
|
14
|
-
export declare function
|
|
17
|
+
export declare function parseQuoteResult(quoteResult: Result, route: Route<Token, Token>, amountSpecified: CoinAmount<ERC20>, tradeType: TradeType): {
|
|
18
|
+
route: Route<Token, Token>;
|
|
19
|
+
amountIn: CoinAmount<ERC20>;
|
|
20
|
+
amountOut: CoinAmount<ERC20>;
|
|
21
|
+
gasEstimate: bigint;
|
|
22
|
+
tradeType: TradeType;
|
|
23
|
+
priceImpact: Fraction;
|
|
24
|
+
};
|
|
25
|
+
export declare function getQuotesForRoutes(provider: Provider, quoterContractAddress: string, routes: Route<Token, Token>[], amountSpecified: CoinAmount<ERC20>, tradeType: TradeType, blockTag: BlockTag): Promise<QuoteResult[]>;
|
|
@@ -1,12 +1,17 @@
|
|
|
1
1
|
import { Multicall, UniswapInterfaceMulticall } from '../contracts/types/Multicall';
|
|
2
2
|
type Address = string;
|
|
3
|
+
export type BlockTag = 'latest' | `0x${string}`;
|
|
3
4
|
export type SingleContractCallOptions = {
|
|
4
5
|
gasRequired: number;
|
|
6
|
+
blockTag: BlockTag;
|
|
7
|
+
};
|
|
8
|
+
export type MulticallOptions = {
|
|
9
|
+
blockTag: BlockTag;
|
|
5
10
|
};
|
|
6
11
|
export type MulticallResponse = {
|
|
7
12
|
blockNumber: bigint;
|
|
8
13
|
returnData: UniswapInterfaceMulticall.ResultStructOutput[];
|
|
9
14
|
};
|
|
10
|
-
export declare function multicallSingleCallDataMultipleContracts(multicallContract: Multicall, functionName: string, addresses: Address[]): Promise<MulticallResponse>;
|
|
15
|
+
export declare function multicallSingleCallDataMultipleContracts(multicallContract: Multicall, functionName: string, addresses: Address[], options?: MulticallOptions): Promise<MulticallResponse>;
|
|
11
16
|
export declare function multicallMultipleCallDataSingContract(multicallContract: Multicall, calldata: string[], address: Address, options?: SingleContractCallOptions): Promise<MulticallResponse>;
|
|
12
17
|
export {};
|
|
@@ -2,6 +2,7 @@ import { Pool } from '@uniswap/v3-sdk';
|
|
|
2
2
|
import { ERC20 } from '../../types';
|
|
3
3
|
import { ERC20Pair } from './generateERC20Pairs';
|
|
4
4
|
import { Multicall } from '../../contracts/types';
|
|
5
|
+
import { BlockTag } from '../multicall';
|
|
5
6
|
export type Slot0 = {
|
|
6
7
|
sqrtPriceX96: bigint;
|
|
7
8
|
tick: number;
|
|
@@ -11,4 +12,4 @@ export type Slot0 = {
|
|
|
11
12
|
feeProtocol: number;
|
|
12
13
|
unlocked: boolean;
|
|
13
14
|
};
|
|
14
|
-
export declare const fetchValidPools: (multicallContract: Multicall, erc20Pair: ERC20Pair, commonRoutingERC20s: ERC20[], factoryAddress: string) => Promise<Pool[]>;
|
|
15
|
+
export declare const fetchValidPools: (multicallContract: Multicall, erc20Pair: ERC20Pair, commonRoutingERC20s: ERC20[], factoryAddress: string, blockTag: BlockTag) => Promise<Pool[]>;
|
|
@@ -4,6 +4,7 @@ import { JsonRpcProvider } from 'ethers';
|
|
|
4
4
|
import { CoinAmount, ERC20 } from '../types';
|
|
5
5
|
import { QuoteResult } from './getQuotesForRoutes';
|
|
6
6
|
import type { Multicall } from '../contracts/types';
|
|
7
|
+
import { BlockTag } from './multicall';
|
|
7
8
|
export type RoutingContracts = {
|
|
8
9
|
multicall: string;
|
|
9
10
|
coreFactory: string;
|
|
@@ -15,7 +16,7 @@ export declare class Router {
|
|
|
15
16
|
routingTokens: ERC20[];
|
|
16
17
|
routingContracts: RoutingContracts;
|
|
17
18
|
constructor(provider: JsonRpcProvider, multicallContract: Multicall, routingTokens: ERC20[], routingContracts: RoutingContracts);
|
|
18
|
-
findOptimalRoute(amountSpecified: CoinAmount<ERC20>, otherToken: ERC20, tradeType: TradeType, maxHops?: number): Promise<QuoteResult>;
|
|
19
|
+
findOptimalRoute(amountSpecified: CoinAmount<ERC20>, otherToken: ERC20, tradeType: TradeType, maxHops?: number, blockTag?: BlockTag): Promise<QuoteResult>;
|
|
19
20
|
private getBestQuoteFromRoutes;
|
|
20
21
|
private bestQuoteForAmountIn;
|
|
21
22
|
private bestQuoteForAmountOut;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -29,6 +29,7 @@ export declare const IMX_TEST_TOKEN: ERC20;
|
|
|
29
29
|
export declare const WIMX_TEST_TOKEN: ERC20;
|
|
30
30
|
export declare const WETH_TEST_TOKEN: ERC20;
|
|
31
31
|
export declare const USDC_TEST_TOKEN: ERC20;
|
|
32
|
+
export declare const USDT_TEST_TOKEN: ERC20;
|
|
32
33
|
export declare const FUN_TEST_TOKEN: ERC20;
|
|
33
34
|
export declare const NATIVE_TEST_TOKEN: Native;
|
|
34
35
|
export declare const nativeTokenService: NativeTokenService;
|
package/package.json
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@imtbl/dex-sdk",
|
|
3
3
|
"description": "DEX Provider package for the Immutable SDK",
|
|
4
|
-
"version": "2.2.
|
|
4
|
+
"version": "2.2.5-alpha.0",
|
|
5
5
|
"author": "Immutable",
|
|
6
6
|
"bugs": "https://github.com/immutable/ts-immutable-sdk/issues",
|
|
7
7
|
"dependencies": {
|
|
8
|
-
"@imtbl/config": "2.2.
|
|
8
|
+
"@imtbl/config": "2.2.5-alpha.0",
|
|
9
9
|
"@uniswap/sdk-core": "^3.0.1",
|
|
10
10
|
"@uniswap/swap-router-contracts": "^1.3.1",
|
|
11
11
|
"@uniswap/v3-sdk": "^3.9.0",
|