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

Commit

Permalink
Parallelize RFQ-T with orderbook query
Browse files Browse the repository at this point in the history
Addresses review comment #2541 (comment)
  • Loading branch information
feuGeneA committed Apr 9, 2020
1 parent 37390e0 commit 5c39291
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions packages/asset-swapper/src/swap_quoter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -535,31 +535,32 @@ export class SwapQuoter {
gasPrice = await this._protocolFeeUtils.getGasPriceEstimationOrThrowAsync();
}
// get the relevant orders for the makerAsset
let orders = await this._getSignedOrdersAsync(makerAssetData, takerAssetData);
const orderPromises: Array<Promise<SignedOrder[]>> = [this._getSignedOrdersAsync(makerAssetData, takerAssetData)];
if (options.intentOnFilling && options.apiKey) {
if (!this.rfqtTakerApiKeyWhitelist.includes(options.apiKey)) {
throw new Error('API key not permissioned for RFQ-T');
}
if (!options.takerAddress || options.takerAddress === constants.NULL_ADDRESS) {
throw new Error('RFQ-T requests must specify a taker address');
}
orders.push(
...(await this._quoteRequestor.requestRfqtFirmQuotesAsync(
orderPromises.push(
this._quoteRequestor.requestRfqtFirmQuotesAsync(
makerAssetData,
takerAssetData,
assetFillAmount,
marketOperation,
options.intentOnFilling,
options.apiKey,
options.takerAddress,
)),
),
);
}
const orders: SignedOrder[] = ([] as SignedOrder[]).concat(...(await Promise.all(orderPromises)));
// if no native orders, pass in a dummy order for the sampler to have required metadata for sampling
if (orders.length === 0) {
orders = [
orders.push(
createDummyOrderForSampler(makerAssetData, takerAssetData, this._contractAddresses.uniswapBridge),
];
);
}

let swapQuote: SwapQuote;
Expand Down

0 comments on commit 5c39291

Please sign in to comment.