#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

#6 in #interest

MIT-0 license

60KB
1K SLoC

Bank Pallet

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

Overview

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.

Interface

Dispatchable Functions

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

Build

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

Test

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.

Benchmark

Run

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

Dependencies

~13–30MB
~470K SLoC