Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs: Update pallet docs #1767

Merged
merged 1 commit into from
Mar 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 36 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,37 +28,63 @@ Centrifuge is the infrastructure that facilitates the decentralized financing of
## Building blocks
On top of the [Substrate FRAME](https://docs.substrate.io/reference/frame-pallets/) framework, Centrifuge Chain is composed of custom pallets which can be found inside the `pallets` folder. The following list gives a brief overview, and links to the corresponding documentation:

- [**pool-system**](https://github.com/centrifuge/centrifuge-chain/tree/main/pallets/pool-system) ([docs](https://reference.centrifuge.io/pallet_pool_system/index.html)): Creating and managing investment pools. It is bundling loans, slicing pools into tranches, and controlling investment epochs.

- [**loans**](https://github.com/centrifuge/centrifuge-chain/tree/main/pallets/loans) ([docs](https://reference.centrifuge.io/pallet_loans/index.html)): Locking a collateral NFT into a pool allowing to borrow from the pool. The loans pallet is also used for bookkeeping loan values and outstanding debt.

- [**anchors**](https://github.com/centrifuge/centrifuge-chain/tree/main/pallets/anchors) ([docs](https://reference.centrifuge.io/pallet_anchors/index.html)): Storing hashes of documents on-chain. The documents are stored in the Private Off-chain Data (POD) node network.

- [**block-rewards**](https://github.com/centrifuge/centrifuge-chain/tree/main/pallets/block-rewards) ([docs](https://reference.centrifuge.io/pallet_block_rewards/index.html)): Provides means of configuring and distributing block rewards to collators as well as the annual treasury inflation.

- [**bridge**](https://github.com/centrifuge/centrifuge-chain/tree/main/pallets/bridge) ([docs](https://reference.centrifuge.io/pallet_bridge/index.html)): Connecting [ChainBridge](https://github.com/centrifuge/chainbridge-substrate) to transfer tokens to and from Ethereum.

- [**collator-allowlist**](https://github.com/centrifuge/centrifuge-chain/tree/main/pallets/collator-allowlist) ([docs](https://reference.centrifuge.io/pallet_collator_allowlist/index.html)): Tracking active collators, and allows the root account to manage this list.

- [**crowdloan-claim**](https://github.com/centrifuge/centrifuge-chain/tree/main/pallets/crowdloan-claim) ([docs](https://reference.centrifuge.io/pallet_crowdloan_claim/index.html)): Claiming user rewards for their crowdloan funding support.

- [**crowdloan-rewards**](https://github.com/centrifuge/centrifuge-chain/tree/main/pallets/crowdloan-reward) ([docs](https://reference.centrifuge.io/pallet_crowdloan_reward/index.html)): Calculating the reward amounts for crowdloan contributors. This is used by the `crowdloan-claim` pallet which handles the actual claims.
- [**ethereum-transaction**](https://github.com/centrifuge/centrifuge-chain/tree/main/pallets/ethereum-transaction) ([docs](https://reference.centrifuge.io/pallet_ethereum_transaction/index.html)): Wrapper around the Ethereum pallet which allows other pallets to execute EVM calls.

- [**fees**](https://github.com/centrifuge/centrifuge-chain/tree/main/pallets/fees) ([docs](https://reference.centrifuge.io/pallet_fees/index.html)): Taking fees from accounts and sending this to the treasury, to the author, or burning them.

- [**foreign-investments**](https://github.com/centrifuge/centrifuge-chain/tree/main/pallets/foreign-investments) ([docs](https://reference.centrifuge.io/pallet_foreign_investments/index.html)): Enables investing, redeeming and collecting in foreign and non-foreign currencies. Can be regarded as an extension of `pallet-investments` which provides the same toolset for pool (non-foreign) currencies.
cdamian marked this conversation as resolved.
Show resolved Hide resolved

- [**interest-accrual**](https://github.com/centrifuge/centrifuge-chain/tree/main/pallets/interest-accrual) ([docs](https://reference.centrifuge.io/pallet_interest_accrual/index.html)): Keeping account of the outstanding debt through interest accrual calculations.

- [**investments**](https://github.com/centrifuge/centrifuge-chain/tree/main/pallets/investments) ([docs](https://reference.centrifuge.io/pallet_investments/index.html)): Provides orders for assets and allows user to collect these orders.

- [**keystore**](https://github.com/centrifuge/centrifuge-chain/tree/main/pallets/keystore) ([docs](https://reference.centrifuge.io/pallet_keystore/index.html)): Linking public keys to accounts. Supporting the operations of the offchain document consensus layer through the Centrifuge POD (Private Offchain Data) Node.

- [**nft**](https://github.com/centrifuge/centrifuge-chain/tree/main/pallets/nft) ([docs](https://reference.centrifuge.io/pallet_nft/index.html)): Validating a mint request that needs to be transferred through the bridge layer to Ethereum.
- [**liquidity-pools**](https://github.com/centrifuge/centrifuge-chain/tree/main/pallets/liquidity-pools) ([docs](https://reference.centrifuge.io/pallet_liquidity_pools/index.html)): Provides the toolset to enable foreign investments on foreign domains.

- [**liquidity-pools-gateway**](https://github.com/centrifuge/centrifuge-chain/tree/main/pallets/liquidity-pools-gateway) ([docs](https://reference.centrifuge.io/pallet_liquidity_pools_gateway/index.html)): The main handler of incoming and outgoing Liquidity Pools messages.

- [**liquidity-pools-gateway-routers**](https://github.com/centrifuge/centrifuge-chain/tree/main/pallets/liquidity-pools-gateway/routers) ([docs](https://reference.centrifuge.io/liquidity_pools_gateway_routers/index.html)): This crate contains the `DomainRouters` used by the Liquidity Pools Gateway pallet.

- [**nft-sales**](https://github.com/centrifuge/centrifuge-chain/tree/main/pallets/nft-sales) ([docs](https://reference.centrifuge.io/pallet_nft_sales/index.html)): Providing a place for digital art creators and owners to offer their NFTs for sale and for potential buyers to browse and buy them.
- [**axelar-gateway-precompile**](https://github.com/centrifuge/centrifuge-chain/tree/main/pallets/liquidity-pools-gateway/axelar-gateway-precompile) ([docs](https://reference.centrifuge.io/axelar_gateway_precompile/index.html)): Pallet that serves as an EVM precompile for incoming Liquidity Pools messages from the Axelar network.

- [**liquidity-rewards**](https://github.com/centrifuge/centrifuge-chain/tree/main/pallets/liquidity-rewards) ([docs](https://reference.centrifuge.io/pallet_liquidity_rewards/index.html)): Epoch based reward system.

- [**loans**](https://github.com/centrifuge/centrifuge-chain/tree/main/pallets/loans) ([docs](https://reference.centrifuge.io/pallet_loans/index.html)): Locking a collateral NFT into a pool allowing to borrow from the pool. The loans pallet is also used for bookkeeping loan values and outstanding debt.

- [**oracle-collection**](https://github.com/centrifuge/centrifuge-chain/tree/main/pallets/oracle-collection) ([docs](https://reference.centrifuge.io/pallet_oracle_collection/index.html)): Pallet used to collect and aggregate oracle values.

- [**oracle-feed**](https://github.com/centrifuge/centrifuge-chain/tree/main/pallets/oracle-feed) ([docs](https://reference.centrifuge.io/pallet_oracle_feed/index.html)): Pallet used to feed oracle values.

- [**order-book**](https://github.com/centrifuge/centrifuge-chain/tree/main/pallets/order-book) ([docs](https://reference.centrifuge.io/pallet_order_book/index.html)): Allows orders for currency swaps to be placed and fulfilled.

- [**permissions**](https://github.com/centrifuge/centrifuge-chain/tree/main/pallets/permissions) ([docs](https://reference.centrifuge.io/pallet_permissions/index.html)): Linking roles to accounts. It is adding and removing relationships between roles and accounts on chain.

- [**pool-fees**](https://github.com/centrifuge/centrifuge-chain/tree/main/pallets/pool-fees) ([docs](https://reference.centrifuge.io/pallet_pool_fees/index.html)): Stores all the fees related to a pool and allows for these fees to be charged.

- [**pool-registry**](https://github.com/centrifuge/centrifuge-chain/tree/main/pallets/pool-registry) ([docs](https://reference.centrifuge.io/pallet_pool_registry/index.html)): Used for creating, updating, and setting the metadata of pools.

- [**pool-system**](https://github.com/centrifuge/centrifuge-chain/tree/main/pallets/pool-system) ([docs](https://reference.centrifuge.io/pallet_pool_system/index.html)): Creating and managing investment pools. It is bundling loans, slicing pools into tranches, and controlling investment epochs.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure about the "it is building loans" part 🤔. It is true that it takes into account the loans portfolio but pallet-pool-system does not know anything about loans.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's not building, it's bundling ^^. This being the case, I think it's correct, given your mention about the loans portfolio?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Makes more sense then 😆


- [**restricted-tokens**](https://github.com/centrifuge/centrifuge-chain/tree/main/pallets/restricted-tokens) ([docs](https://reference.centrifuge.io/pallet_restricted_tokens/index.html)): Transferring tokens and setting balances. It is wrapping `orml-tokens` with the addition of checking for permissions.

- [**restricted-xtokens**](https://github.com/centrifuge/centrifuge-chain/tree/main/pallets/restricted-xtokens) ([docs](https://reference.centrifuge.io/pallet_restricted_xtokens/index.html)): Wrapper pallet over `orml-xtokens` which allows the runtime to create arbitrary filters for transfers of x-chain-transfers.

- [**rewards**](https://github.com/centrifuge/centrifuge-chain/tree/main/pallets/rewards) ([docs](https://reference.centrifuge.io/pallet_rewards/index.html)): Implement a [scalable reward distribution](https://solmaz.io/2019/02/24/scalable-reward-changing/) mechanism that can be used for other pallets to create different rewards systems.

- [**liquidity-rewards**](https://github.com/centrifuge/centrifuge-chain/tree/main/pallets/liquidity-rewards) ([docs](https://reference.centrifuge.io/pallet_liquidity_rewards/index.html)): Epoch based reward system.
- [**swaps**](https://github.com/centrifuge/centrifuge-chain/tree/main/pallets/swaps) ([docs](https://reference.centrifuge.io/pallet_swaps/index.html)): Enables applying swaps independently of previous swaps in the same or opposite directions.

- [**token-mux**](https://github.com/centrifuge/centrifuge-chain/tree/main/pallets/token-mux) ([docs](https://reference.centrifuge.io/pallet_token_mux/index.html)): Enables proxying variants of the same foreign assets to a local asset representation.

- [**transfer-allowlist**](https://github.com/centrifuge/centrifuge-chain/tree/main/pallets/transfer-allowlist) ([docs](https://reference.centrifuge.io/pallet_transfer_allowlist/index.html)): This pallet checks whether an account should be allowed to make a transfer to a receiving location with a specific currency.

## Developing
Instructions for building, testing, and developing Centrifuge Chain can be found in [`docs/DEVELOPING.md`](docs/DEVELOPING.md).
Expand Down
7 changes: 4 additions & 3 deletions pallets/anchors/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,11 @@
// 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.

//! # Anchors pallet for runtime
//
//! # Anchors Pallet
//!
//! This pallet provides functionality of Storing anchors on Chain
//! This pallet provides functionality of Storing anchors on Chain.

#![cfg_attr(not(feature = "std"), no_std)]
// This pallet is getting a big refactor soon, so no sense doing clippy cleanups
#![allow(clippy::all)]
Expand Down
13 changes: 6 additions & 7 deletions pallets/block-rewards/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,12 @@
//
//! # BlockRewards Pallet
//!
//! The BlockRewards pallet provides functionality for distributing rewards to
//! different accounts with different currencies as well as configuring an
//! annual treasury inflation. The distribution happens when a session (a
//! constant time interval) finalizes. Users cannot stake manually as their
//! collator membership is synchronized via a provider.
//! Thus, when new collators join, they will automatically be staked and
//! vice-versa when collators leave, they are unstaked.
//! The BlockRewards pallet provides means of configuring and distributing block
//! rewards to collators as well as the annual treasury inflation. The
//! distribution happens when a session (a constant time interval) finalizes.
//! Users cannot stake manually as their collator membership is synchronized via
//! a provider. Thus, when new collators join, they will automatically be staked
//! and vice-versa when collators leave, they are unstaked.
//!
//! The BlockRewards pallet provides functions for:
//!
Expand Down
4 changes: 2 additions & 2 deletions pallets/bridge/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@
// 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.

//! # Bridge pallet
//
//! # Bridge Pallet
//!
//! This pallet implements a bridge between Chainbridge and Centrifuge Chain.

Expand Down
14 changes: 13 additions & 1 deletion pallets/collator-allowlist/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,16 @@
//! Collator Allowlist Pallet
// Copyright 2024 Centrifuge Foundation (centrifuge.io).
//
// This file is part of the Centrifuge chain project.
// 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.
//
//! # Collator Allowlist Pallet
//!
//! This pallet provides two extrinsics, one that allows sudo to
//! add collator ids to an allowlist, and another one that allows
Expand Down
20 changes: 8 additions & 12 deletions pallets/crowdloan-claim/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,20 +1,16 @@
// Copyright 2021 Parity Technologies (UK) Ltd.
// This file is part of Centrifuge (centrifuge.io) parachain.

// Cumulus is free software: you can redistribute it and/or modify
// Copyright 2024 Centrifuge Foundation (centrifuge.io).
//
// This file is part of the Centrifuge chain project.
// 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.

// Cumulus is distributed in the hope that it will be useful,
// (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.

// You should have received a copy of the GNU General Public License
// along with Cumulus. If not, see <http://www.gnu.org/licenses/>.

//! # Crowdloan claim pallet
//
//! # Crowdloan Claim Pallet
//!
//! A pallet used for claiming reward payouts for crowdloan campaigns. This
//! does not implement the rewarding strategy, that is the role of the
Expand Down
4 changes: 2 additions & 2 deletions pallets/crowdloan-reward/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@
// 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.

//! # Crowdloan reward pallet
//
//! # Crowdloan Reward Pallet
//!
//! This pallet implements a specific rewarding strategy for crowdloan
//! campaign. It worth pointing out that this pallet works hand in hand
Expand Down
18 changes: 11 additions & 7 deletions pallets/ethereum-transaction/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,16 @@
// 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.
//
//! # Ethereum Transaction Pallet
//!
//! The Ethereum Transaction pallet is a wrapper around the Ethereum pallet,
//! and it allows other pallets to execute EVM calls. It keeps track
//! of the nonce used for each call and builds a fake signature for executing
//! the provided call.
//!
//! The execution fees are charged by the Ethereum pallet, the only other extra
//! fee is be the one from the nonce read operation.
#![cfg_attr(not(feature = "std"), no_std)]

use cfg_primitives::TRANSACTION_RECOVERY_ID;
Expand Down Expand Up @@ -91,12 +101,6 @@ pub mod pallet {
OriginFor<T>:
From<pallet_ethereum::Origin> + Into<Result<pallet_ethereum::Origin, OriginFor<T>>>,
{
/// This implementation serves as a wrapper around the Ethereum pallet
/// execute functionality. It keeps track of the nonce used for each
/// call and builds a fake signature for executing the provided call.
///
/// NOTE - The execution fees are charged by the Ethereum pallet,
/// we only have to charge for the nonce read operation.
fn call(
from: H160,
to: H160,
Expand Down Expand Up @@ -158,7 +162,7 @@ pub mod pallet {
// querying the `Pending` storage of the pallet-ethereum.
let pending = pallet_ethereum::Pending::<T>::get();
let (_, _, receipt) = pending.last().ok_or(DispatchError::Other(
"Ethereuem not adding pending storage. Unexpected.",
"Ethereum not adding pending storage. Unexpected.",
))?;

if Pallet::<T>::valid_code(receipt) {
Expand Down
2 changes: 1 addition & 1 deletion pallets/foreign-investments/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
//! # Foreign Investment pallet
//!
//! Enables investing, redeeming and collecting in foreign and non-foreign
//! currencies. Can be regarded as an extension of `pallet-investment` which
//! currencies. Can be regarded as an extension of `pallet-investments` which
//! provides the same toolset for pool (non-foreign) currencies.
//!
//! - [`Pallet`]
Expand Down
2 changes: 1 addition & 1 deletion pallets/investments/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "pallet-investments"
description = "Provides orders for assests and allows user to collect these orders"
description = "Provides orders for assets and allows user to collect these orders."
version = "1.0.0"
authors.workspace = true
edition.workspace = true
Expand Down
5 changes: 4 additions & 1 deletion pallets/investments/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,10 @@
// 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.

//
//! # Investments Pallet
//!
//! Provides orders for assets and allows user to collect these orders.
#![cfg_attr(not(feature = "std"), no_std)]

use cfg_primitives::OrderId;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,11 @@
// 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.
//
//! # Axelar Gateway Precompile
//!
//! Pallet that serves as an EVM precompile for incoming Liquidity Pools
//! messages from the Axelar network.
#![cfg_attr(not(feature = "std"), no_std)]

use cfg_types::domain_address::{Domain, DomainAddress};
Expand Down Expand Up @@ -111,7 +116,7 @@ pub mod pallet {
type RuntimeEvent: From<Event<Self>> + IsType<<Self as frame_system::Config>::RuntimeEvent>;

/// The origin that is allowed to set the gateway address we accept
/// messageas from
/// messages from
type AdminOrigin: EnsureOrigin<<Self as frame_system::Config>::RuntimeOrigin>;

type WeightInfo: WeightInfo;
Expand Down
11 changes: 11 additions & 0 deletions pallets/liquidity-pools-gateway/routers/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,17 @@
// 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.
//
//! # Liquidity Pools Gateway Routers
//!
//! This crate contains the `DomainRouters` used by the Liquidity Pools Gateway
//! pallet.
//!
//! The routers can be used to communicate with:
//!
//! Axelar - via EVM and XCM (through Moonbeam).
//!
//! Moonbeam - via XCM.
#![cfg_attr(not(feature = "std"), no_std)]

// polkadot/blob/19f6665a6162e68cd2651f5fe3615d6676821f90/xcm/src/v3/mod.rs#
Expand Down
15 changes: 15 additions & 0 deletions pallets/liquidity-pools-gateway/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,21 @@
// 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.
//
//! # Liquidity Pools Gateway Pallet.
//!
//! The Liquidity Pools Gateway pallet is the main handler of incoming and
//! outgoing Liquidity Pools messages.
//!
//! For incoming messages it validates the `Domain` and address of the sender,
//! and, upon successful validation, it sends the message to the `InboundQueue`
//! for further processing. The pallet that implements the `InboundQueue` is the
//! Liquidity Pools pallet.
//!
//! For outgoing messages it's using a queue which gets serviced when a block
//! gets finalized. Each message in the `OutboundMessageQueue` has a `Domain`
//! assigned to it, and that `Domain` should have a corresponding `DomainRouter`
//! which should be set prior to sending the message.
#![cfg_attr(not(feature = "std"), no_std)]

use core::fmt::Debug;
Expand Down
Loading
Loading