Skip to content

Commit

Permalink
feat(streamer): added docstring
Browse files Browse the repository at this point in the history
  • Loading branch information
keruch committed Aug 21, 2024
1 parent fd2747f commit 0a13b9a
Showing 1 changed file with 18 additions and 2 deletions.
20 changes: 18 additions & 2 deletions x/streamer/types/distr_info.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,24 @@ func (r DistrRecord) ValidateBasic() error {
return nil
}

// DistrInfoFromDistribution converts sponsorship distribution to the DistrInfo type.
// Returning an empty DistrInfo (with zero DistrInfo.TotalWeight) is a valid scenario.
// DistrInfoFromDistribution converts sponsorship distribution to the DistrInfo type. Returning an empty
// DistrInfo (with zero DistrInfo.TotalWeight) is a valid scenario. Note that some part of the distribution
// might be abstained. In that case, the sum of gauge powers would be less than the total distribution weight.
//
// Example! Let's say we have the following distribution in the sponsorship:
//
// Total: 100
// Gauge1: 30%
// Gauge2: 50%
// Abstained: 20%
//
// We want to distribute 100 DYM according to this distribution. Since 20% is abstained, we will normalize the figures
// for Gauge1 and Gauge2. The total "active" voting power is 80%, which comes from 30% (Gauge1) + 50% (Gauge2).
//
// Gauge1: 30% / 80% = 37.5% (in the new distribution)
// Gauge2: 50% / 80% = 62.5% (in the new distribution)
//
// So, Gauge1 gets 37.5 DYM, and Gauge2 gets 62.5 DYM.
func DistrInfoFromDistribution(d sponsorshiptypes.Distribution) *DistrInfo {
totalWeight := math.ZeroInt()

Expand Down

0 comments on commit 0a13b9a

Please sign in to comment.