PancakeSwap
Launch App
English
English
  • Welcome to PancakeSwap
    • Product Overview
    • ✨How-to Guides
      • Get Started (BSC)
        • Create a Wallet
        • Get BEP20 Tokens
        • Using PancakeSwap without Centralized Exchanges
        • Connect Your Wallet to PancakeSwap
      • Get Started (Aptos)
        • Create a Wallet
        • Get Aptos Coins
        • CAKE Bridging Guide
        • Connect Your Wallet to PancakeSwap
        • Aptos FAQ
      • V3/V2 Migration
        • How to migrate
        • How v3 APR is calculated
        • FAQ
        • V2 Migration
          • Migrate Your Stakings
          • MasterChef v2
            • List of Farms
          • CAKE Syrup Pool
    • 🗺️Roadmap
    • veCAKE Sunset
      • Staked Cake Redemption
      • 🔷[Archive] veCAKE
        • What is veCAKE?
        • How to get veCAKE?
        • Migrate from CAKE Pool
        • veCAKE Managers
        • Bridge your veCAKE
        • Earn CAKE Weekly
          • FAQ
    • 📈Analytics (Info Page)
    • ✅Audits
    • 🤙Contact Us
      • Social Accounts
      • Telegram & Discord Communities
      • 💼Business Partnerships
        • ⛽veCAKE / Gauges
        • 🧑‍🌾Initial Farm Offerings - IFOs
        • 🥞Syrup Pools and Farms
        • 🖼️NFT Marketplace
        • ❓Commonly Asked Business Partnerships Questions
      • Ambassador Program
        • What can you do as an Ambassador?
        • Benefits of a PancakeSwap Ambassador
        • Want to be an Ambassador?
        • ❓ FAQs Page
      • General FAQ
        • I need help
        • Troubleshooting Errors
        • What is an Approval Transaction?
        • Fixing Stuck Pending Transactions on MetaMask
    • 👨‍👨‍👦About Us
      • Team
        • The Kitchen Team
        • Become a Chef
          • Brand / Graphics Designer
          • Motion / Interaction Designer
          • Social Media & Content Manager
          • Developer Relations Manager
          • Product Designer (UX/I)
          • Business Development Manager
          • Senior Backend Engineer
      • Brand & Logos
  • 👴Archive
    • 📂Legacy Products
      • 🖼️[Archived] NFT Marketplace
      • 🎮[Archived] Gaming Platform
        • 📒Brand Kit
        • 🎓Pancake Mayor
        • 🛡️Pancake Protectors
          • FAQ
      • 🍯[Archived] Pottery
        • How to Play Pottery
        • Pottery FAQ
      • 🧈[Archived] Trading Reward
        • How to Participate
          • Top Traders Campaign
          • CAKE Stakers Campaign
        • FAQ
      • 🤝[Archived] Simple Staking
        • How to start Simple Staking
        • FAQ
        • Terms & Conditions
      • 🎯[Archived] PancakeSwap Quest
        • Getting Started
        • How to Join and Complete a Quest
        • Rewards
      • 💧[Archived] Liquid Staking Integration
        • How To Liquid Stake
        • WBETH
          • WBETH FAQ
        • SnBNB
          • SnBNB FAQ
      • 💸[Archived] Options
        • Options Primer
        • CLAMM Options
        • Options FAQ
      • [Archived] CAKE Syrup Pool
        • How to use the Flexible Staking option
        • How to use the Fixed-Term Staking option
    • Old Tokenomics
      • CAKE Tokenomics v1
      • Controlling CAKE supply v1
    • How to Use Farms with BscScan
    • [Archived] Affiliate Program
      • Dashboard & Link
      • Commission Structure and Payment
      • Program Rules & Guidelines
      • Terms & Conditions
  • Trade
    • 🔄Swap
      • Token Swaps
      • How to Trade
      • Fees and Routes
      • Market Maker Integration
      • Smart Router (V2)
        • How to trade using Smart Router
    • ♾️PancakeSwap Infinity
      • Key Features
      • Hooks
        • Dynamic Fee Hook
      • Pool Types
      • Farms
    • 🎯Limit Orders and Twap
      • How to use Limit Orders
      • How to use TWAP
    • 📈Perpetual Trading
      • What is Perpetual Trading?
      • Perpetual Trading V2
        • How can I use it?
        • Dumb Mode
          • Dumb Mode Guide
        • Degen Mode
          • Degen Mode Dynamic Fee
        • MADBTCUSD
          • MADBTCUSD FAQ
        • Perpetuals V2 Glossary
        • Forex
        • Perpetual Trading FAQ
          • Arbitrum
            • ALP Syrup Pool (Arbitrum)
              • ALP Buying & Selling Fees
        • Trading Rewards Program
          • Arbitrum
        • Supported Chains, Modes & Markets
      • Perpetual Trading V1
        • Perpetuals V1 Glossary
        • How can I use it?
        • V1 Perpetual Trading FAQ
    • 🏦Stableswap
      • How to StableSwap
    • 💳Buy Crypto
    • ❓Trading FAQ
      • Swap FAQ
      • v4 FAQ
      • Limit Orders and TWAP FAQ
  • Trading Tools
    • 🛡️PancakeSwap MEV Guard
    • PancakeSwap Auto Slippage
      • How to Set Slippage on PancakeSwap
    • 🔔Notifications
    • ❓Trading Tools FAQ
      • MEV Guard FAQ
  • Bridge
    • 🌉Bridging
      • Between EVMs
      • Between EVM and Aptos
      • Wormhole Bridge Guide
    • ❓Bridging FAQ
      • Wormhole Bridge FAQ
  • Earn
    • 🌊Liquidity Pools
      • How to Add/Remove Liquidity
      • ⛏️Pancake Picks
      • Zap
        • Zap (V2)
    • 🚜Yield Farming
      • How to Use Farms
        • How to Use Farms (Legacy)
      • APR/ROI/IL Calculator
      • Farming on Aptos
        • FAQ
      • Crosschain Farming
        • FAQ
    • 🥩Cake Staking
      • 🍯Syrup Pools - Stake CAKE
        • Syrup Pools
    • 🛍️IFO (Initial Farm Offering)
      • How to Participate in an IFO
      • How to Participate in CrossChain IFOs
      • FAQ
      • NFT Profile System
        • How to Set Up an NFT Profile
        • Teams
      • Contract Details
    • ❓Earn FAQ
      • Cake Staking FAQ
        • Syrup Pool FAQ & Troubleshooting
  • Play
    • 🔮Prediction
      • How to Use Prediction
      • AI Prediction
      • Prediction FAQ
      • Prediction Troubleshooting
      • Prediction Mini App
    • 🎟️Lottery
      • How to Play Lottery
      • Lottery FAQ
  • ❓Play FAQ
  • Protocol
    • 🍰CAKE Tokenomics
    • 📔Governance
      • How to Vote
        • How to Vote with SafePal Wallet
    • 💻Developers
      • Developer Docs
      • Contributing
        • Codebase Overview
