Rename {Rfqt=>Rfq} for types in Asset Swapper (#179)
* Rename {Rfqt=>Rfq} for types in Asset Swapper * PR edit 1 - fix build errors * PR edit 2 - rename mocked types used in tests * PR edit 3 - fix broken test build * PR edit 4 - rename SwapQuoterRfqOpts and add changelog entry
This commit is contained in:
parent
bbaa90bd9a
commit
06b3464756
@ -9,6 +9,10 @@
|
|||||||
{
|
{
|
||||||
"note": "Add a cancel token to ensure timeouts are respected",
|
"note": "Add a cancel token to ensure timeouts are respected",
|
||||||
"pr": 176
|
"pr": 176
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"note": "Rename {Rfqt=>Rfq} for many types in Asset Swapper",
|
||||||
|
"pr": 179
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
@ -8,7 +8,7 @@ import {
|
|||||||
LogFunction,
|
LogFunction,
|
||||||
OrderPrunerOpts,
|
OrderPrunerOpts,
|
||||||
OrderPrunerPermittedFeeTypes,
|
OrderPrunerPermittedFeeTypes,
|
||||||
RfqtRequestOpts,
|
RfqRequestOpts,
|
||||||
SwapQuoteGetOutputOpts,
|
SwapQuoteGetOutputOpts,
|
||||||
SwapQuoteRequestOpts,
|
SwapQuoteRequestOpts,
|
||||||
SwapQuoterOpts,
|
SwapQuoterOpts,
|
||||||
@ -79,7 +79,7 @@ const DEFAULT_SWAP_QUOTE_REQUEST_OPTS: SwapQuoteRequestOpts = {
|
|||||||
...DEFAULT_GET_MARKET_ORDERS_OPTS,
|
...DEFAULT_GET_MARKET_ORDERS_OPTS,
|
||||||
};
|
};
|
||||||
|
|
||||||
const DEFAULT_RFQT_REQUEST_OPTS: Partial<RfqtRequestOpts> = {
|
const DEFAULT_RFQT_REQUEST_OPTS: Partial<RfqRequestOpts> = {
|
||||||
makerEndpointMaxResponseTimeMs: 1000,
|
makerEndpointMaxResponseTimeMs: 1000,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -75,7 +75,7 @@ export { SwapQuoteConsumer } from './quote_consumers/swap_quote_consumer';
|
|||||||
export { SwapQuoter, Orderbook } from './swap_quoter';
|
export { SwapQuoter, Orderbook } from './swap_quoter';
|
||||||
export {
|
export {
|
||||||
AltOffering,
|
AltOffering,
|
||||||
AltRfqtMakerAssetOfferings,
|
AltRfqMakerAssetOfferings,
|
||||||
AffiliateFeeType,
|
AffiliateFeeType,
|
||||||
AffiliateFeeAmount,
|
AffiliateFeeAmount,
|
||||||
AssetSwapperContractAddresses,
|
AssetSwapperContractAddresses,
|
||||||
@ -87,11 +87,11 @@ export {
|
|||||||
MarketBuySwapQuote,
|
MarketBuySwapQuote,
|
||||||
MarketOperation,
|
MarketOperation,
|
||||||
MarketSellSwapQuote,
|
MarketSellSwapQuote,
|
||||||
MockedRfqtQuoteResponse,
|
MockedRfqQuoteResponse,
|
||||||
OrderPrunerPermittedFeeTypes,
|
OrderPrunerPermittedFeeTypes,
|
||||||
RfqtMakerAssetOfferings,
|
RfqMakerAssetOfferings,
|
||||||
RfqtFirmQuoteValidator,
|
RfqFirmQuoteValidator,
|
||||||
RfqtRequestOpts,
|
RfqRequestOpts,
|
||||||
SamplerOverrides,
|
SamplerOverrides,
|
||||||
SignedNativeOrder,
|
SignedNativeOrder,
|
||||||
SignedOrder,
|
SignedOrder,
|
||||||
@ -106,7 +106,7 @@ export {
|
|||||||
SwapQuoteRequestOpts,
|
SwapQuoteRequestOpts,
|
||||||
SwapQuoterError,
|
SwapQuoterError,
|
||||||
SwapQuoterOpts,
|
SwapQuoterOpts,
|
||||||
SwapQuoterRfqtOpts,
|
SwapQuoterRfqOpts,
|
||||||
} from './types';
|
} from './types';
|
||||||
export { affiliateFeeUtils } from './utils/affiliate_fee_utils';
|
export { affiliateFeeUtils } from './utils/affiliate_fee_utils';
|
||||||
export {
|
export {
|
||||||
@ -133,7 +133,7 @@ export {
|
|||||||
FeeSchedule,
|
FeeSchedule,
|
||||||
Fill,
|
Fill,
|
||||||
FillData,
|
FillData,
|
||||||
GetMarketOrdersRfqtOpts,
|
GetMarketOrdersRfqOpts,
|
||||||
KyberFillData,
|
KyberFillData,
|
||||||
LiquidityProviderFillData,
|
LiquidityProviderFillData,
|
||||||
LiquidityProviderRegistry,
|
LiquidityProviderRegistry,
|
||||||
|
@ -14,14 +14,14 @@ import {
|
|||||||
MarketBuySwapQuote,
|
MarketBuySwapQuote,
|
||||||
MarketOperation,
|
MarketOperation,
|
||||||
OrderPrunerPermittedFeeTypes,
|
OrderPrunerPermittedFeeTypes,
|
||||||
RfqtRequestOpts,
|
RfqRequestOpts,
|
||||||
SignedNativeOrder,
|
SignedNativeOrder,
|
||||||
SwapQuote,
|
SwapQuote,
|
||||||
SwapQuoteInfo,
|
SwapQuoteInfo,
|
||||||
SwapQuoteOrdersBreakdown,
|
SwapQuoteOrdersBreakdown,
|
||||||
SwapQuoteRequestOpts,
|
SwapQuoteRequestOpts,
|
||||||
SwapQuoterOpts,
|
SwapQuoterOpts,
|
||||||
SwapQuoterRfqtOpts,
|
SwapQuoterRfqOpts,
|
||||||
} from './types';
|
} from './types';
|
||||||
import { assert } from './utils/assert';
|
import { assert } from './utils/assert';
|
||||||
import { MarketOperationUtils } from './utils/market_operation_utils';
|
import { MarketOperationUtils } from './utils/market_operation_utils';
|
||||||
@ -72,7 +72,7 @@ export class SwapQuoter {
|
|||||||
private readonly _contractAddresses: AssetSwapperContractAddresses;
|
private readonly _contractAddresses: AssetSwapperContractAddresses;
|
||||||
private readonly _protocolFeeUtils: ProtocolFeeUtils;
|
private readonly _protocolFeeUtils: ProtocolFeeUtils;
|
||||||
private readonly _marketOperationUtils: MarketOperationUtils;
|
private readonly _marketOperationUtils: MarketOperationUtils;
|
||||||
private readonly _rfqtOptions?: SwapQuoterRfqtOpts;
|
private readonly _rfqtOptions?: SwapQuoterRfqOpts;
|
||||||
private readonly _quoteRequestorHttpClient: AxiosInstance;
|
private readonly _quoteRequestorHttpClient: AxiosInstance;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -334,7 +334,7 @@ export class SwapQuoter {
|
|||||||
// Get SRA orders (limit orders)
|
// Get SRA orders (limit orders)
|
||||||
const shouldSkipOpenOrderbook =
|
const shouldSkipOpenOrderbook =
|
||||||
!sourceFilters.isAllowed(ERC20BridgeSource.Native) ||
|
!sourceFilters.isAllowed(ERC20BridgeSource.Native) ||
|
||||||
(opts.rfqt && opts.rfqt.nativeExclusivelyRFQT === true);
|
(opts.rfqt && opts.rfqt.nativeExclusivelyRFQ === true);
|
||||||
const nativeOrders = shouldSkipOpenOrderbook
|
const nativeOrders = shouldSkipOpenOrderbook
|
||||||
? await Promise.resolve([])
|
? await Promise.resolve([])
|
||||||
: await this.orderbook.getOrdersAsync(makerToken, takerToken, this._limitOrderPruningFn);
|
: await this.orderbook.getOrdersAsync(makerToken, takerToken, this._limitOrderPruningFn);
|
||||||
@ -420,17 +420,17 @@ export class SwapQuoter {
|
|||||||
|
|
||||||
private _validateRfqtOpts(
|
private _validateRfqtOpts(
|
||||||
sourceFilters: SourceFilters,
|
sourceFilters: SourceFilters,
|
||||||
rfqt: RfqtRequestOpts | undefined,
|
rfqt: RfqRequestOpts | undefined,
|
||||||
): RfqtRequestOpts | undefined {
|
): RfqRequestOpts | undefined {
|
||||||
if (!rfqt) {
|
if (!rfqt) {
|
||||||
return rfqt;
|
return rfqt;
|
||||||
}
|
}
|
||||||
// tslint:disable-next-line: boolean-naming
|
// tslint:disable-next-line: boolean-naming
|
||||||
const { apiKey, nativeExclusivelyRFQT, intentOnFilling, txOrigin } = rfqt;
|
const { apiKey, nativeExclusivelyRFQ, intentOnFilling, txOrigin } = rfqt;
|
||||||
// If RFQT is enabled and `nativeExclusivelyRFQT` is set, then `ERC20BridgeSource.Native` should
|
// If RFQ-T is enabled and `nativeExclusivelyRFQ` is set, then `ERC20BridgeSource.Native` should
|
||||||
// never be excluded.
|
// never be excluded.
|
||||||
if (nativeExclusivelyRFQT === true && !sourceFilters.isAllowed(ERC20BridgeSource.Native)) {
|
if (nativeExclusivelyRFQ === true && !sourceFilters.isAllowed(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.nativeExclusivelyRFQ" is set');
|
||||||
}
|
}
|
||||||
|
|
||||||
// If an API key was provided, but the key is not whitelisted, raise a warning and disable RFQ
|
// If an API key was provided, but the key is not whitelisted, raise a warning and disable RFQ
|
||||||
|
@ -227,19 +227,19 @@ export type SwapQuoteOrdersBreakdown = Partial<
|
|||||||
>;
|
>;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* nativeExclusivelyRFQT: if set to `true`, Swap quote will exclude Open Orderbook liquidity.
|
* nativeExclusivelyRFQ: if set to `true`, Swap quote will exclude Open Orderbook liquidity.
|
||||||
* If set to `true` and `ERC20BridgeSource.Native` is part of the `excludedSources`
|
* If set to `true` and `ERC20BridgeSource.Native` is part of the `excludedSources`
|
||||||
* array in `SwapQuoteRequestOpts`, an Error will be raised.
|
* array in `SwapQuoteRequestOpts`, an Error will be raised.
|
||||||
*/
|
*/
|
||||||
export interface RfqtRequestOpts {
|
export interface RfqRequestOpts {
|
||||||
takerAddress: string;
|
takerAddress: string;
|
||||||
txOrigin: string;
|
txOrigin: string;
|
||||||
apiKey: string;
|
apiKey: string;
|
||||||
intentOnFilling: boolean;
|
intentOnFilling: boolean;
|
||||||
isIndicative?: boolean;
|
isIndicative?: boolean;
|
||||||
makerEndpointMaxResponseTimeMs?: number;
|
makerEndpointMaxResponseTimeMs?: number;
|
||||||
nativeExclusivelyRFQT?: boolean;
|
nativeExclusivelyRFQ?: boolean;
|
||||||
altRfqtAssetOfferings?: AltRfqtMakerAssetOfferings;
|
altRfqAssetOfferings?: AltRfqMakerAssetOfferings;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -247,14 +247,14 @@ export interface RfqtRequestOpts {
|
|||||||
*/
|
*/
|
||||||
export interface SwapQuoteRequestOpts extends GetMarketOrdersOpts {
|
export interface SwapQuoteRequestOpts extends GetMarketOrdersOpts {
|
||||||
gasPrice?: BigNumber;
|
gasPrice?: BigNumber;
|
||||||
rfqt?: RfqtRequestOpts;
|
rfqt?: RfqRequestOpts;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A mapping from RFQ-T quote provider URLs to the trading pairs they support.
|
* A mapping from RFQ-T/M quote provider URLs to the trading pairs they support.
|
||||||
* The value type represents an array of supported asset pairs, with each array element encoded as a 2-element array of token addresses.
|
* The value type represents an array of supported asset pairs, with each array element encoded as a 2-element array of token addresses.
|
||||||
*/
|
*/
|
||||||
export interface RfqtMakerAssetOfferings {
|
export interface RfqMakerAssetOfferings {
|
||||||
[endpoint: string]: Array<[string, string]>;
|
[endpoint: string]: Array<[string, string]>;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -265,7 +265,7 @@ export interface AltOffering {
|
|||||||
baseAssetDecimals: number;
|
baseAssetDecimals: number;
|
||||||
quoteAssetDecimals: number;
|
quoteAssetDecimals: number;
|
||||||
}
|
}
|
||||||
export interface AltRfqtMakerAssetOfferings {
|
export interface AltRfqMakerAssetOfferings {
|
||||||
[endpoint: string]: AltOffering[];
|
[endpoint: string]: AltOffering[];
|
||||||
}
|
}
|
||||||
export enum RfqPairType {
|
export enum RfqPairType {
|
||||||
@ -279,13 +279,13 @@ export interface TypedMakerUrl {
|
|||||||
|
|
||||||
export type LogFunction = (obj: object, msg?: string, ...args: any[]) => void;
|
export type LogFunction = (obj: object, msg?: string, ...args: any[]) => void;
|
||||||
|
|
||||||
export interface RfqtFirmQuoteValidator {
|
export interface RfqFirmQuoteValidator {
|
||||||
getRfqtTakerFillableAmountsAsync(quotes: RfqOrder[]): Promise<BigNumber[]>;
|
getRfqtTakerFillableAmountsAsync(quotes: RfqOrder[]): Promise<BigNumber[]>;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface SwapQuoterRfqtOpts {
|
export interface SwapQuoterRfqOpts {
|
||||||
takerApiKeyWhitelist: string[];
|
takerApiKeyWhitelist: string[];
|
||||||
makerAssetOfferings: RfqtMakerAssetOfferings;
|
makerAssetOfferings: RfqMakerAssetOfferings;
|
||||||
txOriginBlacklist: Set<string>;
|
txOriginBlacklist: Set<string>;
|
||||||
altRfqCreds?: {
|
altRfqCreds?: {
|
||||||
altRfqApiKey: string;
|
altRfqApiKey: string;
|
||||||
@ -314,7 +314,7 @@ export interface SwapQuoterOpts extends OrderPrunerOpts {
|
|||||||
samplerGasLimit?: number;
|
samplerGasLimit?: number;
|
||||||
multiBridgeAddress?: string;
|
multiBridgeAddress?: string;
|
||||||
ethGasStationUrl?: string;
|
ethGasStationUrl?: string;
|
||||||
rfqt?: SwapQuoterRfqtOpts;
|
rfqt?: SwapQuoterRfqOpts;
|
||||||
samplerOverrides?: SamplerOverrides;
|
samplerOverrides?: SamplerOverrides;
|
||||||
tokenAdjacencyGraph?: TokenAdjacencyGraph;
|
tokenAdjacencyGraph?: TokenAdjacencyGraph;
|
||||||
liquidityProviderRegistry?: LiquidityProviderRegistry;
|
liquidityProviderRegistry?: LiquidityProviderRegistry;
|
||||||
@ -360,9 +360,9 @@ export enum OrderPrunerPermittedFeeTypes {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Represents a mocked RFQT maker responses.
|
* Represents a mocked RFQ-T/M maker responses.
|
||||||
*/
|
*/
|
||||||
export interface MockedRfqtQuoteResponse {
|
export interface MockedRfqQuoteResponse {
|
||||||
endpoint: string;
|
endpoint: string;
|
||||||
requestApiKey: string;
|
requestApiKey: string;
|
||||||
requestParams: TakerRequestQueryParams;
|
requestParams: TakerRequestQueryParams;
|
||||||
@ -372,9 +372,9 @@ export interface MockedRfqtQuoteResponse {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Represents a mocked RFQT maker responses.
|
* Represents a mocked RFQ-T/M alternative maker responses.
|
||||||
*/
|
*/
|
||||||
export interface AltMockedRfqtQuoteResponse {
|
export interface AltMockedRfqQuoteResponse {
|
||||||
endpoint: string;
|
endpoint: string;
|
||||||
mmApiKey: string;
|
mmApiKey: string;
|
||||||
requestData: AltQuoteRequestData;
|
requestData: AltQuoteRequestData;
|
||||||
|
@ -11,7 +11,7 @@ import {
|
|||||||
AltQuoteModel,
|
AltQuoteModel,
|
||||||
AltQuoteRequestData,
|
AltQuoteRequestData,
|
||||||
AltQuoteSide,
|
AltQuoteSide,
|
||||||
AltRfqtMakerAssetOfferings,
|
AltRfqMakerAssetOfferings,
|
||||||
} from '../types';
|
} from '../types';
|
||||||
|
|
||||||
function getAltMarketInfo(
|
function getAltMarketInfo(
|
||||||
@ -119,13 +119,13 @@ export async function returnQuoteFromAltMMAsync<ResponseT>(
|
|||||||
makerToken: string,
|
makerToken: string,
|
||||||
takerToken: string,
|
takerToken: string,
|
||||||
maxResponseTimeMs: number,
|
maxResponseTimeMs: number,
|
||||||
altRfqtAssetOfferings: AltRfqtMakerAssetOfferings,
|
altRfqAssetOfferings: AltRfqMakerAssetOfferings,
|
||||||
takerRequestQueryParams: TakerRequestQueryParams,
|
takerRequestQueryParams: TakerRequestQueryParams,
|
||||||
axiosInstance: AxiosInstance,
|
axiosInstance: AxiosInstance,
|
||||||
cancelToken: CancelToken,
|
cancelToken: CancelToken,
|
||||||
): Promise<{ data: ResponseT; status: number }> {
|
): Promise<{ data: ResponseT; status: number }> {
|
||||||
const altPair = getAltMarketInfo(
|
const altPair = getAltMarketInfo(
|
||||||
altRfqtAssetOfferings[url],
|
altRfqAssetOfferings[url],
|
||||||
takerRequestQueryParams.buyTokenAddress,
|
takerRequestQueryParams.buyTokenAddress,
|
||||||
takerRequestQueryParams.sellTokenAddress,
|
takerRequestQueryParams.sellTokenAddress,
|
||||||
);
|
);
|
||||||
|
@ -7,7 +7,7 @@ import { V4RFQIndicativeQuote } from '@0x/quote-server';
|
|||||||
import { MarketOperation } from '@0x/types';
|
import { MarketOperation } from '@0x/types';
|
||||||
import { BigNumber } from '@0x/utils';
|
import { BigNumber } from '@0x/utils';
|
||||||
|
|
||||||
import { NativeOrderWithFillableAmounts, RfqtFirmQuoteValidator, RfqtRequestOpts } from '../../types';
|
import { NativeOrderWithFillableAmounts, RfqFirmQuoteValidator, RfqRequestOpts } from '../../types';
|
||||||
import { QuoteRequestor } from '../../utils/quote_requestor';
|
import { QuoteRequestor } from '../../utils/quote_requestor';
|
||||||
import { QuoteReport } from '../quote_report_generator';
|
import { QuoteReport } from '../quote_report_generator';
|
||||||
|
|
||||||
@ -267,9 +267,9 @@ export type OptimizedMarketOrder =
|
|||||||
| OptimizedMarketOrderBase<NativeLimitOrderFillData>
|
| OptimizedMarketOrderBase<NativeLimitOrderFillData>
|
||||||
| OptimizedMarketOrderBase<NativeRfqOrderFillData>;
|
| OptimizedMarketOrderBase<NativeRfqOrderFillData>;
|
||||||
|
|
||||||
export interface GetMarketOrdersRfqtOpts extends RfqtRequestOpts {
|
export interface GetMarketOrdersRfqOpts extends RfqRequestOpts {
|
||||||
quoteRequestor?: QuoteRequestor;
|
quoteRequestor?: QuoteRequestor;
|
||||||
firmQuoteValidator?: RfqtFirmQuoteValidator;
|
firmQuoteValidator?: RfqFirmQuoteValidator;
|
||||||
}
|
}
|
||||||
|
|
||||||
export type FeeEstimate = (fillData: FillData) => number | BigNumber;
|
export type FeeEstimate = (fillData: FillData) => number | BigNumber;
|
||||||
@ -343,7 +343,7 @@ export interface GetMarketOrdersOpts {
|
|||||||
/**
|
/**
|
||||||
* Options for RFQT such as takerAddress, intent on filling
|
* Options for RFQT such as takerAddress, intent on filling
|
||||||
*/
|
*/
|
||||||
rfqt?: GetMarketOrdersRfqtOpts;
|
rfqt?: GetMarketOrdersRfqOpts;
|
||||||
/**
|
/**
|
||||||
* Whether to generate a quote report
|
* Whether to generate a quote report
|
||||||
*/
|
*/
|
||||||
|
@ -7,12 +7,12 @@ import axios, { AxiosInstance } from 'axios';
|
|||||||
import { constants } from '../constants';
|
import { constants } from '../constants';
|
||||||
import {
|
import {
|
||||||
AltQuoteModel,
|
AltQuoteModel,
|
||||||
AltRfqtMakerAssetOfferings,
|
AltRfqMakerAssetOfferings,
|
||||||
LogFunction,
|
LogFunction,
|
||||||
MarketOperation,
|
MarketOperation,
|
||||||
RfqPairType,
|
RfqPairType,
|
||||||
RfqtMakerAssetOfferings,
|
RfqMakerAssetOfferings,
|
||||||
RfqtRequestOpts,
|
RfqRequestOpts,
|
||||||
SignedNativeOrder,
|
SignedNativeOrder,
|
||||||
TypedMakerUrl,
|
TypedMakerUrl,
|
||||||
} from '../types';
|
} from '../types';
|
||||||
@ -125,7 +125,7 @@ export class QuoteRequestor {
|
|||||||
}
|
}
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
private readonly _rfqtAssetOfferings: RfqtMakerAssetOfferings,
|
private readonly _rfqtAssetOfferings: RfqMakerAssetOfferings,
|
||||||
private readonly _quoteRequestorHttpClient: AxiosInstance,
|
private readonly _quoteRequestorHttpClient: AxiosInstance,
|
||||||
private readonly _altRfqCreds?: { altRfqApiKey: string; altRfqProfile: string },
|
private readonly _altRfqCreds?: { altRfqApiKey: string; altRfqProfile: string },
|
||||||
private readonly _warningLogger: LogFunction = constants.DEFAULT_WARNING_LOGGER,
|
private readonly _warningLogger: LogFunction = constants.DEFAULT_WARNING_LOGGER,
|
||||||
@ -141,9 +141,9 @@ export class QuoteRequestor {
|
|||||||
assetFillAmount: BigNumber,
|
assetFillAmount: BigNumber,
|
||||||
marketOperation: MarketOperation,
|
marketOperation: MarketOperation,
|
||||||
comparisonPrice: BigNumber | undefined,
|
comparisonPrice: BigNumber | undefined,
|
||||||
options: RfqtRequestOpts,
|
options: RfqRequestOpts,
|
||||||
): Promise<SignedNativeOrder[]> {
|
): Promise<SignedNativeOrder[]> {
|
||||||
const _opts: RfqtRequestOpts = { ...constants.DEFAULT_RFQT_REQUEST_OPTS, ...options };
|
const _opts: RfqRequestOpts = { ...constants.DEFAULT_RFQT_REQUEST_OPTS, ...options };
|
||||||
if (!_opts.txOrigin || [undefined, '', '0x', NULL_ADDRESS].includes(_opts.txOrigin)) {
|
if (!_opts.txOrigin || [undefined, '', '0x', NULL_ADDRESS].includes(_opts.txOrigin)) {
|
||||||
throw new Error('RFQ-T firm quotes require the presence of a tx origin');
|
throw new Error('RFQ-T firm quotes require the presence of a tx origin');
|
||||||
}
|
}
|
||||||
@ -222,9 +222,9 @@ export class QuoteRequestor {
|
|||||||
assetFillAmount: BigNumber,
|
assetFillAmount: BigNumber,
|
||||||
marketOperation: MarketOperation,
|
marketOperation: MarketOperation,
|
||||||
comparisonPrice: BigNumber | undefined,
|
comparisonPrice: BigNumber | undefined,
|
||||||
options: RfqtRequestOpts,
|
options: RfqRequestOpts,
|
||||||
): Promise<V4RFQIndicativeQuote[]> {
|
): Promise<V4RFQIndicativeQuote[]> {
|
||||||
const _opts: RfqtRequestOpts = { ...constants.DEFAULT_RFQT_REQUEST_OPTS, ...options };
|
const _opts: RfqRequestOpts = { ...constants.DEFAULT_RFQT_REQUEST_OPTS, ...options };
|
||||||
// Originally a takerAddress was required for indicative quotes, but
|
// Originally a takerAddress was required for indicative quotes, but
|
||||||
// now we've eliminated that requirement. @0x/quote-server, however,
|
// now we've eliminated that requirement. @0x/quote-server, however,
|
||||||
// is still coded to expect a takerAddress. So if the client didn't
|
// is still coded to expect a takerAddress. So if the client didn't
|
||||||
@ -317,7 +317,7 @@ export class QuoteRequestor {
|
|||||||
typedMakerUrl: TypedMakerUrl,
|
typedMakerUrl: TypedMakerUrl,
|
||||||
makerToken: string,
|
makerToken: string,
|
||||||
takerToken: string,
|
takerToken: string,
|
||||||
altMakerAssetOfferings: AltRfqtMakerAssetOfferings | undefined,
|
altMakerAssetOfferings: AltRfqMakerAssetOfferings | undefined,
|
||||||
): boolean {
|
): boolean {
|
||||||
if (typedMakerUrl.pairType === RfqPairType.Standard) {
|
if (typedMakerUrl.pairType === RfqPairType.Standard) {
|
||||||
for (const assetPair of this._rfqtAssetOfferings[typedMakerUrl.url]) {
|
for (const assetPair of this._rfqtAssetOfferings[typedMakerUrl.url]) {
|
||||||
@ -353,7 +353,7 @@ export class QuoteRequestor {
|
|||||||
assetFillAmount: BigNumber,
|
assetFillAmount: BigNumber,
|
||||||
marketOperation: MarketOperation,
|
marketOperation: MarketOperation,
|
||||||
comparisonPrice: BigNumber | undefined,
|
comparisonPrice: BigNumber | undefined,
|
||||||
options: RfqtRequestOpts,
|
options: RfqRequestOpts,
|
||||||
quoteType: 'firm' | 'indicative',
|
quoteType: 'firm' | 'indicative',
|
||||||
): Promise<Array<RfqQuote<ResponseT>>> {
|
): Promise<Array<RfqQuote<ResponseT>>> {
|
||||||
const requestParams = QuoteRequestor.makeQueryParameters(
|
const requestParams = QuoteRequestor.makeQueryParameters(
|
||||||
@ -382,8 +382,8 @@ export class QuoteRequestor {
|
|||||||
return { pairType: RfqPairType.Standard, url: mm };
|
return { pairType: RfqPairType.Standard, url: mm };
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
const altUrls = options.altRfqtAssetOfferings
|
const altUrls = options.altRfqAssetOfferings
|
||||||
? Object.keys(options.altRfqtAssetOfferings).map(
|
? Object.keys(options.altRfqAssetOfferings).map(
|
||||||
(mm: string): TypedMakerUrl => {
|
(mm: string): TypedMakerUrl => {
|
||||||
return { pairType: RfqPairType.Alt, url: mm };
|
return { pairType: RfqPairType.Alt, url: mm };
|
||||||
},
|
},
|
||||||
@ -410,7 +410,7 @@ export class QuoteRequestor {
|
|||||||
if (isBlacklisted) {
|
if (isBlacklisted) {
|
||||||
this._infoLogger({ rfqtMakerInteraction: { ...partialLogEntry } });
|
this._infoLogger({ rfqtMakerInteraction: { ...partialLogEntry } });
|
||||||
return;
|
return;
|
||||||
} else if (!this._makerSupportsPair(typedMakerUrl, makerToken, takerToken, options.altRfqtAssetOfferings)) {
|
} else if (!this._makerSupportsPair(typedMakerUrl, makerToken, takerToken, options.altRfqAssetOfferings)) {
|
||||||
return;
|
return;
|
||||||
} else {
|
} else {
|
||||||
// make request to MM
|
// make request to MM
|
||||||
@ -452,7 +452,7 @@ export class QuoteRequestor {
|
|||||||
makerToken,
|
makerToken,
|
||||||
takerToken,
|
takerToken,
|
||||||
timeoutMs,
|
timeoutMs,
|
||||||
options.altRfqtAssetOfferings || {},
|
options.altRfqAssetOfferings || {},
|
||||||
requestParams,
|
requestParams,
|
||||||
this._quoteRequestorHttpClient,
|
this._quoteRequestorHttpClient,
|
||||||
cancelTokenSource.token,
|
cancelTokenSource.token,
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
import axios, { AxiosInstance } from 'axios';
|
import axios, { AxiosInstance } from 'axios';
|
||||||
import AxiosMockAdapter from 'axios-mock-adapter';
|
import AxiosMockAdapter from 'axios-mock-adapter';
|
||||||
|
|
||||||
import { MockedRfqtQuoteResponse } from '../types';
|
import { MockedRfqQuoteResponse } from '../types';
|
||||||
|
|
||||||
export enum RfqtQuoteEndpoint {
|
export enum RfqtQuoteEndpoint {
|
||||||
Indicative = 'price',
|
Indicative = 'price',
|
||||||
@ -18,7 +18,7 @@ export const rfqtMocker = {
|
|||||||
* requests to RFQ-t providers
|
* requests to RFQ-t providers
|
||||||
*/
|
*/
|
||||||
withMockedRfqtQuotes: async (
|
withMockedRfqtQuotes: async (
|
||||||
mockedResponses: MockedRfqtQuoteResponse[],
|
mockedResponses: MockedRfqQuoteResponse[],
|
||||||
quoteType: RfqtQuoteEndpoint,
|
quoteType: RfqtQuoteEndpoint,
|
||||||
afterResponseCallback: () => Promise<void>,
|
afterResponseCallback: () => Promise<void>,
|
||||||
axiosClient: AxiosInstance = axios,
|
axiosClient: AxiosInstance = axios,
|
||||||
|
@ -14,7 +14,7 @@ import { Web3Wrapper } from '@0x/web3-wrapper';
|
|||||||
import * as _ from 'lodash';
|
import * as _ from 'lodash';
|
||||||
import * as TypeMoq from 'typemoq';
|
import * as TypeMoq from 'typemoq';
|
||||||
|
|
||||||
import { MarketOperation, QuoteRequestor, RfqtRequestOpts, SignedNativeOrder } from '../src';
|
import { MarketOperation, QuoteRequestor, RfqRequestOpts, SignedNativeOrder } from '../src';
|
||||||
import { NativeOrderWithFillableAmounts } from '../src/types';
|
import { NativeOrderWithFillableAmounts } from '../src/types';
|
||||||
import { MarketOperationUtils } from '../src/utils/market_operation_utils/';
|
import { MarketOperationUtils } from '../src/utils/market_operation_utils/';
|
||||||
import { BalancerPoolsCache } from '../src/utils/market_operation_utils/balancer_utils';
|
import { BalancerPoolsCache } from '../src/utils/market_operation_utils/balancer_utils';
|
||||||
@ -714,7 +714,7 @@ describe('MarketOperationUtils tests', () => {
|
|||||||
_assetFillAmount: BigNumber,
|
_assetFillAmount: BigNumber,
|
||||||
_marketOperation: MarketOperation,
|
_marketOperation: MarketOperation,
|
||||||
comparisonPrice: BigNumber | undefined,
|
comparisonPrice: BigNumber | undefined,
|
||||||
_options: RfqtRequestOpts,
|
_options: RfqRequestOpts,
|
||||||
) => {
|
) => {
|
||||||
requestedComparisonPrice = comparisonPrice;
|
requestedComparisonPrice = comparisonPrice;
|
||||||
},
|
},
|
||||||
|
@ -12,13 +12,13 @@ import 'mocha';
|
|||||||
|
|
||||||
import { constants, KEEP_ALIVE_TTL } from '../src/constants';
|
import { constants, KEEP_ALIVE_TTL } from '../src/constants';
|
||||||
import {
|
import {
|
||||||
AltMockedRfqtQuoteResponse,
|
AltMockedRfqQuoteResponse,
|
||||||
AltQuoteModel,
|
AltQuoteModel,
|
||||||
AltQuoteRequestData,
|
AltQuoteRequestData,
|
||||||
AltQuoteSide,
|
AltQuoteSide,
|
||||||
AltRfqtMakerAssetOfferings,
|
AltRfqMakerAssetOfferings,
|
||||||
MarketOperation,
|
MarketOperation,
|
||||||
MockedRfqtQuoteResponse,
|
MockedRfqQuoteResponse,
|
||||||
} from '../src/types';
|
} from '../src/types';
|
||||||
import { NULL_ADDRESS } from '../src/utils/market_operation_utils/constants';
|
import { NULL_ADDRESS } from '../src/utils/market_operation_utils/constants';
|
||||||
import { QuoteRequestor } from '../src/utils/quote_requestor';
|
import { QuoteRequestor } from '../src/utils/quote_requestor';
|
||||||
@ -50,7 +50,7 @@ describe('QuoteRequestor', async () => {
|
|||||||
const [makerToken, takerToken, otherToken1] = tokenUtils.getDummyERC20TokenAddresses();
|
const [makerToken, takerToken, otherToken1] = tokenUtils.getDummyERC20TokenAddresses();
|
||||||
const validSignature = { v: 28, r: '0x', s: '0x', signatureType: SignatureType.EthSign };
|
const validSignature = { v: 28, r: '0x', s: '0x', signatureType: SignatureType.EthSign };
|
||||||
|
|
||||||
const altRfqtAssetOfferings: AltRfqtMakerAssetOfferings = {
|
const altRfqAssetOfferings: AltRfqMakerAssetOfferings = {
|
||||||
'https://132.0.0.1': [
|
'https://132.0.0.1': [
|
||||||
{
|
{
|
||||||
id: 'XYZ-123',
|
id: 'XYZ-123',
|
||||||
@ -70,8 +70,8 @@ describe('QuoteRequestor', async () => {
|
|||||||
|
|
||||||
// Set up RFQT responses
|
// Set up RFQT responses
|
||||||
// tslint:disable-next-line:array-type
|
// tslint:disable-next-line:array-type
|
||||||
const mockedRequests: MockedRfqtQuoteResponse[] = [];
|
const mockedRequests: MockedRfqQuoteResponse[] = [];
|
||||||
const altMockedRequests: AltMockedRfqtQuoteResponse[] = [];
|
const altMockedRequests: AltMockedRfqQuoteResponse[] = [];
|
||||||
|
|
||||||
const expectedParams: TakerRequestQueryParams = {
|
const expectedParams: TakerRequestQueryParams = {
|
||||||
sellTokenAddress: takerToken,
|
sellTokenAddress: takerToken,
|
||||||
@ -237,7 +237,7 @@ describe('QuoteRequestor', async () => {
|
|||||||
takerAddress,
|
takerAddress,
|
||||||
txOrigin: takerAddress,
|
txOrigin: takerAddress,
|
||||||
intentOnFilling: true,
|
intentOnFilling: true,
|
||||||
altRfqtAssetOfferings,
|
altRfqAssetOfferings,
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
expect(resp).to.deep.eq([
|
expect(resp).to.deep.eq([
|
||||||
@ -269,7 +269,7 @@ describe('QuoteRequestor', async () => {
|
|||||||
|
|
||||||
// Set up RFQT responses
|
// Set up RFQT responses
|
||||||
// tslint:disable-next-line:array-type
|
// tslint:disable-next-line:array-type
|
||||||
const mockedRequests: MockedRfqtQuoteResponse[] = [];
|
const mockedRequests: MockedRfqQuoteResponse[] = [];
|
||||||
const expectedParams: TakerRequestQueryParams = {
|
const expectedParams: TakerRequestQueryParams = {
|
||||||
sellTokenAddress: takerToken,
|
sellTokenAddress: takerToken,
|
||||||
buyTokenAddress: makerToken,
|
buyTokenAddress: makerToken,
|
||||||
@ -375,7 +375,7 @@ describe('QuoteRequestor', async () => {
|
|||||||
|
|
||||||
// Set up RFQT responses
|
// Set up RFQT responses
|
||||||
// tslint:disable-next-line:array-type
|
// tslint:disable-next-line:array-type
|
||||||
const mockedRequests: MockedRfqtQuoteResponse[] = [];
|
const mockedRequests: MockedRfqQuoteResponse[] = [];
|
||||||
const expectedParams: TakerRequestQueryParams = {
|
const expectedParams: TakerRequestQueryParams = {
|
||||||
sellTokenAddress: takerToken,
|
sellTokenAddress: takerToken,
|
||||||
buyTokenAddress: makerToken,
|
buyTokenAddress: makerToken,
|
||||||
@ -459,7 +459,7 @@ describe('QuoteRequestor', async () => {
|
|||||||
|
|
||||||
// Set up RFQT responses
|
// Set up RFQT responses
|
||||||
// tslint:disable-next-line:array-type
|
// tslint:disable-next-line:array-type
|
||||||
const mockedRequests: MockedRfqtQuoteResponse[] = [];
|
const mockedRequests: MockedRfqQuoteResponse[] = [];
|
||||||
const expectedParams: TakerRequestQueryParams = {
|
const expectedParams: TakerRequestQueryParams = {
|
||||||
sellTokenAddress: takerToken,
|
sellTokenAddress: takerToken,
|
||||||
buyTokenAddress: makerToken,
|
buyTokenAddress: makerToken,
|
||||||
@ -523,7 +523,7 @@ describe('QuoteRequestor', async () => {
|
|||||||
const quoteToken = takerToken;
|
const quoteToken = takerToken;
|
||||||
|
|
||||||
// Set up RFQT responses
|
// Set up RFQT responses
|
||||||
const altMockedRequests: AltMockedRfqtQuoteResponse[] = [];
|
const altMockedRequests: AltMockedRfqQuoteResponse[] = [];
|
||||||
const altScenarios: Array<{
|
const altScenarios: Array<{
|
||||||
successfulQuote: V4RFQIndicativeQuote;
|
successfulQuote: V4RFQIndicativeQuote;
|
||||||
requestedMakerToken: string;
|
requestedMakerToken: string;
|
||||||
@ -737,7 +737,7 @@ describe('QuoteRequestor', async () => {
|
|||||||
takerAddress,
|
takerAddress,
|
||||||
txOrigin,
|
txOrigin,
|
||||||
intentOnFilling: true,
|
intentOnFilling: true,
|
||||||
altRfqtAssetOfferings,
|
altRfqAssetOfferings,
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
// hack to get the expiry right, since it's dependent on the current timestamp
|
// hack to get the expiry right, since it's dependent on the current timestamp
|
||||||
|
@ -4,7 +4,7 @@ import AxiosMockAdapter from 'axios-mock-adapter';
|
|||||||
import * as _ from 'lodash';
|
import * as _ from 'lodash';
|
||||||
|
|
||||||
import { InsufficientAssetLiquidityError } from '../../src/errors';
|
import { InsufficientAssetLiquidityError } from '../../src/errors';
|
||||||
import { AltMockedRfqtQuoteResponse, MockedRfqtQuoteResponse } from '../../src/types';
|
import { AltMockedRfqQuoteResponse, MockedRfqQuoteResponse } from '../../src/types';
|
||||||
|
|
||||||
export enum RfqtQuoteEndpoint {
|
export enum RfqtQuoteEndpoint {
|
||||||
Indicative = 'price',
|
Indicative = 'price',
|
||||||
@ -37,8 +37,8 @@ export const testHelpers = {
|
|||||||
* requests to RFQ-t providers
|
* requests to RFQ-t providers
|
||||||
*/
|
*/
|
||||||
withMockedRfqtQuotes: async (
|
withMockedRfqtQuotes: async (
|
||||||
standardMockedResponses: MockedRfqtQuoteResponse[],
|
standardMockedResponses: MockedRfqQuoteResponse[],
|
||||||
altMockedResponses: AltMockedRfqtQuoteResponse[],
|
altMockedResponses: AltMockedRfqQuoteResponse[],
|
||||||
quoteType: RfqtQuoteEndpoint,
|
quoteType: RfqtQuoteEndpoint,
|
||||||
afterResponseCallback: () => Promise<void>,
|
afterResponseCallback: () => Promise<void>,
|
||||||
axiosClient: AxiosInstance = axios,
|
axiosClient: AxiosInstance = axios,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user