PancakeSwap
Launch App
中文
中文
  • PancakeSwap 介绍
    • 入门指南 (BSC)
      • 创建钱包
      • 获取 BEP-20 代币
      • 在没有中心化交易所账户的情况下使用PancakeSwap
      • 连接钱包
    • 入门指南 (Aptos)
      • 创建钱包
      • 获取 Aptos 代币
      • Cake 跨链指南
      • 在 PancakeSwap 连接钱包
      • Aptos 常见问题解答
    • V3/V2 迁移
      • 如何进行迁移?
      • v3 的 APR 是怎么计算的?
      • 常见问题解答
      • V2 迁移
        • 迁移到 MasterChef v2
        • MasterChef v2
          • 农场列表
        • CAKE 糖浆池
    • 审计报告
    • veCAKE 退场计划
      • 质押 CAKE 赎回
    • 路线图
    • 需要帮助?点我
      • 故障排除指南
      • 常见问题解答
      • 什么是授权操作?
      • 如何修复 MetaMask 上卡住的交易
      • 来自币安学院的指南
  • 产品
    • 🔄交易
      • 代币兑换
      • 如何进行交易
      • 交易手续费和路由设置
      • 流动性资金池
      • 添加/移除流动性
      • 交易 FAQ
      • 做市商整合
      • 智能路由 (V2)
        • 如何通过智能路由进行交易?
      • Zap
        • Zap- 一键添加流动性 (V2)
      • 稳定币兑换
        • 如何使用稳定币兑换
      • 限价單交易 & 时间加权平均价格 (TWAP)
        • 如何使用限价单?
        • 如何使用时间加权平均价格(TWAP)?
        • 限价单 FAQ(旧)
    • 🚜农场
      • 如何使用农场
        • 如何使用农场 (旧版农场页面)
      • APR/ROI/IL 计算器
      • 农场 FAQ
      • 在 Aptos 链上参与农场
        • Aptos链 农场 FAQ
      • 跨链农场
        • 跨链农场 FAQ
      • bCAKE
        • 如何使用新的 bCAKE ?
        • 迁移指南
        • bCAKE FAQ
        • V2 (已弃用)
          • 如何使用 bCAKE?
    • 🔷veCAKE
      • 什么是 veCAKE?
      • 如何获得 veCAKE?
      • 从 CAKE 糖浆池迁移
      • 每周赚取 CAKE
        • 每周赚取 CAKE FAQ
      • Gauges Voting
        • Gauge Voting FAQ
      • 贿选 (投票激励)
      • veCAKE 管理协议
      • 为项目激励流动性
      • 将你的 veCAKE 跨链
      • veCAKE FAQ
    • 🍯糖浆池-质押 CAKE
      • 其他糖浆池
        • 糖浆池 FAQ 与排错指南
      • CAKE 糖浆池
        • 如何使用灵活质押糖浆池
        • 如何使用锁仓质押糖浆池
        • CAKE 糖浆池 FAQ
    • 🧑‍⚖️农场竞拍
    • 💹收入分成
      • 如何参与?
      • 收入分成 FAQ
    • 🛍️IFO (初次农场发行)
      • 如何参加 IFO
      • 如何参与跨链 IFO?
      • FAQ
      • iCAKE
      • 合约详情
    • 🌉跨链
      • EVM 链之间跨链
      • EVM 链与 Aptos 之间跨链
      • 跨链 FAQ
      • Wormhole Bridge Guide
      • 虫洞跨链桥 FAQ
    • 🤝简单赚币
      • 如何使用简单赚币
      • 简单赚币 FAQ
      • 条款和条件
    • 💧流动权益质押整合
      • 如何进行流动权益质押?
      • WBETH
        • WBETH FAQ
      • SnBNB
        • SnBNB FAQ
    • 🟪永续合约交易
      • 什么是永续合约交易
      • 永续合约交易 V2
        • 我应该如何使用它?
        • Dumb 模式
          • Dumb 模式指南
        • Degen Mode
          • Degen 模式动态费用
        • MADBTCUSD
          • MADBTCUSD FAQ
        • 永续合约 V2 术语表
        • 外汇交易
        • 永续合约交易 FAQ
          • Arbitrum
            • ALP 糖浆池 (Arbitrum)
              • ALP 购买&出售手续费
        • 交易奖励计划
          • Arbitrum
        • 支持的区块链、模式和交易对
      • 永续合约交易 V1
        • 永续合约 V1 术语表
        • 我应该如何使用它?
        • 永续合约 V1 FAQ
    • 🎮游戏平台
      • 📒品牌工具套件
      • 🎓Pancake Mayer
      • 🛡️Pancake Protectors 游戏
        • FAQ
    • 🎯PancakeSwap 任务平台
      • 准备工作
      • 如何参与并完成一个任务
      • 奖励
    • 🧈交易返利
      • 如何参与
        • 顶级交易者交易返利活动
        • CAKE 锁仓用户交易返利活动
      • 交易返利 FAQ
    • 🔮预测
      • 如何使用预测功能
      • AI 预测
      • 预测功能 FAQ
      • 预测功能故障排除
      • 预测 Telegram 小程序
    • 🎟️彩票 v2
      • 如何玩转彩票v2
      • 彩票 FAQ
    • 🍯糖浆彩票
      • 如何玩转糖浆彩票
      • 糖浆彩票抽奖延迟说明
      • 糖浆彩票 FAQ
    • 🖼️NFT市场
      • 🖼️NFT 个人资料系统
        • 如何设置 NFT 个人资料?
        • 战队
    • 💳购买加密货币
    • 🌐PancakeSwap 迷你小程序
      • 如何使用 PancakeSwap 迷你小程序
      • 迷你小程序常见问题解答
      • ⛓️PancakeSwap CEDEFI 整合
    • 📈信息站
    • 🖥️PancakeSwap 私人 RPC
    • 🔔通知服务
    • PancakeSwap v4
      • v4 FAQ
    • 💸期权
      • 期权入门
      • CLAMM 期权
      • 期权 FAQ
  • 治理&代币经济
    • CAKE 代币经济模型
      • CAKE 的总量上限
    • 🗳️投票(旧)
    • 治理(新)
      • 如何投票
        • 如何使用SafePal钱包进行投票
      • vCAKE
  • 生态系统&合作伙伴关系
    • 联盟计划
      • 联盟仪表板&返佣链接
      • 佣金结构及支付详情
      • 联盟计划规则和指南
      • 条款及细则
    • 大使计划
      • 👥社区管理
      • 🌎社区翻译者
      • ❓大使计划 FAQs
    • 品牌和标志
    • 联系我们
      • 客户服务
      • 社交媒体与社区
    • 💼商务合作
      • ⛽Vecake-Gauges
      • 🧑‍🌾初次农场发行- IFO
      • 🥞糖浆池和农场
      • 🖼️NFT 交易市场
      • ❓商务合作常见 FAQ
  • 给开发者们
    • 为项目做出贡献
      • 代码库概览
    • Bug 赏金
    • 智能合约 (EVM)
      • veCAKE & Gauge Voting
      • PancakeSwap 交易相关
        • v3 相关合约
          • PancakeV3Factory
          • 智能路由 V3
            • V3 兑换路由
            • V2 兑换路由
            • StableSwap 路由
          • 非同质化仓位
          • Pancake V3 池子
        • v2 相关合约
          • Factory v2
          • 路由 V2
        • Stable Swap
          • Stableswap 路由
          • StableSwap 池子
      • 主厨合约
        • 主厨合约 V3
      • 糖浆池
        • 可初始化的 SmartChef
        • 池子部署器
      • CAKE 糖浆池
      • IFO
      • 预测
      • 彩票
        • 彩票合约
      • 糖浆彩票
      • 农场助推器 (bCAKE)
      • IFO 投入上限(iCAKE)
      • 跨链农场
      • CAKE 跨链
      • Market Maker Pool
    • 智能合约 (Aptos)
      • PancakeSwap 交易相关
        • V2
          • 兑换核心 V2
          • V2 路由
      • 主厨合约
      • 糖浆池
      • IFO
      • Utils
    • API
      • Subgraph
    • 私人 RPC 节点
  • 团队
    • 厨房团队
    • 成为一名大厨
      • Solidity Engineer (Contract)
      • Frontend Engineer (Contract)
      • 产品设计师(UX/I)
      • 商务开发经理
      • 前端工程师
      • Solidity 工程师
      • 开发运维工程师
  • 联系我们
    • 客户服务
    • 社交媒体与社区
  • 代币分发 (🚧)
  • 参考资料
    • Old Tokenomics
      • CAKE Tokenomics v1
      • Controlling CAKE supply v1
    • 如何通过BscScan使用农场
