Skip to main content

MasterChefV2

The (older) MasterChef contract gives out a constant number of SUSHI tokens per block. It is the only address with minting rights for SUSHI. The idea for this MasterChef V2 (MCV2) contract is therefore to be the owner of a dummy token that is deposited into the MasterChef V1 (MCV1) contract. The allocation point for this pool on MCV1 is the total allocation point for all pools that receive double incentives.

Methods

MASTER_CHEF

function MASTER_CHEF() external view returns (contract IMasterChef)

Address of MCV1 contract.

Returns

NameTypeDescription
_0contract IMasterChefundefined

MASTER_PID

function MASTER_PID() external view returns (uint256)

The index of MCV2 master pool in MCV1.

Returns

NameTypeDescription
_0uint256undefined

SUSHI

function SUSHI() external view returns (contract IERC20)

Address of SUSHI contract.

Returns

NameTypeDescription
_0contract IERC20undefined

add

function add(uint256 allocPoint, contract IERC20 _lpToken, contract IRewarder _rewarder) external nonpayable

Add a new LP to the pool. Can only be called by the owner. DO NOT add the same LP token more than once. Rewards will be messed up if you do.

Parameters

NameTypeDescription
allocPointuint256AP of the new pool.
_lpTokencontract IERC20Address of the LP ERC-20 token.
_rewardercontract IRewarderAddress of the rewarder delegate.

batch

function batch(bytes[] calls, bool revertOnFail) external payable returns (bool[] successes, bytes[] results)

Parameters

NameTypeDescription
callsbytes[]undefined
revertOnFailboolundefined

Returns

NameTypeDescription
successesbool[]undefined
resultsbytes[]undefined

claimOwnership

function claimOwnership() external nonpayable

deposit

function deposit(uint256 pid, uint256 amount, address to) external nonpayable

Deposit LP tokens to MCV2 for SUSHI allocation.

Parameters

NameTypeDescription
piduint256The index of the pool. See poolInfo.
amountuint256LP token amount to deposit.
toaddressThe receiver of amount deposit benefit.

emergencyWithdraw

function emergencyWithdraw(uint256 pid, address to) external nonpayable

Withdraw without caring about rewards. EMERGENCY ONLY.

Parameters

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

harvest

function harvest(uint256 pid, address to) external nonpayable

Harvest proceeds for transaction sender to to.

Parameters

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

harvestFromMasterChef

function harvestFromMasterChef() external nonpayable

Harvests SUSHI from MASTER_CHEF MCV1 and pool MASTER_PID to this MCV2 contract.

init

function init(contract IERC20 dummyToken) external nonpayable

Deposits a dummy token to MASTER_CHEF MCV1. This is required because MCV1 holds the minting rights for SUSHI. Any balance of transaction sender in dummyToken is transferred. The allocation point for the pool on MCV1 is the total allocation point for all pools that receive double incentives.

Parameters

NameTypeDescription
dummyTokencontract IERC20The address of the ERC-20 token to deposit into MCV1.

lpToken

function lpToken(uint256) external view returns (contract IERC20)

Address of the LP token for each MCV2 pool.

Parameters

NameTypeDescription
_0uint256undefined

Returns

NameTypeDescription
_0contract IERC20undefined

massUpdatePools

function massUpdatePools(uint256[] pids) external nonpayable

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.

migrate

function migrate(uint256 _pid) external nonpayable

Migrate LP token to another LP contract through the migrator contract.

Parameters

NameTypeDescription
_piduint256The index of the pool. See poolInfo.

migrator

function migrator() external view returns (contract IMigratorChef)

Returns

NameTypeDescription
_0contract IMigratorChefundefined

owner

function owner() external view returns (address)

Returns

NameTypeDescription
_0addressundefined

pendingOwner

function pendingOwner() external view returns (address)

Returns

NameTypeDescription
_0addressundefined

pendingSushi

function pendingSushi(uint256 _pid, address _user) external view returns (uint256 pending)

View function to see pending SUSHI on frontend.

Parameters

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

Returns

NameTypeDescription
pendinguint256SUSHI reward for a given user.

permitToken

function permitToken(contract IERC20 token, address from, address to, uint256 amount, uint256 deadline, uint8 v, bytes32 r, bytes32 s) external nonpayable

Parameters

NameTypeDescription
tokencontract IERC20undefined
fromaddressundefined
toaddressundefined
amountuint256undefined
deadlineuint256undefined
vuint8undefined
rbytes32undefined
sbytes32undefined

poolInfo

function poolInfo(uint256) external view returns (uint128 accSushiPerShare, uint64 lastRewardBlock, uint64 allocPoint)

