MasterChef V3
Solidity API
MasterChefV3
PoolInfo
UserPositionInfo
poolLength
poolInfo
Info of each MCV3 pool.
userPositionInfos
userPositionInfos[tokenId] => UserPositionInfo
TokenId is unique, and we can query the pid by tokenId.
v3PoolPid
v3PoolPid[token0][token1][fee] => pid
v3PoolAddressPid
v3PoolAddressPid[v3PoolAddress] => pid
CAKE
Address of CAKE contract.
WETH
Address of WETH contract.
receiver
Address of Receiver contract.
nonfungiblePositionManager
LMPoolDeployer
Address of liquidity mining pool deployer contract.
FARM_BOOSTER
Address of farm booster contract.
emergency
Only use for emergency situations.
totalAllocPoint
Total allocation points. Must be the sum of all pools' allocation points.
latestPeriodNumber
latestPeriodStartTime
latestPeriodEndTime
latestPeriodCakePerSecond
operatorAddress
Address of the operator.
PERIOD_DURATION
Default period duration.
MAX_DURATION
MIN_DURATION
PRECISION
BOOST_PRECISION
Basic boost factor, none boosted user's boost factor
MAX_BOOST_PRECISION
Hard limit for maxmium boost factor, it must greater than BOOST_PRECISION
Q128
MAX_U256
cakeAmountBelongToMC
Record the cake amount belong to MasterChefV3.
ZeroAddress
NotOwnerOrOperator
NoBalance
NotPancakeNFT
InvalidNFT
NotOwner
NoLiquidity
InvalidPeriodDuration
NoLMPool
InvalidPid
DuplicatedPool
NotEmpty
WrongReceiver
InconsistentAmount
InsufficientAmount
Init
AddPool
SetPool
Deposit
Withdraw
UpdateLiquidity
NewOperatorAddress
NewLMPoolDeployerAddress
NewReceiver
NewPeriodDuration
Harvest
NewUpkeepPeriod
UpdateUpkeepPeriod
UpdateFarmBoostContract
SetEmergency
onlyOwnerOrOperator
onlyValidPid
onlyReceiver
onlyBoostContract
Throws if caller is not the boost contract.
constructor
Parameters
Name | Type | Description |
---|---|---|
_CAKE | contract IERC20 | The CAKE token contract address. |
_nonfungiblePositionManager | contract INonfungiblePositionManager | the NFT position manager contract address. |
_WETH | address |
getLatestPeriodInfoByPid
Returns the cake per second , period end time.
Parameters
Name | Type | Description |
---|---|---|
_pid | uint256 | The pool pid. |
getLatestPeriodInfo
Returns the cake per second , period end time. This is for liquidity mining pool.
Parameters
Name | Type | Description |
---|---|---|
_v3Pool | address | Address of the V3 pool. |
pendingCake
View function for checking pending CAKE rewards.
The pending cake amount is based on the last state in LMPool. The actual amount will happen whenever liquidity changes or harvest.
Parameters
Name | Type | Description |
---|---|---|
_tokenId | uint256 | Token Id of NFT. |
setEmergency
For emergency use only.
setReceiver
setLMPoolDeployer
add
Add a new pool. Can only be called by the owner. One v3 pool can only create one pool.
Parameters
Name | Type | Description |
---|---|---|
_allocPoint | uint256 | Number of allocation points for the new pool. |
_v3Pool | contract IPancakeV3Pool | Address of the V3 pool. |
_withUpdate | bool | Whether call "massUpdatePools" operation. |
set
Update the given pool's CAKE allocation point. Can only be called by the owner.
Parameters
Name | Type | Description |
---|---|---|
_pid | uint256 | The id of the pool. See |
_allocPoint | uint256 | New number of allocation points for the pool. |
_withUpdate | bool | Whether call "massUpdatePools" operation. |
DepositCache
onERC721Received
Upon receiving a ERC721
harvest
harvest cake from pool.
Parameters
Name | Type | Description |
---|---|---|
_tokenId | uint256 | Token Id of NFT. |
_to | address | Address to. |
harvestOperation
withdraw
Withdraw LP tokens from pool.
Parameters
Name | Type | Description |
---|---|---|
_tokenId | uint256 | Token Id of NFT to deposit. |
_to | address | Address to which NFT token to withdraw. |
updateLiquidity
Update liquidity for the NFT position.
Parameters
Name | Type | Description |
---|---|---|
_tokenId | uint256 | Token Id of NFT to update. |
updateBoostMultiplier
Update farm boost multiplier for the NFT position.
Parameters
Name | Type | Description |
---|---|---|
_tokenId | uint256 | Token Id of NFT to update. |
_newMultiplier | uint256 | New boost multiplier. |
updateLiquidityOperation
increaseLiquidity
Increases the amount of liquidity in a position, with tokens paid by the msg.sender
Parameters
Name | Type | Description |
---|---|---|
params | struct INonfungiblePositionManagerStruct.IncreaseLiquidityParams | tokenId The ID of the token for which liquidity is being increased, amount0Desired The desired amount of token0 to be spent, amount1Desired The desired amount of token1 to be spent, amount0Min The minimum amount of token0 to spend, which serves as a slippage check, amount1Min The minimum amount of token1 to spend, which serves as a slippage check, deadline The time by which the transaction must be included to effect the change |
Return Values
Name | Type | Description |
---|---|---|
liquidity | uint128 | The new liquidity amount as a result of the increase |
amount0 | uint256 | The amount of token0 to acheive resulting liquidity |
amount1 | uint256 | The amount of token1 to acheive resulting liquidity |
pay
Pay.
Parameters
Name | Type | Description |
---|---|---|
_token | address | The token to pay |
_amount | uint256 | The amount to pay |
refund
Refund.
Parameters
Name | Type | Description |
---|---|---|
_token | address | The token to refund |
_amount | uint256 | The amount to refund |
decreaseLiquidity
Decreases the amount of liquidity in a position and accounts it to the position
Parameters
Name | Type | Description |
---|---|---|
params | struct INonfungiblePositionManagerStruct.DecreaseLiquidityParams | tokenId The ID of the token for which liquidity is being decreased, amount The amount by which liquidity will be decreased, amount0Min The minimum amount of token0 that should be accounted for the burned liquidity, amount1Min The minimum amount of token1 that should be accounted for the burned liquidity, deadline The time by which the transaction must be included to effect the change |
Return Values
Name | Type | Description |
---|---|---|
amount0 | uint256 | The amount of token0 accounted to the position's tokens owed |
amount1 | uint256 | The amount of token1 accounted to the position's tokens owed |
collect
Collects up to a maximum amount of fees owed to a specific position to the recipient
Warning!!! Please make sure to use multicall to call unwrapWETH9 or sweepToken when set recipient address(0), or you will lose your funds. amount0Max The maximum amount of token0 to collect, amount1Max The maximum amount of token1 to collect
Parameters
Name | Type | Description |
---|---|---|
params | struct INonfungiblePositionManagerStruct.CollectParams | tokenId The ID of the NFT for which tokens are being collected, recipient The account that should receive the tokens, |
Return Values
Name | Type | Description |
---|---|---|
amount0 | uint256 | The amount of fees collected in token0 |
amount1 | uint256 | The amount of fees collected in token1 |
collectTo
Collect fees and refund.
transferToken
Transfer token from MasterChef V3.
Parameters
Name | Type | Description |
---|---|---|
_token | address | The token to transfer. |
_to | address | The to address. |
unwrapWETH9
Unwraps the contract's WETH9 balance and sends it to recipient as ETH.
The amountMinimum parameter prevents malicious contracts from stealing WETH9 from users.
Parameters
Name | Type | Description |
---|---|---|
amountMinimum | uint256 | The minimum amount of WETH9 to unwrap |
recipient | address | The address receiving ETH |
sweepToken
Transfers the full amount of a token held by this contract to recipient
The amountMinimum parameter prevents malicious contracts from stealing the token from users
Parameters
Name | Type | Description |
---|---|---|
token | address | The contract address of the token which will be transferred to |
amountMinimum | uint256 | The minimum amount of token required for a transfer |
recipient | address | The destination address of the token |
burn
Burns a token ID, which deletes it from the NFT contract. The token must have 0 liquidity and all tokens must be collected first.
Parameters
Name | Type | Description |
---|---|---|
_tokenId | uint256 | The ID of the token that is being burned |
upkeep
Upkeep period.
Parameters
Name | Type | Description |
---|---|---|
_amount | uint256 | The amount of cake injected. |
_duration | uint256 | The period duration. |
_withUpdate | bool | Whether call "massUpdatePools" operation. |
massUpdatePools
Update cake reward for all the liquidity mining pool.
updatePools
Update cake reward for the liquidity mining pool.
Avoid too many pools, and a single transaction cannot be fully executed for all pools.
setOperator
Set operator address.
Callable by owner
Parameters
Name | Type | Description |
---|---|---|
_operatorAddress | address | New operator address. |
setPeriodDuration
Set period duration.
Callable by owner
Parameters
Name | Type | Description |
---|---|---|
_periodDuration | uint256 | New period duration. |
updateFarmBoostContract
Update farm boost contract address.
Parameters
Name | Type | Description |
---|---|---|
_newFarmBoostContract | address | The new farm booster address. |
safeTransferETH
Transfer ETH in a safe way
Parameters
Name | Type | Description |
---|---|---|
to | address | |
value | uint256 |
_safeTransfer
Safe Transfer CAKE.
Parameters
Name | Type | Description |
---|---|---|
_to | address | The CAKE receiver address. |
_amount | uint256 | Transfer CAKE amounts. |
receive
Last updated