@0x/contracts-exchange: Update fill order tests for arbitrary fee tokens. (Still more to do)

This commit is contained in:
Lawrence Forman
2019-05-14 11:33:52 -04:00
committed by Amir Bandeali
parent f4bf4ee0f2
commit 8aa3b535f0
9 changed files with 381 additions and 186 deletions

View File

@@ -138,7 +138,6 @@ describe('Exchange core', () => {
artifacts.Exchange,
provider,
txDefaults,
assetDataUtils.encodeERC20AssetData(zrxToken.address),
new BigNumber(chainId),
);
maliciousWallet = maliciousValidator = await TestStaticCallReceiverContract.deployFrom0xArtifactAsync(

View File

@@ -4,6 +4,7 @@ import {
BalanceAmountScenario,
chaiSetup,
ExpirationTimeSecondsScenario,
FeeAssetDataScenario,
FeeRecipientAddressScenario,
FillScenario,
OrderAssetAmountScenario,
@@ -30,21 +31,23 @@ const defaultFillScenario = {
makerFeeScenario: OrderAssetAmountScenario.Large,
takerFeeScenario: OrderAssetAmountScenario.Large,
expirationTimeSecondsScenario: ExpirationTimeSecondsScenario.InFuture,
makerAssetDataScenario: AssetDataScenario.ERC20NonZRXEighteenDecimals,
takerAssetDataScenario: AssetDataScenario.ERC20NonZRXEighteenDecimals,
makerAssetDataScenario: AssetDataScenario.ERC20EighteenDecimals,
takerAssetDataScenario: AssetDataScenario.ERC20EighteenDecimals,
makerFeeAssetDataScenario: FeeAssetDataScenario.ERC20EighteenDecimals,
takerFeeAssetDataScenario: FeeAssetDataScenario.ERC20EighteenDecimals,
},
takerAssetFillAmountScenario: TakerAssetFillAmountScenario.LessThanRemainingFillableTakerAssetAmount,
makerStateScenario: {
traderAssetBalance: BalanceAmountScenario.Higher,
traderAssetAllowance: AllowanceAmountScenario.Higher,
zrxFeeBalance: BalanceAmountScenario.Higher,
zrxFeeAllowance: AllowanceAmountScenario.Higher,
feeBalance: BalanceAmountScenario.Higher,
feeAllowance: AllowanceAmountScenario.Higher,
},
takerStateScenario: {
traderAssetBalance: BalanceAmountScenario.Higher,
traderAssetAllowance: AllowanceAmountScenario.Higher,
zrxFeeBalance: BalanceAmountScenario.Higher,
zrxFeeAllowance: AllowanceAmountScenario.Higher,
feeBalance: BalanceAmountScenario.Higher,
feeAllowance: AllowanceAmountScenario.Higher,
},
};
@@ -250,7 +253,7 @@ describe('FillOrder Tests', () => {
orderScenario: {
...defaultFillScenario.orderScenario,
makerAssetDataScenario: AssetDataScenario.ERC721,
takerAssetDataScenario: AssetDataScenario.ERC20NonZRXEighteenDecimals,
takerAssetDataScenario: AssetDataScenario.ERC20EighteenDecimals,
},
takerAssetFillAmountScenario: TakerAssetFillAmountScenario.ExactlyRemainingFillableTakerAssetAmount,
};
@@ -262,7 +265,7 @@ describe('FillOrder Tests', () => {
...defaultFillScenario,
orderScenario: {
...defaultFillScenario.orderScenario,
makerAssetDataScenario: AssetDataScenario.ERC20NonZRXEighteenDecimals,
makerAssetDataScenario: AssetDataScenario.ERC20EighteenDecimals,
takerAssetDataScenario: AssetDataScenario.ERC721,
},
takerAssetFillAmountScenario: TakerAssetFillAmountScenario.ExactlyRemainingFillableTakerAssetAmount,
@@ -276,7 +279,7 @@ describe('FillOrder Tests', () => {
orderScenario: {
...defaultFillScenario.orderScenario,
makerAssetDataScenario: AssetDataScenario.ERC721,
takerAssetDataScenario: AssetDataScenario.ERC20NonZRXEighteenDecimals,
takerAssetDataScenario: AssetDataScenario.ERC20EighteenDecimals,
},
takerAssetFillAmountScenario: TakerAssetFillAmountScenario.ExactlyRemainingFillableTakerAssetAmount,
makerStateScenario: {

View File

@@ -35,6 +35,8 @@ const emptyOrder: Order = {
takerAssetAmount: new BigNumber(0),
makerAssetData: '0x',
takerAssetData: '0x',
makerFeeAssetData: '0x',
takerFeeAssetData: '0x',
salt: new BigNumber(0),
feeRecipientAddress: constants.NULL_ADDRESS,
expirationTimeSeconds: new BigNumber(0),

View File

@@ -121,7 +121,6 @@ describe('matchOrders', () => {
artifacts.Exchange,
provider,
txDefaults,
assetDataUtils.encodeERC20AssetData(zrxToken.address),
new BigNumber(chainId),
);
exchangeWrapper = new ExchangeWrapper(exchange, provider);

View File

@@ -115,7 +115,6 @@ describe('Exchange transactions', () => {
artifacts.Exchange,
provider,
txDefaults,
assetDataUtils.encodeERC20AssetData(zrxToken.address),
new BigNumber(chainId),
);
exchangeWrapper = new ExchangeWrapper(exchangeInstance, provider);

View File

@@ -7,6 +7,7 @@ import {
chaiSetup,
constants,
ExpirationTimeSecondsScenario,
FeeAssetDataScenario,
FeeRecipientAddressScenario,
FillScenario,
OrderAssetAmountScenario,
@@ -67,24 +68,23 @@ export async function fillOrderCombinatorialUtilsFactoryAsync(
const erc20Wrapper = new ERC20Wrapper(provider, userAddresses, ownerAddress);
const erc721Wrapper = new ERC721Wrapper(provider, userAddresses, ownerAddress);
const erc20EighteenDecimalTokenCount = 3;
const erc20EighteenDecimalTokenCount = 4;
const eighteenDecimals = new BigNumber(18);
const [
erc20EighteenDecimalTokenA,
erc20EighteenDecimalTokenB,
zrxToken,
] = await erc20Wrapper.deployDummyTokensAsync(erc20EighteenDecimalTokenCount, eighteenDecimals);
const zrxAssetData = assetDataUtils.encodeERC20AssetData(zrxToken.address);
const erc20EighteenDecimalTokens = await erc20Wrapper.deployDummyTokensAsync(
erc20EighteenDecimalTokenCount,
eighteenDecimals,
);
const erc20FiveDecimalTokenCount = 2;
const fiveDecimals = new BigNumber(5);
const [erc20FiveDecimalTokenA, erc20FiveDecimalTokenB] = await erc20Wrapper.deployDummyTokensAsync(
const erc20FiveDecimalTokens = await erc20Wrapper.deployDummyTokensAsync(
erc20FiveDecimalTokenCount,
fiveDecimals,
);
const zeroDecimals = new BigNumber(0);
const erc20ZeroDecimalTokenCount = 2;
const [erc20ZeroDecimalTokenA, erc20ZeroDecimalTokenB] = await erc20Wrapper.deployDummyTokensAsync(
const erc20ZeroDecimalTokens = await erc20Wrapper.deployDummyTokensAsync(
erc20ZeroDecimalTokenCount,
zeroDecimals,
);
@@ -102,7 +102,6 @@ export async function fillOrderCombinatorialUtilsFactoryAsync(
artifacts.Exchange,
provider,
txDefaults,
zrxAssetData,
new BigNumber(chainId),
);
const exchangeWrapper = new ExchangeWrapper(exchangeContract, provider);
@@ -110,24 +109,25 @@ export async function fillOrderCombinatorialUtilsFactoryAsync(
await exchangeWrapper.registerAssetProxyAsync(erc721Proxy.address, ownerAddress);
await web3Wrapper.awaitTransactionSuccessAsync(
await erc20Proxy.addAuthorizedAddress.sendTransactionAsync(exchangeContract.address, {
from: ownerAddress,
}),
await erc20Proxy.addAuthorizedAddress.sendTransactionAsync(
exchangeContract.address,
{ from: ownerAddress },
),
constants.AWAIT_TRANSACTION_MINED_MS,
);
await web3Wrapper.awaitTransactionSuccessAsync(
await erc721Proxy.addAuthorizedAddress.sendTransactionAsync(exchangeContract.address, {
from: ownerAddress,
}),
await erc721Proxy.addAuthorizedAddress.sendTransactionAsync(
exchangeContract.address,
{ from: ownerAddress }
),
constants.AWAIT_TRANSACTION_MINED_MS,
);
const orderFactory = new OrderFactoryFromScenario(
userAddresses,
zrxToken.address,
[erc20EighteenDecimalTokenA.address, erc20EighteenDecimalTokenB.address],
[erc20FiveDecimalTokenA.address, erc20FiveDecimalTokenB.address],
[erc20ZeroDecimalTokenA.address, erc20ZeroDecimalTokenB.address],
erc20EighteenDecimalTokens.map(token => token.address),
erc20FiveDecimalTokens.map(token => token.address),
erc20ZeroDecimalTokens.map(token => token.address),
erc721Token,
erc721Balances,
exchangeContract.address,
@@ -147,7 +147,6 @@ export async function fillOrderCombinatorialUtilsFactoryAsync(
makerAddress,
makerPrivateKey,
takerAddress,
zrxAssetData,
exchangeWrapper,
assetWrapper,
testLibsContract,
@@ -161,7 +160,6 @@ export class FillOrderCombinatorialUtils {
public makerAddress: string;
public makerPrivateKey: Buffer;
public takerAddress: string;
public zrxAssetData: string;
public exchangeWrapper: ExchangeWrapper;
public assetWrapper: AssetWrapper;
public testLibsContract: TestLibsContract;
@@ -201,15 +199,27 @@ export class FillOrderCombinatorialUtils {
];
const makerAssetDataScenario = [
AssetDataScenario.ERC20FiveDecimals,
AssetDataScenario.ERC20NonZRXEighteenDecimals,
AssetDataScenario.ERC20EighteenDecimals,
AssetDataScenario.ERC721,
AssetDataScenario.ZRXFeeToken,
];
const takerAssetDataScenario = [
AssetDataScenario.ERC20FiveDecimals,
AssetDataScenario.ERC20NonZRXEighteenDecimals,
AssetDataScenario.ERC20EighteenDecimals,
AssetDataScenario.ERC721,
AssetDataScenario.ZRXFeeToken,
];
const makerFeeAssetDataScenario = [
FeeAssetDataScenario.ERC20FiveDecimals,
FeeAssetDataScenario.ERC20EighteenDecimals,
FeeAssetDataScenario.ERC721,
FeeAssetDataScenario.MakerToken,
FeeAssetDataScenario.TakerToken,
];
const takerFeeAssetDataScenario = [
FeeAssetDataScenario.ERC20FiveDecimals,
FeeAssetDataScenario.ERC20EighteenDecimals,
FeeAssetDataScenario.ERC721,
FeeAssetDataScenario.MakerToken,
FeeAssetDataScenario.TakerToken,
];
const takerAssetFillAmountScenario = [
TakerAssetFillAmountScenario.ExactlyRemainingFillableTakerAssetAmount,
@@ -227,12 +237,12 @@ export class FillOrderCombinatorialUtils {
// AllowanceAmountScenario.TooLow,
// AllowanceAmountScenario.Unlimited,
];
const makerZRXBalanceScenario = [
const makerFeeBalanceScenario = [
BalanceAmountScenario.Higher,
// BalanceAmountScenario.Exact,
// BalanceAmountScenario.TooLow,
];
const makerZRXAllowanceScenario = [
const makerFeeAllowanceScenario = [
AllowanceAmountScenario.Higher,
// AllowanceAmountScenario.Exact,
// AllowanceAmountScenario.TooLow,
@@ -249,12 +259,12 @@ export class FillOrderCombinatorialUtils {
// AllowanceAmountScenario.TooLow,
// AllowanceAmountScenario.Unlimited,
];
const takerZRXBalanceScenario = [
const takerFeeBalanceScenario = [
BalanceAmountScenario.Higher,
// BalanceAmountScenario.Exact,
// BalanceAmountScenario.TooLow,
];
const takerZRXAllowanceScenario = [
const takerFeeAllowanceScenario = [
AllowanceAmountScenario.Higher,
// AllowanceAmountScenario.Exact,
// AllowanceAmountScenario.TooLow,
@@ -270,15 +280,17 @@ export class FillOrderCombinatorialUtils {
expirationTimeSecondsScenario,
makerAssetDataScenario,
takerAssetDataScenario,
makerFeeAssetDataScenario,
takerFeeAssetDataScenario,
takerAssetFillAmountScenario,
makerAssetBalanceScenario,
makerAssetAllowanceScenario,
makerZRXBalanceScenario,
makerZRXAllowanceScenario,
makerFeeBalanceScenario,
makerFeeAllowanceScenario,
takerAssetBalanceScenario,
takerAssetAllowanceScenario,
takerZRXBalanceScenario,
takerZRXAllowanceScenario,
takerFeeBalanceScenario,
takerFeeAllowanceScenario,
]);
const fillScenarios = _.map(fillScenarioArrays, fillScenarioArray => {
@@ -294,19 +306,21 @@ export class FillOrderCombinatorialUtils {
expirationTimeSecondsScenario: fillScenarioArray[6] as ExpirationTimeSecondsScenario,
makerAssetDataScenario: fillScenarioArray[7] as AssetDataScenario,
takerAssetDataScenario: fillScenarioArray[8] as AssetDataScenario,
makerFeeAssetDataScenario: fillScenarioArray[9] as FeeAssetDataScenario,
takerFeeAssetDataScenario: fillScenarioArray[10] as FeeAssetDataScenario,
},
takerAssetFillAmountScenario: fillScenarioArray[9] as TakerAssetFillAmountScenario,
takerAssetFillAmountScenario: fillScenarioArray[11] as TakerAssetFillAmountScenario,
makerStateScenario: {
traderAssetBalance: fillScenarioArray[10] as BalanceAmountScenario,
traderAssetAllowance: fillScenarioArray[11] as AllowanceAmountScenario,
zrxFeeBalance: fillScenarioArray[12] as BalanceAmountScenario,
zrxFeeAllowance: fillScenarioArray[13] as AllowanceAmountScenario,
traderAssetBalance: fillScenarioArray[12] as BalanceAmountScenario,
traderAssetAllowance: fillScenarioArray[13] as AllowanceAmountScenario,
feeBalance: fillScenarioArray[14] as BalanceAmountScenario,
feeAllowance: fillScenarioArray[15] as AllowanceAmountScenario,
},
takerStateScenario: {
traderAssetBalance: fillScenarioArray[14] as BalanceAmountScenario,
traderAssetAllowance: fillScenarioArray[15] as AllowanceAmountScenario,
zrxFeeBalance: fillScenarioArray[16] as BalanceAmountScenario,
zrxFeeAllowance: fillScenarioArray[17] as AllowanceAmountScenario,
traderAssetBalance: fillScenarioArray[16] as BalanceAmountScenario,
traderAssetAllowance: fillScenarioArray[17] as AllowanceAmountScenario,
feeBalance: fillScenarioArray[18] as BalanceAmountScenario,
feeAllowance: fillScenarioArray[19] as AllowanceAmountScenario,
},
};
// tslint:enable:custom-no-magic-numbers
@@ -346,7 +360,6 @@ export class FillOrderCombinatorialUtils {
makerAddress: string,
makerPrivateKey: Buffer,
takerAddress: string,
zrxAssetData: string,
exchangeWrapper: ExchangeWrapper,
assetWrapper: AssetWrapper,
testLibsContract: TestLibsContract,
@@ -356,7 +369,6 @@ export class FillOrderCombinatorialUtils {
this.makerAddress = makerAddress;
this.makerPrivateKey = makerPrivateKey;
this.takerAddress = takerAddress;
this.zrxAssetData = zrxAssetData;
this.exchangeWrapper = exchangeWrapper;
this.assetWrapper = assetWrapper;
this.testLibsContract = testLibsContract;
@@ -380,7 +392,6 @@ export class FillOrderCombinatorialUtils {
const balanceAndProxyAllowanceFetcher = new SimpleAssetBalanceAndProxyAllowanceFetcher(this.assetWrapper);
const orderFilledCancelledFetcher = new SimpleOrderFilledCancelledFetcher(
this.exchangeWrapper,
this.zrxAssetData,
);
// 3. Figure out fill amount
@@ -411,7 +422,6 @@ export class FillOrderCombinatorialUtils {
signedOrder,
takerAssetFillAmount,
this.takerAddress,
this.zrxAssetData,
);
if (isVerbose) {
logUtils.log(`Expecting fillOrder to succeed.`);
@@ -446,22 +456,24 @@ export class FillOrderCombinatorialUtils {
const makerAddress = signedOrder.makerAddress;
const makerAssetData = signedOrder.makerAssetData;
const takerAssetData = signedOrder.takerAssetData;
const makerFeeAssetData = signedOrder.makerAssetData;
const takerFeeAssetData = signedOrder.takerAssetData;
const feeRecipient = signedOrder.feeRecipientAddress;
const expMakerAssetBalanceOfMaker = await lazyStore.getBalanceAsync(makerAssetData, makerAddress);
const expMakerAssetAllowanceOfMaker = await lazyStore.getProxyAllowanceAsync(makerAssetData, makerAddress);
const expTakerAssetBalanceOfMaker = await lazyStore.getBalanceAsync(takerAssetData, makerAddress);
const expZRXAssetBalanceOfMaker = await lazyStore.getBalanceAsync(this.zrxAssetData, makerAddress);
const expZRXAssetAllowanceOfMaker = await lazyStore.getProxyAllowanceAsync(this.zrxAssetData, makerAddress);
const expMakerFeeAssetBalanceOfMaker = await lazyStore.getBalanceAsync(makerFeeAssetData, makerAddress);
const expTakerFeeAssetBalanceOfMaker = await lazyStore.getBalanceAsync(takerFeeAssetData, makerAddress);
const expMakerFeeAssetAllowanceOfMaker = await lazyStore.getProxyAllowanceAsync(makerFeeAssetData, makerAddress);
const expTakerAssetBalanceOfTaker = await lazyStore.getBalanceAsync(takerAssetData, this.takerAddress);
const expTakerAssetAllowanceOfTaker = await lazyStore.getProxyAllowanceAsync(takerAssetData, this.takerAddress);
const expMakerAssetBalanceOfTaker = await lazyStore.getBalanceAsync(makerAssetData, this.takerAddress);
const expZRXAssetBalanceOfTaker = await lazyStore.getBalanceAsync(this.zrxAssetData, this.takerAddress);
const expZRXAssetAllowanceOfTaker = await lazyStore.getProxyAllowanceAsync(
this.zrxAssetData,
this.takerAddress,
);
const expZRXAssetBalanceOfFeeRecipient = await lazyStore.getBalanceAsync(this.zrxAssetData, feeRecipient);
const expMakerFeeAssetBalanceOfTaker = await lazyStore.getBalanceAsync(makerFeeAssetData, this.takerAddress);
const expTakerFeeAssetBalanceOfTaker = await lazyStore.getBalanceAsync(takerFeeAssetData, this.takerAddress);
const expTakerFeeAssetAllowanceOfTaker = await lazyStore.getProxyAllowanceAsync(takerFeeAssetData, this.takerAddress);
const expMakerFeeAssetBalanceOfFeeRecipient = await lazyStore.getBalanceAsync(makerFeeAssetData, feeRecipient);
const expTakerFeeAssetBalanceOfFeeRecipient = await lazyStore.getBalanceAsync(takerFeeAssetData, feeRecipient);
const orderHash = orderHashUtils.getOrderHashHex(signedOrder);
const alreadyFilledTakerAmount = await this.exchangeWrapper.getTakerAssetFilledAmountAsync(orderHash);
@@ -485,9 +497,11 @@ export class FillOrderCombinatorialUtils {
signedOrder.takerAssetAmount,
signedOrder.takerFee,
);
const fillResults = await this.exchangeWrapper.getFillOrderResultsAsync(signedOrder, this.takerAddress, {
takerAssetFillAmount,
});
const fillResults = await this.exchangeWrapper.getFillOrderResultsAsync(
signedOrder,
this.takerAddress,
{ takerAssetFillAmount }
);
expect(fillResults.takerAssetFilledAmount).to.be.bignumber.equal(
expFilledTakerAmount,
'takerAssetFilledAmount',
@@ -531,7 +545,10 @@ export class FillOrderCombinatorialUtils {
expect(log.args.makerAssetData).to.be.equal(makerAssetData, 'log.args.makerAssetData');
expect(log.args.takerAssetData).to.be.equal(takerAssetData, 'log.args.takerAssetData');
const actMakerAssetBalanceOfMaker = await this.assetWrapper.getBalanceAsync(makerAddress, makerAssetData);
const actMakerAssetBalanceOfMaker = await this.assetWrapper.getBalanceAsync(
makerAddress,
makerAssetData,
);
expect(actMakerAssetBalanceOfMaker).to.be.bignumber.equal(
expMakerAssetBalanceOfMaker,
'makerAssetBalanceOfMaker',
@@ -546,25 +563,46 @@ export class FillOrderCombinatorialUtils {
'makerAssetAllowanceOfMaker',
);
const actTakerAssetBalanceOfMaker = await this.assetWrapper.getBalanceAsync(makerAddress, takerAssetData);
const actTakerAssetBalanceOfMaker = await this.assetWrapper.getBalanceAsync(
makerAddress,
takerAssetData,
);
expect(actTakerAssetBalanceOfMaker).to.be.bignumber.equal(
expTakerAssetBalanceOfMaker,
'takerAssetBalanceOfMaker',
);
const actZRXAssetBalanceOfMaker = await this.assetWrapper.getBalanceAsync(makerAddress, this.zrxAssetData);
expect(actZRXAssetBalanceOfMaker).to.be.bignumber.equal(expZRXAssetBalanceOfMaker, 'ZRXAssetBalanceOfMaker');
const actZRXAssetAllowanceOfMaker = await this.assetWrapper.getProxyAllowanceAsync(
const actMakerFeeAssetBalanceOfMaker = await this.assetWrapper.getBalanceAsync(
makerAddress,
this.zrxAssetData,
makerFeeAssetData,
);
expect(actZRXAssetAllowanceOfMaker).to.be.bignumber.equal(
expZRXAssetAllowanceOfMaker,
'ZRXAssetAllowanceOfMaker',
expect(actMakerFeeAssetBalanceOfMaker).to.be.bignumber.equal(
expMakerFeeAssetBalanceOfMaker,
'makerFeeAssetBalanceOfMaker',
);
const actTakerAssetBalanceOfTaker = await this.assetWrapper.getBalanceAsync(this.takerAddress, takerAssetData);
const actMakerFeeAssetAllowanceOfMaker = await this.assetWrapper.getProxyAllowanceAsync(
makerAddress,
makerFeeAssetData,
);
expect(actMakerFeeAssetAllowanceOfMaker).to.be.bignumber.equal(
expMakerFeeAssetAllowanceOfMaker,
'makerFeeAssetAllowanceOfMaker',
);
const actTakerFeeAssetBalanceOfMaker = await this.assetWrapper.getBalanceAsync(
makerAddress,
takerFeeAssetData,
);
expect(actTakerFeeAssetBalanceOfMaker).to.be.bignumber.equal(
expTakerFeeAssetBalanceOfMaker,
'takerFeeAssetBalanceOfMaker',
);
const actTakerAssetBalanceOfTaker = await this.assetWrapper.getBalanceAsync(
this.takerAddress,
takerAssetData
);
expect(actTakerAssetBalanceOfTaker).to.be.bignumber.equal(
expTakerAssetBalanceOfTaker,
'TakerAssetBalanceOfTaker',
@@ -577,34 +615,61 @@ export class FillOrderCombinatorialUtils {
expect(actTakerAssetAllowanceOfTaker).to.be.bignumber.equal(
expTakerAssetAllowanceOfTaker,
'TakerAssetAllowanceOfTaker',
'takerAssetAllowanceOfTaker',
);
const actMakerAssetBalanceOfTaker = await this.assetWrapper.getBalanceAsync(this.takerAddress, makerAssetData);
const actMakerAssetBalanceOfTaker = await this.assetWrapper.getBalanceAsync(
this.takerAddress,
makerAssetData,
);
expect(actMakerAssetBalanceOfTaker).to.be.bignumber.equal(
expMakerAssetBalanceOfTaker,
'MakerAssetBalanceOfTaker',
'makerAssetBalanceOfTaker',
);
const actZRXAssetBalanceOfTaker = await this.assetWrapper.getBalanceAsync(this.takerAddress, this.zrxAssetData);
expect(actZRXAssetBalanceOfTaker).to.be.bignumber.equal(expZRXAssetBalanceOfTaker, 'ZRXAssetBalanceOfTaker');
const actZRXAssetAllowanceOfTaker = await this.assetWrapper.getProxyAllowanceAsync(
const actMakerFeeAssetBalanceOfTaker = await this.assetWrapper.getBalanceAsync(
this.takerAddress,
this.zrxAssetData,
makerFeeAssetData,
);
expect(actZRXAssetAllowanceOfTaker).to.be.bignumber.equal(
expZRXAssetAllowanceOfTaker,
'ZRXAssetAllowanceOfTaker',
expect(actMakerFeeAssetBalanceOfTaker).to.be.bignumber.equal(
expMakerFeeAssetBalanceOfTaker,
'makerFeeAssetBalanceOfTaker',
);
const actZRXAssetBalanceOfFeeRecipient = await this.assetWrapper.getBalanceAsync(
feeRecipient,
this.zrxAssetData,
const actTakerFeeAssetBalanceOfTaker = await this.assetWrapper.getBalanceAsync(
this.takerAddress,
takerFeeAssetData,
);
expect(actZRXAssetBalanceOfFeeRecipient).to.be.bignumber.equal(
expZRXAssetBalanceOfFeeRecipient,
'ZRXAssetBalanceOfFeeRecipient',
expect(actTakerFeeAssetBalanceOfTaker).to.be.bignumber.equal(
expTakerFeeAssetBalanceOfTaker,
'takerFeeAssetBalanceOfTaker',
);
const actTakerFeeAssetAllowanceOfTaker = await this.assetWrapper.getProxyAllowanceAsync(
this.takerAddress,
takerFeeAssetData,
);
expect(actTakerFeeAssetAllowanceOfTaker).to.be.bignumber.equal(
expTakerFeeAssetAllowanceOfTaker,
'takerFeeAssetAllowanceOfTaker',
);
const actMakerFeeAssetBalanceOfFeeRecipient = await this.assetWrapper.getBalanceAsync(
feeRecipient,
makerFeeAssetData,
);
expect(actMakerFeeAssetBalanceOfFeeRecipient).to.be.bignumber.equal(
expMakerFeeAssetBalanceOfFeeRecipient,
'makerFeeAssetBalanceOfFeeRecipient',
);
const actTakerFeeAssetBalanceOfFeeRecipient = await this.assetWrapper.getBalanceAsync(
feeRecipient,
takerFeeAssetData,
);
expect(actTakerFeeAssetBalanceOfFeeRecipient).to.be.bignumber.equal(
expTakerFeeAssetBalanceOfFeeRecipient,
'takerFeeAssetBalanceOfFeeRecipient',
);
}
private async _getTakerAssetFillAmountAsync(
@@ -700,25 +765,36 @@ export class FillOrderCombinatorialUtils {
signedOrder.takerAssetAmount,
signedOrder.makerFee,
);
switch (makerStateScenario.zrxFeeBalance) {
switch (makerStateScenario.feeBalance) {
case BalanceAmountScenario.Higher:
break; // Noop since this is already the default
case BalanceAmountScenario.TooLow:
if (makerFee.eq(0)) {
throw new Error(`Cannot set zrxAsserBalanceOfMaker TooLow if makerFee is 0`);
throw new Error(`Cannot set makerFeeBalanceOfMaker TooLow if makerFee is 0`);
}
const tooLowBalance = makerFee.minus(1);
await this.assetWrapper.setBalanceAsync(signedOrder.makerAddress, this.zrxAssetData, tooLowBalance);
await this.assetWrapper.setBalanceAsync(
signedOrder.makerAddress,
signedOrder.makerFeeAssetData,
tooLowBalance,
);
break;
case BalanceAmountScenario.Exact:
const exactBalance = makerFee;
await this.assetWrapper.setBalanceAsync(signedOrder.makerAddress, this.zrxAssetData, exactBalance);
await this.assetWrapper.setBalanceAsync(
signedOrder.makerAddress,
signedOrder.makerFeeAssetData,
exactBalance,
);
break;
default:
throw errorUtils.spawnSwitchErr('makerStateScenario.zrxFeeBalance', makerStateScenario.zrxFeeBalance);
throw errorUtils.spawnSwitchErr(
'makerStateScenario.feeBalance',
makerStateScenario.feeBalance,
);
}
switch (makerStateScenario.traderAssetAllowance) {
@@ -758,7 +834,7 @@ export class FillOrderCombinatorialUtils {
);
}
switch (makerStateScenario.zrxFeeAllowance) {
switch (makerStateScenario.feeAllowance) {
case AllowanceAmountScenario.Higher:
break; // Noop since this is already the default
@@ -766,7 +842,7 @@ export class FillOrderCombinatorialUtils {
const tooLowAllowance = makerFee.minus(1);
await this.assetWrapper.setProxyAllowanceAsync(
signedOrder.makerAddress,
this.zrxAssetData,
signedOrder.makerFeeAssetData,
tooLowAllowance,
);
break;
@@ -775,7 +851,7 @@ export class FillOrderCombinatorialUtils {
const exactAllowance = makerFee;
await this.assetWrapper.setProxyAllowanceAsync(
signedOrder.makerAddress,
this.zrxAssetData,
signedOrder.makerFeeAssetData,
exactAllowance,
);
break;
@@ -783,15 +859,15 @@ export class FillOrderCombinatorialUtils {
case AllowanceAmountScenario.Unlimited:
await this.assetWrapper.setProxyAllowanceAsync(
signedOrder.makerAddress,
this.zrxAssetData,
signedOrder.makerFeeAssetData,
constants.UNLIMITED_ALLOWANCE_IN_BASE_UNITS,
);
break;
default:
throw errorUtils.spawnSwitchErr(
'makerStateScenario.zrxFeeAllowance',
makerStateScenario.zrxFeeAllowance,
'makerStateScenario.feeAllowance',
makerStateScenario.feeAllowance,
);
}
@@ -804,12 +880,20 @@ export class FillOrderCombinatorialUtils {
throw new Error(`Cannot set takerAssetBalanceOfTaker TooLow if takerAssetFillAmount is 0`);
}
const tooLowBalance = takerAssetFillAmount.minus(1);
await this.assetWrapper.setBalanceAsync(this.takerAddress, signedOrder.takerAssetData, tooLowBalance);
await this.assetWrapper.setBalanceAsync(
this.takerAddress,
signedOrder.takerAssetData,
tooLowBalance,
);
break;
case BalanceAmountScenario.Exact:
const exactBalance = takerAssetFillAmount;
await this.assetWrapper.setBalanceAsync(this.takerAddress, signedOrder.takerAssetData, exactBalance);
await this.assetWrapper.setBalanceAsync(
this.takerAddress,
signedOrder.takerAssetData,
exactBalance,
);
break;
default:
@@ -824,25 +908,36 @@ export class FillOrderCombinatorialUtils {
signedOrder.takerAssetAmount,
signedOrder.takerFee,
);
switch (takerStateScenario.zrxFeeBalance) {
switch (takerStateScenario.feeBalance) {
case BalanceAmountScenario.Higher:
break; // Noop since this is already the default
case BalanceAmountScenario.TooLow:
if (takerFee.eq(0)) {
throw new Error(`Cannot set zrxAssetBalanceOfTaker TooLow if takerFee is 0`);
throw new Error(`Cannot set takerFeeBalanceOfTaker TooLow if takerFee is 0`);
}
const tooLowBalance = takerFee.minus(1);
await this.assetWrapper.setBalanceAsync(this.takerAddress, this.zrxAssetData, tooLowBalance);
await this.assetWrapper.setBalanceAsync(
this.takerAddress,
signedOrder.takerFeeAssetData,
tooLowBalance,
);
break;
case BalanceAmountScenario.Exact:
const exactBalance = takerFee;
await this.assetWrapper.setBalanceAsync(this.takerAddress, this.zrxAssetData, exactBalance);
await this.assetWrapper.setBalanceAsync(
this.takerAddress,
signedOrder.takerFeeAssetData,
exactBalance,
);
break;
default:
throw errorUtils.spawnSwitchErr('takerStateScenario.zrxFeeBalance', takerStateScenario.zrxFeeBalance);
throw errorUtils.spawnSwitchErr(
'takerStateScenario.feeBalance',
takerStateScenario.feeBalance,
);
}
switch (takerStateScenario.traderAssetAllowance) {
@@ -882,32 +977,40 @@ export class FillOrderCombinatorialUtils {
);
}
switch (takerStateScenario.zrxFeeAllowance) {
switch (takerStateScenario.feeAllowance) {
case AllowanceAmountScenario.Higher:
break; // Noop since this is already the default
case AllowanceAmountScenario.TooLow:
const tooLowAllowance = takerFee.minus(1);
await this.assetWrapper.setProxyAllowanceAsync(this.takerAddress, this.zrxAssetData, tooLowAllowance);
await this.assetWrapper.setProxyAllowanceAsync(
this.takerAddress,
signedOrder.takerFeeAssetData,
tooLowAllowance,
);
break;
case AllowanceAmountScenario.Exact:
const exactAllowance = takerFee;
await this.assetWrapper.setProxyAllowanceAsync(this.takerAddress, this.zrxAssetData, exactAllowance);
await this.assetWrapper.setProxyAllowanceAsync(
this.takerAddress,
signedOrder.takerFeeAssetData,
exactAllowance,
);
break;
case AllowanceAmountScenario.Unlimited:
await this.assetWrapper.setProxyAllowanceAsync(
this.takerAddress,
this.zrxAssetData,
signedOrder.takerFeeAssetData,
constants.UNLIMITED_ALLOWANCE_IN_BASE_UNITS,
);
break;
default:
throw errorUtils.spawnSwitchErr(
'takerStateScenario.zrxFeeAllowance',
takerStateScenario.zrxFeeAllowance,
'takerStateScenario.feeAllowance',
takerStateScenario.feeAllowance,
);
}
}

View File

@@ -4,6 +4,7 @@ import {
constants,
ERC721TokenIdsByOwner,
ExpirationTimeSecondsScenario,
FeeAssetDataScenario,
FeeRecipientAddressScenario,
OrderAssetAmountScenario,
OrderScenario,
@@ -13,20 +14,23 @@ import { assetDataUtils, generatePseudoRandomSalt } from '@0x/order-utils';
import { Order } from '@0x/types';
import { BigNumber, errorUtils } from '@0x/utils';
const TEN_UNITS_EIGHTEEN_DECIMALS = new BigNumber(10_000_000_000_000_000_000);
const FIVE_UNITS_EIGHTEEN_DECIMALS = new BigNumber(5_000_000_000_000_000_000);
const POINT_ONE_UNITS_EIGHTEEN_DECIMALS = new BigNumber(100_000_000_000_000_000);
const POINT_ZERO_FIVE_UNITS_EIGHTEEN_DECIMALS = new BigNumber(50_000_000_000_000_000);
const TEN_UNITS_FIVE_DECIMALS = new BigNumber(1_000_000);
const FIVE_UNITS_FIVE_DECIMALS = new BigNumber(500_000);
const TEN_UNITS_EIGHTEEN_DECIMALS = new BigNumber('10e18');
const FIVE_UNITS_EIGHTEEN_DECIMALS = new BigNumber('5e18');
const POINT_ONE_UNITS_EIGHTEEN_DECIMALS = new BigNumber('0.1e18');
const POINT_ZERO_FIVE_UNITS_EIGHTEEN_DECIMALS = new BigNumber('0.05e18');
const TEN_UNITS_FIVE_DECIMALS = new BigNumber('10e5');
const FIVE_UNITS_FIVE_DECIMALS = new BigNumber('5e5');
const POINT_ONE_UNITS_FIVE_DECIMALS = new BigNumber('0.1e5');
const POINT_ZERO_FIVE_UNITS_FIVE_DECIMALS = new BigNumber('0.05e5');
const TEN_UNITS_ZERO_DECIMALS = new BigNumber(10);
const ONE_THOUSAND_UNITS_ZERO_DECIMALS = new BigNumber(1000);
const ONE_UNITS_ZERO_DECIMALS = new BigNumber(1);
const ONE_NFT_UNIT = new BigNumber(1);
const ZERO_UNITS = new BigNumber(0);
export class OrderFactoryFromScenario {
private readonly _userAddresses: string[];
private readonly _zrxAddress: string;
private readonly _nonZrxERC20EighteenDecimalTokenAddresses: string[];
private readonly _erc20EighteenDecimalTokenAddresses: string[];
private readonly _erc20FiveDecimalTokenAddresses: string[];
private readonly _erc20ZeroDecimalTokenAddresses: string[];
private readonly _erc721Token: DummyERC721TokenContract;
@@ -35,8 +39,7 @@ export class OrderFactoryFromScenario {
private readonly _chainId: number;
constructor(
userAddresses: string[],
zrxAddress: string,
nonZrxERC20EighteenDecimalTokenAddresses: string[],
erc20EighteenDecimalTokenAddresses: string[],
erc20FiveDecimalTokenAddresses: string[],
erc20ZeroDecimalTokenAddresses: string[],
erc721Token: DummyERC721TokenContract,
@@ -45,8 +48,7 @@ export class OrderFactoryFromScenario {
chainId: number,
) {
this._userAddresses = userAddresses;
this._zrxAddress = zrxAddress;
this._nonZrxERC20EighteenDecimalTokenAddresses = nonZrxERC20EighteenDecimalTokenAddresses;
this._erc20EighteenDecimalTokenAddresses = erc20EighteenDecimalTokenAddresses;
this._erc20FiveDecimalTokenAddresses = erc20FiveDecimalTokenAddresses;
this._erc20ZeroDecimalTokenAddresses = erc20ZeroDecimalTokenAddresses;
this._erc721Token = erc721Token;
@@ -65,8 +67,10 @@ export class OrderFactoryFromScenario {
let makerFee;
let takerFee;
let expirationTimeSeconds;
let makerAssetData;
let takerAssetData;
let makerAssetData = constants.NULL_BYTES;
let takerAssetData = constants.NULL_BYTES;
let makerFeeAssetData = constants.NULL_BYTES;
let takerFeeAssetData = constants.NULL_BYTES;
switch (orderScenario.feeRecipientScenario) {
case FeeRecipientAddressScenario.BurnAddress:
@@ -80,11 +84,8 @@ export class OrderFactoryFromScenario {
}
switch (orderScenario.makerAssetDataScenario) {
case AssetDataScenario.ZRXFeeToken:
makerAssetData = assetDataUtils.encodeERC20AssetData(this._zrxAddress);
break;
case AssetDataScenario.ERC20NonZRXEighteenDecimals:
makerAssetData = assetDataUtils.encodeERC20AssetData(this._nonZrxERC20EighteenDecimalTokenAddresses[0]);
case AssetDataScenario.ERC20EighteenDecimals:
makerAssetData = assetDataUtils.encodeERC20AssetData(this._erc20EighteenDecimalTokenAddresses[0]);
break;
case AssetDataScenario.ERC20FiveDecimals:
makerAssetData = assetDataUtils.encodeERC20AssetData(this._erc20FiveDecimalTokenAddresses[0]);
@@ -103,11 +104,8 @@ export class OrderFactoryFromScenario {
}
switch (orderScenario.takerAssetDataScenario) {
case AssetDataScenario.ZRXFeeToken:
takerAssetData = assetDataUtils.encodeERC20AssetData(this._zrxAddress);
break;
case AssetDataScenario.ERC20NonZRXEighteenDecimals:
takerAssetData = assetDataUtils.encodeERC20AssetData(this._nonZrxERC20EighteenDecimalTokenAddresses[1]);
case AssetDataScenario.ERC20EighteenDecimals:
takerAssetData = assetDataUtils.encodeERC20AssetData(this._erc20EighteenDecimalTokenAddresses[1]);
break;
case AssetDataScenario.ERC20FiveDecimals:
takerAssetData = assetDataUtils.encodeERC20AssetData(this._erc20FiveDecimalTokenAddresses[1]);
@@ -128,8 +126,7 @@ export class OrderFactoryFromScenario {
switch (orderScenario.makerAssetAmountScenario) {
case OrderAssetAmountScenario.Large:
switch (orderScenario.makerAssetDataScenario) {
case AssetDataScenario.ZRXFeeToken:
case AssetDataScenario.ERC20NonZRXEighteenDecimals:
case AssetDataScenario.ERC20EighteenDecimals:
makerAssetAmount = TEN_UNITS_EIGHTEEN_DECIMALS;
break;
case AssetDataScenario.ERC20FiveDecimals:
@@ -147,8 +144,7 @@ export class OrderFactoryFromScenario {
break;
case OrderAssetAmountScenario.Small:
switch (orderScenario.makerAssetDataScenario) {
case AssetDataScenario.ZRXFeeToken:
case AssetDataScenario.ERC20NonZRXEighteenDecimals:
case AssetDataScenario.ERC20EighteenDecimals:
makerAssetAmount = FIVE_UNITS_EIGHTEEN_DECIMALS;
break;
case AssetDataScenario.ERC20FiveDecimals:
@@ -174,8 +170,7 @@ export class OrderFactoryFromScenario {
switch (orderScenario.takerAssetAmountScenario) {
case OrderAssetAmountScenario.Large:
switch (orderScenario.takerAssetDataScenario) {
case AssetDataScenario.ERC20NonZRXEighteenDecimals:
case AssetDataScenario.ZRXFeeToken:
case AssetDataScenario.ERC20EighteenDecimals:
takerAssetAmount = TEN_UNITS_EIGHTEEN_DECIMALS;
break;
case AssetDataScenario.ERC20FiveDecimals:
@@ -193,8 +188,7 @@ export class OrderFactoryFromScenario {
break;
case OrderAssetAmountScenario.Small:
switch (orderScenario.takerAssetDataScenario) {
case AssetDataScenario.ERC20NonZRXEighteenDecimals:
case AssetDataScenario.ZRXFeeToken:
case AssetDataScenario.ERC20EighteenDecimals:
takerAssetAmount = FIVE_UNITS_EIGHTEEN_DECIMALS;
break;
case AssetDataScenario.ERC20FiveDecimals:
@@ -217,33 +211,68 @@ export class OrderFactoryFromScenario {
throw errorUtils.spawnSwitchErr('OrderAssetAmountScenario', orderScenario.takerAssetAmountScenario);
}
switch (orderScenario.makerFeeScenario) {
case OrderAssetAmountScenario.Large:
makerFee = POINT_ONE_UNITS_EIGHTEEN_DECIMALS;
break;
case OrderAssetAmountScenario.Small:
makerFee = POINT_ZERO_FIVE_UNITS_EIGHTEEN_DECIMALS;
break;
case OrderAssetAmountScenario.Zero:
makerFee = new BigNumber(0);
break;
default:
throw errorUtils.spawnSwitchErr('OrderAssetAmountScenario', orderScenario.makerFeeScenario);
const feeFromScenario = (
feeAmountScenario : OrderAssetAmountScenario,
feeAssetDataScenario: FeeAssetDataScenario,
erc20EighteenDecimalTokenAddress: string,
erc20FiveDecimalTokenAddress: string,
erc20ZeroDecimalTokenAddress: string,
erc721AssetId: BigNumber,
): [BigNumber, string] => {
const feeAmount = getFeeAmountFromScenario(
orderScenario,
orderScenario.takerAssetDataScenario,
feeAmountScenario,
);
switch (feeAssetDataScenario) {
case FeeAssetDataScenario.MakerToken:
return [ feeAmount, makerAssetData ];
case FeeAssetDataScenario.TakerToken:
return [ feeAmount, takerAssetData ];
case FeeAssetDataScenario.ERC20EighteenDecimals:
return [
feeAmount,
assetDataUtils.encodeERC20AssetData(erc20EighteenDecimalTokenAddress),
];
case FeeAssetDataScenario.ERC20FiveDecimals:
return [
feeAmount,
assetDataUtils.encodeERC20AssetData(erc20FiveDecimalTokenAddress),
];
case FeeAssetDataScenario.ERC20ZeroDecimals:
return [
feeAmount,
assetDataUtils.encodeERC20AssetData(erc20ZeroDecimalTokenAddress),
];
case FeeAssetDataScenario.ERC721:
return [
feeAmount,
assetDataUtils.encodeERC721AssetData(
this._erc721Token.address,
erc721AssetId,
),
];
default:
throw errorUtils.spawnSwitchErr('FeeAssetDataScenario', feeAssetDataScenario);
}
}
switch (orderScenario.takerFeeScenario) {
case OrderAssetAmountScenario.Large:
takerFee = POINT_ONE_UNITS_EIGHTEEN_DECIMALS;
break;
case OrderAssetAmountScenario.Small:
takerFee = POINT_ZERO_FIVE_UNITS_EIGHTEEN_DECIMALS;
break;
case OrderAssetAmountScenario.Zero:
takerFee = new BigNumber(0);
break;
default:
throw errorUtils.spawnSwitchErr('OrderAssetAmountScenario', orderScenario.takerFeeScenario);
}
[ makerFee, makerFeeAssetData ] = feeFromScenario(
orderScenario.makerFeeScenario,
orderScenario.makerFeeAssetDataScenario,
this._erc20EighteenDecimalTokenAddresses[2],
this._erc20FiveDecimalTokenAddresses[2],
this._erc20ZeroDecimalTokenAddresses[2],
erc721MakerAssetIds[1],
);
[ takerFee, takerFeeAssetData ] = feeFromScenario(
orderScenario.takerFeeScenario,
orderScenario.takerFeeAssetDataScenario,
this._erc20EighteenDecimalTokenAddresses[3],
this._erc20FiveDecimalTokenAddresses[3],
this._erc20ZeroDecimalTokenAddresses[3],
erc721TakerAssetIds[2],
);
switch (orderScenario.expirationTimeSecondsScenario) {
case ExpirationTimeSecondsScenario.InFuture:
@@ -286,6 +315,8 @@ export class OrderFactoryFromScenario {
takerAssetAmount,
makerAssetData,
takerAssetData,
makerFeeAssetData,
takerFeeAssetData,
salt: generatePseudoRandomSalt(),
feeRecipientAddress,
expirationTimeSeconds,
@@ -298,3 +329,68 @@ export class OrderFactoryFromScenario {
return order;
}
}
function getFeeAmountFromScenario(
orderScenario: OrderScenario,
feeAssetDataScenario: AssetDataScenario | FeeAssetDataScenario,
feeAmountScenario: OrderAssetAmountScenario,
): BigNumber {
switch (feeAssetDataScenario) {
case FeeAssetDataScenario.ERC721:
switch (feeAmountScenario) {
case OrderAssetAmountScenario.Zero:
return ZERO_UNITS;
case OrderAssetAmountScenario.Small:
case OrderAssetAmountScenario.Large:
return ONE_NFT_UNIT;
default:
throw errorUtils.spawnSwitchErr('OrderAssetAmountScenario', feeAmountScenario);
}
case FeeAssetDataScenario.ERC20ZeroDecimals:
switch (feeAmountScenario) {
case OrderAssetAmountScenario.Zero:
return ZERO_UNITS;
case OrderAssetAmountScenario.Small:
case OrderAssetAmountScenario.Large:
return ONE_UNITS_ZERO_DECIMALS;
default:
throw errorUtils.spawnSwitchErr('OrderAssetAmountScenario', feeAmountScenario);
}
case FeeAssetDataScenario.ERC20FiveDecimals:
switch (feeAmountScenario) {
case OrderAssetAmountScenario.Zero:
return ZERO_UNITS;
case OrderAssetAmountScenario.Small:
return POINT_ZERO_FIVE_UNITS_FIVE_DECIMALS;
case OrderAssetAmountScenario.Large:
return POINT_ONE_UNITS_FIVE_DECIMALS;
default:
throw errorUtils.spawnSwitchErr('OrderAssetAmountScenario', feeAmountScenario);
}
case FeeAssetDataScenario.ERC20EighteenDecimals:
switch (feeAmountScenario) {
case OrderAssetAmountScenario.Zero:
return ZERO_UNITS;
case OrderAssetAmountScenario.Small:
return POINT_ZERO_FIVE_UNITS_EIGHTEEN_DECIMALS;
case OrderAssetAmountScenario.Large:
return POINT_ONE_UNITS_EIGHTEEN_DECIMALS;
default:
throw errorUtils.spawnSwitchErr('OrderAssetAmountScenario', feeAmountScenario);
}
case FeeAssetDataScenario.MakerToken:
return getFeeAmountFromScenario(
orderScenario,
orderScenario.makerAssetDataScenario,
feeAmountScenario
);
case FeeAssetDataScenario.TakerToken:
return getFeeAmountFromScenario(
orderScenario,
orderScenario.takerAssetDataScenario,
feeAmountScenario
);
default:
throw errorUtils.spawnSwitchErr('FeeAssetDataScenario', feeAssetDataScenario);
}
}

View File

@@ -6,10 +6,8 @@ import { ExchangeWrapper } from './exchange_wrapper';
export class SimpleOrderFilledCancelledFetcher implements AbstractOrderFilledCancelledFetcher {
private readonly _exchangeWrapper: ExchangeWrapper;
private readonly _zrxAssetData: string;
constructor(exchange: ExchangeWrapper, zrxAssetData: string) {
constructor(exchange: ExchangeWrapper) {
this._exchangeWrapper = exchange;
this._zrxAssetData = zrxAssetData;
}
public async getFilledTakerAmountAsync(orderHash: string): Promise<BigNumber> {
const filledTakerAmount = new BigNumber(await this._exchangeWrapper.getTakerAssetFilledAmountAsync(orderHash));
@@ -25,7 +23,4 @@ export class SimpleOrderFilledCancelledFetcher implements AbstractOrderFilledCan
const isCancelledByOrderEpoch = orderEpoch > signedOrder.salt;
return isCancelled || isCancelledByOrderEpoch;
}
public getZRXAssetData(): string {
return this._zrxAssetData;
}
}

View File

@@ -96,7 +96,6 @@ describe('Exchange wrappers', () => {
artifacts.Exchange,
provider,
txDefaults,
assetDataUtils.encodeERC20AssetData(zrxToken.address),
new BigNumber(chainId),
);
exchangeWrapper = new ExchangeWrapper(exchange, provider);