Stake-client

Overview

The Stake-client is a part of the staking module, use the multi-signature account to transfer DOT or KSM from para chain to relay chain by XCM protocol and bond the currency on relay chain, or vice versa.
​

Stake process

    1.
    The user clicks the stake button of the para chain client, then the asset will stake into the pool of para chain.
    2.
    Stake-client listens to the balance of the pool, if it needs to withdraw then the stake client of the para chain will create a multi-sig transaction to call 'withdraw' method to transfer assets to the relay chain.
    3.
    State-client listen to the balance of multi-sig address on relay chain, if need to bond, the stake-client will create a multi-sig transaction to call 'bond' or 'bondExtra' method of relay chain.
    4.
    Stake-client listen to the reward event of the relay chain, if received then create a multi-sig transaction to call 'recordRewords' or 'recordSlash' of the para chain.
​

Unstake process

    1.
    The user clicks the unstake button of the para chain client.
    2.
    Stake-client listens to the 'unstaked' event of the para chain, and if received will create a multi-sig transaction to call 'unbond' of the relay chain.
    3.
    Stake-client listens to the 'unbonded' event of the relay chain, and if received will create a multi-sig transaction to call 'process_pending_unstake' of the para chain.
    4.
    Stake-client listens to the current era index of the relay chain, and if locked enough era then creates a multi-sig transaction to call 'withdarw_unbonded' of the relay chain.
    5.
    Stake-client listens to 'withdrawn' event of the relay chain, and if received will create a multi-sig transaction to call 'finish_processed_unstake' of the para chain.

Listener

listen to pool balances

1
fn listen_pool_balance(
2
system_rpc_tx: mpsc::Sender<(TasksType, oneshot::Sender<u64>)>,
3
para_subxt_client: &Client<HeikoRuntime>,
4
pool_account_id: AccountId,
5
currency_id: CurrencyId,
6
)
Copied!
listen to the balance of pool address, if need to withdraw then raise a 'ParaStake' task to the task channel.

listen to balance of relay chain agent

1
fn listen_agent_balance(
2
subxt_relay_client: Client<KusamaRuntime>,
3
system_rpc_tx: TracingUnboundedSender<TasksType>,
4
pool_addr: String,
5
)
Copied!
listen to the balance of the relay chain agent, if need to bond then raises a 'RelayBond' or 'RelayBondExtra' to the task channel.

listen to relay chain reward event

1
fn listen_reward(
2
subxt_relay_client: Client<KusamaRuntime>,
3
mut system_rpc_tx: TracingUnboundedSender<TasksType>,
4
)
Copied!
listen to the reward event of the relay chain, if received then raises a 'ParaRecordRewards' task to the task channel.

listen to relay chain slash event

1
fn listen_slash(
2
subxt_relay_client: Client<KusamaRuntime>,
3
mut system_rpc_tx: TracingUnboundedSender<TasksType>,
4
)
Copied!
listen to the slash event of the relay chain, if received then raises a 'ParaRecordSlash' task to the task channel.

listen to unstaked event

1
fn listen_unstaked_event(
2
mut system_rpc_tx: mpsc::Sender<(TasksType, oneshot::Sender<u64>)>,
3
para_subxt_client: &Client<HeikoRuntime>,
4
)
Copied!
listen to unstaked event of the para chain, if received then raises a 'ParaUnstak' task to the task channel.

listen to unbonded event

1
fn listen_unbonded_event(
2
mut system_rpc_tx: mpsc::Sender<(TasksType, oneshot::Sender<u64>)>,
3
relay_subxt_client: &Client<RelayRuntime>,
4
)
Copied!
listen to unbonded event of the relay chain, if received then raises a 'RelayUnbonded' task to the task channel.

listen to relay chain era index

1
fn listen_relay_chain_era(
2
mut system_rpc_tx: mpsc::Sender<(TasksType, oneshot::Sender<u64>)>,
3
relay_subxt_client: &Client<RelayRuntime>,
4
)
Copied!
listen to the era index of the relay chain, if the current era index changed then raise a 'RelayEraIndexChanged' task to the task channel.

listen to withdraw-unbonded event

