Message: ExecuteMsg::SubmitBatch
The message could be used by anyone and is used to submit a batch for unbonding.
This message does not expect any user parameters.
The message executes the submit_batch
function, which first verifies that the current time is greater than the unbond start time. Then, it calculates the utoken to unbond based on the total supply of ustake, the amount of ustake to burn during unbonding and the current delegations. The formula used to calculate the utoken to unbond is shown below:
Next, it calls the compute_undelegations
function, which, given the current delegations made to validators and a specific amount of utoken to unstake, computes the undelegations to make such that the delegated amount to each validator is as even as possible.
Then, the function stores the pending_batch
as the previous_batches
, initiates a new pending_batch
, and burns the ustake amount of the batch. The function also stores the current snapshot of the balance, which is passed to the CallbackMsg::CheckReceivedCoin
message, and the newly received coins are added to the unlocked_coins
during the callback.