Skip to main content

TribalChief

The idea for this TribalChief contract is to be the owner of tribe token that is deposited into this contract. This contract was forked from sushiswap and has been modified to distribute staking rewards in tribe. All legacy code that relied on MasterChef V1 has been removed so that this contract will pay out staking rewards in tribe. The assumption this code makes is that this MasterChief contract will be funded before going live and offering staking rewards. This contract will not have the ability to mint tribe.

Functions

constructor

function constructor(
address coreAddress
) public

The way this function is constructed, you will not be able to call initialize after this function is constructed, effectively only allowing TribalChief to be used through delegate calls.

Parameters

NameTypeDescription
coreAddressaddressThe Core contract address.

initialize

function initialize(
address _core,
contract IERC20 _tribe
) external

Parameters

NameTypeDescription
_coreaddressThe Core contract address.
_tribecontract IERC20The TRIBE token contract address.

updateBlockReward

function updateBlockReward(
uint256 newBlockReward
) external

Allows governor to change the amount of tribe per block make sure to call the update pool function before hitting this function this will ensure that all of the rewards a user earned previously get paid out

Parameters

NameTypeDescription
newBlockRewarduint256The new amount of tribe per block to distribute

lockPool

function lockPool(
uint256 _pid
) external

Allows governor to lock the pool so the users cannot withdraw until their lockup period is over

Parameters

NameTypeDescription
_piduint256pool ID

unlockPool

function unlockPool(
uint256 _pid
) external

Allows governor to unlock the pool so that users can withdraw before their tokens have been locked for the entire lockup period

Parameters

NameTypeDescription
_piduint256pool ID

governorAddPoolMultiplier

function governorAddPoolMultiplier(
uint256 _pid,
uint64 lockLength,
uint64 newRewardsMultiplier
) external

Allows governor to change the pool multiplier Unlocks the pool if the new multiplier is greater than the old one

Parameters

NameTypeDescription
_piduint256pool ID
lockLengthuint64lock length to change
newRewardsMultiplieruint64updated rewards multiplier

governorWithdrawTribe

function governorWithdrawTribe(
uint256 amount
) external

sends tokens back to governance treasury. Only callable by governance

Parameters

NameTypeDescription
amountuint256the amount of tokens to send back to treasury

numPools

function numPools() public returns (uint256)

Returns the number of pools.

openUserDeposits

function openUserDeposits(
uint256 pid,
address user
) public returns (uint256)

Returns the number of user deposits in a single pool.

Parameters

NameTypeDescription
piduint256
useraddress

getTotalStakedInPool

function getTotalStakedInPool(
uint256 pid,
address user
) public returns (uint256)

Returns the amount a user deposited in a single pool.

Parameters

NameTypeDescription
piduint256
useraddress

add

function add(
uint120 allocPoint,
contract IERC20 _stakedToken,
contract IRewarder _rewarder,
struct TribalChief.RewardData[] rewardData
) external

Add a new pool. Can only be called by the governor.

Parameters

NameTypeDescription
allocPointuint120AP of the new pool.
_stakedTokencontract IERC20Address of the ERC-20 token to stake.
_rewardercontract IRewarderAddress of the rewarder delegate.
rewardDatastruct TribalChief.RewardData[]Reward Multiplier data

set

function set(
uint256 _pid,
uint120 _allocPoint,
contract IRewarder _rewarder,
bool overwrite
) public

Update the given pool's TRIBE allocation point and IRewarder contract. Can only be called by the governor.

Parameters

NameTypeDescription
_piduint256The index of the pool. See poolInfo.
_allocPointuint120New AP of the pool.
_rewardercontract IRewarderAddress of the rewarder delegate.
overwriteboolTrue if _rewarder should be set. Otherwise _rewarder is ignored.

resetRewards

function resetRewards(
uint256 _pid
) public

Reset the given pool's TRIBE allocation to 0 and unlock the pool. Can only be called by the governor or guardian.

Parameters

NameTypeDescription
_piduint256The index of the pool. See poolInfo.

pendingRewards

function pendingRewards(
uint256 _pid,
address _user
) external returns (uint256)

View function to see all pending TRIBE on frontend.

Parameters

NameTypeDescription
_piduint256The index of the pool. See poolInfo.
_useraddressAddress of user.

Return Values

NameTypeDescription
[0]uint256pending TRIBE reward for a given user.

massUpdatePools

function massUpdatePools(
uint256[] pids
) external

