> For the complete documentation index, see [llms.txt](https://docs.bemo.fi/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.bemo.fi/developers/bemo-v1-deprecated/unstake.md).

# Unstake

#### Overview

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

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

```
burn#595f07bc query_id:uint64 jetton_amount:Coins = 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 = 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#0000000a index:uint64 owner:MsgAddressInt withdraw_ton_amount:Coins withdraw_jetton_amount:Coins = InternalMsgBody;
```

Then **Financial** contract checks that its balance is enough (`balance - MIN_TON_FOR_STORAGE >= withdraw_ton_amount`) and if this condition is correct it empty message with value equal to `unstake_amount` (`withdraw_ton_amount + msg_value - (storage_fee + LOCKUP_GAS_CONSUMPTION + UNSTAKE_GAS_CONSUMPTION`) to user.

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

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


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## 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, and the optional `goal` query parameter:

```
GET https://docs.bemo.fi/developers/bemo-v1-deprecated/unstake.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
