Introducing Muffin

Muffin is an AMM protocol that supports concentrated liquidity and multiple fee tiers in one pool. Liquidity providers (LPs) can optimize profits with wider choices fee tiers. Other new features include limit orders, internal account, all built in a single contract.

The protocol’s name comes from the code name “Muffin Pool” (i.e. Multiple Fee Factors Inside a Pool), one of the projects here in Deliswap. We shorten it to “Muffin” and rebrand ourselves from Deliswap to it, because we’re now seeing it as a long-term project worth full recognition as a standalone protocol.

Last year we wrote an initial design of Muffin. Since then, we’ve updated the design a bit with more features. So, let’s have an overview of the core features of Muffin.

1. Concentrated liquidity

Muffin inherits the existing design of concentrated liquidity. Instead of forcing LPs to provide liquidity on the (0, infinity) price range, Muffin allows LPs to concentrate their capital into the price ranges they selected. Using a narrow price range, LPs can amplify their liquidity with the same amount of capital

2. Multiple fee tiers in one pool

The first generation of AMMs arbitrarily set a swap fee for LPs, e.g., Uniswap set a 0.30% fee, PancakeSwap set a 0.25% fee. They were reasonable choices but by no means optimal.

Now AMMs are getting more mature, we start to see a diverging preference for fee tiers. More token pairs have more than one major fee tier in TVL. Liquidity providers are exploring which fee tier generates more fees.

Examples of token pairs with >1 major fee tiers
Examples of token pairs with >1 major fee tiers

Current issues

We want LPs to search for the optimal fee tiers, but existing AMMs effectively give LPs only 1–2 fee tiers to choose from in each token pair. This is not enough.

Sure, we could deploy more pools of new fee tiers, but it fragments liquidity. Each pool has shallower liquidity and thus high slippage. Using a pool router or DEX aggregator can offset this slippage issue but they are gas-intensive to use.

Muffin’s new design

For this, Muffin is designed from scratch to offer “multiple fee tiers per pool”. This is unlike typical AMMs that use one fixed fee tier for one standalone pool. This is a hierarchical change in data structure.

Under the hood, each fee tier in a pool acts like an “inner pool” and has its independent liquidity and price. Liquidity providers have full control on which fee tier and price range they would like to put liquidity on.

Example of liquidity distribution in a pool
Example of liquidity distribution in a pool

More choices of fee tiers

With the change, Muffin can offer LPs more granular choices of fee tiers (up to 6 tiers on Ethereum L1). The choices can also be hand-picked specifically for each pool. For example, ETH-USDC pool with 5/20/40/60 bps fees, stablecoin pools with 0.5/1/3/5 bps fees.

Order optimization

When you swap, you automatically use all tiers’ liquidity at once. Muffin will split your orders into smaller ones and route them to different fee tiers to minimize the aggregate swap fee and price impact.

In existing AMMs, you could spend 400–600k gas to split an order to four fee tiers, but it is unaffordable to small traders. In Muffin, it costs about 3x less gas.

And this is done on-chain. It doesn’t require any off-chain pre-computation on the split path. It means protocols can use directly. Crucial to protocols that need to swap a lot, e.g. liquidity management protocols that frequently rebalance positions.

3. Limit orders

The past concentrated liquidity AMM introduced “range order”, i.e. to deposit a single-sided position to sell tokens along the AMM curve when price moves.

Currently, you could use a narrow range order to imitate limit orders, but range order does not close itself. So, you’ll need yourself or keepers to actively check your position’s status and close it in time to avoid buying back your sold tokens.

Muffin improves on it and introduces “single-tick limit order”, i.e. an 1-tick range order that will settle in the form of one token after it’s entirely filled.


Unlike range order, it does not require you or keepers to monitor when it’s filled and close it manually. The protocol will automatically close it for you. Under the hood, your limit-order position is settled alongside the swap that crosses the tick at which your position becomes entirely converted to a single token currency.


Since the limit order itself is also a liquidity position, you can earn swap fees while it’s being filled.

4. EMA oracle

(Edit 10 Aug: The TWAP oracle functionality is removed from the contracts due to a potential manipulation attack vector. This section is kept here for archival purposes.)

Muffin has embedded 20-min and 40-min EMA price oracles to each pool. You can query token price using only one contract call, without needing to prepay upfront gas to initialize data storage slots like in uniswap v3.

If you’re building a lending protocol for long-tailed assets, you no longer have to worry about how to transit the upfront oracle initialization gas cost to your protocol users. EMA oracles are ready in every pool.

5. Internal accounts

If you’re a frequent trader or active liquidity provider, you can store tokens in your Muffin’s internal account instead of holding them in your own wallets.

You save about 30% gas in every swap and any other action on Muffin, because no tokens are really transferred in and out of the contract.

6. Single-contract design

Unlike typical AMMs that use separate contract addresses per pool, Muffin stores all pools and token reserves in one single contract address.

One notable benefit is that it vastly reduces gas for multi-hop swaps (30–40k gas per hop), because you no longer need to interact with multiple pool contracts and move the intermediate tokens across addresses.

Core objective

The meta objective of Muffin is to make liquidity provision more flexible and configurable, hence unlocking more opportunities to profit in AMM. We do it by offering more input parameters (e.g. fee tiers) and offering more functions that you would expect in traditional order books (e.g. limit orders).

We deliberately make Muffin a neutral platform for LPs, instead of a passive investment vehicle that opinionatedly decides parameters for you. We believe the key to bring efficiency is to empower the smart DeFi players with better tools.

Reach out to us

Muffin is being built by @dken_w and @garyneko. We’re launching very soon. If you’re interested in Muffin, or have questions, reach out to us on Twitter or Discord.

Subscribe to Muffin
Receive the latest updates directly to your inbox.
Mint this entry as an NFT to add it to your collection.
This entry has been permanently stored onchain and signed by its creator.