Introducing PancakeSwap v4: For Developers, Traders & Every User
V4
Product
Preview
Chef’s choice
2024-03-15

PancakeSwap's journey began with a simple AMM model and has evolved into a leading multichain DEX offering a suite of DeFi products. Since the launch of PancakeSwap in 2020, we've achieved remarkable milestones: 711B in total volume, 1.8M active users, 2.24B total value locked, and expansion onto nine chains.

While PancakeSwap v3 brought improvements, such as enhanced capital efficiency for traders and optimized yield generation for liquidity providers (LPs), it lacked composability for leveraging PancakeSwap’s liquidity and user base. Additionally, it didn't offer seamless integration for developers and DeFi protocols to create customized features for liquidity pools or introduce new pricing curves tailored to specific assets or market demands.

Today, we're thrilled to unveil PancakeSwap v4, a groundbreaking iteration designed to address these challenges head-on. Our codebase is open-sourced, inviting developers to explore and contribute. Technical details are available in the whitepaper, with comprehensive documentation to support integration and development efforts.

The DEX is scheduled to launch in the third quarter of this year on Ethereum and BNB Chain, with intentions to expand to additional chains in the future. Developers can begin building and engaging with our platform immediately.

PancakeSwap v4 Vision: Beyond a DEX

Our vision for PancakeSwap v4 extends beyond just a DEX upgrade. We aim to foster the most comprehensive flexibility and functionality within the AMM space, built together by the Kitchen and DeFi developers in the crypto community. Hence, PancakeSwap v4 code will be released under an open-source license.

Addressing the 🧟‍♂️ shortcomings of current AMMs, including inflexibility in pricing models for all assets, lack of CEX-level execution functions, impermanent loss for liquidity providers, and pricey on-chain gas fees for users, is paramount to our mission.

Furthermore, PancakeSwap v4 will enhance the DEX experience and complement with existing and upcoming features, like veCAKE, enabling PancakeSwap to evolve into the highest-functionality DeFi platform.

Key Features of PancakeSwap v4:

Hooks: Tailored Features and Fee Management

Externally deployed contracts, known as hooks, can be integrated to enhance the functionality of swaps and liquidity pools. These contracts, deployed separately from the core AMM logics and pool managers, act as customizable add-ons, enabling developers and protocols to execute predefined logic during key pool and swap actions.

The possibilities are endless with hooks – from dynamic fees, order types, custom oracles, active liquidity management modules, and more. Additionally, fees can be imposed on actions like swapping and liquidity withdrawals, with the flexibility to collect the fees as a hook creator or distribute them to stakeholders.

Custom Pool Types and Donate: Empowering Liquidity Provisioning & Incentivisation

At launch, PancakeSwap v4 supports multiple pool types, including CLAMM and Liquidity Book. The architecture offers flexibility to incorporate any new AMM design to address current AMM models' drawbacks or cater to new types of assets that may be priced better by new curves.

In PancakeSwap v4, we implement the innovative Liquidity Book AMM alongside the widely adopted CLAMM design. While CLAMM follows the X*Y = K formula, the Liquidity Book AMM operates on a constant sum formula: X + Y = K. The liquidity is stacked in price bins rather than following a uniform distribution across a price range, as in the CLAMM design. This allows for liquidity to be deposited in various shapes.

Liquidity Book AMM:

Utilizing a constant sum formula within each bin ensures that traders benefit from 0 price impact trades within a bin, eliminating impermanent loss (IL) for LPs.

The fungibility of liquidity makes position adjustments cost-effective for LPs, supporting single-sided liquidity provisioning and enabling native limit orders akin to an order book model. This is the first Liquidity Book AMM implementation supporting hooks, allowing developers to introduce tailored features and optimizations to these pools.

Donate: The Donate method empowers stakeholders to incentivize in-range LPs, fostering the liquidity ecosystem.

Singleton and Flash Accounting: Gas Optimization Techniques

In contrast to v3, where each pool requires a separate contract, v4 consolidates all pools into a single contract (singleton), reducing the deployment cost by 99%. Gas cost is further reduced for multi-hop swaps as there is no need to transfer tokens between separate contracts.

Flash Accounting optimizes the accounting process by computing net balances for a batch of transactions and settling them collectively, reducing gas consumption compared to previous models. It relies upon a lock mechanism to update internal net balances before executing external transfers, minimizing gas fees for multi-hop transactions. Enabled by EIP-1153, Flash Accounting benefits from "Transient Storage," which stores data temporarily, avoiding serialization costs associated with permanent storage, thus enhancing cost-effectiveness.

Open-Source Licensing

Our v4 mission is crystal clear: to champion open-source principles and uplift the entire DeFi landscape. We're proud to announce that PancakeSwap v4 code will be released under an open-source license, empowering developers to innovate, customize, and collaborate freely. To facilitate the rapid adoption of PancakeSwap v4 across multiple chains, DeFi protocols forking PancakeSwap under the Affiliate initiative will be warmly welcomed and officially recognized by the Kitchen. Join us in building a more inclusive and vibrant DeFi ecosystem for all.

$500,000 Developer Program

With the introduction of PancakeSwap v4, we're committed to providing developers with the resources and support to thrive in the DeFi landscape. Hence, we are launching a $500,000 Developer Program to encourage innovation, creativity, and collaboration within the developer community through Growth Campaigns, Hackathons, a Developer Ambassador Program, and a CAKE Emissions Grants Program.

As part of the CAKE Emission Grants Program: PancakeSwap will allocate CAKE emissions to developers building hooks and other promising solutions on PancakeSwap v4. More details on this initiative will be announced in the coming months.

For more details of the Developer Program, please refer to our official announcement here.

What's Next for v4?

The DEX is scheduled to launch in the third quarter of this year on Ethereum and BNB Chain, with intentions to expand to additional chains in the future. Developers can start building on PancakeSwap immediately by reading the v4 whitepaper and codebase. To get started or learn more about PancakeSwap v4, visit our v4 website.

The Chefs

PancakeSwap v4 Directory

PancakeSwap v4 page

Introducing PancakeSwap v4: For Developers, Traders & Every User

PancakeSwap v4 Whitepaper

PancakeSwap v4 FAQ

Mochi's vision for PancakeSwap v4

Why should Developers build on PancakeSwap v4 and How to build Hooks

Introducing PancakeSwap’s $500K Developer Program and CAKE Emissions Grant Program

What’s in it for Developers, DeFi Protocols, Traders, and Liquidity Providers

PancakeSwap v4 Developer Docs

How does it work?
Learn basics of PancakeSwap
Trade tokens, earn rewards and play to win!