aboutsummaryrefslogtreecommitdiffstats
path: root/packages/0x.js
diff options
context:
space:
mode:
Diffstat (limited to 'packages/0x.js')
-rw-r--r--packages/0x.js/src/utils/order_state_utils.ts2
-rw-r--r--packages/0x.js/test/order_state_watcher_test.ts26
2 files changed, 27 insertions, 1 deletions
diff --git a/packages/0x.js/src/utils/order_state_utils.ts b/packages/0x.js/src/utils/order_state_utils.ts
index 80ab0de63..4187c7139 100644
--- a/packages/0x.js/src/utils/order_state_utils.ts
+++ b/packages/0x.js/src/utils/order_state_utils.ts
@@ -131,7 +131,7 @@ export class OrderStateUtils {
return BigNumber.min(remainingMakerAmount, transferrableMakerTokenAmount);
} else if (transferrableMakerTokenAmount.gte(remainingMakerAmount) &&
transferrableMakerFeeTokenAmount.gte(remainingMakerFeeAmount)) {
- return transferrableMakerTokenAmount;
+ return remainingMakerAmount;
} else {
return this.calculatePartiallyFillableMakerTokenAmount(
transferrableMakerTokenAmount, transferrableMakerFeeTokenAmount, remainingMakerAmount,
diff --git a/packages/0x.js/test/order_state_watcher_test.ts b/packages/0x.js/test/order_state_watcher_test.ts
index 9d432a713..8ab4939c0 100644
--- a/packages/0x.js/test/order_state_watcher_test.ts
+++ b/packages/0x.js/test/order_state_watcher_test.ts
@@ -321,6 +321,32 @@ describe('OrderStateWatcher', () => {
makerToken.address, maker, ZeroEx.NULL_ADDRESS, transferAmount);
})().catch(done);
});
+ it('should equal remaining amount when partially cancelled and order has fees', (done: DoneCallback) => {
+ (async () => {
+ const takerFee = ZeroEx.toBaseUnitAmount(new BigNumber(0), 18);
+ const makerFee = ZeroEx.toBaseUnitAmount(new BigNumber(5), 18);
+ const feeRecipient = taker;
+ signedOrder = await fillScenarios.createFillableSignedOrderWithFeesAsync(
+ makerToken.address, takerToken.address, makerFee, takerFee, maker,
+ taker, fillableAmount, feeRecipient);
+
+ const makerBalance = await zeroEx.token.getBalanceAsync(makerToken.address, maker);
+
+ const remainingTokenAmount = ZeroEx.toBaseUnitAmount(new BigNumber(4), 18);
+ const transferTokenAmount = makerFee.sub(remainingTokenAmount);
+ zeroEx.orderStateWatcher.addOrder(signedOrder);
+
+ const callback = reportCallbackErrors(done)((orderState: OrderState) => {
+ const validOrderState = orderState as OrderStateValid;
+ const orderRelevantState = validOrderState.orderRelevantState;
+ expect(orderRelevantState.remainingFillableMakerTokenAmount).to.be.bignumber.equal(
+ remainingTokenAmount);
+ done();
+ });
+ zeroEx.orderStateWatcher.subscribe(callback);
+ await zeroEx.exchange.cancelOrderAsync(signedOrder, transferTokenAmount);
+ })().catch(done);
+ });
it('should equal ratio amount when fee balance is lowered', (done: DoneCallback) => {
(async () => {
const takerFee = ZeroEx.toBaseUnitAmount(new BigNumber(0), 18);