From 432e711decf01b855cf5ca90b699c9b187399826 Mon Sep 17 00:00:00 2001 From: shrenujb <98204323+shrenujb@users.noreply.github.com> Date: Sat, 29 Jun 2024 02:21:26 -0400 Subject: [PATCH] [TRA-444] Emit a metric to record market mapper revenue per market (#1810) Signed-off-by: Shrenuj Bansal --- protocol/lib/metrics/constants.go | 1 + protocol/x/subaccounts/keeper/transfer.go | 13 ++++++++++++- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/protocol/lib/metrics/constants.go b/protocol/lib/metrics/constants.go index bfddd9745f..0005df4dc4 100644 --- a/protocol/lib/metrics/constants.go +++ b/protocol/lib/metrics/constants.go @@ -302,6 +302,7 @@ const ( GetSubaccount = "get_subaccount" UpdateSubaccounts = "update_subaccounts" SubaccountOwner = "subaccount_owner" + MarketMapperRevenueDistribution = "market_mapper_revenue_distribution" // Liquidation Daemon. CheckCollateralizationForSubaccounts = "check_collateralization_for_subaccounts" diff --git a/protocol/x/subaccounts/keeper/transfer.go b/protocol/x/subaccounts/keeper/transfer.go index 99028725c1..13a3982241 100644 --- a/protocol/x/subaccounts/keeper/transfer.go +++ b/protocol/x/subaccounts/keeper/transfer.go @@ -3,6 +3,8 @@ package keeper import ( "math/big" + "github.com/dydxprotocol/v4-chain/protocol/lib/metrics" + "github.com/dydxprotocol/v4-chain/protocol/lib/log" errorsmod "cosmossdk.io/errors" @@ -262,8 +264,17 @@ func (k Keeper) DistributeFees( // Remaining amount goes to the fee collector feeCollectorShare := new(big.Int).Sub(quantums, marketMapperShare) + // Emit a metric for the amount of fees transferred to the market mapper + labels := []metrics.Label{ + metrics.GetLabelForIntValue(metrics.MarketId, int(perpetual.Params.MarketId)), + } + metrics.AddSampleWithLabels( + metrics.MarketMapperRevenueDistribution, + metrics.GetMetricValueFromBigInt(marketMapperShare), + labels..., + ) + // Transfer fees to the market mapper - // TODO (TRA-444): add monitoring to record the amount of fees transferred to the market mapper if err := k.TransferFees( ctx, assetId,