Skip to content

Commit

Permalink
chore: apply workspace #1609 to pool-fees dummy
Browse files Browse the repository at this point in the history
  • Loading branch information
wischli committed Nov 24, 2023
1 parent 2f6911e commit f7af9c2
Show file tree
Hide file tree
Showing 5 changed files with 108 additions and 29 deletions.
3 changes: 1 addition & 2 deletions Cargo.lock

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

3 changes: 2 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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 }
Expand Down
49 changes: 25 additions & 24 deletions pallets/pool-fees/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,36 +1,37 @@
[package]
authors = ["Centrifuge <[email protected]>"]
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"]
Expand Down
10 changes: 8 additions & 2 deletions pallets/pool-fees/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@

#![cfg_attr(not(feature = "std"), no_std)]

mod types;

pub use pallet::*;

#[frame_support::pallet]
Expand All @@ -27,7 +29,9 @@ pub mod pallet {
#[pallet::config]
pub trait Config: frame_system::Config {
type RuntimeEvent: From<Event<Self>> + IsType<<Self as frame_system::Config>::RuntimeEvent>;
type WeightInfo: WeightInfo;

// TODO: Enable after creating benchmarks
// type WeightInfo: WeightInfo;
}

#[pallet::storage]
Expand All @@ -44,9 +48,11 @@ pub mod pallet {
#[pallet::call]
impl<T: Config> Pallet<T> {
#[pallet::call_index(0)]
#[pallet::weight(10_000)]
#[pallet::weight(Weight::from_parts(10_000, 0))]
pub fn some_extrinsic(origin: OriginFor<T>) -> DispatchResult {
let who = ensure_signed(origin)?;

Ok(())
}
}
}
72 changes: 72 additions & 0 deletions pallets/pool-fees/src/types.rs
Original file line number Diff line number Diff line change
@@ -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<Rate> {
ShareOfPortfolioValuation(Rate),
// Future options: AmountPerYear, AmountPerMonth, ...
}

#[derive(Debug, Encode, Decode, TypeInfo, MaxEncodedLen)]

enum FeeAmount<Rate> {
/// A fixed fee is deducted automatically every epoch
Fixed { amount: FeeRate<Rate> },

/// A fee can be charged up to a limit, paid every epoch
ChargedUpTo { limit: FeeRate<Rate> },
}

#[derive(Debug, Encode, Decode, TypeInfo, MaxEncodedLen)]

enum FeeEditor<AccountId> {
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<AccountId, Rate> {
/// Account that the fees are sent to
pub destination: AccountId,

/// Account that can update this fee
pub editor: FeeEditor<AccountId>,

/// Amount of fees that can be charged
pub amount: FeeAmount<Rate>,
}

// 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<Hash, LoanId, Meta> {
Loan { id: LoanId, meta: Meta },
IpfsHash(Hash),
Metadata(Meta),
}

type IpfsHash = [u8; 46];

0 comments on commit f7af9c2

Please sign in to comment.