Saffron Staking V2

Introduction

Contract for rewarding users with SFI for the Saffron liquidity mining program.

Code based off Sushiswap's Masterchef contract with the addition of SFIRewarder.

NOTE: Do not add pools with LP tokens that are deflationary or have reflection.

Contract State Variables

struct UserInfo

Structure of user deposited amounts and their pending reward debt.

struct UserInfo {
        uint256 amount;
        uint256 rewardDebt;
}

struct PoolInfo

Structure holding information about each pool's LP token and allocation information.

struct PoolInfo {
        IERC20 lpToken;
        uint256 allocPoint;
        uint256 lastRewardBlock; 
        uint256 accSFIPerShare; 
}

Miscellaneous State Variables

Constructor

constructor(address _rewarder, uint256 _sfiPerBlock, uint256 _rewardCutoff)

Governance Functions

setRewarder()

Update the SFIRewarder. Only callable by the contract owner.

function setRewarder(address _rewarder) external onlyOwner

Parameters:

setRewardPerBlock()

Update the SFIRewarder. Only callable by the contract owner.

function setRewardPerBlock(uint256 _sfiPerBlock) external onlyOwner

Parameters:

setRewardCutoff()

Update the reward end block. Only callable by the contract owner.

function setRewardCutoff(uint256 _rewardCutoff) external onlyOwner

Parameters:

setRewardPerBlockAndRewardCutoff()

Update the reward end block and sfiPerBlock atomically. Only callable by the contract owner.

function setRewardPerBlockAndRewardCutoff(uint256 _sfiPerBlock, uint256 _rewardCutoff) external onlyOwner

Parameters:

add()

Add a new pool specifying its lp token and allocation points.

function add(uint256 _allocPoint, address _lpToken) public onlyOwner

Parameters:

set()

Set the allocPoint of the specific pool with id _pid.

function set(uint256 _pid, uint256 _allocPoint) public onlyOwner

Parameters:

Public and External Functions

pendingSFI()

Return the pending SFI rewards of a user for a specific pool id.

function set(uint256 _pid, uint256 _allocPoint) public onlyOwner

Parameters:

Return Values:

massUpdatePools()

Update reward variables for all pools. Be careful of gas spending! More than 100 pools is not recommended.

function massUpdatePools() public

updatePool()

Update accumulated SFI shares of the specified pool.

function updatePool(uint256 _pid) public returns (PoolInfo memory)

Parameters:

Return Values:

deposit()

Deposit the user's lp token into the the specified pool.

function deposit(uint256 _pid, uint256 _amount) public

Parameters:

withdraw()

Withdraw the user's lp token from the specified pool.

function withdraw(uint256 _pid, uint256 _amount) public

Parameters:

emergencyWithdraw()

Emergency function to withdraw a user's asset in a specified pool.

function emergencyWithdraw(uint256 _pid) public

Parameters:

Internal Functions

safeSFITransfer()

Transfer SFI from the SFIRewarder contract to the user's account.

function safeSFITransfer(address to, uint256 amount) internal

Parameters:

View Functions

poolLength()

Return the number of pools in the poolInfo list

function poolLength() external view returns (uint256)

Return Values:

pendingSFI()

Return the pending SFI rewards of a user for a specific pool id.

function pendingSFI(uint256 _pid, address _user) external view returns (uint256)

Parameters:

Return Values:

Logs

TokensDeposited()

Emitted when amount tokens are deposited by user into pool id pid.

event TokensDeposited(address indexed user, uint256 indexed pid, uint256 amount);

TokensWithdrawn()

Emitted when amount tokens are withdrawn by user from pool id pid.

event TokensWithdrawn(address indexed user, uint256 indexed pid, uint256 amount);

TokensEmergencyWithdrawn()

Emitted when amount tokens are emergency withdrawn by user from pool id pid.

event TokensEmergencyWithdrawn(address indexed user, uint256 indexed pid, uint256 amount);

Last updated