fix: asset-swapper depth buy scale (#2659)

This commit is contained in:
Jacob Evans 2020-08-09 16:38:59 +10:00 committed by GitHub
parent c03f1586e6
commit 71cde281b9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 1 deletions

View File

@ -37,6 +37,10 @@
{ {
"note": "Fix optimization of buy paths", "note": "Fix optimization of buy paths",
"pr": 2655 "pr": 2655
},
{
"note": "Fix depth buy scale",
"pr": 2659
} }
] ]
}, },

View File

@ -454,7 +454,11 @@ export class SwapQuoter {
return [ return [
...dexQuotes, ...dexQuotes,
nativeOrders.map((o, i) => { nativeOrders.map((o, i) => {
const scaleFactor = orderFillableAmounts[i].div(o.takerAssetAmount); // When sell order fillable amount is taker
// When buy order fillable amount is maker
const scaleFactor = orderFillableAmounts[i].div(
side === MarketOperation.Sell ? o.takerAssetAmount : o.makerAssetAmount,
);
return { return {
input: (side === MarketOperation.Sell ? o.takerAssetAmount : o.makerAssetAmount) input: (side === MarketOperation.Sell ? o.takerAssetAmount : o.makerAssetAmount)
.times(scaleFactor) .times(scaleFactor)