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
  • 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
  • Trading Tools
    • 🛡️PancakeSwap MEV Guard
    • PancakeSwap Auto Slippage
      • How to Set Slippage on PancakeSwap
    • 🔔Notifications
    • ❓Trading Tools FAQ
      • MEV Guard FAQ
  • Protocol
    • 🍰CAKE Tokenomics
    • 📔Governance
      • How to Vote
    • 💻Developers
      • Developer Docs
      • Contributing
        • Codebase Overview
Powered by GitBook
On this page
  • Contract info
  • Types
  • Resources
  • LPToken
  • TokenPairMetadata
  • TokenPairReserve
  • SwapInfo
  • Public Functions
  • Register LP
  • Is Paired Created
  • LP Balance
  • Total LP Supply
  • Token Reserve
  • Token Balance

Was this helpful?

  1. To Delete
  2. Smart Contracts (Aptos)
  3. PancakeSwap Exchange
  4. v2

Swap Core V2

Last updated 2 years ago

Was this helpful?

Contract info

Contract name: pancake::swap Contract address: c7efb4076dbe143cbcd98cfaaa929ecfc8f299203dfff63b95ccb6bfe19850fa::swap

Admin Multi Sig: b11ccaed0056a75472539c2b0d9511c82fc6a36622bec7578216af5fe550dd0d

Types

Name
Type
Description

X

type address

The coin type address of token X in the pair.

Y

type address

The coin type address of token Y in the pair.

Resources

LPToken

The liquidity token corresponds to each pool XY.

struct LPToken<phantom X, phantom Y> has key {}

TokenPairMetadata

The metadata of pool XY.

struct TokenPairMetadata<phantom X, phantom Y> has key {
    creator: address,
    fee_amount: coin::Coin<LPToken<X, Y>>,
    k_last: u128,
    balance_x: coin::Coin<X>,
    balance_y: coin::Coin<Y>,
    mint_cap: coin::MintCapability<LPToken<X, Y>>,
    burn_cap: coin::BurnCapability<LPToken<X, Y>>,
    freeze_cap: coin::FreezeCapability<LPToken<X, Y>>,
}
Name
Type
Description

creator

address

The creator address of pool.

fee_amount

coin::Coin

The total LP token collected from all the swaps in the pool.

k_last

u128

The multiply of reserve_x and reserve_y in the pool from the last swap.

balance_x

coin::Coin

The total amount of token X in the pool.

balance_y

coin::Coin

The total amount of token Y in the pool.

mint_cap

coin::MintCapability

The mint capability created when the LP is created.

burn_cap

coin::BurnCapability

The burn capability created when the LP is created.

freeze_cap

coin::FreezeCapability

The freeze capability created when the LP is created.

TokenPairReserve

The tokens reserves of pool XY.

struct TokenPairReserve<phantom X, phantom Y> has key {
    reserve_x: u64,
    reserve_y: u64,
    block_timestamp_last: u64
}
Name
Type
Description

reserve_x

u64

The total amount of token X in the pool.

reserve_y

u64

The total amount of token Y in the pool.

block_timstamp_last

u64

The timestamp when reserves get updated.

SwapInfo

The metadata of the module

struct SwapInfo has key {
    signer_cap: account::SignerCapability,
    fee_to: address,
    admin: address,
    pair_created: event::EventHandle<PairCreatedEvent>
}
Name
Type
Description

signer_cap

account::SignerCapabilty

The signer capability created when the module is deployed.

fee_to

address

The address that the fee will be sent to.

admin

address

The admin address of the module

pair_created

event::EventHandle

The event emit when the pool is created.

Public Functions

Register LP

Register the LP token to the account.

public fun register_lp<X, Y>(sender: &signer)

Input Values

Name
Type
Description

sender

signer

The sender's signer when calling the function.

Is Paired Created

Check if the pool XY is created or not.

public fun is_pair_created<X, Y>(): bool

Return Values

Type
Description

bool

Whether the pool is created or not.

LP Balance

Check LP balance of user.

public fun lp_balance<X, Y>(addr: address): u64

Input Values

Name
Type
Description

addr

address

The user address.

Return Values

Type
Description

u128

The amount of LP user own.

Total LP Supply

The total amount of LP exist created from pool XY.

public fun total_lp_supply<X, Y>(): u128

Return Values

Type
Description

u128

The total supply of LP tokens.

Token Reserve

The token reserves of the pool XY.

public fun token_reserves<X, Y>(): (u64, u64, u64)

Return Values

Position
Type
Description

0

u64

The total amount of token X in the pool.

1

u64

The total amount of token Y in the pool.

2

u64

The timestamp when reserves get updated.

Token Balance

The token balance of the pool XY.

public fun token_balances<X, Y>(): (u64, u64)

Return Values

Position
Type

0

u64

The total amount of token X in the pool.

1

u64

The total amount of token Y in the pool.

View on Aptos Explorer