diff --git a/pallets/pallet-bonded-coins/src/benchmarking.rs b/pallets/pallet-bonded-coins/src/benchmarking.rs index 68a6a35f7..82e506ed2 100644 --- a/pallets/pallet-bonded-coins/src/benchmarking.rs +++ b/pallets/pallet-bonded-coins/src/benchmarking.rs @@ -32,6 +32,7 @@ use crate::{ square_root::{SquareRootParameters, SquareRootParametersInput}, Curve, CurveInput, }, + types::BondedCurrenciesSettings, Call, CollateralAssetIdOf, CollateralBalanceOf, Config, CurveParameterTypeOf, FungiblesAssetIdOf, FungiblesBalanceOf, Pallet, }; @@ -229,10 +230,13 @@ mod benchmarks { owner, state, collateral, - denomination, bonded_currencies: BoundedVec::truncate_from(bonded_coin_ids.clone()), - transferable: true, - min_operation_balance: 1u128.saturated_into(), + currencies_settings: BondedCurrenciesSettings { + denomination, + transferable: true, + allow_reset_team: true, + min_operation_balance: 1u128.saturated_into(), + }, deposit: Pallet::::calculate_pool_deposit(bonded_coin_ids.len()), }; Pools::::insert(&pool_id, pool_details); @@ -272,9 +276,12 @@ mod benchmarks { curve, collateral_id, currencies, - 10, - true, - 1, + BondedCurrenciesSettings { + denomination: 10, + allow_reset_team: true, + transferable: true, + min_operation_balance: 1, + }, ); // Verify @@ -310,9 +317,12 @@ mod benchmarks { curve, collateral_id, currencies, - 10, - true, - 1, + BondedCurrenciesSettings { + denomination: 10, + allow_reset_team: true, + transferable: true, + min_operation_balance: 1, + }, ); // Verify @@ -347,9 +357,12 @@ mod benchmarks { curve, collateral_id, currencies, - 10, - true, - 1, + BondedCurrenciesSettings { + denomination: 10, + allow_reset_team: true, + transferable: true, + min_operation_balance: 1, + }, ); // Verify diff --git a/pallets/pallet-bonded-coins/src/lib.rs b/pallets/pallet-bonded-coins/src/lib.rs index c88df826c..c0946d781 100644 --- a/pallets/pallet-bonded-coins/src/lib.rs +++ b/pallets/pallet-bonded-coins/src/lib.rs @@ -36,7 +36,7 @@ mod types; #[cfg(feature = "runtime-benchmarks")] pub use benchmarking::BenchmarkHelper; -pub use types::{PoolDetails, Round}; +pub use types::{BondedCurrenciesSettings, PoolDetails, Round}; pub use default_weights::WeightInfo; @@ -93,10 +93,13 @@ pub mod pallet { use crate::{ curves::{balance_to_fixed, fixed_to_balance, BondingFunction, Curve, CurveInput}, traits::{FreezeAccounts, NextAssetIds, ResetTeam}, - types::{Locks, PoolDetails, PoolManagingTeam, PoolStatus, Round, TokenMeta}, + types::{BondedCurrenciesSettings, Locks, PoolDetails, PoolManagingTeam, PoolStatus, Round, TokenMeta}, WeightInfo, }; + /// The current storage version. + const STORAGE_VERSION: StorageVersion = StorageVersion::new(1); + pub(crate) type AccountIdLookupOf = <::Lookup as sp_runtime::traits::StaticLookup>::Source; @@ -131,6 +134,7 @@ pub mod pallet { BoundedCurrencyVec, CollateralAssetIdOf, DepositBalanceOf, + BondedCurrenciesSettings, >; /// Minimum required amount of integer and fractional bits to perform ln, @@ -189,7 +193,7 @@ pub mod pallet { #[pallet::constant] type BaseDeposit: Get>; - /// The origin for most permissionless and priviledged operations. + /// The origin for most permissionless and privileged operations. type DefaultOrigin: EnsureOrigin; /// The dedicated origin for creating new bonded currency pools /// (typically permissionless). @@ -227,6 +231,7 @@ pub mod pallet { } #[pallet::pallet] + #[pallet::storage_version(STORAGE_VERSION)] pub struct Pallet(_); #[pallet::hooks] @@ -339,9 +344,15 @@ pub mod pallet { /// - `currencies`: A bounded vector of token metadata for the bonded /// currencies. Note that no two currencies may use the same name or /// symbol. - /// - `denomination`: The denomination for the bonded currencies. - /// - `transferable`: A boolean indicating if the bonded currencies are - /// transferable. + /// - `currencies_settings`: Options and settings shared by all bonded + /// currencies. These cannot be changed after the pool is created. + /// - `denomination`: The denomination for the bonded currencies. + /// - `transferable`: A boolean indicating if the bonded currencies + /// are transferable. + /// - `allow_reset_team`: Whether asset management team changes are + /// allowed for this pool. + /// - `min_operation_balance`: The minimum amount that can be + /// minted/burnt. /// /// # Returns /// - `DispatchResult`: The result of the dispatch. @@ -367,12 +378,17 @@ pub mod pallet { curve: CurveInput>, collateral_id: CollateralAssetIdOf, currencies: BoundedVec, T::MaxCurrenciesPerPool>, - denomination: u8, - transferable: bool, - min_operation_balance: u128, + currencies_settings: BondedCurrenciesSettings, ) -> DispatchResult { let who = T::PoolCreateOrigin::ensure_origin(origin)?; + let BondedCurrenciesSettings { + denomination, + transferable, + allow_reset_team, + min_operation_balance, + } = currencies_settings; + ensure!(denomination <= T::MaxDenomination::get(), Error::::InvalidInput); let checked_curve = curve.try_into().map_err(|_| Error::::InvalidInput)?; @@ -450,6 +466,7 @@ pub mod pallet { collateral_id, currency_ids, transferable, + allow_reset_team, denomination, min_operation_balance, deposit_amount, @@ -478,8 +495,9 @@ pub mod pallet { /// /// # Errors /// - `Error::::PoolUnknown`: If the pool does not exist. - /// - `Error::::NoPermission`: If the caller is not a manager of the - /// pool. + /// - `Error::::NoPermission`: If this pool does not allow changing + /// the asset management team, or if the caller is not a manager of + /// the pool. /// - `Error::::CurrencyCount`: If the actual number of currencies in /// the pool is larger than `currency_count`. /// - Other errors depending on the types in the config. @@ -498,7 +516,12 @@ pub mod pallet { let number_of_currencies = Self::get_currencies_number(&pool_details); ensure!(number_of_currencies <= currency_count, Error::::CurrencyCount); - ensure!(pool_details.is_manager(&who), Error::::NoPermission); + let BondedCurrenciesSettings { allow_reset_team, .. } = pool_details.currencies_settings; + + ensure!( + allow_reset_team && pool_details.is_manager(&who), + Error::::NoPermission + ); ensure!(pool_details.state.is_live(), Error::::PoolNotLive); let pool_id_account = pool_id.into(); @@ -703,8 +726,15 @@ pub mod pallet { let number_of_currencies = Self::get_currencies_number(&pool_details); ensure!(number_of_currencies <= currency_count, Error::::CurrencyCount); + let BondedCurrenciesSettings { + min_operation_balance, + denomination, + transferable, + .. + } = pool_details.currencies_settings; + ensure!( - amount_to_mint >= pool_details.min_operation_balance.saturated_into(), + amount_to_mint >= min_operation_balance.saturated_into(), TokenError::BelowMinimum ); @@ -724,16 +754,13 @@ pub mod pallet { let (active_pre, passive) = Self::calculate_normalized_passive_issuance( &bonded_currencies, - pool_details.denomination, + denomination, currency_idx, round_kind, )?; - let normalized_amount_to_mint = balance_to_fixed( - amount_to_mint.saturated_into::(), - pool_details.denomination, - round_kind, - )?; + let normalized_amount_to_mint = + balance_to_fixed(amount_to_mint.saturated_into::(), denomination, round_kind)?; let active_post = active_pre .checked_add(normalized_amount_to_mint) @@ -764,7 +791,7 @@ pub mod pallet { T::Fungibles::mint_into(target_currency_id.clone(), &beneficiary, amount_to_mint)?; - if !pool_details.transferable { + if !transferable { T::Fungibles::freeze(target_currency_id, &beneficiary).map_err(|freeze_error| { log::info!(target: LOG_TARGET, "Failed to freeze account: {:?}", freeze_error); freeze_error.into() @@ -832,8 +859,15 @@ pub mod pallet { let pool_details = Pools::::get(&pool_id).ok_or(Error::::PoolUnknown)?; + let BondedCurrenciesSettings { + min_operation_balance, + denomination, + transferable, + .. + } = pool_details.currencies_settings; + ensure!( - amount_to_burn >= pool_details.min_operation_balance.saturated_into(), + amount_to_burn >= min_operation_balance.saturated_into(), TokenError::BelowMinimum ); @@ -854,12 +888,12 @@ pub mod pallet { let (high, passive) = Self::calculate_normalized_passive_issuance( &bonded_currencies, - pool_details.denomination, + denomination, currency_idx, round_kind, )?; - let normalized_amount_to_burn = balance_to_fixed(amount_to_burn, pool_details.denomination, round_kind)?; + let normalized_amount_to_burn = balance_to_fixed(amount_to_burn, denomination, round_kind)?; let low = high .checked_sub(normalized_amount_to_burn) @@ -905,7 +939,7 @@ pub mod pallet { let account_exists = T::Fungibles::total_balance(target_currency_id.clone(), &who) > Zero::zero(); - if !pool_details.transferable && account_exists { + if !transferable && account_exists { // Restore locks. T::Fungibles::freeze(target_currency_id, &who).map_err(|freeze_error| { log::info!(target: LOG_TARGET, "Failed to freeze account: {:?}", freeze_error); diff --git a/pallets/pallet-bonded-coins/src/mock.rs b/pallets/pallet-bonded-coins/src/mock.rs index 083982590..5d1078142 100644 --- a/pallets/pallet-bonded-coins/src/mock.rs +++ b/pallets/pallet-bonded-coins/src/mock.rs @@ -69,7 +69,7 @@ pub mod runtime { use crate::{ self as pallet_bonded_coins, traits::NextAssetIds, - types::{Locks, PoolStatus}, + types::{BondedCurrenciesSettings, Locks, PoolStatus}, AccountIdOf, Config, DepositBalanceOf, FungiblesAssetIdOf, FungiblesBalanceOf, PoolDetailsOf, }; @@ -118,13 +118,16 @@ pub mod runtime { PoolDetailsOf:: { curve, manager, - transferable, bonded_currencies, state, collateral, - denomination: DEFAULT_BONDED_DENOMINATION, + currencies_settings: BondedCurrenciesSettings { + allow_reset_team: true, + transferable, + min_operation_balance, + denomination: DEFAULT_BONDED_DENOMINATION, + }, owner, - min_operation_balance, deposit: BondingPallet::calculate_pool_deposit(currencies.len()), } } @@ -446,7 +449,7 @@ pub mod runtime { pool_details .bonded_currencies .iter() - .map(|id| (*id, vec![], vec![], pool_details.denomination)) + .map(|id| (*id, vec![], vec![], pool_details.currencies_settings.denomination)) .collect::, Vec, u8)>>() }) .chain( diff --git a/pallets/pallet-bonded-coins/src/tests/transactions/burn_into.rs b/pallets/pallet-bonded-coins/src/tests/transactions/burn_into.rs index 6d313e1d0..17da44bc4 100644 --- a/pallets/pallet-bonded-coins/src/tests/transactions/burn_into.rs +++ b/pallets/pallet-bonded-coins/src/tests/transactions/burn_into.rs @@ -27,7 +27,7 @@ use sp_runtime::{assert_eq_error_rate, bounded_vec, traits::Scale, TokenError}; use crate::{ mock::{runtime::*, *}, - types::{Locks, PoolStatus}, + types::{BondedCurrenciesSettings, Locks, PoolStatus}, AccountIdOf, Error, PoolDetailsOf, }; @@ -55,13 +55,16 @@ fn burn_first_coin() { PoolDetailsOf:: { curve: get_linear_bonding_curve(), manager: None, - transferable: true, bonded_currencies: bounded_vec![DEFAULT_BONDED_CURRENCY_ID], state: PoolStatus::Active, collateral: DEFAULT_COLLATERAL_CURRENCY_ID, - denomination: 0, + currencies_settings: BondedCurrenciesSettings { + transferable: true, + allow_reset_team: true, + denomination: 0, + min_operation_balance: 1, + }, owner: ACCOUNT_99, - min_operation_balance: 1, deposit: BondingPallet::calculate_pool_deposit(1), }, )]) diff --git a/pallets/pallet-bonded-coins/src/tests/transactions/create_pool.rs b/pallets/pallet-bonded-coins/src/tests/transactions/create_pool.rs index edd69b618..8b83f6d16 100644 --- a/pallets/pallet-bonded-coins/src/tests/transactions/create_pool.rs +++ b/pallets/pallet-bonded-coins/src/tests/transactions/create_pool.rs @@ -28,7 +28,7 @@ use sp_std::ops::Sub; use crate::{ mock::{runtime::*, *}, - types::{Locks, PoolStatus}, + types::{BondedCurrenciesSettings, Locks, PoolStatus}, AccountIdOf, Error, Event as BondingPalletEvents, Pools, TokenMetaOf, }; @@ -55,9 +55,12 @@ fn single_currency() { curve, DEFAULT_COLLATERAL_CURRENCY_ID, bounded_vec![bonded_token], - DEFAULT_BONDED_DENOMINATION, - true, - 1, + BondedCurrenciesSettings { + denomination: DEFAULT_BONDED_DENOMINATION, + allow_reset_team: true, + transferable: true, + min_operation_balance: 1 + }, )); let pool_id: AccountIdOf = calculate_pool_id(&[new_asset_id]); @@ -66,7 +69,7 @@ fn single_currency() { assert!(details.is_owner(&ACCOUNT_00)); assert!(details.is_manager(&ACCOUNT_00)); - assert!(details.transferable); + assert!(details.currencies_settings.transferable); assert_eq!( details.state, PoolStatus::Locked(Locks { @@ -74,7 +77,7 @@ fn single_currency() { allow_burn: false, }) ); - assert_eq!(details.denomination, DEFAULT_BONDED_DENOMINATION); + assert_eq!(details.currencies_settings.denomination, DEFAULT_BONDED_DENOMINATION); assert_eq!(details.collateral, DEFAULT_COLLATERAL_CURRENCY_ID); assert_eq!(details.bonded_currencies, vec![new_asset_id]); @@ -137,9 +140,12 @@ fn multi_currency() { curve, DEFAULT_COLLATERAL_CURRENCY_ID, bonded_tokens, - DEFAULT_BONDED_DENOMINATION, - true, - 1 + BondedCurrenciesSettings { + denomination: DEFAULT_BONDED_DENOMINATION, + allow_reset_team: true, + transferable: true, + min_operation_balance: 1 + } )); assert_eq!(NextAssetId::::get(), next_asset_id + 3); @@ -188,9 +194,12 @@ fn multi_currency_with_empty_metadata() { curve, DEFAULT_COLLATERAL_CURRENCY_ID, bonded_tokens, - DEFAULT_BONDED_DENOMINATION, - true, - 1 + BondedCurrenciesSettings { + denomination: DEFAULT_BONDED_DENOMINATION, + allow_reset_team: true, + transferable: true, + min_operation_balance: 1 + } )); assert_eq!(NextAssetId::::get(), next_asset_id + 3); @@ -238,9 +247,12 @@ fn can_create_identical_pools() { curve.clone(), DEFAULT_COLLATERAL_CURRENCY_ID, bounded_vec![bonded_token.clone()], - DEFAULT_BONDED_DENOMINATION, - true, - 1 + BondedCurrenciesSettings { + denomination: DEFAULT_BONDED_DENOMINATION, + allow_reset_team: true, + transferable: true, + min_operation_balance: 1 + } )); assert_ok!(BondingPallet::create_pool( @@ -248,9 +260,12 @@ fn can_create_identical_pools() { curve, DEFAULT_COLLATERAL_CURRENCY_ID, bounded_vec![bonded_token], - DEFAULT_BONDED_DENOMINATION, - true, - 1 + BondedCurrenciesSettings { + denomination: DEFAULT_BONDED_DENOMINATION, + allow_reset_team: true, + transferable: true, + min_operation_balance: 1 + } )); assert_eq!(NextAssetId::::get(), next_asset_id + 2); @@ -302,9 +317,12 @@ fn cannot_reuse_names() { curve, DEFAULT_COLLATERAL_CURRENCY_ID, bonded_tokens, - DEFAULT_BONDED_DENOMINATION, - true, - 1 + BondedCurrenciesSettings { + denomination: DEFAULT_BONDED_DENOMINATION, + allow_reset_team: true, + transferable: true, + min_operation_balance: 1 + } ), Error::::InvalidInput ); @@ -345,9 +363,12 @@ fn cannot_reuse_symbols() { curve, DEFAULT_COLLATERAL_CURRENCY_ID, bonded_tokens, - DEFAULT_BONDED_DENOMINATION, - true, - 1 + BondedCurrenciesSettings { + denomination: DEFAULT_BONDED_DENOMINATION, + allow_reset_team: true, + transferable: true, + min_operation_balance: 1 + } ), Error::::InvalidInput ); @@ -374,9 +395,12 @@ fn fails_if_collateral_not_exists() { curve, 100, bounded_vec![bonded_token], - DEFAULT_BONDED_DENOMINATION, - true, - 1 + BondedCurrenciesSettings { + denomination: DEFAULT_BONDED_DENOMINATION, + allow_reset_team: true, + transferable: true, + min_operation_balance: 1 + } ), AssetsPalletErrors::::Unknown ); @@ -406,9 +430,12 @@ fn cannot_create_circular_pool() { // try specifying the id of the currency to be created as collateral next_asset_id, bounded_vec![bonded_token], - DEFAULT_BONDED_DENOMINATION, - true, - 1 + BondedCurrenciesSettings { + denomination: DEFAULT_BONDED_DENOMINATION, + allow_reset_team: true, + transferable: true, + min_operation_balance: 1 + } ), AssetsPalletErrors::::Unknown ); @@ -439,9 +466,12 @@ fn handles_asset_id_overflow() { curve, DEFAULT_COLLATERAL_CURRENCY_ID, bounded_vec![bonded_token; 2], - DEFAULT_BONDED_DENOMINATION, - true, - 1 + BondedCurrenciesSettings { + denomination: DEFAULT_BONDED_DENOMINATION, + allow_reset_team: true, + transferable: true, + min_operation_balance: 1 + } ), ArithmeticError::Overflow ); diff --git a/pallets/pallet-bonded-coins/src/tests/transactions/reset_team.rs b/pallets/pallet-bonded-coins/src/tests/transactions/reset_team.rs index e96fbca03..5683cc764 100644 --- a/pallets/pallet-bonded-coins/src/tests/transactions/reset_team.rs +++ b/pallets/pallet-bonded-coins/src/tests/transactions/reset_team.rs @@ -248,6 +248,46 @@ fn only_manager_can_change_team() { }) } +#[test] +fn fails_if_asset_team_flag_not_set() { + let curve = get_linear_bonding_curve(); + + let mut pool_details = generate_pool_details( + vec![DEFAULT_BONDED_CURRENCY_ID], + curve, + false, + Some(PoolStatus::Active), + Some(ACCOUNT_00), + None, + Some(ACCOUNT_00), + None, + ); + pool_details.currencies_settings.allow_reset_team = false; + let pool_id: AccountIdOf = calculate_pool_id(&[DEFAULT_BONDED_CURRENCY_ID]); + ExtBuilder::default() + .with_pools(vec![(pool_id.clone(), pool_details)]) + .with_native_balances(vec![(ACCOUNT_00, ONE_HUNDRED_KILT)]) + .with_collaterals(vec![DEFAULT_COLLATERAL_CURRENCY_ID]) + .build_and_execute_with_sanity_tests(|| { + let manager_origin = RawOrigin::Signed(ACCOUNT_00).into(); + + assert_err!( + BondingPallet::reset_team( + manager_origin, + pool_id.clone(), + PoolManagingTeam { + admin: ACCOUNT_00, + freezer: ACCOUNT_00, + }, + 1 + ), + BondingPalletErrors::::NoPermission + ); + + assert_eq!(Assets::admin(DEFAULT_BONDED_CURRENCY_ID), Some(pool_id)); + }) +} + #[test] fn handles_currency_number_incorrect() { let pool_details = generate_pool_details( diff --git a/pallets/pallet-bonded-coins/src/try_state.rs b/pallets/pallet-bonded-coins/src/try_state.rs index b1407bf44..e88481bff 100644 --- a/pallets/pallet-bonded-coins/src/try_state.rs +++ b/pallets/pallet-bonded-coins/src/try_state.rs @@ -18,7 +18,7 @@ pub(crate) fn do_try_state() -> Result<(), TryRuntimeError> { owner, bonded_currencies, state, - denomination, + currencies_settings, .. } = pool_details; @@ -61,7 +61,7 @@ pub(crate) fn do_try_state() -> Result<(), TryRuntimeError> { // The Currency in the fungibles pallet should always match with the // denomination stored in the pool. let currency_denomination = T::Fungibles::decimals(currency_id.clone()); - assert_eq!(currency_denomination, denomination); + assert_eq!(currency_denomination, currencies_settings.denomination); // if currency has on-zero supply -> collateral in pool account must be // non-zero. diff --git a/pallets/pallet-bonded-coins/src/types.rs b/pallets/pallet-bonded-coins/src/types.rs index 12fe093e3..31a3b6a70 100644 --- a/pallets/pallet-bonded-coins/src/types.rs +++ b/pallets/pallet-bonded-coins/src/types.rs @@ -78,12 +78,24 @@ impl PoolStatus { } } +#[derive(Clone, Encode, Decode, PartialEq, Eq, TypeInfo, MaxEncodedLen, Debug)] +pub struct BondedCurrenciesSettings { + /// The minimum amount that can be minted/burnt. + pub min_operation_balance: u128, + /// The denomination of all bonded assets the pool. + pub denomination: u8, + /// Whether asset management team changes are allowed. + pub allow_reset_team: bool, + /// Whether assets are transferable or not. + pub transferable: bool, +} + /// Details of a pool. #[derive(Clone, Encode, Decode, PartialEq, Eq, TypeInfo, MaxEncodedLen, Debug)] -pub struct PoolDetails { +pub struct PoolDetails { /// The owner of the pool. pub owner: AccountId, - /// The manager of the pool. If a manager is set, the pool is permissioned. + /// The manager of the pool, who can execute privileged transactions. pub manager: Option, /// The curve of the pool. pub curve: ParametrizedCurve, @@ -93,18 +105,14 @@ pub struct PoolDetails, - /// Whether the pool is transferable or not. - pub transferable: bool, - /// The denomination of the pool. - pub denomination: u8, - /// The minimum amount that can be minted/burnt. - pub min_operation_balance: u128, + /// Shared settings of the currencies in the pool. + pub currencies_settings: SharedSettings, /// The deposit to be returned upon destruction of this pool. pub deposit: DepositBalance, } impl - PoolDetails + PoolDetails where AccountId: PartialEq + Clone, { @@ -116,6 +124,7 @@ where collateral: BaseCurrencyId, bonded_currencies: Currencies, transferable: bool, + allow_reset_team: bool, denomination: u8, min_operation_balance: u128, deposit: DepositBalance, @@ -126,10 +135,13 @@ where curve, collateral, bonded_currencies, - transferable, + currencies_settings: BondedCurrenciesSettings { + transferable, + allow_reset_team, + denomination, + min_operation_balance, + }, state: PoolStatus::default(), - denomination, - min_operation_balance, deposit, } } diff --git a/runtime-api/bonded-coins/src/pool_details.rs b/runtime-api/bonded-coins/src/pool_details.rs index 071755d8d..214e1263c 100644 --- a/runtime-api/bonded-coins/src/pool_details.rs +++ b/runtime-api/bonded-coins/src/pool_details.rs @@ -16,7 +16,7 @@ // If you feel like getting in touch with us, you can do so at info@botlabs.org -use pallet_bonded_coins::{curves::Curve, PoolDetails}; +use pallet_bonded_coins::{curves::Curve, BondedCurrenciesSettings, PoolDetails}; use parity_scale_codec::{alloc::string::String, Decode, Encode}; use scale_info::TypeInfo; use sp_std::vec::Vec; @@ -28,8 +28,14 @@ pub type CurveOf = Curve; pub type CurrenciesOf = Vec>; /// Human readable pool details. -pub type PoolDetailsOf = - PoolDetails, CollateralDetails, Balance>; +pub type PoolDetailsOf = PoolDetails< + AccountId, + CurveOf, + CurrenciesOf, + CollateralDetails, + Balance, + BondedCurrenciesSettings, +>; /// Collateral currency details used for the runtime API. #[derive(Decode, Encode, TypeInfo)] diff --git a/runtimes/common/src/constants.rs b/runtimes/common/src/constants.rs index b316ab3d7..1364e999d 100644 --- a/runtimes/common/src/constants.rs +++ b/runtimes/common/src/constants.rs @@ -162,7 +162,7 @@ pub mod bonded_coins { use super::*; /// The size is checked in the runtime by a test. - pub const MAX_POOL_BYTE_LENGTH: u32 = 986; + pub const MAX_POOL_BYTE_LENGTH: u32 = 987; pub const BASE_DEPOSIT: Balance = deposit(1, MAX_POOL_BYTE_LENGTH); const ASSET_ID_BYTE_LENGTH: u32 = 8; /// https://github.com/paritytech/polkadot-sdk/blob/master/substrate/frame/assets/src/types.rs#L188 diff --git a/runtimes/peregrine/src/runtime_apis.rs b/runtimes/peregrine/src/runtime_apis.rs index 71540c512..9818f3da5 100644 --- a/runtimes/peregrine/src/runtime_apis.rs +++ b/runtimes/peregrine/src/runtime_apis.rs @@ -521,7 +521,8 @@ impl_runtime_apis! { high: Balance, ) -> Result { let pool = Pools::::get(pool_id).ok_or(BondedCurrencyError::PoolNotFound)?; - let PoolDetailsOf:: { curve, bonded_currencies, denomination, collateral, .. } = pool; + let PoolDetailsOf:: { curve, bonded_currencies, currencies_settings, collateral, .. } = pool; + let denomination = currencies_settings.denomination; let currency_id = bonded_currencies.get(currency_idx.saturated_into::()).ok_or(BondedCurrencyError::CurrencyNotFound)?; let collateral_denomination = NativeAndForeignAssets::decimals(collateral); @@ -578,15 +579,13 @@ impl_runtime_apis! { let pool = Pools::::get(pool_id).ok_or(BondedCurrencyError::PoolNotFound)?; let PoolDetailsOf:: { curve, + currencies_settings, bonded_currencies, owner, collateral, - denomination, deposit, - min_operation_balance, manager, state, - transferable, } = pool; let currencies = bonded_currencies.iter().map(|currency_id| -> Result, BondedCurrencyError> { @@ -629,12 +628,10 @@ impl_runtime_apis! { curve: fmt_curve, collateral: collateral_details, owner, - denomination, deposit, - min_operation_balance, manager, state, - transferable, + currencies_settings }) }