Powered by GitBook
On this page
  • Contract info
  • Resources
  • MasterChef
  • PoolUserInfo
  • UserInfo
  • PoolInfo
  • Entry Functions
  • Deposit
  • Withdraw
  • Emergency Withdraw
  • Mass Update Pools
  • Update Pool
  • Public Function
  • Pending Cake
  • Pool Length
  • Audit

Was this helpful?

  1. To Delete
  2. Smart Contracts (Aptos)

MasterChef

Last updated 2 years ago

Was this helpful?

Contract info

Contract name: pancake::masterchef Contract address:

7968a225eba6c99f5f1070aeec1b405757dee939eabcfda43ba91588bf5fccf3::masterchef

Admin multi sig address: eef8788f3eaa34b936d0bc5897fc40fa3782b1e663bf04edf2cd22fcd18329ff

Resources

MasterChef

Th metadata of the masterchef.

struct MasterChef has key {
    signer_cap: account::SignerCapability,
    admin: address,
    upkeep_admin: address,
    lp_to_pid: TableWithLength<string::String, u64>,
    lps: vector<string::String>,
    pool_info: vector<PoolInfo>,
    total_regular_alloc_point: u64,
    total_special_alloc_point: u64,
    cake_per_second: u64,
    cake_rate_to_regular: u64,
    cake_rate_to_special: u64,
    last_upkeep_timestamp: u64,
    end_timestamp: u64
}
Name

