Skip to content

Commit

Permalink
feat: add more events to the oracle
Browse files Browse the repository at this point in the history
  • Loading branch information
matthiasmatt committed Dec 29, 2023
1 parent 9ba0f80 commit eb7fdbf
Show file tree
Hide file tree
Showing 3 changed files with 419 additions and 27 deletions.
22 changes: 22 additions & 0 deletions proto/nibiru/oracle/v1/event.proto
Original file line number Diff line number Diff line change
Expand Up @@ -53,3 +53,25 @@ message EventAggregatePrevote {
// transaction messages on behalf of the voting validator.
string feeder = 2;
}


message EventValidatorPerformance{
// Validator is the Bech32 address to which the vote will be credited.
string validator = 1;

// Tendermint consensus voting power
int64 voting_power = 2;

// RewardWeight: Weight of rewards the validator should receive in units of
// consensus power.
int64 reward_weight = 3;

// Number of valid votes for which the validator will be rewarded
int64 win_count = 4;

// Number of abstained votes for which there will be no reward or punishment
int64 abstain_count = 5;

// Number of invalid/punishable votes
int64 miss_count = 6;
}
12 changes: 12 additions & 0 deletions x/oracle/keeper/update_exchange_rates.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,18 @@ func (k Keeper) UpdateExchangeRates(ctx sdk.Context) types.ValidatorPerformances
params, _ := k.Params.Get(ctx)
k.clearVotesAndPrevotes(ctx, params.VotePeriod)
k.refreshWhitelist(ctx, params.Whitelist, whitelistedPairs)

for _, validatorPerformance := range validatorPerformances {
_ = ctx.EventManager().EmitTypedEvent(&types.EventValidatorPerformance{
Validator: validatorPerformance.ValAddress.String(),
VotingPower: validatorPerformance.Power,
RewardWeight: validatorPerformance.RewardWeight,
WinCount: validatorPerformance.WinCount,
AbstainCount: validatorPerformance.AbstainCount,
MissCount: validatorPerformance.MissCount,
})
}

return validatorPerformances
}

Expand Down
Loading

0 comments on commit eb7fdbf

Please sign in to comment.