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

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);
    }
}

Last updated