Info of each MCV2 pool.

Parameters

NameTypeDescription
_0uint256undefined

Returns

NameTypeDescription
accSushiPerShareuint128undefined
lastRewardBlockuint64undefined
allocPointuint64undefined

poolLength

function poolLength() external view returns (uint256 pools)

Returns the number of MCV2 pools.

Returns

NameTypeDescription
poolsuint256undefined

rewarder

function rewarder(uint256) external view returns (contract IRewarder)

Address of each IRewarder contract in MCV2.

Parameters

NameTypeDescription
_0uint256undefined

Returns

NameTypeDescription
_0contract IRewarderundefined

set

function set(uint256 _pid, uint256 _allocPoint, contract IRewarder _rewarder, bool overwrite) external nonpayable

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

Parameters

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

setMigrator

function setMigrator(contract IMigratorChef _migrator) external nonpayable

Set the migrator contract. Can only be called by the owner.

Parameters

NameTypeDescription
_migratorcontract IMigratorChefThe contract address to set.

sushiPerBlock

function sushiPerBlock() external view returns (uint256 amount)

Calculates and returns the amount of SUSHI per block.

Returns

NameTypeDescription
amountuint256undefined

totalAllocPoint

function totalAllocPoint() external view returns (uint256)

Total allocation points. Must be the sum of all allocation points in all pools.

Returns

NameTypeDescription
_0uint256undefined

transferOwnership

function transferOwnership(address newOwner, bool direct, bool renounce) external nonpayable

Parameters

NameTypeDescription
newOwneraddressundefined
directboolundefined
renounceboolundefined

updatePool

function updatePool(uint256 pid) external nonpayable returns (struct MasterChefV2.PoolInfo pool)

Update reward variables of the given pool.

Parameters

NameTypeDescription
piduint256The index of the pool. See poolInfo.

Returns

NameTypeDescription
poolMasterChefV2.PoolInfoReturns the pool that was updated.

userInfo

function userInfo(uint256, address) external view returns (uint256 amount, int256 rewardDebt)

Info of each user that stakes LP tokens.

Parameters

NameTypeDescription
_0uint256undefined
_1addressundefined

Returns

NameTypeDescription
amountuint256undefined
rewardDebtint256undefined

withdraw

function withdraw(uint256 pid, uint256 amount, address to) external nonpayable

Withdraw LP tokens from MCV2.

Parameters

NameTypeDescription
piduint256The index of the pool. See poolInfo.
amountuint256LP token amount to withdraw.
toaddressReceiver of the LP tokens.

withdrawAndHarvest

function withdrawAndHarvest(uint256 pid, uint256 amount, address to) external nonpayable

Withdraw LP tokens from MCV2 and harvest proceeds for transaction sender to to.

Parameters

NameTypeDescription
piduint256The index of the pool. See poolInfo.
amountuint256LP token amount to withdraw.
toaddressReceiver of the LP tokens and SUSHI rewards.

Events

Deposit

event Deposit(address indexed user, uint256 indexed pid, uint256 amount, address indexed to)

Parameters

NameTypeDescription
user indexedaddressundefined
pid indexeduint256undefined
amountuint256undefined
to indexedaddressundefined

EmergencyWithdraw

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

Parameters

NameTypeDescription
user indexedaddressundefined
pid indexeduint256undefined
amountuint256undefined
to indexedaddressundefined

Harvest

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

Parameters

NameTypeDescription
user indexedaddressundefined
pid indexeduint256undefined
amountuint256undefined

LogInit

event LogInit()

LogPoolAddition

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

Parameters

NameTypeDescription
pid indexeduint256undefined
allocPointuint256undefined
lpToken indexedcontract IERC20undefined
rewarder indexedcontract IRewarderundefined

LogSetPool

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

Parameters

NameTypeDescription
pid indexeduint256undefined
allocPointuint256undefined
rewarder indexedcontract IRewarderundefined
overwriteboolundefined

LogUpdatePool

event LogUpdatePool(uint256 indexed pid, uint64 lastRewardBlock, uint256 lpSupply, uint256 accSushiPerShare)

Parameters

NameTypeDescription
pid indexeduint256undefined
lastRewardBlockuint64undefined
lpSupplyuint256undefined
accSushiPerShareuint256undefined

OwnershipTransferred

event OwnershipTransferred(address indexed previousOwner, address indexed newOwner)

Parameters

NameTypeDescription
previousOwner indexedaddressundefined
newOwner indexedaddressundefined

Withdraw

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

Parameters

NameTypeDescription
user indexedaddressundefined
pid indexeduint256undefined
amountuint256undefined
to indexedaddressundefined