1
fn listen_withdraw_unbonded_event(
2
mut system_rpc_tx: mpsc::Sender<(TasksType, oneshot::Sender<u64>)>,
3
relay_subxt_client: &Client<RelayRuntime>,
4
)
Copied!
listen to 'withdrawn' event of the relay chain, if received then raise a 'RelayWithdrawUnbonded' task to the task channel.
​

Task channel

TaskType PraraStake

1
fn start_withdraw_task_para(
2
para_subxt_client: &Client<HeikoRuntime>,
3
relay_subxt_client: &Client<RelayRuntime>,
4
para_signer: &(dyn Signer<HeikoRuntime> + Send + Sync),
5
multi_account_id: AccountId,
6
threshold: u16,
7
others: Vec<AccountId>,
8
amount: Amount,
9
first: bool,
10
)
Copied!
start a task to create a multi-sig transaction to call withdraw of the para chain to transfer asset from para chain to relay chain by XCM.

TaskType RelayBond

1
fn relay_bond(
2
subxt_relay_client: &Client<KusamaRuntime>,
3
relay_signer: &(dyn Signer<KusamaRuntime> + Send + Sync),
4
others: Vec<AccountId>,
5
pool_addr: String,
6
first: bool,
7
)
Copied!
start a task to create a multi-sig transaction to call 'bond' of the relay chain.

TaskType RelayBondExtra

1
fn relay_bond_extra(
2
subxt_relay_client: &Client<KusamaRuntime>,
3
relay_signer: &(dyn Signer<KusamaRuntime> + Send + Sync),
4
others: Vec<AccountId>,
5
pool_addr: String,
6
first: bool,
7
)
Copied!
start a task to create a multi-sig transaction to call 'bondExtra' of the relay chain.

TaskType ParaRecordRewards

1
fn para_record_rewards(
2
subxt_para_client: &Client<HeikoRuntime>,
3
para_signer: &(dyn Signer<HeikoRuntime> + Send + Sync),
4
others: Vec<AccountId>,
5
pool_addr: String,
6
amount: Amount,
7
first: bool,
8
)
Copied!
start a task to create a multi-sig transaction to call 'RecordRewards' of the para chain.

TaskType ParaRecordSlash

1
fn para_record_slash(
2
subxt_para_client: &Client<HeikoRuntime>,
3
para_signer: &(dyn Signer<HeikoRuntime> + Send + Sync),
4
others: Vec<AccountId>,
5
pool_addr: String,
6
amount: Amount,
7
first: bool,
8
)
Copied!
start a task to create a multi-sig transaction to call 'RecordSlash' of the para chain.

TaskType ParaUnstake

1
fn start_unstake_task(
2
relay_subxt_client: &Client<RelayRuntime>,
3
amount: Amount,
4
first: bool,
5
)
Copied!
start a task to create a multi-sig transaction to call 'unbond' of the relay chain.

TaskType RelayUnbonded

1
fn start_process_pending_unstake_task_para(
2
para_subxt_client: &Client<HeikoRuntime>,
3
para_signer: &(dyn Signer<HeikoRuntime> + Send + Sync),
4
multi_account_id: AccountId,
5
threshold: u16,
6
others: Vec<AccountId>,
7
agent: AccountId,
8
owner: AccountId,
9
amount: Amount,
10
first: bool,
11
)
Copied!
start a task to create a multi-sig transaction to call 'processPendingUnstake' of the para chain.

TaskType RelayWithdrawUnbonded

1
fn start_finish_processed_unstake_task_para(
2
para_subxt_client: &Client<HeikoRuntime>,
3
para_signer: &(dyn Signer<HeikoRuntime> + Send + Sync),
4
multi_account_id: AccountId,
5
pool_account_id: AccountId,
6
threshold: u16,
7
others: Vec<AccountId>,
8
agent: AccountId,
9
owner: AccountId,
10
amount: Amount,
11
first: bool,
12
)
Copied!
start a task to create a multi-sig transaction to call 'finishProcessedUnstake' of the para chain.

TaskType RelayEraIndexChanged

1
fn do_relay_withdraw_unbonded(subxt_client: &Client<RelayRuntime>) -> Result<(), Error>
Copied!
start a task to create a transaction to call 'withdrawUnbonded' of the relay chain.
​
Last modified 3mo ago