Skip to content
This repository has been archived by the owner on Aug 15, 2023. It is now read-only.

Commit

Permalink
Feat add price service fees to grafana (#108)
Browse files Browse the repository at this point in the history
* feat: add price service fees to grafana
Co-authored-by: Sebastien Verreault <[email protected]>
  • Loading branch information
sebastienverreault authored Jul 4, 2022
1 parent cefedf4 commit 23fa92e
Show file tree
Hide file tree
Showing 3 changed files with 224 additions and 106 deletions.
6 changes: 3 additions & 3 deletions dealer/default.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
33 changes: 33 additions & 0 deletions dealer/src/servers/exporter/exporter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down Expand Up @@ -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({
Expand Down Expand Up @@ -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 +
Expand Down
Loading

0 comments on commit 23fa92e

Please sign in to comment.