@0x/asset-swapper: Special case two-hop quotes in getMinBuyAmount()

This commit is contained in:
Lawrence Forman 2020-09-23 16:52:09 -04:00
parent 6138955f93
commit 4cf566cad8

View File

@ -16,7 +16,7 @@ export function getMinBuyAmount(quote: SwapQuote): BigNumber {
quote.type === MarketOperation.Sell
? BigNumber.sum(...quote.orders.map(o => BigNumber.sum(0, ...o.fills.map(f => f.output))))
: BigNumber.sum(...quote.orders.map(o => BigNumber.sum(0, ...o.fills.map(f => f.input))));
if (totalFillMakerAssetAmount.eq(0)) {
if (quote.isTwoHop || totalFillMakerAssetAmount.eq(0)) {
return quote.worstCaseQuoteInfo.makerAssetAmount;
}
if (totalOrderMakerAssetAmount.eq(totalFillMakerAssetAmount)) {