diff options
author | Fabio Berger <me@fabioberger.com> | 2018-06-08 00:52:14 +0800 |
---|---|---|
committer | Fabio Berger <me@fabioberger.com> | 2018-06-08 00:52:14 +0800 |
commit | b646c8441467212e60f03c868a55d6ab70720aba (patch) | |
tree | 4292c665d7d2943ae9817ab387530b7aa039b2b1 /packages/order-utils | |
parent | 7b7664bd6607852ea97ef5463b3681db8aaf4a89 (diff) | |
parent | a200eaacaa3975b63f24d8be6cdfc7b0921d91ef (diff) | |
download | dexon-sol-tools-b646c8441467212e60f03c868a55d6ab70720aba.tar dexon-sol-tools-b646c8441467212e60f03c868a55d6ab70720aba.tar.gz dexon-sol-tools-b646c8441467212e60f03c868a55d6ab70720aba.tar.bz2 dexon-sol-tools-b646c8441467212e60f03c868a55d6ab70720aba.tar.lz dexon-sol-tools-b646c8441467212e60f03c868a55d6ab70720aba.tar.xz dexon-sol-tools-b646c8441467212e60f03c868a55d6ab70720aba.tar.zst dexon-sol-tools-b646c8441467212e60f03c868a55d6ab70720aba.zip |
Merge branch 'fix/order-utils/remaining-v2-changes' into feature/combinatorial-testing
* fix/order-utils/remaining-v2-changes:
Fix tslint failure
Pass in fee and assetAmount rather then the whole signedOrder
Diffstat (limited to 'packages/order-utils')
3 files changed, 27 insertions, 46 deletions
diff --git a/packages/order-utils/src/order_state_utils.ts b/packages/order-utils/src/order_state_utils.ts index ef868e60f..ca18097c9 100644 --- a/packages/order-utils/src/order_state_utils.ts +++ b/packages/order-utils/src/order_state_utils.ts @@ -113,10 +113,9 @@ export class OrderStateUtils { const zrxAssetData = assetProxyUtils.encodeERC20ProxyData(zrxTokenAddress); const isMakerAssetZRX = signedOrder.makerAssetData === zrxAssetData; - const isTraderMaker = true; const remainingFillableCalculator = new RemainingFillableCalculator( - isTraderMaker, - signedOrder, + signedOrder.makerFee, + signedOrder.makerAssetAmount, isMakerAssetZRX, transferrableMakerAssetAmount, transferrableFeeAssetAmount, diff --git a/packages/order-utils/src/remaining_fillable_calculator.ts b/packages/order-utils/src/remaining_fillable_calculator.ts index acab2f41b..bc146e931 100644 --- a/packages/order-utils/src/remaining_fillable_calculator.ts +++ b/packages/order-utils/src/remaining_fillable_calculator.ts @@ -1,8 +1,6 @@ -import { SignedOrder } from '@0xproject/types'; import { BigNumber } from '@0xproject/utils'; export class RemainingFillableCalculator { - private _signedOrder: SignedOrder; private _isTraderAssetZRX: boolean; // Transferrable Amount is the minimum of Approval and Balance private _transferrableAssetAmount: BigNumber; @@ -12,21 +10,15 @@ export class RemainingFillableCalculator { private _orderFee: BigNumber; private _orderAssetAmount: BigNumber; constructor( - isTraderMaker: boolean, - signedOrder: SignedOrder, + orderFee: BigNumber, + orderAssetAmount: BigNumber, isTraderAssetZRX: boolean, transferrableAssetAmount: BigNumber, transferrableFeeAmount: BigNumber, remainingOrderAssetAmount: BigNumber, ) { - if (isTraderMaker) { - this._orderFee = signedOrder.makerFee; - this._orderAssetAmount = signedOrder.makerAssetAmount; - } else { - this._orderFee = signedOrder.takerFee; - this._orderAssetAmount = signedOrder.takerAssetAmount; - } - this._signedOrder = signedOrder; + this._orderFee = orderFee; + this._orderAssetAmount = orderAssetAmount; this._isTraderAssetZRX = isTraderAssetZRX; this._transferrableAssetAmount = transferrableAssetAmount; this._transferrableFeeAmount = transferrableFeeAmount; diff --git a/packages/order-utils/test/remaining_fillable_calculator_test.ts b/packages/order-utils/test/remaining_fillable_calculator_test.ts index 81f8132b2..c99d10f3f 100644 --- a/packages/order-utils/test/remaining_fillable_calculator_test.ts +++ b/packages/order-utils/test/remaining_fillable_calculator_test.ts @@ -1,4 +1,4 @@ -import { ECSignature, SignedOrder } from '@0xproject/types'; +import { SignedOrder } from '@0xproject/types'; import { BigNumber } from '@0xproject/utils'; import { Web3Wrapper } from '@0xproject/web3-wrapper'; import * as chai from 'chai'; @@ -65,10 +65,9 @@ describe('RemainingFillableCalculator', () => { it('calculates the correct amount when unfilled and funds available', () => { signedOrder = buildSignedOrder(); remainingMakeAssetAmount = signedOrder.makerAssetAmount; - const isTraderMaker = true; calculator = new RemainingFillableCalculator( - isTraderMaker, - signedOrder, + signedOrder.makerFee, + signedOrder.makerAssetAmount, isMakeAssetZRX, transferrableMakeAssetAmount, transferrableMakerFeeTokenAmount, @@ -79,10 +78,9 @@ describe('RemainingFillableCalculator', () => { it('calculates the correct amount when partially filled and funds available', () => { signedOrder = buildSignedOrder(); remainingMakeAssetAmount = Web3Wrapper.toBaseUnitAmount(new BigNumber(1), decimals); - const isTraderMaker = true; calculator = new RemainingFillableCalculator( - isTraderMaker, - signedOrder, + signedOrder.makerFee, + signedOrder.makerAssetAmount, isMakeAssetZRX, transferrableMakeAssetAmount, transferrableMakerFeeTokenAmount, @@ -94,10 +92,9 @@ describe('RemainingFillableCalculator', () => { signedOrder = buildSignedOrder(); transferrableMakerFeeTokenAmount = zero; remainingMakeAssetAmount = signedOrder.makerAssetAmount; - const isTraderMaker = true; calculator = new RemainingFillableCalculator( - isTraderMaker, - signedOrder, + signedOrder.makerFee, + signedOrder.makerAssetAmount, isMakeAssetZRX, transferrableMakeAssetAmount, transferrableMakerFeeTokenAmount, @@ -110,10 +107,9 @@ describe('RemainingFillableCalculator', () => { const partiallyFilledAmount = Web3Wrapper.toBaseUnitAmount(new BigNumber(2), decimals); remainingMakeAssetAmount = signedOrder.makerAssetAmount.minus(partiallyFilledAmount); transferrableMakeAssetAmount = remainingMakeAssetAmount.minus(partiallyFilledAmount); - const isTraderMaker = true; calculator = new RemainingFillableCalculator( - isTraderMaker, - signedOrder, + signedOrder.makerFee, + signedOrder.makerAssetAmount, isMakeAssetZRX, transferrableMakeAssetAmount, transferrableMakerFeeTokenAmount, @@ -134,10 +130,9 @@ describe('RemainingFillableCalculator', () => { remainingMakeAssetAmount = signedOrder.makerAssetAmount; const transferredAmount = Web3Wrapper.toBaseUnitAmount(new BigNumber(2), decimals); transferrableMakeAssetAmount = remainingMakeAssetAmount.minus(transferredAmount); - const isTraderMaker = true; calculator = new RemainingFillableCalculator( - isTraderMaker, - signedOrder, + signedOrder.makerFee, + signedOrder.makerAssetAmount, isMakeAssetZRX, transferrableMakeAssetAmount, transferrableMakerFeeTokenAmount, @@ -159,10 +154,9 @@ describe('RemainingFillableCalculator', () => { remainingMakeAssetAmount = signedOrder.makerAssetAmount; const transferredAmount = Web3Wrapper.toBaseUnitAmount(new BigNumber(2), decimals); transferrableMakeAssetAmount = remainingMakeAssetAmount.minus(transferredAmount); - const isTraderMaker = true; calculator = new RemainingFillableCalculator( - isTraderMaker, - signedOrder, + signedOrder.makerFee, + signedOrder.makerAssetAmount, isMakeAssetZRX, transferrableMakeAssetAmount, transferrableMakerFeeTokenAmount, @@ -186,10 +180,9 @@ describe('RemainingFillableCalculator', () => { transferrableMakeAssetAmount = makerAmount.plus(makerFeeAmount); transferrableMakerFeeTokenAmount = transferrableMakeAssetAmount; remainingMakeAssetAmount = signedOrder.makerAssetAmount; - const isTraderMaker = true; calculator = new RemainingFillableCalculator( - isTraderMaker, - signedOrder, + signedOrder.makerFee, + signedOrder.makerAssetAmount, isMakeAssetZRX, transferrableMakeAssetAmount, transferrableMakerFeeTokenAmount, @@ -200,10 +193,9 @@ describe('RemainingFillableCalculator', () => { it('calculates the correct amount when partially filled and funds available', () => { signedOrder = buildSignedOrder(); remainingMakeAssetAmount = Web3Wrapper.toBaseUnitAmount(new BigNumber(1), decimals); - const isTraderMaker = true; calculator = new RemainingFillableCalculator( - isTraderMaker, - signedOrder, + signedOrder.makerFee, + signedOrder.makerAssetAmount, isMakeAssetZRX, transferrableMakeAssetAmount, transferrableMakerFeeTokenAmount, @@ -216,10 +208,9 @@ describe('RemainingFillableCalculator', () => { transferrableMakeAssetAmount = zero; transferrableMakerFeeTokenAmount = zero; remainingMakeAssetAmount = signedOrder.makerAssetAmount; - const isTraderMaker = true; calculator = new RemainingFillableCalculator( - isTraderMaker, - signedOrder, + signedOrder.makerFee, + signedOrder.makerAssetAmount, isMakeAssetZRX, transferrableMakeAssetAmount, transferrableMakerFeeTokenAmount, @@ -236,10 +227,9 @@ describe('RemainingFillableCalculator', () => { const orderToFeeRatio = signedOrder.makerAssetAmount.dividedToIntegerBy(signedOrder.makerFee); const expectedFillableAmount = new BigNumber(450980); - const isTraderMaker = true; calculator = new RemainingFillableCalculator( - isTraderMaker, - signedOrder, + signedOrder.makerFee, + signedOrder.makerAssetAmount, isMakeAssetZRX, transferrableMakeAssetAmount, transferrableMakerFeeTokenAmount, |