Skip to content

Commit

Permalink
revert runtime oracle & collection-data-feed additions
Browse files Browse the repository at this point in the history
  • Loading branch information
lemunozm committed May 5, 2023
1 parent 44a7df1 commit a9438fe
Show file tree
Hide file tree
Showing 7 changed files with 3 additions and 222 deletions.
6 changes: 0 additions & 6 deletions Cargo.lock

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

5 changes: 0 additions & 5 deletions runtime/altair/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,6 @@ orml-traits = { git = "https://github.com/open-web3-stack/open-runtime-module-li
orml-xcm = { git = "https://github.com/open-web3-stack/open-runtime-module-library", default-features = false, branch = "polkadot-v0.9.37" }
orml-xcm-support = { git = "https://github.com/open-web3-stack/open-runtime-module-library", default-features = false, branch = "polkadot-v0.9.37" }
orml-xtokens = { git = "https://github.com/open-web3-stack/open-runtime-module-library", default-features = false, branch = "polkadot-v0.9.37" }
orml-oracle = { git = "https://github.com/open-web3-stack/open-runtime-module-library", default-features = false, branch = "polkadot-v0.9.37" }

# our custom pallets
cfg-primitives = { path = "../../libs/primitives", default-features = false }
Expand All @@ -105,7 +104,6 @@ pallet-permissions = { path = "../../pallets/permissions", default-features = fa
pallet-pool-registry = { path = "../../pallets/pool-registry", default-features = false }
pallet-pool-system = { path = "../../pallets/pool-system", default-features = false }
pallet-restricted-tokens = { path = "../../pallets/restricted-tokens", default-features = false }
pallet-collection-data-feed = { path = "../../pallets/collection-data-feed", default-features = false }
runtime-common = { path = "../common", default-features = false }

[build-dependencies]
Expand Down Expand Up @@ -134,7 +132,6 @@ std = [
"orml-xcm-support/std",
"orml-xcm/std",
"orml-xtokens/std",
"orml-oracle/std",
"pallet-anchors/std",
"pallet-aura/std",
"pallet-authorship/std",
Expand All @@ -157,7 +154,6 @@ std = [
"pallet-permissions/std",
"pallet-pool-system/std",
"pallet-pool-registry/std",
"pallet-collection-data-feed/std",
"pallet-preimage/std",
"pallet-proxy/std",
"pallet-randomness-collective-flip/std",
Expand Down Expand Up @@ -270,7 +266,6 @@ try-runtime = [
"orml-tokens/try-runtime",
"orml-xcm/try-runtime",
"orml-xtokens/try-runtime",
"orml-oracle/try-runtime",
"pallet-anchors/try-runtime",
"pallet-aura/try-runtime",
"pallet-authorship/try-runtime",
Expand Down
68 changes: 1 addition & 67 deletions runtime/altair/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@ use frame_system::{
limits::{BlockLength, BlockWeights},
EnsureRoot, EnsureSigned,
};
use orml_oracle::{CombineData, DataProviderExtended};
use orml_traits::{currency::MutationHooks, parameter_type_with_key};
use pallet_anchors::AnchorData;
pub use pallet_balances::Call as BalancesCall;
Expand Down Expand Up @@ -1100,69 +1099,6 @@ impl cumulus_pallet_dmp_queue::Config for Runtime {
parameter_types! {
pub const MaxActiveLoansPerPool: u32 = 300;
pub const MaxWriteOffPolicySize: u32 = 100;
pub const MaxHasDispatchedSize: u32 = 1;
pub const MaxPools: u32 = 50;
pub RootMember: AccountId = PalletId(*b"changeme").into_account_truncating(); //TODO
}

type OracleValue = orml_oracle::TimestampedValue<Rate, Moment>;

pub struct LastData;
impl CombineData<PriceId, OracleValue> for LastData {
fn combine_data(
_: &PriceId,
values: Vec<OracleValue>,
_: Option<OracleValue>,
) -> Option<OracleValue> {
values
.into_iter()
.max_by(|v1, v2| v1.timestamp.cmp(&v2.timestamp))
}
}

impl orml_oracle::Config for Runtime {
type CombineData = LastData;
type MaxHasDispatchedSize = MaxHasDispatchedSize;
//TODO
type Members = Elections;
type OnNewData = CollectionPriceFeed;
type OracleKey = PriceId;
type OracleValue = Rate;
type RootOperatorAccountId = RootMember;
type RuntimeEvent = RuntimeEvent;
type Time = Timestamp;
type WeightInfo = ();
}

// This part is forced because of https://github.com/open-web3-stack/open-runtime-module-library/issues/904
pub struct DataProviderBridge;
impl DataProviderExtended<PriceId, (Rate, Moment)> for DataProviderBridge {
fn get_no_op(key: &PriceId) -> Option<(Rate, Moment)> {
OrmlOracle::get_no_op(key).map(|OracleValue { value, timestamp }| (value, timestamp))
}

fn get_all_values() -> Vec<(PriceId, Option<(Rate, Moment)>)> {
OrmlOracle::get_all_values()
.into_iter()
.map(|elem| {
(
elem.0,
elem.1
.map(|OracleValue { value, timestamp }| (value, timestamp)),
)
})
.collect()
}
}

impl pallet_collection_data_feed::Config for Runtime {
type CollectionId = PoolId;
type Data = Rate;
type DataId = PriceId;
type DataProvider = DataProviderBridge;
type MaxCollectionSize = MaxActiveLoansPerPool;
type MaxCollections = MaxPools;
type Moment = Moment;
}

impl pallet_loans_ref::Config for Runtime {
Expand All @@ -1178,7 +1114,7 @@ impl pallet_loans_ref::Config for Runtime {
type Permissions = Permissions;
type Pool = PoolSystem;
type PriceId = PriceId;
type PriceRegistry = CollectionPriceFeed;
type PriceRegistry = pallet_loans_ref::config::NoPriceRegistry<Runtime>;
type Rate = Rate;
type RuntimeEvent = RuntimeEvent;
type Time = Timestamp;
Expand Down Expand Up @@ -1499,7 +1435,6 @@ construct_runtime!(
InterestAccrual: pallet_interest_accrual::{Pallet, Storage, Event<T>, Config<T>} = 101,
Investments: pallet_investments::{Pallet, Call, Storage, Event<T>} = 102,
PoolRegistry: pallet_pool_registry::{Pallet, Call, Storage, Event<T>} = 103,
CollectionPriceFeed: pallet_collection_data_feed::{Pallet, Storage} = 104,

// XCM
XcmpQueue: cumulus_pallet_xcmp_queue::{Pallet, Call, Storage, Event<T>} = 120,
Expand All @@ -1512,7 +1447,6 @@ construct_runtime!(
OrmlTokens: orml_tokens::{Pallet, Storage, Event<T>, Config<T>} = 150,
OrmlAssetRegistry: orml_asset_registry::{Pallet, Storage, Call, Event<T>, Config<T>} = 151,
OrmlXcm: orml_xcm::{Pallet, Storage, Call, Event<T>} = 152,
OrmlOracle: orml_oracle::{Pallet, Storage, Call, Event<T>} = 153,

// migration pallet
Migration: pallet_migration_manager::{Pallet, Call, Storage, Event<T>} = 199,
Expand Down
5 changes: 0 additions & 5 deletions runtime/centrifuge/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,6 @@ orml-traits = { git = "https://github.com/open-web3-stack/open-runtime-module-li
orml-xcm = { git = "https://github.com/open-web3-stack/open-runtime-module-library", default-features = false, branch = "polkadot-v0.9.37" }
orml-xcm-support = { git = "https://github.com/open-web3-stack/open-runtime-module-library", default-features = false, branch = "polkadot-v0.9.37" }
orml-xtokens = { git = "https://github.com/open-web3-stack/open-runtime-module-library", default-features = false, branch = "polkadot-v0.9.37" }
orml-oracle = { git = "https://github.com/open-web3-stack/open-runtime-module-library", default-features = false, branch = "polkadot-v0.9.37" }

# Our pallets and modules
cfg-primitives = { path = "../../libs/primitives", default-features = false }
Expand All @@ -109,7 +108,6 @@ pallet-permissions = { path = "../../pallets/permissions", default-features = fa
pallet-pool-registry = { path = "../../pallets/pool-registry", default-features = false }
pallet-pool-system = { path = "../../pallets/pool-system", default-features = false }
pallet-restricted-tokens = { path = "../../pallets/restricted-tokens", default-features = false }
pallet-collection-data-feed = { path = "../../pallets/collection-data-feed", default-features = false }
runtime-common = { path = "../common", default-features = false }

# bridge pallets
Expand Down Expand Up @@ -147,7 +145,6 @@ std = [
"orml-xcm-support/std",
"orml-xcm/std",
"orml-xtokens/std",
"orml-oracle/std",
"pallet-anchors/std",
"pallet-aura/std",
"pallet-authorship/std",
Expand All @@ -173,7 +170,6 @@ std = [
"pallet-permissions/std",
"pallet-pool-registry/std",
"pallet-pool-system/std",
"pallet-collection-data-feed/std",
"pallet-preimage/std",
"pallet-proxy/std",
"pallet-randomness-collective-flip/std",
Expand Down Expand Up @@ -284,7 +280,6 @@ try-runtime = [
"orml-tokens/try-runtime",
"orml-xcm/try-runtime",
"orml-xtokens/try-runtime",
"orml-oracle/try-runtime",
"pallet-anchors/try-runtime",
"pallet-aura/try-runtime",
"pallet-authorship/try-runtime",
Expand Down
68 changes: 1 addition & 67 deletions runtime/centrifuge/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@ use frame_system::{
limits::{BlockLength, BlockWeights},
EnsureRoot, EnsureSigned,
};
use orml_oracle::{CombineData, DataProviderExtended};
use orml_traits::{currency::MutationHooks, parameter_type_with_key};
use pallet_anchors::AnchorData;
pub use pallet_balances::Call as BalancesCall;
Expand Down Expand Up @@ -1479,69 +1478,6 @@ impl pallet_interest_accrual::Config for Runtime {
parameter_types! {
pub const MaxActiveLoansPerPool: u32 = 1000;
pub const MaxWriteOffPolicySize: u32 = 100;
pub const MaxHasDispatchedSize: u32 = 1;
pub const MaxPools: u32 = 50;
pub RootMember: AccountId = PalletId(*b"changeme").into_account_truncating(); //TODO
}

type OracleValue = orml_oracle::TimestampedValue<Rate, Moment>;

pub struct LastData;
impl CombineData<PriceId, OracleValue> for LastData {
fn combine_data(
_: &PriceId,
values: Vec<OracleValue>,
_: Option<OracleValue>,
) -> Option<OracleValue> {
values
.into_iter()
.max_by(|v1, v2| v1.timestamp.cmp(&v2.timestamp))
}
}

impl orml_oracle::Config for Runtime {
type CombineData = LastData;
type MaxHasDispatchedSize = MaxHasDispatchedSize;
//TODO
type Members = Elections;
type OnNewData = CollectionPriceFeed;
type OracleKey = PriceId;
type OracleValue = Rate;
type RootOperatorAccountId = RootMember;
type RuntimeEvent = RuntimeEvent;
type Time = Timestamp;
type WeightInfo = ();
}

// This part is forced because of https://github.com/open-web3-stack/open-runtime-module-library/issues/904
pub struct DataProviderBridge;
impl DataProviderExtended<PriceId, (Rate, Moment)> for DataProviderBridge {
fn get_no_op(key: &PriceId) -> Option<(Rate, Moment)> {
OrmlOracle::get_no_op(key).map(|OracleValue { value, timestamp }| (value, timestamp))
}

fn get_all_values() -> Vec<(PriceId, Option<(Rate, Moment)>)> {
OrmlOracle::get_all_values()
.into_iter()
.map(|elem| {
(
elem.0,
elem.1
.map(|OracleValue { value, timestamp }| (value, timestamp)),
)
})
.collect()
}
}

impl pallet_collection_data_feed::Config for Runtime {
type CollectionId = PoolId;
type Data = Rate;
type DataId = PriceId;
type DataProvider = DataProviderBridge;
type MaxCollectionSize = MaxActiveLoansPerPool;
type MaxCollections = MaxPools;
type Moment = Moment;
}

impl pallet_loans_ref::Config for Runtime {
Expand All @@ -1557,7 +1493,7 @@ impl pallet_loans_ref::Config for Runtime {
type Permissions = Permissions;
type Pool = PoolSystem;
type PriceId = PriceId;
type PriceRegistry = CollectionPriceFeed;
type PriceRegistry = pallet_loans_ref::config::NoPriceRegistry<Runtime>;
type Rate = Rate;
type RuntimeEvent = RuntimeEvent;
type Time = Timestamp;
Expand Down Expand Up @@ -1681,7 +1617,6 @@ construct_runtime!(
OrmlTokens: orml_tokens::{Pallet, Storage, Event<T>, Config<T>} = 151,
OrmlAssetRegistry: orml_asset_registry::{Pallet, Storage, Call, Event<T>, Config<T>} = 152,
OrmlXcm: orml_xcm::{Pallet, Storage, Call, Event<T>} = 153,
OrmlOracle: orml_oracle::{Pallet, Storage, Call, Event<T>} = 154,

// Synced pallets across all runtimes - Range: 180-240
// WHY: * integrations like fireblocks will need to know the index in the enum
Expand All @@ -1695,7 +1630,6 @@ construct_runtime!(
Uniques: pallet_uniques::{Pallet, Call, Storage, Event<T>} = 185,
Keystore: pallet_keystore::{Pallet, Call, Storage, Event<T>} = 186,
Loans: pallet_loans_ref::{Pallet, Call, Storage, Event<T>} = 187,
CollectionPriceFeed: pallet_collection_data_feed::{Pallet, Storage} = 188,
}
);

Expand Down
5 changes: 0 additions & 5 deletions runtime/development/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,6 @@ orml-traits = { git = "https://github.com/open-web3-stack/open-runtime-module-li
orml-xcm = { git = "https://github.com/open-web3-stack/open-runtime-module-library", default-features = false, branch = "polkadot-v0.9.37" }
orml-xcm-support = { git = "https://github.com/open-web3-stack/open-runtime-module-library", default-features = false, branch = "polkadot-v0.9.37" }
orml-xtokens = { git = "https://github.com/open-web3-stack/open-runtime-module-library", default-features = false, branch = "polkadot-v0.9.37" }
orml-oracle = { git = "https://github.com/open-web3-stack/open-runtime-module-library", default-features = false, branch = "polkadot-v0.9.37" }

# frontier pallets
fp-rpc = { git = "https://github.com/PureStake/frontier", default-features = false, branch = "moonbeam-polkadot-v0.9.37" }
Expand Down Expand Up @@ -131,7 +130,6 @@ pallet-pool-registry = { path = "../../pallets/pool-registry", default-features
pallet-pool-system = { path = "../../pallets/pool-system", default-features = false }
pallet-restricted-tokens = { path = "../../pallets/restricted-tokens", default-features = false }
pallet-rewards = { path = "../../pallets/rewards", default-features = false }
pallet-collection-data-feed = { path = "../../pallets/collection-data-feed", default-features = false }

# Connectors 3rd-party dependencies
moonbeam-relay-encoder = { git = "https://github.com/PureStake/moonbeam", default-features = false, rev = "4c22f7c010573513076b618c09d2824ece6c51eb" }
Expand Down Expand Up @@ -166,7 +164,6 @@ std = [
"orml-asset-registry/std",
"orml-tokens/std",
"orml-xtokens/std",
"orml-oracle/std",
"pallet-anchors/std",
"pallet-aura/std",
"pallet-authorship/std",
Expand Down Expand Up @@ -205,7 +202,6 @@ std = [
"pallet-randomness-collective-flip/std",
"pallet-restricted-tokens/std",
"pallet-rewards/std",
"pallet-collection-data-feed/std",
"pallet-scheduler/std",
"pallet-session/std",
"pallet-sudo/std",
Expand Down Expand Up @@ -347,7 +343,6 @@ try-runtime = [
"orml-tokens/try-runtime",
"orml-xcm/try-runtime",
"orml-xtokens/try-runtime",
"orml-oracle/try-runtime",
"pallet-anchors/try-runtime",
"pallet-aura/try-runtime",
"pallet-authorship/try-runtime",
Expand Down

0 comments on commit a9438fe

Please sign in to comment.