Powered by GitBook
On this page
  • Solidity API
  • MasterChefV3

Was this helpful?

  1. 给开发者们
  2. 智能合约 (EVM)
  3. 主厨合约

主厨合约 V3

MasterChef V3

Solidity API

MasterChefV3

PoolInfo

struct PoolInfo {
  uint256 allocPoint;
  contract IPancakeV3Pool v3Pool;
  address token0;
  address token1;
  uint24 fee;
  uint256 totalLiquidity;
  uint256 totalBoostLiquidity;
}

UserPositionInfo

struct UserPositionInfo {
  uint128 liquidity;
  uint128 boostLiquidity;
  int24 tickLower;
  int24 tickUpper;
  uint256 rewardGrowthInside;
  uint256 reward;
  address user;
  uint256 pid;
  uint256 boostMultiplier;
}

poolLength

uint256 poolLength

poolInfo

mapping(uint256 => struct MasterChefV3.PoolInfo) poolInfo

Info of each MCV3 pool.

userPositionInfos

mapping(uint256 => struct MasterChefV3.UserPositionInfo) userPositionInfos

userPositionInfos[tokenId] => UserPositionInfo

TokenId is unique, and we can query the pid by tokenId.

v3PoolPid

mapping(address => mapping(address => mapping(uint24 => uint256))) v3PoolPid

