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

Fix lend market #1045

Merged
merged 5 commits into from
Sep 15, 2023
Merged
Show file tree
Hide file tree
Changes from 4 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
4 changes: 4 additions & 0 deletions Cargo.lock

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

24 changes: 21 additions & 3 deletions node/service/src/chain_spec/bifrost_kusama.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,10 @@ use std::{
use bifrost_kusama_runtime::{
constants::currency::DOLLARS, AccountId, AssetRegistryConfig, Balance, BalancesConfig,
BlockNumber, CouncilConfig, CouncilMembershipConfig, DefaultBlocksPerRound, DemocracyConfig,
GenesisConfig, IndicesConfig, InflationInfo, ParachainInfoConfig, ParachainStakingConfig,
PolkadotXcmConfig, Range, SS58Prefix, SalpConfig, SessionConfig, SystemConfig,
TechnicalCommitteeConfig, TechnicalMembershipConfig, TokensConfig, VestingConfig, WASM_BINARY,
GenesisConfig, IndicesConfig, InflationInfo, OracleMembershipConfig, ParachainInfoConfig,
ParachainStakingConfig, PolkadotXcmConfig, Range, SS58Prefix, SalpConfig, SessionConfig,
SystemConfig, TechnicalCommitteeConfig, TechnicalMembershipConfig, TokensConfig, VestingConfig,
WASM_BINARY,
};
use bifrost_runtime_common::AuraId;
use cumulus_primitives_core::ParaId;
Expand Down Expand Up @@ -128,6 +129,7 @@ pub fn bifrost_genesis(
Vec<CurrencyId>,
Vec<(CurrencyId, u32, u32, u32)>,
),
oracle_membership: Vec<AccountId>,
) -> GenesisConfig {
GenesisConfig {
system: SystemConfig {
Expand All @@ -144,6 +146,10 @@ 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![],
Expand Down Expand Up @@ -216,6 +222,7 @@ fn development_config_genesis(id: ParaId) -> GenesisConfig {

let council_membership = vec![get_account_id_from_seed::<sr25519::Public>("Alice")];
let technical_committee_membership = vec![get_account_id_from_seed::<sr25519::Public>("Alice")];
let oracle_membership = vec![get_account_id_from_seed::<sr25519::Public>("Alice")];

let salp_multisig: AccountId =
hex!["49daa32c7287890f38b7e1a8cd2961723d36d20baa0bf3b82e0c4bdda93b1c0a"].into();
Expand All @@ -235,6 +242,7 @@ fn development_config_genesis(id: ParaId) -> GenesisConfig {
technical_committee_membership,
salp_multisig,
(vec![], vec![], vec![]),
oracle_membership,
)
}

Expand Down Expand Up @@ -304,6 +312,7 @@ fn local_config_genesis(id: ParaId) -> GenesisConfig {

let council_membership = vec![get_account_id_from_seed::<sr25519::Public>("Alice")];
let technical_committee_membership = vec![get_account_id_from_seed::<sr25519::Public>("Alice")];
let oracle_membership = vec![get_account_id_from_seed::<sr25519::Public>("Alice")];
let salp_multisig: AccountId =
hex!["49daa32c7287890f38b7e1a8cd2961723d36d20baa0bf3b82e0c4bdda93b1c0a"].into();

Expand Down Expand Up @@ -370,6 +379,7 @@ fn local_config_genesis(id: ParaId) -> GenesisConfig {
technical_committee_membership,
salp_multisig,
(currency, vcurrency, vsbond),
oracle_membership,
)
}

Expand Down Expand Up @@ -445,6 +455,10 @@ fn rococo_testnet_config_genesis(id: ParaId) -> GenesisConfig {
// dDWnEWnx3GUgfugXh9mZtgj4CvJdmd8naYkWYCZGxjfb1Cz
hex!["420398e0150cd9d417fb8fd4027b75bd42717262e6eac97c55f2f8f84e8ffb3f"].into(),
];
let oracle_membership = vec![
// dDWnEWnx3GUgfugXh9mZtgj4CvJdmd8naYkWYCZGxjfb1Cz
hex!["420398e0150cd9d417fb8fd4027b75bd42717262e6eac97c55f2f8f84e8ffb3f"].into(),
];

bifrost_genesis(
invulnerables,
Expand All @@ -464,6 +478,7 @@ fn rococo_testnet_config_genesis(id: ParaId) -> GenesisConfig {
vec![],
vec![],
),
oracle_membership,
)
}

Expand Down Expand Up @@ -503,6 +518,7 @@ fn rococo_local_config_genesis(id: ParaId) -> GenesisConfig {

let council_membership = vec![get_account_id_from_seed::<sr25519::Public>("Alice")];
let technical_committee_membership = vec![get_account_id_from_seed::<sr25519::Public>("Alice")];
let oracle_membership = vec![get_account_id_from_seed::<sr25519::Public>("Alice")];

bifrost_genesis(
vec![
Expand All @@ -526,6 +542,7 @@ 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,
)
}

Expand Down Expand Up @@ -642,6 +659,7 @@ fn bifrost_config_genesis(id: ParaId) -> GenesisConfig {
vec![], // technical committee membership
salp_multisig,
(vec![], vec![], vec![]),
vec![],
)
}

Expand Down
15 changes: 13 additions & 2 deletions node/service/src/chain_spec/bifrost_polkadot.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,9 @@
use bifrost_polkadot_runtime::{
constants::currency::DOLLARS, AccountId, AssetRegistryConfig, Balance, BalancesConfig,
BlockNumber, CollatorSelectionConfig, CouncilMembershipConfig, GenesisConfig, IndicesConfig,
ParachainInfoConfig, PolkadotXcmConfig, SS58Prefix, SalpConfig, SessionConfig, SystemConfig,
TechnicalMembershipConfig, TokensConfig, VestingConfig, WASM_BINARY,
OracleMembershipConfig, ParachainInfoConfig, PolkadotXcmConfig, SS58Prefix, SalpConfig,
SessionConfig, SystemConfig, TechnicalMembershipConfig, TokensConfig, VestingConfig,
WASM_BINARY,
};
use bifrost_runtime_common::AuraId;
use cumulus_primitives_core::ParaId;
Expand Down Expand Up @@ -83,6 +84,7 @@ pub fn bifrost_polkadot_genesis(
Vec<CurrencyId>,
Vec<(CurrencyId, u32, u32, u32)>,
),
oracle_membership: Vec<AccountId>,
) -> GenesisConfig {
GenesisConfig {
system: SystemConfig {
Expand All @@ -99,6 +101,10 @@ 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(),
Expand Down Expand Up @@ -156,6 +162,7 @@ fn development_config_genesis(id: ParaId) -> GenesisConfig {

let council_membership = vec![get_account_id_from_seed::<sr25519::Public>("Alice")];
let technical_committee_membership = vec![get_account_id_from_seed::<sr25519::Public>("Alice")];
let oracle_membership = vec![get_account_id_from_seed::<sr25519::Public>("Alice")];
let salp_multisig: AccountId =
hex!["49daa32c7287890f38b7e1a8cd2961723d36d20baa0bf3b82e0c4bdda93b1c0a"].into();

Expand All @@ -172,6 +179,7 @@ fn development_config_genesis(id: ParaId) -> GenesisConfig {
technical_committee_membership,
salp_multisig,
(vec![], vec![], vec![]),
oracle_membership,
)
}

Expand Down Expand Up @@ -219,6 +227,7 @@ fn local_config_genesis(id: ParaId) -> GenesisConfig {
.collect();
let council_membership = vec![get_account_id_from_seed::<sr25519::Public>("Alice")];
let technical_committee_membership = vec![get_account_id_from_seed::<sr25519::Public>("Alice")];
let oracle_membership = vec![get_account_id_from_seed::<sr25519::Public>("Alice")];
let salp_multisig: AccountId =
hex!["49daa32c7287890f38b7e1a8cd2961723d36d20baa0bf3b82e0c4bdda93b1c0a"].into();
let currency = vec![
Expand Down Expand Up @@ -247,6 +256,7 @@ fn local_config_genesis(id: ParaId) -> GenesisConfig {
technical_committee_membership,
salp_multisig,
(currency, vcurrency, vec![]),
oracle_membership,
)
}

Expand Down Expand Up @@ -321,5 +331,6 @@ fn bifrost_polkadot_config_genesis(id: ParaId) -> GenesisConfig {
vec![],
salp_multisig,
(vec![], vec![], vec![]),
vec![],
)
}
2 changes: 0 additions & 2 deletions pallets/lend-market/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -310,8 +310,6 @@ impl pallet_assets::Config for Test {
type WeightInfo = ();
type RemoveItemsLimit = frame_support::traits::ConstU32<1000>;
type CallbackHandle = ();
// #[cfg(feature = "runtime-benchmarks")]
// type BenchmarkHelper = ();
}

impl pallet_prices::Config for Test {
Expand Down
26 changes: 23 additions & 3 deletions runtime/bifrost-kusama/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1710,7 +1710,7 @@ impl orml_oracle::Config<BifrostDataProvider> for Runtime {
type RootOperatorAccountId = OracleRootOperatorAccountId;
type MaxHasDispatchedSize = MaxHasDispatchedSize;
type WeightInfo = weights::orml_oracle::WeightInfo<Runtime>;
type Members = CouncilMembership;
type Members = OracleMembership;
}

pub type TimeStampedPrice = orml_oracle::TimestampedValue<Price, Moment>;
Expand Down Expand Up @@ -1761,6 +1761,23 @@ impl lend_market::Config for Runtime {
type LiquidationFreeAssetId = RelayCurrencyId;
}

parameter_types! {
pub const OracleMaxMembers: u32 = 100;
}

impl pallet_membership::Config<pallet_membership::Instance3> 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<Runtime>;
}

// Below is the implementation of tokens manipulation functions other than native token.
pub struct LocalAssetAdaptor<Local>(PhantomData<Local>);

Expand Down Expand Up @@ -1949,6 +1966,7 @@ construct_runtime! {
LendMarket: lend_market::{Pallet, Call, Storage, Event<T>} = 131,
Prices: pallet_prices::{Pallet, Call, Storage, Event<T>} = 132,
Oracle: orml_oracle::<Instance1>::{Pallet, Storage, Call, Event<T>} = 133,
OracleMembership: pallet_membership::<Instance3>::{Pallet, Call, Storage, Event<T>, Config<T>} = 134,
}
}

Expand Down Expand Up @@ -2017,7 +2035,7 @@ impl<T: bifrost_asset_registry::Config> OnRuntimeUpgrade for BLPOnRuntimeUpgrade
if let Some(old_metadata) =
bifrost_asset_registry::CurrencyMetadatas::<Runtime>::get(CurrencyId::BLP(pool_id))
{
log::info!("Old currency_metadatas is {:?}", old_metadata);
log::info!("Old currency_metadatas name is {:?}", old_metadata.name);
}
}

Expand Down Expand Up @@ -2046,7 +2064,9 @@ impl<T: bifrost_asset_registry::Config> OnRuntimeUpgrade for BLPOnRuntimeUpgrade
if let Some(new_metadata) =
bifrost_asset_registry::CurrencyMetadatas::<Runtime>::get(CurrencyId::BLP(pool_id))
{
log::info!("New currency_metadatas is {:?}", new_metadata);
let symbol = scale_info::prelude::format!("BLP{}", pool_id).as_bytes().to_vec();
assert_eq!(new_metadata.symbol, symbol);
log::info!("New currency_metadatas name is {:?}", new_metadata.name);
}
}

Expand Down
2 changes: 1 addition & 1 deletion runtime/bifrost-kusama/src/weights/orml_oracle.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
//! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("dev"), DB CACHE: 128

// Executed Command:
// /Users/xiliangchen/projects/acala/target/release/acala
// target/release/bifrost
// benchmark
// --chain=dev
// --steps=50
Expand Down
14 changes: 13 additions & 1 deletion runtime/bifrost-polkadot/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ sp-version = { git = "https://github.com/paritytech/substrate", branch = "polkad
# frame dependencies
frame-benchmarking = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.42", default-features = false, optional = true }
frame-executive = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.42", default-features = false }
frame-support = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.42", default-features = false }
frame-support = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.42", default-features = false, features = ["tuples-96"] }
frame-system = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.42", default-features = false }
frame-system-benchmarking = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.42", default-features = false, optional = true }
frame-system-rpc-runtime-api = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.42", default-features = false }
Expand Down Expand Up @@ -113,6 +113,9 @@ pallet-ranked-collective = { git = "https://github.com/paritytech/substrate", br
pallet-referenda = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.42", default-features = false }
bifrost-currencies = { workspace = true }
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 }
Expand All @@ -121,6 +124,7 @@ 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 }
Expand Down Expand Up @@ -199,6 +203,7 @@ 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",
Expand All @@ -221,6 +226,9 @@ std = [
"bifrost-cross-in-out/std",
"substrate-wasm-builder",
"bifrost-slpx/std",
"lend-market/std",
"lend-market-rpc-runtime-api/std",
"pallet-prices/std",
]
with-tracing = ["frame-executive/with-tracing"]

Expand Down Expand Up @@ -253,6 +261,7 @@ runtime-benchmarks = [
"bifrost-slpx/runtime-benchmarks",
"bifrost-vtoken-voting/runtime-benchmarks",
"sp-api/disable-logging",
"lend-market/runtime-benchmarks",
]

try-runtime = [
Expand Down Expand Up @@ -298,6 +307,7 @@ 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",
Expand All @@ -316,6 +326,8 @@ try-runtime = [
"bifrost-cross-in-out/try-runtime",
"bifrost-slpx/try-runtime",
"bifrost-vtoken-voting/try-runtime",
"lend-market/try-runtime",
"pallet-prices/try-runtime",
]

# When enabled, the runtime API will not be build.
Expand Down
Loading
Loading