signer_cap

account::SingerCapability

The signer capability of the resource account.

admin

address

The admin address of the module.

upkeep_admin

address

The account that execute upkeep call.

lp_to_pid

table_with_length::TableWithLength

LP token type info and corresponding pool id.

lps

vector

All added LP token type info array.

pool_info

vector

A list of pool _info struct.

total_regular_alloc_point

u64

Sum of all regular farm allocate points.

total_special_alloc_point

u64

Sum of all special farm allocate points.

cake_per_second

u64

Cake reward per second for all farm pools.

cake_rate_to_regular

u64

The percentage of cake rewards that regular farm can earn

cake_rate_to_special

u64

The percentage of cake rewards that special farm can earn.

last_upkeep_timestamp

u64

The timestamp of the last upkeep execution.

end_timestamp

u64

The last time that farms can get cake reward, each upkeep operation will extend this timestamp.

PoolUserInfo

All pool informations.

struct PoolUserInfo has key {
    pid_to_user_info: TableWithLength<u64, UserInfo>,
    pids: vector<u64>,
}
Name
Type
Description

pid_to_user_info

table_with_length::TableWithLength

A table contains userInfo corresponds to the pool id.

pids

vector

A list of pool id.

UserInfo

The user information in each pool.

struct UserInfo has store {
    amount: u128,
    reward_debt: u128
}
Name
Type
Description

amount

u128

The total amount of token staked in the pool.

reward_debt

u128

The total amount of reward distributed to the user.

PoolInfo

The information of each pool

struct PoolInfo has store {
    total_amount: u128,
    acc_cake_per_share: u128,
    last_reward_timestamp: u64,
    alloc_point: u64,
    is_regular: bool
}
Name
Type
Description

total_amount

u128

The total amount of stake token.

acc_cake_per_share

u128

The accumulated cake per share in the pool.

last_reward_timestamp

u64

The latest time when reward is distributed.

alloc_point

u64

The pool allocated point.

is_regular

bool

True means this pool is regular farm, otherwise is special farm.

Entry Functions

Deposit

Deposit the stake token into the pool. It will also transfer reward token to the user if there's any.

public entry fun deposit<CoinType>(
    sender: &signer,
    amount: u64
)
Name
Type
Description

sender

signer

The sender's signer when calling the function.

amount

u64

The amount of token that will be deposited.

Withdraw

Withdraw the stake token from the pool. It will also transfer reward token to the user if there's any.

public entry fun withdraw<CoinType>(
    sender: &signer,
    amount: u64
)
Name
Type
Description

sender

signer

The sender's signer when calling the function.

amount

u64

The amount of token that will be withdrawn.

Emergency Withdraw

Withdraw the stake token from the pool regardless of any rewards.

public entry fun emergency_withdraw<CoinType>(sender: &signer)
Name
Type
Description

sender

signer

The sender's signer when calling the function.

Mass Update Pools

Update all the pool information.

public entry fun mass_update_pools()

Update Pool

Update a specific pool information.

public entry fun update_pool(pid: u64)
Name
Type
Description

pid

u64

The id of the pool.

Public Function

Pending Cake

The pending cake reward of the user.

public fun pending_cake(
    pid: u64,
    user: address
): u64 

Input Values

Name
Type
Description

pid

u64

The id of the pool.

user

address

The address of the depositor.

Return Values

Type
Description

u64

The total amount of cake reward.

Pool Length

The total number of pools.

public fun pool_length():u64

Return Values

Type
Description

u64

The total number of pools.

Audit

OtterSec's PancakeSwap Aptos MasterChef security audit:

Aptos Explorer
112KB
PancakeSwap_aptos_masterchef_audit.pdf
pdf