Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow the wildcard pairs amounts to be measured as well #165

Merged
merged 3 commits into from
Apr 19, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Allow the wildcard pairs amounts to be measured as well
  • Loading branch information
mikeki committed Apr 19, 2023
commit 60bad1f1b55ce8dbe8395ff8ab5c27bfeba68321
31 changes: 5 additions & 26 deletions lib/dashboards/cached-routes-widgets-factory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,32 +18,11 @@ export class CachedRoutesWidgetsFactory implements WidgetsFactory {
generateWidgets(): Widget[] {
const cacheHitMissWidgets = this.generateCacheHitMissMetricsWidgets()

const [wildcardStrategies, strategies] = _.partition(Array.from(CACHED_ROUTES_CONFIGURATION.values()), (strategy) =>
strategy.pair.includes('*')
const strategiesWidgets = _.flatMap(Array.from(CACHED_ROUTES_CONFIGURATION.values()), (cacheStrategy) =>
this.generateWidgetsForStrategies(cacheStrategy)
)

let wildcardStrategiesWidgets: Widget[] = []
if (wildcardStrategies.length > 0) {
wildcardStrategiesWidgets = _.flatMap(wildcardStrategies, (cacheStrategy) => {
const tokenIn = cacheStrategy.pair.split('/')[0].replace('*', 'TokenIn')
const tokenOut = cacheStrategy.pair.split('/')[1].replace('*', 'TokenOut')

return this.generateTapcompareWidgets(tokenIn, tokenOut, cacheStrategy.readablePairTradeTypeChainId())
})

wildcardStrategiesWidgets.unshift({
type: 'text',
width: 24,
height: 1,
properties: {
markdown: `# Wildcard pairs`,
},
})
}

const strategiesWidgets = _.flatMap(strategies, (cacheStrategy) => this.generateWidgetsForStrategies(cacheStrategy))

return cacheHitMissWidgets.concat(wildcardStrategiesWidgets).concat(strategiesWidgets)
return cacheHitMissWidgets.concat(strategiesWidgets)
}

private generateCacheHitMissMetricsWidgets(): Widget[] {
Expand Down Expand Up @@ -128,8 +107,8 @@ export class CachedRoutesWidgetsFactory implements WidgetsFactory {
const getQuoteMetricName = `GET_QUOTE_AMOUNT_${cacheStrategy.pair}_${cacheStrategy.tradeType.toUpperCase()}_CHAIN_${
cacheStrategy.chainId
}`
const tokenIn = cacheStrategy.pair.split('/')[0]
const tokenOut = cacheStrategy.pair.split('/')[1]
const tokenIn = cacheStrategy.pair.split('/')[0].replace('*', 'TokenIn')
const tokenOut = cacheStrategy.pair.split('/')[1].replace('*', 'TokenIn')

const quoteAmountsMetrics: Widget[] = [
{
Expand Down
9 changes: 7 additions & 2 deletions lib/handlers/quote/quote.ts
Original file line number Diff line number Diff line change
Expand Up @@ -503,11 +503,16 @@ export class QuoteHandler extends APIGLambdaHandler<
routeString: string
): void {
const tradingPair = `${currencyIn.symbol}/${currencyOut.symbol}`
const wildcardInPair = `${currencyIn.symbol}/*`
const wildcardOutPair = `*/${currencyOut.symbol}`
const tradeTypeEnumValue = tradeType == 'exactIn' ? TradeType.EXACT_INPUT : TradeType.EXACT_OUTPUT
const pairsTracked = PAIRS_TO_TRACK.get(chainId)?.get(tradeTypeEnumValue)

if (pairsTracked?.includes(tradingPair) || pairsTracked?.includes(wildcardInPair) || pairsTracked?.includes(wildcardOutPair)) {
const metricPair = pairsTracked?.includes(tradingPair) ? tradingPair : pairsTracked?.includes(wildcardInPair) ? wildcardInPair : wildcardOutPair

if (PAIRS_TO_TRACK.get(chainId)?.get(tradeTypeEnumValue)?.includes(tradingPair)) {
metric.putMetric(
`GET_QUOTE_AMOUNT_${tradingPair}_${tradeType.toUpperCase()}_CHAIN_${chainId}`,
`GET_QUOTE_AMOUNT_${metricPair}_${tradeType.toUpperCase()}_CHAIN_${chainId}`,
Number(amount.toExact()),
MetricLoggerUnit.None
)
Expand Down
2 changes: 1 addition & 1 deletion lib/handlers/quote/util/pairs-to-track.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ export const PAIRS_TO_TRACK: Map<ChainId, Map<TradeType, string[]>> = new Map([
[
ChainId.MAINNET,
new Map([
[TradeType.EXACT_INPUT, ['WETH/USDC', 'USDC/WETH', 'USDT/WETH', 'WETH/USDT']],
[TradeType.EXACT_INPUT, ['WETH/USDC', 'USDC/WETH', 'USDT/WETH', 'WETH/USDT', 'WETH/*']],
[TradeType.EXACT_OUTPUT, ['USDC/WETH']],
]),
],
Expand Down