Skip to content
This repository has been archived by the owner on Jul 9, 2021. It is now read-only.

Commit

Permalink
Merge pull request #2583 from 0xProject/feat/estimated-gas-token-refund
Browse files Browse the repository at this point in the history
Expose fills object in asset-swapper quote orders
  • Loading branch information
Francesco Agosti authored May 20, 2020
2 parents d9e13d6 + f694072 commit b23f1eb
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ def __init__(
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 == (
Expand Down
4 changes: 4 additions & 0 deletions packages/asset-swapper/CHANGELOG.json
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
]
},
Expand Down
6 changes: 3 additions & 3 deletions packages/asset-swapper/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';

/**
Expand Down Expand Up @@ -132,15 +132,15 @@ 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.
*/
export interface SwapQuoteBase {
takerAssetData: string;
makerAssetData: string;
gasPrice: BigNumber;
orders: SignedOrder[];
orders: OptimizedMarketOrder[];
bestCaseQuoteInfo: SwapQuoteInfo;
worstCaseQuoteInfo: SwapQuoteInfo;
sourceBreakdown: SwapQuoteOrdersBreakdown;
Expand Down
4 changes: 1 addition & 3 deletions packages/asset-swapper/src/utils/swap_quote_calculator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import {
MarketBuySwapQuote,
MarketOperation,
MarketSellSwapQuote,
SignedOrderWithFillableAmounts,
SwapQuote,
SwapQuoteBase,
SwapQuoteInfo,
Expand Down Expand Up @@ -200,8 +199,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) {
Expand Down
2 changes: 1 addition & 1 deletion packages/asset-swapper/test/utils/swap_quote.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ export async function getFullyFillableSwapQuoteWithNoFeesAsync(
const quoteBase = {
makerAssetData,
takerAssetData,
orders,
orders: orders.map(order => ({ ...order, fills: [] })),
gasPrice,
bestCaseQuoteInfo: quoteInfo,
worstCaseQuoteInfo: quoteInfo,
Expand Down

0 comments on commit b23f1eb

Please sign in to comment.