@pioneer-platform/uniswap-client 0.0.22 → 0.0.24

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/lib/constants/chainInfo.d.ts +19 -22
  2. package/lib/constants/chainInfo.js +134 -117
  3. package/lib/constants/chains.d.ts +36 -47
  4. package/lib/constants/chains.js +118 -83
  5. package/lib/constants/chains.test.js +22 -25
  6. package/lib/constants/governance.d.ts +8 -0
  7. package/lib/constants/governance.js +24 -0
  8. package/lib/constants/lists.d.ts +12 -0
  9. package/lib/constants/lists.js +64 -0
  10. package/lib/constants/localCurrencies.d.ts +6 -0
  11. package/lib/constants/localCurrencies.js +94 -0
  12. package/lib/constants/localCurrencyIcons.d.ts +18 -0
  13. package/lib/constants/localCurrencyIcons.js +298 -0
  14. package/lib/constants/locales.d.ts +1 -1
  15. package/lib/constants/locales.js +0 -3
  16. package/lib/constants/misc.d.ts +2 -7
  17. package/lib/constants/misc.js +17 -23
  18. package/lib/constants/networks.d.ts +21 -0
  19. package/lib/constants/networks.js +170 -0
  20. package/lib/constants/proposals/index.d.ts +5 -0
  21. package/lib/constants/proposals/index.js +8 -0
  22. package/lib/constants/proposals/polygon_proposal_title.d.ts +1 -0
  23. package/lib/constants/proposals/polygon_proposal_title.js +4 -0
  24. package/lib/constants/proposals/uniswap_grants_proposal_description.d.ts +1 -0
  25. package/lib/constants/proposals/uniswap_grants_proposal_description.js +4 -0
  26. package/lib/constants/providers.d.ts +19 -0
  27. package/lib/constants/providers.js +33 -0
  28. package/lib/constants/routing.d.ts +9 -13
  29. package/lib/constants/routing.js +91 -55
  30. package/lib/constants/routing.test.d.ts +1 -0
  31. package/lib/constants/routing.test.js +32 -0
  32. package/lib/constants/supportArticles.d.ts +13 -0
  33. package/lib/constants/supportArticles.js +17 -0
  34. package/lib/constants/tokenLists/broken.tokenlist.json +22 -0
  35. package/lib/constants/tokenLogoLookup.d.ts +8 -0
  36. package/lib/constants/tokenLogoLookup.js +48 -0
  37. package/lib/constants/tokenSafety.js +129 -0
  38. package/lib/constants/tokenSafetyLookup.d.ts +18 -0
  39. package/lib/constants/tokenSafetyLookup.js +66 -0
  40. package/lib/constants/tokenSaftey.test.d.ts +1 -0
  41. package/lib/constants/tokenSaftey.test.js +31 -0
  42. package/lib/constants/tokens.d.ts +34 -42
  43. package/lib/constants/tokens.js +190 -147
  44. package/lib/index.d.ts +1 -40
  45. package/lib/index.js +150 -641
  46. package/lib/routing/clientSideSmartOrderRouter.d.ts +5 -0
  47. package/lib/routing/clientSideSmartOrderRouter.js +136 -0
  48. package/lib/routing/gas.d.ts +5 -0
  49. package/lib/routing/gas.js +158 -0
  50. package/lib/routing/types.d.ts +393 -0
  51. package/lib/routing/types.js +424 -0
  52. package/lib/routing/utils.d.ts +28 -0
  53. package/lib/routing/utils.js +319 -0
  54. package/lib/rpc/AppJsonRpcProvider.d.ts +44 -0
  55. package/lib/rpc/AppJsonRpcProvider.js +183 -0
  56. package/lib/rpc/ConfiguredJsonRpcProvider.d.ts +8 -0
  57. package/lib/rpc/ConfiguredJsonRpcProvider.js +35 -0
  58. package/lib/utils/contracts/getContract.d.ts +3 -0
  59. package/lib/utils/contracts/getContract.js +29 -0
  60. package/lib/utils/transformSwapRouteToGetQuoteResult.d.ts +4 -0
  61. package/lib/utils/transformSwapRouteToGetQuoteResult.js +116 -0
  62. package/lib/utils/uniswapData.d.ts +21 -0
  63. package/lib/utils/uniswapData.js +217 -0
  64. package/package.json +11 -8
  65. package/lib/constants/addresses.d.ts +0 -9
  66. package/lib/constants/addresses.js +0 -41
  67. package/lib/constants/eip1193.d.ts +0 -8
  68. package/lib/constants/eip1193.js +0 -14
  69. package/lib/constants/index.d.ts +0 -9
  70. package/lib/constants/index.js +0 -26
  71. package/lib/constants/jsonRpcEndpoints.d.ts +0 -12
  72. package/lib/constants/jsonRpcEndpoints.js +0 -101
  73. package/lib/constants/utils/constructSameAddressMap.d.ts +0 -4
  74. package/lib/constants/utils/constructSameAddressMap.js +0 -19
