> For the complete documentation index, see [llms.txt](https://docs.tokensfarm.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.tokensfarm.com/for-developers/integrate-tokensfarm/how-to-integrate-tokensfarmsdk.md).

# How to integrate TokensFarmSDK

* `deposit` - remember deposit and based on that calculate all info for giving rewards
* `reduceStakeOrUnstake` - remember that stake was used to pay something or it was unstaked
* `withdrawRewards` - claim collected rewards for user

```solidity
pragma solidity 0.6.12;

import "ISDK.sol";

contract ExampleContract {
    address public farmAddress;
    
    function setFarmAddress(
        address _farmAddress
    ) 
        external 
        onlyOnwer 
    { 
        require(_farmAddress != address(0x0));
        farmAddress = _farmAddress;
    }
    
    function deposit()
        external 
        onlyOnwer
    {
        // If warmup == 0 => deposit
        ISDK(farmAddress).deposit(msg.sender, amount);
        
        // If warmup != 0 makeDepoistRequest + finaliseDeposit
        ISDK(farmAddress).makeDepositRequest(msg.sender, amount);
        // After warmup has passed
        ISDK(farmAddress).finaliseDeposit(_user, stakeId);
    }
    
    function reduceStakeOrUnstake()
        external
        onlyOwner
    {
        // IF Example Contract is storring stake amount in multiple stakes
        ISDK(farmAddress).noticeReducedStake(
            msg.sender,
            amount,
            stakeID
       );
       
       // IF Example Contract is just adding stake amount to one balance 
        ISDK(farmAddress).noticeReducedStakeWithoutStakeId(
            msg.sender,
            amount,
            stakeID
        );
    }
    
    function withdrawRewards()
        external
        onlyOwner
    {
        ISDK(farmAddress).withdrawRewards(msg.sender);
    }
}
```


---

# 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.tokensfarm.com/for-developers/integrate-tokensfarm/how-to-integrate-tokensfarmsdk.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.
