aboutsummaryrefslogtreecommitdiffstats
path: root/src/utils/order_state_utils.ts
diff options
context:
space:
mode:
Diffstat (limited to 'src/utils/order_state_utils.ts')
-rw-r--r--src/utils/order_state_utils.ts11
1 files changed, 11 insertions, 0 deletions
diff --git a/src/utils/order_state_utils.ts b/src/utils/order_state_utils.ts
index 2a5becf9a..36a4b68d6 100644
--- a/src/utils/order_state_utils.ts
+++ b/src/utils/order_state_utils.ts
@@ -60,6 +60,16 @@ export class OrderStateUtils {
);
const filledTakerTokenAmount = await this.exchangeWrapper.getFilledTakerAmountAsync(orderHash, methodOpts);
const canceledTakerTokenAmount = await this.exchangeWrapper.getCanceledTakerAmountAsync(orderHash, methodOpts);
+ const unavailableTakerTokenAmount =
+ await this.exchangeWrapper.getUnavailableTakerAmountAsync(orderHash, methodOpts);
+ const totalMakerTokenAmount = signedOrder.makerTokenAmount;
+ const totalTakerTokenAmount = signedOrder.takerTokenAmount;
+ const remainingTakerTokenAmount = totalTakerTokenAmount.minus(unavailableTakerTokenAmount);
+ const remainingMakerTokenAmount = remainingTakerTokenAmount.times(totalMakerTokenAmount)
+ .dividedToIntegerBy(totalTakerTokenAmount);
+ const fillableMakerTokenAmount = BigNumber.min([makerProxyAllowance, makerBalance]);
+ const remainingFillableMakerTokenAmount = BigNumber.min(fillableMakerTokenAmount, remainingMakerTokenAmount);
+ // TODO: Handle edge case where maker token is ZRX with fee
const orderRelevantState = {
makerBalance,
makerProxyAllowance,
@@ -67,6 +77,7 @@ export class OrderStateUtils {
makerFeeProxyAllowance,
filledTakerTokenAmount,
canceledTakerTokenAmount,
+ remainingFillableMakerTokenAmount,
};
return orderRelevantState;
}