Skip to content

Commit

Permalink
[TRA-444] Emit a metric to record market mapper revenue per market (d…
Browse files Browse the repository at this point in the history
…ydxprotocol#1810)

Signed-off-by: Shrenuj Bansal <[email protected]>
  • Loading branch information
shrenujb authored Jun 29, 2024
1 parent 3c07400 commit 432e711
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
1 change: 1 addition & 0 deletions protocol/lib/metrics/constants.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
13 changes: 12 additions & 1 deletion protocol/x/subaccounts/keeper/transfer.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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,
Expand Down

0 comments on commit 432e711

Please sign in to comment.