Message: ExecuteMsg::Bond
This message could be used by anyone to provide utokens and start staking.
The parameters that a user can control are the following:
receiver
— This is the address to which ustake tokens are minted to. If this address is not provided, the address of info.sender
is used. info.funds
— The list of tokens sent along with the message.
The message executes the bond
function with the donate
parameter set to false. The function first validates the funds sent to it and then finds the validator with the smallest amount of delegation to delegate tokens to it. Next, it calculates the amount of ustake to be minted using the formula shown below, where utoken_to_bond
is the amount of utokens supplied by the user:
Next, it increases the total supply of the ustake tokens and creates an appropriate message to mint these tokens to the receiver
.
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.