aboutsummaryrefslogtreecommitdiffstats
path: root/packages/contracts/src
diff options
context:
space:
mode:
Diffstat (limited to 'packages/contracts/src')
-rw-r--r--packages/contracts/src/utils/core_combinatorial_utils.ts47
-rw-r--r--packages/contracts/src/utils/new_order_factory.ts34
-rw-r--r--packages/contracts/src/utils/types.ts10
3 files changed, 48 insertions, 43 deletions
diff --git a/packages/contracts/src/utils/core_combinatorial_utils.ts b/packages/contracts/src/utils/core_combinatorial_utils.ts
index 4ce23d450..776d7b2fe 100644
--- a/packages/contracts/src/utils/core_combinatorial_utils.ts
+++ b/packages/contracts/src/utils/core_combinatorial_utils.ts
@@ -33,11 +33,11 @@ import {
AssetDataScenario,
ExpirationTimeSecondsScenario,
FeeRecipientAddressScenario,
- OrderAmountScenario,
+ FillScenario,
+ OrderAssetAmountScenario,
OrderScenario,
TakerAssetFillAmountScenario,
TakerScenario,
- FillScenario,
} from '../utils/types';
chaiSetup.configure();
@@ -144,13 +144,13 @@ export class CoreCombinatorialUtils {
public zrxAssetData: string;
public exchangeWrapper: ExchangeWrapper;
public assetWrapper: AssetWrapper;
- public static generateOrderCombinations(): OrderScenario[] {
+ public static generateFillOrderCombinations(): FillScenario[] {
const takerScenarios = [TakerScenario.Unspecified];
const feeRecipientScenarios = [FeeRecipientAddressScenario.EthUserAddress];
- const makerAssetAmountScenario = [OrderAmountScenario.Large];
- const takerAssetAmountScenario = [OrderAmountScenario.Large];
- const makerFeeScenario = [OrderAmountScenario.Large];
- const takerFeeScenario = [OrderAmountScenario.Large];
+ const makerAssetAmountScenario = [OrderAssetAmountScenario.Large];
+ const takerAssetAmountScenario = [OrderAssetAmountScenario.Large];
+ const makerFeeScenario = [OrderAssetAmountScenario.Large];
+ const takerFeeScenario = [OrderAssetAmountScenario.Large];
const expirationTimeSecondsScenario = [ExpirationTimeSecondsScenario.InFuture];
const makerAssetDataScenario = [
AssetDataScenario.ERC20FiveDecimals,
@@ -164,7 +164,8 @@ export class CoreCombinatorialUtils {
AssetDataScenario.ERC721,
AssetDataScenario.ZRXFeeToken,
];
- const orderScenarioArrays = CoreCombinatorialUtils._allPossibleCases([
+ const takerAssetFillAmountScenario = [TakerAssetFillAmountScenario.ExactlyRemainingFillableTakerAssetAmount];
+ const fillScenarioArrays = CoreCombinatorialUtils._allPossibleCases([
takerScenarios,
feeRecipientScenarios,
makerAssetAmountScenario,
@@ -174,24 +175,28 @@ export class CoreCombinatorialUtils {
expirationTimeSecondsScenario,
makerAssetDataScenario,
takerAssetDataScenario,
+ takerAssetFillAmountScenario,
]);
- const orderScenarios = _.map(orderScenarioArrays, orderScenarioArray => {
- const orderScenario: OrderScenario = {
- takerScenario: orderScenarioArray[0] as TakerScenario,
- feeRecipientScenario: orderScenarioArray[1] as FeeRecipientAddressScenario,
- makerAssetAmountScenario: orderScenarioArray[2] as OrderAmountScenario,
- takerAssetAmountScenario: orderScenarioArray[3] as OrderAmountScenario,
- makerFeeScenario: orderScenarioArray[4] as OrderAmountScenario,
- takerFeeScenario: orderScenarioArray[5] as OrderAmountScenario,
- expirationTimeSecondsScenario: orderScenarioArray[6] as ExpirationTimeSecondsScenario,
- makerAssetDataScenario: orderScenarioArray[7] as AssetDataScenario,
- takerAssetDataScenario: orderScenarioArray[8] as AssetDataScenario,
+ const fillScenarios = _.map(fillScenarioArrays, fillScenarioArray => {
+ const fillScenario: FillScenario = {
+ orderScenario: {
+ takerScenario: fillScenarioArray[0] as TakerScenario,
+ feeRecipientScenario: fillScenarioArray[1] as FeeRecipientAddressScenario,
+ makerAssetAmountScenario: fillScenarioArray[2] as OrderAssetAmountScenario,
+ takerAssetAmountScenario: fillScenarioArray[3] as OrderAssetAmountScenario,
+ makerFeeScenario: fillScenarioArray[4] as OrderAssetAmountScenario,
+ takerFeeScenario: fillScenarioArray[5] as OrderAssetAmountScenario,
+ expirationTimeSecondsScenario: fillScenarioArray[6] as ExpirationTimeSecondsScenario,
+ makerAssetDataScenario: fillScenarioArray[7] as AssetDataScenario,
+ takerAssetDataScenario: fillScenarioArray[8] as AssetDataScenario,
+ },
+ takerAssetFillAmountScenario: fillScenarioArray[9] as TakerAssetFillAmountScenario,
};
- return orderScenario;
+ return fillScenario;
});
- return orderScenarios;
+ return fillScenarios;
}
private static _allPossibleCases(arrays: string[][]): string[][] {
if (arrays.length === 1) {
diff --git a/packages/contracts/src/utils/new_order_factory.ts b/packages/contracts/src/utils/new_order_factory.ts
index 7de7be3bd..22705d3e7 100644
--- a/packages/contracts/src/utils/new_order_factory.ts
+++ b/packages/contracts/src/utils/new_order_factory.ts
@@ -10,7 +10,7 @@ import {
ERC721TokenIdsByOwner,
ExpirationTimeSecondsScenario,
FeeRecipientAddressScenario,
- OrderAmountScenario,
+ OrderAssetAmountScenario,
OrderScenario,
TakerScenario,
} from './types';
@@ -118,7 +118,7 @@ export class NewOrderFactory {
}
switch (orderScenario.makerAssetAmountScenario) {
- case OrderAmountScenario.Large:
+ case OrderAssetAmountScenario.Large:
switch (orderScenario.makerAssetDataScenario) {
case AssetDataScenario.ZRXFeeToken:
case AssetDataScenario.ERC20NonZRXEighteenDecimals:
@@ -134,7 +134,7 @@ export class NewOrderFactory {
throw errorUtils.spawnSwitchErr('AssetDataScenario', orderScenario.makerAssetDataScenario);
}
break;
- case OrderAmountScenario.Small:
+ case OrderAssetAmountScenario.Small:
switch (orderScenario.makerAssetDataScenario) {
case AssetDataScenario.ZRXFeeToken:
case AssetDataScenario.ERC20NonZRXEighteenDecimals:
@@ -150,15 +150,15 @@ export class NewOrderFactory {
throw errorUtils.spawnSwitchErr('AssetDataScenario', orderScenario.makerAssetDataScenario);
}
break;
- case OrderAmountScenario.Zero:
+ case OrderAssetAmountScenario.Zero:
makerAssetAmount = new BigNumber(0);
break;
default:
- throw errorUtils.spawnSwitchErr('OrderAmountScenario', orderScenario.makerAssetAmountScenario);
+ throw errorUtils.spawnSwitchErr('OrderAssetAmountScenario', orderScenario.makerAssetAmountScenario);
}
switch (orderScenario.takerAssetAmountScenario) {
- case OrderAmountScenario.Large:
+ case OrderAssetAmountScenario.Large:
switch (orderScenario.takerAssetDataScenario) {
case AssetDataScenario.ERC20NonZRXEighteenDecimals:
case AssetDataScenario.ZRXFeeToken:
@@ -174,7 +174,7 @@ export class NewOrderFactory {
throw errorUtils.spawnSwitchErr('AssetDataScenario', orderScenario.takerAssetDataScenario);
}
break;
- case OrderAmountScenario.Small:
+ case OrderAssetAmountScenario.Small:
switch (orderScenario.takerAssetDataScenario) {
case AssetDataScenario.ERC20NonZRXEighteenDecimals:
case AssetDataScenario.ZRXFeeToken:
@@ -190,39 +190,39 @@ export class NewOrderFactory {
throw errorUtils.spawnSwitchErr('AssetDataScenario', orderScenario.takerAssetDataScenario);
}
break;
- case OrderAmountScenario.Zero:
+ case OrderAssetAmountScenario.Zero:
takerAssetAmount = new BigNumber(0);
break;
default:
- throw errorUtils.spawnSwitchErr('OrderAmountScenario', orderScenario.takerAssetAmountScenario);
+ throw errorUtils.spawnSwitchErr('OrderAssetAmountScenario', orderScenario.takerAssetAmountScenario);
}
switch (orderScenario.makerFeeScenario) {
- case OrderAmountScenario.Large:
+ case OrderAssetAmountScenario.Large:
makerFee = POINT_ONE_UNITS_EIGHTEEN_DECIMALS;
break;
- case OrderAmountScenario.Small:
+ case OrderAssetAmountScenario.Small:
makerFee = POINT_ZERO_FIVE_UNITS_EIGHTEEN_DECIMALS;
break;
- case OrderAmountScenario.Zero:
+ case OrderAssetAmountScenario.Zero:
makerFee = new BigNumber(0);
break;
default:
- throw errorUtils.spawnSwitchErr('OrderAmountScenario', orderScenario.makerFeeScenario);
+ throw errorUtils.spawnSwitchErr('OrderAssetAmountScenario', orderScenario.makerFeeScenario);
}
switch (orderScenario.takerFeeScenario) {
- case OrderAmountScenario.Large:
+ case OrderAssetAmountScenario.Large:
takerFee = POINT_ONE_UNITS_EIGHTEEN_DECIMALS;
break;
- case OrderAmountScenario.Small:
+ case OrderAssetAmountScenario.Small:
takerFee = POINT_ZERO_FIVE_UNITS_EIGHTEEN_DECIMALS;
break;
- case OrderAmountScenario.Zero:
+ case OrderAssetAmountScenario.Zero:
takerFee = new BigNumber(0);
break;
default:
- throw errorUtils.spawnSwitchErr('OrderAmountScenario', orderScenario.takerFeeScenario);
+ throw errorUtils.spawnSwitchErr('OrderAssetAmountScenario', orderScenario.takerFeeScenario);
}
switch (orderScenario.expirationTimeSecondsScenario) {
diff --git a/packages/contracts/src/utils/types.ts b/packages/contracts/src/utils/types.ts
index 318ea91f9..f0e2dde02 100644
--- a/packages/contracts/src/utils/types.ts
+++ b/packages/contracts/src/utils/types.ts
@@ -158,7 +158,7 @@ export enum FeeRecipientAddressScenario {
EthUserAddress = 'ETH_USER_ADDRESS',
}
-export enum OrderAmountScenario {
+export enum OrderAssetAmountScenario {
Zero = 'ZERO',
Large = 'LARGE',
Small = 'SMALL',
@@ -192,10 +192,10 @@ export enum TakerAssetFillAmountScenario {
export interface OrderScenario {
takerScenario: TakerScenario;
feeRecipientScenario: FeeRecipientAddressScenario;
- makerAssetAmountScenario: OrderAmountScenario;
- takerAssetAmountScenario: OrderAmountScenario;
- makerFeeScenario: OrderAmountScenario;
- takerFeeScenario: OrderAmountScenario;
+ makerAssetAmountScenario: OrderAssetAmountScenario;
+ takerAssetAmountScenario: OrderAssetAmountScenario;
+ makerFeeScenario: OrderAssetAmountScenario;
+ takerFeeScenario: OrderAssetAmountScenario;
expirationTimeSecondsScenario: ExpirationTimeSecondsScenario;
makerAssetDataScenario: AssetDataScenario;
takerAssetDataScenario: AssetDataScenario;