Ran prettier
This commit is contained in:
parent
b5e3f0b90c
commit
a9d0cec6d1
@ -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(
|
? getRfqtIndicativeQuotesAsync(
|
||||||
nativeOrders[0].makerAssetData,
|
nativeOrders[0].makerAssetData,
|
||||||
nativeOrders[0].takerAssetData,
|
nativeOrders[0].takerAssetData,
|
||||||
@ -364,7 +365,8 @@ export class MarketOperationUtils {
|
|||||||
this._liquidityProviderRegistry,
|
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(
|
? getRfqtIndicativeQuotesAsync(
|
||||||
nativeOrders[0].makerAssetData,
|
nativeOrders[0].makerAssetData,
|
||||||
nativeOrders[0].takerAssetData,
|
nativeOrders[0].takerAssetData,
|
||||||
@ -675,7 +677,12 @@ export class MarketOperationUtils {
|
|||||||
|
|
||||||
// If RFQ liquidity is enabled, make a request to check RFQ liquidity
|
// If RFQ liquidity is enabled, make a request to check RFQ liquidity
|
||||||
const { rfqt } = _opts;
|
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.
|
// Calculate a suggested price. For now, this is simply the overall price of the aggregation.
|
||||||
let comparisonPrice: BigNumber | undefined;
|
let comparisonPrice: BigNumber | undefined;
|
||||||
if (optimizerResult) {
|
if (optimizerResult) {
|
||||||
|
@ -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(
|
const mockedMarketOpUtils = TypeMoq.Mock.ofType(
|
||||||
MarketOperationUtils,
|
MarketOperationUtils,
|
||||||
TypeMoq.MockBehavior.Loose,
|
TypeMoq.MockBehavior.Loose,
|
||||||
@ -743,14 +746,28 @@ describe('MarketOperationUtils tests', () => {
|
|||||||
.verifiable(TypeMoq.Times.once());
|
.verifiable(TypeMoq.Times.once());
|
||||||
|
|
||||||
const totalAssetAmount = ORDERS.map(o => o.takerAssetAmount).reduce((a, b) => a.plus(b));
|
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();
|
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
|
// Set up mocked quote requestor, will return an order that is better
|
||||||
// than the best of the orders.
|
// 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;
|
let requestedComparisonPrice: BigNumber | undefined;
|
||||||
mockedQuoteRequestor
|
mockedQuoteRequestor
|
||||||
@ -801,7 +818,11 @@ describe('MarketOperationUtils tests', () => {
|
|||||||
mockedMarketOpUtils.callBase = true;
|
mockedMarketOpUtils.callBase = true;
|
||||||
mockedMarketOpUtils
|
mockedMarketOpUtils
|
||||||
.setup(mou =>
|
.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 () => {
|
.returns(async () => {
|
||||||
return {
|
return {
|
||||||
@ -839,7 +860,8 @@ describe('MarketOperationUtils tests', () => {
|
|||||||
takerAddress: randomAddress(),
|
takerAddress: randomAddress(),
|
||||||
intentOnFilling: true,
|
intentOnFilling: true,
|
||||||
quoteRequestor: {
|
quoteRequestor: {
|
||||||
requestRfqtFirmQuotesAsync: mockedQuoteRequestor.object.requestRfqtFirmQuotesAsync,
|
requestRfqtFirmQuotesAsync:
|
||||||
|
mockedQuoteRequestor.object.requestRfqtFirmQuotesAsync,
|
||||||
} as any,
|
} as any,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@ -849,9 +871,14 @@ describe('MarketOperationUtils tests', () => {
|
|||||||
expect(requestedComparisonPrice!.toString()).to.eql('320');
|
expect(requestedComparisonPrice!.toString()).to.eql('320');
|
||||||
expect(result.optimizedOrders[0].makerAssetAmount.toString()).to.eql('321000000');
|
expect(result.optimizedOrders[0].makerAssetAmount.toString()).to.eql('321000000');
|
||||||
expect(result.optimizedOrders[0].takerAssetAmount.toString()).to.eql('1000000000000000000');
|
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
|
// Ensure that `_generateOptimizedOrdersAsync` is only called once
|
||||||
const mockedMarketOpUtils = TypeMoq.Mock.ofType(
|
const mockedMarketOpUtils = TypeMoq.Mock.ofType(
|
||||||
MarketOperationUtils,
|
MarketOperationUtils,
|
||||||
@ -884,10 +911,19 @@ describe('MarketOperationUtils tests', () => {
|
|||||||
});
|
});
|
||||||
mockedMarketOpUtils.verifyAll();
|
mockedMarketOpUtils.verifyAll();
|
||||||
requestor.verifyAll();
|
requestor.verifyAll();
|
||||||
} : undefined);
|
}
|
||||||
|
: undefined,
|
||||||
|
);
|
||||||
|
|
||||||
it('getMarketSellOrdersAsync() will rerun the optimizer if one or more indicative are returned', IS_PRICE_AWARE_RFQ_ENABLED ? async () => {
|
it(
|
||||||
const requestor = getMockedQuoteRequestor('indicative', [ORDERS[0], ORDERS[1]], TypeMoq.Times.once());
|
'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 numOrdersInCall: number[] = [];
|
||||||
const numIndicativeQuotesInCall: number[] = [];
|
const numIndicativeQuotesInCall: number[] = [];
|
||||||
@ -922,7 +958,8 @@ describe('MarketOperationUtils tests', () => {
|
|||||||
takerAddress: randomAddress(),
|
takerAddress: randomAddress(),
|
||||||
intentOnFilling: true,
|
intentOnFilling: true,
|
||||||
quoteRequestor: {
|
quoteRequestor: {
|
||||||
requestRfqtIndicativeQuotesAsync: requestor.object.requestRfqtIndicativeQuotesAsync,
|
requestRfqtIndicativeQuotesAsync:
|
||||||
|
requestor.object.requestRfqtIndicativeQuotesAsync,
|
||||||
} as any,
|
} as any,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@ -940,9 +977,14 @@ describe('MarketOperationUtils tests', () => {
|
|||||||
expect(numIndicativeQuotesInCall.length).to.eql(2);
|
expect(numIndicativeQuotesInCall.length).to.eql(2);
|
||||||
expect(numIndicativeQuotesInCall[0]).to.eql(0);
|
expect(numIndicativeQuotesInCall[0]).to.eql(0);
|
||||||
expect(numIndicativeQuotesInCall[1]).to.eql(2);
|
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());
|
const requestor = getMockedQuoteRequestor('firm', [ORDERS[0]], TypeMoq.Times.once());
|
||||||
|
|
||||||
// Ensure that `_generateOptimizedOrdersAsync` is only called 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.
|
// The first call to optimizer was with an extra RFQ order.
|
||||||
expect(numOrdersInCall[0]).to.eql(2);
|
expect(numOrdersInCall[0]).to.eql(2);
|
||||||
expect(numOrdersInCall[1]).to.eql(3);
|
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 hasFirstOptimizationRun = false;
|
||||||
let hasSecondOptimizationRun = 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(
|
const mockedMarketOpUtils = TypeMoq.Mock.ofType(
|
||||||
MarketOperationUtils,
|
MarketOperationUtils,
|
||||||
@ -1044,7 +1095,9 @@ describe('MarketOperationUtils tests', () => {
|
|||||||
|
|
||||||
expect(hasFirstOptimizationRun).to.eql(true);
|
expect(hasFirstOptimizationRun).to.eql(true);
|
||||||
expect(hasSecondOptimizationRun).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 () => {
|
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(
|
const mockedMarketOpUtils = TypeMoq.Mock.ofType(
|
||||||
|
Loading…
x
Reference in New Issue
Block a user