From 1657820794e570f2d339904d56ddb3b1b6c7212e Mon Sep 17 00:00:00 2001 From: yooml Date: Fri, 15 Sep 2023 15:31:10 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=F0=9F=8E=B8=20rm=20lend-market=20from?= =?UTF-8?q?=20runtime?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Cargo.lock | 8 -- node/rpc/src/lib.rs | 6 +- node/service/src/chain_spec/bifrost_kusama.rs | 24 +--- .../src/chain_spec/bifrost_polkadot.rs | 15 +-- runtime/bifrost-kusama/Cargo.toml | 12 -- runtime/bifrost-kusama/src/lib.rs | 107 ------------------ runtime/bifrost-kusama/src/weights/mod.rs | 1 - .../bifrost-kusama/src/weights/orml_oracle.rs | 45 -------- runtime/bifrost-polkadot/Cargo.toml | 12 -- runtime/bifrost-polkadot/src/lib.rs | 106 ----------------- runtime/bifrost-polkadot/src/weights/mod.rs | 1 - .../src/weights/orml_oracle.rs | 45 -------- 12 files changed, 6 insertions(+), 376 deletions(-) delete mode 100644 runtime/bifrost-kusama/src/weights/orml_oracle.rs delete mode 100644 runtime/bifrost-polkadot/src/weights/orml_oracle.rs diff --git a/Cargo.lock b/Cargo.lock index ba6e5a7be6..d5a3e04548 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -904,13 +904,10 @@ dependencies = [ "frame-system-rpc-runtime-api", "frame-try-runtime", "hex-literal 0.3.4", - "lend-market", - "lend-market-rpc-runtime-api", "log", "merkle-distributor", "node-primitives", "nutsfinance-stable-asset", - "orml-oracle", "orml-tokens", "orml-traits", "orml-unknown-tokens", @@ -931,7 +928,6 @@ dependencies = [ "pallet-membership", "pallet-multisig", "pallet-preimage", - "pallet-prices", "pallet-proxy", "pallet-ranked-collective", "pallet-referenda", @@ -1087,13 +1083,10 @@ dependencies = [ "frame-system-rpc-runtime-api", "frame-try-runtime", "hex-literal 0.3.4", - "lend-market", - "lend-market-rpc-runtime-api", "log", "merkle-distributor", "node-primitives", "nutsfinance-stable-asset", - "orml-oracle", "orml-tokens", "orml-traits", "orml-unknown-tokens", @@ -1114,7 +1107,6 @@ dependencies = [ "pallet-membership", "pallet-multisig", "pallet-preimage", - "pallet-prices", "pallet-proxy", "pallet-ranked-collective", "pallet-referenda", diff --git a/node/rpc/src/lib.rs b/node/rpc/src/lib.rs index 851a3e160f..6ad002e816 100644 --- a/node/rpc/src/lib.rs +++ b/node/rpc/src/lib.rs @@ -43,8 +43,6 @@ use bifrost_stable_pool_rpc_api::{StablePoolRpc, StablePoolRpcApiServer}; use bifrost_stable_pool_rpc_runtime_api::StablePoolRuntimeApi; use bifrost_ve_minting_rpc_api::{VeMintingRpc, VeMintingRpcApiServer}; use bifrost_ve_minting_rpc_runtime_api::VeMintingRuntimeApi; -use lend_market_rpc::{LendMarket, LendMarketApiServer}; -use lend_market_rpc_runtime_api::LendMarketApi; use node_primitives::{AccountId, Balance, Block, CurrencyId, Nonce, ParaId, PoolId}; use pallet_transaction_payment_rpc::{TransactionPayment, TransactionPaymentApiServer}; use sc_rpc_api::DenyUnsafe; @@ -88,7 +86,6 @@ where C::Api: FeeRuntimeApi, C::Api: SalpRuntimeApi, C::Api: StablePoolRuntimeApi, - C::Api: LendMarketApi, C::Api: ZenlinkProtocolRuntimeApi, C::Api: zenlink_stable_amm_runtime_api::StableAmmApi, @@ -106,8 +103,7 @@ where module.merge(SalpRpc::new(client.clone()).into_rpc())?; module.merge(ZenlinkProtocol::new(client.clone()).into_rpc())?; module.merge(StableAmm::new(client.clone()).into_rpc())?; - module.merge(StablePoolRpc::new(client.clone()).into_rpc())?; - module.merge(LendMarket::new(client.clone()).into_rpc())?; + module.merge(StablePoolRpc::new(client).into_rpc())?; Ok(module) } diff --git a/node/service/src/chain_spec/bifrost_kusama.rs b/node/service/src/chain_spec/bifrost_kusama.rs index bde462d310..1c93e54983 100644 --- a/node/service/src/chain_spec/bifrost_kusama.rs +++ b/node/service/src/chain_spec/bifrost_kusama.rs @@ -24,10 +24,9 @@ use std::{ use bifrost_kusama_runtime::{ constants::currency::DOLLARS, AccountId, AssetRegistryConfig, Balance, BalancesConfig, BlockNumber, CouncilConfig, CouncilMembershipConfig, DefaultBlocksPerRound, DemocracyConfig, - GenesisConfig, IndicesConfig, InflationInfo, OracleMembershipConfig, ParachainInfoConfig, - ParachainStakingConfig, PolkadotXcmConfig, Range, SS58Prefix, SalpConfig, SessionConfig, - SystemConfig, TechnicalCommitteeConfig, TechnicalMembershipConfig, TokensConfig, VestingConfig, - WASM_BINARY, + GenesisConfig, IndicesConfig, InflationInfo, ParachainInfoConfig, ParachainStakingConfig, + PolkadotXcmConfig, Range, SS58Prefix, SalpConfig, SessionConfig, SystemConfig, + TechnicalCommitteeConfig, TechnicalMembershipConfig, TokensConfig, VestingConfig, WASM_BINARY, }; use bifrost_runtime_common::AuraId; use cumulus_primitives_core::ParaId; @@ -129,7 +128,6 @@ pub fn bifrost_genesis( Vec, Vec<(CurrencyId, u32, u32, u32)>, ), - oracle_membership: Vec, ) -> GenesisConfig { GenesisConfig { system: SystemConfig { @@ -146,10 +144,6 @@ pub fn bifrost_genesis( members: technical_committee_membership.try_into().expect("convert error!"), phantom: Default::default(), }, - oracle_membership: OracleMembershipConfig { - members: oracle_membership.try_into().expect("convert error!"), - phantom: Default::default(), - }, council: CouncilConfig { members: vec![], phantom: Default::default() }, technical_committee: TechnicalCommitteeConfig { members: vec![], @@ -222,7 +216,6 @@ fn development_config_genesis(id: ParaId) -> GenesisConfig { let council_membership = vec![get_account_id_from_seed::("Alice")]; let technical_committee_membership = vec![get_account_id_from_seed::("Alice")]; - let oracle_membership = vec![get_account_id_from_seed::("Alice")]; let salp_multisig: AccountId = hex!["49daa32c7287890f38b7e1a8cd2961723d36d20baa0bf3b82e0c4bdda93b1c0a"].into(); @@ -242,7 +235,6 @@ fn development_config_genesis(id: ParaId) -> GenesisConfig { technical_committee_membership, salp_multisig, (vec![], vec![], vec![]), - oracle_membership, ) } @@ -312,7 +304,6 @@ fn local_config_genesis(id: ParaId) -> GenesisConfig { let council_membership = vec![get_account_id_from_seed::("Alice")]; let technical_committee_membership = vec![get_account_id_from_seed::("Alice")]; - let oracle_membership = vec![get_account_id_from_seed::("Alice")]; let salp_multisig: AccountId = hex!["49daa32c7287890f38b7e1a8cd2961723d36d20baa0bf3b82e0c4bdda93b1c0a"].into(); @@ -379,7 +370,6 @@ fn local_config_genesis(id: ParaId) -> GenesisConfig { technical_committee_membership, salp_multisig, (currency, vcurrency, vsbond), - oracle_membership, ) } @@ -455,10 +445,6 @@ fn rococo_testnet_config_genesis(id: ParaId) -> GenesisConfig { // dDWnEWnx3GUgfugXh9mZtgj4CvJdmd8naYkWYCZGxjfb1Cz hex!["420398e0150cd9d417fb8fd4027b75bd42717262e6eac97c55f2f8f84e8ffb3f"].into(), ]; - let oracle_membership = vec![ - // dDWnEWnx3GUgfugXh9mZtgj4CvJdmd8naYkWYCZGxjfb1Cz - hex!["420398e0150cd9d417fb8fd4027b75bd42717262e6eac97c55f2f8f84e8ffb3f"].into(), - ]; bifrost_genesis( invulnerables, @@ -478,7 +464,6 @@ fn rococo_testnet_config_genesis(id: ParaId) -> GenesisConfig { vec![], vec![], ), - oracle_membership, ) } @@ -518,7 +503,6 @@ fn rococo_local_config_genesis(id: ParaId) -> GenesisConfig { let council_membership = vec![get_account_id_from_seed::("Alice")]; let technical_committee_membership = vec![get_account_id_from_seed::("Alice")]; - let oracle_membership = vec![get_account_id_from_seed::("Alice")]; bifrost_genesis( vec![ @@ -542,7 +526,6 @@ fn rococo_local_config_genesis(id: ParaId) -> GenesisConfig { technical_committee_membership, salp_multisig, (vec![(Token(DOT), 100_000_000, None), (Token(KSM), 10_000_000, None)], vec![], vec![]), - oracle_membership, ) } @@ -659,7 +642,6 @@ fn bifrost_config_genesis(id: ParaId) -> GenesisConfig { vec![], // technical committee membership salp_multisig, (vec![], vec![], vec![]), - vec![], ) } diff --git a/node/service/src/chain_spec/bifrost_polkadot.rs b/node/service/src/chain_spec/bifrost_polkadot.rs index c53d9df4f8..b624a1406e 100644 --- a/node/service/src/chain_spec/bifrost_polkadot.rs +++ b/node/service/src/chain_spec/bifrost_polkadot.rs @@ -19,9 +19,8 @@ use bifrost_polkadot_runtime::{ constants::currency::DOLLARS, AccountId, AssetRegistryConfig, Balance, BalancesConfig, BlockNumber, CollatorSelectionConfig, CouncilMembershipConfig, GenesisConfig, IndicesConfig, - OracleMembershipConfig, ParachainInfoConfig, PolkadotXcmConfig, SS58Prefix, SalpConfig, - SessionConfig, SystemConfig, TechnicalMembershipConfig, TokensConfig, VestingConfig, - WASM_BINARY, + ParachainInfoConfig, PolkadotXcmConfig, SS58Prefix, SalpConfig, SessionConfig, SystemConfig, + TechnicalMembershipConfig, TokensConfig, VestingConfig, WASM_BINARY, }; use bifrost_runtime_common::AuraId; use cumulus_primitives_core::ParaId; @@ -84,7 +83,6 @@ pub fn bifrost_polkadot_genesis( Vec, Vec<(CurrencyId, u32, u32, u32)>, ), - oracle_membership: Vec, ) -> GenesisConfig { GenesisConfig { system: SystemConfig { @@ -101,10 +99,6 @@ pub fn bifrost_polkadot_genesis( members: technical_committee_membership.try_into().expect("convert error!"), phantom: Default::default(), }, - oracle_membership: OracleMembershipConfig { - members: oracle_membership.try_into().expect("convert error!"), - phantom: Default::default(), - }, council: Default::default(), technical_committee: Default::default(), treasury: Default::default(), @@ -162,7 +156,6 @@ fn development_config_genesis(id: ParaId) -> GenesisConfig { let council_membership = vec![get_account_id_from_seed::("Alice")]; let technical_committee_membership = vec![get_account_id_from_seed::("Alice")]; - let oracle_membership = vec![get_account_id_from_seed::("Alice")]; let salp_multisig: AccountId = hex!["49daa32c7287890f38b7e1a8cd2961723d36d20baa0bf3b82e0c4bdda93b1c0a"].into(); @@ -179,7 +172,6 @@ fn development_config_genesis(id: ParaId) -> GenesisConfig { technical_committee_membership, salp_multisig, (vec![], vec![], vec![]), - oracle_membership, ) } @@ -227,7 +219,6 @@ fn local_config_genesis(id: ParaId) -> GenesisConfig { .collect(); let council_membership = vec![get_account_id_from_seed::("Alice")]; let technical_committee_membership = vec![get_account_id_from_seed::("Alice")]; - let oracle_membership = vec![get_account_id_from_seed::("Alice")]; let salp_multisig: AccountId = hex!["49daa32c7287890f38b7e1a8cd2961723d36d20baa0bf3b82e0c4bdda93b1c0a"].into(); let currency = vec![ @@ -256,7 +247,6 @@ fn local_config_genesis(id: ParaId) -> GenesisConfig { technical_committee_membership, salp_multisig, (currency, vcurrency, vec![]), - oracle_membership, ) } @@ -331,6 +321,5 @@ fn bifrost_polkadot_config_genesis(id: ParaId) -> GenesisConfig { vec![], salp_multisig, (vec![], vec![], vec![]), - vec![], ) } diff --git a/runtime/bifrost-kusama/Cargo.toml b/runtime/bifrost-kusama/Cargo.toml index f239ad897d..e548352637 100644 --- a/runtime/bifrost-kusama/Cargo.toml +++ b/runtime/bifrost-kusama/Cargo.toml @@ -119,9 +119,6 @@ bifrost-slpx = { path = "../../pallets/slpx", default-features = false } bifrost-stable-pool = { path = "../../pallets/stable-pool", default-features = false } bifrost-stable-pool-rpc-runtime-api = { path = "../../pallets/stable-pool/rpc/runtime-api", default-features = false } bifrost-currencies = { workspace = true } -lend-market = { path = "../../pallets/lend-market", default-features = false } -lend-market-rpc-runtime-api = { path = "../../pallets/lend-market/rpc/runtime-api", default-features = false } -pallet-prices = { path = "../../pallets/prices", default-features = false } bifrost-vtoken-voting = { path = "../../pallets/vtoken-voting", default-features = false, features = [ "kusama" ] } # orml @@ -131,7 +128,6 @@ orml-xtokens = { version = "0.4.1-dev", default-features = false } orml-unknown-tokens = { version = "0.4.1-dev", default-features = false } orml-xcm = { version = "0.4.1-dev", default-features = false } orml-xcm-support = { version = "0.4.1-dev", default-features = false } -orml-oracle = { version = "0.4.1-dev", default-features = false } merkle-distributor = { version = "*", default-features = false } zenlink-protocol = { version = "*", default-features = false } @@ -214,7 +210,6 @@ std = [ "orml-unknown-tokens/std", "orml-xcm/std", "orml-xcm-support/std", - "orml-oracle/std", "nutsfinance-stable-asset/std", "bifrost-runtime-common/std", "bifrost-farming/std", @@ -236,9 +231,6 @@ std = [ "bifrost-slpx/std", "bifrost-stable-pool/std", "bifrost-stable-pool-rpc-runtime-api/std", - "lend-market/std", - "lend-market-rpc-runtime-api/std", - "pallet-prices/std", "bifrost-vtoken-voting/std", "zenlink-protocol/std", "zenlink-protocol-runtime-api/std", @@ -293,7 +285,6 @@ runtime-benchmarks = [ "bifrost-slpx/runtime-benchmarks", "bifrost-stable-pool/runtime-benchmarks", "bifrost-vtoken-voting/runtime-benchmarks", - "lend-market/runtime-benchmarks", ] try-runtime = [ @@ -339,7 +330,6 @@ try-runtime = [ "bifrost-currencies/try-runtime", "orml-unknown-tokens/try-runtime", "orml-xcm/try-runtime", - "orml-oracle/try-runtime", "zenlink-protocol/try-runtime", "merkle-distributor/try-runtime", "zenlink-stable-amm/try-runtime", @@ -362,8 +352,6 @@ try-runtime = [ "bifrost-slpx/try-runtime", "nutsfinance-stable-asset/try-runtime", "bifrost-stable-pool/try-runtime", - "lend-market/try-runtime", - "pallet-prices/try-runtime", "bifrost-vtoken-voting/try-runtime", ] diff --git a/runtime/bifrost-kusama/src/lib.rs b/runtime/bifrost-kusama/src/lib.rs index c2c6213416..01b341f47a 100644 --- a/runtime/bifrost-kusama/src/lib.rs +++ b/runtime/bifrost-kusama/src/lib.rs @@ -97,7 +97,6 @@ pub use node_primitives::{ DistributionId, ExtraFeeInfo, ExtraFeeName, Liquidity, Moment, Nonce, ParaId, PoolId, Price, Rate, Ratio, RpcContributionStatus, Shortfall, TimeUnit, TokenSymbol, }; -use orml_oracle::{DataFeeder, DataProvider, DataProviderExtended}; // zenlink imports use zenlink_protocol::{ @@ -1689,93 +1688,6 @@ impl bifrost_stable_pool::Config for Runtime { type CurrencyIdRegister = AssetIdMaps; } -parameter_types! { - pub const MinimumCount: u32 = 3; - pub const ExpiresIn: Moment = 1000 * 60 * 60; // 60 mins - pub const MaxHasDispatchedSize: u32 = 100; - pub OracleRootOperatorAccountId: AccountId = OraclePalletId::get().into_account_truncating(); -} - -type BifrostDataProvider = orml_oracle::Instance1; -impl orml_oracle::Config for Runtime { - type RuntimeEvent = RuntimeEvent; - type OnNewData = (); - type CombineData = - orml_oracle::DefaultCombineData; - type Time = Timestamp; - type OracleKey = CurrencyId; - type OracleValue = Price; - type RootOperatorAccountId = OracleRootOperatorAccountId; - type MaxHasDispatchedSize = MaxHasDispatchedSize; - type WeightInfo = weights::orml_oracle::WeightInfo; - type Members = OracleMembership; -} - -pub type TimeStampedPrice = orml_oracle::TimestampedValue; -pub struct AggregatedDataProvider; -impl DataProvider for AggregatedDataProvider { - fn get(key: &CurrencyId) -> Option { - Oracle::get(key) - } -} - -impl DataProviderExtended for AggregatedDataProvider { - fn get_no_op(key: &CurrencyId) -> Option { - Oracle::get_no_op(key) - } - - fn get_all_values() -> Vec<(CurrencyId, Option)> { - Oracle::get_all_values() - } -} - -impl DataFeeder for AggregatedDataProvider { - fn feed_value(_: AccountId, _: CurrencyId, _: TimeStampedPrice) -> DispatchResult { - Err("Not supported".into()) - } -} - -impl pallet_prices::Config for Runtime { - type RuntimeEvent = RuntimeEvent; - type Source = AggregatedDataProvider; - type FeederOrigin = EitherOfDiverse; - type UpdateOrigin = EitherOfDiverse; - type RelayCurrency = RelayCurrencyId; - type CurrencyIdConvert = AssetIdMaps; - type Assets = Currencies; - type WeightInfo = pallet_prices::weights::SubstrateWeight; -} - -impl lend_market::Config for Runtime { - type RuntimeEvent = RuntimeEvent; - type PalletId = LendMarketPalletId; - type PriceFeeder = Prices; - type ReserveOrigin = EitherOfDiverse; - type UpdateOrigin = EitherOfDiverse; - type WeightInfo = lend_market::weights::BifrostWeight; - type UnixTime = Timestamp; - type Assets = Currencies; - type RewardAssetId = NativeCurrencyId; - type LiquidationFreeAssetId = RelayCurrencyId; -} - -parameter_types! { - pub const OracleMaxMembers: u32 = 100; -} - -impl pallet_membership::Config for Runtime { - type AddOrigin = MoreThanHalfCouncil; - type RuntimeEvent = RuntimeEvent; - type MaxMembers = OracleMaxMembers; - type MembershipInitialized = (); - type MembershipChanged = (); - type PrimeOrigin = MoreThanHalfCouncil; - type RemoveOrigin = MoreThanHalfCouncil; - type ResetOrigin = MoreThanHalfCouncil; - type SwapOrigin = MoreThanHalfCouncil; - type WeightInfo = pallet_membership::weights::SubstrateWeight; -} - // Below is the implementation of tokens manipulation functions other than native token. pub struct LocalAssetAdaptor(PhantomData); @@ -1961,10 +1873,6 @@ construct_runtime! { StableAsset: nutsfinance_stable_asset::{Pallet, Storage, Event} = 128, StablePool: bifrost_stable_pool::{Pallet, Call, Storage} = 129, VtokenVoting: bifrost_vtoken_voting::{Pallet, Call, Storage, Event} = 130, - LendMarket: lend_market::{Pallet, Call, Storage, Event} = 131, - Prices: pallet_prices::{Pallet, Call, Storage, Event} = 132, - Oracle: orml_oracle::::{Pallet, Storage, Call, Event} = 133, - OracleMembership: pallet_membership::::{Pallet, Call, Storage, Event, Config} = 134, } } @@ -2096,7 +2004,6 @@ mod benches { [bifrost_vstoken_conversion, VstokenConversion] [bifrost_vtoken_minting, VtokenMinting] [bifrost_vtoken_voting, VtokenVoting] - [lend_market, LendMarket] ); } @@ -2391,20 +2298,6 @@ impl_runtime_apis! { } } - impl lend_market_rpc_runtime_api::LendMarketApi for Runtime { - fn get_account_liquidity(account: AccountId) -> Result<(Liquidity, Shortfall, Liquidity, Shortfall), DispatchError> { - LendMarket::get_account_liquidity(&account) - } - - fn get_market_status(asset_id: CurrencyId) -> Result<(Rate, Rate, Rate, Ratio, Balance, Balance, sp_runtime::FixedU128), DispatchError> { - LendMarket::get_market_status(asset_id) - } - - fn get_liquidation_threshold_liquidity(account: AccountId) -> Result<(Liquidity, Shortfall, Liquidity, Shortfall), DispatchError> { - LendMarket::get_account_liquidation_threshold_liquidity(&account) - } - } - #[cfg(feature = "runtime-benchmarks")] impl frame_benchmarking::Benchmark for Runtime { fn benchmark_metadata(extra: bool) -> ( diff --git a/runtime/bifrost-kusama/src/weights/mod.rs b/runtime/bifrost-kusama/src/weights/mod.rs index 73b98d1d66..af2596d470 100644 --- a/runtime/bifrost-kusama/src/weights/mod.rs +++ b/runtime/bifrost-kusama/src/weights/mod.rs @@ -38,6 +38,5 @@ pub mod bifrost_vsbond_auction; pub mod bifrost_vstoken_conversion; pub mod bifrost_vtoken_minting; pub mod bifrost_vtoken_voting; -pub mod orml_oracle; pub mod orml_tokens; pub mod pallet_xcm; diff --git a/runtime/bifrost-kusama/src/weights/orml_oracle.rs b/runtime/bifrost-kusama/src/weights/orml_oracle.rs deleted file mode 100644 index dffcbeaf83..0000000000 --- a/runtime/bifrost-kusama/src/weights/orml_oracle.rs +++ /dev/null @@ -1,45 +0,0 @@ -//! Autogenerated weights for orml_oracle -//! -//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 3.0.0 -//! DATE: 2021-05-04, STEPS: [50, ], REPEAT: 20, LOW RANGE: [], HIGH RANGE: [] -//! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("dev"), DB CACHE: 128 - -// Executed Command: -// target/release/bifrost -// benchmark -// --chain=dev -// --steps=50 -// --repeat=20 -// --pallet=orml_oracle -// --extrinsic=* -// --execution=wasm -// --wasm-execution=compiled -// --heap-pages=4096 -// --output=./oracle/src/weights.rs -// --template -// ../templates/orml-weight-template.hbs - - -#![cfg_attr(rustfmt, rustfmt_skip)] -#![allow(unused_parens)] -#![allow(unused_imports)] -#![allow(clippy::unnecessary_cast)] - -use frame_support::{traits::Get, weights::{Weight, constants::RocksDbWeight}}; -use sp_std::marker::PhantomData; - -pub struct WeightInfo(PhantomData); -impl orml_oracle::WeightInfo for WeightInfo { - fn feed_values(c: u32, ) -> Weight { - Weight::from_parts(16_800_000, 0) - // Standard Error: 84_000 - .saturating_add(Weight::from_parts(3_600_000, 0).saturating_mul(c as u64)) - .saturating_add(RocksDbWeight::get().reads(3 as u64)) - .saturating_add(RocksDbWeight::get().writes(1 as u64)) - .saturating_add(RocksDbWeight::get().writes((2 as u64).saturating_mul(c as u64))) - } - fn on_finalize() -> Weight { - Weight::from_parts(3_000_000, 0) - .saturating_add(RocksDbWeight::get().writes(1 as u64)) - } -} \ No newline at end of file diff --git a/runtime/bifrost-polkadot/Cargo.toml b/runtime/bifrost-polkadot/Cargo.toml index 801c256d1c..78f6e5b19a 100644 --- a/runtime/bifrost-polkadot/Cargo.toml +++ b/runtime/bifrost-polkadot/Cargo.toml @@ -118,9 +118,6 @@ bifrost-currencies = { workspace = true } bifrost-stable-pool = { path = "../../pallets/stable-pool", default-features = false } bifrost-stable-pool-rpc-runtime-api = { path = "../../pallets/stable-pool/rpc/runtime-api", default-features = false } bifrost-vtoken-voting = { path = "../../pallets/vtoken-voting", default-features = false, features = [ "polkadot" ] } -lend-market = { path = "../../pallets/lend-market", default-features = false } -lend-market-rpc-runtime-api = { path = "../../pallets/lend-market/rpc/runtime-api", default-features = false } -pallet-prices = { path = "../../pallets/prices", default-features = false } # orml orml-tokens = { version = "0.4.1-dev", default-features = false } @@ -129,7 +126,6 @@ orml-xtokens = { version = "0.4.1-dev", default-features = false } orml-unknown-tokens = { version = "0.4.1-dev", default-features = false } orml-xcm = { version = "0.4.1-dev", default-features = false } orml-xcm-support = { version = "0.4.1-dev", default-features = false } -orml-oracle = { version = "0.4.1-dev", default-features = false } merkle-distributor = { version = "*", default-features = false } zenlink-protocol = { version = "*", default-features = false } @@ -208,7 +204,6 @@ std = [ "orml-unknown-tokens/std", "orml-xcm/std", "orml-xcm-support/std", - "orml-oracle/std", "bifrost-runtime-common/std", "bifrost-farming/std", "bifrost-farming-rpc-runtime-api/std", @@ -231,9 +226,6 @@ std = [ "bifrost-cross-in-out/std", "substrate-wasm-builder", "bifrost-slpx/std", - "lend-market/std", - "lend-market-rpc-runtime-api/std", - "pallet-prices/std", "bifrost-stable-pool/std", "bifrost-stable-pool-rpc-runtime-api/std", ] @@ -269,7 +261,6 @@ runtime-benchmarks = [ "bifrost-stable-pool/runtime-benchmarks", "bifrost-vtoken-voting/runtime-benchmarks", "sp-api/disable-logging", - "lend-market/runtime-benchmarks", ] try-runtime = [ @@ -315,7 +306,6 @@ try-runtime = [ "bifrost-currencies/try-runtime", "orml-unknown-tokens/try-runtime", "orml-xcm/try-runtime", - "orml-oracle/try-runtime", "zenlink-protocol/try-runtime", "merkle-distributor/try-runtime", "bifrost-flexible-fee/try-runtime", @@ -336,8 +326,6 @@ try-runtime = [ "nutsfinance-stable-asset/try-runtime", "bifrost-stable-pool/try-runtime", "bifrost-vtoken-voting/try-runtime", - "lend-market/try-runtime", - "pallet-prices/try-runtime", ] # When enabled, the runtime API will not be build. diff --git a/runtime/bifrost-polkadot/src/lib.rs b/runtime/bifrost-polkadot/src/lib.rs index a9ed59026e..29c922a41d 100644 --- a/runtime/bifrost-polkadot/src/lib.rs +++ b/runtime/bifrost-polkadot/src/lib.rs @@ -50,7 +50,6 @@ pub use frame_support::{ PalletId, RuntimeDebug, StorageValue, }; use frame_system::limits::{BlockLength, BlockWeights}; -use orml_oracle::{DataFeeder, DataProvider, DataProviderExtended}; pub use pallet_balances::Call as BalancesCall; pub use pallet_timestamp::Call as TimestampCall; use sp_api::impl_runtime_apis; @@ -1498,93 +1497,6 @@ impl bifrost_ve_minting::Config for Runtime { type VoteWeightMultiplier = VoteWeightMultiplier; } -parameter_types! { - pub const MinimumCount: u32 = 3; - pub const ExpiresIn: Moment = 1000 * 60 * 60; // 60 mins - pub const MaxHasDispatchedSize: u32 = 100; - pub OracleRootOperatorAccountId: AccountId = OraclePalletId::get().into_account_truncating(); -} - -type BifrostDataProvider = orml_oracle::Instance1; -impl orml_oracle::Config for Runtime { - type RuntimeEvent = RuntimeEvent; - type OnNewData = (); - type CombineData = - orml_oracle::DefaultCombineData; - type Time = Timestamp; - type OracleKey = CurrencyId; - type OracleValue = Price; - type RootOperatorAccountId = OracleRootOperatorAccountId; - type MaxHasDispatchedSize = MaxHasDispatchedSize; - type WeightInfo = weights::orml_oracle::WeightInfo; - type Members = OracleMembership; -} - -pub type TimeStampedPrice = orml_oracle::TimestampedValue; -pub struct AggregatedDataProvider; -impl DataProvider for AggregatedDataProvider { - fn get(key: &CurrencyId) -> Option { - Oracle::get(key) - } -} - -impl DataProviderExtended for AggregatedDataProvider { - fn get_no_op(key: &CurrencyId) -> Option { - Oracle::get_no_op(key) - } - - fn get_all_values() -> Vec<(CurrencyId, Option)> { - Oracle::get_all_values() - } -} - -impl DataFeeder for AggregatedDataProvider { - fn feed_value(_: AccountId, _: CurrencyId, _: TimeStampedPrice) -> DispatchResult { - Err("Not supported".into()) - } -} - -impl pallet_prices::Config for Runtime { - type RuntimeEvent = RuntimeEvent; - type Source = AggregatedDataProvider; - type FeederOrigin = EitherOfDiverse; - type UpdateOrigin = EitherOfDiverse; - type RelayCurrency = RelayCurrencyId; - type CurrencyIdConvert = AssetIdMaps; - type Assets = Currencies; - type WeightInfo = pallet_prices::weights::SubstrateWeight; -} - -impl lend_market::Config for Runtime { - type RuntimeEvent = RuntimeEvent; - type PalletId = LendMarketPalletId; - type PriceFeeder = Prices; - type ReserveOrigin = EitherOfDiverse; - type UpdateOrigin = EitherOfDiverse; - type WeightInfo = lend_market::weights::BifrostWeight; - type UnixTime = Timestamp; - type Assets = Currencies; - type RewardAssetId = NativeCurrencyId; - type LiquidationFreeAssetId = RelayCurrencyId; -} - -parameter_types! { - pub const OracleMaxMembers: u32 = 100; -} - -impl pallet_membership::Config for Runtime { - type AddOrigin = MoreThanHalfCouncil; - type RuntimeEvent = RuntimeEvent; - type MaxMembers = OracleMaxMembers; - type MembershipInitialized = (); - type MembershipChanged = (); - type PrimeOrigin = MoreThanHalfCouncil; - type RemoveOrigin = MoreThanHalfCouncil; - type ResetOrigin = MoreThanHalfCouncil; - type SwapOrigin = MoreThanHalfCouncil; - type WeightInfo = pallet_membership::weights::SubstrateWeight; -} - // Below is the implementation of tokens manipulation functions other than native token. pub struct LocalAssetAdaptor(PhantomData); @@ -1767,10 +1679,6 @@ construct_runtime! { StableAsset: nutsfinance_stable_asset::{Pallet, Storage, Event} = 128, StablePool: bifrost_stable_pool::{Pallet, Call, Storage} = 129, VtokenVoting: bifrost_vtoken_voting::{Pallet, Call, Storage, Event} = 130, - LendMarket: lend_market::{Pallet, Call, Storage, Event} = 131, - Prices: pallet_prices::{Pallet, Call, Storage, Event} = 132, - Oracle: orml_oracle::::{Pallet, Storage, Call, Event} = 133, - OracleMembership: pallet_membership::::{Pallet, Call, Storage, Event, Config} = 134, } } @@ -2070,20 +1978,6 @@ impl_runtime_apis! { } } - impl lend_market_rpc_runtime_api::LendMarketApi for Runtime { - fn get_account_liquidity(account: AccountId) -> Result<(Liquidity, Shortfall, Liquidity, Shortfall), DispatchError> { - LendMarket::get_account_liquidity(&account) - } - - fn get_market_status(asset_id: CurrencyId) -> Result<(Rate, Rate, Rate, Ratio, Balance, Balance, sp_runtime::FixedU128), DispatchError> { - LendMarket::get_market_status(asset_id) - } - - fn get_liquidation_threshold_liquidity(account: AccountId) -> Result<(Liquidity, Shortfall, Liquidity, Shortfall), DispatchError> { - LendMarket::get_account_liquidation_threshold_liquidity(&account) - } - } - impl bifrost_stable_pool_rpc_runtime_api::StablePoolRuntimeApi for Runtime { fn get_swap_output( pool_id: u32, diff --git a/runtime/bifrost-polkadot/src/weights/mod.rs b/runtime/bifrost-polkadot/src/weights/mod.rs index 4190333bd1..239b4103b5 100644 --- a/runtime/bifrost-polkadot/src/weights/mod.rs +++ b/runtime/bifrost-polkadot/src/weights/mod.rs @@ -37,6 +37,5 @@ pub mod bifrost_ve_minting; pub mod bifrost_vstoken_conversion; pub mod bifrost_vtoken_minting; pub mod bifrost_vtoken_voting; -pub mod orml_oracle; pub mod orml_tokens; pub mod pallet_xcm; diff --git a/runtime/bifrost-polkadot/src/weights/orml_oracle.rs b/runtime/bifrost-polkadot/src/weights/orml_oracle.rs deleted file mode 100644 index dffcbeaf83..0000000000 --- a/runtime/bifrost-polkadot/src/weights/orml_oracle.rs +++ /dev/null @@ -1,45 +0,0 @@ -//! Autogenerated weights for orml_oracle -//! -//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 3.0.0 -//! DATE: 2021-05-04, STEPS: [50, ], REPEAT: 20, LOW RANGE: [], HIGH RANGE: [] -//! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("dev"), DB CACHE: 128 - -// Executed Command: -// target/release/bifrost -// benchmark -// --chain=dev -// --steps=50 -// --repeat=20 -// --pallet=orml_oracle -// --extrinsic=* -// --execution=wasm -// --wasm-execution=compiled -// --heap-pages=4096 -// --output=./oracle/src/weights.rs -// --template -// ../templates/orml-weight-template.hbs - - -#![cfg_attr(rustfmt, rustfmt_skip)] -#![allow(unused_parens)] -#![allow(unused_imports)] -#![allow(clippy::unnecessary_cast)] - -use frame_support::{traits::Get, weights::{Weight, constants::RocksDbWeight}}; -use sp_std::marker::PhantomData; - -pub struct WeightInfo(PhantomData); -impl orml_oracle::WeightInfo for WeightInfo { - fn feed_values(c: u32, ) -> Weight { - Weight::from_parts(16_800_000, 0) - // Standard Error: 84_000 - .saturating_add(Weight::from_parts(3_600_000, 0).saturating_mul(c as u64)) - .saturating_add(RocksDbWeight::get().reads(3 as u64)) - .saturating_add(RocksDbWeight::get().writes(1 as u64)) - .saturating_add(RocksDbWeight::get().writes((2 as u64).saturating_mul(c as u64))) - } - fn on_finalize() -> Weight { - Weight::from_parts(3_000_000, 0) - .saturating_add(RocksDbWeight::get().writes(1 as u64)) - } -} \ No newline at end of file