aboutsummaryrefslogtreecommitdiffstats
path: root/packages/asset-buyer/src/utils
diff options
context:
space:
mode:
authorBrandon Millman <brandon@0xproject.com>2018-10-10 09:15:33 +0800
committerGitHub <noreply@github.com>2018-10-10 09:15:33 +0800
commitafb34da72978b5272cfb5a235498e483c72556bc (patch)
treefce86678fa990f238aa54860c5470ebd75cf4a53 /packages/asset-buyer/src/utils
parent402089db4e1776c826119ed3555c05f61c198953 (diff)
parent8155d311af04339c105f1a29b74f1ddbced85197 (diff)
downloaddexon-sol-tools-afb34da72978b5272cfb5a235498e483c72556bc.tar
dexon-sol-tools-afb34da72978b5272cfb5a235498e483c72556bc.tar.gz
dexon-sol-tools-afb34da72978b5272cfb5a235498e483c72556bc.tar.bz2
dexon-sol-tools-afb34da72978b5272cfb5a235498e483c72556bc.tar.lz
dexon-sol-tools-afb34da72978b5272cfb5a235498e483c72556bc.tar.xz
dexon-sol-tools-afb34da72978b5272cfb5a235498e483c72556bc.tar.zst
dexon-sol-tools-afb34da72978b5272cfb5a235498e483c72556bc.zip
Merge pull request #1116 from 0xProject/feature/asset-buyer/api-tweaks
[asset-buyer] Fix order expiration calc bug and expose gas options to executeBuyQuote
Diffstat (limited to 'packages/asset-buyer/src/utils')
-rw-r--r--packages/asset-buyer/src/utils/buy_quote_calculator.ts10
-rw-r--r--packages/asset-buyer/src/utils/order_utils.ts2
2 files changed, 6 insertions, 6 deletions
diff --git a/packages/asset-buyer/src/utils/buy_quote_calculator.ts b/packages/asset-buyer/src/utils/buy_quote_calculator.ts
index cb0fd128c..a1d334eef 100644
--- a/packages/asset-buyer/src/utils/buy_quote_calculator.ts
+++ b/packages/asset-buyer/src/utils/buy_quote_calculator.ts
@@ -72,7 +72,6 @@ export const buyQuoteCalculator = {
assetBuyAmount,
feePercentage,
);
-
return {
assetData,
orders: resultOrders,
@@ -98,13 +97,14 @@ function calculateQuoteInfo(
);
// find the total eth needed to buy fees
const ethAmountToBuyFees = findEthAmountNeededToBuyFees(feeOrdersAndFillableAmounts, zrxAmountToBuyAsset);
- const ethAmountBeforeAffiliateFee = ethAmountToBuyAsset.plus(ethAmountToBuyFees);
- const totalEthAmount = ethAmountBeforeAffiliateFee.mul(feePercentage + 1);
+ const affiliateFeeEthAmount = ethAmountToBuyAsset.mul(feePercentage);
+ const totalEthAmountWithoutAffiliateFee = ethAmountToBuyAsset.plus(ethAmountToBuyFees);
+ const totalEthAmount = totalEthAmountWithoutAffiliateFee.plus(affiliateFeeEthAmount);
// divide into the assetBuyAmount in order to find rate of makerAsset / WETH
- const ethPerAssetPrice = ethAmountBeforeAffiliateFee.div(assetBuyAmount);
+ const ethPerAssetPrice = totalEthAmountWithoutAffiliateFee.div(assetBuyAmount);
return {
totalEthAmount,
- feeEthAmount: totalEthAmount.minus(ethAmountBeforeAffiliateFee),
+ feeEthAmount: affiliateFeeEthAmount,
ethPerAssetPrice,
};
}
diff --git a/packages/asset-buyer/src/utils/order_utils.ts b/packages/asset-buyer/src/utils/order_utils.ts
index 62166eb76..cfc13a8a1 100644
--- a/packages/asset-buyer/src/utils/order_utils.ts
+++ b/packages/asset-buyer/src/utils/order_utils.ts
@@ -10,7 +10,7 @@ export const orderUtils = {
willOrderExpire(order: SignedOrder, secondsFromNow: number): boolean {
const millisecondsInSecond = 1000;
const currentUnixTimestampSec = new BigNumber(Date.now() / millisecondsInSecond).round();
- return order.expirationTimeSeconds.lessThan(currentUnixTimestampSec.minus(secondsFromNow));
+ return order.expirationTimeSeconds.lessThan(currentUnixTimestampSec.plus(secondsFromNow));
},
calculateRemainingMakerAssetAmount(order: SignedOrder, remainingTakerAssetAmount: BigNumber): BigNumber {
if (remainingTakerAssetAmount.eq(0)) {