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
  • Contract info
  • Audits
  • Lottery Status states
  • Read/View functions
  • viewCurrentLotteryId
  • viewLottery
  • viewNumbersAndStatusesForTicketIds
  • viewRewardsForTicketId
  • viewUserInfoForLotteryId
  • calculateRewardsForTicketId

Was this helpful?

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

彩票

v2

Previous预测Next彩票合约

Last updated 1 year ago

Was this helpful?

Contract info

Contract name: PancakeSwapLottery Contract address: 0x5aF6D33DE2ccEC94efb1bDF8f92Bd58085432d2c Random number generator address: 0x8c6375Aab6e5B26a30bF241EBBf29AD6e6c503c2 (Random number generator contract must be deployed first)

View .

View the .

Audits

The PancakeSwap Lottery V2 has been audited twice so far. View the results below:

Lottery Status states

The lottery has four Status states, Pending, Open, Close, and Claimable, that determine which actions can and cannot be taken at a given time.

Read/View functions

viewCurrentLotteryId

function viewCurrentLotteryId() external view override returns (uint256);

Returns the Id# of the current Lottery round as an integer. Round Id#s correlate to round number, and are incremental, e.g. the ninth round of Lottery will be 9.

viewLottery

function viewLottery(uint256 _lotteryId) external view returns (Lottery memory);

Returns information on specified Lottery round as tuple (see Lottery structure below).

        uint256 startTime;
        uint256 endTime;
        uint256 priceTicketInCake;
        uint256 discountDivisor;
        uint256[6] rewardsBreakdown; // 0: 1 matching number // 5: 6 matching numbers
        uint256 treasuryFee; // 500: 5% // 200: 2% // 50: 0.5%
        uint256[6] cakePerBracket;
        uint256[6] countWinnersPerBracket;
        uint256 firstTicketId;
        uint256 firstTicketIdNextLottery;
        uint256 amountCollectedInCake;
        uint32 finalNumber;

Name

Type

Description

startTime

uint256

Starting block for Lottery round.

endTime

uint256

Ending block for Lottery round (approximately 12 hours after a round begins).

priceTicketInCake

uint256

The price of a ticket in CAKE (approximately $5 USD).

discountDivisor

uint256

The divisor used to calculate bulk ticket discount.

rewardsBreakdown

uint256[6]

The division of rewards across brackets (total must add up to 10,000).

treasuryFee

uint256

Amount taken from funds raised per round that's moved to treasury address (maximum 3000).

cakePerBracket

uint256[6]

The amount of CAKE to distribute to winners of each bracket.

countWinnersPerBracket

uint256[6]

Moves through brackets, starting from the highest, accounting for winners when value > 0.

firstTicketId

uint256

Id of the first ticket, set with the opening of the Lottery round, that determines the range of eligible tickets for the current round.

firstTicketIdNextLottery

uint256

Id of the first ticket, set at the closing of current round, that determines the range of eligible tickets for the current round.

amountCollectedInCake

uint256

The amount of CAKE collected through ticket sales for the Lottery round.

finalNumber

uint32

viewNumbersAndStatusesForTicketIds

function viewNumbersAndStatusesForTicketIds(uint256[] calldata _ticketIds)
    external
    view
    returns (uint32[] memory, bool[] memory);

Returns the corresponding numbers and the statuses of ticketIds array of tickets defined by their ticketId.

viewRewardsForTicketId

function viewRewardsForTicketId(
    uint256 _lotteryId,
    uint256 _ticketId,
    uint32 _bracket;

Name

Type

Description

lotteryId

uint256

The id of the Lottery.

ticketId

uint256

The id of the ticket.

bracket

uint32

Bracket for the ticketId to verify the claim and calculate rewards.

viewUserInfoForLotteryId

    function viewUserInfoForLottery(
        address _user,
        uint256 _lotteryId,
        uint256 _cursor,
        uint256 _size
    )
        external
        view
        returns (
            uint256[] memory,
            uint32[] memory,
            bool[] memory,
            uint256
        )

Returns user lotteryTicketIds, ticketNumbers, and ticketStatuses of a user for a given Lottery (defined by lotteryID).

Name

Type

Description

user

address

The address of the user.

lotteryId

uint256

The id of the Lottery.

cursor

uint256

Cursor to start where to retrieve the tickets.

size

uint256

The number of tickets to retrieve.

calculateRewardsForTicketId

    function _calculateRewardsForTicketId(
        uint256 _lotteryId,
        uint256 _ticketId,
        uint32 _bracket
    ) internal view returns (uint256);

Calculates rewards for a ticket after draw given the lotteryId, ticketId, and bracket.

Name

Type

Description

lotteryId

uint256

The id of the Lottery.

ticketId

uint256

The id of the ticket.

bracket

uint32

Bracket for the ticketId to verify the claim and calculate rewards.

The final number determined by randomResult obtained from the number generator contract () using Chainlink VRF.

Calculates rewards for a ticket after draw given the lotteryId, ticketId, and bracket. Filling and querying will provide a link to detailed price information on .

PancakeSwapLottery.sol on BscScan
PancakeSwap: Lottery contract on BscScan
Peckshield's Lottery V2 Audit
Slowmist's Lottery V2 Audit
BscScan
RandomNumberGenerator.sol