XCM Oracle

What is Bifrost XCM Oracle?

In order to facilitate easy querying of Bifrost vToken Exchange Price on other chains at the Pallet and Contract levels, a scheduled price feed task sent by Bifrost SLPx Pallet is needed. Hence, Bifrost Runtime will automatically send XCM messages to the SLPx Contract of the target chain to update the Exchange Price of vTokens in the Contract.

Below link will help you quickly understand the relevant concepts:

- SLPx XCM Oracle Tech Doc

- How is vToken Exchange Price calculated and verified in the Bifrost parachain?

- What is SLPx?

- What is XCM?


How to verify that XCM Oracle uses XCM to synchronize messages to the target chain?

  1. The SLPx Pallet synchronizes the vToken Exchange Price on Bifrost and sends it to the target chain at regular intervals. Link to the code base

let configuration = XcmEthereumCallConfiguration::<T>::get();
				match configuration {
					Some(mut configuration) => {
						let currency_id = currency_list[0];
						let token_amount = T::VtokenMintingInterface::get_token_pool(currency_id);
						// It's impossible to go wrong.
						let vcurrency_id = T::VtokenMintingInterface::vtoken_id(currency_id)
							.expect("Error convert vcurrency_id");
						let vtoken_amount = T::MultiCurrency::total_issuance(vcurrency_id);

						if configuration.last_block + configuration.period < n {
							let encoded_call = Self::encode_transact_call(
								configuration.contract,
								currency_id,
								token_amount,
								vtoken_amount,
							);

							let result = Self::send_xcm_to_set_token_amount(
								encoded_call,
								configuration.xcm_weight,
								configuration.xcm_fee,
							);

							if result.is_err() {
								return weight
									.saturating_add(T::DbWeight::get().reads_writes(4, 0));
							}
							Self::deposit_event(Event::XcmSetTokenAmount {
								currency_id,
								token_amount,
								vcurrency_id,
								vtoken_amount,
							});
  1. Query messages sent by Bifrost XCM Oracle: Link to Bifrost Subscan. The capture below includes the total amount of DOT (Token2:0) and vDOT (vToken2:0) in Bifrost liquid staking. (Check other token index in the Library.)

  1. Query XCM Oracle transactions in XCM Message: Here is a case.

  1. View Bifrost Parachain Address (mapped by Moonbeam EVM) transactions synchronizing price information to the Oracle contract on Moonbeam or Moonriver: Link to Moonscan

  1. Query the latest price of vToken in the XCM Oracle contract on Moonbeam or Moonriver:

- Moonriver

- Moonbeam

For example, querying the price of vDOT by DOT with 10 decimals.

Last updated