@pioneer-platform/uniswap-client 0.1.0 → 0.2.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 (51) hide show
  1. package/CHANGELOG.md +27 -0
  2. package/package.json +15 -24
  3. package/tsconfig.json +2 -1
  4. package/lib/constants/chainInfo.d.ts +0 -47
  5. package/lib/constants/chainInfo.js +0 -248
  6. package/lib/constants/chains.d.ts +0 -46
  7. package/lib/constants/chains.js +0 -136
  8. package/lib/constants/governance.d.ts +0 -8
  9. package/lib/constants/governance.js +0 -23
  10. package/lib/constants/lists.d.ts +0 -12
  11. package/lib/constants/lists.js +0 -56
  12. package/lib/constants/locales.d.ts +0 -6
  13. package/lib/constants/locales.js +0 -71
  14. package/lib/constants/misc.d.ts +0 -16
  15. package/lib/constants/misc.js +0 -31
  16. package/lib/constants/networks.d.ts +0 -21
  17. package/lib/constants/networks.js +0 -169
  18. package/lib/constants/proposals/index.d.ts +0 -5
  19. package/lib/constants/proposals/index.js +0 -8
  20. package/lib/constants/proposals/polygon_proposal_title.d.ts +0 -1
  21. package/lib/constants/proposals/polygon_proposal_title.js +0 -4
  22. package/lib/constants/proposals/uniswap_grants_proposal_description.d.ts +0 -1
  23. package/lib/constants/proposals/uniswap_grants_proposal_description.js +0 -109
  24. package/lib/constants/providers.d.ts +0 -20
  25. package/lib/constants/providers.js +0 -32
  26. package/lib/constants/routing.d.ts +0 -16
  27. package/lib/constants/routing.js +0 -106
  28. package/lib/constants/supportArticles.d.ts +0 -13
  29. package/lib/constants/supportArticles.js +0 -17
  30. package/lib/constants/tokens.d.ts +0 -70
  31. package/lib/constants/tokens.js +0 -252
  32. package/lib/index.d.ts +0 -1
  33. package/lib/index.js +0 -724
  34. package/lib/routing/clientSideSmartOrderRouter.d.ts +0 -5
  35. package/lib/routing/clientSideSmartOrderRouter.js +0 -102
  36. package/lib/routing/gas.d.ts +0 -5
  37. package/lib/routing/gas.js +0 -71
  38. package/lib/routing/types.d.ts +0 -393
  39. package/lib/routing/types.js +0 -320
  40. package/lib/routing/utils.d.ts +0 -28
  41. package/lib/routing/utils.js +0 -264
  42. package/lib/rpc/AppJsonRpcProvider.d.ts +0 -44
  43. package/lib/rpc/AppJsonRpcProvider.js +0 -92
  44. package/lib/rpc/ConfiguredJsonRpcProvider.d.ts +0 -8
  45. package/lib/rpc/ConfiguredJsonRpcProvider.js +0 -16
  46. package/lib/utils/contracts/getContract.d.ts +0 -3
  47. package/lib/utils/contracts/getContract.js +0 -28
  48. package/lib/utils/transformSwapRouteToGetQuoteResult.d.ts +0 -4
  49. package/lib/utils/transformSwapRouteToGetQuoteResult.js +0 -113
  50. package/lib/utils/uniswapData.d.ts +0 -21
  51. package/lib/utils/uniswapData.js +0 -139
