Matching Pool
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.
One period is usually equal to 1 era(6 hours on Kusama and 1 day on Polkadot). since relaychain will update all users' ledgers every era.

Process

The matching process looks like this.

Details

During each era, all users' stake amount will be accumulated into `total_stake_amount`, and all users' unstake amount will be accumulated into `total_unstake_amount`.
Consider current unlocking amount on relaychain, calculate and decide whether to do unbond/rebond/bond on next era.
Here is the matching logic implemented in our code.
Copy link