From 5226bb5596543d47b1e966d76a3d75f538c556bc Mon Sep 17 00:00:00 2001 From: fragosti Date: Wed, 20 May 2020 12:50:15 -0700 Subject: [PATCH 1/5] Expose fills in asset-swapper quote --- .../abi-gen/test-cli/output/python/lib_dummy/__init__.py | 2 +- packages/asset-swapper/src/types.ts | 6 +++--- packages/asset-swapper/src/utils/swap_quote_calculator.ts | 4 ++-- packages/asset-swapper/test/utils/swap_quote.ts | 2 +- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/packages/abi-gen/test-cli/output/python/lib_dummy/__init__.py b/packages/abi-gen/test-cli/output/python/lib_dummy/__init__.py index 12e96c147f..6c1375710e 100644 --- a/packages/abi-gen/test-cli/output/python/lib_dummy/__init__.py +++ b/packages/abi-gen/test-cli/output/python/lib_dummy/__init__.py @@ -90,7 +90,7 @@ class LibDummy: try: for middleware in MIDDLEWARE: web3.middleware_onion.inject( - middleware["function"], layer=middleware["layer"], + middleware["function"], layer=middleware["layer"] ) except ValueError as value_error: if value_error.args == ( diff --git a/packages/asset-swapper/src/types.ts b/packages/asset-swapper/src/types.ts index f08de9d704..5ba75c7487 100644 --- a/packages/asset-swapper/src/types.ts +++ b/packages/asset-swapper/src/types.ts @@ -2,7 +2,7 @@ import { ContractAddresses } from '@0x/contract-wrappers'; import { SignedOrder } from '@0x/types'; import { BigNumber } from '@0x/utils'; -import { GetMarketOrdersOpts } from './utils/market_operation_utils/types'; +import { GetMarketOrdersOpts, OptimizedMarketOrder } from './utils/market_operation_utils/types'; import { LogFunction } from './utils/quote_requestor'; /** @@ -132,7 +132,7 @@ export interface GetExtensionContractTypeOpts { * takerAssetData: String that represents a specific taker asset (for more info: https://github.com/0xProject/0x-protocol-specification/blob/master/v2/v2-specification.md). * makerAssetData: String that represents a specific maker asset (for more info: https://github.com/0xProject/0x-protocol-specification/blob/master/v2/v2-specification.md). * gasPrice: gas price used to determine protocolFee amount, default to ethGasStation fast amount. - * orders: An array of objects conforming to SignedOrder. These orders can be used to cover the requested assetBuyAmount plus slippage. + * orders: An array of objects conforming to OptimizedMarketOrder. These orders can be used to cover the requested assetBuyAmount plus slippage. * bestCaseQuoteInfo: Info about the best case price for the asset. * worstCaseQuoteInfo: Info about the worst case price for the asset. */ @@ -140,7 +140,7 @@ export interface SwapQuoteBase { takerAssetData: string; makerAssetData: string; gasPrice: BigNumber; - orders: SignedOrder[]; + orders: OptimizedMarketOrder[]; bestCaseQuoteInfo: SwapQuoteInfo; worstCaseQuoteInfo: SwapQuoteInfo; sourceBreakdown: SwapQuoteOrdersBreakdown; diff --git a/packages/asset-swapper/src/utils/swap_quote_calculator.ts b/packages/asset-swapper/src/utils/swap_quote_calculator.ts index 7ce60afbbc..f1f42d08b8 100644 --- a/packages/asset-swapper/src/utils/swap_quote_calculator.ts +++ b/packages/asset-swapper/src/utils/swap_quote_calculator.ts @@ -176,6 +176,7 @@ function createSwapQuote( assetFillAmount: BigNumber, gasPrice: BigNumber, gasSchedule: { [source: string]: number }, + gasTokenSupply: BigNumber = new BigNumber(10000000000000000000000), ): SwapQuote { const bestCaseFillResult = simulateBestCaseFill({ gasPrice, @@ -200,8 +201,7 @@ function createSwapQuote( bestCaseQuoteInfo: fillResultsToQuoteInfo(bestCaseFillResult), worstCaseQuoteInfo: fillResultsToQuoteInfo(worstCaseFillResult), sourceBreakdown: getSwapQuoteOrdersBreakdown(bestCaseFillResult.fillAmountBySource), - // Remove fill metadata. - orders: resultOrders.map(o => _.omit(o, 'fills')) as SignedOrderWithFillableAmounts[], + orders: resultOrders, }; if (operation === MarketOperation.Buy) { diff --git a/packages/asset-swapper/test/utils/swap_quote.ts b/packages/asset-swapper/test/utils/swap_quote.ts index de3bde6e72..dcaca4491f 100644 --- a/packages/asset-swapper/test/utils/swap_quote.ts +++ b/packages/asset-swapper/test/utils/swap_quote.ts @@ -34,7 +34,7 @@ export async function getFullyFillableSwapQuoteWithNoFeesAsync( const quoteBase = { makerAssetData, takerAssetData, - orders, + orders: orders.map(order => ({...order, fills: [] })), gasPrice, bestCaseQuoteInfo: quoteInfo, worstCaseQuoteInfo: quoteInfo, From e9638ef95e3bb39dcc8151c296ef3964c6c3cd82 Mon Sep 17 00:00:00 2001 From: fragosti Date: Wed, 20 May 2020 12:52:35 -0700 Subject: [PATCH 2/5] Add to changelog --- packages/asset-swapper/CHANGELOG.json | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/packages/asset-swapper/CHANGELOG.json b/packages/asset-swapper/CHANGELOG.json index d7ac3735e3..7ac8dc03f5 100644 --- a/packages/asset-swapper/CHANGELOG.json +++ b/packages/asset-swapper/CHANGELOG.json @@ -69,6 +69,10 @@ { "note": "Remove Kyber exclusion when Uniswap/Eth2Dai is present", "pr": 2575 + }, + { + "note": "Expose fills object in asset-swapper quote orders", + "pr": 2583 } ] }, From 71811ed04fdeb265827f7f215d4d0bed5b49e22d Mon Sep 17 00:00:00 2001 From: fragosti Date: Wed, 20 May 2020 12:53:58 -0700 Subject: [PATCH 3/5] Remove unused variable --- packages/asset-swapper/src/utils/swap_quote_calculator.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/packages/asset-swapper/src/utils/swap_quote_calculator.ts b/packages/asset-swapper/src/utils/swap_quote_calculator.ts index f1f42d08b8..cf3a91215e 100644 --- a/packages/asset-swapper/src/utils/swap_quote_calculator.ts +++ b/packages/asset-swapper/src/utils/swap_quote_calculator.ts @@ -176,7 +176,6 @@ function createSwapQuote( assetFillAmount: BigNumber, gasPrice: BigNumber, gasSchedule: { [source: string]: number }, - gasTokenSupply: BigNumber = new BigNumber(10000000000000000000000), ): SwapQuote { const bestCaseFillResult = simulateBestCaseFill({ gasPrice, From 10de266e0f436aba7f94bf4581363df218bb6fd5 Mon Sep 17 00:00:00 2001 From: fragosti Date: Wed, 20 May 2020 13:13:01 -0700 Subject: [PATCH 4/5] Remove unused variable SignedOrderWithFillableAmounts --- packages/asset-swapper/src/utils/swap_quote_calculator.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/packages/asset-swapper/src/utils/swap_quote_calculator.ts b/packages/asset-swapper/src/utils/swap_quote_calculator.ts index cf3a91215e..ffa5d2aaa7 100644 --- a/packages/asset-swapper/src/utils/swap_quote_calculator.ts +++ b/packages/asset-swapper/src/utils/swap_quote_calculator.ts @@ -8,7 +8,6 @@ import { MarketBuySwapQuote, MarketOperation, MarketSellSwapQuote, - SignedOrderWithFillableAmounts, SwapQuote, SwapQuoteBase, SwapQuoteInfo, From f694072b5a238ee9ba6901fdd3f139232c17c8e9 Mon Sep 17 00:00:00 2001 From: fragosti Date: Wed, 20 May 2020 14:20:54 -0700 Subject: [PATCH 5/5] Run prettier --- packages/asset-swapper/test/utils/swap_quote.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/asset-swapper/test/utils/swap_quote.ts b/packages/asset-swapper/test/utils/swap_quote.ts index dcaca4491f..2f8838e3aa 100644 --- a/packages/asset-swapper/test/utils/swap_quote.ts +++ b/packages/asset-swapper/test/utils/swap_quote.ts @@ -34,7 +34,7 @@ export async function getFullyFillableSwapQuoteWithNoFeesAsync( const quoteBase = { makerAssetData, takerAssetData, - orders: orders.map(order => ({...order, fills: [] })), + orders: orders.map(order => ({ ...order, fills: [] })), gasPrice, bestCaseQuoteInfo: quoteInfo, worstCaseQuoteInfo: quoteInfo,