v3PoolPid[token0][token1][fee] => pid

v3PoolAddressPid

mapping(address => uint256) v3PoolAddressPid

v3PoolAddressPid[v3PoolAddress] => pid

CAKE

contract IERC20 CAKE

Address of CAKE contract.

WETH

address WETH

Address of WETH contract.

receiver

address receiver

Address of Receiver contract.

nonfungiblePositionManager

contract INonfungiblePositionManager nonfungiblePositionManager

LMPoolDeployer

contract ILMPoolDeployer LMPoolDeployer

Address of liquidity mining pool deployer contract.

FARM_BOOSTER

contract IFarmBooster FARM_BOOSTER

Address of farm booster contract.

emergency

bool emergency

Only use for emergency situations.

totalAllocPoint

uint256 totalAllocPoint

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

latestPeriodNumber

uint256 latestPeriodNumber

latestPeriodStartTime

uint256 latestPeriodStartTime

latestPeriodEndTime

uint256 latestPeriodEndTime

latestPeriodCakePerSecond

uint256 latestPeriodCakePerSecond

operatorAddress

address operatorAddress

Address of the operator.

PERIOD_DURATION

uint256 PERIOD_DURATION

Default period duration.

MAX_DURATION

uint256 MAX_DURATION

MIN_DURATION

uint256 MIN_DURATION

PRECISION

uint256 PRECISION

BOOST_PRECISION

uint256 BOOST_PRECISION

Basic boost factor, none boosted user's boost factor

MAX_BOOST_PRECISION

uint256 MAX_BOOST_PRECISION

Hard limit for maxmium boost factor, it must greater than BOOST_PRECISION

Q128

uint256 Q128

MAX_U256

uint256 MAX_U256

cakeAmountBelongToMC

uint256 cakeAmountBelongToMC

Record the cake amount belong to MasterChefV3.

ZeroAddress

error ZeroAddress()

NotOwnerOrOperator

error NotOwnerOrOperator()

NoBalance

error NoBalance()

NotPancakeNFT

