diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/types.ts | 1 | ||||
-rw-r--r-- | src/utils/order_state_utils.ts | 11 |
2 files changed, 12 insertions, 0 deletions
diff --git a/src/types.ts b/src/types.ts index 160b71fda..a366fc31e 100644 --- a/src/types.ts +++ b/src/types.ts @@ -493,6 +493,7 @@ export interface OrderRelevantState { makerFeeProxyAllowance: BigNumber; filledTakerTokenAmount: BigNumber; canceledTakerTokenAmount: BigNumber; + remainingFillableMakerTokenAmount: BigNumber; } export interface OrderStateValid { 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; } |