aboutsummaryrefslogtreecommitdiffstats
path: root/packages
diff options
context:
space:
mode:
authorSteve Klebanoff <steve.klebanoff@gmail.com>2018-12-22 08:29:53 +0800
committerSteve Klebanoff <steve.klebanoff@gmail.com>2018-12-22 08:29:53 +0800
commit26977f6408442883c20001a57a3b9001f4ab9b25 (patch)
tree7890fbbee04b5f02dc4ef258690870628a4e0b73 /packages
parentc8c8219c055cc5798cf5cdc71199ee7ae505cd5a (diff)
downloaddexon-sol-tools-26977f6408442883c20001a57a3b9001f4ab9b25.tar
dexon-sol-tools-26977f6408442883c20001a57a3b9001f4ab9b25.tar.gz
dexon-sol-tools-26977f6408442883c20001a57a3b9001f4ab9b25.tar.bz2
dexon-sol-tools-26977f6408442883c20001a57a3b9001f4ab9b25.tar.lz
dexon-sol-tools-26977f6408442883c20001a57a3b9001f4ab9b25.tar.xz
dexon-sol-tools-26977f6408442883c20001a57a3b9001f4ab9b25.tar.zst
dexon-sol-tools-26977f6408442883c20001a57a3b9001f4ab9b25.zip
Fix var name and use floor instead of .round(0, ROUND_DOWN)
Diffstat (limited to 'packages')
-rw-r--r--packages/asset-buyer/src/utils/buy_quote_calculator.ts16
1 files changed, 7 insertions, 9 deletions
diff --git a/packages/asset-buyer/src/utils/buy_quote_calculator.ts b/packages/asset-buyer/src/utils/buy_quote_calculator.ts
index ceeee93d3..fcded6ab1 100644
--- a/packages/asset-buyer/src/utils/buy_quote_calculator.ts
+++ b/packages/asset-buyer/src/utils/buy_quote_calculator.ts
@@ -36,16 +36,14 @@ export const buyQuoteCalculator = {
if (remainingFillAmount.gt(constants.ZERO_AMOUNT)) {
// We needed the amount they requested to buy, plus the amount for slippage
const totalAmountRequested = assetBuyAmount.plus(slippageBufferAmount);
- const amountUnableToFill = totalAmountRequested.minus(remainingFillAmount);
- // multiplerNeededWithSlippage represents what we need to multiply the assetBuyAmount by
+ const amountAbleToFill = totalAmountRequested.minus(remainingFillAmount);
+ // multiplierNeededWithSlippage represents what we need to multiply the assetBuyAmount by
// in order to get the total amount needed considering slippage
- // i.e. if slippagePercent was 0.2 (20%), multiplerNeededWithSlippage would be 1.2
- const multiplerNeededWithSlippage = new BigNumber(1).plus(slippagePercentage);
- // Given amountAvailableToFillConsideringSlippage * multiplerNeededWithSlippage = amountUnableToFill
- // We divide amountUnableToFill by multiplerNeededWithSlippage to determine amountAvailableToFillConsideringSlippage
- const amountAvailableToFillConsideringSlippage = amountUnableToFill
- .div(multiplerNeededWithSlippage)
- .round(0, BigNumber.ROUND_DOWN);
+ // i.e. if slippagePercent was 0.2 (20%), multiplierNeededWithSlippage would be 1.2
+ const multiplierNeededWithSlippage = new BigNumber(1).plus(slippagePercentage);
+ // Given amountAvailableToFillConsideringSlippage * multiplierNeededWithSlippage = amountAbleToFill
+ // We divide amountUnableToFill by multiplierNeededWithSlippage to determine amountAvailableToFillConsideringSlippage
+ const amountAvailableToFillConsideringSlippage = amountAbleToFill.div(multiplierNeededWithSlippage).floor();
throw new InsufficientAssetLiquidityError(amountAvailableToFillConsideringSlippage);
}