error NotPancakeNFT()

InvalidNFT

error InvalidNFT()

NotOwner

error NotOwner()

NoLiquidity

error NoLiquidity()

InvalidPeriodDuration

error InvalidPeriodDuration()

NoLMPool

error NoLMPool()

InvalidPid

error InvalidPid()

DuplicatedPool

error DuplicatedPool(uint256 pid)

NotEmpty

error NotEmpty()

WrongReceiver

error WrongReceiver()

InconsistentAmount

error InconsistentAmount()

InsufficientAmount

error InsufficientAmount()

Init

event Init()

AddPool

event AddPool(uint256 pid, uint256 allocPoint, contract IPancakeV3Pool v3Pool, contract ILMPool lmPool)

SetPool

event SetPool(uint256 pid, uint256 allocPoint)

Deposit

event Deposit(address from, uint256 pid, uint256 tokenId, uint256 liquidity, int24 tickLower, int24 tickUpper)

Withdraw

event Withdraw(address from, address to, uint256 pid, uint256 tokenId)

UpdateLiquidity

event UpdateLiquidity(address from, uint256 pid, uint256 tokenId, int128 liquidity, int24 tickLower, int24 tickUpper)

NewOperatorAddress

event NewOperatorAddress(address operator)

NewLMPoolDeployerAddress

event NewLMPoolDeployerAddress(address deployer)

NewReceiver

event NewReceiver(address receiver)

NewPeriodDuration

event NewPeriodDuration(uint256 periodDuration)

Harvest

event Harvest(address sender, address to, uint256 pid, uint256 tokenId, uint256 reward)

NewUpkeepPeriod

event NewUpkeepPeriod(uint256 periodNumber, uint256 startTime, uint256 endTime, uint256 cakePerSecond, uint256 cakeAmount)

UpdateUpkeepPeriod

event UpdateUpkeepPeriod(uint256 periodNumber, uint256 oldEndTime, uint256 newEndTime, uint256 remainingCake)

UpdateFarmBoostContract

event UpdateFarmBoostContract(address farmBoostContract)

SetEmergency

event SetEmergency(bool emergency)

onlyOwnerOrOperator

modifier onlyOwnerOrOperator()

onlyValidPid

modifier onlyValidPid(uint256 _pid)

onlyReceiver

modifier onlyReceiver()

onlyBoostContract

modifier onlyBoostContract()

Throws if caller is not the boost contract.

constructor

constructor(contract IERC20 _CAKE, contract INonfungiblePositionManager _nonfungiblePositionManager, address _WETH) public

Parameters

Name
Type
Description

_CAKE

contract IERC20

The CAKE token contract address.

_nonfungiblePositionManager

contract INonfungiblePositionManager

the NFT position manager contract address.

_WETH

address

getLatestPeriodInfoByPid

function getLatestPeriodInfoByPid(uint256 _pid) public view returns (uint256 cakePerSecond, uint256 endTime)

Returns the cake per second , period end time.

Parameters

Name
Type
Description

_pid

uint256

The pool pid.

getLatestPeriodInfo

function getLatestPeriodInfo(address _v3Pool) public view returns (uint256 cakePerSecond, uint256 endTime)

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

function pendingCake(uint256 _tokenId) external view returns (uint256 reward)

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

function setEmergency(bool _emergency) external

For emergency use only.

setReceiver

function setReceiver(address _receiver) external

setLMPoolDeployer

function setLMPoolDeployer(contract ILMPoolDeployer _LMPoolDeployer) external

add

function add(uint256 _allocPoint, contract IPancakeV3Pool _v3Pool, bool _withUpdate) external

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

function set(uint256 _pid, uint256 _allocPoint, bool _withUpdate) external

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 poolInfo.

_allocPoint

uint256

New number of allocation points for the pool.

_withUpdate

bool

Whether call "massUpdatePools" operation.

DepositCache

struct DepositCache {
  address token0;
  address token1;
  uint24 fee;
  int24 tickLower;
  int24 tickUpper;
  uint128 liquidity;
}

onERC721Received

