prettified
This commit is contained in:
parent
e6dcf92ec8
commit
d7918ea047
@ -559,7 +559,11 @@ export class SwapQuoter {
|
|||||||
|
|
||||||
// If RFQT is enabled and `nativeExclusivelyRFQT` is set, then `ERC20BridgeSource.Native` should
|
// If RFQT is enabled and `nativeExclusivelyRFQT` is set, then `ERC20BridgeSource.Native` should
|
||||||
// never be excluded.
|
// never be excluded.
|
||||||
if ((opts.rfqt && opts.rfqt.nativeExclusivelyRFQT === true) && opts.excludedSources.includes(ERC20BridgeSource.Native)) {
|
if (
|
||||||
|
opts.rfqt &&
|
||||||
|
opts.rfqt.nativeExclusivelyRFQT === true &&
|
||||||
|
opts.excludedSources.includes(ERC20BridgeSource.Native)
|
||||||
|
) {
|
||||||
throw new Error('Native liquidity cannot be excluded if "rfqt.nativeExclusivelyRFQT" is set');
|
throw new Error('Native liquidity cannot be excluded if "rfqt.nativeExclusivelyRFQT" is set');
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -567,7 +571,8 @@ export class SwapQuoter {
|
|||||||
const orderBatchPromises: Array<Promise<SignedOrder[]>> = [];
|
const orderBatchPromises: Array<Promise<SignedOrder[]>> = [];
|
||||||
orderBatchPromises.push(
|
orderBatchPromises.push(
|
||||||
// Don't fetch Open Orderbook orders from the DB if Native has been excluded, or if `nativeExclusivelyRFQT` has been set.
|
// Don't fetch Open Orderbook orders from the DB if Native has been excluded, or if `nativeExclusivelyRFQT` has been set.
|
||||||
opts.excludedSources.includes(ERC20BridgeSource.Native) || (opts.rfqt && opts.rfqt.nativeExclusivelyRFQT === true)
|
opts.excludedSources.includes(ERC20BridgeSource.Native) ||
|
||||||
|
(opts.rfqt && opts.rfqt.nativeExclusivelyRFQT === true)
|
||||||
? Promise.resolve([])
|
? Promise.resolve([])
|
||||||
: this._getSignedOrdersAsync(makerAssetData, takerAssetData),
|
: this._getSignedOrdersAsync(makerAssetData, takerAssetData),
|
||||||
);
|
);
|
||||||
|
@ -26,6 +26,14 @@ import {
|
|||||||
OrderDomain,
|
OrderDomain,
|
||||||
} from './types';
|
} from './types';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns a indicative quotes or an empty array if RFQT is not enabled or requested
|
||||||
|
* @param makerAssetData the maker asset data
|
||||||
|
* @param takerAssetData the taker asset data
|
||||||
|
* @param marketOperation Buy or Sell
|
||||||
|
* @param assetFillAmount the amount to fill, in base units
|
||||||
|
* @param opts market request options
|
||||||
|
*/
|
||||||
export async function getRfqtIndicativeQuotesAsync(
|
export async function getRfqtIndicativeQuotesAsync(
|
||||||
makerAssetData: string,
|
makerAssetData: string,
|
||||||
takerAssetData: string,
|
takerAssetData: string,
|
||||||
|
@ -351,13 +351,14 @@ describe('MarketOperationUtils tests', () => {
|
|||||||
MarketOperation.Sell,
|
MarketOperation.Sell,
|
||||||
new BigNumber('100e18'),
|
new BigNumber('100e18'),
|
||||||
{
|
{
|
||||||
rfqt: {quoteRequestor: requestor.object, ...partialRfqt},
|
rfqt: { quoteRequestor: requestor.object, ...partialRfqt },
|
||||||
excludedSources: [ERC20BridgeSource.Native],
|
excludedSources: [ERC20BridgeSource.Native],
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
expect(result.length).to.eql(0);
|
expect(result.length).to.eql(0);
|
||||||
requestor.verify(
|
requestor.verify(
|
||||||
r => r.requestRfqtIndicativeQuotesAsync(
|
r =>
|
||||||
|
r.requestRfqtIndicativeQuotesAsync(
|
||||||
TypeMoq.It.isAny(),
|
TypeMoq.It.isAny(),
|
||||||
TypeMoq.It.isAny(),
|
TypeMoq.It.isAny(),
|
||||||
TypeMoq.It.isAny(),
|
TypeMoq.It.isAny(),
|
||||||
@ -370,22 +371,25 @@ describe('MarketOperationUtils tests', () => {
|
|||||||
|
|
||||||
it('calls RFQT if Native source is not excluded', async () => {
|
it('calls RFQT if Native source is not excluded', async () => {
|
||||||
const requestor = TypeMoq.Mock.ofType(QuoteRequestor, TypeMoq.MockBehavior.Loose);
|
const requestor = TypeMoq.Mock.ofType(QuoteRequestor, TypeMoq.MockBehavior.Loose);
|
||||||
requestor.setup(
|
requestor
|
||||||
r => r.requestRfqtIndicativeQuotesAsync(
|
.setup(r =>
|
||||||
|
r.requestRfqtIndicativeQuotesAsync(
|
||||||
TypeMoq.It.isAny(),
|
TypeMoq.It.isAny(),
|
||||||
TypeMoq.It.isAny(),
|
TypeMoq.It.isAny(),
|
||||||
TypeMoq.It.isAny(),
|
TypeMoq.It.isAny(),
|
||||||
TypeMoq.It.isAny(),
|
TypeMoq.It.isAny(),
|
||||||
TypeMoq.It.isAny(),
|
TypeMoq.It.isAny(),
|
||||||
),
|
),
|
||||||
).returns(() => Promise.resolve([])).verifiable(TypeMoq.Times.once());
|
)
|
||||||
|
.returns(() => Promise.resolve([]))
|
||||||
|
.verifiable(TypeMoq.Times.once());
|
||||||
await getRfqtIndicativeQuotesAsync(
|
await getRfqtIndicativeQuotesAsync(
|
||||||
MAKER_ASSET_DATA,
|
MAKER_ASSET_DATA,
|
||||||
TAKER_ASSET_DATA,
|
TAKER_ASSET_DATA,
|
||||||
MarketOperation.Sell,
|
MarketOperation.Sell,
|
||||||
new BigNumber('100e18'),
|
new BigNumber('100e18'),
|
||||||
{
|
{
|
||||||
rfqt: {quoteRequestor: requestor.object, ...partialRfqt},
|
rfqt: { quoteRequestor: requestor.object, ...partialRfqt },
|
||||||
excludedSources: [],
|
excludedSources: [],
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user