diff options
author | Brandon Millman <brandon.millman@gmail.com> | 2018-10-23 14:23:50 +0800 |
---|---|---|
committer | Brandon Millman <brandon.millman@gmail.com> | 2018-10-24 05:06:21 +0800 |
commit | 4db33ba2b37f4682ecae5da325e631d546a8a24e (patch) | |
tree | c0453e856ee02a5d4538ee640a34cdb46861dc94 /packages/asset-buyer/src/asset_buyer.ts | |
parent | 37f87ab267c5eb10c70d7eb4d3eef01bf8ed7ac1 (diff) | |
download | dexon-0x-contracts-4db33ba2b37f4682ecae5da325e631d546a8a24e.tar.gz dexon-0x-contracts-4db33ba2b37f4682ecae5da325e631d546a8a24e.tar.zst dexon-0x-contracts-4db33ba2b37f4682ecae5da325e631d546a8a24e.zip |
feat(asset-buyer): update buyQuoteCalculator to match rounding behavior in contracts
Diffstat (limited to 'packages/asset-buyer/src/asset_buyer.ts')
-rw-r--r-- | packages/asset-buyer/src/asset_buyer.ts | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/packages/asset-buyer/src/asset_buyer.ts b/packages/asset-buyer/src/asset_buyer.ts index 2f9a3108e..74f3cb471 100644 --- a/packages/asset-buyer/src/asset_buyer.ts +++ b/packages/asset-buyer/src/asset_buyer.ts @@ -135,9 +135,14 @@ export class AssetBuyer { assert.isBoolean('shouldForceOrderRefresh', shouldForceOrderRefresh); assert.isNumber('slippagePercentage', slippagePercentage); const zrxTokenAssetData = this._getZrxTokenAssetDataOrThrow(); + const isMakerAssetZrxToken = assetData === zrxTokenAssetData; + // get the relevant orders for the makerAsset and fees + // if the requested assetData is ZRX, don't get the fee info const [ordersAndFillableAmounts, feeOrdersAndFillableAmounts] = await Promise.all([ this._getOrdersAndFillableAmountsAsync(assetData, shouldForceOrderRefresh), - this._getOrdersAndFillableAmountsAsync(zrxTokenAssetData, shouldForceOrderRefresh), + isMakerAssetZrxToken + ? Promise.resolve(constants.EMPTY_ORDERS_AND_FILLABLE_AMOUNTS) + : this._getOrdersAndFillableAmountsAsync(zrxTokenAssetData, shouldForceOrderRefresh), shouldForceOrderRefresh, ]); if (ordersAndFillableAmounts.orders.length === 0) { @@ -149,6 +154,7 @@ export class AssetBuyer { assetBuyAmount, feePercentage, slippagePercentage, + isMakerAssetZrxToken, ); return buyQuote; } |