As Polkadot uses NPoS (Nominated Proof-of-Stake), DOT holders stake their DOT tokens to nominate validators to earn yields. Stakers may want to expand the utility of their staked DOT.
Parallel finance comes out a solution to unlock the liquidity of staked DOT without compromising the security of the network.
There are 5 layers of architecture: Application Layer is for user side, Access Layer is for API request, On-chain Layer include main logic about relaychain and parachain. Off-chain Layer implements by stake-client, and Security Layer is for private key security.
Function Module Diagram
It indicates mainly storage and method in parachain.
Stake and Unstake process
Parachain will match all users' stake and unstake requests during one period, and then bond or unbond on relaychain. if the first period is unbond and the second period is bond, it may do rebond first.
View Data Storage
The exchange rate converts staking native token to xtoken.
pub type ExchangeRate<T: Config> = StorageValue<_, Rate, ValueQuery>;
The total amount of staked assets in relaychain.
pub type StakingPool<T: Config> = StorageValue<_, BalanceOf<T>, ValueQuery>;
Records reward or slash during each era.
pub type StakingSettlementRecords<T: Config> = StorageDoubleMap<
Put assets under staking, the native assets will be transferred to the account owned by the pallet, the user receives the voucher in return, such vouchers can be further used as collateral for lending.