@@ -1,5 +0,0 @@
1
- import { ChainId } from '@uniswap/sdk-core';
2
- import { AlphaRouter, AlphaRouterConfig } from '@uniswap/smart-order-router';
3
- import { GetQuoteArgs, QuoteResult } from '../routing/types';
4
- export declare function getRouter(chainId: ChainId): AlphaRouter;
5
- export declare function getClientSideQuote({ tokenInAddress, tokenInChainId, tokenInDecimals, tokenInSymbol, tokenOutAddress, tokenOutChainId, tokenOutDecimals, tokenOutSymbol, amount, tradeType, }: GetQuoteArgs, router: AlphaRouter, config: Partial<AlphaRouterConfig>): Promise<QuoteResult>;
@@ -1,102 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.getRouter = getRouter;
7
- exports.getClientSideQuote = getClientSideQuote;
8
- const sdk_core_1 = require("@uniswap/sdk-core");
9
- // This file is lazy-loaded, so the import of smart-order-router is intentional.
10
- // eslint-disable-next-line @typescript-eslint/no-restricted-imports
11
- const smart_order_router_1 = require("@uniswap/smart-order-router");
12
- const chains_1 = require("../constants/chains");
13
- const providers_1 = require("../constants/providers");
14
- const tokens_1 = require("../constants/tokens");
15
- const jsbi_1 = __importDefault(require("jsbi"));
16
- const types_1 = require("../routing/types");
17
- const transformSwapRouteToGetQuoteResult_1 = require("../utils/transformSwapRouteToGetQuoteResult");
18
- const CLIENT_SIDE_ROUTING_ALLOW_LIST = [
19
- sdk_core_1.ChainId.MAINNET,
20
- sdk_core_1.ChainId.OPTIMISM,
21
- sdk_core_1.ChainId.OPTIMISM_GOERLI,
22
- sdk_core_1.ChainId.ARBITRUM_ONE,
23
- sdk_core_1.ChainId.ARBITRUM_GOERLI,
24
- sdk_core_1.ChainId.POLYGON,
25
- sdk_core_1.ChainId.POLYGON_MUMBAI,
26
- sdk_core_1.ChainId.GOERLI,
27
- sdk_core_1.ChainId.SEPOLIA,
28
- sdk_core_1.ChainId.CELO_ALFAJORES,
29
- sdk_core_1.ChainId.CELO,
30
- sdk_core_1.ChainId.BNB,
31
- sdk_core_1.ChainId.AVALANCHE,
32
- sdk_core_1.ChainId.BASE,
33
- ];
34
- const routers = new Map();
35
- function getRouter(chainId) {
36
- const router = routers.get(chainId);
37
- if (router)
38
- return router;
39
- const supportedChainId = (0, chains_1.asSupportedChain)(chainId);
40
- if (supportedChainId && CLIENT_SIDE_ROUTING_ALLOW_LIST.includes(chainId)) {
41
- const provider = providers_1.RPC_PROVIDERS[supportedChainId];
42
- const router = new smart_order_router_1.AlphaRouter({ chainId, provider });
43
- routers.set(chainId, router);
44
- return router;
45
- }
46
- throw new Error(`Router does not support this chain (chainId: ${chainId}).`);
47
- }
48
- async function getQuote({ tradeType, tokenIn, tokenOut, amount: amountRaw, }, router, routerConfig) {
49
- console.log("Checkpoint: getQuote");
50
- const tokenInIsNative = Object.values(types_1.SwapRouterNativeAssets).includes(tokenIn.address);
51
- const tokenOutIsNative = Object.values(types_1.SwapRouterNativeAssets).includes(tokenOut.address);
52
- console.log("Checkpoint: getQuote2");
53
- let currencyIn;
54
- if (tokenInIsNative) {
55
- console.log("Checkpoint: tokenInIsNative");
56
- currencyIn = (0, tokens_1.nativeOnChain)(tokenIn.chainId); // Use the native token for the chain if tokenIn is native
57
- }
58
- else {
59
- console.log("Checkpoint: !tokenInIsNative tokenIn: ", tokenIn);
60
- currencyIn = new sdk_core_1.Token(tokenIn.chainId, tokenIn.address, tokenIn.decimals, tokenIn.symbol); // Otherwise, create a new token
61
- }
62
- // Determine the output currency type
63
- let currencyOut;
64
- if (tokenOutIsNative) {
65
- console.log("Checkpoint: tokenOutIsNative");
66
- currencyOut = (0, tokens_1.nativeOnChain)(tokenOut.chainId); // Use the native token for the chain if tokenOut is native
67
- }
68
- else {
69
- console.log("Checkpoint: !tokenOutIsNative");
70
- currencyOut = new sdk_core_1.Token(tokenOut.chainId, tokenOut.address, tokenOut.decimals, tokenOut.symbol); // Otherwise, create a new token
71
- }
72
- const baseCurrency = tradeType === sdk_core_1.TradeType.EXACT_INPUT ? currencyIn : currencyOut;
73
- const quoteCurrency = tradeType === sdk_core_1.TradeType.EXACT_INPUT ? currencyOut : currencyIn;
74
- console.log("baseCurrency", baseCurrency);
75
- console.log("quoteCurrency", quoteCurrency);
76
- const amount = sdk_core_1.CurrencyAmount.fromRawAmount(baseCurrency, jsbi_1.default.BigInt(amountRaw));
77
- // TODO (WEB-2055): explore initializing client side routing on first load (when amountRaw is null) if there are enough users using client-side router preference.
78
- const swapRoute = await router.route(amount, quoteCurrency, tradeType, /*swapConfig=*/ undefined, routerConfig);
79
- console.log("swapRoute", swapRoute);
80
- if (!swapRoute) {
81
- return { state: types_1.QuoteState.NOT_FOUND };
82
- }
83
- return (0, transformSwapRouteToGetQuoteResult_1.transformSwapRouteToGetQuoteResult)(tradeType, amount, swapRoute);
84
- }
85
- async function getClientSideQuote({ tokenInAddress, tokenInChainId, tokenInDecimals, tokenInSymbol, tokenOutAddress, tokenOutChainId, tokenOutDecimals, tokenOutSymbol, amount, tradeType, }, router, config) {
86
- return getQuote({
87
- tradeType,
88
- tokenIn: {
89
- address: tokenInAddress,
90
- chainId: tokenInChainId,
91
- decimals: tokenInDecimals,
92
- symbol: tokenInSymbol,
93
- },
94
- tokenOut: {
95
- address: tokenOutAddress,
96
- chainId: tokenOutChainId,
97
- decimals: tokenOutDecimals,
98
- symbol: tokenOutSymbol,
99
- },
100
- amount,
101
- }, router, config);
102
- }
@@ -1,5 +0,0 @@
1
- import { Currency } from '@uniswap/sdk-core';
2
- import { SupportedInterfaceChain } from '../constants/chains';
3
- import { ApproveInfo, WrapInfo } from './types';
4
- export declare function getApproveInfo(account: string | undefined, currency: Currency, amount: string, usdCostPerGas?: number): Promise<ApproveInfo>;
5
- export declare function getWrapInfo(needsWrap: boolean, account: string | undefined, chainId: SupportedInterfaceChain, amount: string, usdCostPerGas?: number): Promise<WrapInfo>;
@@ -1,71 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.getApproveInfo = getApproveInfo;
7
- exports.getWrapInfo = getWrapInfo;
8
- const permit2_sdk_1 = require("@uniswap/permit2-sdk");
9
- const sdk_core_1 = require("@uniswap/sdk-core");
10
- const providers_1 = require("../constants/providers");
11
- const tokens_1 = require("../constants/tokens");
12
- const erc20_json_1 = __importDefault(require("../uniswap/src/abis/erc20.json"));
13
- const weth_json_1 = __importDefault(require("../uniswap/src/abis/weth.json"));
14
- const getContract_1 = require("../utils/contracts/getContract");
15
- // TODO(UniswapX): add fallback gas limits per chain? l2s have higher costs
16
- const WRAP_FALLBACK_GAS_LIMIT = 45000;
17
- const APPROVE_FALLBACK_GAS_LIMIT = 65000;
18
- async function getApproveInfo(account, currency, amount, usdCostPerGas) {
19
- // native currencies do not need token approvals
20
- if (currency.isNative)
21
- return { needsApprove: false };
22
- // If any of these arguments aren't provided, then we cannot generate approval cost info
23
- if (!account || !usdCostPerGas)
24
- return { needsApprove: false };
25
- // routing-api under estimates gas for Arbitrum swaps so it inflates cost per gas by a lot
26
- // so disable showing approves for Arbitrum until routing-api gives more accurate gas estimates
27
- if (currency.chainId === sdk_core_1.ChainId.ARBITRUM_ONE || currency.chainId === sdk_core_1.ChainId.ARBITRUM_GOERLI) {
28
- return { needsApprove: false };
29
- }
30
- const provider = providers_1.RPC_PROVIDERS[currency.chainId];
31
- const tokenContract = (0, getContract_1.getContract)(currency.address, erc20_json_1.default, provider);
32
- let approveGasUseEstimate;
33
- try {
34
- const allowance = await tokenContract.callStatic.allowance(account, permit2_sdk_1.PERMIT2_ADDRESS);
35
- if (!allowance.lt(amount))
36
- return { needsApprove: false };
37
- }
38
- catch (_) {
39
- // If contract lookup fails (eg if Infura goes down), then don't show gas info for approving the token
40
- return { needsApprove: false };
41
- }
42
- try {
43
- const approveTx = await tokenContract.populateTransaction.approve(permit2_sdk_1.PERMIT2_ADDRESS, permit2_sdk_1.MaxUint256);
44
- approveGasUseEstimate = (await provider.estimateGas({ from: account, ...approveTx })).toNumber();
45
- }
46
- catch (_) {
47
- // estimateGas will error if the account doesn't have sufficient token balance, but we should show an estimated cost anyway
48
- approveGasUseEstimate = APPROVE_FALLBACK_GAS_LIMIT;
49
- }
50
- return { needsApprove: true, approveGasEstimateUSD: approveGasUseEstimate * usdCostPerGas };
51
- }
52
- async function getWrapInfo(needsWrap, account, chainId, amount, usdCostPerGas) {
53
- if (!needsWrap)
54
- return { needsWrap: false };
55
- const provider = providers_1.RPC_PROVIDERS[chainId];
56
- const wethAddress = tokens_1.WRAPPED_NATIVE_CURRENCY[chainId]?.address;
57
- // If any of these arguments aren't provided, then we cannot generate wrap cost info
58
- if (!wethAddress || !usdCostPerGas)
59
- return { needsWrap: false };
60
- let wrapGasUseEstimate;
61
- try {
62
- const wethContract = (0, getContract_1.getContract)(wethAddress, weth_json_1.default, provider, account);
63
- const wethTx = await wethContract.populateTransaction.deposit({ value: amount });
64
- // estimateGas will error if the account doesn't have sufficient ETH balance, but we should show an estimated cost anyway
65
- wrapGasUseEstimate = (await provider.estimateGas({ from: account, ...wethTx })).toNumber();
66
- }
67
- catch (_) {
68
- wrapGasUseEstimate = WRAP_FALLBACK_GAS_LIMIT;
69
- }
70
- return { needsWrap: true, wrapGasEstimateUSD: wrapGasUseEstimate * usdCostPerGas };
71
- }
@@ -1,393 +0,0 @@
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: any;
245
- outputTax: any;
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: any;
307
- outputTax: any;
308
- slippageTolerance: any;
309
- quoteId: any;
310
- requestId: any;
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 {};