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