function onERC721Received(address, address _from, uint256 _tokenId, bytes) external returns (bytes4)

Upon receiving a ERC721

harvest

function harvest(uint256 _tokenId, address _to) external returns (uint256 reward)

harvest cake from pool.

Parameters

Name
Type
Description

_tokenId

uint256

Token Id of NFT.

_to

address

Address to.

harvestOperation

function harvestOperation(struct MasterChefV3.UserPositionInfo positionInfo, uint256 _tokenId, address _to) internal returns (uint256 reward)

withdraw

function withdraw(uint256 _tokenId, address _to) external returns (uint256 reward)

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

function updateLiquidity(uint256 _tokenId) external

Update liquidity for the NFT position.

Parameters

Name
Type
Description

_tokenId

uint256

Token Id of NFT to update.

updateBoostMultiplier

function updateBoostMultiplier(uint256 _tokenId, uint256 _newMultiplier) external

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

function updateLiquidityOperation(struct MasterChefV3.UserPositionInfo positionInfo, uint256 _tokenId, uint256 _newMultiplier) internal

increaseLiquidity

function increaseLiquidity(struct INonfungiblePositionManagerStruct.IncreaseLiquidityParams params) external payable returns (uint128 liquidity, uint256 amount0, uint256 amount1)

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

function pay(address _token, uint256 _amount) internal

Pay.

Parameters

Name
Type
Description

_token

address

The token to pay

_amount

uint256

The amount to pay

refund

function refund(address _token, uint256 _amount) internal

Refund.

Parameters

Name
Type
Description

_token

address

The token to refund

_amount

uint256

The amount to refund

decreaseLiquidity

function decreaseLiquidity(struct INonfungiblePositionManagerStruct.DecreaseLiquidityParams params) external returns (uint256 amount0, uint256 amount1)

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

function collect(struct INonfungiblePositionManagerStruct.CollectParams params) external returns (uint256 amount0, uint256 amount1)

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

function collectTo(struct INonfungiblePositionManagerStruct.CollectParams params, address to) external returns (uint256 amount0, uint256 amount1)

Collect fees and refund.

transferToken

function transferToken(address _token, address _to) internal

Transfer token from MasterChef V3.

Parameters

Name
Type
Description

_token

address

The token to transfer.

_to

address

The to address.

unwrapWETH9

function unwrapWETH9(uint256 amountMinimum, address recipient) external

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

function sweepToken(address token, uint256 amountMinimum, address recipient) external

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 recipient

amountMinimum

uint256

The minimum amount of token required for a transfer

recipient

address

The destination address of the token

burn

function burn(uint256 _tokenId) external

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

function upkeep(uint256 _amount, uint256 _duration, bool _withUpdate) external

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

function massUpdatePools() internal

Update cake reward for all the liquidity mining pool.

updatePools

function updatePools(uint256[] pids) external

Update cake reward for the liquidity mining pool.

Avoid too many pools, and a single transaction cannot be fully executed for all pools.

setOperator

function setOperator(address _operatorAddress) external

Set operator address.

Callable by owner

Parameters

Name
Type
Description

_operatorAddress

address

New operator address.

setPeriodDuration

function setPeriodDuration(uint256 _periodDuration) external

Set period duration.

Callable by owner

Parameters

Name
Type
Description

_periodDuration

uint256

New period duration.

updateFarmBoostContract

function updateFarmBoostContract(address _newFarmBoostContract) external

Update farm boost contract address.

Parameters

Name
Type
Description

_newFarmBoostContract

address

The new farm booster address.

safeTransferETH

function safeTransferETH(address to, uint256 value) internal

Transfer ETH in a safe way

Parameters

Name
Type
Description

to

address

value

uint256

_safeTransfer

function _safeTransfer(address _to, uint256 _amount) internal

Safe Transfer CAKE.

Parameters

Name
Type
Description

_to

address

The CAKE receiver address.

_amount

uint256

Transfer CAKE amounts.

receive

receive() external payable
Previous主厨合约Next糖浆池

Last updated 1 year ago

Was this helpful?