linting and remove unused function

This commit is contained in:
Steve Klebanoff 2020-07-08 15:49:42 -07:00
parent 615874d2ec
commit 120714ecfc
No known key found for this signature in database
GPG Key ID: 8A2D7E51E87DB8B9
8 changed files with 40 additions and 30 deletions

View File

@ -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 : [];
}

View File

@ -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.

View File

@ -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 };
}

View File

@ -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 {

View File

@ -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) {

View File

@ -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}`,
);
}

View File

@ -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';

View File

@ -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,