aboutsummaryrefslogtreecommitdiffstats
path: root/packages/instant/src/util
diff options
context:
space:
mode:
Diffstat (limited to 'packages/instant/src/util')
-rw-r--r--packages/instant/src/util/asset.ts9
-rw-r--r--packages/instant/src/util/format.ts8
-rw-r--r--packages/instant/src/util/gas_price_estimator.ts2
-rw-r--r--packages/instant/src/util/maybe_big_number.ts2
4 files changed, 12 insertions, 9 deletions
diff --git a/packages/instant/src/util/asset.ts b/packages/instant/src/util/asset.ts
index 709561dbc..b5c97913d 100644
--- a/packages/instant/src/util/asset.ts
+++ b/packages/instant/src/util/asset.ts
@@ -114,15 +114,18 @@ export const assetUtils = {
const assetName = assetUtils.bestNameForAsset(asset, 'of this asset');
if (
error instanceof InsufficientAssetLiquidityError &&
- error.amountAvailableToFill.greaterThan(BIG_NUMBER_ZERO)
+ error.amountAvailableToFill.isGreaterThan(BIG_NUMBER_ZERO)
) {
const unitAmountAvailableToFill = Web3Wrapper.toUnitAmount(
error.amountAvailableToFill,
asset.metaData.decimals,
);
- const roundedUnitAmountAvailableToFill = unitAmountAvailableToFill.round(2, BigNumber.ROUND_DOWN);
+ const roundedUnitAmountAvailableToFill = unitAmountAvailableToFill.decimalPlaces(
+ 2,
+ BigNumber.ROUND_DOWN,
+ );
- if (roundedUnitAmountAvailableToFill.greaterThan(BIG_NUMBER_ZERO)) {
+ if (roundedUnitAmountAvailableToFill.isGreaterThan(BIG_NUMBER_ZERO)) {
return `There are only ${roundedUnitAmountAvailableToFill} ${assetName} available to buy`;
}
}
diff --git a/packages/instant/src/util/format.ts b/packages/instant/src/util/format.ts
index 4adb63e21..61aeb839f 100644
--- a/packages/instant/src/util/format.ts
+++ b/packages/instant/src/util/format.ts
@@ -25,16 +25,16 @@ export const format = {
if (_.isUndefined(ethUnitAmount)) {
return defaultText;
}
- let roundedAmount = ethUnitAmount.round(decimalPlaces).toDigits(decimalPlaces);
+ let roundedAmount = ethUnitAmount.decimalPlaces(decimalPlaces).precision(decimalPlaces);
- if (roundedAmount.eq(BIG_NUMBER_ZERO) && ethUnitAmount.greaterThan(BIG_NUMBER_ZERO)) {
+ if (roundedAmount.eq(BIG_NUMBER_ZERO) && ethUnitAmount.isGreaterThan(BIG_NUMBER_ZERO)) {
// Sometimes for small ETH amounts (i.e. 0.000045) the amount rounded to 4 decimalPlaces is 0
// If that is the case, show to 1 significant digit
roundedAmount = new BigNumber(ethUnitAmount.toPrecision(1));
}
const displayAmount =
- roundedAmount.greaterThan(BIG_NUMBER_ZERO) && roundedAmount.lessThan(minUnitAmountToDisplay)
+ roundedAmount.isGreaterThan(BIG_NUMBER_ZERO) && roundedAmount.isLessThan(minUnitAmountToDisplay)
? `< ${minUnitAmountToDisplay.toString()}`
: roundedAmount.toString();
@@ -62,7 +62,7 @@ export const format = {
if (_.isUndefined(ethUnitAmount) || _.isUndefined(ethUsdPrice)) {
return defaultText;
}
- const rawUsdPrice = ethUnitAmount.mul(ethUsdPrice);
+ const rawUsdPrice = ethUnitAmount.multipliedBy(ethUsdPrice);
const roundedUsdPrice = rawUsdPrice.toFixed(decimalPlaces);
if (roundedUsdPrice === '0.00' && rawUsdPrice.gt(BIG_NUMBER_ZERO)) {
return '<$0.01';
diff --git a/packages/instant/src/util/gas_price_estimator.ts b/packages/instant/src/util/gas_price_estimator.ts
index 332c8d00a..9792b60ba 100644
--- a/packages/instant/src/util/gas_price_estimator.ts
+++ b/packages/instant/src/util/gas_price_estimator.ts
@@ -35,7 +35,7 @@ const fetchFastAmountInWeiAsync = async (): Promise<GasInfo> => {
const gasPriceInGwei = new BigNumber(gasInfo.fast / 10);
// Time is in minutes
const estimatedTimeMs = gasInfo.fastWait * 60 * 1000; // Minutes to MS
- return { gasPriceInWei: gasPriceInGwei.mul(GWEI_IN_WEI), estimatedTimeMs };
+ return { gasPriceInWei: gasPriceInGwei.multipliedBy(GWEI_IN_WEI), estimatedTimeMs };
};
export class GasPriceEstimator {
diff --git a/packages/instant/src/util/maybe_big_number.ts b/packages/instant/src/util/maybe_big_number.ts
index 9d3746e10..f48473389 100644
--- a/packages/instant/src/util/maybe_big_number.ts
+++ b/packages/instant/src/util/maybe_big_number.ts
@@ -18,7 +18,7 @@ export const maybeBigNumberUtil = {
},
areMaybeBigNumbersEqual: (val1: Maybe<BigNumber>, val2: Maybe<BigNumber>): boolean => {
if (!_.isUndefined(val1) && !_.isUndefined(val2)) {
- return val1.equals(val2);
+ return val1.isEqualTo(val2);
}
return _.isUndefined(val1) && _.isUndefined(val2);
},