@@ -0,0 +1,393 @@
1
+ import { MixedRouteSDK, Protocol, Trade } from '@uniswap/router-sdk';
2
+ import { ChainId, Currency, CurrencyAmount, Percent, Price, Token, TradeType } from '@uniswap/sdk-core';
3
+ import { DutchOrderInfo, DutchOrderInfoJSON, DutchOrderTrade as IDutchOrderTrade } from '@uniswap/uniswapx-sdk';
4
+ import { Route as V2Route } from '@uniswap/v2-sdk';
5
+ import { Route as V3Route } from '@uniswap/v3-sdk';
6
+ import { BigNumber } from 'ethers/lib/ethers';
7
+ declare enum SignatureType {
8
+ SIGN_UNISWAPX_ORDER = "signUniswapXOrder",
9
+ SIGN_UNISWAPX_V2_ORDER = "signUniswapXV2Order",
10
+ SIGN_LIMIT = "signLimit"
11
+ }
12
+ export declare enum TradeState {
13
+ LOADING = "loading",
14
+ INVALID = "invalid",
15
+ STALE = "stale",
16
+ NO_ROUTE_FOUND = "no_route_found",
17
+ VALID = "valid"
18
+ }
19
+ export declare enum QuoteMethod {
20
+ ROUTING_API = "ROUTING_API",
21
+ QUICK_ROUTE = "QUICK_ROUTE",
22
+ CLIENT_SIDE_FALLBACK = "CLIENT_SIDE_FALLBACK"
23
+ }
24
+ export declare const INTERNAL_ROUTER_PREFERENCE_PRICE: "price";
25
+ export declare enum RouterPreference {
26
+ X = "uniswapx",
27
+ API = "api"
28
+ }
29
+ export declare enum QuoteIntent {
30
+ Pricing = "pricing",
31
+ Quote = "quote"
32
+ }
33
+ export interface GetQuoteArgs {
34
+ tokenInAddress: string;
35
+ tokenInChainId: ChainId;
36
+ tokenInDecimals: number;
37
+ tokenInSymbol?: string;
38
+ tokenOutAddress: string;
39
+ tokenOutChainId: ChainId;
40
+ tokenOutDecimals: number;
41
+ tokenOutSymbol?: string;
42
+ amount: string;
43
+ account?: string;
44
+ routerPreference: RouterPreference | typeof INTERNAL_ROUTER_PREFERENCE_PRICE;
45
+ tradeType: TradeType;
46
+ needsWrapIfUniswapX: boolean;
47
+ uniswapXForceSyntheticQuotes: boolean;
48
+ sendPortionEnabled: boolean;
49
+ }
50
+ export type GetQuickQuoteArgs = {
51
+ amount: string;
52
+ tokenInAddress: string;
53
+ tokenInChainId: ChainId;
54
+ tokenInDecimals: number;
55
+ tokenInSymbol?: string;
56
+ tokenOutAddress: string;
57
+ tokenOutChainId: ChainId;
58
+ tokenOutDecimals: number;
59
+ tokenOutSymbol?: string;
60
+ tradeType: TradeType;
61
+ inputTax: Percent;
62
+ outputTax: Percent;
63
+ };
64
+ export type TokenInRoute = Pick<Token, 'address' | 'chainId' | 'symbol' | 'decimals'> & {
65
+ buyFeeBps?: string;
66
+ sellFeeBps?: string;
67
+ };
68
+ export type V3PoolInRoute = {
69
+ type: 'v3-pool';
70
+ tokenIn: TokenInRoute;
71
+ tokenOut: TokenInRoute;
72
+ sqrtRatioX96: string;
73
+ liquidity: string;
74
+ tickCurrent: string;
75
+ fee: string;
76
+ amountIn?: string;
77
+ amountOut?: string;
78
+ address?: string;
79
+ };
80
+ type V2Reserve = {
81
+ token: TokenInRoute;
82
+ quotient: string;
83
+ };
84
+ export type V2PoolInRoute = {
85
+ type: 'v2-pool';
86
+ tokenIn: TokenInRoute;
87
+ tokenOut: TokenInRoute;
88
+ reserve0: V2Reserve;
89
+ reserve1: V2Reserve;
90
+ amountIn?: string;
91
+ amountOut?: string;
92
+ address?: string;
93
+ };
94
+ export interface ClassicQuoteData {
95
+ quoteId?: string;
96
+ requestId?: string;
97
+ blockNumber: string;
98
+ amount: string;
99
+ amountDecimals: string;
100
+ gasPriceWei?: string;
101
+ gasUseEstimate?: string;
102
+ gasUseEstimateQuote?: string;
103
+ gasUseEstimateQuoteDecimals?: string;
104
+ gasUseEstimateUSD?: string;
105
+ methodParameters?: {
106
+ calldata: string;
107
+ value: string;
108
+ };
109
+ quote: string;
110
+ quoteDecimals: string;
111
+ quoteGasAdjusted: string;
112
+ quoteGasAdjustedDecimals: string;
113
+ route: Array<(V3PoolInRoute | V2PoolInRoute)[]>;
114
+ routeString: string;
115
+ portionBips?: number;
116
+ portionRecipient?: string;
117
+ portionAmount?: string;
118
+ portionAmountDecimals?: string;
119
+ quoteGasAndPortionAdjusted?: string;
120
+ quoteGasAndPortionAdjustedDecimals?: string;
121
+ }
122
+ export type URADutchOrderQuoteData = {
123
+ auctionPeriodSecs: number;
124
+ deadlineBufferSecs: number;
125
+ startTimeBufferSecs: number;
126
+ orderInfo: DutchOrderInfoJSON;
127
+ quoteId?: string;
128
+ requestId?: string;
129
+ slippageTolerance: string;
130
+ portionBips?: number;
131
+ portionRecipient?: string;
132
+ portionAmount?: string;
133
+ };
134
+ export type URADutchOrderQuoteResponse = {
135
+ routing: URAQuoteType.DUTCH_LIMIT;
136
+ quote: URADutchOrderQuoteData;
137
+ allQuotes: Array<URAQuoteResponse>;
138
+ };
139
+ type URAClassicQuoteResponse = {
140
+ routing: URAQuoteType.CLASSIC;
141
+ quote: ClassicQuoteData;
142
+ allQuotes: Array<URAQuoteResponse>;
143
+ };
144
+ export type URAQuoteResponse = URAClassicQuoteResponse | URADutchOrderQuoteResponse;
145
+ export type QuickRouteResponse = {
146
+ tokenIn: {
147
+ address: string;
148
+ decimals: number;
149
+ symbol: string;
150
+ name: string;
151
+ };
152
+ tokenOut: {
153
+ address: string;
154
+ decimals: number;
155
+ symbol: string;
156
+ name: string;
157
+ };
158
+ tradeType: 'EXACT_IN' | 'EXACT_OUT';
159
+ quote: {
160
+ amount: string;
161
+ path: string;
162
+ };
163
+ };
164
+ export declare function isClassicQuoteResponse(data: URAQuoteResponse): data is URAClassicQuoteResponse;
165
+ export declare enum TradeFillType {
166
+ Classic = "classic",// Uniswap V1, V2, and V3 trades with on-chain routes
167
+ UniswapX = "uniswap_x",// off-chain trades, no routes
168
+ None = "none"
169
+ }
170
+ export type ApproveInfo = {
171
+ needsApprove: true;
172
+ approveGasEstimateUSD: number;
173
+ } | {
174
+ needsApprove: false;
175
+ };
176
+ export type WrapInfo = {
177
+ needsWrap: true;
178
+ wrapGasEstimateUSD: number;
179
+ } | {
180
+ needsWrap: false;
181
+ };
182
+ export type SwapFeeInfo = {
183
+ recipient: string;
184
+ percent: Percent;
185
+ amount: string;
186
+ };
187
+ export declare class ClassicTrade extends Trade<Currency, Currency, TradeType> {
188
+ readonly fillType = TradeFillType.Classic;
189
+ approveInfo: ApproveInfo;
190
+ gasUseEstimate?: number;
191
+ gasUseEstimateUSD?: number;
192
+ blockNumber: string | null | undefined;
193
+ requestId: string | undefined;
194
+ quoteMethod: QuoteMethod;
195
+ swapFee: SwapFeeInfo | undefined;
196
+ constructor({ gasUseEstimate, gasUseEstimateUSD, blockNumber, requestId, quoteMethod, approveInfo, swapFee, ...routes }: {
197
+ gasUseEstimate?: number;
198
+ gasUseEstimateUSD?: number;
199
+ totalGasUseEstimateUSD?: number;
200
+ blockNumber?: string | null;
201
+ requestId?: string;
202
+ quoteMethod: QuoteMethod;
203
+ approveInfo: ApproveInfo;
204
+ swapFee?: SwapFeeInfo;
205
+ v2Routes: {
206
+ routev2: V2Route<Currency, Currency>;
207
+ inputAmount: CurrencyAmount<Currency>;
208
+ outputAmount: CurrencyAmount<Currency>;
209
+ }[];
210
+ v3Routes: {
211
+ routev3: V3Route<Currency, Currency>;
212
+ inputAmount: CurrencyAmount<Currency>;
213
+ outputAmount: CurrencyAmount<Currency>;
214
+ }[];
215
+ tradeType: TradeType;
216
+ mixedRoutes?: {
217
+ mixedRoute: MixedRouteSDK<Currency, Currency>;
218
+ inputAmount: CurrencyAmount<Currency>;
219
+ outputAmount: CurrencyAmount<Currency>;
220
+ }[];
221
+ });
222
+ get executionPrice(): Price<Currency, Currency>;
223
+ get postSwapFeeOutputAmount(): CurrencyAmount<Currency>;
224
+ get totalGasUseEstimateUSD(): number | undefined;
225
+ }
226
+ export declare enum OffchainOrderType {
227
+ DUTCH_AUCTION = "Dutch",
228
+ DUTCH_V2_AUCTION = "Dutch_V2",
229
+ LIMIT_ORDER = "Limit"
230
+ }
231
+ export declare const OFFCHAIN_ORDER_TYPE_TO_SIGNATURE_TYPE: Record<OffchainOrderType, SignatureType>;
232
+ export declare class DutchOrderTrade extends IDutchOrderTrade<Currency, Currency, TradeType> {
233
+ readonly fillType = TradeFillType.UniswapX;
234
+ readonly offchainOrderType = OffchainOrderType.DUTCH_AUCTION;
235
+ quoteId?: string;
236
+ requestId?: string;
237
+ wrapInfo: WrapInfo;
238
+ approveInfo: ApproveInfo;
239
+ classicGasUseEstimateUSD?: number;
240
+ auctionPeriodSecs: number;
241
+ startTimeBufferSecs: number;
242
+ deadlineBufferSecs: number;
243
+ slippageTolerance: Percent;
244
+ inputTax: Percent;
245
+ outputTax: Percent;
246
+ swapFee: SwapFeeInfo | undefined;
247
+ constructor({ currencyIn, currenciesOut, orderInfo, tradeType, quoteId, requestId, wrapInfo, approveInfo, classicGasUseEstimateUSD, auctionPeriodSecs, startTimeBufferSecs, deadlineBufferSecs, slippageTolerance, swapFee, }: {
248
+ currencyIn: Currency;
249
+ currenciesOut: Currency[];
250
+ orderInfo: DutchOrderInfo;
251
+ tradeType: TradeType;
252
+ quoteId?: string;
253
+ requestId?: string;
254
+ approveInfo: ApproveInfo;
255
+ wrapInfo: WrapInfo;
256
+ classicGasUseEstimateUSD?: number;
257
+ auctionPeriodSecs: number;
258
+ startTimeBufferSecs: number;
259
+ deadlineBufferSecs: number;
260
+ slippageTolerance: Percent;
261
+ swapFee?: SwapFeeInfo;
262
+ });
263
+ get totalGasUseEstimateUSD(): number;
264
+ asDutchOrderTrade(): this;
265
+ }
266
+ export declare class PreviewTrade {
267
+ readonly fillType = TradeFillType.None;
268
+ readonly quoteMethod = QuoteMethod.QUICK_ROUTE;
269
+ readonly tradeType: TradeType;
270
+ readonly inputAmount: CurrencyAmount<Currency>;
271
+ readonly outputAmount: CurrencyAmount<Currency>;
272
+ constructor({ inputAmount, outputAmount, tradeType, }: {
273
+ inputAmount: CurrencyAmount<Currency>;
274
+ outputAmount: CurrencyAmount<Currency>;
275
+ tradeType: TradeType;
276
+ });
277
+ minimumAmountOut(slippageTolerance: Percent, amountOut?: CurrencyAmount<Currency>): CurrencyAmount<Currency>;
278
+ maximumAmountIn(slippageTolerance: Percent, amountIn?: CurrencyAmount<Currency>): CurrencyAmount<Currency>;
279
+ /**
280
+ * Returns the sell tax of the input token
281
+ */
282
+ get inputTax(): Percent;
283
+ /**
284
+ * Returns the buy tax of the output token
285
+ */
286
+ get outputTax(): Percent;
287
+ private _executionPrice;
288
+ /**
289
+ * The price expressed in terms of output amount/input amount.
290
+ */
291
+ get executionPrice(): Price<Currency, Currency>;
292
+ worstExecutionPrice(slippageTolerance: Percent): Price<Currency, Currency>;
293
+ }
294
+ export declare class LimitOrderTrade {
295
+ readonly fillType = TradeFillType.UniswapX;
296
+ readonly offchainOrderType = OffchainOrderType.LIMIT_ORDER;
297
+ deadlineBufferSecs: number;
298
+ wrapInfo: WrapInfo;
299
+ approveInfo: ApproveInfo;
300
+ swapFee: SwapFeeInfo | undefined;
301
+ amountIn: CurrencyAmount<Token>;
302
+ amountOut: CurrencyAmount<Currency>;
303
+ tradeType: TradeType;
304
+ swapper: string;
305
+ deadline: number;
306
+ inputTax: Percent;
307
+ outputTax: Percent;
308
+ slippageTolerance: Percent;
309
+ quoteId: undefined;
310
+ requestId: undefined;
311
+ constructor({ tradeType, amountIn, amountOut, deadlineBufferSecs, swapFee, wrapInfo, approveInfo, swapper, }: {
312
+ tradeType: TradeType;
313
+ amountIn: CurrencyAmount<Token>;
314
+ amountOut: CurrencyAmount<Currency>;
315
+ deadlineBufferSecs: number;
316
+ swapFee?: SwapFeeInfo;
317
+ wrapInfo: WrapInfo;
318
+ approveInfo: ApproveInfo;
319
+ swapper: string;
320
+ });
321
+ asDutchOrderTrade(options?: {
322
+ nonce: BigNumber;
323
+ swapper: string;
324
+ }): IDutchOrderTrade<Currency, Currency, TradeType>;
325
+ get inputAmount(): CurrencyAmount<Token>;
326
+ get outputAmount(): CurrencyAmount<Currency>;
327
+ /** For UniswapX, handling token taxes in the output amount is outsourced to quoters */
328
+ get postTaxOutputAmount(): CurrencyAmount<Currency>;
329
+ get totalGasUseEstimateUSD(): number;
330
+ get classicGasUseEstimateUSD(): number;
331
+ get startTimeBufferSecs(): number;
332
+ get auctionPeriodSecs(): number;
333
+ get executionPrice(): Price<Currency, Currency>;
334
+ worstExecutionPrice(): Price<Currency, Currency>;
335
+ maximumAmountIn(): CurrencyAmount<Currency>;
336
+ minimumAmountOut(): CurrencyAmount<Currency>;
337
+ }
338
+ export type SubmittableTrade = ClassicTrade | DutchOrderTrade | LimitOrderTrade;
339
+ export type InterfaceTrade = SubmittableTrade | PreviewTrade;
340
+ export declare enum QuoteState {
341
+ SUCCESS = "Success",
342
+ NOT_FOUND = "Not found"
343
+ }
344
+ export type QuoteResult = {
345
+ state: QuoteState.NOT_FOUND;
346
+ data?: undefined;
347
+ } | {
348
+ state: QuoteState.SUCCESS;
349
+ data: URAQuoteResponse;
350
+ };
351
+ export type TradeResult = {
352
+ state: QuoteState.NOT_FOUND;
353
+ trade?: undefined;
354
+ latencyMs?: number;
355
+ } | {
356
+ state: QuoteState.SUCCESS;
357
+ trade: SubmittableTrade;
358
+ latencyMs?: number;
359
+ };
360
+ export type PreviewTradeResult = {
361
+ state: QuoteState.NOT_FOUND;
362
+ trade?: undefined;
363
+ latencyMs?: number;
364
+ } | {
365
+ state: QuoteState.SUCCESS;
366
+ trade: PreviewTrade;
367
+ latencyMs?: number;
368
+ };
369
+ export declare enum PoolType {
370
+ V2Pool = "v2-pool",
371
+ V3Pool = "v3-pool"
372
+ }
373
+ export declare enum SwapRouterNativeAssets {
374
+ MATIC = "MATIC",
375
+ BNB = "BNB",
376
+ AVAX = "AVAX",
377
+ ETH = "ETH"
378
+ }
379
+ export declare enum URAQuoteType {
380
+ CLASSIC = "CLASSIC",
381
+ DUTCH_LIMIT = "DUTCH_LIMIT"
382
+ }
383
+ type ClassicAPIConfig = {
384
+ protocols: Protocol[];
385
+ };
386
+ type UniswapXConfig = {
387
+ swapper?: string;
388
+ exclusivityOverrideBps?: number;
389
+ auctionPeriodSecs?: number;
390
+ startTimeBufferSecs?: number;
391
+ };
392
+ export type RoutingConfig = (UniswapXConfig | ClassicAPIConfig)[];
393
+ export {};