# Unstake

**Overview**

<figure><img src="/files/a6NQhUGpQmVF38yBLzb1" alt=""><figcaption></figcaption></figure>

To unstake user needs to send message with `OP::BURN` to its **Jetton Wallet** and specify amount of bmTON to burn. The TL-B scheme of burn request is following:

```
burn#595f07bc query_id:uint64 jetton_amount:Coins forward_payload:(Maybe ^Cell) = InternalMsgBody;
```

Then message with `OP::BURN_NOTIFICATION` comes from **Jetton Wallet** to **Financial** contract. **Financial** checks that sender is valid and message has enough TON for burn notification and if everything is correct it deploys **Unstake Request** contract with user address (`owner_address`) and `withdraw_ton_amount` (`int withdraw_ton_amount = muldiv(ton_total_supply, withdraw_jetton_amount, jetton_total_supply)`). To retrieve `ton_total_supply` and `jetton_total_supply` (if needed) you have to invoke `get_full_data` method in **Financial** contract:

```
// TL-B:
get_full_data#_ = (
    jetton_total_supply:Coins 
    ton_total_supply:Coins 
    commission_total_supply:Coins
    commission_factor:uint16
    commission_address:MsgAddressInt
    admin_address:MsgAddressInt
    transaction_address:MsgAddressInt
    content:^Cell
    jetton_wallet_code:^Cell
    unstake_request_code:^Cell
    last_lockup_epoch:uint32
    lockup_supply:Coins
    next_lockup_supply:Coins
    later_lockup_supply:Coins
    next_unstake_request_index:uint64
)
```

The TL-B scheme of burn notification is following:

```
burn_notification#7bdd97de query_id:uint64 withdraw_jetton_amount:Coins owner_address:MsgAddressInt receiver_address:MsgAddressInt forward_payload:(Maybe ^Cell) = InternalMsgBody;
```

After **Unstake Request** is deployed, anyone can send message to it. Contract checks that unlock timestamp has passed and if everything is correct it sends message to **Financial** with `OP::UNSTAKE`, ton amount, jetton amount (currently unused) and user address. The TL-B scheme of this message is following:

```
unstake#492ab1b3 index:uint64 owner:MsgAddressInt ton_amount:Coins jetton_amount:Coins forward_payload:(Maybe ^Cell) = InternalMsgBody;
```

Then **Financial** contract checks that its balance is enough (`balance >= withdraw_ton_amount + msg_value`) and if this condition is correct it sends message with `OP::UNSTAKE_NOTIFICATION` and value equal to `unstake_amount - storage_fee` to user. The TL-B scheme of this message is following:

```
unstake_notification#90c80a07 query_id:uint64 forward_payload:(Maybe ^Cell) = InternalMsgBody;
```

Otherwise, it sends message back to **Unstake Request**. The TL-B scheme of this message is following:

```
return_unstake_request#38633538 unlock_timestamp:uint32 = InternalMsgBody;
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.bemo.fi/developers/bemo-v2/unstake.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
