#pallet #fd #interest #amount #account #set #substrate

no-std pallet-bank

FRAME pallet bank for handling financial systems of investment, loans, etc

1 unstable release

0.1.4 Jul 17, 2023
0.1.2 Jul 10, 2023
0.1.1 Jul 6, 2023
0.1.0 Jul 6, 2023

#4 in #interest

MIT-0 license


Bank Pallet

A pallet for handling financial systems of investment, loans, etc.


Anyone can open FD (Fixed Deposit) by reserving some amount of currency with allowed maturity period. The FD principal amount has to be within the range of min_fd_amount & max_fd_amount (set by admin). The FD amount is reserved from the user's free_balance.

During the FD period, the reserved amount cannot be used that's why need to be freed from the free_balance. In order to receive interest, FD can only be closed after the fd_epoch (set by admin) is elapsed, else the reserved amount is returned to the user without any interest as per the premature withdrawal facility and a penalty (0.5-1%) is charged. The penalty_rate is data persistent & set by the root origin.

But, if the FD is closed after individual FD vault's maturity_period (set during opening), then the reserved amount is returned to the user with accrued interest. The interest_rate is stored & set by the root origin.

The accrued interest comes from a treasury 💎 account which is funded by the root origin. And the treasury account is funded via network's inflation or balance slashing of the user in case of malicious activity.

NOTE: The runtime must include the Balances pallet to handle the accounts and balances for your chain. It has been shown as a [dev-dependencies] in the Cargo.toml file.


Dispatchable Functions

  • set_fd_params
  • set_treasury
  • open_fd
  • close_fd
  • lock_for_membership
  • unlock_for_membership


Check if the dependencies are working properly:

$ cargo check -p node-template-runtime

Build the runtime's WASM binary with the following command:

$ cargo build -r


To run all the tests in a pallet:

$ cargo test -p pallet-bank

To run the individual test:

# example
$ cargo test -p pallet-bank --lib -- tests::it_works_for_default_value

Although there is a button shown above to run individual test in VSCode.



Run a relaychain node (w/o debug mode):

$ ./target/release/node-template --dev

In debug mode, run a relaychain node:

$ RUST_LOG=runtime=debug ./target/release/node-template --dev


~459K SLoC