diff --git a/.github/workflows/static_analysis.yml b/.github/workflows/static_analysis.yml index c567edb2ed..ad99350942 100644 --- a/.github/workflows/static_analysis.yml +++ b/.github/workflows/static_analysis.yml @@ -24,6 +24,8 @@ jobs: run: | sudo rm -rf /usr/local/share/boost sudo rm -rf "$AGENT_TOOLSDIRECTORY" + sudo apt-get update + sudo apt-get install protobuf-compiler -y # v2.7.1 - uses: Swatinem/rust-cache@3cf7f8cc28d1b4e7d01e3783be10a97d55d483c8 diff --git a/Cargo.lock b/Cargo.lock index 6dc5033ecd..d2c8d839f5 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -7755,6 +7755,7 @@ dependencies = [ "common", "derivative", "dex-manager", + "extended-assets", "frame-benchmarking", "frame-support", "frame-system", @@ -8097,6 +8098,7 @@ dependencies = [ "oracle-proxy", "order-book", "pallet-balances", + "pallet-timestamp", "parity-scale-codec", "permissions", "pool-xyk", diff --git a/common/src/primitives.rs b/common/src/primitives.rs index 90c8abcbb6..d8ea0606de 100644 --- a/common/src/primitives.rs +++ b/common/src/primitives.rs @@ -72,6 +72,9 @@ pub const ASSET_ID_PREFIX_KENSETSU_PEGGED_TO_SORA: u8 = 4; /// Kensetsu asset ids pegged to oracle start with 0x05... pub const ASSET_ID_PREFIX_KENSETSU_PEGGED_TO_ORACLE: u8 = 5; +/// Predefined SBT asset ids start with 0x06... +pub const ASSET_ID_PREFIX_SBT_PREDEFINED: u8 = 6; + /// Wrapper type which extends Balance serialization, used for json in RPC's. #[derive(Encode, Decode, Debug, Clone, PartialEq, Eq, scale_info::TypeInfo)] pub struct BalanceWrapper(pub Balance); @@ -270,6 +273,41 @@ impl Default for PredefinedAssetId { } } +/// Predefined SBT asset identifier. +#[derive( + Encode, + Decode, + Eq, + PartialEq, + Copy, + Clone, + PartialOrd, + Ord, + RuntimeDebug, + scale_info::TypeInfo, + MaxEncodedLen, +)] +#[cfg_attr(feature = "std", derive(Serialize, Deserialize, Hash))] +#[repr(u8)] +pub enum PredefinedSbtAssetId { + PRACS = 0, + PRINVST = 1, + PRCRDT = 2, +} + +pub const SBT_PRACS: AssetId32 = + AssetId32::from_sbt_asset_id(PredefinedSbtAssetId::PRACS); +pub const SBT_PRINVST: AssetId32 = + AssetId32::from_sbt_asset_id(PredefinedSbtAssetId::PRINVST); +pub const SBT_PRCRDT: AssetId32 = + AssetId32::from_sbt_asset_id(PredefinedSbtAssetId::PRCRDT); + +impl IsRepresentation for PredefinedSbtAssetId { + fn is_representation(&self) -> bool { + false + } +} + /// This code is H256 like. pub type AssetId32Code = [u8; 32]; @@ -373,6 +411,13 @@ impl AssetId32 { Self::from_bytes(bytes) } + pub const fn from_sbt_asset_id(asset_id: PredefinedSbtAssetId) -> Self { + let mut bytes = [0u8; 32]; + bytes[0] = ASSET_ID_PREFIX_SBT_PREDEFINED; + bytes[2] = asset_id as u8; + Self::from_bytes(bytes) + } + /// Construct asset id for synthetic asset using its `reference_symbol` pub fn from_synthetic_reference_symbol(reference_symbol: &Symbol) -> Self where @@ -425,6 +470,12 @@ impl From> for AssetId32Code { } } +impl From for AssetId32 { + fn from(value: AssetId32Code) -> Self { + AssetId32::new(value, Default::default()) + } +} + impl Default for AssetId32 where AssetId32: From>, @@ -455,6 +506,18 @@ where } } +impl From> for AssetId32 { + fn from(value: AssetId32) -> Self { + AssetId32::new(value.code, Default::default()) + } +} + +impl AssetId32 { + pub fn into_predefined(self) -> AssetId32 { + self.into() + } +} + /// DEX identifier. #[derive( Encode, diff --git a/common/src/traits.rs b/common/src/traits.rs index aad02a82f9..7bff7cf2d0 100644 --- a/common/src/traits.rs +++ b/common/src/traits.rs @@ -1563,6 +1563,10 @@ pub trait OrderBookManager { output_asset_id: &AssetId, ) -> Option>; + fn tech_account_id_for_order_book( + order_book_id: &OrderBookId, + ) -> Result; + fn initialize_orderbook( order_book_id: &OrderBookId, tick_size: Balance, @@ -1590,6 +1594,12 @@ impl OrderBookManager, + ) -> Result { + unimplemented!() + } + fn initialize_orderbook( _order_book_id: &OrderBookId, _tick_size: Balance, @@ -1611,3 +1621,28 @@ impl OrderBookManager { + fn set_metadata(sbt_asset_id: &AssetId, external_url: Option, issued_at: Moment); + + fn bind_regulated_asset_to_sbt_asset( + sbt_asset_id: &AssetId, + regulated_asset_id: &AssetId, + ) -> Result<(), DispatchError>; +} + +impl ExtendedAssetsManager for () { + fn set_metadata( + _sbt_asset_id: &AssetId, + _external_url: Option, + _issued_at: Moment, + ) { + } + + fn bind_regulated_asset_to_sbt_asset( + _sbt_asset_id: &AssetId, + _regulated_asset_id: &AssetId, + ) -> Result<(), DispatchError> { + Ok(()) + } +} diff --git a/node/chain_spec/src/lib.rs b/node/chain_spec/src/lib.rs index 5513dbcb9b..9bc216423b 100644 --- a/node/chain_spec/src/lib.rs +++ b/node/chain_spec/src/lib.rs @@ -40,8 +40,9 @@ use common::prelude::{Balance, DEXInfo, FixedWrapper}; use common::{ balance, fixed, hash, our_include, our_include_bytes, vec_push, BalancePrecision, DEXId, Fixed, - SymbolName, TechPurpose, APOLLO_ASSET_ID, DAI, DEFAULT_BALANCE_PRECISION, ETH, HERMES_ASSET_ID, - KARMA, KEN, KGOLD, KUSD, KXOR, PRUSD, PSWAP, SB, TBCD, USDT, VAL, VXOR, XOR, XST, XSTUSD, + PredefinedAssetId, SymbolName, TechPurpose, APOLLO_ASSET_ID, DAI, DEFAULT_BALANCE_PRECISION, + ETH, HERMES_ASSET_ID, KARMA, KEN, KGOLD, KUSD, KXOR, PRUSD, PSWAP, SB, SBT_PRACS, SBT_PRCRDT, + SBT_PRINVST, TBCD, USDT, VAL, VXOR, XOR, XST, XSTUSD, }; use frame_support::sp_runtime::Percent; use framenode_runtime::eth_bridge::{AssetConfig, BridgeAssetData, NetworkConfig}; @@ -53,9 +54,9 @@ use framenode_runtime::{ assets, eth_bridge, frame_system, AccountId, AssetId, AssetName, AssetSymbol, AssetsConfig, BabeConfig, BalancesConfig, BeefyConfig, BeefyId, BridgeMultisigConfig, BridgeOutboundChannelConfig, CouncilConfig, DEXAPIConfig, DEXManagerConfig, DemocracyConfig, - EthBridgeConfig, GenesisConfig, GetBaseAssetId, GetParliamentAccountId, GetPswapAssetId, - GetSyntheticBaseAssetId, GetValAssetId, GetXorAssetId, GrandpaConfig, ImOnlineId, - IrohaMigrationConfig, KensetsuConfig, LiquiditySourceType, + EthBridgeConfig, ExtendedAssetsConfig, GenesisConfig, GetBaseAssetId, GetParliamentAccountId, + GetPswapAssetId, GetSyntheticBaseAssetId, GetValAssetId, GetXorAssetId, GrandpaConfig, + ImOnlineId, IrohaMigrationConfig, KensetsuConfig, LiquiditySourceType, MulticollateralBondingCurvePoolConfig, PermissionsConfig, PswapDistributionConfig, RewardsConfig, Runtime, SS58Prefix, SessionConfig, Signature, StakerStatus, StakingConfig, SystemConfig, TechAccountId, TechnicalCommitteeConfig, TechnicalConfig, TokensConfig, @@ -1192,6 +1193,10 @@ fn testnet_genesis( VAL, parliament_investment_fund_balance, ), + #[cfg(feature = "wip")] // presto + (presto_account_id.clone(), SBT_PRACS.into(), 1), + #[cfg(feature = "wip")] // presto + (presto_buffer_account_id.clone(), SBT_PRACS.into(), 1), ]; let faucet_config = { let initial_faucet_balance = balance!(6000000000); @@ -1415,7 +1420,7 @@ fn testnet_genesis( None, ), ( - common::AssetId32::from_bytes(hex!( + common::AssetId32::::from_bytes(hex!( "008bcfd2387d3fc453333557eecb0efe59fcba128769b2feefdd306e98e66440" )) .into(), @@ -1505,6 +1510,8 @@ fn testnet_genesis( None, None, ), + ], + regulated_assets: vec![ #[cfg(feature = "wip")] // presto ( PRUSD, @@ -1518,12 +1525,50 @@ fn testnet_genesis( None, ), ], + sbt_assets: vec![ + #[cfg(feature = "wip")] // presto + ( + SBT_PRACS.into_predefined(), + assets_and_permissions_account_id.clone(), + AssetSymbol(b"PRACS".to_vec()), + AssetName(b"Presto Access".to_vec()), + 0, + Balance::zero(), + true, + None, + None, + ), + #[cfg(feature = "wip")] // presto + ( + SBT_PRINVST.into_predefined(), + assets_and_permissions_account_id.clone(), + AssetSymbol(b"PRINVST".to_vec()), + AssetName(b"Presto Investor".to_vec()), + 0, + Balance::zero(), + true, + None, + None, + ), + #[cfg(feature = "wip")] // presto + ( + SBT_PRCRDT.into_predefined(), + assets_and_permissions_account_id.clone(), + AssetSymbol(b"PRCRDT".to_vec()), + AssetName(b"Presto Creditor".to_vec()), + 0, + Balance::zero(), + true, + None, + None, + ), + ], }, permissions: PermissionsConfig { initial_permission_owners: vec![ ( permissions::MANAGE_DEX, - Scope::Limited(hash(&0u32)), + Scope::Unlimited, vec![assets_and_permissions_account_id.clone()], ), ( @@ -1600,6 +1645,30 @@ fn testnet_genesis( Scope::Limited(hash(&PRUSD)), vec![permissions::MINT, permissions::BURN], ), + #[cfg(feature = "wip")] // presto + ( + presto_account_id.clone(), + Scope::Limited(hash(&SBT_PRACS)), + vec![permissions::MINT, permissions::BURN], + ), + #[cfg(feature = "wip")] // presto + ( + presto_account_id.clone(), + Scope::Limited(hash(&SBT_PRINVST)), + vec![permissions::MINT, permissions::BURN], + ), + #[cfg(feature = "wip")] // presto + ( + presto_account_id.clone(), + Scope::Limited(hash(&SBT_PRCRDT)), + vec![permissions::MINT, permissions::BURN], + ), + #[cfg(feature = "wip")] // presto + ( + presto_account_id.clone(), + Scope::Limited(hash(&4u32)), + vec![permissions::MANAGE_DEX], + ), ], }, balances: BalancesConfig { balances }, @@ -1643,11 +1712,17 @@ fn testnet_genesis( DEXInfo { base_asset_id: PRUSD, synthetic_base_asset_id: GetSyntheticBaseAssetId::get(), - is_public: true, + is_public: false, }, ), ], }, + extended_assets: ExtendedAssetsConfig { + assets_metadata: vec![ + #[cfg(feature = "wip")] // presto + (SBT_PRACS.into(), None, PRUSD), + ], + }, faucet: faucet_config, tokens: TokensConfig { balances: tokens_endowed_accounts, @@ -2219,7 +2294,7 @@ fn mainnet_genesis( None, ), ( - common::AssetId32::from_bytes(hex!( + common::AssetId32::::from_bytes(hex!( "008bcfd2387d3fc453333557eecb0efe59fcba128769b2feefdd306e98e66440" )) .into(), @@ -2298,6 +2373,9 @@ fn mainnet_genesis( None, None, ), + ]; + + let regulated_assets = vec![ #[cfg(feature = "wip")] // presto ( PRUSD, @@ -2311,6 +2389,46 @@ fn mainnet_genesis( None, ), ]; + + let sbt_assets = vec![ + #[cfg(feature = "wip")] // presto + ( + SBT_PRACS.into_predefined(), + assets_and_permissions_account_id.clone(), + AssetSymbol(b"PRACS".to_vec()), + AssetName(b"Presto Access".to_vec()), + 0, + Balance::zero(), + true, + None, + None, + ), + #[cfg(feature = "wip")] // presto + ( + SBT_PRINVST.into_predefined(), + assets_and_permissions_account_id.clone(), + AssetSymbol(b"PRINVST".to_vec()), + AssetName(b"Presto Investor".to_vec()), + 0, + Balance::zero(), + true, + None, + None, + ), + #[cfg(feature = "wip")] // presto + ( + SBT_PRCRDT.into_predefined(), + assets_and_permissions_account_id.clone(), + AssetSymbol(b"PRCRDT".to_vec()), + AssetName(b"Presto Creditor".to_vec()), + 0, + Balance::zero(), + true, + None, + None, + ), + ]; + let bridge_assets_data: Vec> = Vec::new(); bridge_assets.extend(bridge_assets_data.iter().map(|x| { AssetConfig::sidechain( @@ -2400,13 +2518,15 @@ fn mainnet_genesis( ..Default::default() }, assets: AssetsConfig { - endowed_assets: endowed_assets, + endowed_assets, + regulated_assets, + sbt_assets, }, permissions: PermissionsConfig { initial_permission_owners: vec![ ( permissions::MANAGE_DEX, - Scope::Limited(hash(&0u32)), + Scope::Unlimited, vec![assets_and_permissions_account_id.clone()], ), ( @@ -2483,6 +2603,30 @@ fn mainnet_genesis( Scope::Limited(hash(&PRUSD)), vec![permissions::MINT, permissions::BURN], ), + #[cfg(feature = "wip")] // presto + ( + presto_account_id.clone(), + Scope::Limited(hash(&SBT_PRACS)), + vec![permissions::MINT, permissions::BURN], + ), + #[cfg(feature = "wip")] // presto + ( + presto_account_id.clone(), + Scope::Limited(hash(&SBT_PRINVST)), + vec![permissions::MINT, permissions::BURN], + ), + #[cfg(feature = "wip")] // presto + ( + presto_account_id.clone(), + Scope::Limited(hash(&SBT_PRCRDT)), + vec![permissions::MINT, permissions::BURN], + ), + #[cfg(feature = "wip")] // presto + ( + presto_account_id.clone(), + Scope::Limited(hash(&4u32)), + vec![permissions::MANAGE_DEX], + ), ], }, balances: BalancesConfig { @@ -2568,11 +2712,17 @@ fn mainnet_genesis( DEXInfo { base_asset_id: PRUSD, synthetic_base_asset_id: GetSyntheticBaseAssetId::get(), - is_public: true, + is_public: false, }, ), ], }, + extended_assets: ExtendedAssetsConfig { + assets_metadata: vec![ + #[cfg(feature = "wip")] // presto + (SBT_PRACS.into(), None, PRUSD), + ], + }, tokens: TokensConfig { balances: vec![ ( @@ -2603,6 +2753,18 @@ fn mainnet_genesis( PSWAP, initial_pswap_market_maker_rewards, ), + #[cfg(feature = "wip")] // presto + ( + presto_account_id, + SBT_PRACS.into(), + 1, + ), + #[cfg(feature = "wip")] // presto + ( + presto_buffer_account_id, + SBT_PRACS.into(), + 1 + ), ], }, trading_pair: TradingPairConfig { diff --git a/pallets/apollo-platform/src/mock.rs b/pallets/apollo-platform/src/mock.rs index e55848b4cf..853fd3f659 100644 --- a/pallets/apollo-platform/src/mock.rs +++ b/pallets/apollo-platform/src/mock.rs @@ -397,6 +397,8 @@ impl ExtBuilder { assets::GenesisConfig:: { endowed_assets: self.endowed_assets, + regulated_assets: Default::default(), + sbt_assets: Default::default(), } .assimilate_storage(&mut t) .unwrap(); diff --git a/pallets/assets/src/lib.rs b/pallets/assets/src/lib.rs index dbfe440c0d..8857ce06cb 100644 --- a/pallets/assets/src/lib.rs +++ b/pallets/assets/src/lib.rs @@ -602,6 +602,28 @@ pub mod pallet { Option, Option, )>, + pub regulated_assets: Vec<( + T::AssetId, + T::AccountId, + AssetSymbol, + AssetName, + BalancePrecision, + Balance, + bool, + Option, + Option, + )>, + pub sbt_assets: Vec<( + T::AssetId, + T::AccountId, + AssetSymbol, + AssetName, + BalancePrecision, + Balance, + bool, + Option, + Option, + )>, } #[cfg(feature = "std")] @@ -609,6 +631,8 @@ pub mod pallet { fn default() -> Self { Self { endowed_assets: Default::default(), + regulated_assets: Default::default(), + sbt_assets: Default::default(), } } } @@ -640,9 +664,63 @@ pub mod pallet { content_source, description, ) - .expect("Failed to register asset."); + .expect("Failed to register regular asset."); + }, + ); + self.regulated_assets.iter().cloned().for_each( + |( + asset_id, + account_id, + symbol, + name, + precision, + initial_supply, + is_mintable, + content_source, + description, + )| { + Pallet::::register_asset_id( + account_id, + asset_id, + symbol, + name, + precision, + initial_supply, + is_mintable, + AssetType::Regulated, + content_source, + description, + ) + .expect("Failed to register regulated asset."); + }, + ); + self.sbt_assets.iter().cloned().for_each( + |( + asset_id, + account_id, + symbol, + name, + precision, + initial_supply, + is_mintable, + content_source, + description, + )| { + Pallet::::register_asset_id( + account_id, + asset_id, + symbol, + name, + precision, + initial_supply, + is_mintable, + AssetType::Soulbound, + content_source, + description, + ) + .expect("Failed to register soulbound asset."); }, - ) + ); } } } diff --git a/pallets/bridge-proxy/src/mock.rs b/pallets/bridge-proxy/src/mock.rs index b72d397226..d8573c382d 100644 --- a/pallets/bridge-proxy/src/mock.rs +++ b/pallets/bridge-proxy/src/mock.rs @@ -302,6 +302,8 @@ pub fn new_tester() -> sp_io::TestExternalities { None, ), ], + regulated_assets: Default::default(), + sbt_assets: Default::default(), } .assimilate_storage(&mut storage) .unwrap(); diff --git a/pallets/ceres-governance-platform/src/mock.rs b/pallets/ceres-governance-platform/src/mock.rs index 971b5101df..ead874c983 100644 --- a/pallets/ceres-governance-platform/src/mock.rs +++ b/pallets/ceres-governance-platform/src/mock.rs @@ -160,6 +160,8 @@ impl ExtBuilder { assets::GenesisConfig:: { endowed_assets: self.endowed_assets, + regulated_assets: Default::default(), + sbt_assets: Default::default(), } .assimilate_storage(&mut t) .unwrap(); diff --git a/pallets/ceres-launchpad/src/mock.rs b/pallets/ceres-launchpad/src/mock.rs index 927994a03e..664608b2f7 100644 --- a/pallets/ceres-launchpad/src/mock.rs +++ b/pallets/ceres-launchpad/src/mock.rs @@ -247,6 +247,8 @@ impl ExtBuilder { assets::GenesisConfig:: { endowed_assets: self.endowed_assets, + regulated_assets: Default::default(), + sbt_assets: Default::default(), } .assimilate_storage(&mut t) .unwrap(); diff --git a/pallets/ceres-staking/src/mock.rs b/pallets/ceres-staking/src/mock.rs index 7e2022d885..620338d9f8 100644 --- a/pallets/ceres-staking/src/mock.rs +++ b/pallets/ceres-staking/src/mock.rs @@ -154,6 +154,8 @@ impl ExtBuilder { assets::GenesisConfig:: { endowed_assets: self.endowed_assets, + regulated_assets: Default::default(), + sbt_assets: Default::default(), } .assimilate_storage(&mut t) .unwrap(); diff --git a/pallets/ceres-token-locker/src/mock.rs b/pallets/ceres-token-locker/src/mock.rs index 8a08707abf..6832196434 100644 --- a/pallets/ceres-token-locker/src/mock.rs +++ b/pallets/ceres-token-locker/src/mock.rs @@ -153,6 +153,8 @@ impl ExtBuilder { assets::GenesisConfig:: { endowed_assets: self.endowed_assets, + regulated_assets: Default::default(), + sbt_assets: Default::default(), } .assimilate_storage(&mut t) .unwrap(); diff --git a/pallets/eth-bridge/src/tests/mock.rs b/pallets/eth-bridge/src/tests/mock.rs index aa50ec607f..41cbf89011 100644 --- a/pallets/eth-bridge/src/tests/mock.rs +++ b/pallets/eth-bridge/src/tests/mock.rs @@ -835,6 +835,8 @@ impl ExtBuilder { AssetsConfig { endowed_assets: endowed_assets.into_iter().collect(), + regulated_assets: Default::default(), + sbt_assets: Default::default(), } .assimilate_storage(&mut storage) .unwrap(); diff --git a/pallets/extended-assets/Cargo.toml b/pallets/extended-assets/Cargo.toml index 80efe2cfe8..e585f5d386 100644 --- a/pallets/extended-assets/Cargo.toml +++ b/pallets/extended-assets/Cargo.toml @@ -1,10 +1,10 @@ [package] -authors = ["Polka Biome Ltd. "] +name = "extended-assets" +authors = ["Soramitsu"] license = "BSD-4-Clause" homepage = "https://sora.org" repository = "https://github.com/sora-xor/sora2-network" edition = "2021" -name = "extended-assets" version = "1.0.0" [package.metadata.docs.rs] @@ -42,13 +42,19 @@ technical = { path = "../technical" } default = ["std"] std = [ - "scale-info/std", + "codec/std", + "common/std", "frame-support/std", "frame-benchmarking/std", "frame-system/std", + "pallet-balances/std", "pallet-timestamp/std", + "permissions/std", + "scale-info/std", "sp-core/std", + "sp-runtime/std", "sp-std/std", + "technical/std", ] runtime-benchmarks = [ diff --git a/pallets/extended-assets/src/lib.rs b/pallets/extended-assets/src/lib.rs index 62ec314622..490b29a75b 100644 --- a/pallets/extended-assets/src/lib.rs +++ b/pallets/extended-assets/src/lib.rs @@ -53,10 +53,11 @@ pub mod weights; use codec::{Decode, Encode, MaxEncodedLen}; use common::{ - permissions::{PermissionId, TRANSFER}, + permissions::{PermissionId, BURN, MINT, TRANSFER}, AssetIdOf, AssetInfoProvider, AssetManager, AssetName, AssetRegulator, AssetSymbol, AssetType, - BalancePrecision, ContentSource, Description, IsValid, + BalancePrecision, ContentSource, Description, ExtendedAssetsManager, IsValid, }; +use frame_support::ensure; use frame_support::sp_runtime::DispatchError; use frame_support::BoundedBTreeSet; use sp_core::Get; @@ -71,11 +72,11 @@ pub use pallet::*; #[scale_info(skip_type_params(MaxRegulatedAssetsPerSBT))] pub struct SoulboundTokenMetadata> { /// External link of issued place - external_url: Option, + pub external_url: Option, /// Issuance Timestamp - issued_at: Moment, + pub issued_at: Moment, /// List of regulated assets permissioned by this token - regulated_assets: BoundedBTreeSet, + pub regulated_assets: BoundedBTreeSet, } #[frame_support::pallet] @@ -86,6 +87,7 @@ pub mod pallet { use frame_support::pallet_prelude::{OptionQuery, ValueQuery, *}; use frame_support::traits::StorageVersion; use frame_system::pallet_prelude::*; + use sp_core::TryCollect; #[pallet::config] pub trait Config: @@ -218,13 +220,7 @@ pub mod pallet { description.clone(), )?; - let metadata = SoulboundTokenMetadata { - external_url: external_url.clone(), - issued_at: now_timestamp, - regulated_assets: Default::default(), - }; - - >::insert(sbt_asset_id, metadata); + Self::set_metadata(&sbt_asset_id, external_url.clone(), now_timestamp); Self::deposit_event(Event::SoulboundTokenIssued { asset_id: sbt_asset_id, @@ -300,39 +296,18 @@ pub mod pallet { ) -> DispatchResult { let who = ensure_signed(origin)?; - // Ensure the asset exists and is an SBT - Self::soulbound_asset(sbt_asset_id).ok_or(Error::::SBTNotFound)?; - // Ensure the caller is the owner of the SBT ensure!( ::AssetInfoProvider::is_asset_owner(&sbt_asset_id, &who), Error::::NotSBTOwner ); - Self::check_regulated_assets_for_binding(®ulated_asset_id, &who)?; - - // In case the regulated asset is already bound to another SBT, we need to unbind it - // by removing it from the previous SBT's regulated assets list. - if >::contains_key(regulated_asset_id) { - let previous_sbt = Self::regulated_asset_to_sbt(regulated_asset_id); - >::mutate(previous_sbt, |metadata| { - if let Some(metadata) = metadata { - metadata.regulated_assets.remove(®ulated_asset_id); - } - }); - } + ensure!( + ::AssetInfoProvider::is_asset_owner(®ulated_asset_id, &who), + Error::::RegulatedAssetNoOwnedBySBTIssuer + ); - // Bind the regulated asset to the SBT and update the SBT's metadata - >::set(regulated_asset_id, sbt_asset_id); - >::try_mutate(sbt_asset_id, |metadata| -> DispatchResult { - if let Some(metadata) = metadata { - metadata - .regulated_assets - .try_insert(regulated_asset_id) - .map_err(|_| Error::::RegulatedAssetsPerSBTExceeded)?; - } - Ok(()) - })?; + Self::bind_regulated_asset_to_sbt_asset(&sbt_asset_id, ®ulated_asset_id)?; Self::deposit_event(Event::RegulatedAssetBoundToSBT { regulated_asset_id, @@ -450,27 +425,44 @@ pub mod pallet { #[pallet::getter(fn sbt_asset_expiration)] pub type SBTExpiration = StorageDoubleMap<_, Identity, T::AccountId, Identity, AssetIdOf, T::Moment, OptionQuery>; -} -impl Pallet { - pub fn check_regulated_assets_for_binding( - regulated_asset_id: &AssetIdOf, - sbt_issuer: &T::AccountId, - ) -> Result<(), Error> { - let is_asset_owner = - ::AssetInfoProvider::is_asset_owner(regulated_asset_id, sbt_issuer); + #[pallet::genesis_config] + pub struct GenesisConfig { + pub assets_metadata: Vec<(AssetIdOf, Option, AssetIdOf)>, + } - if !is_asset_owner { - return Err(Error::::RegulatedAssetNoOwnedBySBTIssuer); + #[cfg(feature = "std")] + impl Default for GenesisConfig { + fn default() -> Self { + Self { + assets_metadata: Default::default(), + } } + } - if !Self::is_asset_regulated(regulated_asset_id) { - return Err(Error::::AssetNotRegulated); + #[pallet::genesis_build] + impl GenesisBuild for GenesisConfig { + fn build(&self) { + self.assets_metadata.iter().cloned().for_each( + |(sbt_asset_id, external_url, regulated_asset)| { + let metadata = SoulboundTokenMetadata { + external_url, + issued_at: Timestamp::::now(), + regulated_assets: vec![regulated_asset] + .into_iter() + .try_collect() + .expect("Failed to bind regulated assets with soulbound asset."), + }; + + >::insert(sbt_asset_id, metadata); + >::set(regulated_asset, sbt_asset_id); + }, + ); } - - Ok(()) } +} +impl Pallet { pub fn check_account_has_valid_sbt_for_regulated_asset( account_id: &T::AccountId, regulated_asset_id: &AssetIdOf, @@ -494,6 +486,58 @@ impl Pallet { let asset_type = ::AssetInfoProvider::get_asset_type(asset_id); asset_type == AssetType::Regulated } + + pub fn set_metadata( + sbt_asset_id: &AssetIdOf, + external_url: Option, + issued_at: T::Moment, + ) { + let metadata = SoulboundTokenMetadata { + external_url, + issued_at, + regulated_assets: Default::default(), + }; + + >::insert(sbt_asset_id, metadata); + } + + pub fn bind_regulated_asset_to_sbt_asset( + sbt_asset_id: &AssetIdOf, + regulated_asset_id: &AssetIdOf, + ) -> Result<(), DispatchError> { + // Ensure the asset exists and is an SBT + Self::soulbound_asset(sbt_asset_id).ok_or(Error::::SBTNotFound)?; + + ensure!( + Self::is_asset_regulated(regulated_asset_id), + Error::::AssetNotRegulated + ); + + // In case the regulated asset is already bound to another SBT, we need to unbind it + // by removing it from the previous SBT's regulated assets list. + if >::contains_key(regulated_asset_id) { + let previous_sbt = Self::regulated_asset_to_sbt(regulated_asset_id); + >::mutate(previous_sbt, |metadata| { + if let Some(metadata) = metadata { + metadata.regulated_assets.remove(regulated_asset_id); + } + }); + } + + // Bind the regulated asset to the SBT and update the SBT's metadata + >::set(regulated_asset_id, *sbt_asset_id); + >::try_mutate(sbt_asset_id, |metadata| -> Result<(), DispatchError> { + if let Some(metadata) = metadata { + metadata + .regulated_assets + .try_insert(*regulated_asset_id) + .map_err(|_| Error::::RegulatedAssetsPerSBTExceeded)?; + } + Ok(()) + })?; + + Ok(()) + } } impl AssetRegulator, AssetIdOf> for Pallet { @@ -517,10 +561,13 @@ impl AssetRegulator, AssetIdOf> for Pallet { if is_asset_owner { // Asset owner of the SBT can do all asset operations except transfer - if permission_id == &TRANSFER { + if *permission_id == TRANSFER { return Err(Error::::SoulboundAssetNotTransferable.into()); } return Ok(()); + } else if *permission_id == MINT || *permission_id == BURN { + // These persmissions are checked in `permissions` pallet + return Ok(()); } else { return Err(Error::::SoulboundAssetNotOperationable.into()); } @@ -554,3 +601,20 @@ impl AssetRegulator, AssetIdOf> for Pallet { Ok(()) } } + +impl ExtendedAssetsManager, T::Moment, ContentSource> for Pallet { + fn set_metadata( + sbt_asset_id: &AssetIdOf, + external_url: Option, + issued_at: T::Moment, + ) { + Self::set_metadata(sbt_asset_id, external_url, issued_at); + } + + fn bind_regulated_asset_to_sbt_asset( + sbt_asset_id: &AssetIdOf, + regulated_asset_id: &AssetIdOf, + ) -> Result<(), DispatchError> { + Self::bind_regulated_asset_to_sbt_asset(sbt_asset_id, regulated_asset_id) + } +} diff --git a/pallets/farming/src/mock.rs b/pallets/farming/src/mock.rs index 1ed803af40..6caf4c78c6 100644 --- a/pallets/farming/src/mock.rs +++ b/pallets/farming/src/mock.rs @@ -362,6 +362,8 @@ impl ExtBuilder { None, ), ], + regulated_assets: Default::default(), + sbt_assets: Default::default(), } .assimilate_storage(&mut t) .unwrap(); diff --git a/pallets/faucet/src/mock.rs b/pallets/faucet/src/mock.rs index 012c5a03d1..5e535ac7d7 100644 --- a/pallets/faucet/src/mock.rs +++ b/pallets/faucet/src/mock.rs @@ -176,6 +176,8 @@ impl ExtBuilder { None, ), ], + regulated_assets: Default::default(), + sbt_assets: Default::default(), } .assimilate_storage(&mut t) .unwrap(); diff --git a/pallets/hermes-governance-platform/src/mock.rs b/pallets/hermes-governance-platform/src/mock.rs index c125b28e0c..465b50cfbe 100644 --- a/pallets/hermes-governance-platform/src/mock.rs +++ b/pallets/hermes-governance-platform/src/mock.rs @@ -185,6 +185,8 @@ impl ExtBuilder { assets::GenesisConfig:: { endowed_assets: self.endowed_assets, + regulated_assets: Default::default(), + sbt_assets: Default::default(), } .assimilate_storage(&mut t) .unwrap(); diff --git a/pallets/iroha-migration/src/mock.rs b/pallets/iroha-migration/src/mock.rs index efdd8943a8..c65bb1d10f 100644 --- a/pallets/iroha-migration/src/mock.rs +++ b/pallets/iroha-migration/src/mock.rs @@ -146,6 +146,8 @@ pub fn test_ext(add_iroha_accounts: bool) -> sp_io::TestExternalities { None, None, )], + regulated_assets: Default::default(), + sbt_assets: Default::default(), } .assimilate_storage(&mut t) .unwrap(); diff --git a/pallets/kensetsu/src/mock.rs b/pallets/kensetsu/src/mock.rs index 4784228152..d411a52141 100644 --- a/pallets/kensetsu/src/mock.rs +++ b/pallets/kensetsu/src/mock.rs @@ -495,6 +495,8 @@ pub fn new_test_ext() -> sp_io::TestExternalities { None, ), ], + regulated_assets: Default::default(), + sbt_assets: Default::default(), } .assimilate_storage(&mut storage) .unwrap(); diff --git a/pallets/liquidity-proxy/benchmarking/src/mock.rs b/pallets/liquidity-proxy/benchmarking/src/mock.rs index 8b6ec4c5cf..a182ef49b1 100644 --- a/pallets/liquidity-proxy/benchmarking/src/mock.rs +++ b/pallets/liquidity-proxy/benchmarking/src/mock.rs @@ -491,6 +491,8 @@ impl ExtBuilder { AssetsConfig { endowed_assets: self.endowed_assets, + regulated_assets: Default::default(), + sbt_assets: Default::default(), } .assimilate_storage(&mut t) .unwrap(); diff --git a/pallets/liquidity-proxy/src/mock.rs b/pallets/liquidity-proxy/src/mock.rs index 21d0cca043..14ff209adb 100644 --- a/pallets/liquidity-proxy/src/mock.rs +++ b/pallets/liquidity-proxy/src/mock.rs @@ -904,6 +904,8 @@ impl ExtBuilder { ) }) .collect(), + regulated_assets: Default::default(), + sbt_assets: Default::default(), } .assimilate_storage(&mut t) .unwrap(); diff --git a/pallets/multicollateral-bonding-curve-pool/src/mock.rs b/pallets/multicollateral-bonding-curve-pool/src/mock.rs index a5ce5af707..48c8e5a348 100644 --- a/pallets/multicollateral-bonding-curve-pool/src/mock.rs +++ b/pallets/multicollateral-bonding-curve-pool/src/mock.rs @@ -852,6 +852,8 @@ impl ExtBuilder { ) }) .collect(), + regulated_assets: Default::default(), + sbt_assets: Default::default(), } .assimilate_storage(&mut t) .unwrap(); diff --git a/pallets/order-book/Cargo.toml b/pallets/order-book/Cargo.toml index c092ea8235..12c287aaa6 100644 --- a/pallets/order-book/Cargo.toml +++ b/pallets/order-book/Cargo.toml @@ -67,8 +67,3 @@ private-net = [ ] test = [] - -wip = [ - "framenode-chain-spec/wip", - "framenode-runtime/wip", -] diff --git a/pallets/order-book/src/lib.rs b/pallets/order-book/src/lib.rs index 8b90fda050..15b5a49f7f 100644 --- a/pallets/order-book/src/lib.rs +++ b/pallets/order-book/src/lib.rs @@ -654,7 +654,7 @@ pub mod pallet { LiquiditySourceType::OrderBook, )?; - Self::deregister_tech_account(order_book_id)?; + Self::deregister_tech_account(&order_book_id)?; >::remove(order_book_id); Self::deposit_event(Event::::OrderBookDeleted { order_book_id }); @@ -992,7 +992,7 @@ pub mod pallet { impl CurrencyLocker, T::DEXId, DispatchError> for Pallet { fn lock_liquidity( account: &T::AccountId, - order_book_id: OrderBookId, T::DEXId>, + order_book_id: &OrderBookId, T::DEXId>, asset_id: &AssetIdOf, amount: OrderVolume, ) -> Result<(), DispatchError> { @@ -1006,7 +1006,7 @@ impl CurrencyUnlocker, T::DEXId, DispatchE { fn unlock_liquidity( account: &T::AccountId, - order_book_id: OrderBookId, T::DEXId>, + order_book_id: &OrderBookId, T::DEXId>, asset_id: &AssetIdOf, amount: OrderVolume, ) -> Result<(), DispatchError> { @@ -1015,7 +1015,7 @@ impl CurrencyUnlocker, T::DEXId, DispatchE } fn unlock_liquidity_batch( - order_book_id: OrderBookId, T::DEXId>, + order_book_id: &OrderBookId, T::DEXId>, asset_id: &AssetIdOf, receivers: &BTreeMap, ) -> Result<(), DispatchError> { @@ -1152,9 +1152,9 @@ impl Delegate, T::OrderId, T::DEXId, Momen impl Pallet { pub fn tech_account_for_order_book( - order_book_id: OrderBookId, T::DEXId>, + order_book_id: &OrderBookId, T::DEXId>, ) -> ::TechAccountId { - let trading_pair: TradingPair> = order_book_id.into(); + let trading_pair: TradingPair> = (*order_book_id).into(); // Same as in xyk accounts let tech_pair = trading_pair.map(|a| a.into()); ::TechAccountId::to_order_tech_unit_from_dex_and_trading_pair( @@ -1166,7 +1166,7 @@ impl Pallet { /// Validity of asset ids (for example, to have the same base asset /// for dex and pair) should be done beforehand pub fn register_tech_account( - order_book_id: OrderBookId, T::DEXId>, + order_book_id: &OrderBookId, T::DEXId>, ) -> Result<(), DispatchError> { let tech_account = Self::tech_account_for_order_book(order_book_id); technical::Pallet::::register_tech_account_id(tech_account) @@ -1175,7 +1175,7 @@ impl Pallet { /// Validity of asset ids (for example, to have the same base asset /// for dex and pair) should be done beforehand pub fn deregister_tech_account( - order_book_id: OrderBookId, T::DEXId>, + order_book_id: &OrderBookId, T::DEXId>, ) -> Result<(), DispatchError> { let tech_account = Self::tech_account_for_order_book(order_book_id); technical::Pallet::::deregister_tech_account_id(tech_account) @@ -1338,7 +1338,7 @@ impl Pallet { ) }; >::insert(order_book_id, order_book); - Self::register_tech_account(*order_book_id) + Self::register_tech_account(order_book_id) } pub fn inner_create_orderbook( @@ -1431,6 +1431,14 @@ impl OrderBookManager, T::DEXId, MomentOf< Self::assemble_order_book_id(dex_id, input_asset_id, output_asset_id) } + fn tech_account_id_for_order_book( + order_book_id: &OrderBookId, T::DEXId>, + ) -> Result { + let tech_account = Self::tech_account_for_order_book(order_book_id); + let account_id = technical::Pallet::::tech_account_id_to_account_id(&tech_account)?; + Ok(account_id) + } + fn initialize_orderbook( order_book_id: &OrderBookId, T::DEXId>, tick_size: Balance, diff --git a/pallets/order-book/src/tests/extrinsics.rs b/pallets/order-book/src/tests/extrinsics.rs index 22ba957020..36a24636e6 100644 --- a/pallets/order-book/src/tests/extrinsics.rs +++ b/pallets/order-book/src/tests/extrinsics.rs @@ -30,8 +30,6 @@ use crate::test_utils::*; use assets::AssetIdOf; -#[cfg(feature = "wip")] // presto -use common::PRUSD; use common::{ balance, AssetId32, AssetName, AssetSymbol, Balance, OrderBookId, PriceVariant, DEFAULT_BALANCE_PRECISION, ETH, KUSD, PSWAP, VAL, VXOR, XOR, XST, XSTUSD, @@ -188,45 +186,6 @@ fn should_create_order_book_with_correct_dex_id_polkaswap_vxor() { }); } -#[cfg(feature = "wip")] // presto -#[test] -fn should_create_order_book_with_correct_dex_id_polkaswap_prusd() { - ext().execute_with(|| { - let order_book_id = OrderBookId::, DEXId> { - dex_id: common::DEXId::PolkaswapPresto.into(), - base: VAL, - quote: PRUSD, - }; - - assert_ok!(TradingPair::register( - RawOrigin::Signed(accounts::alice::()).into(), - order_book_id.dex_id, - order_book_id.quote, - order_book_id.base - )); - - assert_ok!(OrderBookPallet::create_orderbook( - RawOrigin::Root.into(), - order_book_id, - balance!(0.00001), - balance!(0.00001), - balance!(1), - balance!(1000) - )); - - assert_eq!( - OrderBookPallet::order_books(order_book_id).unwrap(), - OrderBook::new( - order_book_id, - OrderPrice::divisible(balance!(0.00001)), - OrderVolume::divisible(balance!(0.00001)), - OrderVolume::divisible(balance!(1)), - OrderVolume::divisible(balance!(1000)) - ) - ); - }); -} - #[test] fn should_not_create_order_book_with_same_assets() { ext().execute_with(|| { @@ -285,27 +244,6 @@ fn should_not_create_order_book_with_wrong_quote_asset() { OrderBookPallet::create_orderbook(RawOrigin::Root.into(), order_book_id, 0, 0, 0, 0), E::NotAllowedQuoteAsset ); - - #[cfg(feature = "wip")] // presto - { - let order_book_id = OrderBookId::, DEXId> { - dex_id: common::DEXId::PolkaswapPresto.into(), - base: VAL, - quote: XOR, - }; - - assert_err!( - OrderBookPallet::create_orderbook( - RawOrigin::Root.into(), - order_book_id, - 0, - 0, - 0, - 0 - ), - E::NotAllowedQuoteAsset - ); - } }); } @@ -827,7 +765,7 @@ fn should_delete_order_book() { let owner = accounts::bob::(); let tech_account = technical::Pallet::::tech_account_id_to_account_id( - &OrderBookPallet::tech_account_for_order_book(order_book_id), + &OrderBookPallet::tech_account_for_order_book(&order_book_id), ) .unwrap(); diff --git a/pallets/order-book/src/tests/order_book.rs b/pallets/order-book/src/tests/order_book.rs index 5cfdca4de2..17c6dd38ee 100644 --- a/pallets/order-book/src/tests/order_book.rs +++ b/pallets/order-book/src/tests/order_book.rs @@ -217,7 +217,7 @@ fn should_place_nft_limit_order() { OrderVolume::indivisible(1000), ); - OrderBookPallet::register_tech_account(order_book_id).unwrap(); + OrderBookPallet::register_tech_account(&order_book_id).unwrap(); let order_id = 11; let price = balance!(10).into(); @@ -652,7 +652,7 @@ fn should_not_place_limit_order_when_status_doesnt_allow() { OrderVolume::divisible(balance!(1)), OrderVolume::divisible(balance!(1000)), ); - OrderBookPallet::register_tech_account(order_book_id).unwrap(); + OrderBookPallet::register_tech_account(&order_book_id).unwrap(); fill_balance::(accounts::alice::(), order_book_id); @@ -834,7 +834,7 @@ fn should_not_place_limit_order_that_doesnt_meet_restrictions_for_user() { OrderVolume::divisible(balance!(1)), OrderVolume::divisible(balance!(1000)), ); - OrderBookPallet::register_tech_account(order_book_id).unwrap(); + OrderBookPallet::register_tech_account(&order_book_id).unwrap(); fill_balance::(accounts::alice::(), order_book_id); @@ -899,7 +899,7 @@ fn should_not_place_limit_order_that_doesnt_meet_restrictions_for_orders_in_pric OrderVolume::divisible(balance!(1000)), ); - OrderBookPallet::register_tech_account(order_book_id).unwrap(); + OrderBookPallet::register_tech_account(&order_book_id).unwrap(); let max_orders_for_price: u32 = ::MaxLimitOrdersForPrice::get(); let mut buy_order = LimitOrder::::new( @@ -976,7 +976,7 @@ fn should_not_place_limit_order_that_doesnt_meet_restrictions_for_side() { OrderVolume::divisible(balance!(1)), OrderVolume::divisible(balance!(1000)), ); - OrderBookPallet::register_tech_account(order_book_id).unwrap(); + OrderBookPallet::register_tech_account(&order_book_id).unwrap(); let max_prices_for_side: u32 = ::MaxSidePriceCount::get(); let mut buy_order = LimitOrder::::new( @@ -1236,7 +1236,7 @@ fn should_cancel_all_limit_orders() { let order_book = create_and_fill_order_book::(order_book_id); let tech_account = technical::Pallet::::tech_account_id_to_account_id( - &OrderBookPallet::tech_account_for_order_book(order_book_id), + &OrderBookPallet::tech_account_for_order_book(&order_book_id), ) .unwrap(); diff --git a/pallets/order-book/src/tests/pallet.rs b/pallets/order-book/src/tests/pallet.rs index f6d93c2c5d..239495f7f6 100644 --- a/pallets/order-book/src/tests/pallet.rs +++ b/pallets/order-book/src/tests/pallet.rs @@ -84,12 +84,12 @@ fn should_register_technical_account() { // register (on order book creation) for order_book_id in order_books { - assert_ok!(OrderBookPallet::register_tech_account(order_book_id)); + assert_ok!(OrderBookPallet::register_tech_account(&order_book_id)); } // deregister (on order book removal) for order_book_id in order_books { - assert_ok!(OrderBookPallet::deregister_tech_account(order_book_id)); + assert_ok!(OrderBookPallet::deregister_tech_account(&order_book_id)); } }); } @@ -104,7 +104,7 @@ fn test_lock_unlock_same_account( assert_ok!(OrderBookPallet::lock_liquidity( account, - order_book_id, + &order_book_id, asset_id, amount_to_lock.into() )); @@ -114,7 +114,7 @@ fn test_lock_unlock_same_account( assert_ok!(OrderBookPallet::unlock_liquidity( account, - order_book_id, + &order_book_id, asset_id, amount_to_lock.into() )); @@ -135,7 +135,7 @@ fn test_lock_unlock_other_account( assert_ok!(OrderBookPallet::lock_liquidity( lock_account, - order_book_id, + &order_book_id, asset_id, amount_to_lock.into() )); @@ -148,7 +148,7 @@ fn test_lock_unlock_other_account( assert_ok!(OrderBookPallet::unlock_liquidity( unlock_account, - order_book_id, + &order_book_id, asset_id, amount_to_lock.into() )); @@ -174,7 +174,7 @@ fn test_lock_unlock_other_accounts( assert_ok!(OrderBookPallet::lock_liquidity( lock_account, - order_book_id, + &order_book_id, asset_id, amount_to_lock.into() )); @@ -194,7 +194,7 @@ fn test_lock_unlock_other_accounts( ]); assert_ok!(OrderBookPallet::unlock_liquidity_batch( - order_book_id, + &order_book_id, asset_id, &unlocks )); @@ -229,7 +229,7 @@ fn should_lock_unlock_base_asset() { base: VAL, quote: XOR, }; - OrderBookPallet::register_tech_account(order_book_id).unwrap(); + OrderBookPallet::register_tech_account(&order_book_id).unwrap(); // Alice -> Alice (expected on order cancellation) test_lock_unlock_same_account( @@ -277,7 +277,7 @@ fn should_lock_unlock_other_asset() { base: VAL, quote: XOR, }; - OrderBookPallet::register_tech_account(order_book_id).unwrap(); + OrderBookPallet::register_tech_account(&order_book_id).unwrap(); // Alice -> Alice (expected on order cancellation) test_lock_unlock_same_account( @@ -323,7 +323,7 @@ fn should_lock_unlock_indivisible_nft() { base: nft, quote: XOR, }; - OrderBookPallet::register_tech_account(order_book_id).unwrap(); + OrderBookPallet::register_tech_account(&order_book_id).unwrap(); // Alice -> Alice (expected on order cancellation) test_lock_unlock_same_account(order_book_id, &nft, 1, &accounts::alice::()); @@ -364,7 +364,7 @@ fn should_lock_unlock_multiple_indivisible_nfts() { base: nft, quote: XOR, }; - OrderBookPallet::register_tech_account(order_book_id).unwrap(); + OrderBookPallet::register_tech_account(&order_book_id).unwrap(); // Alice -> Bob & Charlie test_lock_unlock_other_accounts( @@ -395,12 +395,12 @@ fn should_not_lock_insufficient_base_asset() { base: VAL, quote: XOR, }; - OrderBookPallet::register_tech_account(order_book_id).unwrap(); + OrderBookPallet::register_tech_account(&order_book_id).unwrap(); assert_err!( OrderBookPallet::lock_liquidity( &accounts::alice::(), - order_book_id, + &order_book_id, &XOR, amount_to_lock.into() ), @@ -426,12 +426,12 @@ fn should_not_lock_insufficient_other_asset() { base: VAL, quote: XOR, }; - OrderBookPallet::register_tech_account(order_book_id).unwrap(); + OrderBookPallet::register_tech_account(&order_book_id).unwrap(); assert_err!( OrderBookPallet::lock_liquidity( &accounts::alice::(), - order_book_id, + &order_book_id, &VAL, amount_to_lock.into() ), @@ -465,12 +465,12 @@ fn should_not_lock_insufficient_nft() { base: nft, quote: XOR, }; - OrderBookPallet::register_tech_account(order_book_id).unwrap(); + OrderBookPallet::register_tech_account(&order_book_id).unwrap(); assert_err!( OrderBookPallet::lock_liquidity( &caller, - order_book_id, + &order_book_id, &nft, OrderVolume::indivisible(1) ), @@ -497,11 +497,11 @@ fn should_not_unlock_more_base_that_tech_account_has() { base: VAL, quote: XOR, }; - OrderBookPallet::register_tech_account(order_book_id).unwrap(); + OrderBookPallet::register_tech_account(&order_book_id).unwrap(); assert_ok!(OrderBookPallet::lock_liquidity( &accounts::alice::(), - order_book_id, + &order_book_id, &XOR, amount_to_lock.into() )); @@ -509,7 +509,7 @@ fn should_not_unlock_more_base_that_tech_account_has() { assert_err!( OrderBookPallet::unlock_liquidity( &accounts::alice::(), - order_book_id, + &order_book_id, &XOR, amount_to_try_unlock.into() ), @@ -536,11 +536,11 @@ fn should_not_unlock_more_other_that_tech_account_has() { base: VAL, quote: XOR, }; - OrderBookPallet::register_tech_account(order_book_id).unwrap(); + OrderBookPallet::register_tech_account(&order_book_id).unwrap(); assert_ok!(OrderBookPallet::lock_liquidity( &accounts::alice::(), - order_book_id, + &order_book_id, &VAL, amount_to_lock.into() )); @@ -548,7 +548,7 @@ fn should_not_unlock_more_other_that_tech_account_has() { assert_err!( OrderBookPallet::unlock_liquidity( &accounts::alice::(), - order_book_id, + &order_book_id, &VAL, amount_to_try_unlock.into() ), @@ -582,12 +582,12 @@ fn should_not_unlock_more_nft_that_tech_account_has() { base: nft, quote: XOR, }; - OrderBookPallet::register_tech_account(order_book_id).unwrap(); + OrderBookPallet::register_tech_account(&order_book_id).unwrap(); assert_err!( OrderBookPallet::unlock_liquidity( &accounts::alice::(), - order_book_id, + &order_book_id, &nft, OrderVolume::indivisible(1) ), diff --git a/pallets/order-book/src/tests/types.rs b/pallets/order-book/src/tests/types.rs index dd1e37ad16..9c68e2d74d 100644 --- a/pallets/order-book/src/tests/types.rs +++ b/pallets/order-book/src/tests/types.rs @@ -661,7 +661,7 @@ fn check_payment_execute_all() { quote: XOR, }; - OrderBookPallet::register_tech_account(order_book_id).unwrap(); + OrderBookPallet::register_tech_account(&order_book_id).unwrap(); fill_balance::(accounts::alice::(), order_book_id); fill_balance::(accounts::bob::(), order_book_id); diff --git a/pallets/order-book/src/traits.rs b/pallets/order-book/src/traits.rs index a4ca1e0807..f4b5787a80 100644 --- a/pallets/order-book/src/traits.rs +++ b/pallets/order-book/src/traits.rs @@ -194,7 +194,7 @@ pub trait CurrencyLocker { /// The assets are taken from `account`. fn lock_liquidity( account: &AccountId, - order_book_id: OrderBookId, + order_book_id: &OrderBookId, asset_id: &AssetId, amount: OrderVolume, ) -> Result<(), Error>; @@ -205,13 +205,13 @@ pub trait CurrencyUnlocker { /// The assets are taken from `account`. fn unlock_liquidity( account: &AccountId, - order_book_id: OrderBookId, + order_book_id: &OrderBookId, asset_id: &AssetId, amount: OrderVolume, ) -> Result<(), Error>; fn unlock_liquidity_batch( - order_book_id: OrderBookId, + order_book_id: &OrderBookId, asset_id: &AssetId, receivers: &BTreeMap, ) -> Result<(), Error>; diff --git a/pallets/order-book/src/types.rs b/pallets/order-book/src/types.rs index 3b68646a42..9b79cbf388 100644 --- a/pallets/order-book/src/types.rs +++ b/pallets/order-book/src/types.rs @@ -299,7 +299,7 @@ where { for (asset_id, from_whom) in self.to_lock.iter() { for (account, amount) in from_whom.iter() { - Locker::lock_liquidity(account, self.order_book_id, asset_id, *amount)?; + Locker::lock_liquidity(account, &self.order_book_id, asset_id, *amount)?; } } @@ -311,7 +311,7 @@ where Unlocker: CurrencyUnlocker, { for (asset_id, to_whom) in self.to_unlock.iter() { - Unlocker::unlock_liquidity_batch(self.order_book_id, asset_id, to_whom)?; + Unlocker::unlock_liquidity_batch(&self.order_book_id, asset_id, to_whom)?; } Ok(()) diff --git a/pallets/pool-xyk/src/mock.rs b/pallets/pool-xyk/src/mock.rs index 3529852157..bf78712c5b 100644 --- a/pallets/pool-xyk/src/mock.rs +++ b/pallets/pool-xyk/src/mock.rs @@ -334,6 +334,8 @@ impl ExtBuilder { ) }) .collect(), + regulated_assets: Default::default(), + sbt_assets: Default::default(), } .assimilate_storage(&mut t) .unwrap(); diff --git a/pallets/presto/Cargo.toml b/pallets/presto/Cargo.toml index d32d3b183a..583f564568 100644 --- a/pallets/presto/Cargo.toml +++ b/pallets/presto/Cargo.toml @@ -31,6 +31,7 @@ hex-literal = "0.4.1" common = { path = "../../common", features = ["test"] } currencies = { git = "https://github.com/open-web3-stack/open-runtime-module-library.git", package = "orml-currencies", default-features = false } dex-manager = { path = "../dex-manager", default-features = false } +extended-assets = { path = "../extended-assets", default-features = false } order-book = { path = "../order-book", default-features = false } pallet-balances = { git = "https://github.com/sora-xor/substrate.git", branch = "polkadot-v0.9.38", default-features = false } pallet-timestamp = { git = "https://github.com/sora-xor/substrate.git", branch = "polkadot-v0.9.38", default-features = false } @@ -47,6 +48,7 @@ std = [ "codec/std", "currencies/std", "dex-manager/std", + "extended-assets/std", "frame-support/std", "frame-system/std", "pallet-balances/std", diff --git a/pallets/presto/src/benchmarking.rs b/pallets/presto/src/benchmarking.rs index 962551531d..298f320a9c 100644 --- a/pallets/presto/src/benchmarking.rs +++ b/pallets/presto/src/benchmarking.rs @@ -109,6 +109,48 @@ benchmarks! { assert_last_event::(Event::::AuditorRemoved { auditor: alice::() }.into()); } + apply_investor_kyc { + Pallet::::add_presto_manager(RawOrigin::Root.into(), alice::()).unwrap(); + }: { + Pallet::::apply_investor_kyc(RawOrigin::Signed(alice::()).into(), bob::()).unwrap(); + } + verify { + assert_eq!(Assets::::free_balance(&T::PrestoKycAssetId::get(), &bob::()).unwrap(), 1); + assert_eq!(Assets::::free_balance(&T::PrestoKycInvestorAssetId::get(), &bob::()).unwrap(), 1); + } + + apply_creditor_kyc { + Pallet::::add_presto_manager(RawOrigin::Root.into(), alice::()).unwrap(); + }: { + Pallet::::apply_creditor_kyc(RawOrigin::Signed(alice::()).into(), bob::()).unwrap(); + } + verify { + assert_eq!(Assets::::free_balance(&T::PrestoKycAssetId::get(), &bob::()).unwrap(), 1); + assert_eq!(Assets::::free_balance(&T::PrestoKycCreditorAssetId::get(), &bob::()).unwrap(), 1); + } + + remove_investor_kyc { + Pallet::::add_presto_manager(RawOrigin::Root.into(), alice::()).unwrap(); + Pallet::::apply_investor_kyc(RawOrigin::Signed(alice::()).into(), bob::()).unwrap(); + }: { + Pallet::::remove_investor_kyc(RawOrigin::Signed(alice::()).into(), bob::()).unwrap(); + } + verify { + assert_eq!(Assets::::free_balance(&T::PrestoKycAssetId::get(), &bob::()).unwrap(), 0); + assert_eq!(Assets::::free_balance(&T::PrestoKycInvestorAssetId::get(), &bob::()).unwrap(), 0); + } + + remove_creditor_kyc { + Pallet::::add_presto_manager(RawOrigin::Root.into(), alice::()).unwrap(); + Pallet::::apply_creditor_kyc(RawOrigin::Signed(alice::()).into(), bob::()).unwrap(); + }: { + Pallet::::remove_creditor_kyc(RawOrigin::Signed(alice::()).into(), bob::()).unwrap(); + } + verify { + assert_eq!(Assets::::free_balance(&T::PrestoKycAssetId::get(), &bob::()).unwrap(), 0); + assert_eq!(Assets::::free_balance(&T::PrestoKycCreditorAssetId::get(), &bob::()).unwrap(), 0); + } + mint_presto_usd { Pallet::::add_presto_manager(RawOrigin::Root.into(), alice::()).unwrap(); let amount = balance!(1000); @@ -135,6 +177,7 @@ benchmarks! { send_presto_usd { Pallet::::add_presto_manager(RawOrigin::Root.into(), alice::()).unwrap(); + Pallet::::apply_investor_kyc(RawOrigin::Signed(alice::()).into(), bob::()).unwrap(); let mint_amount = balance!(1000); Pallet::::mint_presto_usd(RawOrigin::Signed(alice::()).into(), mint_amount).unwrap(); let send_amount = balance!(200); @@ -147,6 +190,8 @@ benchmarks! { } create_deposit_request { + Pallet::::add_presto_manager(RawOrigin::Root.into(), alice::()).unwrap(); + Pallet::::apply_investor_kyc(RawOrigin::Signed(alice::()).into(), bob::()).unwrap(); let request_id = 1u32.into(); }: { Pallet::::create_deposit_request(RawOrigin::Signed(bob::()).into(), balance!(10000), BoundedString::truncate_from("payment reference"), Some(BoundedString::truncate_from("details"))).unwrap(); @@ -157,6 +202,7 @@ benchmarks! { create_withdraw_request { Pallet::::add_presto_manager(RawOrigin::Root.into(), alice::()).unwrap(); + Pallet::::apply_investor_kyc(RawOrigin::Signed(alice::()).into(), bob::()).unwrap(); Pallet::::mint_presto_usd(RawOrigin::Signed(alice::()).into(), balance!(10000)).unwrap(); let send_amount = balance!(2000); Pallet::::send_presto_usd(RawOrigin::Signed(alice::()).into(), send_amount, bob::()).unwrap(); @@ -172,6 +218,8 @@ benchmarks! { } cancel_request { + Pallet::::add_presto_manager(RawOrigin::Root.into(), alice::()).unwrap(); + Pallet::::apply_investor_kyc(RawOrigin::Signed(alice::()).into(), bob::()).unwrap(); Pallet::::create_deposit_request(RawOrigin::Signed(bob::()).into(), balance!(10000), BoundedString::truncate_from("payment reference"), Some(BoundedString::truncate_from("details"))).unwrap(); let request_id = 1u32.into(); }: { @@ -183,6 +231,7 @@ benchmarks! { approve_deposit_request { Pallet::::add_presto_manager(RawOrigin::Root.into(), alice::()).unwrap(); + Pallet::::apply_investor_kyc(RawOrigin::Signed(alice::()).into(), bob::()).unwrap(); let mint_amount = balance!(100000); Pallet::::mint_presto_usd(RawOrigin::Signed(alice::()).into(), mint_amount).unwrap(); let deposit_amount = balance!(10000); @@ -199,6 +248,7 @@ benchmarks! { approve_withdraw_request { Pallet::::add_presto_manager(RawOrigin::Root.into(), alice::()).unwrap(); + Pallet::::apply_investor_kyc(RawOrigin::Signed(alice::()).into(), bob::()).unwrap(); let mint_amount = balance!(10000); Pallet::::mint_presto_usd(RawOrigin::Signed(alice::()).into(), mint_amount).unwrap(); let send_amount = balance!(2000); @@ -218,6 +268,7 @@ benchmarks! { decline_request { Pallet::::add_presto_manager(RawOrigin::Root.into(), alice::()).unwrap(); + Pallet::::apply_investor_kyc(RawOrigin::Signed(alice::()).into(), bob::()).unwrap(); Pallet::::create_deposit_request(RawOrigin::Signed(bob::()).into(), balance!(10000), BoundedString::truncate_from("payment reference"), Some(BoundedString::truncate_from("details"))).unwrap(); let request_id = 1u32.into(); }: { @@ -228,6 +279,9 @@ benchmarks! { } create_crop_receipt { + Pallet::::add_presto_manager(RawOrigin::Root.into(), alice::()).unwrap(); + Pallet::::apply_creditor_kyc(RawOrigin::Signed(alice::()).into(), bob::()).unwrap(); + let amount = balance!(10000); let close_initial_period = 123u32.into(); let date_of_issue = 234u32.into(); @@ -247,6 +301,8 @@ benchmarks! { rate_crop_receipt { Pallet::::add_presto_auditor(RawOrigin::Root.into(), alice::()).unwrap(); + Pallet::::add_presto_manager(RawOrigin::Root.into(), alice::()).unwrap(); + Pallet::::apply_creditor_kyc(RawOrigin::Signed(alice::()).into(), bob::()).unwrap(); let amount = balance!(10000); let close_initial_period = 123u32.into(); @@ -268,6 +324,8 @@ benchmarks! { decline_crop_receipt { Pallet::::add_presto_auditor(RawOrigin::Root.into(), alice::()).unwrap(); + Pallet::::add_presto_manager(RawOrigin::Root.into(), alice::()).unwrap(); + Pallet::::apply_creditor_kyc(RawOrigin::Signed(alice::()).into(), bob::()).unwrap(); let amount = balance!(10000); let close_initial_period = 123u32.into(); @@ -291,6 +349,8 @@ benchmarks! { publish_crop_receipt { Pallet::::add_presto_auditor(RawOrigin::Root.into(), alice::()).unwrap(); + Pallet::::add_presto_manager(RawOrigin::Root.into(), alice::()).unwrap(); + Pallet::::apply_creditor_kyc(RawOrigin::Signed(alice::()).into(), bob::()).unwrap(); let amount = balance!(10000); let close_initial_period = 123u32.into(); diff --git a/pallets/presto/src/lib.rs b/pallets/presto/src/lib.rs index 2b4717a444..8701bb8004 100644 --- a/pallets/presto/src/lib.rs +++ b/pallets/presto/src/lib.rs @@ -41,11 +41,13 @@ mod test; mod treasury; pub mod weights; -use common::{AccountIdOf, Balance}; +use common::{AccountIdOf, AssetInfoProvider, Balance}; use frame_support::ensure; use frame_support::sp_runtime::DispatchError; use frame_support::traits::Time; -use sp_runtime::traits::{One, Saturating}; +use sp_core::Get; +use sp_runtime::traits::{One, Saturating, Zero}; +use sp_std::vec::Vec; pub use pallet::*; @@ -68,7 +70,8 @@ pub mod pallet { use common::prelude::BalanceUnit; use common::{ balance, itoa, AssetIdOf, AssetManager, AssetName, AssetSymbol, AssetType, BoundedString, - DEXId, ItoaInteger, OrderBookManager, PriceVariant, TradingPairSourceManager, + ContentSource, DEXId, ExtendedAssetsManager, ItoaInteger, OrderBookManager, PriceVariant, + TradingPairSourceManager, }; use core::fmt::Debug; use frame_support::pallet_prelude::*; @@ -98,7 +101,15 @@ pub mod pallet { Self::DEXId, MomentOf, >; + type ExtendedAssetsManager: ExtendedAssetsManager< + AssetIdOf, + MomentOf, + ContentSource, + >; type PrestoUsdAssetId: Get>; + type PrestoKycAssetId: Get>; + type PrestoKycInvestorAssetId: Get>; + type PrestoKycCreditorAssetId: Get>; type PrestoTechAccount: Get; type PrestoBufferTechAccount: Get; type RequestId: Parameter @@ -324,6 +335,16 @@ pub mod pallet { CallerIsNotManager, /// This account is not an auditor CallerIsNotAuditor, + /// Account already passed KYC + KycAlreadyPassed, + /// Account not passed KYC + KycNotPassed, + /// Account not passed KYC as investor + InvestorKycNotPassed, + /// Account not passed KYC as creditor + CreditorKycNotPassed, + /// Account has any Presto asset + AccountHasPrestoAssets, /// Zero amount doesn't make sense AmountIsZero, /// This account has reached the max count of requests @@ -435,6 +456,138 @@ pub mod pallet { } #[pallet::call_index(4)] + #[pallet::weight(::WeightInfo::apply_investor_kyc())] + pub fn apply_investor_kyc( + origin: OriginFor, + investor: AccountIdOf, + ) -> DispatchResult { + let manager = ensure_signed(origin)?; + Self::ensure_is_manager(&manager)?; + + Self::ensure_no_kyc(&investor)?; + + let presto_tech_account_id = technical::Pallet::::tech_account_id_to_account_id( + &T::PrestoTechAccount::get(), + )?; + + T::AssetManager::mint_to( + &T::PrestoKycAssetId::get(), + &presto_tech_account_id, + &investor, + 1, + )?; + + T::AssetManager::mint_to( + &T::PrestoKycInvestorAssetId::get(), + &presto_tech_account_id, + &investor, + 1, + )?; + + Ok(()) + } + + #[pallet::call_index(5)] + #[pallet::weight(::WeightInfo::apply_creditor_kyc())] + pub fn apply_creditor_kyc( + origin: OriginFor, + creditor: AccountIdOf, + ) -> DispatchResult { + let manager = ensure_signed(origin)?; + Self::ensure_is_manager(&manager)?; + + Self::ensure_no_kyc(&creditor)?; + + let presto_tech_account_id = technical::Pallet::::tech_account_id_to_account_id( + &T::PrestoTechAccount::get(), + )?; + + T::AssetManager::mint_to( + &T::PrestoKycAssetId::get(), + &presto_tech_account_id, + &creditor, + 1, + )?; + + T::AssetManager::mint_to( + &T::PrestoKycCreditorAssetId::get(), + &presto_tech_account_id, + &creditor, + 1, + )?; + + Ok(()) + } + + #[pallet::call_index(6)] + #[pallet::weight(::WeightInfo::remove_investor_kyc())] + pub fn remove_investor_kyc( + origin: OriginFor, + investor: AccountIdOf, + ) -> DispatchResult { + let manager = ensure_signed(origin)?; + Self::ensure_is_manager(&manager)?; + + let kyc_amount = Self::ensure_has_kyc(&investor)?; + let investor_kyc_amount = Self::ensure_has_investor_kyc(&investor)?; + Self::ensure_no_presto_assets(&investor)?; + + let presto_tech_account_id = technical::Pallet::::tech_account_id_to_account_id( + &T::PrestoTechAccount::get(), + )?; + + T::AssetManager::burn_from( + &T::PrestoKycAssetId::get(), + &presto_tech_account_id, + &investor, + kyc_amount, + )?; + + T::AssetManager::burn_from( + &T::PrestoKycInvestorAssetId::get(), + &presto_tech_account_id, + &investor, + investor_kyc_amount, + )?; + + Ok(()) + } + + #[pallet::call_index(7)] + #[pallet::weight(::WeightInfo::remove_creditor_kyc())] + pub fn remove_creditor_kyc( + origin: OriginFor, + creditor: AccountIdOf, + ) -> DispatchResult { + let manager = ensure_signed(origin)?; + Self::ensure_is_manager(&manager)?; + + let kyc_amount = Self::ensure_has_kyc(&creditor)?; + let creditor_kyc_amount = Self::ensure_has_creditor_kyc(&creditor)?; + Self::ensure_no_presto_assets(&creditor)?; + + let presto_tech_account_id = technical::Pallet::::tech_account_id_to_account_id( + &T::PrestoTechAccount::get(), + )?; + + T::AssetManager::burn_from( + &T::PrestoKycAssetId::get(), + &presto_tech_account_id, + &creditor, + kyc_amount, + )?; + + T::AssetManager::burn_from( + &T::PrestoKycCreditorAssetId::get(), + &presto_tech_account_id, + &creditor, + creditor_kyc_amount, + )?; + + Ok(()) + } + + #[pallet::call_index(8)] #[pallet::weight(::WeightInfo::mint_presto_usd())] pub fn mint_presto_usd(origin: OriginFor, amount: Balance) -> DispatchResult { let who = ensure_signed(origin)?; @@ -447,7 +600,7 @@ pub mod pallet { Ok(()) } - #[pallet::call_index(5)] + #[pallet::call_index(9)] #[pallet::weight(::WeightInfo::burn_presto_usd())] pub fn burn_presto_usd(origin: OriginFor, amount: Balance) -> DispatchResult { let who = ensure_signed(origin)?; @@ -460,7 +613,7 @@ pub mod pallet { Ok(()) } - #[pallet::call_index(6)] + #[pallet::call_index(10)] #[pallet::weight(::WeightInfo::send_presto_usd())] pub fn send_presto_usd( origin: OriginFor, @@ -475,7 +628,7 @@ pub mod pallet { Ok(()) } - #[pallet::call_index(7)] + #[pallet::call_index(11)] #[pallet::weight(::WeightInfo::create_deposit_request())] pub fn create_deposit_request( origin: OriginFor, @@ -486,6 +639,7 @@ pub mod pallet { let owner = ensure_signed(origin)?; ensure!(!amount.is_zero(), Error::::AmountIsZero); + Self::ensure_has_kyc(&owner)?; let id = Self::next_request_id(); let request = Request::Deposit(DepositRequest::new( @@ -507,7 +661,7 @@ pub mod pallet { Ok(()) } - #[pallet::call_index(8)] + #[pallet::call_index(12)] #[pallet::weight(::WeightInfo::create_withdraw_request())] pub fn create_withdraw_request( origin: OriginFor, @@ -517,6 +671,7 @@ pub mod pallet { let owner = ensure_signed(origin)?; ensure!(!amount.is_zero(), Error::::AmountIsZero); + Self::ensure_has_kyc(&owner)?; let id = Self::next_request_id(); let request = Request::Withdraw(WithdrawRequest::new(owner.clone(), amount, details)?); @@ -533,10 +688,11 @@ pub mod pallet { Ok(()) } - #[pallet::call_index(9)] + #[pallet::call_index(13)] #[pallet::weight(::WeightInfo::cancel_request())] pub fn cancel_request(origin: OriginFor, request_id: T::RequestId) -> DispatchResult { let who = ensure_signed(origin)?; + Self::ensure_has_kyc(&who)?; Requests::::try_mutate(request_id, |request| { let request = request.as_mut().ok_or(Error::::RequestIsNotExists)?; @@ -556,7 +712,7 @@ pub mod pallet { }) } - #[pallet::call_index(10)] + #[pallet::call_index(14)] #[pallet::weight(::WeightInfo::approve_deposit_request())] pub fn approve_deposit_request( origin: OriginFor, @@ -588,7 +744,7 @@ pub mod pallet { }) } - #[pallet::call_index(11)] + #[pallet::call_index(15)] #[pallet::weight(::WeightInfo::approve_withdraw_request())] pub fn approve_withdraw_request( origin: OriginFor, @@ -621,7 +777,7 @@ pub mod pallet { }) } - #[pallet::call_index(12)] + #[pallet::call_index(16)] #[pallet::weight(::WeightInfo::decline_request())] pub fn decline_request(origin: OriginFor, request_id: T::RequestId) -> DispatchResult { let manager = ensure_signed(origin)?; @@ -646,7 +802,7 @@ pub mod pallet { }) } - #[pallet::call_index(13)] + #[pallet::call_index(17)] #[pallet::weight(::WeightInfo::create_crop_receipt())] pub fn create_crop_receipt( origin: OriginFor, @@ -662,6 +818,7 @@ pub mod pallet { ) -> DispatchResult { let owner = ensure_signed(origin)?; ensure!(!amount.is_zero(), Error::::AmountIsZero); + Self::ensure_has_creditor_kyc(&owner)?; let id = Self::next_crop_receipt_id(); let crop_receipt = CropReceipt::::new( @@ -692,7 +849,7 @@ pub mod pallet { Ok(()) } - #[pallet::call_index(14)] + #[pallet::call_index(18)] #[pallet::weight(::WeightInfo::rate_crop_receipt())] pub fn rate_crop_receipt( origin: OriginFor, @@ -718,13 +875,14 @@ pub mod pallet { }) } - #[pallet::call_index(15)] + #[pallet::call_index(19)] #[pallet::weight(::WeightInfo::decline_crop_receipt())] pub fn decline_crop_receipt( origin: OriginFor, crop_receipt_id: T::CropReceiptId, ) -> DispatchResult { let who = ensure_signed(origin)?; + Self::ensure_has_creditor_kyc(&who)?; CropReceipts::::try_mutate(crop_receipt_id, |crop_receipt| { let crop_receipt = crop_receipt @@ -742,7 +900,7 @@ pub mod pallet { }) } - #[pallet::call_index(16)] + #[pallet::call_index(20)] #[pallet::weight(::WeightInfo::publish_crop_receipt())] pub fn publish_crop_receipt( origin: OriginFor, @@ -751,6 +909,7 @@ pub mod pallet { ) -> DispatchResult { let who = ensure_signed(origin)?; ensure!(!supply.is_zero(), Error::::AmountIsZero); + Self::ensure_has_creditor_kyc(&who)?; let coupon_supply = BalanceUnit::indivisible(supply); @@ -789,11 +948,16 @@ pub mod pallet { 0, supply, false, - AssetType::Regular, + AssetType::Regulated, None, None, )?; + T::ExtendedAssetsManager::bind_regulated_asset_to_sbt_asset( + &T::PrestoKycAssetId::get(), + &coupon_asset_id, + )?; + Coupons::::insert(coupon_asset_id, crop_receipt_id); T::AssetManager::transfer_from( @@ -869,6 +1033,17 @@ pub mod pallet { max_lot_size, )?; + let order_book_account_id = + T::OrderBookManager::tech_account_id_for_order_book(&order_book_id)?; + + // Presto KYC SBT for order book tech account + T::AssetManager::mint_to( + &T::PrestoKycAssetId::get(), + &presto_tech_account_id, + &order_book_account_id, + 1, + )?; + // place all supply in order book in according with `max_lot_size` limitation let mut remaining_amount = supply; while !remaining_amount.is_zero() { @@ -940,4 +1115,45 @@ impl Pallet { let steps = price.saturating_div(tick_size); Ok(tick_size.saturating_mul(steps)) } + + pub fn ensure_no_kyc(account: &AccountIdOf) -> Result<(), DispatchError> { + ensure!( + T::AssetInfoProvider::free_balance(&T::PrestoKycAssetId::get(), account)?.is_zero(), + Error::::KycAlreadyPassed + ); + Ok(()) + } + + pub fn ensure_has_kyc(account: &AccountIdOf) -> Result { + let amount = T::AssetInfoProvider::free_balance(&T::PrestoKycAssetId::get(), account)?; + ensure!(amount > Zero::zero(), Error::::KycNotPassed); + Ok(amount) + } + + pub fn ensure_has_investor_kyc(account: &AccountIdOf) -> Result { + let amount = + T::AssetInfoProvider::free_balance(&T::PrestoKycInvestorAssetId::get(), account)?; + ensure!(amount > Zero::zero(), Error::::InvestorKycNotPassed); + Ok(amount) + } + + pub fn ensure_has_creditor_kyc(account: &AccountIdOf) -> Result { + let amount = + T::AssetInfoProvider::free_balance(&T::PrestoKycCreditorAssetId::get(), account)?; + ensure!(amount > Zero::zero(), Error::::CreditorKycNotPassed); + Ok(amount) + } + + pub fn ensure_no_presto_assets(account: &AccountIdOf) -> Result<(), DispatchError> { + let mut presto_assets = Coupons::::iter_keys().collect::>(); + presto_assets.push(T::PrestoUsdAssetId::get()); + + for asset in presto_assets { + ensure!( + T::AssetInfoProvider::free_balance(&asset, account)?.is_zero(), + Error::::AccountHasPrestoAssets + ); + } + Ok(()) + } } diff --git a/pallets/presto/src/mock.rs b/pallets/presto/src/mock.rs index 3785978d9c..1f5bed02a3 100644 --- a/pallets/presto/src/mock.rs +++ b/pallets/presto/src/mock.rs @@ -34,11 +34,12 @@ use crate as presto; use common::mock::ExistentialDeposits; use common::{ - mock_assets_config, mock_common_config, mock_currencies_config, mock_dex_manager_config, - mock_frame_system_config, mock_pallet_balances_config, mock_pallet_timestamp_config, - mock_permissions_config, mock_technical_config, mock_tokens_config, mock_trading_pair_config, - Amount, AssetId32, AssetName, AssetSymbol, DEXId, DEXInfo, FromGenericPair, PredefinedAssetId, - DEFAULT_BALANCE_PRECISION, KUSD, PRUSD, XOR, XST, + hash, mock_assets_config, mock_common_config, mock_currencies_config, mock_dex_manager_config, + mock_extended_assets_config, mock_frame_system_config, mock_pallet_balances_config, + mock_pallet_timestamp_config, mock_permissions_config, mock_technical_config, + mock_tokens_config, mock_trading_pair_config, Amount, AssetId32, AssetName, AssetSymbol, DEXId, + DEXInfo, FromGenericPair, PredefinedAssetId, DEFAULT_BALANCE_PRECISION, KUSD, PRUSD, SBT_PRACS, + SBT_PRCRDT, SBT_PRINVST, XOR, XST, }; use currencies::BasicCurrencyAdapter; use frame_support::traits::{ConstU32, EitherOfDiverse, GenesisBuild}; @@ -74,6 +75,7 @@ construct_runtime! { Timestamp: pallet_timestamp::{Pallet, Call, Storage, Inherent}, Currencies: currencies::{Pallet, Call, Storage}, Assets: assets::{Pallet, Call, Config, Storage, Event}, + ExtendedAssets: extended_assets::{Pallet, Call, Config, Storage, Event}, Balances: pallet_balances::{Pallet, Call, Storage, Event}, DexManager: dex_manager::{Pallet, Call, Config, Storage}, OrderBook: order_book::{Pallet, Call, Storage, Event}, @@ -90,9 +92,16 @@ parameter_types! { } mock_common_config!(Runtime); -mock_assets_config!(Runtime); +mock_assets_config!( + Runtime, + ( + permissions::Pallet, + extended_assets::Pallet, + ) +); mock_currencies_config!(Runtime); mock_dex_manager_config!(Runtime); +mock_extended_assets_config!(Runtime); mock_tokens_config!(Runtime); mock_pallet_balances_config!(Runtime); mock_frame_system_config!(Runtime); @@ -133,6 +142,9 @@ impl order_book::Config for Runtime { parameter_types! { pub const PrestoUsdAssetId: AssetId = PRUSD; + pub PrestoKycAssetId: AssetId = SBT_PRACS.into_predefined(); + pub PrestoKycInvestorAssetId: AssetId = SBT_PRINVST.into_predefined(); + pub PrestoKycCreditorAssetId: AssetId = SBT_PRCRDT.into_predefined(); pub PrestoTechAccountId: TechAccountId = { TechAccountId::from_generic_pair( presto::TECH_ACCOUNT_PREFIX.to_vec(), @@ -159,7 +171,11 @@ impl presto::Config for Runtime { type RuntimeEvent = RuntimeEvent; type TradingPairSourceManager = trading_pair::Pallet; type OrderBookManager = order_book::Pallet; + type ExtendedAssetsManager = extended_assets::Pallet; type PrestoUsdAssetId = PrestoUsdAssetId; + type PrestoKycAssetId = PrestoKycAssetId; + type PrestoKycInvestorAssetId = PrestoKycInvestorAssetId; + type PrestoKycCreditorAssetId = PrestoKycCreditorAssetId; type PrestoTechAccount = PrestoTechAccountId; type PrestoBufferTechAccount = PrestoBufferTechAccountId; type RequestId = u64; @@ -220,35 +236,100 @@ pub fn ext() -> sp_io::TestExternalities { Scope::Unlimited, vec![assets_and_permissions_account_id.clone()], ), + ( + permissions::MANAGE_DEX, + Scope::Unlimited, + vec![assets_and_permissions_account_id.clone()], + ), + ], + initial_permissions: vec![ + ( + assets_and_permissions_account_id.clone(), + Scope::Unlimited, + vec![permissions::MINT, permissions::BURN], + ), + ( + PrestoAccountId::get(), + Scope::Limited(hash(&PRUSD)), + vec![permissions::MINT, permissions::BURN], + ), + ( + PrestoAccountId::get(), + Scope::Limited(hash(&SBT_PRACS)), + vec![permissions::MINT, permissions::BURN], + ), + ( + PrestoAccountId::get(), + Scope::Limited(hash(&SBT_PRINVST)), + vec![permissions::MINT, permissions::BURN], + ), + ( + PrestoAccountId::get(), + Scope::Limited(hash(&SBT_PRCRDT)), + vec![permissions::MINT, permissions::BURN], + ), + ( + PrestoAccountId::get(), + Scope::Limited(hash(&DEXId::PolkaswapPresto)), + vec![permissions::MANAGE_DEX], + ), ], - initial_permissions: vec![( - assets_and_permissions_account_id.clone(), - Scope::Unlimited, - vec![permissions::MINT, permissions::BURN], - )], } .assimilate_storage(&mut storage) .unwrap(); AssetsConfig { - endowed_assets: vec![ + endowed_assets: vec![( + XOR, + assets_and_permissions_account_id.clone(), + AssetSymbol(b"XOR".to_vec()), + AssetName(b"SORA".to_vec()), + DEFAULT_BALANCE_PRECISION, + 0, + true, + None, + None, + )], + regulated_assets: vec![( + PRUSD, + assets_and_permissions_account_id.clone(), + AssetSymbol(b"PRUSD".to_vec()), + AssetName(b"Presto USD".to_vec()), + DEFAULT_BALANCE_PRECISION, + 0, + true, + None, + None, + )], + sbt_assets: vec![ ( - XOR, - assets_and_permissions_account_id, - AssetSymbol(b"XOR".to_vec()), - AssetName(b"SORA".to_vec()), - DEFAULT_BALANCE_PRECISION, + SBT_PRACS.into_predefined(), + assets_and_permissions_account_id.clone(), + AssetSymbol(b"PRACS".to_vec()), + AssetName(b"Presto Access".to_vec()), + 0, 0, true, None, None, ), ( - PRUSD, - PrestoAccountId::get(), - AssetSymbol(b"PRUSD".to_vec()), - AssetName(b"Presto USD".to_vec()), - DEFAULT_BALANCE_PRECISION, + SBT_PRINVST.into_predefined(), + assets_and_permissions_account_id.clone(), + AssetSymbol(b"PRINVST".to_vec()), + AssetName(b"Presto Investor".to_vec()), + 0, + 0, + true, + None, + None, + ), + ( + SBT_PRCRDT.into_predefined(), + assets_and_permissions_account_id, + AssetSymbol(b"PRCRDT".to_vec()), + AssetName(b"Presto Creditor".to_vec()), + 0, 0, true, None, @@ -274,7 +355,7 @@ pub fn ext() -> sp_io::TestExternalities { DEXInfo { base_asset_id: PRUSD, synthetic_base_asset_id: XST, - is_public: true, + is_public: false, }, ), ], @@ -282,6 +363,21 @@ pub fn ext() -> sp_io::TestExternalities { .assimilate_storage(&mut storage) .unwrap(); + ExtendedAssetsConfig { + assets_metadata: vec![(SBT_PRACS.into(), None, PRUSD)], + } + .assimilate_storage(&mut storage) + .unwrap(); + + TokensConfig { + balances: vec![ + (PrestoAccountId::get(), SBT_PRACS.into(), 1), + (PrestoBufferAccountId::get(), SBT_PRACS.into(), 1), + ], + } + .assimilate_storage(&mut storage) + .unwrap(); + let mut ext: sp_io::TestExternalities = storage.into(); ext.execute_with(|| { System::set_block_number(1); diff --git a/pallets/presto/src/test.rs b/pallets/presto/src/test.rs index 549559728b..54f21ccfa8 100644 --- a/pallets/presto/src/test.rs +++ b/pallets/presto/src/test.rs @@ -44,10 +44,11 @@ use crate::requests::{DepositRequest, Request, RequestStatus, WithdrawRequest}; use common::prelude::BalanceUnit; use common::{ balance, AssetIdOf, AssetInfoProvider, AssetName, AssetSymbol, Balance, BoundedString, DEXId, - OrderBookId, PRUSD, + OrderBookId, PRUSD, SBT_PRACS, SBT_PRCRDT, SBT_PRINVST, }; use frame_support::{assert_err, assert_ok}; use sp_runtime::DispatchError::BadOrigin; +use sp_std::collections::btree_set::BTreeSet; type PrestoPallet = Pallet; type OrderBookPallet = order_book::Pallet; @@ -70,6 +71,10 @@ fn free_balance(asset: &AssetId, account: &AccountId) -> Balance { assets::Pallet::::free_balance(asset, account).unwrap() } +fn burn_balance(asset: &AssetId, issuer: &AccountId, account: &AccountId, amount: Balance) { + assets::Pallet::::burn_from(asset, issuer, account, amount).unwrap() +} + fn tech_account_id_to_account_id(tech: &TechAccountId) -> AccountId { technical::Pallet::::tech_account_id_to_account_id(tech).unwrap() } @@ -281,6 +286,194 @@ fn should_burn_presto_usd() { }); } +#[test] +fn should_apply_investor_kyc() { + ext().execute_with(|| { + // prepare + + assert_ok!(PrestoPallet::add_presto_manager( + RuntimeOrigin::root(), + alice() + )); + + assert_eq!(free_balance(&SBT_PRACS.into(), &bob()), balance!(0)); + assert_eq!(free_balance(&SBT_PRINVST.into(), &bob()), balance!(0)); + assert_eq!(free_balance(&SBT_PRCRDT.into(), &bob()), balance!(0)); + + // test + + assert_err!( + PrestoPallet::apply_investor_kyc(RuntimeOrigin::signed(charlie()), bob()), + E::CallerIsNotManager + ); + + assert_ok!(PrestoPallet::apply_investor_kyc( + RuntimeOrigin::signed(alice()), + bob() + )); + + assert_eq!(free_balance(&SBT_PRACS.into(), &bob()), 1); + assert_eq!(free_balance(&SBT_PRINVST.into(), &bob()), 1); + assert_eq!(free_balance(&SBT_PRCRDT.into(), &bob()), balance!(0)); + + assert_err!( + PrestoPallet::apply_investor_kyc(RuntimeOrigin::signed(alice()), bob()), + E::KycAlreadyPassed + ); + }); +} + +#[test] +fn should_apply_creditor_kyc() { + ext().execute_with(|| { + // prepare + + assert_ok!(PrestoPallet::add_presto_manager( + RuntimeOrigin::root(), + alice() + )); + + assert_eq!(free_balance(&SBT_PRACS.into(), &bob()), balance!(0)); + assert_eq!(free_balance(&SBT_PRINVST.into(), &bob()), balance!(0)); + assert_eq!(free_balance(&SBT_PRCRDT.into(), &bob()), balance!(0)); + + // test + + assert_err!( + PrestoPallet::apply_creditor_kyc(RuntimeOrigin::signed(charlie()), bob()), + E::CallerIsNotManager + ); + + assert_ok!(PrestoPallet::apply_creditor_kyc( + RuntimeOrigin::signed(alice()), + bob() + )); + + assert_eq!(free_balance(&SBT_PRACS.into(), &bob()), 1); + assert_eq!(free_balance(&SBT_PRINVST.into(), &bob()), balance!(0)); + assert_eq!(free_balance(&SBT_PRCRDT.into(), &bob()), 1); + + assert_err!( + PrestoPallet::apply_creditor_kyc(RuntimeOrigin::signed(alice()), bob()), + E::KycAlreadyPassed + ); + }); +} + +#[test] +fn should_remove_investor_kyc() { + ext().execute_with(|| { + // prepare + + assert_ok!(PrestoPallet::add_presto_manager( + RuntimeOrigin::root(), + alice() + )); + + assert_ok!(PrestoPallet::apply_investor_kyc( + RuntimeOrigin::signed(alice()), + bob() + )); + + assert_ok!(PrestoPallet::mint_presto_usd( + RuntimeOrigin::signed(alice()), + balance!(1000) + )); + + assert_ok!(PrestoPallet::send_presto_usd( + RuntimeOrigin::signed(alice()), + balance!(200), + bob() + )); + + // test + + assert_err!( + PrestoPallet::remove_investor_kyc(RuntimeOrigin::signed(charlie()), bob()), + E::CallerIsNotManager + ); + + assert_err!( + PrestoPallet::remove_investor_kyc(RuntimeOrigin::signed(alice()), bob()), + E::AccountHasPrestoAssets + ); + + let main_tech_account = tech_account_id_to_account_id(&PrestoTechAccountId::get()); + burn_balance(&PRUSD, &main_tech_account, &bob(), balance!(200)); + + assert_ok!(PrestoPallet::remove_investor_kyc( + RuntimeOrigin::signed(alice()), + bob() + )); + + assert_eq!(free_balance(&SBT_PRACS.into(), &bob()), balance!(0)); + assert_eq!(free_balance(&SBT_PRINVST.into(), &bob()), balance!(0)); + assert_eq!(free_balance(&SBT_PRCRDT.into(), &bob()), balance!(0)); + + assert_err!( + PrestoPallet::remove_investor_kyc(RuntimeOrigin::signed(alice()), bob()), + E::KycNotPassed + ); + }); +} + +#[test] +fn should_remove_creditor_kyc() { + ext().execute_with(|| { + // prepare + + assert_ok!(PrestoPallet::add_presto_manager( + RuntimeOrigin::root(), + alice() + )); + + assert_ok!(PrestoPallet::apply_creditor_kyc( + RuntimeOrigin::signed(alice()), + bob() + )); + + assert_ok!(PrestoPallet::mint_presto_usd( + RuntimeOrigin::signed(alice()), + balance!(1000) + )); + + assert_ok!(PrestoPallet::send_presto_usd( + RuntimeOrigin::signed(alice()), + balance!(200), + bob() + )); + + // test + + assert_err!( + PrestoPallet::remove_creditor_kyc(RuntimeOrigin::signed(charlie()), bob()), + E::CallerIsNotManager + ); + + assert_err!( + PrestoPallet::remove_creditor_kyc(RuntimeOrigin::signed(alice()), bob()), + E::AccountHasPrestoAssets + ); + + let main_tech_account = tech_account_id_to_account_id(&PrestoTechAccountId::get()); + burn_balance(&PRUSD, &main_tech_account, &bob(), balance!(200)); + + assert_ok!(PrestoPallet::remove_creditor_kyc( + RuntimeOrigin::signed(alice()), + bob() + )); + + assert_eq!(free_balance(&SBT_PRACS.into(), &bob()), balance!(0)); + assert_eq!(free_balance(&SBT_PRINVST.into(), &bob()), balance!(0)); + assert_eq!(free_balance(&SBT_PRCRDT.into(), &bob()), balance!(0)); + + assert_err!( + PrestoPallet::remove_creditor_kyc(RuntimeOrigin::signed(alice()), bob()), + E::KycNotPassed + ); + }); +} + #[test] fn should_send_presto_usd() { ext().execute_with(|| { @@ -298,6 +491,11 @@ fn should_send_presto_usd() { balance!(1000) )); + assert_ok!(PrestoPallet::apply_investor_kyc( + RuntimeOrigin::signed(alice()), + dave() + )); + assert_eq!(free_balance(&PRUSD, &main_tech_account), balance!(1000)); assert_eq!(free_balance(&PRUSD, &dave()), balance!(0)); @@ -334,6 +532,11 @@ fn should_create_deposit_request() { alice() )); + assert_ok!(PrestoPallet::apply_investor_kyc( + RuntimeOrigin::signed(alice()), + bob() + )); + // test assert_eq!(PrestoPallet::requests(1), None); @@ -368,6 +571,21 @@ fn should_create_deposit_request() { }) ); + assert_err!( + PrestoPallet::create_deposit_request( + RuntimeOrigin::signed(charlie()), + balance!(200), + BoundedString::truncate_from("payment reference"), + None + ), + E::KycNotPassed + ); + + assert_ok!(PrestoPallet::apply_investor_kyc( + RuntimeOrigin::signed(alice()), + charlie() + )); + assert_ok!(PrestoPallet::create_deposit_request( RuntimeOrigin::signed(charlie()), balance!(200), @@ -402,6 +620,11 @@ fn should_create_withdraw_request() { alice() )); + assert_ok!(PrestoPallet::apply_investor_kyc( + RuntimeOrigin::signed(alice()), + bob() + )); + assert_ok!(PrestoPallet::mint_presto_usd( RuntimeOrigin::signed(alice()), balance!(1000) @@ -430,6 +653,15 @@ fn should_create_withdraw_request() { E::AmountIsZero ); + assert_err!( + PrestoPallet::create_withdraw_request( + RuntimeOrigin::signed(charlie()), + balance!(200), + Some(BoundedString::truncate_from("details")) + ), + E::KycNotPassed + ); + assert_ok!(PrestoPallet::create_withdraw_request( RuntimeOrigin::signed(bob()), balance!(200), @@ -467,6 +699,16 @@ fn should_cancel_request() { alice() )); + assert_ok!(PrestoPallet::apply_investor_kyc( + RuntimeOrigin::signed(alice()), + bob() + )); + + assert_ok!(PrestoPallet::apply_investor_kyc( + RuntimeOrigin::signed(alice()), + charlie() + )); + assert_ok!(PrestoPallet::mint_presto_usd( RuntimeOrigin::signed(alice()), balance!(1000) @@ -518,6 +760,16 @@ fn should_cancel_request() { // test + assert_err!( + PrestoPallet::cancel_request(RuntimeOrigin::signed(dave()), 1), + E::KycNotPassed + ); + + assert_ok!(PrestoPallet::apply_investor_kyc( + RuntimeOrigin::signed(alice()), + dave() + )); + assert_err!( PrestoPallet::cancel_request(RuntimeOrigin::signed(dave()), 1), E::CallerIsNotRequestOwner @@ -578,6 +830,16 @@ fn should_approve_deposit_request() { alice() )); + assert_ok!(PrestoPallet::apply_investor_kyc( + RuntimeOrigin::signed(alice()), + bob() + )); + + assert_ok!(PrestoPallet::apply_investor_kyc( + RuntimeOrigin::signed(alice()), + charlie() + )); + assert_ok!(PrestoPallet::mint_presto_usd( RuntimeOrigin::signed(alice()), balance!(1000) @@ -688,6 +950,16 @@ fn should_approve_withdraw_request() { alice() )); + assert_ok!(PrestoPallet::apply_investor_kyc( + RuntimeOrigin::signed(alice()), + bob() + )); + + assert_ok!(PrestoPallet::apply_investor_kyc( + RuntimeOrigin::signed(alice()), + charlie() + )); + assert_ok!(PrestoPallet::mint_presto_usd( RuntimeOrigin::signed(alice()), balance!(1000) @@ -819,6 +1091,16 @@ fn should_decline_request() { alice() )); + assert_ok!(PrestoPallet::apply_investor_kyc( + RuntimeOrigin::signed(alice()), + bob() + )); + + assert_ok!(PrestoPallet::apply_investor_kyc( + RuntimeOrigin::signed(alice()), + charlie() + )); + assert_ok!(PrestoPallet::mint_presto_usd( RuntimeOrigin::signed(alice()), balance!(1000) @@ -953,6 +1235,32 @@ fn should_create_crop_receipt() { E::AmountIsZero ); + assert_err!( + PrestoPallet::create_crop_receipt( + RuntimeOrigin::signed(bob()), + amount, + Country::Brazil, + close_initial_period, + date_of_issue, + place_of_issue.clone(), + debtor.clone(), + creditor.clone(), + perfomance_time, + data.clone() + ), + E::CreditorKycNotPassed + ); + + assert_ok!(PrestoPallet::add_presto_manager( + RuntimeOrigin::root(), + alice() + )); + + assert_ok!(PrestoPallet::apply_creditor_kyc( + RuntimeOrigin::signed(alice()), + bob() + )); + assert_ok!(PrestoPallet::create_crop_receipt( RuntimeOrigin::signed(bob()), amount, @@ -1003,6 +1311,21 @@ fn should_rate_crop_receipt() { alice() )); + assert_ok!(PrestoPallet::add_presto_manager( + RuntimeOrigin::root(), + dave() + )); + + assert_ok!(PrestoPallet::apply_creditor_kyc( + RuntimeOrigin::signed(dave()), + bob() + )); + + assert_ok!(PrestoPallet::apply_creditor_kyc( + RuntimeOrigin::signed(dave()), + charlie() + )); + assert_ok!(PrestoPallet::create_crop_receipt( RuntimeOrigin::signed(bob()), balance!(10000), @@ -1063,6 +1386,21 @@ fn should_decline_crop_receipt() { alice() )); + assert_ok!(PrestoPallet::add_presto_manager( + RuntimeOrigin::root(), + dave() + )); + + assert_ok!(PrestoPallet::apply_creditor_kyc( + RuntimeOrigin::signed(dave()), + bob() + )); + + assert_ok!(PrestoPallet::apply_creditor_kyc( + RuntimeOrigin::signed(dave()), + charlie() + )); + assert_ok!(PrestoPallet::create_crop_receipt( RuntimeOrigin::signed(bob()), balance!(10000), @@ -1126,6 +1464,21 @@ fn should_publish_crop_receipt() { alice() )); + assert_ok!(PrestoPallet::add_presto_manager( + RuntimeOrigin::root(), + dave() + )); + + assert_ok!(PrestoPallet::apply_creditor_kyc( + RuntimeOrigin::signed(dave()), + bob() + )); + + assert_ok!(PrestoPallet::apply_creditor_kyc( + RuntimeOrigin::signed(dave()), + charlie() + )); + assert_ok!(PrestoPallet::create_crop_receipt( RuntimeOrigin::signed(bob()), balance!(100000), @@ -1141,6 +1494,17 @@ fn should_publish_crop_receipt() { // test + assert_eq!( + extended_assets::Pallet::::soulbound_asset(SBT_PRACS.into_predefined()) + .unwrap() + .regulated_assets, + BTreeSet::from([PRUSD]) + ); + assert_eq!( + extended_assets::Pallet::::regulated_asset_to_sbt(PRUSD), + SBT_PRACS.into() + ); + let supply = 10000; assert_err!( @@ -1223,5 +1587,20 @@ fn should_publish_crop_receipt() { let order = OrderBookPallet::limit_orders(order_book_id, id).unwrap(); assert_eq!(order.owner, bob()); } + + assert_eq!( + extended_assets::Pallet::::soulbound_asset(SBT_PRACS.into_predefined()) + .unwrap() + .regulated_assets, + BTreeSet::from([PRUSD, coupon_asset_id]) + ); + assert_eq!( + extended_assets::Pallet::::regulated_asset_to_sbt(PRUSD), + SBT_PRACS.into() + ); + assert_eq!( + extended_assets::Pallet::::regulated_asset_to_sbt(coupon_asset_id), + SBT_PRACS.into() + ); }); } diff --git a/pallets/presto/src/weights.rs b/pallets/presto/src/weights.rs index 030ef9afd7..cc776d7a17 100644 --- a/pallets/presto/src/weights.rs +++ b/pallets/presto/src/weights.rs @@ -31,7 +31,7 @@ //! Autogenerated weights for `presto` //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2024-12-10, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! DATE: 2024-12-28, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` //! WORST CASE MAP SIZE: `1000000` //! HOSTNAME: `Local`, CPU: `12th Gen Intel(R) Core(TM) i5-12600K` //! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("local"), DB CACHE: 1024 @@ -51,8 +51,6 @@ // 50 // --repeat // 20 -// --output -// ./benches #![cfg_attr(rustfmt, rustfmt_skip)] #![allow(unused_parens)] @@ -67,6 +65,10 @@ pub trait WeightInfo { fn remove_presto_manager() -> Weight; fn add_presto_auditor() -> Weight; fn remove_presto_auditor() -> Weight; + fn apply_investor_kyc() -> Weight; + fn apply_creditor_kyc() -> Weight; + fn remove_investor_kyc() -> Weight; + fn remove_creditor_kyc() -> Weight; fn mint_presto_usd() -> Weight; fn burn_presto_usd() -> Weight; fn send_presto_usd() -> Weight; @@ -85,642 +87,926 @@ pub trait WeightInfo { /// Weight functions for `presto`. pub struct SubstrateWeight(PhantomData); impl WeightInfo for SubstrateWeight { - /// Storage: Presto Managers (r:1 w:1) - /// Proof: Presto Managers (max_values: Some(1), max_size: Some(3202), added: 3697, mode: MaxEncodedLen) - fn add_presto_manager() -> Weight { - // Proof Size summary in bytes: - // Measured: `76` - // Estimated: `3697` - // Minimum execution time: 6_617 nanoseconds. - Weight::from_parts(7_100_000, 3697) - .saturating_add(T::DbWeight::get().reads(1)) - .saturating_add(T::DbWeight::get().writes(1)) - } - /// Storage: Presto Managers (r:1 w:1) - /// Proof: Presto Managers (max_values: Some(1), max_size: Some(3202), added: 3697, mode: MaxEncodedLen) - fn remove_presto_manager() -> Weight { - // Proof Size summary in bytes: - // Measured: `167` - // Estimated: `3697` - // Minimum execution time: 7_713 nanoseconds. - Weight::from_parts(8_696_000, 3697) - .saturating_add(T::DbWeight::get().reads(1)) - .saturating_add(T::DbWeight::get().writes(1)) - } - /// Storage: Presto Auditors (r:1 w:1) - /// Proof: Presto Auditors (max_values: Some(1), max_size: Some(3202), added: 3697, mode: MaxEncodedLen) - fn add_presto_auditor() -> Weight { - // Proof Size summary in bytes: - // Measured: `76` - // Estimated: `3697` - // Minimum execution time: 6_256 nanoseconds. - Weight::from_parts(6_909_000, 3697) - .saturating_add(T::DbWeight::get().reads(1)) - .saturating_add(T::DbWeight::get().writes(1)) - } - /// Storage: Presto Auditors (r:1 w:1) - /// Proof: Presto Auditors (max_values: Some(1), max_size: Some(3202), added: 3697, mode: MaxEncodedLen) - fn remove_presto_auditor() -> Weight { - // Proof Size summary in bytes: - // Measured: `167` - // Estimated: `3697` - // Minimum execution time: 7_677 nanoseconds. - Weight::from_parts(8_145_000, 3697) - .saturating_add(T::DbWeight::get().reads(1)) - .saturating_add(T::DbWeight::get().writes(1)) - } - /// Storage: Presto Managers (r:1 w:0) - /// Proof: Presto Managers (max_values: Some(1), max_size: Some(3202), added: 3697, mode: MaxEncodedLen) - /// Storage: Assets AssetInfosV2 (r:1 w:0) - /// Proof Skipped: Assets AssetInfosV2 (max_values: None, max_size: None, mode: Measured) - /// Storage: Permissions Permissions (r:1 w:0) - /// Proof Skipped: Permissions Permissions (max_values: None, max_size: None, mode: Measured) - /// Storage: ExtendedAssets SoulboundAsset (r:1 w:0) - /// Proof: ExtendedAssets SoulboundAsset (max_values: None, max_size: Some(322091), added: 324566, mode: MaxEncodedLen) - /// Storage: Tokens Accounts (r:1 w:1) - /// Proof: Tokens Accounts (max_values: None, max_size: Some(136), added: 2611, mode: MaxEncodedLen) - /// Storage: Tokens TotalIssuance (r:1 w:1) - /// Proof: Tokens TotalIssuance (max_values: None, max_size: Some(56), added: 2531, mode: MaxEncodedLen) - /// Storage: System Account (r:1 w:1) - /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: MaxEncodedLen) - fn mint_presto_usd() -> Weight { - // Proof Size summary in bytes: - // Measured: `2120` - // Estimated: `345198` - // Minimum execution time: 39_146 nanoseconds. - Weight::from_parts(41_702_000, 345198) - .saturating_add(T::DbWeight::get().reads(7)) - .saturating_add(T::DbWeight::get().writes(3)) - } - /// Storage: Presto Managers (r:1 w:0) - /// Proof: Presto Managers (max_values: Some(1), max_size: Some(3202), added: 3697, mode: MaxEncodedLen) - /// Storage: ExtendedAssets SoulboundAsset (r:1 w:0) - /// Proof: ExtendedAssets SoulboundAsset (max_values: None, max_size: Some(322091), added: 324566, mode: MaxEncodedLen) - /// Storage: Assets AssetInfosV2 (r:1 w:0) - /// Proof Skipped: Assets AssetInfosV2 (max_values: None, max_size: None, mode: Measured) - /// Storage: Tokens Accounts (r:1 w:1) - /// Proof: Tokens Accounts (max_values: None, max_size: Some(136), added: 2611, mode: MaxEncodedLen) - /// Storage: Tokens TotalIssuance (r:1 w:1) - /// Proof: Tokens TotalIssuance (max_values: None, max_size: Some(56), added: 2531, mode: MaxEncodedLen) - fn burn_presto_usd() -> Weight { - // Proof Size summary in bytes: - // Measured: `1716` - // Estimated: `337596` - // Minimum execution time: 29_891 nanoseconds. - Weight::from_parts(31_087_000, 337596) - .saturating_add(T::DbWeight::get().reads(5)) - .saturating_add(T::DbWeight::get().writes(2)) - } - /// Storage: Presto Managers (r:1 w:0) - /// Proof: Presto Managers (max_values: Some(1), max_size: Some(3202), added: 3697, mode: MaxEncodedLen) - /// Storage: ExtendedAssets SoulboundAsset (r:1 w:0) - /// Proof: ExtendedAssets SoulboundAsset (max_values: None, max_size: Some(322091), added: 324566, mode: MaxEncodedLen) - /// Storage: Assets AssetInfosV2 (r:1 w:0) - /// Proof Skipped: Assets AssetInfosV2 (max_values: None, max_size: None, mode: Measured) - /// Storage: Tokens Accounts (r:2 w:2) - /// Proof: Tokens Accounts (max_values: None, max_size: Some(136), added: 2611, mode: MaxEncodedLen) - /// Storage: System Account (r:2 w:1) - /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: MaxEncodedLen) - fn send_presto_usd() -> Weight { - // Proof Size summary in bytes: - // Measured: `1838` - // Estimated: `343004` - // Minimum execution time: 37_014 nanoseconds. - Weight::from_parts(38_331_000, 343004) - .saturating_add(T::DbWeight::get().reads(7)) - .saturating_add(T::DbWeight::get().writes(3)) - } - /// Storage: Presto LastRequestId (r:1 w:1) - /// Proof: Presto LastRequestId (max_values: Some(1), max_size: Some(8), added: 503, mode: MaxEncodedLen) - /// Storage: Timestamp Now (r:1 w:0) - /// Proof: Timestamp Now (max_values: Some(1), max_size: Some(8), added: 503, mode: MaxEncodedLen) - /// Storage: Presto UserRequests (r:1 w:1) - /// Proof: Presto UserRequests (max_values: None, max_size: Some(524332), added: 526807, mode: MaxEncodedLen) - /// Storage: Presto Requests (r:0 w:1) - /// Proof: Presto Requests (max_values: None, max_size: Some(420), added: 2895, mode: MaxEncodedLen) - fn create_deposit_request() -> Weight { - // Proof Size summary in bytes: - // Measured: `256` - // Estimated: `527813` - // Minimum execution time: 10_917 nanoseconds. - Weight::from_parts(11_705_000, 527813) - .saturating_add(T::DbWeight::get().reads(3)) - .saturating_add(T::DbWeight::get().writes(3)) - } - /// Storage: Presto LastRequestId (r:1 w:1) - /// Proof: Presto LastRequestId (max_values: Some(1), max_size: Some(8), added: 503, mode: MaxEncodedLen) - /// Storage: ExtendedAssets SoulboundAsset (r:1 w:0) - /// Proof: ExtendedAssets SoulboundAsset (max_values: None, max_size: Some(322091), added: 324566, mode: MaxEncodedLen) - /// Storage: Assets AssetInfosV2 (r:1 w:0) - /// Proof Skipped: Assets AssetInfosV2 (max_values: None, max_size: None, mode: Measured) - /// Storage: Tokens Accounts (r:2 w:2) - /// Proof: Tokens Accounts (max_values: None, max_size: Some(136), added: 2611, mode: MaxEncodedLen) - /// Storage: System Account (r:2 w:1) - /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: MaxEncodedLen) - /// Storage: Timestamp Now (r:1 w:0) - /// Proof: Timestamp Now (max_values: Some(1), max_size: Some(8), added: 503, mode: MaxEncodedLen) - /// Storage: Presto UserRequests (r:1 w:1) - /// Proof: Presto UserRequests (max_values: None, max_size: Some(524332), added: 526807, mode: MaxEncodedLen) - /// Storage: Presto Requests (r:0 w:1) - /// Proof: Presto Requests (max_values: None, max_size: Some(420), added: 2895, mode: MaxEncodedLen) - fn create_withdraw_request() -> Weight { - // Proof Size summary in bytes: - // Measured: `2064` - // Estimated: `867346` - // Minimum execution time: 45_444 nanoseconds. - Weight::from_parts(47_933_000, 867346) - .saturating_add(T::DbWeight::get().reads(9)) - .saturating_add(T::DbWeight::get().writes(6)) - } - /// Storage: Presto Requests (r:1 w:1) - /// Proof: Presto Requests (max_values: None, max_size: Some(420), added: 2895, mode: MaxEncodedLen) - fn cancel_request() -> Weight { - // Proof Size summary in bytes: - // Measured: `298` - // Estimated: `2895` - // Minimum execution time: 8_267 nanoseconds. - Weight::from_parts(8_626_000, 2895) - .saturating_add(T::DbWeight::get().reads(1)) - .saturating_add(T::DbWeight::get().writes(1)) - } - /// Storage: Presto Managers (r:1 w:0) - /// Proof: Presto Managers (max_values: Some(1), max_size: Some(3202), added: 3697, mode: MaxEncodedLen) - /// Storage: Presto Requests (r:1 w:1) - /// Proof: Presto Requests (max_values: None, max_size: Some(420), added: 2895, mode: MaxEncodedLen) - /// Storage: ExtendedAssets SoulboundAsset (r:1 w:0) - /// Proof: ExtendedAssets SoulboundAsset (max_values: None, max_size: Some(322091), added: 324566, mode: MaxEncodedLen) - /// Storage: Assets AssetInfosV2 (r:1 w:0) - /// Proof Skipped: Assets AssetInfosV2 (max_values: None, max_size: None, mode: Measured) - /// Storage: Tokens Accounts (r:2 w:2) - /// Proof: Tokens Accounts (max_values: None, max_size: Some(136), added: 2611, mode: MaxEncodedLen) - /// Storage: System Account (r:2 w:1) - /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: MaxEncodedLen) - /// Storage: Timestamp Now (r:1 w:0) - /// Proof: Timestamp Now (max_values: Some(1), max_size: Some(8), added: 503, mode: MaxEncodedLen) - fn approve_deposit_request() -> Weight { - // Proof Size summary in bytes: - // Measured: `2236` - // Estimated: `346800` - // Minimum execution time: 45_051 nanoseconds. - Weight::from_parts(47_826_000, 346800) - .saturating_add(T::DbWeight::get().reads(9)) - .saturating_add(T::DbWeight::get().writes(4)) - } - /// Storage: Presto Managers (r:1 w:0) - /// Proof: Presto Managers (max_values: Some(1), max_size: Some(3202), added: 3697, mode: MaxEncodedLen) - /// Storage: Presto Requests (r:1 w:1) - /// Proof: Presto Requests (max_values: None, max_size: Some(420), added: 2895, mode: MaxEncodedLen) - /// Storage: ExtendedAssets SoulboundAsset (r:1 w:0) - /// Proof: ExtendedAssets SoulboundAsset (max_values: None, max_size: Some(322091), added: 324566, mode: MaxEncodedLen) - /// Storage: Assets AssetInfosV2 (r:1 w:0) - /// Proof Skipped: Assets AssetInfosV2 (max_values: None, max_size: None, mode: Measured) - /// Storage: Tokens Accounts (r:2 w:2) - /// Proof: Tokens Accounts (max_values: None, max_size: Some(136), added: 2611, mode: MaxEncodedLen) - /// Storage: System Account (r:1 w:0) - /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: MaxEncodedLen) - /// Storage: Timestamp Now (r:1 w:0) - /// Proof: Timestamp Now (max_values: Some(1), max_size: Some(8), added: 503, mode: MaxEncodedLen) - fn approve_withdraw_request() -> Weight { - // Proof Size summary in bytes: - // Measured: `2359` - // Estimated: `344320` - // Minimum execution time: 42_741 nanoseconds. - Weight::from_parts(44_619_000, 344320) - .saturating_add(T::DbWeight::get().reads(8)) - .saturating_add(T::DbWeight::get().writes(3)) - } - /// Storage: Presto Managers (r:1 w:0) - /// Proof: Presto Managers (max_values: Some(1), max_size: Some(3202), added: 3697, mode: MaxEncodedLen) - /// Storage: Presto Requests (r:1 w:1) - /// Proof: Presto Requests (max_values: None, max_size: Some(420), added: 2895, mode: MaxEncodedLen) - /// Storage: Timestamp Now (r:1 w:0) - /// Proof: Timestamp Now (max_values: Some(1), max_size: Some(8), added: 503, mode: MaxEncodedLen) - fn decline_request() -> Weight { - // Proof Size summary in bytes: - // Measured: `565` - // Estimated: `7095` - // Minimum execution time: 11_711 nanoseconds. - Weight::from_parts(12_575_000, 7095) - .saturating_add(T::DbWeight::get().reads(3)) - .saturating_add(T::DbWeight::get().writes(1)) - } - /// Storage: Presto LastCropReceiptId (r:1 w:1) - /// Proof: Presto LastCropReceiptId (max_values: Some(1), max_size: Some(8), added: 503, mode: MaxEncodedLen) - /// Storage: Timestamp Now (r:1 w:0) - /// Proof: Timestamp Now (max_values: Some(1), max_size: Some(8), added: 503, mode: MaxEncodedLen) - /// Storage: Presto UserCropReceipts (r:1 w:1) - /// Proof: Presto UserCropReceipts (max_values: None, max_size: Some(524332), added: 526807, mode: MaxEncodedLen) - /// Storage: Presto CropReceiptsContent (r:0 w:1) - /// Proof: Presto CropReceiptsContent (max_values: None, max_size: Some(30740), added: 33215, mode: MaxEncodedLen) - /// Storage: Presto CropReceipts (r:0 w:1) - /// Proof: Presto CropReceipts (max_values: None, max_size: Some(398), added: 2873, mode: MaxEncodedLen) - fn create_crop_receipt() -> Weight { - // Proof Size summary in bytes: - // Measured: `256` - // Estimated: `527813` - // Minimum execution time: 15_160 nanoseconds. - Weight::from_parts(16_304_000, 527813) - .saturating_add(T::DbWeight::get().reads(3)) - .saturating_add(T::DbWeight::get().writes(4)) - } - /// Storage: Presto Auditors (r:1 w:0) - /// Proof: Presto Auditors (max_values: Some(1), max_size: Some(3202), added: 3697, mode: MaxEncodedLen) - /// Storage: Presto CropReceipts (r:1 w:1) - /// Proof: Presto CropReceipts (max_values: None, max_size: Some(398), added: 2873, mode: MaxEncodedLen) - fn rate_crop_receipt() -> Weight { - // Proof Size summary in bytes: - // Measured: `429` - // Estimated: `6570` - // Minimum execution time: 10_366 nanoseconds. - Weight::from_parts(11_125_000, 6570) - .saturating_add(T::DbWeight::get().reads(2)) - .saturating_add(T::DbWeight::get().writes(1)) - } - /// Storage: Presto CropReceipts (r:1 w:1) - /// Proof: Presto CropReceipts (max_values: None, max_size: Some(398), added: 2873, mode: MaxEncodedLen) - fn decline_crop_receipt() -> Weight { - // Proof Size summary in bytes: - // Measured: `408` - // Estimated: `2873` - // Minimum execution time: 8_628 nanoseconds. - Weight::from_parts(9_092_000, 2873) - .saturating_add(T::DbWeight::get().reads(1)) - .saturating_add(T::DbWeight::get().writes(1)) - } - /// Storage: Presto CropReceipts (r:1 w:1) - /// Proof: Presto CropReceipts (max_values: None, max_size: Some(398), added: 2873, mode: MaxEncodedLen) - /// Storage: Presto LastCouponId (r:1 w:1) - /// Proof: Presto LastCouponId (max_values: Some(1), max_size: Some(8), added: 503, mode: MaxEncodedLen) - /// Storage: System Account (r:3 w:3) - /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: MaxEncodedLen) - /// Storage: Assets AssetOwners (r:2 w:1) - /// Proof Skipped: Assets AssetOwners (max_values: None, max_size: None, mode: Measured) - /// Storage: Permissions Owners (r:2 w:2) - /// Proof Skipped: Permissions Owners (max_values: None, max_size: None, mode: Measured) - /// Storage: Permissions Permissions (r:3 w:1) - /// Proof Skipped: Permissions Permissions (max_values: None, max_size: None, mode: Measured) - /// Storage: Tokens Accounts (r:3 w:3) - /// Proof: Tokens Accounts (max_values: None, max_size: Some(136), added: 2611, mode: MaxEncodedLen) - /// Storage: Tokens TotalIssuance (r:1 w:1) - /// Proof: Tokens TotalIssuance (max_values: None, max_size: Some(56), added: 2531, mode: MaxEncodedLen) - /// Storage: ExtendedAssets SoulboundAsset (r:1 w:0) - /// Proof: ExtendedAssets SoulboundAsset (max_values: None, max_size: Some(322091), added: 324566, mode: MaxEncodedLen) - /// Storage: DEXManager DEXInfos (r:1 w:0) - /// Proof Skipped: DEXManager DEXInfos (max_values: None, max_size: None, mode: Measured) - /// Storage: TradingPair EnabledSources (r:1 w:1) - /// Proof Skipped: TradingPair EnabledSources (max_values: None, max_size: None, mode: Measured) - /// Storage: OrderBook OrderBooks (r:1 w:1) - /// Proof: OrderBook OrderBooks (max_values: None, max_size: Some(238), added: 2713, mode: MaxEncodedLen) - /// Storage: Technical TechAccounts (r:1 w:1) - /// Proof Skipped: Technical TechAccounts (max_values: None, max_size: None, mode: Measured) - /// Storage: Timestamp Now (r:1 w:0) - /// Proof: Timestamp Now (max_values: Some(1), max_size: Some(8), added: 503, mode: MaxEncodedLen) - /// Storage: OrderBook UserLimitOrders (r:1 w:1) - /// Proof: OrderBook UserLimitOrders (max_values: None, max_size: Some(16518), added: 18993, mode: MaxEncodedLen) - /// Storage: OrderBook Asks (r:1 w:1) - /// Proof: OrderBook Asks (max_values: None, max_size: Some(16503), added: 18978, mode: MaxEncodedLen) - /// Storage: OrderBook AggregatedAsks (r:1 w:1) - /// Proof: OrderBook AggregatedAsks (max_values: None, max_size: Some(34902), added: 37377, mode: MaxEncodedLen) - /// Storage: OrderBook AggregatedBids (r:1 w:0) - /// Proof: OrderBook AggregatedBids (max_values: None, max_size: Some(34902), added: 37377, mode: MaxEncodedLen) - /// Storage: OrderBook LimitOrders (r:1 w:1) - /// Proof: OrderBook LimitOrders (max_values: None, max_size: Some(236), added: 2711, mode: MaxEncodedLen) - /// Storage: OrderBook ExpirationsAgenda (r:1 w:1) - /// Proof: OrderBook ExpirationsAgenda (max_values: None, max_size: Some(86022), added: 88497, mode: MaxEncodedLen) - /// Storage: Assets AssetInfosV2 (r:0 w:1) - /// Proof Skipped: Assets AssetInfosV2 (max_values: None, max_size: None, mode: Measured) - /// Storage: Assets AssetInfos (r:0 w:1) - /// Proof Skipped: Assets AssetInfos (max_values: None, max_size: None, mode: Measured) - /// Storage: Presto Coupons (r:0 w:1) - /// Proof: Presto Coupons (max_values: None, max_size: Some(48), added: 2523, mode: MaxEncodedLen) - fn publish_crop_receipt() -> Weight { - // Proof Size summary in bytes: - // Measured: `5096` - // Estimated: `618782` - // Minimum execution time: 217_008 nanoseconds. - Weight::from_parts(226_387_000, 618782) - .saturating_add(T::DbWeight::get().reads(28)) - .saturating_add(T::DbWeight::get().writes(24)) - } + /// Storage: Presto Managers (r:1 w:1) + /// Proof: Presto Managers (max_values: Some(1), max_size: Some(3202), added: 3697, mode: MaxEncodedLen) + fn add_presto_manager() -> Weight { + // Proof Size summary in bytes: + // Measured: `76` + // Estimated: `3697` + // Minimum execution time: 6_489 nanoseconds. + Weight::from_parts(6_937_000, 3697) + .saturating_add(T::DbWeight::get().reads(1)) + .saturating_add(T::DbWeight::get().writes(1)) + } + /// Storage: Presto Managers (r:1 w:1) + /// Proof: Presto Managers (max_values: Some(1), max_size: Some(3202), added: 3697, mode: MaxEncodedLen) + fn remove_presto_manager() -> Weight { + // Proof Size summary in bytes: + // Measured: `167` + // Estimated: `3697` + // Minimum execution time: 7_453 nanoseconds. + Weight::from_parts(7_787_000, 3697) + .saturating_add(T::DbWeight::get().reads(1)) + .saturating_add(T::DbWeight::get().writes(1)) + } + /// Storage: Presto Auditors (r:1 w:1) + /// Proof: Presto Auditors (max_values: Some(1), max_size: Some(3202), added: 3697, mode: MaxEncodedLen) + fn add_presto_auditor() -> Weight { + // Proof Size summary in bytes: + // Measured: `76` + // Estimated: `3697` + // Minimum execution time: 6_514 nanoseconds. + Weight::from_parts(6_769_000, 3697) + .saturating_add(T::DbWeight::get().reads(1)) + .saturating_add(T::DbWeight::get().writes(1)) + } + /// Storage: Presto Auditors (r:1 w:1) + /// Proof: Presto Auditors (max_values: Some(1), max_size: Some(3202), added: 3697, mode: MaxEncodedLen) + fn remove_presto_auditor() -> Weight { + // Proof Size summary in bytes: + // Measured: `167` + // Estimated: `3697` + // Minimum execution time: 7_613 nanoseconds. + Weight::from_parts(7_935_000, 3697) + .saturating_add(T::DbWeight::get().reads(1)) + .saturating_add(T::DbWeight::get().writes(1)) + } + /// Storage: Presto Managers (r:1 w:0) + /// Proof: Presto Managers (max_values: Some(1), max_size: Some(3202), added: 3697, mode: MaxEncodedLen) + /// Storage: Tokens Accounts (r:2 w:2) + /// Proof: Tokens Accounts (max_values: None, max_size: Some(136), added: 2611, mode: MaxEncodedLen) + /// Storage: Assets AssetOwners (r:1 w:0) + /// Proof Skipped: Assets AssetOwners (max_values: None, max_size: None, mode: Measured) + /// Storage: Assets AssetInfosV2 (r:2 w:0) + /// Proof Skipped: Assets AssetInfosV2 (max_values: None, max_size: None, mode: Measured) + /// Storage: Permissions Permissions (r:2 w:0) + /// Proof Skipped: Permissions Permissions (max_values: None, max_size: None, mode: Measured) + /// Storage: ExtendedAssets SoulboundAsset (r:2 w:0) + /// Proof: ExtendedAssets SoulboundAsset (max_values: None, max_size: Some(322091), added: 324566, mode: MaxEncodedLen) + /// Storage: Tokens TotalIssuance (r:2 w:2) + /// Proof: Tokens TotalIssuance (max_values: None, max_size: Some(56), added: 2531, mode: MaxEncodedLen) + /// Storage: System Account (r:1 w:1) + /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: MaxEncodedLen) + fn apply_investor_kyc() -> Weight { + // Proof Size summary in bytes: + // Measured: `3116` + // Estimated: `687439` + // Minimum execution time: 61_406 nanoseconds. + Weight::from_parts(65_447_000, 687439) + .saturating_add(T::DbWeight::get().reads(13)) + .saturating_add(T::DbWeight::get().writes(5)) + } + /// Storage: Presto Managers (r:1 w:0) + /// Proof: Presto Managers (max_values: Some(1), max_size: Some(3202), added: 3697, mode: MaxEncodedLen) + /// Storage: Tokens Accounts (r:2 w:2) + /// Proof: Tokens Accounts (max_values: None, max_size: Some(136), added: 2611, mode: MaxEncodedLen) + /// Storage: Assets AssetOwners (r:1 w:0) + /// Proof Skipped: Assets AssetOwners (max_values: None, max_size: None, mode: Measured) + /// Storage: Assets AssetInfosV2 (r:2 w:0) + /// Proof Skipped: Assets AssetInfosV2 (max_values: None, max_size: None, mode: Measured) + /// Storage: Permissions Permissions (r:2 w:0) + /// Proof Skipped: Permissions Permissions (max_values: None, max_size: None, mode: Measured) + /// Storage: ExtendedAssets SoulboundAsset (r:2 w:0) + /// Proof: ExtendedAssets SoulboundAsset (max_values: None, max_size: Some(322091), added: 324566, mode: MaxEncodedLen) + /// Storage: Tokens TotalIssuance (r:2 w:2) + /// Proof: Tokens TotalIssuance (max_values: None, max_size: Some(56), added: 2531, mode: MaxEncodedLen) + /// Storage: System Account (r:1 w:1) + /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: MaxEncodedLen) + fn apply_creditor_kyc() -> Weight { + // Proof Size summary in bytes: + // Measured: `3143` + // Estimated: `687520` + // Minimum execution time: 64_817 nanoseconds. + Weight::from_parts(69_972_000, 687520) + .saturating_add(T::DbWeight::get().reads(13)) + .saturating_add(T::DbWeight::get().writes(5)) + } + /// Storage: Presto Managers (r:1 w:0) + /// Proof: Presto Managers (max_values: Some(1), max_size: Some(3202), added: 3697, mode: MaxEncodedLen) + /// Storage: Tokens Accounts (r:3 w:2) + /// Proof: Tokens Accounts (max_values: None, max_size: Some(136), added: 2611, mode: MaxEncodedLen) + /// Storage: Presto Coupons (r:1 w:0) + /// Proof: Presto Coupons (max_values: None, max_size: Some(48), added: 2523, mode: MaxEncodedLen) + /// Storage: Assets AssetOwners (r:2 w:0) + /// Proof Skipped: Assets AssetOwners (max_values: None, max_size: None, mode: Measured) + /// Storage: Permissions Permissions (r:2 w:0) + /// Proof Skipped: Permissions Permissions (max_values: None, max_size: None, mode: Measured) + /// Storage: ExtendedAssets SoulboundAsset (r:2 w:0) + /// Proof: ExtendedAssets SoulboundAsset (max_values: None, max_size: Some(322091), added: 324566, mode: MaxEncodedLen) + /// Storage: Tokens TotalIssuance (r:2 w:2) + /// Proof: Tokens TotalIssuance (max_values: None, max_size: Some(56), added: 2531, mode: MaxEncodedLen) + /// Storage: Assets AssetInfosV2 (r:1 w:0) + /// Proof Skipped: Assets AssetInfosV2 (max_values: None, max_size: None, mode: Measured) + fn remove_investor_kyc() -> Weight { + // Proof Size summary in bytes: + // Measured: `3261` + // Estimated: `690405` + // Minimum execution time: 62_887 nanoseconds. + Weight::from_parts(66_677_000, 690405) + .saturating_add(T::DbWeight::get().reads(14)) + .saturating_add(T::DbWeight::get().writes(4)) + } + /// Storage: Presto Managers (r:1 w:0) + /// Proof: Presto Managers (max_values: Some(1), max_size: Some(3202), added: 3697, mode: MaxEncodedLen) + /// Storage: Tokens Accounts (r:3 w:2) + /// Proof: Tokens Accounts (max_values: None, max_size: Some(136), added: 2611, mode: MaxEncodedLen) + /// Storage: Presto Coupons (r:1 w:0) + /// Proof: Presto Coupons (max_values: None, max_size: Some(48), added: 2523, mode: MaxEncodedLen) + /// Storage: Assets AssetOwners (r:2 w:0) + /// Proof Skipped: Assets AssetOwners (max_values: None, max_size: None, mode: Measured) + /// Storage: Permissions Permissions (r:2 w:0) + /// Proof Skipped: Permissions Permissions (max_values: None, max_size: None, mode: Measured) + /// Storage: ExtendedAssets SoulboundAsset (r:2 w:0) + /// Proof: ExtendedAssets SoulboundAsset (max_values: None, max_size: Some(322091), added: 324566, mode: MaxEncodedLen) + /// Storage: Tokens TotalIssuance (r:2 w:2) + /// Proof: Tokens TotalIssuance (max_values: None, max_size: Some(56), added: 2531, mode: MaxEncodedLen) + /// Storage: Assets AssetInfosV2 (r:1 w:0) + /// Proof Skipped: Assets AssetInfosV2 (max_values: None, max_size: None, mode: Measured) + fn remove_creditor_kyc() -> Weight { + // Proof Size summary in bytes: + // Measured: `3264` + // Estimated: `690414` + // Minimum execution time: 64_141 nanoseconds. + Weight::from_parts(66_715_000, 690414) + .saturating_add(T::DbWeight::get().reads(14)) + .saturating_add(T::DbWeight::get().writes(4)) + } + /// Storage: Presto Managers (r:1 w:0) + /// Proof: Presto Managers (max_values: Some(1), max_size: Some(3202), added: 3697, mode: MaxEncodedLen) + /// Storage: Assets AssetInfosV2 (r:1 w:0) + /// Proof Skipped: Assets AssetInfosV2 (max_values: None, max_size: None, mode: Measured) + /// Storage: Permissions Permissions (r:1 w:0) + /// Proof Skipped: Permissions Permissions (max_values: None, max_size: None, mode: Measured) + /// Storage: ExtendedAssets SoulboundAsset (r:1 w:0) + /// Proof: ExtendedAssets SoulboundAsset (max_values: None, max_size: Some(322091), added: 324566, mode: MaxEncodedLen) + /// Storage: Timestamp Now (r:1 w:0) + /// Proof: Timestamp Now (max_values: Some(1), max_size: Some(8), added: 503, mode: MaxEncodedLen) + /// Storage: ExtendedAssets RegulatedAssetToSoulboundAsset (r:1 w:0) + /// Proof: ExtendedAssets RegulatedAssetToSoulboundAsset (max_values: None, max_size: Some(64), added: 2539, mode: MaxEncodedLen) + /// Storage: Tokens Accounts (r:2 w:1) + /// Proof: Tokens Accounts (max_values: None, max_size: Some(136), added: 2611, mode: MaxEncodedLen) + /// Storage: ExtendedAssets SBTExpiration (r:1 w:0) + /// Proof: ExtendedAssets SBTExpiration (max_values: None, max_size: Some(72), added: 2547, mode: MaxEncodedLen) + /// Storage: Tokens TotalIssuance (r:1 w:1) + /// Proof: Tokens TotalIssuance (max_values: None, max_size: Some(56), added: 2531, mode: MaxEncodedLen) + /// Storage: System Account (r:1 w:1) + /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: MaxEncodedLen) + fn mint_presto_usd() -> Weight { + // Proof Size summary in bytes: + // Measured: `2864` + // Estimated: `354886` + // Minimum execution time: 50_228 nanoseconds. + Weight::from_parts(53_612_000, 354886) + .saturating_add(T::DbWeight::get().reads(11)) + .saturating_add(T::DbWeight::get().writes(3)) + } + /// Storage: Presto Managers (r:1 w:0) + /// Proof: Presto Managers (max_values: Some(1), max_size: Some(3202), added: 3697, mode: MaxEncodedLen) + /// Storage: ExtendedAssets SoulboundAsset (r:1 w:0) + /// Proof: ExtendedAssets SoulboundAsset (max_values: None, max_size: Some(322091), added: 324566, mode: MaxEncodedLen) + /// Storage: Assets AssetInfosV2 (r:1 w:0) + /// Proof Skipped: Assets AssetInfosV2 (max_values: None, max_size: None, mode: Measured) + /// Storage: Timestamp Now (r:1 w:0) + /// Proof: Timestamp Now (max_values: Some(1), max_size: Some(8), added: 503, mode: MaxEncodedLen) + /// Storage: ExtendedAssets RegulatedAssetToSoulboundAsset (r:1 w:0) + /// Proof: ExtendedAssets RegulatedAssetToSoulboundAsset (max_values: None, max_size: Some(64), added: 2539, mode: MaxEncodedLen) + /// Storage: Tokens Accounts (r:2 w:1) + /// Proof: Tokens Accounts (max_values: None, max_size: Some(136), added: 2611, mode: MaxEncodedLen) + /// Storage: ExtendedAssets SBTExpiration (r:1 w:0) + /// Proof: ExtendedAssets SBTExpiration (max_values: None, max_size: Some(72), added: 2547, mode: MaxEncodedLen) + /// Storage: Tokens TotalIssuance (r:1 w:1) + /// Proof: Tokens TotalIssuance (max_values: None, max_size: Some(56), added: 2531, mode: MaxEncodedLen) + fn burn_presto_usd() -> Weight { + // Proof Size summary in bytes: + // Measured: `2302` + // Estimated: `346382` + // Minimum execution time: 40_654 nanoseconds. + Weight::from_parts(41_964_000, 346382) + .saturating_add(T::DbWeight::get().reads(9)) + .saturating_add(T::DbWeight::get().writes(2)) + } + /// Storage: Presto Managers (r:1 w:0) + /// Proof: Presto Managers (max_values: Some(1), max_size: Some(3202), added: 3697, mode: MaxEncodedLen) + /// Storage: ExtendedAssets SoulboundAsset (r:1 w:0) + /// Proof: ExtendedAssets SoulboundAsset (max_values: None, max_size: Some(322091), added: 324566, mode: MaxEncodedLen) + /// Storage: Assets AssetInfosV2 (r:1 w:0) + /// Proof Skipped: Assets AssetInfosV2 (max_values: None, max_size: None, mode: Measured) + /// Storage: Timestamp Now (r:1 w:0) + /// Proof: Timestamp Now (max_values: Some(1), max_size: Some(8), added: 503, mode: MaxEncodedLen) + /// Storage: ExtendedAssets RegulatedAssetToSoulboundAsset (r:1 w:0) + /// Proof: ExtendedAssets RegulatedAssetToSoulboundAsset (max_values: None, max_size: Some(64), added: 2539, mode: MaxEncodedLen) + /// Storage: Tokens Accounts (r:4 w:2) + /// Proof: Tokens Accounts (max_values: None, max_size: Some(136), added: 2611, mode: MaxEncodedLen) + /// Storage: ExtendedAssets SBTExpiration (r:2 w:0) + /// Proof: ExtendedAssets SBTExpiration (max_values: None, max_size: Some(72), added: 2547, mode: MaxEncodedLen) + /// Storage: System Account (r:2 w:1) + /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: MaxEncodedLen) + fn send_presto_usd() -> Weight { + // Proof Size summary in bytes: + // Measured: `2605` + // Estimated: `357129` + // Minimum execution time: 53_156 nanoseconds. + Weight::from_parts(56_088_000, 357129) + .saturating_add(T::DbWeight::get().reads(13)) + .saturating_add(T::DbWeight::get().writes(3)) + } + /// Storage: Tokens Accounts (r:1 w:0) + /// Proof: Tokens Accounts (max_values: None, max_size: Some(136), added: 2611, mode: MaxEncodedLen) + /// Storage: Presto LastRequestId (r:1 w:1) + /// Proof: Presto LastRequestId (max_values: Some(1), max_size: Some(8), added: 503, mode: MaxEncodedLen) + /// Storage: Timestamp Now (r:1 w:0) + /// Proof: Timestamp Now (max_values: Some(1), max_size: Some(8), added: 503, mode: MaxEncodedLen) + /// Storage: Presto UserRequests (r:1 w:1) + /// Proof: Presto UserRequests (max_values: None, max_size: Some(524332), added: 526807, mode: MaxEncodedLen) + /// Storage: Presto Requests (r:0 w:1) + /// Proof: Presto Requests (max_values: None, max_size: Some(420), added: 2895, mode: MaxEncodedLen) + fn create_deposit_request() -> Weight { + // Proof Size summary in bytes: + // Measured: `876` + // Estimated: `530424` + // Minimum execution time: 18_148 nanoseconds. + Weight::from_parts(19_552_000, 530424) + .saturating_add(T::DbWeight::get().reads(4)) + .saturating_add(T::DbWeight::get().writes(3)) + } + /// Storage: Tokens Accounts (r:4 w:2) + /// Proof: Tokens Accounts (max_values: None, max_size: Some(136), added: 2611, mode: MaxEncodedLen) + /// Storage: Presto LastRequestId (r:1 w:1) + /// Proof: Presto LastRequestId (max_values: Some(1), max_size: Some(8), added: 503, mode: MaxEncodedLen) + /// Storage: ExtendedAssets SoulboundAsset (r:1 w:0) + /// Proof: ExtendedAssets SoulboundAsset (max_values: None, max_size: Some(322091), added: 324566, mode: MaxEncodedLen) + /// Storage: Assets AssetInfosV2 (r:1 w:0) + /// Proof Skipped: Assets AssetInfosV2 (max_values: None, max_size: None, mode: Measured) + /// Storage: Timestamp Now (r:1 w:0) + /// Proof: Timestamp Now (max_values: Some(1), max_size: Some(8), added: 503, mode: MaxEncodedLen) + /// Storage: ExtendedAssets RegulatedAssetToSoulboundAsset (r:1 w:0) + /// Proof: ExtendedAssets RegulatedAssetToSoulboundAsset (max_values: None, max_size: Some(64), added: 2539, mode: MaxEncodedLen) + /// Storage: ExtendedAssets SBTExpiration (r:2 w:0) + /// Proof: ExtendedAssets SBTExpiration (max_values: None, max_size: Some(72), added: 2547, mode: MaxEncodedLen) + /// Storage: System Account (r:2 w:1) + /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: MaxEncodedLen) + /// Storage: Presto UserRequests (r:1 w:1) + /// Proof: Presto UserRequests (max_values: None, max_size: Some(524332), added: 526807, mode: MaxEncodedLen) + /// Storage: Presto Requests (r:0 w:1) + /// Proof: Presto Requests (max_values: None, max_size: Some(420), added: 2895, mode: MaxEncodedLen) + fn create_withdraw_request() -> Weight { + // Proof Size summary in bytes: + // Measured: `2617` + // Estimated: `880754` + // Minimum execution time: 61_425 nanoseconds. + Weight::from_parts(63_450_000, 880754) + .saturating_add(T::DbWeight::get().reads(14)) + .saturating_add(T::DbWeight::get().writes(6)) + } + /// Storage: Tokens Accounts (r:1 w:0) + /// Proof: Tokens Accounts (max_values: None, max_size: Some(136), added: 2611, mode: MaxEncodedLen) + /// Storage: Presto Requests (r:1 w:1) + /// Proof: Presto Requests (max_values: None, max_size: Some(420), added: 2895, mode: MaxEncodedLen) + fn cancel_request() -> Weight { + // Proof Size summary in bytes: + // Measured: `913` + // Estimated: `5506` + // Minimum execution time: 15_114 nanoseconds. + Weight::from_parts(15_987_000, 5506) + .saturating_add(T::DbWeight::get().reads(2)) + .saturating_add(T::DbWeight::get().writes(1)) + } + /// Storage: Presto Managers (r:1 w:0) + /// Proof: Presto Managers (max_values: Some(1), max_size: Some(3202), added: 3697, mode: MaxEncodedLen) + /// Storage: Presto Requests (r:1 w:1) + /// Proof: Presto Requests (max_values: None, max_size: Some(420), added: 2895, mode: MaxEncodedLen) + /// Storage: ExtendedAssets SoulboundAsset (r:1 w:0) + /// Proof: ExtendedAssets SoulboundAsset (max_values: None, max_size: Some(322091), added: 324566, mode: MaxEncodedLen) + /// Storage: Assets AssetInfosV2 (r:1 w:0) + /// Proof Skipped: Assets AssetInfosV2 (max_values: None, max_size: None, mode: Measured) + /// Storage: Timestamp Now (r:1 w:0) + /// Proof: Timestamp Now (max_values: Some(1), max_size: Some(8), added: 503, mode: MaxEncodedLen) + /// Storage: ExtendedAssets RegulatedAssetToSoulboundAsset (r:1 w:0) + /// Proof: ExtendedAssets RegulatedAssetToSoulboundAsset (max_values: None, max_size: Some(64), added: 2539, mode: MaxEncodedLen) + /// Storage: Tokens Accounts (r:4 w:2) + /// Proof: Tokens Accounts (max_values: None, max_size: Some(136), added: 2611, mode: MaxEncodedLen) + /// Storage: ExtendedAssets SBTExpiration (r:2 w:0) + /// Proof: ExtendedAssets SBTExpiration (max_values: None, max_size: Some(72), added: 2547, mode: MaxEncodedLen) + /// Storage: System Account (r:2 w:1) + /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: MaxEncodedLen) + fn approve_deposit_request() -> Weight { + // Proof Size summary in bytes: + // Measured: `2823` + // Estimated: `360242` + // Minimum execution time: 60_904 nanoseconds. + Weight::from_parts(63_373_000, 360242) + .saturating_add(T::DbWeight::get().reads(14)) + .saturating_add(T::DbWeight::get().writes(4)) + } + /// Storage: Presto Managers (r:1 w:0) + /// Proof: Presto Managers (max_values: Some(1), max_size: Some(3202), added: 3697, mode: MaxEncodedLen) + /// Storage: Presto Requests (r:1 w:1) + /// Proof: Presto Requests (max_values: None, max_size: Some(420), added: 2895, mode: MaxEncodedLen) + /// Storage: ExtendedAssets SoulboundAsset (r:1 w:0) + /// Proof: ExtendedAssets SoulboundAsset (max_values: None, max_size: Some(322091), added: 324566, mode: MaxEncodedLen) + /// Storage: Assets AssetInfosV2 (r:1 w:0) + /// Proof Skipped: Assets AssetInfosV2 (max_values: None, max_size: None, mode: Measured) + /// Storage: Timestamp Now (r:1 w:0) + /// Proof: Timestamp Now (max_values: Some(1), max_size: Some(8), added: 503, mode: MaxEncodedLen) + /// Storage: ExtendedAssets RegulatedAssetToSoulboundAsset (r:1 w:0) + /// Proof: ExtendedAssets RegulatedAssetToSoulboundAsset (max_values: None, max_size: Some(64), added: 2539, mode: MaxEncodedLen) + /// Storage: Tokens Accounts (r:4 w:2) + /// Proof: Tokens Accounts (max_values: None, max_size: Some(136), added: 2611, mode: MaxEncodedLen) + /// Storage: ExtendedAssets SBTExpiration (r:2 w:0) + /// Proof: ExtendedAssets SBTExpiration (max_values: None, max_size: Some(72), added: 2547, mode: MaxEncodedLen) + /// Storage: System Account (r:1 w:0) + /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: MaxEncodedLen) + fn approve_withdraw_request() -> Weight { + // Proof Size summary in bytes: + // Measured: `2829` + // Estimated: `357645` + // Minimum execution time: 57_031 nanoseconds. + Weight::from_parts(60_629_000, 357645) + .saturating_add(T::DbWeight::get().reads(13)) + .saturating_add(T::DbWeight::get().writes(3)) + } + /// Storage: Presto Managers (r:1 w:0) + /// Proof: Presto Managers (max_values: Some(1), max_size: Some(3202), added: 3697, mode: MaxEncodedLen) + /// Storage: Presto Requests (r:1 w:1) + /// Proof: Presto Requests (max_values: None, max_size: Some(420), added: 2895, mode: MaxEncodedLen) + /// Storage: Timestamp Now (r:1 w:0) + /// Proof: Timestamp Now (max_values: Some(1), max_size: Some(8), added: 503, mode: MaxEncodedLen) + fn decline_request() -> Weight { + // Proof Size summary in bytes: + // Measured: `565` + // Estimated: `7095` + // Minimum execution time: 13_619 nanoseconds. + Weight::from_parts(15_023_000, 7095) + .saturating_add(T::DbWeight::get().reads(3)) + .saturating_add(T::DbWeight::get().writes(1)) + } + /// Storage: Tokens Accounts (r:1 w:0) + /// Proof: Tokens Accounts (max_values: None, max_size: Some(136), added: 2611, mode: MaxEncodedLen) + /// Storage: Presto LastCropReceiptId (r:1 w:1) + /// Proof: Presto LastCropReceiptId (max_values: Some(1), max_size: Some(8), added: 503, mode: MaxEncodedLen) + /// Storage: Timestamp Now (r:1 w:0) + /// Proof: Timestamp Now (max_values: Some(1), max_size: Some(8), added: 503, mode: MaxEncodedLen) + /// Storage: Presto UserCropReceipts (r:1 w:1) + /// Proof: Presto UserCropReceipts (max_values: None, max_size: Some(524332), added: 526807, mode: MaxEncodedLen) + /// Storage: Presto CropReceiptsContent (r:0 w:1) + /// Proof: Presto CropReceiptsContent (max_values: None, max_size: Some(30740), added: 33215, mode: MaxEncodedLen) + /// Storage: Presto CropReceipts (r:0 w:1) + /// Proof: Presto CropReceipts (max_values: None, max_size: Some(398), added: 2873, mode: MaxEncodedLen) + fn create_crop_receipt() -> Weight { + // Proof Size summary in bytes: + // Measured: `876` + // Estimated: `530424` + // Minimum execution time: 22_650 nanoseconds. + Weight::from_parts(23_812_000, 530424) + .saturating_add(T::DbWeight::get().reads(4)) + .saturating_add(T::DbWeight::get().writes(4)) + } + /// Storage: Presto Auditors (r:1 w:0) + /// Proof: Presto Auditors (max_values: Some(1), max_size: Some(3202), added: 3697, mode: MaxEncodedLen) + /// Storage: Presto CropReceipts (r:1 w:1) + /// Proof: Presto CropReceipts (max_values: None, max_size: Some(398), added: 2873, mode: MaxEncodedLen) + fn rate_crop_receipt() -> Weight { + // Proof Size summary in bytes: + // Measured: `462` + // Estimated: `6570` + // Minimum execution time: 12_201 nanoseconds. + Weight::from_parts(12_933_000, 6570) + .saturating_add(T::DbWeight::get().reads(2)) + .saturating_add(T::DbWeight::get().writes(1)) + } + /// Storage: Tokens Accounts (r:1 w:0) + /// Proof: Tokens Accounts (max_values: None, max_size: Some(136), added: 2611, mode: MaxEncodedLen) + /// Storage: Presto CropReceipts (r:1 w:1) + /// Proof: Presto CropReceipts (max_values: None, max_size: Some(398), added: 2873, mode: MaxEncodedLen) + fn decline_crop_receipt() -> Weight { + // Proof Size summary in bytes: + // Measured: `1023` + // Estimated: `5484` + // Minimum execution time: 15_763 nanoseconds. + Weight::from_parts(16_970_000, 5484) + .saturating_add(T::DbWeight::get().reads(2)) + .saturating_add(T::DbWeight::get().writes(1)) + } + /// Storage: Tokens Accounts (r:7 w:4) + /// Proof: Tokens Accounts (max_values: None, max_size: Some(136), added: 2611, mode: MaxEncodedLen) + /// Storage: Presto CropReceipts (r:1 w:1) + /// Proof: Presto CropReceipts (max_values: None, max_size: Some(398), added: 2873, mode: MaxEncodedLen) + /// Storage: Presto LastCouponId (r:1 w:1) + /// Proof: Presto LastCouponId (max_values: Some(1), max_size: Some(8), added: 503, mode: MaxEncodedLen) + /// Storage: System Account (r:3 w:3) + /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: MaxEncodedLen) + /// Storage: Assets AssetOwners (r:3 w:1) + /// Proof Skipped: Assets AssetOwners (max_values: None, max_size: None, mode: Measured) + /// Storage: Permissions Owners (r:2 w:2) + /// Proof Skipped: Permissions Owners (max_values: None, max_size: None, mode: Measured) + /// Storage: Permissions Permissions (r:7 w:1) + /// Proof Skipped: Permissions Permissions (max_values: None, max_size: None, mode: Measured) + /// Storage: Tokens TotalIssuance (r:2 w:2) + /// Proof: Tokens TotalIssuance (max_values: None, max_size: Some(56), added: 2531, mode: MaxEncodedLen) + /// Storage: ExtendedAssets SoulboundAsset (r:2 w:1) + /// Proof: ExtendedAssets SoulboundAsset (max_values: None, max_size: Some(322091), added: 324566, mode: MaxEncodedLen) + /// Storage: ExtendedAssets RegulatedAssetToSoulboundAsset (r:1 w:1) + /// Proof: ExtendedAssets RegulatedAssetToSoulboundAsset (max_values: None, max_size: Some(64), added: 2539, mode: MaxEncodedLen) + /// Storage: Timestamp Now (r:1 w:0) + /// Proof: Timestamp Now (max_values: Some(1), max_size: Some(8), added: 503, mode: MaxEncodedLen) + /// Storage: ExtendedAssets SBTExpiration (r:3 w:0) + /// Proof: ExtendedAssets SBTExpiration (max_values: None, max_size: Some(72), added: 2547, mode: MaxEncodedLen) + /// Storage: DEXManager DEXInfos (r:1 w:0) + /// Proof Skipped: DEXManager DEXInfos (max_values: None, max_size: None, mode: Measured) + /// Storage: TradingPair EnabledSources (r:1 w:1) + /// Proof Skipped: TradingPair EnabledSources (max_values: None, max_size: None, mode: Measured) + /// Storage: OrderBook OrderBooks (r:1 w:1) + /// Proof: OrderBook OrderBooks (max_values: None, max_size: Some(238), added: 2713, mode: MaxEncodedLen) + /// Storage: Technical TechAccounts (r:1 w:1) + /// Proof Skipped: Technical TechAccounts (max_values: None, max_size: None, mode: Measured) + /// Storage: Assets AssetInfosV2 (r:1 w:1) + /// Proof Skipped: Assets AssetInfosV2 (max_values: None, max_size: None, mode: Measured) + /// Storage: OrderBook UserLimitOrders (r:1 w:1) + /// Proof: OrderBook UserLimitOrders (max_values: None, max_size: Some(16518), added: 18993, mode: MaxEncodedLen) + /// Storage: OrderBook Asks (r:1 w:1) + /// Proof: OrderBook Asks (max_values: None, max_size: Some(16503), added: 18978, mode: MaxEncodedLen) + /// Storage: OrderBook AggregatedAsks (r:1 w:1) + /// Proof: OrderBook AggregatedAsks (max_values: None, max_size: Some(34902), added: 37377, mode: MaxEncodedLen) + /// Storage: OrderBook AggregatedBids (r:1 w:0) + /// Proof: OrderBook AggregatedBids (max_values: None, max_size: Some(34902), added: 37377, mode: MaxEncodedLen) + /// Storage: OrderBook LimitOrders (r:1 w:1) + /// Proof: OrderBook LimitOrders (max_values: None, max_size: Some(236), added: 2711, mode: MaxEncodedLen) + /// Storage: OrderBook ExpirationsAgenda (r:1 w:1) + /// Proof: OrderBook ExpirationsAgenda (max_values: None, max_size: Some(86022), added: 88497, mode: MaxEncodedLen) + /// Storage: Assets AssetInfos (r:0 w:1) + /// Proof Skipped: Assets AssetInfos (max_values: None, max_size: None, mode: Measured) + /// Storage: Presto Coupons (r:0 w:1) + /// Proof: Presto Coupons (max_values: None, max_size: Some(48), added: 2523, mode: MaxEncodedLen) + fn publish_crop_receipt() -> Weight { + // Proof Size summary in bytes: + // Measured: `6885` + // Estimated: `995665` + // Minimum execution time: 305_880 nanoseconds. + Weight::from_parts(312_918_000, 995665) + .saturating_add(T::DbWeight::get().reads(44)) + .saturating_add(T::DbWeight::get().writes(28)) + } } // For backwards compatibility and tests impl WeightInfo for () { - /// Storage: Presto Managers (r:1 w:1) - /// Proof: Presto Managers (max_values: Some(1), max_size: Some(3202), added: 3697, mode: MaxEncodedLen) - fn add_presto_manager() -> Weight { - // Proof Size summary in bytes: - // Measured: `76` - // Estimated: `3697` - // Minimum execution time: 6_617 nanoseconds. - Weight::from_parts(7_100_000, 3697) - .saturating_add(RocksDbWeight::get().reads(1)) - .saturating_add(RocksDbWeight::get().writes(1)) - } - /// Storage: Presto Managers (r:1 w:1) - /// Proof: Presto Managers (max_values: Some(1), max_size: Some(3202), added: 3697, mode: MaxEncodedLen) - fn remove_presto_manager() -> Weight { - // Proof Size summary in bytes: - // Measured: `167` - // Estimated: `3697` - // Minimum execution time: 7_713 nanoseconds. - Weight::from_parts(8_696_000, 3697) - .saturating_add(RocksDbWeight::get().reads(1)) - .saturating_add(RocksDbWeight::get().writes(1)) - } - /// Storage: Presto Auditors (r:1 w:1) - /// Proof: Presto Auditors (max_values: Some(1), max_size: Some(3202), added: 3697, mode: MaxEncodedLen) - fn add_presto_auditor() -> Weight { - // Proof Size summary in bytes: - // Measured: `76` - // Estimated: `3697` - // Minimum execution time: 6_256 nanoseconds. - Weight::from_parts(6_909_000, 3697) - .saturating_add(RocksDbWeight::get().reads(1)) - .saturating_add(RocksDbWeight::get().writes(1)) - } - /// Storage: Presto Auditors (r:1 w:1) - /// Proof: Presto Auditors (max_values: Some(1), max_size: Some(3202), added: 3697, mode: MaxEncodedLen) - fn remove_presto_auditor() -> Weight { - // Proof Size summary in bytes: - // Measured: `167` - // Estimated: `3697` - // Minimum execution time: 7_677 nanoseconds. - Weight::from_parts(8_145_000, 3697) - .saturating_add(RocksDbWeight::get().reads(1)) - .saturating_add(RocksDbWeight::get().writes(1)) - } - /// Storage: Presto Managers (r:1 w:0) - /// Proof: Presto Managers (max_values: Some(1), max_size: Some(3202), added: 3697, mode: MaxEncodedLen) - /// Storage: Assets AssetInfosV2 (r:1 w:0) - /// Proof Skipped: Assets AssetInfosV2 (max_values: None, max_size: None, mode: Measured) - /// Storage: Permissions Permissions (r:1 w:0) - /// Proof Skipped: Permissions Permissions (max_values: None, max_size: None, mode: Measured) - /// Storage: ExtendedAssets SoulboundAsset (r:1 w:0) - /// Proof: ExtendedAssets SoulboundAsset (max_values: None, max_size: Some(322091), added: 324566, mode: MaxEncodedLen) - /// Storage: Tokens Accounts (r:1 w:1) - /// Proof: Tokens Accounts (max_values: None, max_size: Some(136), added: 2611, mode: MaxEncodedLen) - /// Storage: Tokens TotalIssuance (r:1 w:1) - /// Proof: Tokens TotalIssuance (max_values: None, max_size: Some(56), added: 2531, mode: MaxEncodedLen) - /// Storage: System Account (r:1 w:1) - /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: MaxEncodedLen) - fn mint_presto_usd() -> Weight { - // Proof Size summary in bytes: - // Measured: `2120` - // Estimated: `345198` - // Minimum execution time: 39_146 nanoseconds. - Weight::from_parts(41_702_000, 345198) - .saturating_add(RocksDbWeight::get().reads(7)) - .saturating_add(RocksDbWeight::get().writes(3)) - } - /// Storage: Presto Managers (r:1 w:0) - /// Proof: Presto Managers (max_values: Some(1), max_size: Some(3202), added: 3697, mode: MaxEncodedLen) - /// Storage: ExtendedAssets SoulboundAsset (r:1 w:0) - /// Proof: ExtendedAssets SoulboundAsset (max_values: None, max_size: Some(322091), added: 324566, mode: MaxEncodedLen) - /// Storage: Assets AssetInfosV2 (r:1 w:0) - /// Proof Skipped: Assets AssetInfosV2 (max_values: None, max_size: None, mode: Measured) - /// Storage: Tokens Accounts (r:1 w:1) - /// Proof: Tokens Accounts (max_values: None, max_size: Some(136), added: 2611, mode: MaxEncodedLen) - /// Storage: Tokens TotalIssuance (r:1 w:1) - /// Proof: Tokens TotalIssuance (max_values: None, max_size: Some(56), added: 2531, mode: MaxEncodedLen) - fn burn_presto_usd() -> Weight { - // Proof Size summary in bytes: - // Measured: `1716` - // Estimated: `337596` - // Minimum execution time: 29_891 nanoseconds. - Weight::from_parts(31_087_000, 337596) - .saturating_add(RocksDbWeight::get().reads(5)) - .saturating_add(RocksDbWeight::get().writes(2)) - } - /// Storage: Presto Managers (r:1 w:0) - /// Proof: Presto Managers (max_values: Some(1), max_size: Some(3202), added: 3697, mode: MaxEncodedLen) - /// Storage: ExtendedAssets SoulboundAsset (r:1 w:0) - /// Proof: ExtendedAssets SoulboundAsset (max_values: None, max_size: Some(322091), added: 324566, mode: MaxEncodedLen) - /// Storage: Assets AssetInfosV2 (r:1 w:0) - /// Proof Skipped: Assets AssetInfosV2 (max_values: None, max_size: None, mode: Measured) - /// Storage: Tokens Accounts (r:2 w:2) - /// Proof: Tokens Accounts (max_values: None, max_size: Some(136), added: 2611, mode: MaxEncodedLen) - /// Storage: System Account (r:2 w:1) - /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: MaxEncodedLen) - fn send_presto_usd() -> Weight { - // Proof Size summary in bytes: - // Measured: `1838` - // Estimated: `343004` - // Minimum execution time: 37_014 nanoseconds. - Weight::from_parts(38_331_000, 343004) - .saturating_add(RocksDbWeight::get().reads(7)) - .saturating_add(RocksDbWeight::get().writes(3)) - } - /// Storage: Presto LastRequestId (r:1 w:1) - /// Proof: Presto LastRequestId (max_values: Some(1), max_size: Some(8), added: 503, mode: MaxEncodedLen) - /// Storage: Timestamp Now (r:1 w:0) - /// Proof: Timestamp Now (max_values: Some(1), max_size: Some(8), added: 503, mode: MaxEncodedLen) - /// Storage: Presto UserRequests (r:1 w:1) - /// Proof: Presto UserRequests (max_values: None, max_size: Some(524332), added: 526807, mode: MaxEncodedLen) - /// Storage: Presto Requests (r:0 w:1) - /// Proof: Presto Requests (max_values: None, max_size: Some(420), added: 2895, mode: MaxEncodedLen) - fn create_deposit_request() -> Weight { - // Proof Size summary in bytes: - // Measured: `256` - // Estimated: `527813` - // Minimum execution time: 10_917 nanoseconds. - Weight::from_parts(11_705_000, 527813) - .saturating_add(RocksDbWeight::get().reads(3)) - .saturating_add(RocksDbWeight::get().writes(3)) - } - /// Storage: Presto LastRequestId (r:1 w:1) - /// Proof: Presto LastRequestId (max_values: Some(1), max_size: Some(8), added: 503, mode: MaxEncodedLen) - /// Storage: ExtendedAssets SoulboundAsset (r:1 w:0) - /// Proof: ExtendedAssets SoulboundAsset (max_values: None, max_size: Some(322091), added: 324566, mode: MaxEncodedLen) - /// Storage: Assets AssetInfosV2 (r:1 w:0) - /// Proof Skipped: Assets AssetInfosV2 (max_values: None, max_size: None, mode: Measured) - /// Storage: Tokens Accounts (r:2 w:2) - /// Proof: Tokens Accounts (max_values: None, max_size: Some(136), added: 2611, mode: MaxEncodedLen) - /// Storage: System Account (r:2 w:1) - /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: MaxEncodedLen) - /// Storage: Timestamp Now (r:1 w:0) - /// Proof: Timestamp Now (max_values: Some(1), max_size: Some(8), added: 503, mode: MaxEncodedLen) - /// Storage: Presto UserRequests (r:1 w:1) - /// Proof: Presto UserRequests (max_values: None, max_size: Some(524332), added: 526807, mode: MaxEncodedLen) - /// Storage: Presto Requests (r:0 w:1) - /// Proof: Presto Requests (max_values: None, max_size: Some(420), added: 2895, mode: MaxEncodedLen) - fn create_withdraw_request() -> Weight { - // Proof Size summary in bytes: - // Measured: `2064` - // Estimated: `867346` - // Minimum execution time: 45_444 nanoseconds. - Weight::from_parts(47_933_000, 867346) - .saturating_add(RocksDbWeight::get().reads(9)) - .saturating_add(RocksDbWeight::get().writes(6)) - } - /// Storage: Presto Requests (r:1 w:1) - /// Proof: Presto Requests (max_values: None, max_size: Some(420), added: 2895, mode: MaxEncodedLen) - fn cancel_request() -> Weight { - // Proof Size summary in bytes: - // Measured: `298` - // Estimated: `2895` - // Minimum execution time: 8_267 nanoseconds. - Weight::from_parts(8_626_000, 2895) - .saturating_add(RocksDbWeight::get().reads(1)) - .saturating_add(RocksDbWeight::get().writes(1)) - } - /// Storage: Presto Managers (r:1 w:0) - /// Proof: Presto Managers (max_values: Some(1), max_size: Some(3202), added: 3697, mode: MaxEncodedLen) - /// Storage: Presto Requests (r:1 w:1) - /// Proof: Presto Requests (max_values: None, max_size: Some(420), added: 2895, mode: MaxEncodedLen) - /// Storage: ExtendedAssets SoulboundAsset (r:1 w:0) - /// Proof: ExtendedAssets SoulboundAsset (max_values: None, max_size: Some(322091), added: 324566, mode: MaxEncodedLen) - /// Storage: Assets AssetInfosV2 (r:1 w:0) - /// Proof Skipped: Assets AssetInfosV2 (max_values: None, max_size: None, mode: Measured) - /// Storage: Tokens Accounts (r:2 w:2) - /// Proof: Tokens Accounts (max_values: None, max_size: Some(136), added: 2611, mode: MaxEncodedLen) - /// Storage: System Account (r:2 w:1) - /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: MaxEncodedLen) - /// Storage: Timestamp Now (r:1 w:0) - /// Proof: Timestamp Now (max_values: Some(1), max_size: Some(8), added: 503, mode: MaxEncodedLen) - fn approve_deposit_request() -> Weight { - // Proof Size summary in bytes: - // Measured: `2236` - // Estimated: `346800` - // Minimum execution time: 45_051 nanoseconds. - Weight::from_parts(47_826_000, 346800) - .saturating_add(RocksDbWeight::get().reads(9)) - .saturating_add(RocksDbWeight::get().writes(4)) - } - /// Storage: Presto Managers (r:1 w:0) - /// Proof: Presto Managers (max_values: Some(1), max_size: Some(3202), added: 3697, mode: MaxEncodedLen) - /// Storage: Presto Requests (r:1 w:1) - /// Proof: Presto Requests (max_values: None, max_size: Some(420), added: 2895, mode: MaxEncodedLen) - /// Storage: ExtendedAssets SoulboundAsset (r:1 w:0) - /// Proof: ExtendedAssets SoulboundAsset (max_values: None, max_size: Some(322091), added: 324566, mode: MaxEncodedLen) - /// Storage: Assets AssetInfosV2 (r:1 w:0) - /// Proof Skipped: Assets AssetInfosV2 (max_values: None, max_size: None, mode: Measured) - /// Storage: Tokens Accounts (r:2 w:2) - /// Proof: Tokens Accounts (max_values: None, max_size: Some(136), added: 2611, mode: MaxEncodedLen) - /// Storage: System Account (r:1 w:0) - /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: MaxEncodedLen) - /// Storage: Timestamp Now (r:1 w:0) - /// Proof: Timestamp Now (max_values: Some(1), max_size: Some(8), added: 503, mode: MaxEncodedLen) - fn approve_withdraw_request() -> Weight { - // Proof Size summary in bytes: - // Measured: `2359` - // Estimated: `344320` - // Minimum execution time: 42_741 nanoseconds. - Weight::from_parts(44_619_000, 344320) - .saturating_add(RocksDbWeight::get().reads(8)) - .saturating_add(RocksDbWeight::get().writes(3)) - } - /// Storage: Presto Managers (r:1 w:0) - /// Proof: Presto Managers (max_values: Some(1), max_size: Some(3202), added: 3697, mode: MaxEncodedLen) - /// Storage: Presto Requests (r:1 w:1) - /// Proof: Presto Requests (max_values: None, max_size: Some(420), added: 2895, mode: MaxEncodedLen) - /// Storage: Timestamp Now (r:1 w:0) - /// Proof: Timestamp Now (max_values: Some(1), max_size: Some(8), added: 503, mode: MaxEncodedLen) - fn decline_request() -> Weight { - // Proof Size summary in bytes: - // Measured: `565` - // Estimated: `7095` - // Minimum execution time: 11_711 nanoseconds. - Weight::from_parts(12_575_000, 7095) - .saturating_add(RocksDbWeight::get().reads(3)) - .saturating_add(RocksDbWeight::get().writes(1)) - } - /// Storage: Presto LastCropReceiptId (r:1 w:1) - /// Proof: Presto LastCropReceiptId (max_values: Some(1), max_size: Some(8), added: 503, mode: MaxEncodedLen) - /// Storage: Timestamp Now (r:1 w:0) - /// Proof: Timestamp Now (max_values: Some(1), max_size: Some(8), added: 503, mode: MaxEncodedLen) - /// Storage: Presto UserCropReceipts (r:1 w:1) - /// Proof: Presto UserCropReceipts (max_values: None, max_size: Some(524332), added: 526807, mode: MaxEncodedLen) - /// Storage: Presto CropReceiptsContent (r:0 w:1) - /// Proof: Presto CropReceiptsContent (max_values: None, max_size: Some(30740), added: 33215, mode: MaxEncodedLen) - /// Storage: Presto CropReceipts (r:0 w:1) - /// Proof: Presto CropReceipts (max_values: None, max_size: Some(398), added: 2873, mode: MaxEncodedLen) - fn create_crop_receipt() -> Weight { - // Proof Size summary in bytes: - // Measured: `256` - // Estimated: `527813` - // Minimum execution time: 15_160 nanoseconds. - Weight::from_parts(16_304_000, 527813) - .saturating_add(RocksDbWeight::get().reads(3)) - .saturating_add(RocksDbWeight::get().writes(4)) - } - /// Storage: Presto Auditors (r:1 w:0) - /// Proof: Presto Auditors (max_values: Some(1), max_size: Some(3202), added: 3697, mode: MaxEncodedLen) - /// Storage: Presto CropReceipts (r:1 w:1) - /// Proof: Presto CropReceipts (max_values: None, max_size: Some(398), added: 2873, mode: MaxEncodedLen) - fn rate_crop_receipt() -> Weight { - // Proof Size summary in bytes: - // Measured: `429` - // Estimated: `6570` - // Minimum execution time: 10_366 nanoseconds. - Weight::from_parts(11_125_000, 6570) - .saturating_add(RocksDbWeight::get().reads(2)) - .saturating_add(RocksDbWeight::get().writes(1)) - } - /// Storage: Presto CropReceipts (r:1 w:1) - /// Proof: Presto CropReceipts (max_values: None, max_size: Some(398), added: 2873, mode: MaxEncodedLen) - fn decline_crop_receipt() -> Weight { - // Proof Size summary in bytes: - // Measured: `408` - // Estimated: `2873` - // Minimum execution time: 8_628 nanoseconds. - Weight::from_parts(9_092_000, 2873) - .saturating_add(RocksDbWeight::get().reads(1)) - .saturating_add(RocksDbWeight::get().writes(1)) - } - /// Storage: Presto CropReceipts (r:1 w:1) - /// Proof: Presto CropReceipts (max_values: None, max_size: Some(398), added: 2873, mode: MaxEncodedLen) - /// Storage: Presto LastCouponId (r:1 w:1) - /// Proof: Presto LastCouponId (max_values: Some(1), max_size: Some(8), added: 503, mode: MaxEncodedLen) - /// Storage: System Account (r:3 w:3) - /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: MaxEncodedLen) - /// Storage: Assets AssetOwners (r:2 w:1) - /// Proof Skipped: Assets AssetOwners (max_values: None, max_size: None, mode: Measured) - /// Storage: Permissions Owners (r:2 w:2) - /// Proof Skipped: Permissions Owners (max_values: None, max_size: None, mode: Measured) - /// Storage: Permissions Permissions (r:3 w:1) - /// Proof Skipped: Permissions Permissions (max_values: None, max_size: None, mode: Measured) - /// Storage: Tokens Accounts (r:3 w:3) - /// Proof: Tokens Accounts (max_values: None, max_size: Some(136), added: 2611, mode: MaxEncodedLen) - /// Storage: Tokens TotalIssuance (r:1 w:1) - /// Proof: Tokens TotalIssuance (max_values: None, max_size: Some(56), added: 2531, mode: MaxEncodedLen) - /// Storage: ExtendedAssets SoulboundAsset (r:1 w:0) - /// Proof: ExtendedAssets SoulboundAsset (max_values: None, max_size: Some(322091), added: 324566, mode: MaxEncodedLen) - /// Storage: DEXManager DEXInfos (r:1 w:0) - /// Proof Skipped: DEXManager DEXInfos (max_values: None, max_size: None, mode: Measured) - /// Storage: TradingPair EnabledSources (r:1 w:1) - /// Proof Skipped: TradingPair EnabledSources (max_values: None, max_size: None, mode: Measured) - /// Storage: OrderBook OrderBooks (r:1 w:1) - /// Proof: OrderBook OrderBooks (max_values: None, max_size: Some(238), added: 2713, mode: MaxEncodedLen) - /// Storage: Technical TechAccounts (r:1 w:1) - /// Proof Skipped: Technical TechAccounts (max_values: None, max_size: None, mode: Measured) - /// Storage: Timestamp Now (r:1 w:0) - /// Proof: Timestamp Now (max_values: Some(1), max_size: Some(8), added: 503, mode: MaxEncodedLen) - /// Storage: OrderBook UserLimitOrders (r:1 w:1) - /// Proof: OrderBook UserLimitOrders (max_values: None, max_size: Some(16518), added: 18993, mode: MaxEncodedLen) - /// Storage: OrderBook Asks (r:1 w:1) - /// Proof: OrderBook Asks (max_values: None, max_size: Some(16503), added: 18978, mode: MaxEncodedLen) - /// Storage: OrderBook AggregatedAsks (r:1 w:1) - /// Proof: OrderBook AggregatedAsks (max_values: None, max_size: Some(34902), added: 37377, mode: MaxEncodedLen) - /// Storage: OrderBook AggregatedBids (r:1 w:0) - /// Proof: OrderBook AggregatedBids (max_values: None, max_size: Some(34902), added: 37377, mode: MaxEncodedLen) - /// Storage: OrderBook LimitOrders (r:1 w:1) - /// Proof: OrderBook LimitOrders (max_values: None, max_size: Some(236), added: 2711, mode: MaxEncodedLen) - /// Storage: OrderBook ExpirationsAgenda (r:1 w:1) - /// Proof: OrderBook ExpirationsAgenda (max_values: None, max_size: Some(86022), added: 88497, mode: MaxEncodedLen) - /// Storage: Assets AssetInfosV2 (r:0 w:1) - /// Proof Skipped: Assets AssetInfosV2 (max_values: None, max_size: None, mode: Measured) - /// Storage: Assets AssetInfos (r:0 w:1) - /// Proof Skipped: Assets AssetInfos (max_values: None, max_size: None, mode: Measured) - /// Storage: Presto Coupons (r:0 w:1) - /// Proof: Presto Coupons (max_values: None, max_size: Some(48), added: 2523, mode: MaxEncodedLen) - fn publish_crop_receipt() -> Weight { - // Proof Size summary in bytes: - // Measured: `5096` - // Estimated: `618782` - // Minimum execution time: 217_008 nanoseconds. - Weight::from_parts(226_387_000, 618782) - .saturating_add(RocksDbWeight::get().reads(28)) - .saturating_add(RocksDbWeight::get().writes(24)) - } + /// Storage: Presto Managers (r:1 w:1) + /// Proof: Presto Managers (max_values: Some(1), max_size: Some(3202), added: 3697, mode: MaxEncodedLen) + fn add_presto_manager() -> Weight { + // Proof Size summary in bytes: + // Measured: `76` + // Estimated: `3697` + // Minimum execution time: 6_489 nanoseconds. + Weight::from_parts(6_937_000, 3697) + .saturating_add(RocksDbWeight::get().reads(1)) + .saturating_add(RocksDbWeight::get().writes(1)) + } + /// Storage: Presto Managers (r:1 w:1) + /// Proof: Presto Managers (max_values: Some(1), max_size: Some(3202), added: 3697, mode: MaxEncodedLen) + fn remove_presto_manager() -> Weight { + // Proof Size summary in bytes: + // Measured: `167` + // Estimated: `3697` + // Minimum execution time: 7_453 nanoseconds. + Weight::from_parts(7_787_000, 3697) + .saturating_add(RocksDbWeight::get().reads(1)) + .saturating_add(RocksDbWeight::get().writes(1)) + } + /// Storage: Presto Auditors (r:1 w:1) + /// Proof: Presto Auditors (max_values: Some(1), max_size: Some(3202), added: 3697, mode: MaxEncodedLen) + fn add_presto_auditor() -> Weight { + // Proof Size summary in bytes: + // Measured: `76` + // Estimated: `3697` + // Minimum execution time: 6_514 nanoseconds. + Weight::from_parts(6_769_000, 3697) + .saturating_add(RocksDbWeight::get().reads(1)) + .saturating_add(RocksDbWeight::get().writes(1)) + } + /// Storage: Presto Auditors (r:1 w:1) + /// Proof: Presto Auditors (max_values: Some(1), max_size: Some(3202), added: 3697, mode: MaxEncodedLen) + fn remove_presto_auditor() -> Weight { + // Proof Size summary in bytes: + // Measured: `167` + // Estimated: `3697` + // Minimum execution time: 7_613 nanoseconds. + Weight::from_parts(7_935_000, 3697) + .saturating_add(RocksDbWeight::get().reads(1)) + .saturating_add(RocksDbWeight::get().writes(1)) + } + /// Storage: Presto Managers (r:1 w:0) + /// Proof: Presto Managers (max_values: Some(1), max_size: Some(3202), added: 3697, mode: MaxEncodedLen) + /// Storage: Tokens Accounts (r:2 w:2) + /// Proof: Tokens Accounts (max_values: None, max_size: Some(136), added: 2611, mode: MaxEncodedLen) + /// Storage: Assets AssetOwners (r:1 w:0) + /// Proof Skipped: Assets AssetOwners (max_values: None, max_size: None, mode: Measured) + /// Storage: Assets AssetInfosV2 (r:2 w:0) + /// Proof Skipped: Assets AssetInfosV2 (max_values: None, max_size: None, mode: Measured) + /// Storage: Permissions Permissions (r:2 w:0) + /// Proof Skipped: Permissions Permissions (max_values: None, max_size: None, mode: Measured) + /// Storage: ExtendedAssets SoulboundAsset (r:2 w:0) + /// Proof: ExtendedAssets SoulboundAsset (max_values: None, max_size: Some(322091), added: 324566, mode: MaxEncodedLen) + /// Storage: Tokens TotalIssuance (r:2 w:2) + /// Proof: Tokens TotalIssuance (max_values: None, max_size: Some(56), added: 2531, mode: MaxEncodedLen) + /// Storage: System Account (r:1 w:1) + /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: MaxEncodedLen) + fn apply_investor_kyc() -> Weight { + // Proof Size summary in bytes: + // Measured: `3116` + // Estimated: `687439` + // Minimum execution time: 61_406 nanoseconds. + Weight::from_parts(65_447_000, 687439) + .saturating_add(RocksDbWeight::get().reads(13)) + .saturating_add(RocksDbWeight::get().writes(5)) + } + /// Storage: Presto Managers (r:1 w:0) + /// Proof: Presto Managers (max_values: Some(1), max_size: Some(3202), added: 3697, mode: MaxEncodedLen) + /// Storage: Tokens Accounts (r:2 w:2) + /// Proof: Tokens Accounts (max_values: None, max_size: Some(136), added: 2611, mode: MaxEncodedLen) + /// Storage: Assets AssetOwners (r:1 w:0) + /// Proof Skipped: Assets AssetOwners (max_values: None, max_size: None, mode: Measured) + /// Storage: Assets AssetInfosV2 (r:2 w:0) + /// Proof Skipped: Assets AssetInfosV2 (max_values: None, max_size: None, mode: Measured) + /// Storage: Permissions Permissions (r:2 w:0) + /// Proof Skipped: Permissions Permissions (max_values: None, max_size: None, mode: Measured) + /// Storage: ExtendedAssets SoulboundAsset (r:2 w:0) + /// Proof: ExtendedAssets SoulboundAsset (max_values: None, max_size: Some(322091), added: 324566, mode: MaxEncodedLen) + /// Storage: Tokens TotalIssuance (r:2 w:2) + /// Proof: Tokens TotalIssuance (max_values: None, max_size: Some(56), added: 2531, mode: MaxEncodedLen) + /// Storage: System Account (r:1 w:1) + /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: MaxEncodedLen) + fn apply_creditor_kyc() -> Weight { + // Proof Size summary in bytes: + // Measured: `3143` + // Estimated: `687520` + // Minimum execution time: 64_817 nanoseconds. + Weight::from_parts(69_972_000, 687520) + .saturating_add(RocksDbWeight::get().reads(13)) + .saturating_add(RocksDbWeight::get().writes(5)) + } + /// Storage: Presto Managers (r:1 w:0) + /// Proof: Presto Managers (max_values: Some(1), max_size: Some(3202), added: 3697, mode: MaxEncodedLen) + /// Storage: Tokens Accounts (r:3 w:2) + /// Proof: Tokens Accounts (max_values: None, max_size: Some(136), added: 2611, mode: MaxEncodedLen) + /// Storage: Presto Coupons (r:1 w:0) + /// Proof: Presto Coupons (max_values: None, max_size: Some(48), added: 2523, mode: MaxEncodedLen) + /// Storage: Assets AssetOwners (r:2 w:0) + /// Proof Skipped: Assets AssetOwners (max_values: None, max_size: None, mode: Measured) + /// Storage: Permissions Permissions (r:2 w:0) + /// Proof Skipped: Permissions Permissions (max_values: None, max_size: None, mode: Measured) + /// Storage: ExtendedAssets SoulboundAsset (r:2 w:0) + /// Proof: ExtendedAssets SoulboundAsset (max_values: None, max_size: Some(322091), added: 324566, mode: MaxEncodedLen) + /// Storage: Tokens TotalIssuance (r:2 w:2) + /// Proof: Tokens TotalIssuance (max_values: None, max_size: Some(56), added: 2531, mode: MaxEncodedLen) + /// Storage: Assets AssetInfosV2 (r:1 w:0) + /// Proof Skipped: Assets AssetInfosV2 (max_values: None, max_size: None, mode: Measured) + fn remove_investor_kyc() -> Weight { + // Proof Size summary in bytes: + // Measured: `3261` + // Estimated: `690405` + // Minimum execution time: 62_887 nanoseconds. + Weight::from_parts(66_677_000, 690405) + .saturating_add(RocksDbWeight::get().reads(14)) + .saturating_add(RocksDbWeight::get().writes(4)) + } + /// Storage: Presto Managers (r:1 w:0) + /// Proof: Presto Managers (max_values: Some(1), max_size: Some(3202), added: 3697, mode: MaxEncodedLen) + /// Storage: Tokens Accounts (r:3 w:2) + /// Proof: Tokens Accounts (max_values: None, max_size: Some(136), added: 2611, mode: MaxEncodedLen) + /// Storage: Presto Coupons (r:1 w:0) + /// Proof: Presto Coupons (max_values: None, max_size: Some(48), added: 2523, mode: MaxEncodedLen) + /// Storage: Assets AssetOwners (r:2 w:0) + /// Proof Skipped: Assets AssetOwners (max_values: None, max_size: None, mode: Measured) + /// Storage: Permissions Permissions (r:2 w:0) + /// Proof Skipped: Permissions Permissions (max_values: None, max_size: None, mode: Measured) + /// Storage: ExtendedAssets SoulboundAsset (r:2 w:0) + /// Proof: ExtendedAssets SoulboundAsset (max_values: None, max_size: Some(322091), added: 324566, mode: MaxEncodedLen) + /// Storage: Tokens TotalIssuance (r:2 w:2) + /// Proof: Tokens TotalIssuance (max_values: None, max_size: Some(56), added: 2531, mode: MaxEncodedLen) + /// Storage: Assets AssetInfosV2 (r:1 w:0) + /// Proof Skipped: Assets AssetInfosV2 (max_values: None, max_size: None, mode: Measured) + fn remove_creditor_kyc() -> Weight { + // Proof Size summary in bytes: + // Measured: `3264` + // Estimated: `690414` + // Minimum execution time: 64_141 nanoseconds. + Weight::from_parts(66_715_000, 690414) + .saturating_add(RocksDbWeight::get().reads(14)) + .saturating_add(RocksDbWeight::get().writes(4)) + } + /// Storage: Presto Managers (r:1 w:0) + /// Proof: Presto Managers (max_values: Some(1), max_size: Some(3202), added: 3697, mode: MaxEncodedLen) + /// Storage: Assets AssetInfosV2 (r:1 w:0) + /// Proof Skipped: Assets AssetInfosV2 (max_values: None, max_size: None, mode: Measured) + /// Storage: Permissions Permissions (r:1 w:0) + /// Proof Skipped: Permissions Permissions (max_values: None, max_size: None, mode: Measured) + /// Storage: ExtendedAssets SoulboundAsset (r:1 w:0) + /// Proof: ExtendedAssets SoulboundAsset (max_values: None, max_size: Some(322091), added: 324566, mode: MaxEncodedLen) + /// Storage: Timestamp Now (r:1 w:0) + /// Proof: Timestamp Now (max_values: Some(1), max_size: Some(8), added: 503, mode: MaxEncodedLen) + /// Storage: ExtendedAssets RegulatedAssetToSoulboundAsset (r:1 w:0) + /// Proof: ExtendedAssets RegulatedAssetToSoulboundAsset (max_values: None, max_size: Some(64), added: 2539, mode: MaxEncodedLen) + /// Storage: Tokens Accounts (r:2 w:1) + /// Proof: Tokens Accounts (max_values: None, max_size: Some(136), added: 2611, mode: MaxEncodedLen) + /// Storage: ExtendedAssets SBTExpiration (r:1 w:0) + /// Proof: ExtendedAssets SBTExpiration (max_values: None, max_size: Some(72), added: 2547, mode: MaxEncodedLen) + /// Storage: Tokens TotalIssuance (r:1 w:1) + /// Proof: Tokens TotalIssuance (max_values: None, max_size: Some(56), added: 2531, mode: MaxEncodedLen) + /// Storage: System Account (r:1 w:1) + /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: MaxEncodedLen) + fn mint_presto_usd() -> Weight { + // Proof Size summary in bytes: + // Measured: `2864` + // Estimated: `354886` + // Minimum execution time: 50_228 nanoseconds. + Weight::from_parts(53_612_000, 354886) + .saturating_add(RocksDbWeight::get().reads(11)) + .saturating_add(RocksDbWeight::get().writes(3)) + } + /// Storage: Presto Managers (r:1 w:0) + /// Proof: Presto Managers (max_values: Some(1), max_size: Some(3202), added: 3697, mode: MaxEncodedLen) + /// Storage: ExtendedAssets SoulboundAsset (r:1 w:0) + /// Proof: ExtendedAssets SoulboundAsset (max_values: None, max_size: Some(322091), added: 324566, mode: MaxEncodedLen) + /// Storage: Assets AssetInfosV2 (r:1 w:0) + /// Proof Skipped: Assets AssetInfosV2 (max_values: None, max_size: None, mode: Measured) + /// Storage: Timestamp Now (r:1 w:0) + /// Proof: Timestamp Now (max_values: Some(1), max_size: Some(8), added: 503, mode: MaxEncodedLen) + /// Storage: ExtendedAssets RegulatedAssetToSoulboundAsset (r:1 w:0) + /// Proof: ExtendedAssets RegulatedAssetToSoulboundAsset (max_values: None, max_size: Some(64), added: 2539, mode: MaxEncodedLen) + /// Storage: Tokens Accounts (r:2 w:1) + /// Proof: Tokens Accounts (max_values: None, max_size: Some(136), added: 2611, mode: MaxEncodedLen) + /// Storage: ExtendedAssets SBTExpiration (r:1 w:0) + /// Proof: ExtendedAssets SBTExpiration (max_values: None, max_size: Some(72), added: 2547, mode: MaxEncodedLen) + /// Storage: Tokens TotalIssuance (r:1 w:1) + /// Proof: Tokens TotalIssuance (max_values: None, max_size: Some(56), added: 2531, mode: MaxEncodedLen) + fn burn_presto_usd() -> Weight { + // Proof Size summary in bytes: + // Measured: `2302` + // Estimated: `346382` + // Minimum execution time: 40_654 nanoseconds. + Weight::from_parts(41_964_000, 346382) + .saturating_add(RocksDbWeight::get().reads(9)) + .saturating_add(RocksDbWeight::get().writes(2)) + } + /// Storage: Presto Managers (r:1 w:0) + /// Proof: Presto Managers (max_values: Some(1), max_size: Some(3202), added: 3697, mode: MaxEncodedLen) + /// Storage: ExtendedAssets SoulboundAsset (r:1 w:0) + /// Proof: ExtendedAssets SoulboundAsset (max_values: None, max_size: Some(322091), added: 324566, mode: MaxEncodedLen) + /// Storage: Assets AssetInfosV2 (r:1 w:0) + /// Proof Skipped: Assets AssetInfosV2 (max_values: None, max_size: None, mode: Measured) + /// Storage: Timestamp Now (r:1 w:0) + /// Proof: Timestamp Now (max_values: Some(1), max_size: Some(8), added: 503, mode: MaxEncodedLen) + /// Storage: ExtendedAssets RegulatedAssetToSoulboundAsset (r:1 w:0) + /// Proof: ExtendedAssets RegulatedAssetToSoulboundAsset (max_values: None, max_size: Some(64), added: 2539, mode: MaxEncodedLen) + /// Storage: Tokens Accounts (r:4 w:2) + /// Proof: Tokens Accounts (max_values: None, max_size: Some(136), added: 2611, mode: MaxEncodedLen) + /// Storage: ExtendedAssets SBTExpiration (r:2 w:0) + /// Proof: ExtendedAssets SBTExpiration (max_values: None, max_size: Some(72), added: 2547, mode: MaxEncodedLen) + /// Storage: System Account (r:2 w:1) + /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: MaxEncodedLen) + fn send_presto_usd() -> Weight { + // Proof Size summary in bytes: + // Measured: `2605` + // Estimated: `357129` + // Minimum execution time: 53_156 nanoseconds. + Weight::from_parts(56_088_000, 357129) + .saturating_add(RocksDbWeight::get().reads(13)) + .saturating_add(RocksDbWeight::get().writes(3)) + } + /// Storage: Tokens Accounts (r:1 w:0) + /// Proof: Tokens Accounts (max_values: None, max_size: Some(136), added: 2611, mode: MaxEncodedLen) + /// Storage: Presto LastRequestId (r:1 w:1) + /// Proof: Presto LastRequestId (max_values: Some(1), max_size: Some(8), added: 503, mode: MaxEncodedLen) + /// Storage: Timestamp Now (r:1 w:0) + /// Proof: Timestamp Now (max_values: Some(1), max_size: Some(8), added: 503, mode: MaxEncodedLen) + /// Storage: Presto UserRequests (r:1 w:1) + /// Proof: Presto UserRequests (max_values: None, max_size: Some(524332), added: 526807, mode: MaxEncodedLen) + /// Storage: Presto Requests (r:0 w:1) + /// Proof: Presto Requests (max_values: None, max_size: Some(420), added: 2895, mode: MaxEncodedLen) + fn create_deposit_request() -> Weight { + // Proof Size summary in bytes: + // Measured: `876` + // Estimated: `530424` + // Minimum execution time: 18_148 nanoseconds. + Weight::from_parts(19_552_000, 530424) + .saturating_add(RocksDbWeight::get().reads(4)) + .saturating_add(RocksDbWeight::get().writes(3)) + } + /// Storage: Tokens Accounts (r:4 w:2) + /// Proof: Tokens Accounts (max_values: None, max_size: Some(136), added: 2611, mode: MaxEncodedLen) + /// Storage: Presto LastRequestId (r:1 w:1) + /// Proof: Presto LastRequestId (max_values: Some(1), max_size: Some(8), added: 503, mode: MaxEncodedLen) + /// Storage: ExtendedAssets SoulboundAsset (r:1 w:0) + /// Proof: ExtendedAssets SoulboundAsset (max_values: None, max_size: Some(322091), added: 324566, mode: MaxEncodedLen) + /// Storage: Assets AssetInfosV2 (r:1 w:0) + /// Proof Skipped: Assets AssetInfosV2 (max_values: None, max_size: None, mode: Measured) + /// Storage: Timestamp Now (r:1 w:0) + /// Proof: Timestamp Now (max_values: Some(1), max_size: Some(8), added: 503, mode: MaxEncodedLen) + /// Storage: ExtendedAssets RegulatedAssetToSoulboundAsset (r:1 w:0) + /// Proof: ExtendedAssets RegulatedAssetToSoulboundAsset (max_values: None, max_size: Some(64), added: 2539, mode: MaxEncodedLen) + /// Storage: ExtendedAssets SBTExpiration (r:2 w:0) + /// Proof: ExtendedAssets SBTExpiration (max_values: None, max_size: Some(72), added: 2547, mode: MaxEncodedLen) + /// Storage: System Account (r:2 w:1) + /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: MaxEncodedLen) + /// Storage: Presto UserRequests (r:1 w:1) + /// Proof: Presto UserRequests (max_values: None, max_size: Some(524332), added: 526807, mode: MaxEncodedLen) + /// Storage: Presto Requests (r:0 w:1) + /// Proof: Presto Requests (max_values: None, max_size: Some(420), added: 2895, mode: MaxEncodedLen) + fn create_withdraw_request() -> Weight { + // Proof Size summary in bytes: + // Measured: `2617` + // Estimated: `880754` + // Minimum execution time: 61_425 nanoseconds. + Weight::from_parts(63_450_000, 880754) + .saturating_add(RocksDbWeight::get().reads(14)) + .saturating_add(RocksDbWeight::get().writes(6)) + } + /// Storage: Tokens Accounts (r:1 w:0) + /// Proof: Tokens Accounts (max_values: None, max_size: Some(136), added: 2611, mode: MaxEncodedLen) + /// Storage: Presto Requests (r:1 w:1) + /// Proof: Presto Requests (max_values: None, max_size: Some(420), added: 2895, mode: MaxEncodedLen) + fn cancel_request() -> Weight { + // Proof Size summary in bytes: + // Measured: `913` + // Estimated: `5506` + // Minimum execution time: 15_114 nanoseconds. + Weight::from_parts(15_987_000, 5506) + .saturating_add(RocksDbWeight::get().reads(2)) + .saturating_add(RocksDbWeight::get().writes(1)) + } + /// Storage: Presto Managers (r:1 w:0) + /// Proof: Presto Managers (max_values: Some(1), max_size: Some(3202), added: 3697, mode: MaxEncodedLen) + /// Storage: Presto Requests (r:1 w:1) + /// Proof: Presto Requests (max_values: None, max_size: Some(420), added: 2895, mode: MaxEncodedLen) + /// Storage: ExtendedAssets SoulboundAsset (r:1 w:0) + /// Proof: ExtendedAssets SoulboundAsset (max_values: None, max_size: Some(322091), added: 324566, mode: MaxEncodedLen) + /// Storage: Assets AssetInfosV2 (r:1 w:0) + /// Proof Skipped: Assets AssetInfosV2 (max_values: None, max_size: None, mode: Measured) + /// Storage: Timestamp Now (r:1 w:0) + /// Proof: Timestamp Now (max_values: Some(1), max_size: Some(8), added: 503, mode: MaxEncodedLen) + /// Storage: ExtendedAssets RegulatedAssetToSoulboundAsset (r:1 w:0) + /// Proof: ExtendedAssets RegulatedAssetToSoulboundAsset (max_values: None, max_size: Some(64), added: 2539, mode: MaxEncodedLen) + /// Storage: Tokens Accounts (r:4 w:2) + /// Proof: Tokens Accounts (max_values: None, max_size: Some(136), added: 2611, mode: MaxEncodedLen) + /// Storage: ExtendedAssets SBTExpiration (r:2 w:0) + /// Proof: ExtendedAssets SBTExpiration (max_values: None, max_size: Some(72), added: 2547, mode: MaxEncodedLen) + /// Storage: System Account (r:2 w:1) + /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: MaxEncodedLen) + fn approve_deposit_request() -> Weight { + // Proof Size summary in bytes: + // Measured: `2823` + // Estimated: `360242` + // Minimum execution time: 60_904 nanoseconds. + Weight::from_parts(63_373_000, 360242) + .saturating_add(RocksDbWeight::get().reads(14)) + .saturating_add(RocksDbWeight::get().writes(4)) + } + /// Storage: Presto Managers (r:1 w:0) + /// Proof: Presto Managers (max_values: Some(1), max_size: Some(3202), added: 3697, mode: MaxEncodedLen) + /// Storage: Presto Requests (r:1 w:1) + /// Proof: Presto Requests (max_values: None, max_size: Some(420), added: 2895, mode: MaxEncodedLen) + /// Storage: ExtendedAssets SoulboundAsset (r:1 w:0) + /// Proof: ExtendedAssets SoulboundAsset (max_values: None, max_size: Some(322091), added: 324566, mode: MaxEncodedLen) + /// Storage: Assets AssetInfosV2 (r:1 w:0) + /// Proof Skipped: Assets AssetInfosV2 (max_values: None, max_size: None, mode: Measured) + /// Storage: Timestamp Now (r:1 w:0) + /// Proof: Timestamp Now (max_values: Some(1), max_size: Some(8), added: 503, mode: MaxEncodedLen) + /// Storage: ExtendedAssets RegulatedAssetToSoulboundAsset (r:1 w:0) + /// Proof: ExtendedAssets RegulatedAssetToSoulboundAsset (max_values: None, max_size: Some(64), added: 2539, mode: MaxEncodedLen) + /// Storage: Tokens Accounts (r:4 w:2) + /// Proof: Tokens Accounts (max_values: None, max_size: Some(136), added: 2611, mode: MaxEncodedLen) + /// Storage: ExtendedAssets SBTExpiration (r:2 w:0) + /// Proof: ExtendedAssets SBTExpiration (max_values: None, max_size: Some(72), added: 2547, mode: MaxEncodedLen) + /// Storage: System Account (r:1 w:0) + /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: MaxEncodedLen) + fn approve_withdraw_request() -> Weight { + // Proof Size summary in bytes: + // Measured: `2829` + // Estimated: `357645` + // Minimum execution time: 57_031 nanoseconds. + Weight::from_parts(60_629_000, 357645) + .saturating_add(RocksDbWeight::get().reads(13)) + .saturating_add(RocksDbWeight::get().writes(3)) + } + /// Storage: Presto Managers (r:1 w:0) + /// Proof: Presto Managers (max_values: Some(1), max_size: Some(3202), added: 3697, mode: MaxEncodedLen) + /// Storage: Presto Requests (r:1 w:1) + /// Proof: Presto Requests (max_values: None, max_size: Some(420), added: 2895, mode: MaxEncodedLen) + /// Storage: Timestamp Now (r:1 w:0) + /// Proof: Timestamp Now (max_values: Some(1), max_size: Some(8), added: 503, mode: MaxEncodedLen) + fn decline_request() -> Weight { + // Proof Size summary in bytes: + // Measured: `565` + // Estimated: `7095` + // Minimum execution time: 13_619 nanoseconds. + Weight::from_parts(15_023_000, 7095) + .saturating_add(RocksDbWeight::get().reads(3)) + .saturating_add(RocksDbWeight::get().writes(1)) + } + /// Storage: Tokens Accounts (r:1 w:0) + /// Proof: Tokens Accounts (max_values: None, max_size: Some(136), added: 2611, mode: MaxEncodedLen) + /// Storage: Presto LastCropReceiptId (r:1 w:1) + /// Proof: Presto LastCropReceiptId (max_values: Some(1), max_size: Some(8), added: 503, mode: MaxEncodedLen) + /// Storage: Timestamp Now (r:1 w:0) + /// Proof: Timestamp Now (max_values: Some(1), max_size: Some(8), added: 503, mode: MaxEncodedLen) + /// Storage: Presto UserCropReceipts (r:1 w:1) + /// Proof: Presto UserCropReceipts (max_values: None, max_size: Some(524332), added: 526807, mode: MaxEncodedLen) + /// Storage: Presto CropReceiptsContent (r:0 w:1) + /// Proof: Presto CropReceiptsContent (max_values: None, max_size: Some(30740), added: 33215, mode: MaxEncodedLen) + /// Storage: Presto CropReceipts (r:0 w:1) + /// Proof: Presto CropReceipts (max_values: None, max_size: Some(398), added: 2873, mode: MaxEncodedLen) + fn create_crop_receipt() -> Weight { + // Proof Size summary in bytes: + // Measured: `876` + // Estimated: `530424` + // Minimum execution time: 22_650 nanoseconds. + Weight::from_parts(23_812_000, 530424) + .saturating_add(RocksDbWeight::get().reads(4)) + .saturating_add(RocksDbWeight::get().writes(4)) + } + /// Storage: Presto Auditors (r:1 w:0) + /// Proof: Presto Auditors (max_values: Some(1), max_size: Some(3202), added: 3697, mode: MaxEncodedLen) + /// Storage: Presto CropReceipts (r:1 w:1) + /// Proof: Presto CropReceipts (max_values: None, max_size: Some(398), added: 2873, mode: MaxEncodedLen) + fn rate_crop_receipt() -> Weight { + // Proof Size summary in bytes: + // Measured: `462` + // Estimated: `6570` + // Minimum execution time: 12_201 nanoseconds. + Weight::from_parts(12_933_000, 6570) + .saturating_add(RocksDbWeight::get().reads(2)) + .saturating_add(RocksDbWeight::get().writes(1)) + } + /// Storage: Tokens Accounts (r:1 w:0) + /// Proof: Tokens Accounts (max_values: None, max_size: Some(136), added: 2611, mode: MaxEncodedLen) + /// Storage: Presto CropReceipts (r:1 w:1) + /// Proof: Presto CropReceipts (max_values: None, max_size: Some(398), added: 2873, mode: MaxEncodedLen) + fn decline_crop_receipt() -> Weight { + // Proof Size summary in bytes: + // Measured: `1023` + // Estimated: `5484` + // Minimum execution time: 15_763 nanoseconds. + Weight::from_parts(16_970_000, 5484) + .saturating_add(RocksDbWeight::get().reads(2)) + .saturating_add(RocksDbWeight::get().writes(1)) + } + /// Storage: Tokens Accounts (r:7 w:4) + /// Proof: Tokens Accounts (max_values: None, max_size: Some(136), added: 2611, mode: MaxEncodedLen) + /// Storage: Presto CropReceipts (r:1 w:1) + /// Proof: Presto CropReceipts (max_values: None, max_size: Some(398), added: 2873, mode: MaxEncodedLen) + /// Storage: Presto LastCouponId (r:1 w:1) + /// Proof: Presto LastCouponId (max_values: Some(1), max_size: Some(8), added: 503, mode: MaxEncodedLen) + /// Storage: System Account (r:3 w:3) + /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: MaxEncodedLen) + /// Storage: Assets AssetOwners (r:3 w:1) + /// Proof Skipped: Assets AssetOwners (max_values: None, max_size: None, mode: Measured) + /// Storage: Permissions Owners (r:2 w:2) + /// Proof Skipped: Permissions Owners (max_values: None, max_size: None, mode: Measured) + /// Storage: Permissions Permissions (r:7 w:1) + /// Proof Skipped: Permissions Permissions (max_values: None, max_size: None, mode: Measured) + /// Storage: Tokens TotalIssuance (r:2 w:2) + /// Proof: Tokens TotalIssuance (max_values: None, max_size: Some(56), added: 2531, mode: MaxEncodedLen) + /// Storage: ExtendedAssets SoulboundAsset (r:2 w:1) + /// Proof: ExtendedAssets SoulboundAsset (max_values: None, max_size: Some(322091), added: 324566, mode: MaxEncodedLen) + /// Storage: ExtendedAssets RegulatedAssetToSoulboundAsset (r:1 w:1) + /// Proof: ExtendedAssets RegulatedAssetToSoulboundAsset (max_values: None, max_size: Some(64), added: 2539, mode: MaxEncodedLen) + /// Storage: Timestamp Now (r:1 w:0) + /// Proof: Timestamp Now (max_values: Some(1), max_size: Some(8), added: 503, mode: MaxEncodedLen) + /// Storage: ExtendedAssets SBTExpiration (r:3 w:0) + /// Proof: ExtendedAssets SBTExpiration (max_values: None, max_size: Some(72), added: 2547, mode: MaxEncodedLen) + /// Storage: DEXManager DEXInfos (r:1 w:0) + /// Proof Skipped: DEXManager DEXInfos (max_values: None, max_size: None, mode: Measured) + /// Storage: TradingPair EnabledSources (r:1 w:1) + /// Proof Skipped: TradingPair EnabledSources (max_values: None, max_size: None, mode: Measured) + /// Storage: OrderBook OrderBooks (r:1 w:1) + /// Proof: OrderBook OrderBooks (max_values: None, max_size: Some(238), added: 2713, mode: MaxEncodedLen) + /// Storage: Technical TechAccounts (r:1 w:1) + /// Proof Skipped: Technical TechAccounts (max_values: None, max_size: None, mode: Measured) + /// Storage: Assets AssetInfosV2 (r:1 w:1) + /// Proof Skipped: Assets AssetInfosV2 (max_values: None, max_size: None, mode: Measured) + /// Storage: OrderBook UserLimitOrders (r:1 w:1) + /// Proof: OrderBook UserLimitOrders (max_values: None, max_size: Some(16518), added: 18993, mode: MaxEncodedLen) + /// Storage: OrderBook Asks (r:1 w:1) + /// Proof: OrderBook Asks (max_values: None, max_size: Some(16503), added: 18978, mode: MaxEncodedLen) + /// Storage: OrderBook AggregatedAsks (r:1 w:1) + /// Proof: OrderBook AggregatedAsks (max_values: None, max_size: Some(34902), added: 37377, mode: MaxEncodedLen) + /// Storage: OrderBook AggregatedBids (r:1 w:0) + /// Proof: OrderBook AggregatedBids (max_values: None, max_size: Some(34902), added: 37377, mode: MaxEncodedLen) + /// Storage: OrderBook LimitOrders (r:1 w:1) + /// Proof: OrderBook LimitOrders (max_values: None, max_size: Some(236), added: 2711, mode: MaxEncodedLen) + /// Storage: OrderBook ExpirationsAgenda (r:1 w:1) + /// Proof: OrderBook ExpirationsAgenda (max_values: None, max_size: Some(86022), added: 88497, mode: MaxEncodedLen) + /// Storage: Assets AssetInfos (r:0 w:1) + /// Proof Skipped: Assets AssetInfos (max_values: None, max_size: None, mode: Measured) + /// Storage: Presto Coupons (r:0 w:1) + /// Proof: Presto Coupons (max_values: None, max_size: Some(48), added: 2523, mode: MaxEncodedLen) + fn publish_crop_receipt() -> Weight { + // Proof Size summary in bytes: + // Measured: `6885` + // Estimated: `995665` + // Minimum execution time: 305_880 nanoseconds. + Weight::from_parts(312_918_000, 995665) + .saturating_add(RocksDbWeight::get().reads(44)) + .saturating_add(RocksDbWeight::get().writes(28)) + } } diff --git a/pallets/price-tools/src/mock.rs b/pallets/price-tools/src/mock.rs index a880aecfa0..b67bca3af1 100644 --- a/pallets/price-tools/src/mock.rs +++ b/pallets/price-tools/src/mock.rs @@ -365,6 +365,8 @@ impl ExtBuilder { ) }) .collect(), + regulated_assets: Default::default(), + sbt_assets: Default::default(), } .assimilate_storage(&mut t) .unwrap(); diff --git a/pallets/pswap-distribution/benchmarking/src/mock.rs b/pallets/pswap-distribution/benchmarking/src/mock.rs index a2eebe64b4..0979dff481 100644 --- a/pallets/pswap-distribution/benchmarking/src/mock.rs +++ b/pallets/pswap-distribution/benchmarking/src/mock.rs @@ -294,6 +294,8 @@ impl ExtBuilder { AssetsConfig { endowed_assets: self.endowed_assets, + regulated_assets: Default::default(), + sbt_assets: Default::default(), } .assimilate_storage(&mut t) .unwrap(); diff --git a/pallets/pswap-distribution/src/mock.rs b/pallets/pswap-distribution/src/mock.rs index e79d4630a3..c7bef83e51 100644 --- a/pallets/pswap-distribution/src/mock.rs +++ b/pallets/pswap-distribution/src/mock.rs @@ -332,6 +332,8 @@ impl ExtBuilder { AssetsConfig { endowed_assets: self.endowed_assets, + regulated_assets: Default::default(), + sbt_assets: Default::default(), } .assimilate_storage(&mut t) .unwrap(); diff --git a/pallets/qa-tools/Cargo.toml b/pallets/qa-tools/Cargo.toml index f467cac2b3..1f79129f7d 100644 --- a/pallets/qa-tools/Cargo.toml +++ b/pallets/qa-tools/Cargo.toml @@ -28,6 +28,7 @@ dex-manager = { path = "../dex-manager", default-features = false } multicollateral-bonding-curve-pool = { path = "../multicollateral-bonding-curve-pool", default-features = false } oracle-proxy = { path = "../oracle-proxy", default-features = false } order-book = { path = "../order-book", default-features = false } +pallet-timestamp = { git = "https://github.com/sora-xor/substrate.git", branch = "polkadot-v0.9.38", default-features = false } permissions = { path = "../permissions", default-features = false } pool-xyk = { path = "../pool-xyk", default-features = false } presto = { path = "../presto", default-features = false } @@ -56,6 +57,7 @@ std = [ "frame-system/std", "oracle-proxy/std", "order-book/std", + "pallet-timestamp/std", "pool-xyk/std", "price-tools/std", "scale-info/std", diff --git a/pallets/qa-tools/src/lib.rs b/pallets/qa-tools/src/lib.rs index d42bec04f5..426a2f2c5d 100644 --- a/pallets/qa-tools/src/lib.rs +++ b/pallets/qa-tools/src/lib.rs @@ -58,8 +58,8 @@ pub mod pallet { use common::{ AccountIdOf, AssetIdOf, AssetInfoProvider, AssetName, AssetSymbol, BalancePrecision, - ContentSource, DEXInfo, Description, DexIdOf, DexInfoProvider, OrderBookId, - SyntheticInfoProvider, TradingPairSourceManager, + ContentSource, DEXInfo, Description, DexIdOf, DexInfoProvider, ExtendedAssetsManager, + OrderBookId, SyntheticInfoProvider, TradingPairSourceManager, }; use frame_support::dispatch::{DispatchErrorWithPostInfo, PostDispatchInfo}; use frame_support::pallet_prelude::*; @@ -100,6 +100,11 @@ pub mod pallet { type DexInfoProvider: DexInfoProvider>>; type SyntheticInfoProvider: SyntheticInfoProvider>; type TradingPairSourceManager: TradingPairSourceManager>; + type ExtendedAssetsManager: ExtendedAssetsManager< + AssetIdOf, + Self::Moment, + ContentSource, + >; type Symbol: From<::Symbol> + From<::Symbol> + Into<::Symbol> @@ -181,6 +186,10 @@ pub mod pallet { /// Cannot deduce price of synthetic base asset because there is no existing price for reference asset. /// You can use `price_tools_set_asset_price` extrinsic to set its price. ReferenceAssetPriceNotFound, + + // presto errors + /// Cannot initialize SBT metadata with the list of regulated assets + FailToInitializeRegulatedAssets, } #[derive(Clone, PartialEq, Eq, Encode, Decode, scale_info::TypeInfo, Debug)] @@ -460,7 +469,7 @@ pub mod pallet { pub fn presto_initialize_assets(origin: OriginFor) -> DispatchResultWithPostInfo { ensure_root(origin)?; - pallet_tools::presto::register_presto_usd::()?; + pallet_tools::presto::register_presto_assets::()?; // Extrinsic is only for testing, so we return all fees // for simplicity. diff --git a/pallets/qa-tools/src/pallet_tools/presto.rs b/pallets/qa-tools/src/pallet_tools/presto.rs index 527cf7d75b..249b0556b2 100644 --- a/pallets/qa-tools/src/pallet_tools/presto.rs +++ b/pallets/qa-tools/src/pallet_tools/presto.rs @@ -32,10 +32,11 @@ use crate::Config; use common::{ AccountIdOf, AssetManager, AssetName, AssetSymbol, AssetType, DEXId, DEXInfo, DexIdOf, - FromGenericPair, DEFAULT_BALANCE_PRECISION, PRUSD, XST, + ExtendedAssetsManager, FromGenericPair, DEFAULT_BALANCE_PRECISION, PRUSD, SBT_PRACS, + SBT_PRCRDT, SBT_PRINVST, XST, }; use frame_support::sp_runtime::{DispatchError, DispatchResult}; -use permissions::{Scope, BURN, MINT}; +use permissions::{Scope, BURN, MANAGE_DEX, MINT}; fn system_asset_account_id() -> Result, DispatchError> { let assets_and_permissions_tech_account_id = T::TechAccountId::from_generic_pair( @@ -55,9 +56,21 @@ fn presto_main_account_id() -> Result, DispatchError> technical::Pallet::::tech_account_id_to_account_id(&tech_account_id) } -pub fn register_presto_usd() -> DispatchResult { +fn presto_buffer_account_id() -> Result, DispatchError> { + let tech_account_id = T::TechAccountId::from_generic_pair( + presto::TECH_ACCOUNT_PREFIX.to_vec(), + presto::TECH_ACCOUNT_BUFFER.to_vec(), + ); + + technical::Pallet::::tech_account_id_to_account_id(&tech_account_id) +} + +pub fn register_presto_assets() -> DispatchResult { let system_account_id = system_asset_account_id::()?; let presto_account_id = presto_main_account_id::()?; + let presto_buffer_account_id = presto_buffer_account_id::()?; + + let now = pallet_timestamp::Pallet::::now(); frame_system::Pallet::::inc_providers(&presto_account_id); @@ -69,25 +82,92 @@ pub fn register_presto_usd() -> DispatchResult { DEFAULT_BALANCE_PRECISION, 0, true, - AssetType::Regular, // TODO change to Regulated after adding of KYC SB token + AssetType::Regulated, + None, + None, + )?; + + T::AssetManager::register_asset_id( + system_account_id.clone(), + SBT_PRACS.into_predefined().into(), + AssetSymbol(b"PRACS".to_vec()), + AssetName(b"Presto Access".to_vec()), + 0, + 0, + true, + AssetType::Soulbound, + None, + None, + )?; + T::ExtendedAssetsManager::set_metadata(&SBT_PRACS.into_predefined().into(), None, now); + T::ExtendedAssetsManager::bind_regulated_asset_to_sbt_asset( + &SBT_PRACS.into_predefined().into(), + &PRUSD.into(), + )?; + + T::AssetManager::mint_to( + &SBT_PRACS.into_predefined().into(), + &system_account_id, + &presto_account_id, + 1, + )?; + T::AssetManager::mint_to( + &SBT_PRACS.into_predefined().into(), + &system_account_id, + &presto_buffer_account_id, + 1, + )?; + + T::AssetManager::register_asset_id( + system_account_id.clone(), + SBT_PRINVST.into_predefined().into(), + AssetSymbol(b"PRINVST".to_vec()), + AssetName(b"Presto Investor".to_vec()), + 0, + 0, + true, + AssetType::Soulbound, None, None, )?; + T::ExtendedAssetsManager::set_metadata(&SBT_PRINVST.into_predefined().into(), None, now); + + T::AssetManager::register_asset_id( + system_account_id.clone(), + SBT_PRCRDT.into_predefined().into(), + AssetSymbol(b"PRCRDT".to_vec()), + AssetName(b"Presto Creditor".to_vec()), + 0, + 0, + true, + AssetType::Soulbound, + None, + None, + )?; + T::ExtendedAssetsManager::set_metadata(&SBT_PRCRDT.into_predefined().into(), None, now); + + let scopes = [ + Scope::Limited(common::hash(&PRUSD)), + Scope::Limited(common::hash(&SBT_PRACS)), + Scope::Limited(common::hash(&SBT_PRINVST)), + Scope::Limited(common::hash(&SBT_PRCRDT)), + ]; - let scope = Scope::Limited(common::hash(&PRUSD)); let permission_ids = [MINT, BURN]; - for permission_id in &permission_ids { - let permission_owner = permissions::Owners::::get(permission_id, scope) - .pop() - .unwrap_or(system_account_id.clone()); - - permissions::Pallet::::grant_permission_with_scope( - permission_owner, - presto_account_id.clone(), - *permission_id, - scope, - )?; + for scope in scopes { + for permission_id in &permission_ids { + let permission_owner = permissions::Owners::::get(permission_id, scope) + .pop() + .unwrap_or(system_account_id.clone()); + + permissions::Pallet::::grant_permission_with_scope( + permission_owner, + presto_account_id.clone(), + *permission_id, + scope, + )?; + } } let dex_id: DexIdOf = DEXId::PolkaswapPresto.into(); @@ -98,10 +178,17 @@ pub fn register_presto_usd() -> DispatchResult { DEXInfo { base_asset_id: PRUSD.into(), synthetic_base_asset_id: XST.into(), - is_public: true, + is_public: false, }, ); } + permissions::Pallet::::assign_permission( + system_account_id, + &presto_account_id, + MANAGE_DEX, + Scope::Limited(common::hash(&DEXId::PolkaswapPresto)), + )?; + Ok(()) } diff --git a/pallets/referrals/src/mock.rs b/pallets/referrals/src/mock.rs index 9a08d4b051..a61fff7c62 100644 --- a/pallets/referrals/src/mock.rs +++ b/pallets/referrals/src/mock.rs @@ -135,6 +135,8 @@ pub fn test_ext() -> sp_io::TestExternalities { None, ), ], + regulated_assets: Default::default(), + sbt_assets: Default::default(), } .assimilate_storage(&mut t) .unwrap(); diff --git a/pallets/rewards/src/mock.rs b/pallets/rewards/src/mock.rs index 198362262d..45fab9ebb8 100644 --- a/pallets/rewards/src/mock.rs +++ b/pallets/rewards/src/mock.rs @@ -174,6 +174,8 @@ impl ExtBuilder { None, ), ], + regulated_assets: Default::default(), + sbt_assets: Default::default(), } .assimilate_storage(&mut t) .unwrap(); diff --git a/pallets/trading-pair/src/mock.rs b/pallets/trading-pair/src/mock.rs index dabecfc82c..23c21f2947 100644 --- a/pallets/trading-pair/src/mock.rs +++ b/pallets/trading-pair/src/mock.rs @@ -320,6 +320,8 @@ impl ExtBuilder { assets::GenesisConfig:: { endowed_assets: self.endowed_assets, + regulated_assets: Default::default(), + sbt_assets: Default::default(), } .assimilate_storage(&mut t) .unwrap(); diff --git a/pallets/vested-rewards/src/mock.rs b/pallets/vested-rewards/src/mock.rs index 71a8a6d358..71783516aa 100644 --- a/pallets/vested-rewards/src/mock.rs +++ b/pallets/vested-rewards/src/mock.rs @@ -305,6 +305,8 @@ impl ExtBuilder { assets::GenesisConfig:: { endowed_assets: self.endowed_assets, + regulated_assets: Default::default(), + sbt_assets: Default::default(), } .assimilate_storage(&mut t) .unwrap(); diff --git a/pallets/xor-fee/src/mock.rs b/pallets/xor-fee/src/mock.rs index 9dcba09284..98f40e5010 100644 --- a/pallets/xor-fee/src/mock.rs +++ b/pallets/xor-fee/src/mock.rs @@ -486,6 +486,8 @@ impl ExtBuilder { None, ), ], + regulated_assets: Default::default(), + sbt_assets: Default::default(), } .assimilate_storage(&mut t) .unwrap(); diff --git a/pallets/xst/benchmarking/src/mock.rs b/pallets/xst/benchmarking/src/mock.rs index a0ce186fba..2b2866e925 100644 --- a/pallets/xst/benchmarking/src/mock.rs +++ b/pallets/xst/benchmarking/src/mock.rs @@ -333,6 +333,8 @@ impl ExtBuilder { ) }) .collect(), + regulated_assets: Default::default(), + sbt_assets: Default::default(), } .assimilate_storage(&mut t) .unwrap(); diff --git a/pallets/xst/src/mock.rs b/pallets/xst/src/mock.rs index 735a8f6307..f2a28022b5 100644 --- a/pallets/xst/src/mock.rs +++ b/pallets/xst/src/mock.rs @@ -392,6 +392,8 @@ impl ExtBuilder { ) }) .collect(), + regulated_assets: Default::default(), + sbt_assets: Default::default(), } .assimilate_storage(&mut t) .unwrap(); diff --git a/runtime/Cargo.toml b/runtime/Cargo.toml index 8ea4edb903..1ff4884208 100644 --- a/runtime/Cargo.toml +++ b/runtime/Cargo.toml @@ -312,7 +312,6 @@ wip = [ "beefy-light-client", "beefy-light-client-runtime-api", "evm-fungible-app", - "order-book/wip", "pallet-beefy", "pallet-beefy-mmr", "presto/wip", diff --git a/runtime/src/lib.rs b/runtime/src/lib.rs index 04708cf174..e24a9209d4 100644 --- a/runtime/src/lib.rs +++ b/runtime/src/lib.rs @@ -62,9 +62,9 @@ use bridge_types::types::LeafExtraData; use bridge_types::U256; use common::prelude::constants::{BIG_FEE, MINIMAL_FEE, SMALL_FEE}; use common::prelude::QuoteAmount; -#[cfg(feature = "wip")] // presto -use common::PRUSD; use common::{AssetId32, Description, PredefinedAssetId, DOT, KUSD, XOR, XSTUSD}; +#[cfg(feature = "wip")] // presto +use common::{PRUSD, SBT_PRACS, SBT_PRCRDT, SBT_PRINVST}; use constants::currency::deposit; use constants::time::*; use frame_support::traits::EitherOf; @@ -1557,6 +1557,7 @@ impl qa_tools::Config for Runtime { type DexInfoProvider = dex_manager::Pallet; type SyntheticInfoProvider = XSTPool; type TradingPairSourceManager = trading_pair::Pallet; + type ExtendedAssetsManager = ExtendedAssets; type WeightInfo = qa_tools::weights::SubstrateWeight; type Symbol = ::Symbol; } @@ -2511,6 +2512,9 @@ impl extended_assets::Config for Runtime { #[cfg(feature = "wip")] // presto parameter_types! { pub const PrestoUsdAssetId: AssetId = PRUSD; + pub PrestoKycAssetId: AssetId = SBT_PRACS.into_predefined(); + pub PrestoKycInvestorAssetId: AssetId = SBT_PRINVST.into_predefined(); + pub PrestoKycCreditorAssetId: AssetId = SBT_PRCRDT.into_predefined(); pub PrestoTechAccountId: TechAccountId = { TechAccountId::from_generic_pair( presto::TECH_ACCOUNT_PREFIX.to_vec(), @@ -2530,7 +2534,11 @@ impl presto::Config for Runtime { type RuntimeEvent = RuntimeEvent; type TradingPairSourceManager = trading_pair::Pallet; type OrderBookManager = OrderBook; + type ExtendedAssetsManager = ExtendedAssets; type PrestoUsdAssetId = PrestoUsdAssetId; + type PrestoKycAssetId = PrestoKycAssetId; + type PrestoKycInvestorAssetId = PrestoKycInvestorAssetId; + type PrestoKycCreditorAssetId = PrestoKycCreditorAssetId; type PrestoTechAccount = PrestoTechAccountId; type PrestoBufferTechAccount = PrestoBufferTechAccountId; type RequestId = u64; @@ -2674,7 +2682,7 @@ construct_runtime! { QaTools: qa_tools::{Pallet, Call, Event} = 112, ApolloPlatform: apollo_platform::{Pallet, Call, Storage, Event, ValidateUnsigned} = 114, - ExtendedAssets: extended_assets::{Pallet, Call, Storage, Event} = 115, + ExtendedAssets: extended_assets::{Pallet, Call, Storage, Event, Config} = 115, Soratopia: soratopia::{Pallet, Call, Storage, Event} = 116, }