fixed build issues

This commit is contained in:
David Sun
2019-07-17 13:38:30 -07:00
parent bf0d90d079
commit 88ff38eca6
7 changed files with 35 additions and 9 deletions

View File

@@ -1,5 +1,5 @@
import { ContractWrappers, ContractWrappersError, ForwarderWrapperError } from '@0x/contract-wrappers';
import { calldataOptimizationUtils } from '@0x/contract-wrappers/src/utils/calldata_optimization_utils';
import { calldataOptimizationUtils } from '@0x/contract-wrappers/lib/src/utils/calldata_optimization_utils';
import { MarketOperation } from '@0x/types';
import { AbiEncoder, providerUtils } from '@0x/utils';
import { SupportedProvider, ZeroExProvider } from '@0x/web3-wrapper';

View File

@@ -1,12 +1,11 @@
import { ContractWrappers, ContractWrappersError, ForwarderWrapperError } from '@0x/contract-wrappers';
import { calldataOptimizationUtils } from '@0x/contract-wrappers/src/utils/calldata_optimization_utils';
import { calldataOptimizationUtils } from '@0x/contract-wrappers/lib/src/utils/calldata_optimization_utils';
import { MarketOperation } from '@0x/types';
import { AbiEncoder, providerUtils } from '@0x/utils';
import { SupportedProvider, ZeroExProvider } from '@0x/web3-wrapper';
import { MethodAbi } from 'ethereum-types';
import * as _ from 'lodash';
import { constants } from '../constants';
import {
CalldataInfo,

View File

@@ -89,5 +89,5 @@ export class SwapQuoteConsumer implements SwapQuoteConsumerBase<SmartContractPar
opts,
);
}
}
}
}

View File

