diff --git a/protocol/lib/metrics/constants.go b/protocol/lib/metrics/constants.go index a0f851eb58..795856530f 100644 --- a/protocol/lib/metrics/constants.go +++ b/protocol/lib/metrics/constants.go @@ -305,6 +305,8 @@ const ( UpdateSubaccounts = "update_subaccounts" SubaccountOwner = "subaccount_owner" MarketMapperRevenueDistribution = "market_mapper_revenue_distribution" + RevenueShareDistribution = "revenue_share_distribution" + NetFeesPostRevenueShareDistribution = "net_fees_post_revenue_share_distribution" // Liquidation Daemon. CheckCollateralizationForSubaccounts = "check_collateralization_for_subaccounts" @@ -410,6 +412,9 @@ const ( ValidatorNumMatchedTakerOrders = "validator_num_matched_taker_orders" ValidatorVolumeQuoteQuantums = "validator_volume_quote_quantums" + // x/revshare + RevShareType = "rev_share_type" + // x/acocuntplus TimestampNonce = "timestamp_nonce" diff --git a/protocol/x/revshare/types/types.go b/protocol/x/revshare/types/types.go index 17ecd548a3..5cdbb6afda 100644 --- a/protocol/x/revshare/types/types.go +++ b/protocol/x/revshare/types/types.go @@ -60,3 +60,18 @@ type RevSharesForFill struct { FeeSourceToRevSharePpm map[RevShareFeeSource]uint32 AllRevShares []RevShare } + +func (r RevShareType) String() string { + switch r { + case REV_SHARE_TYPE_UNSPECIFIED: + return "REV_SHARE_TYPE_UNSPECIFIED" + case REV_SHARE_TYPE_MARKET_MAPPER: + return "REV_SHARE_TYPE_MARKET_MAPPER" + case REV_SHARE_TYPE_UNCONDITIONAL: + return "REV_SHARE_TYPE_UNCONDITIONAL" + case REV_SHARE_TYPE_AFFILIATE: + return "REV_SHARE_TYPE_AFFILIATE" + default: + return "UNKNOWN" + } +} diff --git a/protocol/x/subaccounts/keeper/transfer.go b/protocol/x/subaccounts/keeper/transfer.go index ecf79952be..52ffedce14 100644 --- a/protocol/x/subaccounts/keeper/transfer.go +++ b/protocol/x/subaccounts/keeper/transfer.go @@ -250,7 +250,15 @@ func (k Keeper) DistributeFees( return err } - // emit a metric for the amount of fees transferred to the market mapper + // Emit revenue share + metrics.AddSampleWithLabels( + metrics.RevenueShareDistribution, + metrics.GetMetricValueFromBigInt(revShare.QuoteQuantums), + metrics.GetLabelForStringValue(metrics.RevShareType, revShare.RevShareType.String()), + metrics.GetLabelForStringValue(metrics.RecipientAddress, revShare.Recipient), + ) + + // Old metric which is being kept for now to ensure data continuity if revShare.RevShareType == revsharetypes.REV_SHARE_TYPE_MARKET_MAPPER { labels := []metrics.Label{ metrics.GetLabelForIntValue(metrics.MarketId, int(perpetual.Params.MarketId)), @@ -289,6 +297,12 @@ func (k Keeper) DistributeFees( panic("fee collector share is < 0") } + // Emit fee colletor metric + metrics.AddSample( + metrics.NetFeesPostRevenueShareDistribution, + metrics.GetMetricValueFromBigInt(feeCollectorShare), + ) + // Transfer fees to the fee collector if err := k.TransferFees( ctx,