Assessment reports>Nibiru>Threat Models>Hook: UpdateExchangeRates

Hook: UpdateExchangeRates

The UpdateExchangeRates hook is called every VotePeriod blocks and is responsible for updating the exchange rates based on all the votes that have been cast from the validators. The basic flow is

  1. Reset the current exchange rates by removing them all from the store.

  2. Split the votes into ballots by pair, removing any votes from nonbonded or jailed validators, any non-whitelisted pairs, pairs with less than the minimum number of votes, or pairs that have less than the voting power threshold.

  3. For each valid pair, tally up the votes and find the weighted median exchange rate and record the validators that voted for an exchange rate that was within the reward band, and then update the exchange rate.

  4. Count up the validators who missed the vote and increase the appropriate miss counters.

  5. Distribute rewards to the validators that voted for an exchange rate that was within the reward band.

  6. Clear previous prevotes and all votes from the store.

Zellic © 2024Back to top ↑