@@ -95,7 +95,8 @@ export interface ExchangeMarketSellSmartContractParams extends SmartContractPara
}
export enum ConsumerType {
Forwarder, Exchange,
Forwarder,
Exchange,
}
/**

View File

@@ -32,7 +32,6 @@ export const swapQuoteCalculator = {
isMakerAssetZrxToken,
shouldDisableFeeOrderCalculations,
MarketOperation.Sell,
) as MarketSellSwapQuote;
},
calculateMarketBuySwapQuote(

View File

@@ -22,12 +22,17 @@ export class SwapQuoteUtils {
this._contractWrappers = new ContractWrappers(this.provider, {
networkId,
});
}
public async isTakerAddressAllowanceEnoughForBestAndWorstQuoteInfoAsync(swapQuote: SwapQuote, takerAddress: string): Promise<[boolean, boolean]> {
public async isTakerAddressAllowanceEnoughForBestAndWorstQuoteInfoAsync(
swapQuote: SwapQuote,
takerAddress: string,
): Promise<[boolean, boolean]> {
const orderValidatorWrapper = this._contractWrappers.orderValidator;
const balanceAndAllowance = await orderValidatorWrapper.getBalanceAndAllowanceAsync(takerAddress, swapQuote.takerAssetData);
const balanceAndAllowance = await orderValidatorWrapper.getBalanceAndAllowanceAsync(
takerAddress,
swapQuote.takerAssetData,
);
return [
balanceAndAllowance.allowance.isGreaterThanOrEqualTo(swapQuote.bestCaseQuoteInfo.totalTakerTokenAmount),
balanceAndAllowance.allowance.isGreaterThanOrEqualTo(swapQuote.worstCaseQuoteInfo.totalTakerTokenAmount),

View File

@@ -78,6 +78,7 @@ describe('swapQuoteCalculator', () => {
new BigNumber(200),
0,
false,
false,
);
};
testHelpers.expectInsufficientLiquidityError(expect, errorFunction, new BigNumber(150));
@@ -91,6 +92,7 @@ describe('swapQuoteCalculator', () => {
new BigNumber(200),
0.2,
false,
false,
);
};
testHelpers.expectInsufficientLiquidityError(expect, errorFunction, new BigNumber(125));
@@ -104,6 +106,7 @@ describe('swapQuoteCalculator', () => {
new BigNumber(200),
0.05,
false,
false,
);
};
testHelpers.expectInsufficientLiquidityError(expect, errorFunction, new BigNumber(142));
@@ -121,6 +124,7 @@ describe('swapQuoteCalculator', () => {
new BigNumber(51),
0,
false,
false,
);
};
testHelpers.expectInsufficientLiquidityError(expect, errorFunction, new BigNumber(50));
@@ -142,6 +146,7 @@ describe('swapQuoteCalculator', () => {
new BigNumber(81),
0,
false,
false,
);
};
testHelpers.expectInsufficientLiquidityError(expect, errorFunction, new BigNumber(80));
@@ -159,6 +164,7 @@ describe('swapQuoteCalculator', () => {
new BigNumber(100),
0,
false,
false,
);
};
testHelpers.expectInsufficientLiquidityError(expect, errorFunction, new BigNumber(1));
@@ -176,6 +182,7 @@ describe('swapQuoteCalculator', () => {
new BigNumber(100),
0.2,
false,
false,
);
};
testHelpers.expectInsufficientLiquidityError(expect, errorFunction, new BigNumber(0));
@@ -189,6 +196,7 @@ describe('swapQuoteCalculator', () => {
new BigNumber(125),
0,
false,
false,
),
).to.not.throw();
});
@@ -201,6 +209,7 @@ describe('swapQuoteCalculator', () => {
new BigNumber(125),
0,
false,
false,
),
).to.throw(SwapQuoterError.InsufficientZrxLiquidity);
});
@@ -215,6 +224,7 @@ describe('swapQuoteCalculator', () => {
assetSellAmount,
slippagePercentage,
false,
false,
);
// test if orders are correct
expect(swapQuote.orders).to.deep.equal([ordersAndFillableAmounts.orders[0]]);
@@ -258,6 +268,7 @@ describe('swapQuoteCalculator', () => {
assetSellAmount,
slippagePercentage,
false,
false,
);
// test if orders are correct
expect(swapQuote.orders).to.deep.equal(ordersAndFillableAmounts.orders);
@@ -352,6 +363,7 @@ describe('swapQuoteCalculator', () => {
new BigNumber(500),
0,
false,
false,
);
};
testHelpers.expectInsufficientLiquidityError(expect, errorFunction, new BigNumber(400));
@@ -365,6 +377,7 @@ describe('swapQuoteCalculator', () => {
new BigNumber(500),
0.2,
false,
false,
);
};
testHelpers.expectInsufficientLiquidityError(expect, errorFunction, new BigNumber(333));
@@ -378,6 +391,7 @@ describe('swapQuoteCalculator', () => {
new BigNumber(600),
0.05,
false,
false,
);
};
testHelpers.expectInsufficientLiquidityError(expect, errorFunction, new BigNumber(380));
@@ -395,6 +409,7 @@ describe('swapQuoteCalculator', () => {
new BigNumber(201),
0,
false,
false,
);
};
testHelpers.expectInsufficientLiquidityError(expect, errorFunction, new BigNumber(200));
@@ -416,6 +431,7 @@ describe('swapQuoteCalculator', () => {
new BigNumber(124),
0,
false,
false,
);
};
testHelpers.expectInsufficientLiquidityError(expect, errorFunction, new BigNumber(123));
@@ -433,6 +449,7 @@ describe('swapQuoteCalculator', () => {
new BigNumber(600),
0,
false,
false,
);
};
testHelpers.expectInsufficientLiquidityError(expect, errorFunction, new BigNumber(1));
@@ -450,6 +467,7 @@ describe('swapQuoteCalculator', () => {
new BigNumber(600),
0.2,
false,
false,
);
};
testHelpers.expectInsufficientLiquidityError(expect, errorFunction, new BigNumber(0));
@@ -463,6 +481,7 @@ describe('swapQuoteCalculator', () => {
new BigNumber(300),
0,
false,
false,
),
).to.not.throw();
});
@@ -475,6 +494,7 @@ describe('swapQuoteCalculator', () => {
new BigNumber(300),
0,
false,
false,
),
).to.throw(SwapQuoterError.InsufficientZrxLiquidity);
});
@@ -489,6 +509,7 @@ describe('swapQuoteCalculator', () => {
assetBuyAmount,
slippagePercentage,
false,
false,
);
// test if orders are correct
expect(swapQuote.orders).to.deep.equal([ordersAndFillableAmounts.orders[0]]);
@@ -532,6 +553,7 @@ describe('swapQuoteCalculator', () => {
assetBuyAmount,
slippagePercentage,
false,
false,
);
// test if orders are correct
expect(swapQuote.orders).to.deep.equal(ordersAndFillableAmounts.orders);