From 23fa92ed0fc0e6f94e2b7bb53248e8d0206c503f Mon Sep 17 00:00:00 2001 From: sebastienverreault Date: Mon, 4 Jul 2022 19:18:38 +0900 Subject: [PATCH] Feat add price service fees to grafana (#108) * feat: add price service fees to grafana Co-authored-by: Sebastien Verreault --- dealer/default.yaml | 6 +- dealer/src/servers/exporter/exporter.ts | 33 ++ .../provisioning/dashboards/galoy-dealer.json | 291 +++++++++++------- 3 files changed, 224 insertions(+), 106 deletions(-) diff --git a/dealer/default.yaml b/dealer/default.yaml index 5f2099e0..ae591a6d 100644 --- a/dealer/default.yaml +++ b/dealer/default.yaml @@ -24,9 +24,9 @@ rebalancing: minOnchain: 10000000 # 0.1 fees: - BASE_FEE: 0.0003 - IMMEDIATE_CONVERSION_SPREAD: 0.0001 - DELAYED_CONVERSION_SPREAD: 0.0002 + BASE_FEE: 0.0005 + IMMEDIATE_CONVERSION_SPREAD: 0.0005 + DELAYED_CONVERSION_SPREAD: 0.0007 withdrawal: MIN_ON_CHAIN_WITHDRAWAL_AMOUNT: 0.001 diff --git a/dealer/src/servers/exporter/exporter.ts b/dealer/src/servers/exporter/exporter.ts index 7a3b24c5..f0cd2276 100644 --- a/dealer/src/servers/exporter/exporter.ts +++ b/dealer/src/servers/exporter/exporter.ts @@ -11,9 +11,12 @@ import { SemanticAttributes, } from "../../services/tracing" import { ErrorLevel } from "../../Result" +import { yamlConfig } from "../../config" dotenv.config() +const fees = yamlConfig.fees + const logger = baseLogger.child({ module: "exporter" }) const server = express() @@ -512,6 +515,27 @@ const metrics: { [key: string]: IMetricData } = { help: "5Y funding yield", }), }, + baseFee: { + value: NaN, + gauge: new client.Gauge({ + name: `${prefix}_baseFee`, + help: "price service base fee", + }), + }, + immediateConversionSpread: { + value: NaN, + gauge: new client.Gauge({ + name: `${prefix}_immediateConversionSpread`, + help: "price service immediate conversion spread", + }), + }, + delayedConversionSpread: { + value: NaN, + gauge: new client.Gauge({ + name: `${prefix}_delayedConversionSpread`, + help: "price service delayed conversion spread", + }), + }, exchangeStatus: { value: NaN, gauge: new client.Gauge({ @@ -782,6 +806,15 @@ export async function exporter() { // Is exchange up? Metrics.set(metrics["exchangeStatus"], await dealer.getExchangeStatus()) + // Price Service fees & spread + Metrics.set(metrics["exchangeStatus"], await dealer.getExchangeStatus()) + Metrics.set(metrics["baseFee"], fees.BASE_FEE) + Metrics.set( + metrics["immediateConversionSpread"], + fees.IMMEDIATE_CONVERSION_SPREAD, + ) + Metrics.set(metrics["delayedConversionSpread"], fees.DELAYED_CONVERSION_SPREAD) + // Realized Profit And Loss const strategyRPnlInSats = tradingFeesMetrics.tradingFeesTotalInSats + diff --git a/grafana/provisioning/dashboards/galoy-dealer.json b/grafana/provisioning/dashboards/galoy-dealer.json index 59a35efa..c0d27f61 100644 --- a/grafana/provisioning/dashboards/galoy-dealer.json +++ b/grafana/provisioning/dashboards/galoy-dealer.json @@ -3096,136 +3096,88 @@ }, { "datasource": null, - "description": "", "fieldConfig": { "defaults": { "color": { - "mode": "palette-classic" - }, - "custom": { - "axisLabel": "", - "axisPlacement": "auto", - "axisSoftMax": 1, - "axisSoftMin": -1, - "barAlignment": 0, - "drawStyle": "bars", - "fillOpacity": 100, - "gradientMode": "scheme", - "hideFrom": { - "legend": false, - "tooltip": false, - "viz": false - }, - "lineInterpolation": "linear", - "lineWidth": 1, - "pointSize": 5, - "scaleDistribution": { - "type": "linear" - }, - "showPoints": "auto", - "spanNulls": false, - "stacking": { - "group": "A", - "mode": "none" - }, - "thresholdsStyle": { - "mode": "off" - } + "mode": "thresholds" }, - "mappings": [ - { - "options": { - "from": 0, - "result": { - "color": "green", - "index": 0, - "text": "UP" - }, - "to": 1 - }, - "type": "range" - }, - { - "options": { - "from": -1, - "result": { - "color": "red", - "index": 1, - "text": "DOWN" - }, - "to": 0 - }, - "type": "range" - } - ], + "mappings": [], + "min": 0, "thresholds": { "mode": "absolute", "steps": [ - { - "color": "red", - "value": null - }, - { - "color": "red", - "value": -0.0001 - }, { "color": "green", - "value": 0 - }, - { - "color": "green", - "value": 0.001 + "value": null } ] - } + }, + "unit": "percentunit" }, - "overrides": [ - { - "matcher": { - "id": "byName", - "options": "isExchangeAlive" - }, - "properties": [ - { - "id": "color", - "value": { - "mode": "thresholds", - "seriesBy": "last" - } - } - ] - } - ] + "overrides": [] }, "gridPos": { - "h": 14, + "h": 5, "w": 12, "x": 0, "y": 42 }, - "id": 64, + "id": 69, "options": { - "legend": { - "calcs": ["last"], - "displayMode": "list", - "placement": "bottom" + "displayMode": "lcd", + "orientation": "horizontal", + "reduceOptions": { + "calcs": ["lastNotNull"], + "fields": "", + "values": false }, - "tooltip": { - "mode": "multi" - } + "showUnfilled": true, + "text": {} }, + "pluginVersion": "8.1.1", "targets": [ { "exemplar": true, - "expr": "avg by (container)(galoy_dealer_exchangeStatus)", + "expr": "avg by (container)(galoy_dealer_baseFee)", "interval": "", - "legendFormat": "isExchangeAlive", + "legendFormat": "base fee", "refId": "A" + }, + { + "exemplar": true, + "expr": "avg by (container)(galoy_dealer_immediateConversionSpread)", + "hide": false, + "interval": "", + "legendFormat": "immediate spread", + "refId": "B" + }, + { + "exemplar": true, + "expr": "avg by (container)(galoy_dealer_delayedConversionSpread)", + "hide": false, + "interval": "", + "legendFormat": "delayed spread", + "refId": "C" + }, + { + "exemplar": true, + "expr": "avg by (container)(galoy_dealer_baseFee + galoy_dealer_immediateConversionSpread)", + "hide": false, + "interval": "", + "legendFormat": "immediate fee (base + spread)", + "refId": "D" + }, + { + "exemplar": true, + "expr": "avg by (container)(galoy_dealer_baseFee + galoy_dealer_delayedConversionSpread)", + "hide": false, + "interval": "", + "legendFormat": "delayed fee (base + spread)", + "refId": "E" } ], - "title": "Exchange Status", - "type": "timeseries" + "title": "Price Service Spreads & Fees", + "type": "bargauge" }, { "datasource": null, @@ -3393,6 +3345,139 @@ "title": "InFlight Transfers", "type": "bargauge" }, + { + "datasource": null, + "description": "", + "fieldConfig": { + "defaults": { + "color": { + "mode": "palette-classic" + }, + "custom": { + "axisLabel": "", + "axisPlacement": "auto", + "axisSoftMax": 1, + "axisSoftMin": -1, + "barAlignment": 0, + "drawStyle": "bars", + "fillOpacity": 100, + "gradientMode": "scheme", + "hideFrom": { + "legend": false, + "tooltip": false, + "viz": false + }, + "lineInterpolation": "linear", + "lineWidth": 1, + "pointSize": 5, + "scaleDistribution": { + "type": "linear" + }, + "showPoints": "auto", + "spanNulls": false, + "stacking": { + "group": "A", + "mode": "none" + }, + "thresholdsStyle": { + "mode": "off" + } + }, + "mappings": [ + { + "options": { + "from": 0, + "result": { + "color": "green", + "index": 0, + "text": "UP" + }, + "to": 1 + }, + "type": "range" + }, + { + "options": { + "from": -1, + "result": { + "color": "red", + "index": 1, + "text": "DOWN" + }, + "to": 0 + }, + "type": "range" + } + ], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "red", + "value": null + }, + { + "color": "red", + "value": -0.0001 + }, + { + "color": "green", + "value": 0 + }, + { + "color": "green", + "value": 0.001 + } + ] + } + }, + "overrides": [ + { + "matcher": { + "id": "byName", + "options": "isExchangeAlive" + }, + "properties": [ + { + "id": "color", + "value": { + "mode": "thresholds", + "seriesBy": "last" + } + } + ] + } + ] + }, + "gridPos": { + "h": 9, + "w": 12, + "x": 0, + "y": 47 + }, + "id": 64, + "options": { + "legend": { + "calcs": ["last"], + "displayMode": "list", + "placement": "bottom" + }, + "tooltip": { + "mode": "multi" + } + }, + "targets": [ + { + "exemplar": true, + "expr": "avg by (container)(galoy_dealer_exchangeStatus)", + "interval": "", + "legendFormat": "isExchangeAlive", + "refId": "A" + } + ], + "title": "Exchange Status", + "type": "timeseries" + }, { "datasource": null, "fieldConfig": { @@ -3586,5 +3671,5 @@ "timezone": "", "title": "Galoy Dealer", "uid": "pTEP9n47k", - "version": 74 + "version": 78 }