diff options
author | Brandon Millman <brandon.millman@gmail.com> | 2018-08-06 08:48:56 +0800 |
---|---|---|
committer | Brandon Millman <brandon.millman@gmail.com> | 2018-08-06 08:48:56 +0800 |
commit | 8382161f7553539ed6f436be88df8672b00bf35e (patch) | |
tree | 87600b83c7e3be18f4a2fb4cbb67ab9b2fb5d58e /packages/order-utils/src | |
parent | bc5f8e52de9dfe920ce1d0e6b44c90a5a5826cbe (diff) | |
download | dexon-sol-tools-8382161f7553539ed6f436be88df8672b00bf35e.tar dexon-sol-tools-8382161f7553539ed6f436be88df8672b00bf35e.tar.gz dexon-sol-tools-8382161f7553539ed6f436be88df8672b00bf35e.tar.bz2 dexon-sol-tools-8382161f7553539ed6f436be88df8672b00bf35e.tar.lz dexon-sol-tools-8382161f7553539ed6f436be88df8672b00bf35e.tar.xz dexon-sol-tools-8382161f7553539ed6f436be88df8672b00bf35e.tar.zst dexon-sol-tools-8382161f7553539ed6f436be88df8672b00bf35e.zip |
Add tests for findFeeOrdersThatCoverFeesForTargetOrders
Diffstat (limited to 'packages/order-utils/src')
-rw-r--r-- | packages/order-utils/src/constants.ts | 2 | ||||
-rw-r--r-- | packages/order-utils/src/market_utils.ts | 14 |
2 files changed, 10 insertions, 6 deletions
diff --git a/packages/order-utils/src/constants.ts b/packages/order-utils/src/constants.ts index 5137ff499..c23578c20 100644 --- a/packages/order-utils/src/constants.ts +++ b/packages/order-utils/src/constants.ts @@ -11,6 +11,6 @@ export const constants = { ERC721_ASSET_DATA_MINIMUM_BYTE_LENGTH: 53, SELECTOR_LENGTH: 4, BASE_16: 16, - INFINITE_TIMESTAMP_SEC: new BigNumber(2524604400), // Close to infinite, + INFINITE_TIMESTAMP_SEC: new BigNumber(2524604400), // Close to infinite ZERO_AMOUNT: new BigNumber(0), }; diff --git a/packages/order-utils/src/market_utils.ts b/packages/order-utils/src/market_utils.ts index d66448a0b..94b5be4eb 100644 --- a/packages/order-utils/src/market_utils.ts +++ b/packages/order-utils/src/market_utils.ts @@ -17,7 +17,7 @@ export const marketUtils = { * You can use OrderStateUtils @0xproject/order-utils to perform blockchain lookups * for these values. * @param makerAssetFillAmount The amount of makerAsset desired to be filled. - * @param slippageBufferAmount An additional amount makerAsset to be covered by the result in case of trade collisions or partial fills. + * @param slippageBufferAmount An additional amount of makerAsset to be covered by the result in case of trade collisions or partial fills. * @return Resulting orders and remaining fill amount that could not be covered by the input. */ findOrdersThatCoverMakerAssetFillAmount( @@ -80,8 +80,8 @@ export const marketUtils = { * @param remainingFillableFeeAmounts An array of BigNumbers corresponding to the signedFeeOrders parameter. * You can use OrderStateUtils @0xproject/order-utils to perform blockchain lookups * for these values. - * @param slippageBufferAmount An additional amount makerAsset to be covered by the result in case of trade collisions or partial fills. - * @return Resulting orders and remaining fill amount that could not be covered by the input. + * @param slippageBufferAmount An additional amount of fee to be covered by the result in case of trade collisions or partial fills. + * @return Resulting orders and remaining fee amount that could not be covered by the input. */ findFeeOrdersThatCoverFeesForTargetOrders( signedOrders: SignedOrder[], @@ -89,7 +89,7 @@ export const marketUtils = { signedFeeOrders: SignedOrder[], remainingFillableFeeAmounts: BigNumber[], slippageBufferAmount: BigNumber = constants.ZERO_AMOUNT, - ): { resultOrders: SignedOrder[]; remainingFillAmount: BigNumber } { + ): { resultOrders: SignedOrder[]; remainingFeeAmount: BigNumber } { // type assertions assert.doesConformToSchema('signedOrders', signedOrders, schemas.signedOrdersSchema); _.forEach(remainingFillableMakerAssetAmounts, (amount, index) => @@ -121,12 +121,16 @@ export const marketUtils = { }, constants.ZERO_AMOUNT, ); - return marketUtils.findOrdersThatCoverMakerAssetFillAmount( + const { resultOrders, remainingFillAmount } = marketUtils.findOrdersThatCoverMakerAssetFillAmount( signedFeeOrders, remainingFillableFeeAmounts, totalFeeAmount, slippageBufferAmount, ); + return { + resultOrders, + remainingFeeAmount: remainingFillAmount, + }; // TODO: add more orders here to cover rounding // https://github.com/0xProject/0x-protocol-specification/blob/master/v2/forwarding-contract-specification.md#over-buying-zrx }, |