Message: ExecuteMsg::WithdrawUnbonded
This message can only be invoked by users with unclaimed unbond requests.
The parameter that a user can control is receiver
— this is the address to which the underlying tokens are transferred. If this address is not provided, the address of info.sender
is used.
The function first fetches all unclaimed unbond requests belonging to the user's address. It then loads the previous batches for each request ID. If the batch has been reconciled and the current block time has exceeded the unbond end time, then the refund amount is computed as follows:
$utoken\_to\_refund = \frac{(batch\_utoken\_unclaimed) * (request\_shares)}{batch\_total\_shares}$
```
This amount is added to the total refund amount. Next, the requested shares are subtracted from the total shares and the utoken to refund are subtracted from the utoken unclaimed. The batch is removed if no remaining shares are left. The unbonding request is removed.
The total refund amount for the underlying token is transferred back to the receiver.