Fix orderValidationUtils where was confusing a makerAssetAmount as a takerAssetAmount
This commit is contained in:
@@ -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;
|
||||
|
@@ -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;
|
||||
}
|
||||
|
@@ -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;
|
||||
},
|
||||
};
|
||||
|
Reference in New Issue
Block a user