@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,92 +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
- const chainInfo_1 = require("../constants/chainInfo");
7
- const ConfiguredJsonRpcProvider_1 = __importDefault(require("./ConfiguredJsonRpcProvider"));
8
- /**
9
- * A controller which marks itself disabled on an error, and re-enables itself using exponential backoff.
10
- * After each retry, it will wait twice as long to retry again. After a success, it will reset the backoff.
11
- */
12
- class Controller {
13
- constructor(minimumBackoffTime) {
14
- this.minimumBackoffTime = minimumBackoffTime;
15
- this.isEnabled = true;
16
- this.exponentialBackoffFactor = 1;
17
- }
18
- reset() {
19
- this.isEnabled = true;
20
- // @ts-ignore
21
- clearTimeout(this.timeout);
22
- this.timeout = undefined;
23
- }
24
- onSuccess() {
25
- this.reset();
26
- this.exponentialBackoffFactor = 1;
27
- }
28
- /**
29
- * Called onError.
30
- * Idempotent - calling this multiple times will *not* reset the exponential backoff timer.
31
- */
32
- onError() {
33
- this.isEnabled = false;
34
- if (!this.timeout) {
35
- this.timeout = setTimeout(() => {
36
- this.reset();
37
- this.exponentialBackoffFactor *= 2;
38
- }, this.minimumBackoffTime * this.exponentialBackoffFactor);
39
- }
40
- }
41
- get enabled() {
42
- return this.isEnabled;
43
- }
44
- }
45
- /**
46
- * An application-specific JSON-RPC provider.
47
- *
48
- * This super-provider will instantiate providers for all supported JSON-RPC URLs, so that it may use them as fallbacks.
49
- * It will use the first (primary) JSON-RPC URL unless there is issue, at which point it will fallback to the next, &c.,
50
- * retrying the former using exponential backoff. This prevents secondary URLs from permanently overtaking primary URLs.
51
- */
52
- class AppJsonRpcProvider extends ConfiguredJsonRpcProvider_1.default {
53
- constructor(providers, { minimumBackoffTime = chainInfo_1.AVERAGE_L1_BLOCK_TIME } = {}) {
54
- if (providers.length === 0)
55
- throw new Error('Missing providers for AppJsonRpcProvider');
56
- super(undefined, providers[0].network);
57
- // AppJsonRpcProvider configures its own pollingInterval, so the encapsulated providers do not need to poll.
58
- // providers.forEach((provider) => (provider.pollingInterval = Infinity))
59
- this.providers = providers.map((provider) => ({ provider, controller: new Controller(minimumBackoffTime) }));
60
- }
61
- async perform(method, params) {
62
- const sortedProviders = AppJsonRpcProvider.sortProviders(this.providers);
63
- for (const { provider, controller } of sortedProviders) {
64
- try {
65
- const result = await provider.perform(method, params);
66
- controller.onSuccess();
67
- return result;
68
- }
69
- catch (error) {
70
- console.warn('rpc action failed', error);
71
- controller.onError();
72
- }
73
- }
74
- throw new Error(`All providers failed to perform the operation: ${method}`);
75
- }
76
- static sortProviders(providers) {
77
- // Try enabled providers before resorting to disabled providers.
78
- // Note that we do not filtered out disabled providers.
79
- return [...providers].sort(({ controller: { enabled: a } }, { controller: { enabled: b } }) => {
80
- if (a && !b) {
81
- return -1;
82
- }
83
- else if (!a && b) {
84
- return 1;
85
- }
86
- else {
87
- return 0; // sort is stable
88
- }
89
- });
90
- }
91
- }
92
- exports.default = AppJsonRpcProvider;
@@ -1,8 +0,0 @@
1
- import { Networkish } from '@ethersproject/networks';
2
- import { StaticJsonRpcProvider } from '@ethersproject/providers';
3
- import { SupportedInterfaceChain } from '../constants/chains';
4
- export default class ConfiguredJsonRpcProvider extends StaticJsonRpcProvider {
5
- constructor(url: string | undefined, networkish: Networkish & {
6
- chainId: SupportedInterfaceChain;
7
- }, pollingInterval?: any);
8
- }
@@ -1,16 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const providers_1 = require("@ethersproject/providers");
4
- const chainInfo_1 = require("../constants/chainInfo");
5
- class ConfiguredJsonRpcProvider extends providers_1.StaticJsonRpcProvider {
6
- constructor(url,
7
- // Including networkish allows ethers to skip the initial detectNetwork call.
8
- networkish, pollingInterval = chainInfo_1.AVERAGE_L1_BLOCK_TIME) {
9
- super(url, networkish);
10
- // NB: Third-party providers (eg MetaMask) will have their own polling intervals,
11
- // which should be left as-is to allow operations (eg transaction confirmation) to resolve faster.
12
- // Network providers need to update less frequently to be considered responsive.
13
- this.pollingInterval = pollingInterval;
14
- }
15
- }
16
- exports.default = ConfiguredJsonRpcProvider;
@@ -1,3 +0,0 @@
1
- import { Contract, ContractInterface } from '@ethersproject/contracts';
2
- import { JsonRpcProvider } from '@ethersproject/providers';
3
- export declare function getContract(address: string, ABI: ContractInterface, provider: JsonRpcProvider, account?: string): Contract;
@@ -1,28 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getContract = getContract;
4
- const constants_1 = require("@ethersproject/constants");
5
- const contracts_1 = require("@ethersproject/contracts");
6
- const address_1 = require("@ethersproject/address");
7
- function isAddress(value) {
8
- if (!value) {
9
- return false;
10
- }
11
- try {
12
- // Alphabetical letters must be made lowercase for getAddress to work.
13
- // See documentation here: https://docs.ethers.io/v5/api/utils/address/
14
- return (0, address_1.getAddress)(value.toLowerCase());
15
- }
16
- catch {
17
- return false;
18
- }
19
- }
20
- function getContract(address, ABI, provider, account) {
21
- if (!isAddress(address) || address === constants_1.AddressZero) {
22
- throw Error(`Invalid 'address' parameter '${address}'.`);
23
- }
24
- return new contracts_1.Contract(address, ABI, getProviderOrSigner(provider, account));
25
- }
26
- function getProviderOrSigner(provider, account) {
27
- return account ? provider.getSigner(account).connectUnchecked() : provider;
28
- }
@@ -1,4 +0,0 @@
1
- import { Currency, CurrencyAmount, TradeType } from '@uniswap/sdk-core';
2
- import { SwapRoute } from '@uniswap/smart-order-router';
3
- import { QuoteResult } from '../routing/types';
4
- export declare function transformSwapRouteToGetQuoteResult(tradeType: TradeType, amount: CurrencyAmount<Currency>, { quote, quoteGasAdjusted, route, estimatedGasUsed, estimatedGasUsedQuoteToken, estimatedGasUsedUSD, gasPriceWei, methodParameters, blockNumber, }: SwapRoute): QuoteResult;
@@ -1,113 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.transformSwapRouteToGetQuoteResult = transformSwapRouteToGetQuoteResult;
4
- const router_sdk_1 = require("@uniswap/router-sdk");
5
- const sdk_core_1 = require("@uniswap/sdk-core");
6
- // This file is lazy-loaded, so the import of smart-order-router is intentional.
7
- // eslint-disable-next-line @typescript-eslint/no-restricted-imports
8
- const smart_order_router_1 = require("@uniswap/smart-order-router");
9
- const v3_sdk_1 = require("@uniswap/v3-sdk");
10
- const types_1 = require("../routing/types");
11
- // from routing-api (https://github.com/Uniswap/routing-api/blob/main/lib/handlers/quote/quote.ts#L243-L311)
12
- function transformSwapRouteToGetQuoteResult(tradeType, amount, { quote, quoteGasAdjusted, route, estimatedGasUsed, estimatedGasUsedQuoteToken, estimatedGasUsedUSD, gasPriceWei, methodParameters, blockNumber, }) {
13
- const routeResponse = [];
14
- for (const subRoute of route) {
15
- const { amount, quote, tokenPath } = subRoute;
16
- const pools = subRoute.protocol === router_sdk_1.Protocol.V2 ? subRoute.route.pairs : subRoute.route.pools;
17
- const curRoute = [];
18
- for (let i = 0; i < pools.length; i++) {
19
- const nextPool = pools[i];
20
- const tokenIn = tokenPath[i];
21
- const tokenOut = tokenPath[i + 1];
22
- let edgeAmountIn = undefined;
23
- if (i === 0) {
24
- edgeAmountIn = tradeType === sdk_core_1.TradeType.EXACT_INPUT ? amount.quotient.toString() : quote.quotient.toString();
25
- }
26
- let edgeAmountOut = undefined;
27
- if (i === pools.length - 1) {
28
- edgeAmountOut = tradeType === sdk_core_1.TradeType.EXACT_INPUT ? quote.quotient.toString() : amount.quotient.toString();
29
- }
30
- if (nextPool instanceof v3_sdk_1.Pool) {
31
- curRoute.push({
32
- type: 'v3-pool',
33
- tokenIn: {
34
- chainId: tokenIn.chainId,
35
- decimals: tokenIn.decimals,
36
- address: tokenIn.address,
37
- symbol: tokenIn.symbol,
38
- },
39
- tokenOut: {
40
- chainId: tokenOut.chainId,
41
- decimals: tokenOut.decimals,
42
- address: tokenOut.address,
43
- symbol: tokenOut.symbol,
44
- },
45
- fee: nextPool.fee.toString(),
46
- liquidity: nextPool.liquidity.toString(),
47
- sqrtRatioX96: nextPool.sqrtRatioX96.toString(),
48
- tickCurrent: nextPool.tickCurrent.toString(),
49
- amountIn: edgeAmountIn,
50
- amountOut: edgeAmountOut,
51
- });
52
- }
53
- else {
54
- const reserve0 = nextPool.reserve0;
55
- const reserve1 = nextPool.reserve1;
56
- curRoute.push({
57
- type: 'v2-pool',
58
- tokenIn: {
59
- chainId: tokenIn.chainId,
60
- decimals: tokenIn.decimals,
61
- address: tokenIn.address,
62
- symbol: tokenIn.symbol,
63
- },
64
- tokenOut: {
65
- chainId: tokenOut.chainId,
66
- decimals: tokenOut.decimals,
67
- address: tokenOut.address,
68
- symbol: tokenOut.symbol,
69
- },
70
- reserve0: {
71
- token: {
72
- chainId: reserve0.currency.wrapped.chainId,
73
- decimals: reserve0.currency.wrapped.decimals,
74
- address: reserve0.currency.wrapped.address,
75
- symbol: reserve0.currency.wrapped.symbol,
76
- },
77
- quotient: reserve0.quotient.toString(),
78
- },
79
- reserve1: {
80
- token: {
81
- chainId: reserve1.currency.wrapped.chainId,
82
- decimals: reserve1.currency.wrapped.decimals,
83
- address: reserve1.currency.wrapped.address,
84
- symbol: reserve1.currency.wrapped.symbol,
85
- },
86
- quotient: reserve1.quotient.toString(),
87
- },
88
- amountIn: edgeAmountIn,
89
- amountOut: edgeAmountOut,
90
- });
91
- }
92
- }
93
- routeResponse.push(curRoute);
94
- }
95
- const result = {
96
- methodParameters,
97
- blockNumber: blockNumber.toString(),
98
- amount: amount.quotient.toString(),
99
- amountDecimals: amount.toExact(),
100
- quote: quote.quotient.toString(),
101
- quoteDecimals: quote.toExact(),
102
- quoteGasAdjusted: quoteGasAdjusted.quotient.toString(),
103
- quoteGasAdjustedDecimals: quoteGasAdjusted.toExact(),
104
- gasUseEstimateQuote: estimatedGasUsedQuoteToken.quotient.toString(),
105
- gasUseEstimateQuoteDecimals: estimatedGasUsedQuoteToken.toExact(),
106
- gasUseEstimate: estimatedGasUsed.toString(),
107
- gasUseEstimateUSD: estimatedGasUsedUSD.toExact(),
108
- gasPriceWei: gasPriceWei.toString(),
109
- route: routeResponse,
110
- routeString: (0, smart_order_router_1.routeAmountsToString)(route),
111
- };
112
- return { state: types_1.QuoteState.SUCCESS, data: { routing: types_1.URAQuoteType.CLASSIC, quote: result, allQuotes: [] } };
113
- }
@@ -1,21 +0,0 @@
1
- import { MixedRouteTrade, Trade as RouterTrade } from '@uniswap/router-sdk';
2
- import { Trade as V2Trade, Pair } from '@uniswap/v2-sdk';
3
- import { Trade as V3Trade, Pool, FeeAmount } from '@uniswap/v3-sdk';
4
- import { TradeType, Token, Currency } from '@uniswap/sdk-core';
5
- export declare const ETHER: any;
6
- export declare const WETH: any;
7
- export declare const DAI: any;
8
- export declare const USDC: any;
9
- export declare const FEE_AMOUNT: any;
10
- type UniswapPools = {
11
- WETH_USDC_V2: Pair;
12
- USDC_DAI_V2: Pair;
13
- WETH_USDC_V3: Pool;
14
- WETH_USDC_V3_LOW_FEE: Pool;
15
- USDC_DAI_V3: Pool;
16
- };
17
- export declare function getUniswapPools(forkBlock?: number): Promise<UniswapPools>;
18
- export declare function getPair(tokenA: Token, tokenB: Token, blockNumber: number): Promise<Pair>;
19
- export declare function getPool(tokenA: Token, tokenB: Token, feeAmount: FeeAmount, blockNumber: number): Promise<Pool>;
20
- export declare function buildTrade(trades: (V2Trade<Currency, Currency, TradeType> | V3Trade<Currency, Currency, TradeType> | MixedRouteTrade<Currency, Currency, TradeType>)[]): RouterTrade<Currency, Currency, TradeType>;
21
- export {};
@@ -1,139 +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.FEE_AMOUNT = exports.USDC = exports.DAI = exports.WETH = exports.ETHER = void 0;
7
- exports.getUniswapPools = getUniswapPools;
8
- exports.getPair = getPair;
9
- exports.getPool = getPool;
10
- exports.buildTrade = buildTrade;
11
- const jsbi_1 = __importDefault(require("jsbi"));
12
- const ethers_1 = require("ethers");
13
- const router_sdk_1 = require("@uniswap/router-sdk");
14
- const v2_sdk_1 = require("@uniswap/v2-sdk");
15
- const v3_sdk_1 = require("@uniswap/v3-sdk");
16
- // import { SwapOptions } from '../../src'
17
- const sdk_core_1 = require("@uniswap/sdk-core");
18
- const UniswapV3Pool_json_1 = __importDefault(require("@uniswap/v3-core/artifacts/contracts/UniswapV3Pool.sol/UniswapV3Pool.json"));
19
- // import { TEST_RECIPIENT_ADDRESS } from './addresses'
20
- const V2_FACTORY = '0x5C69bEe701ef814a2B6a3EDD4B1652CB9cc5aA6f';
21
- const V2_ABI = [
22
- {
23
- constant: true,
24
- inputs: [],
25
- name: 'getReserves',
26
- outputs: [
27
- {
28
- internalType: 'uint112',
29
- name: 'reserve0',
30
- type: 'uint112',
31
- },
32
- {
33
- internalType: 'uint112',
34
- name: 'reserve1',
35
- type: 'uint112',
36
- },
37
- {
38
- internalType: 'uint32',
39
- name: 'blockTimestampLast',
40
- type: 'uint32',
41
- },
42
- ],
43
- payable: false,
44
- stateMutability: 'view',
45
- type: 'function',
46
- },
47
- ];
48
- const FORK_BLOCK = 16075500;
49
- exports.ETHER = sdk_core_1.Ether.onChain(1);
50
- exports.WETH = new sdk_core_1.Token(1, '0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2', 18, 'WETH', 'Wrapped Ether');
51
- exports.DAI = new sdk_core_1.Token(1, '0x6B175474E89094C44Da98b954EedeAC495271d0F', 18, 'DAI', 'dai');
52
- exports.USDC = new sdk_core_1.Token(1, '0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48', 6, 'USDC', 'USD Coin');
53
- exports.FEE_AMOUNT = v3_sdk_1.FeeAmount.MEDIUM;
54
- async function getUniswapPools(forkBlock) {
55
- const fork = forkBlock ?? FORK_BLOCK;
56
- const WETH_USDC_V2 = await getPair(exports.WETH, exports.USDC, fork);
57
- const USDC_DAI_V2 = await getPair(exports.USDC, exports.DAI, fork);
58
- const WETH_USDC_V3 = await getPool(exports.WETH, exports.USDC, exports.FEE_AMOUNT, fork);
59
- const WETH_USDC_V3_LOW_FEE = await getPool(exports.WETH, exports.USDC, v3_sdk_1.FeeAmount.LOW, fork);
60
- const USDC_DAI_V3 = await getPool(exports.USDC, exports.DAI, v3_sdk_1.FeeAmount.LOW, fork);
61
- return {
62
- WETH_USDC_V2,
63
- USDC_DAI_V2,
64
- WETH_USDC_V3,
65
- WETH_USDC_V3_LOW_FEE,
66
- USDC_DAI_V3,
67
- };
68
- }
69
- function getProvider() {
70
- return new ethers_1.ethers.providers.JsonRpcProvider(process.env['FORK_URL']);
71
- }
72
- async function getPair(tokenA, tokenB, blockNumber) {
73
- const pairAddress = (0, v2_sdk_1.computePairAddress)({ factoryAddress: V2_FACTORY, tokenA, tokenB });
74
- const contract = new ethers_1.ethers.Contract(pairAddress, V2_ABI, getProvider());
75
- const { reserve0, reserve1 } = await contract.getReserves({ blockTag: blockNumber });
76
- const [token0, token1] = tokenA.sortsBefore(tokenB) ? [tokenA, tokenB] : [tokenB, tokenA]; // does safety checks
77
- return new v2_sdk_1.Pair(sdk_core_1.CurrencyAmount.fromRawAmount(token0, reserve0), sdk_core_1.CurrencyAmount.fromRawAmount(token1, reserve1));
78
- }
79
- async function getPool(tokenA, tokenB, feeAmount, blockNumber) {
80
- const [token0, token1] = tokenA.sortsBefore(tokenB) ? [tokenA, tokenB] : [tokenB, tokenA]; // does safety checks
81
- const poolAddress = v3_sdk_1.Pool.getAddress(token0, token1, feeAmount);
82
- const contract = new ethers_1.ethers.Contract(poolAddress, UniswapV3Pool_json_1.default.abi, getProvider());
83
- let liquidity = await contract.liquidity({ blockTag: blockNumber });
84
- let { sqrtPriceX96, tick } = await contract.slot0({ blockTag: blockNumber });
85
- liquidity = jsbi_1.default.BigInt(liquidity.toString());
86
- sqrtPriceX96 = jsbi_1.default.BigInt(sqrtPriceX96.toString());
87
- return new v3_sdk_1.Pool(token0, token1, feeAmount, sqrtPriceX96, liquidity, tick, [
88
- {
89
- index: (0, v3_sdk_1.nearestUsableTick)(v3_sdk_1.TickMath.MIN_TICK, v3_sdk_1.TICK_SPACINGS[feeAmount]),
90
- liquidityNet: liquidity,
91
- liquidityGross: liquidity,
92
- },
93
- {
94
- index: (0, v3_sdk_1.nearestUsableTick)(v3_sdk_1.TickMath.MAX_TICK, v3_sdk_1.TICK_SPACINGS[feeAmount]),
95
- liquidityNet: jsbi_1.default.multiply(liquidity, jsbi_1.default.BigInt('-1')),
96
- liquidityGross: liquidity,
97
- },
98
- ]);
99
- }
100
- // use some sane defaults
101
- // export function swapOptions(options: Partial<SwapOptions>): SwapOptions {
102
- // // If theres a fee this counts as "slippage" for the amount out, so take it into account
103
- // let slippageTolerance = new Percent(5, 100)
104
- // if (!!options.fee) slippageTolerance = slippageTolerance.add(options.fee.fee)
105
- // return Object.assign(
106
- // {
107
- // slippageTolerance,
108
- // recipient: TEST_RECIPIENT_ADDRESS,
109
- // },
110
- // options
111
- // )
112
- // }
113
- // alternative constructor to create from protocol-specific sdks
114
- function buildTrade(trades) {
115
- return new router_sdk_1.Trade({
116
- v2Routes: trades
117
- .filter((trade) => trade instanceof v2_sdk_1.Trade)
118
- .map((trade) => ({
119
- routev2: trade.route,
120
- inputAmount: trade.inputAmount,
121
- outputAmount: trade.outputAmount,
122
- })),
123
- v3Routes: trades
124
- .filter((trade) => trade instanceof v3_sdk_1.Trade)
125
- .map((trade) => ({
126
- routev3: trade.route,
127
- inputAmount: trade.inputAmount,
128
- outputAmount: trade.outputAmount,
129
- })),
130
- mixedRoutes: trades
131
- .filter((trade) => trade instanceof router_sdk_1.MixedRouteTrade)
132
- .map((trade) => ({
133
- mixedRoute: trade.route,
134
- inputAmount: trade.inputAmount,
135
- outputAmount: trade.outputAmount,
136
- })),
137
- tradeType: trades[0].tradeType,
138
- });
139
- }