Ran prettier

This commit is contained in:
F. Eugene Aumson 2020-10-20 14:17:48 -04:00
parent b5e3f0b90c
commit a9d0cec6d1
No known key found for this signature in database
GPG Key ID: 23E6737B1374A24A
2 changed files with 378 additions and 318 deletions

View File

@ -217,7 +217,8 @@ export class MarketOperationUtils {
),
);
const rfqtPromise = !IS_PRICE_AWARE_RFQ_ENABLED && quoteSourceFilters.isAllowed(ERC20BridgeSource.Native)
const rfqtPromise =
!IS_PRICE_AWARE_RFQ_ENABLED && quoteSourceFilters.isAllowed(ERC20BridgeSource.Native)
? getRfqtIndicativeQuotesAsync(
nativeOrders[0].makerAssetData,
nativeOrders[0].takerAssetData,
@ -364,7 +365,8 @@ export class MarketOperationUtils {
this._liquidityProviderRegistry,
),
);
const rfqtPromise = !IS_PRICE_AWARE_RFQ_ENABLED && quoteSourceFilters.isAllowed(ERC20BridgeSource.Native)
const rfqtPromise =
!IS_PRICE_AWARE_RFQ_ENABLED && quoteSourceFilters.isAllowed(ERC20BridgeSource.Native)
? getRfqtIndicativeQuotesAsync(
nativeOrders[0].makerAssetData,
nativeOrders[0].takerAssetData,
@ -675,7 +677,12 @@ export class MarketOperationUtils {
// If RFQ liquidity is enabled, make a request to check RFQ liquidity
const { rfqt } = _opts;
if (IS_PRICE_AWARE_RFQ_ENABLED && rfqt && rfqt.quoteRequestor && marketSideLiquidity.quoteSourceFilters.isAllowed(ERC20BridgeSource.Native)) {
if (
IS_PRICE_AWARE_RFQ_ENABLED &&
rfqt &&
rfqt.quoteRequestor &&
marketSideLiquidity.quoteSourceFilters.isAllowed(ERC20BridgeSource.Native)
) {
// Calculate a suggested price. For now, this is simply the overall price of the aggregation.
let comparisonPrice: BigNumber | undefined;
if (optimizerResult) {

View File

@ -725,7 +725,10 @@ describe('MarketOperationUtils tests', () => {
}
});
it('getMarketSellOrdersAsync() optimizer will be called once only if RFQ if not defined', IS_PRICE_AWARE_RFQ_ENABLED ? async () => {
it(
'getMarketSellOrdersAsync() optimizer will be called once only if RFQ if not defined',
IS_PRICE_AWARE_RFQ_ENABLED
? async () => {
const mockedMarketOpUtils = TypeMoq.Mock.ofType(
MarketOperationUtils,
TypeMoq.MockBehavior.Loose,
@ -743,14 +746,28 @@ describe('MarketOperationUtils tests', () => {
.verifiable(TypeMoq.Times.once());
const totalAssetAmount = ORDERS.map(o => o.takerAssetAmount).reduce((a, b) => a.plus(b));
await mockedMarketOpUtils.object.getMarketSellOrdersAsync(ORDERS, totalAssetAmount, DEFAULT_OPTS);
await mockedMarketOpUtils.object.getMarketSellOrdersAsync(
ORDERS,
totalAssetAmount,
DEFAULT_OPTS,
);
mockedMarketOpUtils.verifyAll();
} : undefined);
}
: undefined,
);
it('optimizer will send in a comparison price to RFQ providers', IS_PRICE_AWARE_RFQ_ENABLED ? async () => {
it(
'optimizer will send in a comparison price to RFQ providers',
IS_PRICE_AWARE_RFQ_ENABLED
? async () => {
// Set up mocked quote requestor, will return an order that is better
// than the best of the orders.
const mockedQuoteRequestor = TypeMoq.Mock.ofType(QuoteRequestor, TypeMoq.MockBehavior.Loose, false, {});
const mockedQuoteRequestor = TypeMoq.Mock.ofType(
QuoteRequestor,
TypeMoq.MockBehavior.Loose,
false,
{},
);
let requestedComparisonPrice: BigNumber | undefined;
mockedQuoteRequestor
@ -801,7 +818,11 @@ describe('MarketOperationUtils tests', () => {
mockedMarketOpUtils.callBase = true;
mockedMarketOpUtils
.setup(mou =>
mou.getMarketSellLiquidityAsync(TypeMoq.It.isAny(), TypeMoq.It.isAny(), TypeMoq.It.isAny()),
mou.getMarketSellLiquidityAsync(
TypeMoq.It.isAny(),
TypeMoq.It.isAny(),
TypeMoq.It.isAny(),
),
)
.returns(async () => {
return {
@ -839,7 +860,8 @@ describe('MarketOperationUtils tests', () => {
takerAddress: randomAddress(),
intentOnFilling: true,
quoteRequestor: {
requestRfqtFirmQuotesAsync: mockedQuoteRequestor.object.requestRfqtFirmQuotesAsync,
requestRfqtFirmQuotesAsync:
mockedQuoteRequestor.object.requestRfqtFirmQuotesAsync,
} as any,
},
},
@ -849,9 +871,14 @@ describe('MarketOperationUtils tests', () => {
expect(requestedComparisonPrice!.toString()).to.eql('320');
expect(result.optimizedOrders[0].makerAssetAmount.toString()).to.eql('321000000');
expect(result.optimizedOrders[0].takerAssetAmount.toString()).to.eql('1000000000000000000');
} : undefined);
}
: undefined,
);
it('getMarketSellOrdersAsync() will not rerun the optimizer if no orders are returned', IS_PRICE_AWARE_RFQ_ENABLED ? async () => {
it(
'getMarketSellOrdersAsync() will not rerun the optimizer if no orders are returned',
IS_PRICE_AWARE_RFQ_ENABLED
? async () => {
// Ensure that `_generateOptimizedOrdersAsync` is only called once
const mockedMarketOpUtils = TypeMoq.Mock.ofType(
MarketOperationUtils,
@ -884,10 +911,19 @@ describe('MarketOperationUtils tests', () => {
});
mockedMarketOpUtils.verifyAll();
requestor.verifyAll();
} : undefined);
}
: undefined,
);
it('getMarketSellOrdersAsync() will rerun the optimizer if one or more indicative are returned', IS_PRICE_AWARE_RFQ_ENABLED ? async () => {
const requestor = getMockedQuoteRequestor('indicative', [ORDERS[0], ORDERS[1]], TypeMoq.Times.once());
it(
'getMarketSellOrdersAsync() will rerun the optimizer if one or more indicative are returned',
IS_PRICE_AWARE_RFQ_ENABLED
? async () => {
const requestor = getMockedQuoteRequestor(
'indicative',
[ORDERS[0], ORDERS[1]],
TypeMoq.Times.once(),
);
const numOrdersInCall: number[] = [];
const numIndicativeQuotesInCall: number[] = [];
@ -922,7 +958,8 @@ describe('MarketOperationUtils tests', () => {
takerAddress: randomAddress(),
intentOnFilling: true,
quoteRequestor: {
requestRfqtIndicativeQuotesAsync: requestor.object.requestRfqtIndicativeQuotesAsync,
requestRfqtIndicativeQuotesAsync:
requestor.object.requestRfqtIndicativeQuotesAsync,
} as any,
},
},
@ -940,9 +977,14 @@ describe('MarketOperationUtils tests', () => {
expect(numIndicativeQuotesInCall.length).to.eql(2);
expect(numIndicativeQuotesInCall[0]).to.eql(0);
expect(numIndicativeQuotesInCall[1]).to.eql(2);
} : undefined);
}
: undefined,
);
it('getMarketSellOrdersAsync() will rerun the optimizer if one or more RFQ orders are returned', IS_PRICE_AWARE_RFQ_ENABLED ? async () => {
it(
'getMarketSellOrdersAsync() will rerun the optimizer if one or more RFQ orders are returned',
IS_PRICE_AWARE_RFQ_ENABLED
? async () => {
const requestor = getMockedQuoteRequestor('firm', [ORDERS[0]], TypeMoq.Times.once());
// Ensure that `_generateOptimizedOrdersAsync` is only called once
@ -991,12 +1033,21 @@ describe('MarketOperationUtils tests', () => {
// The first call to optimizer was with an extra RFQ order.
expect(numOrdersInCall[0]).to.eql(2);
expect(numOrdersInCall[1]).to.eql(3);
} : undefined);
}
: undefined,
);
it('getMarketSellOrdersAsync() will not raise a NoOptimalPath error if no initial path was found during on-chain DEX optimization, but a path was found after RFQ optimization', IS_PRICE_AWARE_RFQ_ENABLED ? async () => {
it(
'getMarketSellOrdersAsync() will not raise a NoOptimalPath error if no initial path was found during on-chain DEX optimization, but a path was found after RFQ optimization',
IS_PRICE_AWARE_RFQ_ENABLED
? async () => {
let hasFirstOptimizationRun = false;
let hasSecondOptimizationRun = false;
const requestor = getMockedQuoteRequestor('firm', [ORDERS[0], ORDERS[1]], TypeMoq.Times.once());
const requestor = getMockedQuoteRequestor(
'firm',
[ORDERS[0], ORDERS[1]],
TypeMoq.Times.once(),
);
const mockedMarketOpUtils = TypeMoq.Mock.ofType(
MarketOperationUtils,
@ -1044,7 +1095,9 @@ describe('MarketOperationUtils tests', () => {
expect(hasFirstOptimizationRun).to.eql(true);
expect(hasSecondOptimizationRun).to.eql(true);
} : undefined);
}
: undefined,
);
it('getMarketSellOrdersAsync() will raise a NoOptimalPath error if no path was found during on-chain DEX optimization and RFQ optimization', async () => {
const mockedMarketOpUtils = TypeMoq.Mock.ofType(