@uniswap/universal-router-sdk 5.2.0 → 5.3.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/README.md +81 -0
- package/dist/cjs/src/index.d.ts +3 -0
- package/dist/cjs/src/index.js +6 -1
- package/dist/cjs/src/index.js.map +1 -1
- package/dist/cjs/src/swapRouter.d.ts +17 -1
- package/dist/cjs/src/swapRouter.js +83 -8
- package/dist/cjs/src/swapRouter.js.map +1 -1
- package/dist/cjs/src/types/encodeSwaps.d.ts +149 -0
- package/dist/cjs/src/types/encodeSwaps.js +3 -0
- package/dist/cjs/src/types/encodeSwaps.js.map +1 -0
- package/dist/cjs/src/utils/computeEncodeSwapsAmounts.d.ts +8 -0
- package/dist/cjs/src/utils/computeEncodeSwapsAmounts.js +47 -0
- package/dist/cjs/src/utils/computeEncodeSwapsAmounts.js.map +1 -0
- package/dist/cjs/src/utils/encodeSwapStep.d.ts +4 -0
- package/dist/cjs/src/utils/encodeSwapStep.js +61 -0
- package/dist/cjs/src/utils/encodeSwapStep.js.map +1 -0
- package/dist/cjs/src/utils/encodeV4Action.d.ts +8 -0
- package/dist/cjs/src/utils/encodeV4Action.js +97 -0
- package/dist/cjs/src/utils/encodeV4Action.js.map +1 -0
- package/dist/cjs/src/utils/normalizeEncodeSwapsSpec.d.ts +2 -0
- package/dist/cjs/src/utils/normalizeEncodeSwapsSpec.js +18 -0
- package/dist/cjs/src/utils/normalizeEncodeSwapsSpec.js.map +1 -0
- package/dist/cjs/src/utils/validateEncodeSwaps.d.ts +2 -0
- package/dist/cjs/src/utils/validateEncodeSwaps.js +135 -0
- package/dist/cjs/src/utils/validateEncodeSwaps.js.map +1 -0
- package/dist/esm/src/index.d.ts +3 -0
- package/dist/esm/src/index.js +3 -0
- package/dist/esm/src/index.js.map +1 -1
- package/dist/esm/src/swapRouter.d.ts +17 -1
- package/dist/esm/src/swapRouter.js +85 -10
- package/dist/esm/src/swapRouter.js.map +1 -1
- package/dist/esm/src/types/encodeSwaps.d.ts +149 -0
- package/dist/esm/src/types/encodeSwaps.js +2 -0
- package/dist/esm/src/types/encodeSwaps.js.map +1 -0
- package/dist/esm/src/utils/computeEncodeSwapsAmounts.d.ts +8 -0
- package/dist/esm/src/utils/computeEncodeSwapsAmounts.js +43 -0
- package/dist/esm/src/utils/computeEncodeSwapsAmounts.js.map +1 -0
- package/dist/esm/src/utils/encodeSwapStep.d.ts +4 -0
- package/dist/esm/src/utils/encodeSwapStep.js +57 -0
- package/dist/esm/src/utils/encodeSwapStep.js.map +1 -0
- package/dist/esm/src/utils/encodeV4Action.d.ts +8 -0
- package/dist/esm/src/utils/encodeV4Action.js +92 -0
- package/dist/esm/src/utils/encodeV4Action.js.map +1 -0
- package/dist/esm/src/utils/normalizeEncodeSwapsSpec.d.ts +2 -0
- package/dist/esm/src/utils/normalizeEncodeSwapsSpec.js +14 -0
- package/dist/esm/src/utils/normalizeEncodeSwapsSpec.js.map +1 -0
- package/dist/esm/src/utils/validateEncodeSwaps.d.ts +2 -0
- package/dist/esm/src/utils/validateEncodeSwaps.js +130 -0
- package/dist/esm/src/utils/validateEncodeSwaps.js.map +1 -0
- package/dist/types/src/index.d.ts +3 -0
- package/dist/types/src/swapRouter.d.ts +17 -1
- package/dist/types/src/types/encodeSwaps.d.ts +149 -0
- package/dist/types/src/utils/computeEncodeSwapsAmounts.d.ts +8 -0
- package/dist/types/src/utils/encodeSwapStep.d.ts +4 -0
- package/dist/types/src/utils/encodeV4Action.d.ts +8 -0
- package/dist/types/src/utils/normalizeEncodeSwapsSpec.d.ts +2 -0
- package/dist/types/src/utils/validateEncodeSwaps.d.ts +2 -0
- package/package.json +1 -1
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
import { BigNumberish } from 'ethers';
|
|
2
|
+
import { Currency, CurrencyAmount, Percent, TradeType } from '@uniswap/sdk-core';
|
|
3
|
+
import { type PathKey, type PoolKey } from '@uniswap/v4-sdk';
|
|
4
|
+
import { TokenTransferMode } from '../entities/actions/uniswap';
|
|
5
|
+
import { Permit2Permit } from '../utils/inputTokens';
|
|
6
|
+
import { UniversalRouterVersion } from '../utils/constants';
|
|
7
|
+
export type { PathKey, PoolKey };
|
|
8
|
+
export type Fee = {
|
|
9
|
+
kind: 'portion';
|
|
10
|
+
recipient: string;
|
|
11
|
+
fee: Percent;
|
|
12
|
+
} | {
|
|
13
|
+
kind: 'flat';
|
|
14
|
+
recipient: string;
|
|
15
|
+
amount: BigNumberish;
|
|
16
|
+
};
|
|
17
|
+
export type SwapSpecification = {
|
|
18
|
+
tradeType: TradeType;
|
|
19
|
+
routing: {
|
|
20
|
+
inputToken: Currency;
|
|
21
|
+
outputToken: Currency;
|
|
22
|
+
amount: CurrencyAmount<Currency>;
|
|
23
|
+
quote: CurrencyAmount<Currency>;
|
|
24
|
+
};
|
|
25
|
+
slippageTolerance: Percent;
|
|
26
|
+
recipient?: string;
|
|
27
|
+
fee?: Fee;
|
|
28
|
+
tokenTransferMode?: TokenTransferMode;
|
|
29
|
+
permit?: Permit2Permit;
|
|
30
|
+
chainId?: number;
|
|
31
|
+
deadline?: BigNumberish;
|
|
32
|
+
urVersion?: UniversalRouterVersion;
|
|
33
|
+
safeMode?: boolean;
|
|
34
|
+
};
|
|
35
|
+
export type NormalizedSwapSpecification = Omit<SwapSpecification, 'recipient' | 'tokenTransferMode' | 'urVersion' | 'safeMode'> & {
|
|
36
|
+
recipient: string;
|
|
37
|
+
tokenTransferMode: TokenTransferMode;
|
|
38
|
+
urVersion: UniversalRouterVersion;
|
|
39
|
+
safeMode: boolean;
|
|
40
|
+
};
|
|
41
|
+
export type V2SwapExactIn = {
|
|
42
|
+
type: 'V2_SWAP_EXACT_IN';
|
|
43
|
+
recipient: string;
|
|
44
|
+
amountIn: BigNumberish;
|
|
45
|
+
amountOutMin: BigNumberish;
|
|
46
|
+
path: string[];
|
|
47
|
+
minHopPriceX36?: BigNumberish[];
|
|
48
|
+
};
|
|
49
|
+
export type V2SwapExactOut = {
|
|
50
|
+
type: 'V2_SWAP_EXACT_OUT';
|
|
51
|
+
recipient: string;
|
|
52
|
+
amountOut: BigNumberish;
|
|
53
|
+
amountInMax: BigNumberish;
|
|
54
|
+
path: string[];
|
|
55
|
+
minHopPriceX36?: BigNumberish[];
|
|
56
|
+
};
|
|
57
|
+
export type V3SwapExactIn = {
|
|
58
|
+
type: 'V3_SWAP_EXACT_IN';
|
|
59
|
+
recipient: string;
|
|
60
|
+
amountIn: BigNumberish;
|
|
61
|
+
amountOutMin: BigNumberish;
|
|
62
|
+
path: string;
|
|
63
|
+
minHopPriceX36?: BigNumberish[];
|
|
64
|
+
};
|
|
65
|
+
export type V3SwapExactOut = {
|
|
66
|
+
type: 'V3_SWAP_EXACT_OUT';
|
|
67
|
+
recipient: string;
|
|
68
|
+
amountOut: BigNumberish;
|
|
69
|
+
amountInMax: BigNumberish;
|
|
70
|
+
path: string;
|
|
71
|
+
minHopPriceX36?: BigNumberish[];
|
|
72
|
+
};
|
|
73
|
+
export type V4Swap = {
|
|
74
|
+
type: 'V4_SWAP';
|
|
75
|
+
v4Actions: V4Action[];
|
|
76
|
+
};
|
|
77
|
+
export type WrapEth = {
|
|
78
|
+
type: 'WRAP_ETH';
|
|
79
|
+
recipient: string;
|
|
80
|
+
amount: BigNumberish;
|
|
81
|
+
};
|
|
82
|
+
export type UnwrapWeth = {
|
|
83
|
+
type: 'UNWRAP_WETH';
|
|
84
|
+
recipient: string;
|
|
85
|
+
amountMin: BigNumberish;
|
|
86
|
+
};
|
|
87
|
+
export type SwapStep = V2SwapExactIn | V2SwapExactOut | V3SwapExactIn | V3SwapExactOut | V4Swap | WrapEth | UnwrapWeth;
|
|
88
|
+
export type V4SwapExactIn = {
|
|
89
|
+
action: 'SWAP_EXACT_IN';
|
|
90
|
+
currencyIn: string;
|
|
91
|
+
path: PathKey[];
|
|
92
|
+
amountIn: BigNumberish;
|
|
93
|
+
amountOutMinimum: BigNumberish;
|
|
94
|
+
minHopPriceX36?: BigNumberish[];
|
|
95
|
+
};
|
|
96
|
+
export type V4SwapExactInSingle = {
|
|
97
|
+
action: 'SWAP_EXACT_IN_SINGLE';
|
|
98
|
+
poolKey: PoolKey;
|
|
99
|
+
zeroForOne: boolean;
|
|
100
|
+
amountIn: BigNumberish;
|
|
101
|
+
amountOutMinimum: BigNumberish;
|
|
102
|
+
minHopPriceX36?: BigNumberish;
|
|
103
|
+
hookData: string;
|
|
104
|
+
};
|
|
105
|
+
export type V4SwapExactOut = {
|
|
106
|
+
action: 'SWAP_EXACT_OUT';
|
|
107
|
+
currencyOut: string;
|
|
108
|
+
path: PathKey[];
|
|
109
|
+
amountOut: BigNumberish;
|
|
110
|
+
amountInMaximum: BigNumberish;
|
|
111
|
+
minHopPriceX36?: BigNumberish[];
|
|
112
|
+
};
|
|
113
|
+
export type V4SwapExactOutSingle = {
|
|
114
|
+
action: 'SWAP_EXACT_OUT_SINGLE';
|
|
115
|
+
poolKey: PoolKey;
|
|
116
|
+
zeroForOne: boolean;
|
|
117
|
+
amountOut: BigNumberish;
|
|
118
|
+
amountInMaximum: BigNumberish;
|
|
119
|
+
minHopPriceX36?: BigNumberish;
|
|
120
|
+
hookData: string;
|
|
121
|
+
};
|
|
122
|
+
export type V4Settle = {
|
|
123
|
+
action: 'SETTLE';
|
|
124
|
+
currency: string;
|
|
125
|
+
amount: BigNumberish;
|
|
126
|
+
};
|
|
127
|
+
export type V4SettleAll = {
|
|
128
|
+
action: 'SETTLE_ALL';
|
|
129
|
+
currency: string;
|
|
130
|
+
maxAmount: BigNumberish;
|
|
131
|
+
};
|
|
132
|
+
export type V4Take = {
|
|
133
|
+
action: 'TAKE';
|
|
134
|
+
currency: string;
|
|
135
|
+
recipient: string;
|
|
136
|
+
amount: BigNumberish;
|
|
137
|
+
};
|
|
138
|
+
export type V4TakeAll = {
|
|
139
|
+
action: 'TAKE_ALL';
|
|
140
|
+
currency: string;
|
|
141
|
+
minAmount: BigNumberish;
|
|
142
|
+
};
|
|
143
|
+
export type V4TakePortion = {
|
|
144
|
+
action: 'TAKE_PORTION';
|
|
145
|
+
currency: string;
|
|
146
|
+
recipient: string;
|
|
147
|
+
bips: BigNumberish;
|
|
148
|
+
};
|
|
149
|
+
export type V4Action = V4SwapExactIn | V4SwapExactInSingle | V4SwapExactOut | V4SwapExactOutSingle | V4Settle | V4SettleAll | V4Take | V4TakeAll | V4TakePortion;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { BigNumber } from 'ethers';
|
|
2
|
+
import { NormalizedSwapSpecification } from '../types/encodeSwaps';
|
|
3
|
+
export type EncodeSwapsAmounts = {
|
|
4
|
+
exactOrMaxAmountIn: BigNumber;
|
|
5
|
+
grossMinOrExactAmountOut: BigNumber;
|
|
6
|
+
netMinOrExactAmountOut: BigNumber;
|
|
7
|
+
};
|
|
8
|
+
export declare function computeEncodeSwapsAmounts(spec: NormalizedSwapSpecification): EncodeSwapsAmounts;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { UniversalRouterVersion } from './constants';
|
|
2
|
+
import { RoutePlanner } from './routerCommands';
|
|
3
|
+
import { SwapStep } from '../types/encodeSwaps';
|
|
4
|
+
export declare function encodeSwapStep(planner: RoutePlanner, step: SwapStep, urVersion?: UniversalRouterVersion): void;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { Actions, URVersion } from '@uniswap/v4-sdk';
|
|
2
|
+
import { UniversalRouterVersion } from './constants';
|
|
3
|
+
import { V4Action } from '../types/encodeSwaps';
|
|
4
|
+
export declare function toV4URVersion(version?: UniversalRouterVersion): URVersion;
|
|
5
|
+
export declare function encodeV4Action(v4Action: V4Action, urVersion?: UniversalRouterVersion): {
|
|
6
|
+
action: Actions;
|
|
7
|
+
params: any[];
|
|
8
|
+
};
|