Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Optimize oracle #1318

Merged
merged 3 commits into from
Jul 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion pallets/prices/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ use bifrost_primitives::*;
use frame_support::{dispatch::DispatchClass, pallet_prelude::*, transactional};
use frame_system::pallet_prelude::*;
use log;
use orml_traits::{DataFeeder, DataProvider, DataProviderExtended};
use orml_oracle::{DataFeeder, DataProvider, DataProviderExtended};
pub use pallet::*;
use pallet_traits::*;
use sp_runtime::{traits::CheckedDiv, FixedU128};
Expand Down
15 changes: 12 additions & 3 deletions runtime/bifrost-kusama/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ use sp_runtime::{
AccountIdConversion, AccountIdLookup, BlakeTwo256, Block as BlockT, StaticLookup, Zero,
},
transaction_validity::{TransactionSource, TransactionValidity},
ApplyExtrinsicResult, DispatchError, DispatchResult, Perbill, Permill, RuntimeDebug,
ApplyExtrinsicResult, DispatchError, DispatchResult, FixedU128, Perbill, Permill, RuntimeDebug,
SaturatedConversion,
};
use sp_std::{marker::PhantomData, prelude::*};
Expand Down Expand Up @@ -1608,14 +1608,22 @@ parameter_types! {
pub const ExpiresIn: Moment = 1000 * 60 * 60; // 60 mins
pub const MaxHasDispatchedSize: u32 = 100;
pub OracleRootOperatorAccountId: AccountId = OraclePalletId::get().into_account_truncating();
pub const MinimumTimestampInterval: Moment = 1000 * 60 * 10; // 10 mins
pub const MaximumValueInterval: Price = FixedU128::from_inner(3_000_000_000_000_000); // 0.3%
}

type BifrostDataProvider = orml_oracle::Instance1;
impl orml_oracle::Config<BifrostDataProvider> for Runtime {
type RuntimeEvent = RuntimeEvent;
type OnNewData = ();
type CombineData =
orml_oracle::DefaultCombineData<Runtime, MinimumCount, ExpiresIn, BifrostDataProvider>;
type CombineData = orml_oracle::DefaultCombineData<
Runtime,
MinimumCount,
ExpiresIn,
MinimumTimestampInterval,
MaximumValueInterval,
BifrostDataProvider,
>;
type Time = Timestamp;
type OracleKey = CurrencyId;
type OracleValue = Price;
Expand All @@ -1624,6 +1632,7 @@ impl orml_oracle::Config<BifrostDataProvider> for Runtime {
type WeightInfo = weights::orml_oracle::WeightInfo<Runtime>;
type Members = OracleMembership;
type MaxFeedValues = ConstU32<100>;
type ControlOrigin = TechAdminOrCouncil;
}

pub type TimeStampedPrice = orml_oracle::TimestampedValue<Price, Moment>;
Expand Down
15 changes: 12 additions & 3 deletions runtime/bifrost-polkadot/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ use sp_runtime::{
create_runtime_str, generic, impl_opaque_keys,
traits::{AccountIdConversion, BlakeTwo256, Block as BlockT, Zero},
transaction_validity::{TransactionSource, TransactionValidity},
ApplyExtrinsicResult, DispatchError, DispatchResult, Perbill, Permill, RuntimeDebug,
ApplyExtrinsicResult, DispatchError, DispatchResult, FixedU128, Perbill, Permill, RuntimeDebug,
};
use sp_std::{marker::PhantomData, prelude::*};
#[cfg(feature = "std")]
Expand Down Expand Up @@ -1424,14 +1424,22 @@ parameter_types! {
pub const ExpiresIn: Moment = 1000 * 60 * 60; // 60 mins
pub const MaxHasDispatchedSize: u32 = 100;
pub OracleRootOperatorAccountId: AccountId = OraclePalletId::get().into_account_truncating();
pub const MinimumTimestampInterval: Moment = 1000 * 60 * 10; // 10 mins
pub const MaximumValueInterval: Price = FixedU128::from_inner(3_000_000_000_000_000); // 0.3%
}

type BifrostDataProvider = orml_oracle::Instance1;
impl orml_oracle::Config<BifrostDataProvider> for Runtime {
type RuntimeEvent = RuntimeEvent;
type OnNewData = ();
type CombineData =
orml_oracle::DefaultCombineData<Runtime, MinimumCount, ExpiresIn, BifrostDataProvider>;
type CombineData = orml_oracle::DefaultCombineData<
Runtime,
MinimumCount,
ExpiresIn,
MinimumTimestampInterval,
MaximumValueInterval,
BifrostDataProvider,
>;
type Time = Timestamp;
type OracleKey = CurrencyId;
type OracleValue = Price;
Expand All @@ -1440,6 +1448,7 @@ impl orml_oracle::Config<BifrostDataProvider> for Runtime {
type WeightInfo = weights::orml_oracle::WeightInfo<Runtime>;
type Members = OracleMembership;
type MaxFeedValues = ConstU32<100>;
type ControlOrigin = TechAdminOrCouncil;
}

pub type TimeStampedPrice = orml_oracle::TimestampedValue<Price, Moment>;
Expand Down