aboutsummaryrefslogtreecommitdiffstats
path: root/packages
diff options
context:
space:
mode:
Diffstat (limited to 'packages')
-rw-r--r--packages/order-utils/src/order_state_utils.ts9
-rw-r--r--packages/order-utils/src/order_validation_utils.ts13
-rw-r--r--packages/order-utils/src/utils.ts7
3 files changed, 18 insertions, 11 deletions
diff --git a/packages/order-utils/src/order_state_utils.ts b/packages/order-utils/src/order_state_utils.ts
index dbb65de59..3752fdadb 100644
--- a/packages/order-utils/src/order_state_utils.ts
+++ b/packages/order-utils/src/order_state_utils.ts
@@ -14,6 +14,7 @@ import { AbstractOrderFilledCancelledFetcher } from './abstract/abstract_order_f
import { constants } from './constants';
import { orderHashUtils } from './order_hash';
import { RemainingFillableCalculator } from './remaining_fillable_calculator';
+import { utils } from './utils';
interface SidedOrderRelevantState {
isMakerSide: boolean;
@@ -161,7 +162,13 @@ export class OrderStateUtils {
signedOrder,
signedOrder.takerAddress,
);
- const remainingFillableTakerAssetAmountGivenMakersStatus = orderRelevantMakerState.remainingFillableAssetAmount;
+ const remainingFillableTakerAssetAmountGivenMakersStatus = signedOrder.makerAssetAmount.eq(0)
+ ? new BigNumber(0)
+ : utils.getPartialAmount(
+ orderRelevantMakerState.remainingFillableAssetAmount,
+ signedOrder.makerAssetAmount,
+ signedOrder.takerAssetAmount,
+ );
// Get max fillable amount for an order, considering the takers ability to fill
isMaker = false;
diff --git a/packages/order-utils/src/order_validation_utils.ts b/packages/order-utils/src/order_validation_utils.ts
index fb96502f2..da5b37456 100644
--- a/packages/order-utils/src/order_validation_utils.ts
+++ b/packages/order-utils/src/order_validation_utils.ts
@@ -54,7 +54,7 @@ export class OrderValidationUtils {
senderAddress: string,
zrxAssetData: string,
): Promise<void> {
- const fillMakerTokenAmount = OrderValidationUtils._getPartialAmount(
+ const fillMakerTokenAmount = utils.getPartialAmount(
fillTakerAssetAmount,
signedOrder.takerAssetAmount,
signedOrder.makerAssetAmount,
@@ -75,7 +75,7 @@ export class OrderValidationUtils {
TradeSide.Taker,
TransferType.Trade,
);
- const makerFeeAmount = OrderValidationUtils._getPartialAmount(
+ const makerFeeAmount = utils.getPartialAmount(
fillTakerAssetAmount,
signedOrder.takerAssetAmount,
signedOrder.makerFee,
@@ -88,7 +88,7 @@ export class OrderValidationUtils {
TradeSide.Maker,
TransferType.Fee,
);
- const takerFeeAmount = OrderValidationUtils._getPartialAmount(
+ const takerFeeAmount = utils.getPartialAmount(
fillTakerAssetAmount,
signedOrder.takerAssetAmount,
signedOrder.takerFee,
@@ -116,13 +116,6 @@ export class OrderValidationUtils {
throw new Error(ExchangeContractErrs.OrderFillExpired);
}
}
- private static _getPartialAmount(numerator: BigNumber, denominator: BigNumber, target: BigNumber): BigNumber {
- const fillMakerTokenAmount = numerator
- .mul(target)
- .div(denominator)
- .round(0);
- return fillMakerTokenAmount;
- }
constructor(orderFilledCancelledFetcher: AbstractOrderFilledCancelledFetcher) {
this._orderFilledCancelledFetcher = orderFilledCancelledFetcher;
}
diff --git a/packages/order-utils/src/utils.ts b/packages/order-utils/src/utils.ts
index 6149316f6..7aaaf0609 100644
--- a/packages/order-utils/src/utils.ts
+++ b/packages/order-utils/src/utils.ts
@@ -12,4 +12,11 @@ export const utils = {
const milisecondsInSecond = 1000;
return new BigNumber(Date.now() / milisecondsInSecond).round();
},
+ getPartialAmount(numerator: BigNumber, denominator: BigNumber, target: BigNumber): BigNumber {
+ const fillMakerTokenAmount = numerator
+ .mul(target)
+ .div(denominator)
+ .round(0);
+ return fillMakerTokenAmount;
+ },
};