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.ts16
1 files changed, 16 insertions, 0 deletions
diff --git a/src/utils/order_state_utils.ts b/src/utils/order_state_utils.ts
index 2a5becf9a..ff5c1880d 100644
--- a/src/utils/order_state_utils.ts
+++ b/src/utils/order_state_utils.ts
@@ -60,6 +60,21 @@ 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);
+ // 200 in order, 100 unavailable = 100 remaning, 0.5 remaning proportion
+ const remainingTakerProportion = remainingTakerTokenAmount.dividedBy(totalTakerTokenAmount);
+ const remainingMakerTokenAmount = remainingTakerProportion.times(totalMakerTokenAmount);
+ // min allowance, balance in account of maker
+ const fillableMakerTokenAmount = BigNumber.min([makerProxyAllowance, makerBalance]);
+ // min ^, remaining order maker token amount
+ const remainingFillableMakerTokenAmount = BigNumber.min(fillableMakerTokenAmount, remainingMakerTokenAmount);
+ // TODO
+ // edge case when maker token is ZRX
+ // rounding issues, check if its fillabae
const orderRelevantState = {
makerBalance,
makerProxyAllowance,
@@ -67,6 +82,7 @@ export class OrderStateUtils {
makerFeeProxyAllowance,
filledTakerTokenAmount,
canceledTakerTokenAmount,
+ remainingFillableMakerTokenAmount,
};
return orderRelevantState;
}