Update reward variables for all pools. Be careful of gas spending!

Parameters

NameTypeDescription
pidsuint256[]Pool IDs of all to be updated. Make sure to update all active pools.

tribePerBlock

function tribePerBlock() public returns (uint256)

Calculates and returns the amount of TRIBE per block.

updatePool

function updatePool(
uint256 pid
) public

Update reward variables of the given pool.

Parameters

NameTypeDescription
piduint256The index of the pool. See poolInfo.

deposit

function deposit(
uint256 pid,
uint256 amount,
uint64 lockLength
) public

Deposit tokens to earn TRIBE allocation.

Parameters

NameTypeDescription
piduint256The index of the pool. See poolInfo.
amountuint256The token amount to deposit.
lockLengthuint64The length of time you would like to lock tokens

withdrawAllAndHarvest

function withdrawAllAndHarvest(
uint256 pid,
address to
) external

Withdraw staked tokens from pool.

Parameters

NameTypeDescription
piduint256The index of the pool. See poolInfo.
toaddressReceiver of the tokens.

withdrawFromDeposit

function withdrawFromDeposit(
uint256 pid,
uint256 amount,
address to,
uint256 index
) public

Withdraw tokens from pool.

Parameters

NameTypeDescription
piduint256The index of the pool. See poolInfo.
amountuint256Token amount to withdraw.
toaddressReceiver of the tokens.
indexuint256

_harvest

function _harvest(
uint256 pid,
address to
) private

Helper function to harvest users tribe rewards

Parameters

NameTypeDescription
piduint256The index of the pool. See poolInfo.
toaddressReceiver of TRIBE rewards.

harvest

function harvest(
uint256 pid,
address to
) public

Harvest proceeds for transaction sender to to.

Parameters

NameTypeDescription
piduint256The index of the pool. See poolInfo.
toaddressReceiver of TRIBE rewards.

emergencyWithdraw

function emergencyWithdraw(
uint256 pid,
address to
) public

Withdraw without caring about rewards. EMERGENCY ONLY.

Parameters

NameTypeDescription
piduint256The index of the pool. See poolInfo.
toaddressReceiver of the deposited tokens.

Events

Deposit

event Deposit(
address user,
uint256 pid,
uint256 amount,
uint256 depositID
)

Parameters

NameTypeDescription
useraddress
piduint256
amountuint256
depositIDuint256

Withdraw

event Withdraw(
address user,
uint256 pid,
uint256 amount,
address to
)

Parameters

NameTypeDescription
useraddress
piduint256
amountuint256
toaddress

EmergencyWithdraw

event EmergencyWithdraw(
address user,
uint256 pid,
uint256 amount,
address to
)

Parameters

NameTypeDescription
useraddress
piduint256
amountuint256
toaddress

Harvest

event Harvest(
address user,
uint256 pid,
uint256 amount
)

Parameters

NameTypeDescription
useraddress
piduint256
amountuint256

LogPoolAddition

event LogPoolAddition(
uint256 pid,
uint256 allocPoint,
contract IERC20 stakedToken,
contract IRewarder rewarder
)

Parameters

NameTypeDescription
piduint256
allocPointuint256
stakedTokencontract IERC20
rewardercontract IRewarder

LogSetPool

event LogSetPool(
uint256 pid,
uint256 allocPoint,
contract IRewarder rewarder,
bool overwrite
)

Parameters

NameTypeDescription
piduint256
allocPointuint256
rewardercontract IRewarder
overwritebool

LogPoolMultiplier

event LogPoolMultiplier(
uint256 pid,
uint128 lockLength,
uint256 multiplier
)

Parameters

NameTypeDescription
piduint256
lockLengthuint128
multiplieruint256

LogUpdatePool

event LogUpdatePool(
uint256 pid,
uint128 lastRewardBlock,
uint256 lpSupply,
uint256 accTribePerShare
)

Parameters

NameTypeDescription
piduint256
lastRewardBlockuint128
lpSupplyuint256
accTribePerShareuint256

TribeWithdraw

event TribeWithdraw(
uint256 amount
)

tribe withdraw event

Parameters

NameTypeDescription
amountuint256

NewTribePerBlock

event NewTribePerBlock(
uint256 amount
)

Parameters

NameTypeDescription
amountuint256

PoolLocked

event PoolLocked(
bool locked,
uint256 pid
)

Parameters

NameTypeDescription
lockedbool
piduint256