diff options
author | Fabio Berger <me@fabioberger.com> | 2018-06-14 17:16:32 +0800 |
---|---|---|
committer | Fabio Berger <me@fabioberger.com> | 2018-06-14 17:16:32 +0800 |
commit | 432ff58107704bb4b2fde23f4a99c75f2bca24fa (patch) | |
tree | 061d54ff3e8c2da4ad5f4c47100cb4771e555b71 /packages | |
parent | d31b051fc57ead4243f52e5536ab0959e3588b4c (diff) | |
download | dexon-sol-tools-432ff58107704bb4b2fde23f4a99c75f2bca24fa.tar dexon-sol-tools-432ff58107704bb4b2fde23f4a99c75f2bca24fa.tar.gz dexon-sol-tools-432ff58107704bb4b2fde23f4a99c75f2bca24fa.tar.bz2 dexon-sol-tools-432ff58107704bb4b2fde23f4a99c75f2bca24fa.tar.lz dexon-sol-tools-432ff58107704bb4b2fde23f4a99c75f2bca24fa.tar.xz dexon-sol-tools-432ff58107704bb4b2fde23f4a99c75f2bca24fa.tar.zst dexon-sol-tools-432ff58107704bb4b2fde23f4a99c75f2bca24fa.zip |
Fix calculation of expFilledTakerAmount and expected values in events emitted
Diffstat (limited to 'packages')
-rw-r--r-- | packages/contracts/src/utils/core_combinatorial_utils.ts | 11 |
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( |