aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFabio Berger <me@fabioberger.com>2018-06-14 17:16:32 +0800
committerFabio Berger <me@fabioberger.com>2018-06-14 17:16:32 +0800
commit432ff58107704bb4b2fde23f4a99c75f2bca24fa (patch)
tree061d54ff3e8c2da4ad5f4c47100cb4771e555b71
parentd31b051fc57ead4243f52e5536ab0959e3588b4c (diff)
downloaddexon-0x-contracts-432ff58107704bb4b2fde23f4a99c75f2bca24fa.tar.gz
dexon-0x-contracts-432ff58107704bb4b2fde23f4a99c75f2bca24fa.tar.zst
dexon-0x-contracts-432ff58107704bb4b2fde23f4a99c75f2bca24fa.zip
Fix calculation of expFilledTakerAmount and expected values in events emitted
-rw-r--r--packages/contracts/src/utils/core_combinatorial_utils.ts11
1 files changed, 7 insertions, 4 deletions
diff --git a/packages/contracts/src/utils/core_combinatorial_utils.ts b/packages/contracts/src/utils/core_combinatorial_utils.ts
index dac4e9edd..4ce23d450 100644
--- a/packages/contracts/src/utils/core_combinatorial_utils.ts
+++ b/packages/contracts/src/utils/core_combinatorial_utils.ts
@@ -352,11 +352,14 @@ export class CoreCombinatorialUtils {
const expZRXAssetBalanceOfFeeRecipient = await lazyStore.getBalanceAsync(this.zrxAssetData, feeRecipient);
const orderHash = orderHashUtils.getOrderHashHex(signedOrder);
- const initialFilledTakerAmount = await this.exchangeWrapper.getTakerAssetFilledAmountAsync(orderHash);
- const expFilledTakerAmount = initialFilledTakerAmount.add(takerAssetFillAmount);
+ const alreadyFilledTakerAmount = await this.exchangeWrapper.getTakerAssetFilledAmountAsync(orderHash);
+ const remainingTakerAmountToFill = signedOrder.takerAssetAmount.minus(alreadyFilledTakerAmount);
+ const expFilledTakerAmount = takerAssetFillAmount.gt(remainingTakerAmountToFill)
+ ? remainingTakerAmountToFill
+ : alreadyFilledTakerAmount.add(takerAssetFillAmount);
const expFilledMakerAmount = orderUtils.getPartialAmount(
- takerAssetFillAmount,
+ expFilledTakerAmount,
signedOrder.takerAssetAmount,
signedOrder.makerAssetAmount,
);
@@ -380,7 +383,7 @@ export class CoreCombinatorialUtils {
'log.args.makerAssetFilledAmount',
);
expect(log.args.takerAssetFilledAmount).to.be.bignumber.equal(
- takerAssetFillAmount,
+ expFilledTakerAmount,
'log.args.takerAssetFilledAmount',
);
const expMakerFeePaid = orderUtils.getPartialAmount(