diff --git a/Cargo.lock b/Cargo.lock index 4c0bccee07..cf49d36c3d 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -8295,9 +8295,8 @@ dependencies = [ [[package]] name = "pallet-pool-fees" -version = "0.1.0" +version = "0.0.1" dependencies = [ - "bitflags 1.3.2", "cfg-primitives", "cfg-traits", "cfg-types", diff --git a/Cargo.toml b/Cargo.toml index ee524ce191..aae4d2d54d 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -86,7 +86,7 @@ smallvec = "1.6.1" serde = { version = "1.0.119", features = ["derive"] } codec = { package = "parity-scale-codec", version = "3.0", default-features = false, features = ["derive"] } scale-info = { version = "2.3.0", default-features = false, features = ["derive"] } -log = "0.4" +log = { version = "0.4", default-features = false } getrandom = { version = "0.2", features = ["js"] } static_assertions = "1.1.0" lazy_static = "1.4.0" @@ -246,6 +246,7 @@ pallet-nft = { path = "pallets/nft", default-features = false } pallet-nft-sales = { path = "pallets/nft-sales", default-features = false } pallet-order-book = { path = "pallets/order-book", default-features = false } pallet-permissions = { path = "pallets/permissions", default-features = false } +pallet-pool-fees = { path = "pallets/pool-fees", default-features = false } pallet-pool-registry = { path = "pallets/pool-registry", default-features = false } pallet-pool-system = { path = "pallets/pool-system", default-features = false } pallet-restricted-tokens = { path = "pallets/restricted-tokens", default-features = false } diff --git a/pallets/pool-fees/Cargo.toml b/pallets/pool-fees/Cargo.toml index e104a60a3c..e2bfbe1142 100644 --- a/pallets/pool-fees/Cargo.toml +++ b/pallets/pool-fees/Cargo.toml @@ -1,36 +1,37 @@ [package] -authors = ["Centrifuge "] -description = "Pool Fees Pallet" -edition = "2021" -license = "LGPL-3.0" +authors.workspace = true +edition.workspace = true +license.workspace = true +repository.workspace = true +homepage.workspace = true +documentation.workspace = true name = "pallet-pool-fees" -repository = "https://github.com/centrifuge/centrifuge-chain" -version = "0.1.0" +description = "Pool Fees Pallet" +version = "0.0.1" [package.metadata.docs.rs] targets = ["x86_64-unknown-linux-gnu"] -[dependencies] -codec = { package = "parity-scale-codec", version = "3.0.0", features = ["derive"], default-features = false } -log = { version = "0.4.0", default-features = false } -scale-info = { version = "2.3.0", default-features = false, features = ["derive"] } +[dev-dependencies] -frame-benchmarking = { git = "https://github.com/paritytech/substrate", default-features = false, optional = true, branch = "polkadot-v0.9.43" } -frame-support = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.43" } -frame-system = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.43" } -pallet-timestamp = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.43" } -sp-arithmetic = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.43" } -sp-core = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.43" } -sp-io = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.43" } -sp-runtime = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.43" } -sp-std = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.43" } +[dependencies] +codec = { package = "parity-scale-codec", workspace = true, features = ["derive"] } +log = { workspace = true } +scale-info = { workspace = true, features = ["derive"] } -cfg-primitives = { path = "../../libs/primitives", default-features = false } -cfg-traits = { path = "../../libs/traits", default-features = false } -cfg-types = { path = "../../libs/types", default-features = false } +frame-benchmarking.workspace = true +frame-support.workspace = true +frame-system.workspace = true +pallet-timestamp.workspace = true +sp-arithmetic.workspace = true +sp-core.workspace = true +sp-io.workspace = true +sp-runtime.workspace = true +sp-std.workspace = true -[dev-dependencies] -bitflags = "1.3" +cfg-primitives.workspace = true +cfg-traits.workspace = true +cfg-types.workspace = true [features] default = ["std"] diff --git a/pallets/pool-fees/src/lib.rs b/pallets/pool-fees/src/lib.rs index 906c53fa0f..e2cc0246cb 100644 --- a/pallets/pool-fees/src/lib.rs +++ b/pallets/pool-fees/src/lib.rs @@ -12,6 +12,8 @@ #![cfg_attr(not(feature = "std"), no_std)] +mod types; + pub use pallet::*; #[frame_support::pallet] @@ -27,7 +29,9 @@ pub mod pallet { #[pallet::config] pub trait Config: frame_system::Config { type RuntimeEvent: From> + IsType<::RuntimeEvent>; - type WeightInfo: WeightInfo; + + // TODO: Enable after creating benchmarks + // type WeightInfo: WeightInfo; } #[pallet::storage] @@ -44,9 +48,11 @@ pub mod pallet { #[pallet::call] impl Pallet { #[pallet::call_index(0)] - #[pallet::weight(10_000)] + #[pallet::weight(Weight::from_parts(10_000, 0))] pub fn some_extrinsic(origin: OriginFor) -> DispatchResult { let who = ensure_signed(origin)?; + + Ok(()) } } } diff --git a/pallets/pool-fees/src/types.rs b/pallets/pool-fees/src/types.rs new file mode 100644 index 0000000000..9f64b32b87 --- /dev/null +++ b/pallets/pool-fees/src/types.rs @@ -0,0 +1,72 @@ +// Copyright 2023 Centrifuge Foundation (centrifuge.io). + +// Centrifuge is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version (see http://www.gnu.org/licenses). + +// Centrifuge is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +use cfg_primitives::{AccountId, LoanId}; +use codec::{Decode, Encode, MaxEncodedLen}; +use frame_support::dispatch::TypeInfo; + +#[derive(Debug, Encode, Decode, TypeInfo, MaxEncodedLen)] +enum FeeRate { + ShareOfPortfolioValuation(Rate), + // Future options: AmountPerYear, AmountPerMonth, ... +} + +#[derive(Debug, Encode, Decode, TypeInfo, MaxEncodedLen)] + +enum FeeAmount { + /// A fixed fee is deducted automatically every epoch + Fixed { amount: FeeRate }, + + /// A fee can be charged up to a limit, paid every epoch + ChargedUpTo { limit: FeeRate }, +} + +#[derive(Debug, Encode, Decode, TypeInfo, MaxEncodedLen)] + +enum FeeEditor { + Root, + Account(AccountId), +} + +#[derive(Debug, Encode, Decode, TypeInfo, MaxEncodedLen)] + +enum FeeBucket { + /// Fees that are charged first, before any redemptions, investments, + /// repayments or originations + Top, + // Future: AfterTranche(TrancheId) +} + +#[derive(Debug, Encode, Decode, TypeInfo, MaxEncodedLen)] + +struct Fee { + /// Account that the fees are sent to + pub destination: AccountId, + + /// Account that can update this fee + pub editor: FeeEditor, + + /// Amount of fees that can be charged + pub amount: FeeAmount, +} + +// NOTE: Remark feature will be a separate feature in the future (post Pool Fees +// MVP). The following enum is necessary to deliver the MVP. +#[derive(Debug, Encode, Decode, TypeInfo, MaxEncodedLen)] + +enum Remark { + Loan { id: LoanId, meta: Meta }, + IpfsHash(Hash), + Metadata(Meta), +} + +type IpfsHash = [u8; 46];