Merge pull request #2684 from 0xProject/feat/asset-swapper/rfqt-indicative-without-takerAddress
asset-swapper: Stop requiring takerAddress for indicative RFQ-T quotes.
This commit is contained in:
commit
7b0a1c3630
@ -62,6 +62,10 @@
|
|||||||
"note": "Added `Mooniswap`",
|
"note": "Added `Mooniswap`",
|
||||||
"pr": 2675
|
"pr": 2675
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"note": "Stop requiring takerAddress for RFQ-T indicative quotes",
|
||||||
|
"pr": 2684
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"note": "Added two-hop support",
|
"note": "Added two-hop support",
|
||||||
"pr": 2647
|
"pr": 2647
|
||||||
|
@ -39,18 +39,6 @@ function getTokenAddressOrThrow(assetData: string): string {
|
|||||||
throw new Error(`Decoded asset data (${JSON.stringify(decodedAssetData)}) does not contain a token address`);
|
throw new Error(`Decoded asset data (${JSON.stringify(decodedAssetData)}) does not contain a token address`);
|
||||||
}
|
}
|
||||||
|
|
||||||
function assertTakerAddressOrThrow(takerAddress: string | undefined): void {
|
|
||||||
if (
|
|
||||||
takerAddress === undefined ||
|
|
||||||
takerAddress === '' ||
|
|
||||||
takerAddress === '0x' ||
|
|
||||||
!takerAddress ||
|
|
||||||
takerAddress === constants.NULL_ADDRESS
|
|
||||||
) {
|
|
||||||
throw new Error('RFQ-T requires the presence of a taker address');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function inferQueryParams(
|
function inferQueryParams(
|
||||||
marketOperation: MarketOperation,
|
marketOperation: MarketOperation,
|
||||||
makerAssetData: string,
|
makerAssetData: string,
|
||||||
@ -137,7 +125,15 @@ export class QuoteRequestor {
|
|||||||
options: RfqtRequestOpts,
|
options: RfqtRequestOpts,
|
||||||
): Promise<RFQTFirmQuote[]> {
|
): Promise<RFQTFirmQuote[]> {
|
||||||
const _opts: RfqtRequestOpts = { ...constants.DEFAULT_RFQT_REQUEST_OPTS, ...options };
|
const _opts: RfqtRequestOpts = { ...constants.DEFAULT_RFQT_REQUEST_OPTS, ...options };
|
||||||
assertTakerAddressOrThrow(_opts.takerAddress);
|
if (
|
||||||
|
_opts.takerAddress === undefined ||
|
||||||
|
_opts.takerAddress === '' ||
|
||||||
|
_opts.takerAddress === '0x' ||
|
||||||
|
!_opts.takerAddress ||
|
||||||
|
_opts.takerAddress === constants.NULL_ADDRESS
|
||||||
|
) {
|
||||||
|
throw new Error('RFQ-T firm quotes require the presence of a taker address');
|
||||||
|
}
|
||||||
|
|
||||||
const firmQuoteResponses = await this._getQuotesAsync<RFQTFirmQuote>( // not yet BigNumber
|
const firmQuoteResponses = await this._getQuotesAsync<RFQTFirmQuote>( // not yet BigNumber
|
||||||
makerAssetData,
|
makerAssetData,
|
||||||
@ -217,7 +213,15 @@ export class QuoteRequestor {
|
|||||||
options: RfqtRequestOpts,
|
options: RfqtRequestOpts,
|
||||||
): Promise<RFQTIndicativeQuote[]> {
|
): Promise<RFQTIndicativeQuote[]> {
|
||||||
const _opts: RfqtRequestOpts = { ...constants.DEFAULT_RFQT_REQUEST_OPTS, ...options };
|
const _opts: RfqtRequestOpts = { ...constants.DEFAULT_RFQT_REQUEST_OPTS, ...options };
|
||||||
assertTakerAddressOrThrow(_opts.takerAddress);
|
|
||||||
|
// Originally a takerAddress was required for indicative quotes, but
|
||||||
|
// now we've eliminated that requirement. @0x/quote-server, however,
|
||||||
|
// is still coded to expect a takerAddress. So if the client didn't
|
||||||
|
// send one, just use the null address to satisfy the quote server's
|
||||||
|
// expectations.
|
||||||
|
if (!_opts.takerAddress) {
|
||||||
|
_opts.takerAddress = constants.NULL_ADDRESS;
|
||||||
|
}
|
||||||
|
|
||||||
const responsesWithStringInts = await this._getQuotesAsync<RFQTIndicativeQuote>( // not yet BigNumber
|
const responsesWithStringInts = await this._getQuotesAsync<RFQTIndicativeQuote>( // not yet BigNumber
|
||||||
makerAssetData,
|
makerAssetData,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user