From 3ef5de93bb715671b9736213febb789d63aaea48 Mon Sep 17 00:00:00 2001 From: Kyu Date: Thu, 28 Jul 2022 09:26:07 -0700 Subject: [PATCH] Remove `getBidAskLiquidityForMakerTakerAssetPairAsync` (#528) --- packages/asset-swapper/src/index.ts | 2 - packages/asset-swapper/src/swap_quoter.ts | 64 ------------------- .../src/utils/market_operation_utils/types.ts | 9 --- 3 files changed, 75 deletions(-) diff --git a/packages/asset-swapper/src/index.ts b/packages/asset-swapper/src/index.ts index a9f56cb9d8..7f1dc8fe78 100644 --- a/packages/asset-swapper/src/index.ts +++ b/packages/asset-swapper/src/index.ts @@ -157,8 +157,6 @@ export { GetMarketOrdersRfqOpts, LiquidityProviderFillData, LiquidityProviderRegistry, - MarketDepth, - MarketDepthSide, MooniswapFillData, MultiHopFillData, NativeRfqOrderFillData, diff --git a/packages/asset-swapper/src/swap_quoter.ts b/packages/asset-swapper/src/swap_quoter.ts index 1d1b88a8b7..67eb9891ce 100644 --- a/packages/asset-swapper/src/swap_quoter.ts +++ b/packages/asset-swapper/src/swap_quoter.ts @@ -36,9 +36,6 @@ import { FillData, GasSchedule, GetMarketOrdersOpts, - MarketDepth, - MarketDepthSide, - MarketSideLiquidity, OptimizedMarketOrder, OptimizerResultWithReport, } from './utils/market_operation_utils/types'; @@ -228,67 +225,6 @@ export class SwapQuoter { return batchSwapQuotes.filter(x => x !== undefined) as MarketBuySwapQuote[]; } - /** - * Returns the bids and asks liquidity for the entire market. - * For certain sources (like AMM's) it is recommended to provide a practical maximum takerAssetAmount. - * @param makerTokenAddress The address of the maker asset - * @param takerTokenAddress The address of the taker asset - * @param takerAssetAmount The amount to sell and buy for the bids and asks. - * - * @return An object that conforms to MarketDepth that contains all of the samples and liquidity - * information for the source. - */ - public async getBidAskLiquidityForMakerTakerAssetPairAsync( - makerToken: string, - takerToken: string, - takerAssetAmount: BigNumber, - options: Partial = {}, - ): Promise { - assert.isString('makerToken', makerToken); - assert.isString('takerToken', takerToken); - const sourceFilters = new SourceFilters([], options.excludedSources, options.includedSources); - - let [sellOrders, buyOrders] = !sourceFilters.isAllowed(ERC20BridgeSource.Native) - ? [[], []] - : await Promise.all([ - this.orderbook.getOrdersAsync(makerToken, takerToken), - this.orderbook.getOrdersAsync(takerToken, makerToken), - ]); - if (!sellOrders || sellOrders.length === 0) { - sellOrders = [createDummyOrder(makerToken, takerToken)]; - } - if (!buyOrders || buyOrders.length === 0) { - buyOrders = [createDummyOrder(takerToken, makerToken)]; - } - - const getMarketDepthSide = (marketSideLiquidity: MarketSideLiquidity): MarketDepthSide => { - const { dexQuotes, nativeOrders } = marketSideLiquidity.quotes; - const { side } = marketSideLiquidity; - - return [ - ...dexQuotes, - nativeOrders.map(o => { - return { - input: side === MarketOperation.Sell ? o.fillableTakerAmount : o.fillableMakerAmount, - output: side === MarketOperation.Sell ? o.fillableMakerAmount : o.fillableTakerAmount, - fillData: o, - source: ERC20BridgeSource.Native, - }; - }), - ]; - }; - const [bids, asks] = await Promise.all([ - this._marketOperationUtils.getMarketBuyLiquidityAsync(buyOrders, takerAssetAmount, options), - this._marketOperationUtils.getMarketSellLiquidityAsync(sellOrders, takerAssetAmount, options), - ]); - return { - bids: getMarketDepthSide(bids), - asks: getMarketDepthSide(asks), - makerTokenDecimals: asks.makerTokenDecimals, - takerTokenDecimals: asks.takerTokenDecimals, - }; - } - /** * Returns the recommended gas price for a fast transaction */ 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 f30961eed9..3504b0d899 100644 --- a/packages/asset-swapper/src/utils/market_operation_utils/types.ts +++ b/packages/asset-swapper/src/utils/market_operation_utils/types.ts @@ -617,15 +617,6 @@ export interface OptimizerResultWithReport extends OptimizerResult { priceComparisonsReport?: PriceComparisonsReport; } -export type MarketDepthSide = Array>>; - -export interface MarketDepth { - bids: MarketDepthSide; - asks: MarketDepthSide; - makerTokenDecimals: number; - takerTokenDecimals: number; -} - export interface MarketSideLiquidity { side: MarketOperation; inputAmount: BigNumber;