diff --git a/src/aggregator_functions.ts b/src/aggregator_functions.ts index fb8844b8..19a96d41 100644 --- a/src/aggregator_functions.ts +++ b/src/aggregator_functions.ts @@ -114,6 +114,7 @@ export function crossCheckPriceData( // 1. Prices should not deviate more than maxPercentageDeviation. const prices = tickerData.map((price: WeightedPrice) => price.price) const maxNormalizedAbsMeanDev = maxPercentageDeviaton(prices) + config.metricCollector?.maxPercentageDeviation(config.currencyPair, maxNormalizedAbsMeanDev) assert( maxNormalizedAbsMeanDev.isLessThanOrEqualTo(config.maxPercentageDeviation), `Max price cross-sectional deviation too large (${maxNormalizedAbsMeanDev} >= ${config.maxPercentageDeviation} )` diff --git a/src/metric_collector.ts b/src/metric_collector.ts index 96bc2d7f..0c74bab2 100644 --- a/src/metric_collector.ts +++ b/src/metric_collector.ts @@ -67,6 +67,7 @@ export class MetricCollector { private tickerPropertyGauge: Gauge private priceSourceGauge: Gauge + private maxPercentageDeviationGauge: Gauge private transactionBlockNumberGauge: Gauge private transactionGasGauge: Gauge @@ -158,6 +159,12 @@ export class MetricCollector { labelNames: ['pair', 'source', 'property'], }) + this.maxPercentageDeviationGauge = new Gauge({ + name: 'oracle_max_percentage_deviation', + help: 'Gauge to indicate the max price cross-sectional deviation of a price pair', + labelNames: ['currencyPair'], + }) + this.transactionBlockNumberGauge = new Gauge({ name: 'oracle_transaction_block_number', help: 'Gauge showing the block number of the most recent transaction defined by type', @@ -331,6 +338,13 @@ export class MetricCollector { this.priceSourceGauge.set({ pair, source, property: 'weight' }, weightedPrice.weight.toNumber()) } + /** + * Indicates the max price cross-sectional deviation of a price pair + */ + maxPercentageDeviation(pair: string, maxPercentageDeviation: BigNumber) { + this.maxPercentageDeviationGauge.set({ pair }, maxPercentageDeviation.toNumber()) + } + /** * Indicates the most recent block number of a specific type */