Skip to content

Commit

Permalink
changes
Browse files Browse the repository at this point in the history
  • Loading branch information
affanv14 committed Oct 3, 2024
1 parent e3a56ac commit a04d5da
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 21 deletions.
3 changes: 1 addition & 2 deletions protocol/lib/metrics/constants.go
Original file line number Diff line number Diff line change
Expand Up @@ -306,8 +306,7 @@ const (
SubaccountOwner = "subaccount_owner"
MarketMapperRevenueDistribution = "market_mapper_revenue_distribution"
AffiliateRevenueShareDistribution = "affiliate_revenue_share_distribution"
UnconditionalRevenueShareDistribution = "unconditional_revenue_share_distribution"
NetFeesPostRevenueShareDistribution = "net_fees_post_revenue_share_distribution"
RevenueShareDistribution = "revenue_share_distribution"

// Liquidation Daemon.
CheckCollateralizationForSubaccounts = "check_collateralization_for_subaccounts"
Expand Down
34 changes: 15 additions & 19 deletions protocol/x/subaccounts/keeper/transfer.go
Original file line number Diff line number Diff line change
Expand Up @@ -250,28 +250,24 @@ func (k Keeper) DistributeFees(
return err
}

// emit a metric for revenue share
labels := []metrics.Label{}
var metricName string
switch revShare.RevShareType {
case revsharetypes.REV_SHARE_TYPE_MARKET_MAPPER:
labels = append(labels, metrics.GetLabelForIntValue(metrics.MarketId, int(perpetual.Params.MarketId)))
metricName = metrics.MarketMapperRevenueDistribution
case revsharetypes.REV_SHARE_TYPE_AFFILIATE:
labels = append(labels, metrics.GetLabelForStringValue(metrics.RecipientAddress, revShare.Recipient))
metricName = metrics.AffiliateRevenueShareDistribution
case revsharetypes.REV_SHARE_TYPE_UNCONDITIONAL:
labels = append(labels, metrics.GetLabelForStringValue(metrics.RecipientAddress, revShare.Recipient))
metricName = metrics.UnconditionalRevenueShareDistribution
default:
ctx.Logger().Error("invalid rev share type", "type", revShare.RevShareType)
continue
}
// Emit revenue share
metrics.AddSampleWithLabels(
metricName,
metrics.RevenueShareDistribution,
metrics.GetMetricValueFromBigInt(revShare.QuoteQuantums),
labels...,
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)),
}
metrics.AddSampleWithLabels(
metrics.RevenueShareDistribution,
metrics.GetMetricValueFromBigInt(revShare.QuoteQuantums),
labels...,
)
}
}

totalTakerFeeRevShareQuantums := big.NewInt(0)
Expand Down

0 comments on commit a04d5da

Please sign in to comment.