changes to order utils

This commit is contained in:
David Sun
2019-06-26 15:20:53 -07:00
parent a7db900e51
commit 6691f490bc
2 changed files with 23 additions and 0 deletions

View File

@@ -9,10 +9,20 @@ import {
FeeOrdersAndRemainingFeeAmount,
FindFeeOrdersThatCoverFeesForTargetOrdersOpts,
FindOrdersThatCoverMakerAssetFillAmountOpts,
FindOrdersThatCoverTakerAssetFillAmountOpts,
OrdersAndRemainingFillAmount,
} from './types';
export const marketUtils = {
findOrdersThatCoverTakerAssetFillAmount<T extends Order>(
orders: T[],
takerAssetFillAmount: BigNumber,
opts?: FindOrdersThatCoverTakerAssetFillAmountOpts,
): OrdersAndRemainingFillAmount<T> {
assert.doesConformToSchema('orders', orders, schemas.ordersSchema);
assert.isValidBaseUnitAmount('takerAssetFillAmount', takerAssetFillAmount);
},
/**
* Takes an array of orders and returns a subset of those orders that has enough makerAssetAmount
* in order to fill the input makerAssetFillAmount plus slippageBufferAmount. Iterates from first order to last order.

View File

@@ -33,6 +33,19 @@ export interface CreateOrderOpts {
* Defaults to 0
*/
export interface FindOrdersThatCoverMakerAssetFillAmountOpts {
remainingFillableMakerAssetAmounts?: BigNumber[];
remainingFillableTakerAssetAmounts?: BigNumber[];
slippageBufferAmount?: BigNumber;
}
/**
* remainingFillableTakerAssetAmount: An array of BigNumbers corresponding to the `orders` parameter.
* You can use `OrderStateUtils` `@0x/order-utils` to perform blockchain lookups for these values.
* Defaults to `makerAssetAmount` values from the orders param.
* slippageBufferAmount: An additional amount of makerAsset to be covered by the result in case of trade collisions or partial fills.
* Defaults to 0
*/
export interface FindOrdersThatCoverTakerAssetFillAmountOpts {
remainingFillableMakerAssetAmounts?: BigNumber[];
slippageBufferAmount?: BigNumber;
}