aboutsummaryrefslogtreecommitdiffstats
path: root/packages/asset-buyer/src
diff options
context:
space:
mode:
authorBrandon Millman <brandon.millman@gmail.com>2018-10-06 06:42:19 +0800
committerBrandon Millman <brandon.millman@gmail.com>2018-10-06 06:42:19 +0800
commitf9f8e06c1c8ac5b254dfae08e216ea199a77ff02 (patch)
treeb658e45627e1ef63fb9d86c46db93ee50b13c61a /packages/asset-buyer/src
parentcb1311ecc5889a0fd81b61f3ab7b66605d75960f (diff)
downloaddexon-0x-contracts-f9f8e06c1c8ac5b254dfae08e216ea199a77ff02.tar
dexon-0x-contracts-f9f8e06c1c8ac5b254dfae08e216ea199a77ff02.tar.gz
dexon-0x-contracts-f9f8e06c1c8ac5b254dfae08e216ea199a77ff02.tar.bz2
dexon-0x-contracts-f9f8e06c1c8ac5b254dfae08e216ea199a77ff02.tar.lz
dexon-0x-contracts-f9f8e06c1c8ac5b254dfae08e216ea199a77ff02.tar.xz
dexon-0x-contracts-f9f8e06c1c8ac5b254dfae08e216ea199a77ff02.tar.zst
dexon-0x-contracts-f9f8e06c1c8ac5b254dfae08e216ea199a77ff02.zip
Fix incorrect affiliate fee calculations and associated tests
Diffstat (limited to 'packages/asset-buyer/src')
-rw-r--r--packages/asset-buyer/src/utils/buy_quote_calculator.ts10
1 files changed, 5 insertions, 5 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,
};
}