@uniswap/universal-router-sdk 2.0.2 → 2.0.4-beta.1
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/README.md +1 -60
- package/dist/entities/Command.d.ts +1 -3
- package/dist/entities/protocols/index.d.ts +0 -2
- package/dist/entities/protocols/uniswap.d.ts +4 -1
- package/dist/index.d.ts +1 -0
- package/dist/test/utils/uniswapData.d.ts +23 -0
- package/dist/universal-router-sdk.cjs.development.js +184 -113
- package/dist/universal-router-sdk.cjs.development.js.map +1 -1
- package/dist/universal-router-sdk.cjs.production.min.js +1 -1
- package/dist/universal-router-sdk.cjs.production.min.js.map +1 -1
- package/dist/universal-router-sdk.esm.js +188 -116
- package/dist/universal-router-sdk.esm.js.map +1 -1
- package/dist/utils/constants.d.ts +1 -3
- package/dist/utils/routerCommands.d.ts +1 -3
- package/dist/utils/routerTradeAdapter.d.ts +57 -0
- package/package.json +74 -39
- package/dist/entities/protocols/unwrapSTETH.d.ts +0 -10
- package/dist/entities/protocols/wrapSTETH.d.ts +0 -13
|
@@ -1,13 +1,11 @@
|
|
|
1
1
|
import { BigNumber } from 'ethers';
|
|
2
|
-
export declare const NOT_SUPPORTED_ON_CHAIN = "0x0000000000000000000000000000000000000000";
|
|
3
2
|
export declare const UNIVERSAL_ROUTER_ADDRESS: (chainId: number) => string;
|
|
4
3
|
export declare const UNIVERSAL_ROUTER_CREATION_BLOCK: (chainId: number) => number;
|
|
5
4
|
export declare const WETH_ADDRESS: (chainId: number) => string;
|
|
6
|
-
export declare const STETH_ADDRESS: (chainId: number) => string;
|
|
7
|
-
export declare const WSTETH_ADDRESS: (chainId: number) => string;
|
|
8
5
|
export declare const PERMIT2_ADDRESS = "0x000000000022D473030F116dDEE9F6B43aC78BA3";
|
|
9
6
|
export declare const CONTRACT_BALANCE: BigNumber;
|
|
10
7
|
export declare const ETH_ADDRESS = "0x0000000000000000000000000000000000000000";
|
|
8
|
+
export declare const E_ETH_ADDRESS = "0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee";
|
|
11
9
|
export declare const ZERO_ADDRESS = "0x0000000000000000000000000000000000000000";
|
|
12
10
|
export declare const MAX_UINT256: BigNumber;
|
|
13
11
|
export declare const MAX_UINT160: BigNumber;
|
|
@@ -34,9 +34,7 @@ export declare enum CommandType {
|
|
|
34
34
|
ELEMENT_MARKET = 30,
|
|
35
35
|
SEAPORT_V1_4 = 32,
|
|
36
36
|
EXECUTE_SUB_PLAN = 33,
|
|
37
|
-
APPROVE_ERC20 = 34
|
|
38
|
-
WRAP_STETH = 35,
|
|
39
|
-
UNWRAP_STETH = 36
|
|
37
|
+
APPROVE_ERC20 = 34
|
|
40
38
|
}
|
|
41
39
|
export declare class RoutePlanner {
|
|
42
40
|
commands: string;
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { Trade as RouterTrade } from '@uniswap/router-sdk';
|
|
2
|
+
import { Currency, TradeType } from '@uniswap/sdk-core';
|
|
3
|
+
export declare type TokenInRoute = {
|
|
4
|
+
address: string;
|
|
5
|
+
chainId: number;
|
|
6
|
+
symbol: string;
|
|
7
|
+
decimals: string;
|
|
8
|
+
name?: string;
|
|
9
|
+
buyFeeBps?: string;
|
|
10
|
+
sellFeeBps?: string;
|
|
11
|
+
};
|
|
12
|
+
export declare enum PoolType {
|
|
13
|
+
V2Pool = "v2-pool",
|
|
14
|
+
V3Pool = "v3-pool"
|
|
15
|
+
}
|
|
16
|
+
export declare type V2Reserve = {
|
|
17
|
+
token: TokenInRoute;
|
|
18
|
+
quotient: string;
|
|
19
|
+
};
|
|
20
|
+
export declare type V2PoolInRoute = {
|
|
21
|
+
type: PoolType.V2Pool;
|
|
22
|
+
address?: string;
|
|
23
|
+
tokenIn: TokenInRoute;
|
|
24
|
+
tokenOut: TokenInRoute;
|
|
25
|
+
reserve0: V2Reserve;
|
|
26
|
+
reserve1: V2Reserve;
|
|
27
|
+
amountIn?: string;
|
|
28
|
+
amountOut?: string;
|
|
29
|
+
};
|
|
30
|
+
export declare type V3PoolInRoute = {
|
|
31
|
+
type: PoolType.V3Pool;
|
|
32
|
+
address?: string;
|
|
33
|
+
tokenIn: TokenInRoute;
|
|
34
|
+
tokenOut: TokenInRoute;
|
|
35
|
+
sqrtRatioX96: string;
|
|
36
|
+
liquidity: string;
|
|
37
|
+
tickCurrent: string;
|
|
38
|
+
fee: string;
|
|
39
|
+
amountIn?: string;
|
|
40
|
+
amountOut?: string;
|
|
41
|
+
};
|
|
42
|
+
export declare type PartialClassicQuote = {
|
|
43
|
+
tokenIn: string;
|
|
44
|
+
tokenOut: string;
|
|
45
|
+
tradeType: TradeType;
|
|
46
|
+
route: Array<(V3PoolInRoute | V2PoolInRoute)[]>;
|
|
47
|
+
};
|
|
48
|
+
export declare const isNativeCurrency: (address: string) => boolean;
|
|
49
|
+
export declare class RouterTradeAdapter {
|
|
50
|
+
static fromClassicQuote(quote: PartialClassicQuote): RouterTrade<Currency, Currency, TradeType>;
|
|
51
|
+
private static toCurrency;
|
|
52
|
+
private static toPoolOrPair;
|
|
53
|
+
private static toToken;
|
|
54
|
+
private static toPool;
|
|
55
|
+
private static toPair;
|
|
56
|
+
private static isVersionedRoute;
|
|
57
|
+
}
|
package/package.json
CHANGED
|
@@ -1,7 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@uniswap/universal-router-sdk",
|
|
3
|
-
"version": "2.0.2",
|
|
4
3
|
"description": "sdk for integrating with the Universal Router contracts",
|
|
4
|
+
"repository": "https://github.com/Uniswap/sdks.git",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"uniswap",
|
|
7
|
+
"ethereum"
|
|
8
|
+
],
|
|
9
|
+
"license": "MIT",
|
|
5
10
|
"main": "dist/index.js",
|
|
6
11
|
"typings": "dist/index.d.ts",
|
|
7
12
|
"files": [
|
|
@@ -10,60 +15,90 @@
|
|
|
10
15
|
"engines": {
|
|
11
16
|
"node": ">=14"
|
|
12
17
|
},
|
|
13
|
-
"publishConfig": {
|
|
14
|
-
"access": "public"
|
|
15
|
-
},
|
|
16
18
|
"scripts": {
|
|
17
|
-
"test:all": "yarn test:hardhat && yarn test:forge",
|
|
18
|
-
"test:hardhat": "env TS_NODE_COMPILER_OPTIONS='{\"module\": \"commonjs\" }' hardhat test",
|
|
19
|
-
"test:forge": "forge test",
|
|
20
|
-
"install:ur": "cd node_modules/@uniswap/universal-router && forge install",
|
|
21
19
|
"build": "tsdx build",
|
|
22
|
-
"
|
|
20
|
+
"docs": "typedoc",
|
|
23
21
|
"forge:fix": "forge fmt",
|
|
22
|
+
"install:ur": "cd node_modules/@uniswap/universal-router && forge install",
|
|
23
|
+
"lint": "yarn prettier",
|
|
24
24
|
"lint:fix": "yarn prettier:fix && yarn forge:fix",
|
|
25
25
|
"prettier": "prettier --check '**/*.ts' && prettier --check '**/*.json'",
|
|
26
|
-
"
|
|
26
|
+
"prettier:fix": "prettier --write '**/*.ts' && prettier --write '**/*.json'",
|
|
27
|
+
"release": "semantic-release",
|
|
28
|
+
"test": "yarn test:hardhat && yarn test:forge",
|
|
29
|
+
"test:forge": "yarn install:ur && forge test",
|
|
30
|
+
"test:hardhat": "env TS_NODE_COMPILER_OPTIONS='{\"module\": \"commonjs\" }' hardhat test"
|
|
27
31
|
},
|
|
28
|
-
"
|
|
29
|
-
|
|
30
|
-
"
|
|
31
|
-
"
|
|
32
|
-
"
|
|
33
|
-
"
|
|
32
|
+
"dependencies": {
|
|
33
|
+
"@uniswap/permit2-sdk": "^1.2.0",
|
|
34
|
+
"@uniswap/router-sdk": "^1.9.0",
|
|
35
|
+
"@uniswap/sdk-core": "^4.2.0",
|
|
36
|
+
"@uniswap/universal-router": "1.6.0",
|
|
37
|
+
"@uniswap/v2-sdk": "^4.3.0",
|
|
38
|
+
"@uniswap/v3-sdk": "^3.11.0",
|
|
39
|
+
"bignumber.js": "^9.0.2",
|
|
40
|
+
"ethers": "^5.7.0"
|
|
34
41
|
},
|
|
35
42
|
"devDependencies": {
|
|
36
|
-
"@types/chai": "^4.
|
|
37
|
-
"@types/mocha": "^
|
|
38
|
-
"@types/node": "^
|
|
43
|
+
"@types/chai": "^4.3.3",
|
|
44
|
+
"@types/mocha": "^9.1.1",
|
|
45
|
+
"@types/node": "^18.7.16",
|
|
39
46
|
"@types/node-fetch": "^2.6.2",
|
|
40
|
-
"chai": "^4.3.
|
|
47
|
+
"chai": "^4.3.6",
|
|
41
48
|
"dotenv": "^16.0.3",
|
|
42
|
-
"eslint-plugin-prettier": "^3.4.
|
|
43
|
-
"hardhat": "^2.
|
|
44
|
-
"prettier": "^2.
|
|
45
|
-
"ts-node": "^10.
|
|
49
|
+
"eslint-plugin-prettier": "^3.4.1",
|
|
50
|
+
"hardhat": "^2.14.0",
|
|
51
|
+
"prettier": "^2.4.1",
|
|
52
|
+
"ts-node": "^10.9.1",
|
|
46
53
|
"tsdx": "^0.14.1",
|
|
47
54
|
"tslib": "^2.3.0",
|
|
48
55
|
"typedoc": "^0.21.2",
|
|
49
56
|
"typescript": "^4.3.3"
|
|
50
57
|
},
|
|
51
|
-
"
|
|
52
|
-
"
|
|
53
|
-
"
|
|
54
|
-
"
|
|
55
|
-
"
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
"
|
|
59
|
-
"ethers": "^5.3.1"
|
|
58
|
+
"prettier": {
|
|
59
|
+
"printWidth": 120,
|
|
60
|
+
"semi": false,
|
|
61
|
+
"singleQuote": true,
|
|
62
|
+
"trailingComma": "es5"
|
|
63
|
+
},
|
|
64
|
+
"publishConfig": {
|
|
65
|
+
"access": "public"
|
|
60
66
|
},
|
|
61
|
-
"
|
|
62
|
-
"
|
|
63
|
-
"
|
|
67
|
+
"release": {
|
|
68
|
+
"extends": "semantic-release-monorepo",
|
|
69
|
+
"branches": [
|
|
70
|
+
{
|
|
71
|
+
"name": "main",
|
|
72
|
+
"prerelease": false
|
|
73
|
+
},
|
|
74
|
+
{
|
|
75
|
+
"name": "beta",
|
|
76
|
+
"prerelease": true
|
|
77
|
+
}
|
|
78
|
+
],
|
|
79
|
+
"plugins": [
|
|
80
|
+
[
|
|
81
|
+
"@semantic-release/commit-analyzer",
|
|
82
|
+
{
|
|
83
|
+
"preset": "angular",
|
|
84
|
+
"releaseRules": "../../publishing/release-rules.cjs"
|
|
85
|
+
}
|
|
86
|
+
],
|
|
87
|
+
"@semantic-release/release-notes-generator",
|
|
88
|
+
"@semantic-release/npm",
|
|
89
|
+
"@semantic-release/github",
|
|
90
|
+
[
|
|
91
|
+
"@semantic-release/exec",
|
|
92
|
+
{
|
|
93
|
+
"successCmd": "git restore yarn.lock && yarn",
|
|
94
|
+
"failCmd": "git restore yarn.lock && yarn",
|
|
95
|
+
"execCwd": "../.."
|
|
96
|
+
}
|
|
97
|
+
]
|
|
98
|
+
]
|
|
64
99
|
},
|
|
65
|
-
"
|
|
66
|
-
"
|
|
100
|
+
"installConfig": {
|
|
101
|
+
"hoistingLimits": "workspaces"
|
|
67
102
|
},
|
|
68
|
-
"
|
|
103
|
+
"version": "2.0.4-beta.1"
|
|
69
104
|
}
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { BigNumberish } from 'ethers';
|
|
2
|
-
import { RoutePlanner } from '../../utils/routerCommands';
|
|
3
|
-
import { Command, RouterTradeType, TradeConfig } from '../Command';
|
|
4
|
-
export declare class UnwrapSTETH implements Command {
|
|
5
|
-
readonly tradeType: RouterTradeType;
|
|
6
|
-
readonly recipient: string;
|
|
7
|
-
readonly amountMinimum: BigNumberish;
|
|
8
|
-
constructor(recipient: string, amountMinimum: BigNumberish, chainId: number);
|
|
9
|
-
encode(planner: RoutePlanner, _: TradeConfig): void;
|
|
10
|
-
}
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { BigNumberish } from 'ethers';
|
|
2
|
-
import { RoutePlanner } from '../../utils/routerCommands';
|
|
3
|
-
import { Permit2Permit } from '../../utils/inputTokens';
|
|
4
|
-
import { Command, RouterTradeType, TradeConfig } from '../Command';
|
|
5
|
-
export declare class WrapSTETH implements Command {
|
|
6
|
-
readonly tradeType: RouterTradeType;
|
|
7
|
-
readonly permit2Data: Permit2Permit;
|
|
8
|
-
readonly stethAddress: string;
|
|
9
|
-
readonly amount: BigNumberish;
|
|
10
|
-
readonly wrapAmount: BigNumberish;
|
|
11
|
-
constructor(amount: BigNumberish, chainId: number, permit2?: Permit2Permit, wrapAmount?: BigNumberish);
|
|
12
|
-
encode(planner: RoutePlanner, _: TradeConfig): void;
|
|
13
|
-
}
|