Oracle

The Oracle module brings up price feeds and exchange rates to Kiichain.

  • It allows validators to submit price data, which can be used by other modules or smart contracts (EVM and Wasm).

  • It supports multiple price feeds, allowing for a diverse set of data sources

  • It provides a mechanism for price data to be aggregated and made available on-chain

Price feeder

Our official implementation for the price feeder is available at Kiichain Price Feeder.

  • The price must be ran by a validator or a delegated address

  • The price feeder is responsible for submitting the price data to the Oracle module

  • More information can be found at the project readme

Core functionality

The Oracle module works as follows:

  • Validators submit price data for arbitrary assets, which are defined in the module params

  • The module aggregates the price data submitted by validators and calculates a final exchange rate for each asset

  • The final exchange rate is stored on-chain and can be queried by other modules or smart contracts

The Exchange Vote is done as following:

  1. A new block is created

  2. Validators submit their votes for the price of each asset in the whitelist through the MsgExchangeRateVote message

  • This message is feeless as long as its the first vote for the validator in the current voting period

  • The vote can be submitted by the validator itself or a delegated address (feeder address)

    • By using a delegated address, validators can separate their voting actions from their staking address

  1. The module aggregates the votes and calculates the final exchange rate for each asset

  2. If no vote is submitted by a validator in the current voting period, the module will slash the validator's stake according to the slash_fraction parameter

  3. The final exchange rate is stored on-chain and can be queried by other modules or smart contracts

State

These are the most important state types used by the Oracle module:

Params

Params stores the module wide configuration. Its defined as:

Exchange Rates

Exchange rates are the single entry for a price data on the chain. Its stored as a Key-Value pair in the store, where the key is the asset denom and the value is the price data.

The price data is defined as:

FeederDelegation

Feeder delegations is the correlation between a validator and a feeder address. It allows validators to use a different address to submit votes.

The FeederDelegation is defined as:

Messages

The Oracle module expose the following messages:

AggregateExchangeRateVote

The MsgAggregateExchangeRateVote message is used by validators to submit their votes for the price of each asset in the whitelist. It contains the following fields:

DelegateFeedConsent

The MsgDelegateFeedConsent message is used to delegate the right to submit votes to a different address. The message contains the following fields:

UpdateParams

The MsgUpdateParams message is used to update the module parameters. Only the governance module can call the message. It contains the following fields:

Begin block

On each ABCI call, the Oracle module performs the following actions:

  1. Check if we are under a new slash window

  2. Check the slash counters for validators and slash them if they didn't submit enough votes in the previous voting period

  3. Remove the excess feeds

End block

At the end of each block, the Oracle module performs the following actions:

  1. Check if we are under a new voting period

  2. Iterate the votes

  3. Calculate the final exchange rate for each asset in the whitelist

  4. Store the final exchange rate on-chain

Ante handler

The Oracle module ignores fees from validators on their first vote in the current voting period. The following is done:

  1. Check if the message is a MsgAggregateExchangeRateVote

  2. Check the validator/feeder relationship

  3. If the validator is voting for the first time in the current voting period, ignore the fees

Acknowledgments

Special thanks to the SEI team. Your contributions to the Cosmos SDK ecosystem are greatly appreciated. The original implementation of the Oracle module can be found in the SEI repository

Last updated