> For the complete documentation index, see [llms.txt](https://docs.quipuswap.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.quipuswap.com/smart-contracts/farming/qfarm-contract/entrypoints-overview/farming-entrypoints/withdraw.md).

# withdraw

An entrypoint that withdraws (unstakes) tokens. In time of every withdraw it claims user's rewards if timelock is finished (only for farms with timelock) and burns user's rewards if timelock is not finished (only for farms with timelock). In farms without timelock it just claims the rewards. In the case of claiming, rewards are minted to the user and to the referrer (***harvest\_fee***). Also it takes a commission in staked tokens on withdrawal (***withdrawal\_fee***) if timelock is not finished (only for farms with timelock) and takes this commission from the farm's name. At the end it revotes for a baker if the farm supports QuipuSwap V1 TOK/TEZ LP tokens.

### Call parameter

```pascaligo
type withdraw_type      is [@layout:comb] record [
  fid                     : fid_type;
  amt                     : nat;
  receiver                : address;
  rewards_receiver        : address;
]
```

<table><thead><tr><th width="502.3333333333333">Field</th><th>Type</th><th>Description</th></tr></thead><tbody><tr><td>fid</td><td>fid_type (nat)</td><td>Farm's ID</td></tr><tr><td>amt</td><td>nat</td><td>Amount of tokens to withdraw</td></tr><tr><td>receiver</td><td>address</td><td>Receiver of unstaked tokens</td></tr><tr><td>rewards_receiver</td><td>address</td><td>Receiver of earned tokens</td></tr></tbody></table>

### Usage

{% tabs %}
{% tab title="🌮 Taquito" %}

```javascript
const qFarmAddress = "KT1...";
const params = {
    fid: 1,
    amt: 100,
    receiver: "tz1.../KT1...",
    rewards_receiver: "tz1.../KT1...",
};
const qFarm = await tezos.contract.at(qFarmAddress);
const operation = await qFarm.methodsObject.withdraw(params).send();

await operation.confirmation();
```

{% endtab %}
{% endtabs %}

### Errors

* `QSystem/farm-not-set` - farming with `fid` parameter doesn't exist.
* `QFarm/balance-too-low` - user's staked balance too low.


---

# 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.quipuswap.com/smart-contracts/farming/qfarm-contract/entrypoints-overview/farming-entrypoints/withdraw.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.
