Skip to content

Commit

Permalink
feat: accept v4Enabled request param from URA header 'x-v4-enabled'
Browse files Browse the repository at this point in the history
  • Loading branch information
jsy1218 committed Sep 5, 2024
1 parent d90b276 commit 3733a02
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions lib/handlers/quote/quote.ts
Original file line number Diff line number Diff line change
Expand Up @@ -251,6 +251,8 @@ export class QuoteHandler extends APIGLambdaHandler<

const requestSourceHeader = params.event.headers && params.event.headers['x-request-source']
const appVersion = params.event.headers && params.event.headers['x-app-version']
const isV4Enabled = params.event.headers && params.event.headers['x-v4-enabled'] === '1'
const excludedProtocolsFromMixed = isV4Enabled ? undefined : [Protocol.V4]

if (requestSourceHeader) {
metric.putMetric(`RequestSource.${requestSourceHeader}`, 1)
Expand All @@ -261,7 +263,7 @@ export class QuoteHandler extends APIGLambdaHandler<
}

const requestSource = requestSourceHeader ?? params.requestQueryParams.source ?? ''
const protocols = QuoteHandler.protocolsFromRequest(chainId, protocolsStr, forceCrossProtocol)
const protocols = QuoteHandler.protocolsFromRequest(chainId, isV4Enabled, protocolsStr, forceCrossProtocol)

if (protocols === undefined) {
return {
Expand Down Expand Up @@ -325,6 +327,7 @@ export class QuoteHandler extends APIGLambdaHandler<
// accidentally override usedCachedRoutes in the normal path.
...(enableFeeOnTransferFeeFetching ? FEE_ON_TRANSFER_SPECIFIC_CONFIG(enableFeeOnTransferFeeFetching) : {}),
...(gasToken ? { gasToken } : {}),
...(excludedProtocolsFromMixed ? { excludedProtocolsFromMixed } : {}),
}

metric.putMetric(`${intent}Intent`, 1, MetricLoggerUnit.Count)
Expand Down Expand Up @@ -690,8 +693,9 @@ export class QuoteHandler extends APIGLambdaHandler<

static protocolsFromRequest(
chainId: ChainId,
requestedProtocols: string[] | string | undefined,
forceCrossProtocol: boolean | undefined
isV4Enabled: boolean,
requestedProtocols?: string[] | string,
forceCrossProtocol?: boolean
): Protocol[] | undefined {
const excludeV2 = false

Expand All @@ -709,7 +713,9 @@ export class QuoteHandler extends APIGLambdaHandler<
protocols.push(Protocol.V3)
break
case Protocol.V4:
protocols.push(Protocol.V4)
if (isV4Enabled) {
protocols.push(Protocol.V4)
}
break
case Protocol.MIXED:
if (chainId === ChainId.MAINNET || !excludeV2) {
Expand Down

0 comments on commit 3733a02

Please sign in to comment.