Skip to content
This repository was archived by the owner on Jul 9, 2021. It is now read-only.

Commit 5c39291

Browse files
committed
Parallelize RFQ-T with orderbook query
Addresses review comment #2541 (comment)
1 parent 37390e0 commit 5c39291

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

packages/asset-swapper/src/swap_quoter.ts

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -535,31 +535,32 @@ export class SwapQuoter {
535535
gasPrice = await this._protocolFeeUtils.getGasPriceEstimationOrThrowAsync();
536536
}
537537
// get the relevant orders for the makerAsset
538-
let orders = await this._getSignedOrdersAsync(makerAssetData, takerAssetData);
538+
const orderPromises: Array<Promise<SignedOrder[]>> = [this._getSignedOrdersAsync(makerAssetData, takerAssetData)];
539539
if (options.intentOnFilling && options.apiKey) {
540540
if (!this.rfqtTakerApiKeyWhitelist.includes(options.apiKey)) {
541541
throw new Error('API key not permissioned for RFQ-T');
542542
}
543543
if (!options.takerAddress || options.takerAddress === constants.NULL_ADDRESS) {
544544
throw new Error('RFQ-T requests must specify a taker address');
545545
}
546-
orders.push(
547-
...(await this._quoteRequestor.requestRfqtFirmQuotesAsync(
546+
orderPromises.push(
547+
this._quoteRequestor.requestRfqtFirmQuotesAsync(
548548
makerAssetData,
549549
takerAssetData,
550550
assetFillAmount,
551551
marketOperation,
552552
options.intentOnFilling,
553553
options.apiKey,
554554
options.takerAddress,
555-
)),
555+
),
556556
);
557557
}
558+
const orders: SignedOrder[] = ([] as SignedOrder[]).concat(...(await Promise.all(orderPromises)));
558559
// if no native orders, pass in a dummy order for the sampler to have required metadata for sampling
559560
if (orders.length === 0) {
560-
orders = [
561+
orders.push(
561562
createDummyOrderForSampler(makerAssetData, takerAssetData, this._contractAddresses.uniswapBridge),
562-
];
563+
);
563564
}
564565

565566
let swapQuote: SwapQuote;

0 commit comments

Comments
 (0)