From 120714ecfc9ed931e80bd86bae702ca5999163f7 Mon Sep 17 00:00:00 2001 From: Steve Klebanoff Date: Wed, 8 Jul 2020 15:49:42 -0700 Subject: [PATCH] linting and remove unused function --- packages/asset-swapper/src/swap_quoter.ts | 9 --------- packages/asset-swapper/src/types.ts | 2 +- .../src/utils/market_operation_utils/index.ts | 13 ++++++++++--- .../src/utils/market_operation_utils/types.ts | 2 +- .../src/utils/quote_report_generator.ts | 16 ++++++++++------ .../asset-swapper/src/utils/quote_requestor.ts | 15 ++++++++++----- .../src/utils/swap_quote_calculator.ts | 7 +++++-- .../test/market_operation_utils_test.ts | 6 +++--- 8 files changed, 40 insertions(+), 30 deletions(-) diff --git a/packages/asset-swapper/src/swap_quoter.ts b/packages/asset-swapper/src/swap_quoter.ts index 4e76ef686b..cc82bfc307 100644 --- a/packages/asset-swapper/src/swap_quoter.ts +++ b/packages/asset-swapper/src/swap_quoter.ts @@ -610,15 +610,6 @@ export class SwapQuoter { return swapQuote; } - private _shouldEnableIndicativeRfqt(opts: CalculateSwapQuoteOpts['rfqt'], op: MarketOperation): boolean { - return ( - opts !== undefined && - opts.isIndicative !== undefined && - opts.isIndicative && - this._rfqtTakerApiKeyWhitelist().includes(opts.apiKey) && - !(op === MarketOperation.Buy && this._shouldSkipRfqtBuyRequests()) - ); - } private _rfqtTakerApiKeyWhitelist(): string[] { return this._rfqtOptions ? this._rfqtOptions.takerApiKeyWhitelist : []; } diff --git a/packages/asset-swapper/src/types.ts b/packages/asset-swapper/src/types.ts index a5dfb17a3d..15975433dd 100644 --- a/packages/asset-swapper/src/types.ts +++ b/packages/asset-swapper/src/types.ts @@ -220,7 +220,7 @@ export interface SwapQuoteRequestOpts extends CalculateSwapQuoteOpts { /** * Opts required to generate a SwapQuote with SwapQuoteCalculator */ -export interface CalculateSwapQuoteOpts extends GetMarketOrdersOpts { } +export interface CalculateSwapQuoteOpts extends GetMarketOrdersOpts {} /** * A mapping from RFQ-T quote provider URLs to the trading pairs they support. diff --git a/packages/asset-swapper/src/utils/market_operation_utils/index.ts b/packages/asset-swapper/src/utils/market_operation_utils/index.ts index 6ed304ff85..4238aa5021 100644 --- a/packages/asset-swapper/src/utils/market_operation_utils/index.ts +++ b/packages/asset-swapper/src/utils/market_operation_utils/index.ts @@ -381,8 +381,8 @@ export class MarketOperationUtils { const [last, penultimateIfExists] = optimalPath.slice().reverse(); const lastNativeFillIfExists = last.source === ERC20BridgeSource.Native && - penultimateIfExists && - penultimateIfExists.source !== ERC20BridgeSource.Native + penultimateIfExists && + penultimateIfExists.source !== ERC20BridgeSource.Native ? last : undefined; // By prepending native paths to the front they cannot split on-chain sources and incur @@ -402,7 +402,14 @@ export class MarketOperationUtils { multiBridgeAddress: opts.multiBridgeAddress, shouldBatchBridgeOrders: !!opts.shouldBatchBridgeOrders, }); - const quoteReport = new QuoteReportGenerator(opts.side, _.flatten(opts.dexQuotes), opts.nativeOrders, opts.orderFillableAmounts, _.flatten(optimizedOrders.map(o => o.fills)), opts.quoteRequestor).generateReport(); + const quoteReport = new QuoteReportGenerator( + opts.side, + _.flatten(opts.dexQuotes), + opts.nativeOrders, + opts.orderFillableAmounts, + _.flatten(optimizedOrders.map(o => o.fills)), + opts.quoteRequestor, + ).generateReport(); return { optimizedOrders, quoteReport }; } diff --git a/packages/asset-swapper/src/utils/market_operation_utils/types.ts b/packages/asset-swapper/src/utils/market_operation_utils/types.ts index d08756b94d..1a05c8fad5 100644 --- a/packages/asset-swapper/src/utils/market_operation_utils/types.ts +++ b/packages/asset-swapper/src/utils/market_operation_utils/types.ts @@ -43,7 +43,7 @@ export enum ERC20BridgeSource { } // Internal `fillData` field for `Fill` objects. -export interface FillData { } +export interface FillData {} // `FillData` for native fills. export interface NativeFillData extends FillData { diff --git a/packages/asset-swapper/src/utils/quote_report_generator.ts b/packages/asset-swapper/src/utils/quote_report_generator.ts index 773916a8e4..88b8711a7e 100644 --- a/packages/asset-swapper/src/utils/quote_report_generator.ts +++ b/packages/asset-swapper/src/utils/quote_report_generator.ts @@ -1,5 +1,5 @@ import { orderHashUtils } from '@0x/order-utils'; -import { BigNumber, NULL_ADDRESS } from '@0x/utils'; +import { BigNumber } from '@0x/utils'; import * as _ from 'lodash'; import { ERC20BridgeSource, SignedOrder } from '..'; @@ -44,7 +44,14 @@ export class QuoteReportGenerator { private readonly _collapsedFills: CollapsedFill[]; private readonly _quoteRequestor?: QuoteRequestor; - constructor(marketOperation: MarketOperation, dexQuotes: DexSample[], nativeOrders: SignedOrder[], orderFillableAmounts: BigNumber[], collapsedFills: CollapsedFill[], quoteRequestor?: QuoteRequestor) { + constructor( + marketOperation: MarketOperation, + dexQuotes: DexSample[], + nativeOrders: SignedOrder[], + orderFillableAmounts: BigNumber[], + collapsedFills: CollapsedFill[], + quoteRequestor?: QuoteRequestor, + ) { this._dexQuotes = dexQuotes; this._nativeOrders = nativeOrders; this._marketOperation = marketOperation; @@ -68,10 +75,7 @@ export class QuoteReportGenerator { const dexReportSourcesConsidered = this._dexQuotes.map(ds => this._dexSampleToReportSource(ds)); const nativeOrderSourcesConsidered = this._nativeOrders.map(no => this._nativeOrderToReportSource(no)); - const sourcesConsidered = [ - ...dexReportSourcesConsidered, - ...nativeOrderSourcesConsidered, - ]; + const sourcesConsidered = [...dexReportSourcesConsidered, ...nativeOrderSourcesConsidered]; const sourcesDelivered = this._collapsedFills.map(collapsedFill => { const foundNativeOrder = (collapsedFill as NativeCollapsedFill).nativeOrder; if (foundNativeOrder) { diff --git a/packages/asset-swapper/src/utils/quote_requestor.ts b/packages/asset-swapper/src/utils/quote_requestor.ts index 6430064c8f..90dec24245 100644 --- a/packages/asset-swapper/src/utils/quote_requestor.ts +++ b/packages/asset-swapper/src/utils/quote_requestor.ts @@ -1,9 +1,9 @@ import { schemas, SchemaValidator } from '@0x/json-schemas'; -import { assetDataUtils, orderCalculationUtils, SignedOrder, orderHashUtils } from '@0x/order-utils'; +import { assetDataUtils, orderCalculationUtils, orderHashUtils, SignedOrder } from '@0x/order-utils'; import { RFQTFirmQuote, RFQTIndicativeQuote, TakerRequest } from '@0x/quote-server'; import { ERC20AssetData } from '@0x/types'; import { BigNumber, logUtils } from '@0x/utils'; -import Axios, { AxiosResponse } from 'axios'; +import Axios from 'axios'; import { constants } from '../constants'; import { MarketOperation, RfqtMakerAssetOfferings, RfqtRequestOpts } from '../types'; @@ -94,7 +94,7 @@ export class QuoteRequestor { private readonly _infoLogger: LogFunction = (obj, msg) => logUtils.log(`${msg ? `${msg}: ` : ''}${JSON.stringify(obj)}`), private readonly _expiryBufferMs: number = constants.DEFAULT_SWAP_QUOTER_OPTS.expiryBufferMs, - ) { } + ) {} public async requestRfqtFirmQuotesAsync( makerAssetData: string, @@ -156,7 +156,12 @@ export class QuoteRequestor { salt: new BigNumber(orderWithStringInts.salt), }; - if (orderCalculationUtils.willOrderExpire(orderWithBigNumberInts, this._expiryBufferMs / constants.ONE_SECOND_MS)) { + if ( + orderCalculationUtils.willOrderExpire( + orderWithBigNumberInts, + this._expiryBufferMs / constants.ONE_SECOND_MS, + ) + ) { this._warningLogger(orderWithBigNumberInts, 'Expiry too soon in RFQ-T order, filtering out'); return; } @@ -353,7 +358,7 @@ export class QuoteRequestor { this._warningLogger( convertIfAxiosError(err), `Failed to get RFQ-T ${quoteType} quote from market maker endpoint ${url} for API key ${ - options.apiKey + options.apiKey } for taker address ${options.takerAddress}`, ); } diff --git a/packages/asset-swapper/src/utils/swap_quote_calculator.ts b/packages/asset-swapper/src/utils/swap_quote_calculator.ts index c498a6873c..232dbb75d9 100644 --- a/packages/asset-swapper/src/utils/swap_quote_calculator.ts +++ b/packages/asset-swapper/src/utils/swap_quote_calculator.ts @@ -9,7 +9,6 @@ import { MarketOperation, MarketSellSwapQuote, SwapQuote, - SwapQuoteBase, SwapQuoteInfo, SwapQuoteOrdersBreakdown, SwapQuoterError, @@ -17,7 +16,11 @@ import { import { MarketOperationUtils } from './market_operation_utils'; import { convertNativeOrderToFullyFillableOptimizedOrders } from './market_operation_utils/orders'; -import { GetMarketOrdersOpts, OptimizedMarketOrder, OptimizedOrdersAndQuoteReport } from './market_operation_utils/types'; +import { + GetMarketOrdersOpts, + OptimizedMarketOrder, + OptimizedOrdersAndQuoteReport, +} from './market_operation_utils/types'; import { isSupportedAssetDataInOrders } from './utils'; import { QuoteReport } from './quote_report_generator'; diff --git a/packages/asset-swapper/test/market_operation_utils_test.ts b/packages/asset-swapper/test/market_operation_utils_test.ts index 8a7b285282..e0e3841f0d 100644 --- a/packages/asset-swapper/test/market_operation_utils_test.ts +++ b/packages/asset-swapper/test/market_operation_utils_test.ts @@ -248,9 +248,9 @@ describe('MarketOperationUtils tests', () => { function getLiquidityProviderFromRegistryAndReturnCallParameters( liquidityProviderAddress: string = NULL_ADDRESS, ): [ - { registryAddress?: string; takerToken?: string; makerToken?: string }, - GetLiquidityProviderFromRegistryOperation - ] { + { registryAddress?: string; takerToken?: string; makerToken?: string }, + GetLiquidityProviderFromRegistryOperation + ] { const callArgs: { registryAddress?: string; takerToken?: string; makerToken?: string } = { registryAddress: undefined, takerToken: undefined,