Puzzle Swap mega pools: How it works

Puzzle Network
6 min readMar 16, 2022

--

Mega pools, along with the Puzzle Aggregator, are the key feature of Puzzle Swap. This article explains in detail how the Puzzle mega pools are designed under the hood and how swaps and liquidity provisioning are executed.

The classic AMM model assumes only 2 assets in one pool that are traded between each other. Puzzle Swap uses another AMM model which supports up to 10 assets in one pool because the maximum of 10 payments can be attached to a script invocation on Waves. We call such pools mega pools.

What makes the mega pool special?

  • Users enjoy the convenience of direct exchanges between any pair of pooled tokens.
  • Each trade affects not only the price of the two exchanged tokens, but also prices of other tokens in the pool, which creates constant opportunities for arbitrageurs.
  • Thus, a single trade can cause 3–5 other trades, which increases the trading volume and, consequently, the fees. That’s why investing in mega pools turns out to be more efficient than in traditional pools.
  • Beyond providing the high yield, the mega pool model reduces risks for liquidity providers: they diversify their portfolios and mitigate their volatility at once. The similar instrument in traditional finance is called an index — a security with a value based on all underlying assets.

Variety of mega pools

You can see the list of currently available mega pools on the Invest page. Note the featured pools:

  • Pool Farms 1 and Pool Farms 2 are related to Waves Ducks Metaverse. They contain share tokens of the collective farms, Waves Ducks EGG — the main token on the Metaverse, and the USDN stablecoin. The farms’ tokens are automatically staked, and the staking rewards in EGG give a significant increase in pool yields. Learn more about the collective farms.
  • Waves DeFi Pool contains the most popular and frequently used coins of the Waves ecosystem, so the pool attracts the greatest exchange volume and liquidity.
  • Egg Uneven Pool contains 80% EGG and 20% USDN. This pool is convenient for EGG holders who would like to keep their balance mostly in EGG.

The page also displays tokens included in each pool and their weights. Highlighted tokens are the ones you have in your wallet.

Token weights

Token weights in the pool are set on the pool creation and never change. The token weight is the value of liquidity in that token (in USDN) relative to the total value of the pool liquidity.

For example, in Waves DeFi Pool:

  • WAVES and PUZZLE have a weight of 20% each
  • USDN have a weight of 15%
  • EGG and USDT have a weight of 10% each
  • Other tokens have a weight of 5% each

When a user, for example, exchanges WAVES for EGG (spends WAVES and receives EGG), the amounts of these tokens in the pool change, and the prices also change, so the token weights remain the same.

Swap math

The formula behind mega pools is proposed by Balancer:

Where

  • t ranges over the tokens in the pool;
  • Bt is the balance of the token in the pool;
  • Wt is the normalized weight of the token;
  • V is a constant when swaps occur.

For example, Egg Uneven Pool contains 80% EGG and 20% USDN. When the current balances are as on the picture below, V is calculated as

As Balancer proved in their white paper, when a user spends token i to receive token o, the output amount is calculated as follows:

Where

  • Ao is the amount of output token;
  • Bo is the initial balance of output token in the pool;
  • Wo is the normalized weight of output token;
  • Ai is the amount of input token;
  • Bi is the initial balance of input token;
  • Wi is the normalized weight of input token

Note that the amount the user actually receives is not Ao, but Ao is reduced by the fee.

Swap Fees

For the currently existing mega pools, the swap fee is 2% of the output amount:

  • 1.2% goes to liquidity providers
  • 0.8% goes to PUZZLE stakers.

The fee is rather high, so the liquidity providers and stakers enjoy the high APY. At the same time, Puzzle aggregator fairly finds the most profitable routes of exchange for traders, and it often turns out that the swap on Puzzle is less expensive even with the fee.

In the future, users will be able to add custom mega pools and set a fee from 0.5% to 3%.

Providing Liquidity

There are two options to add liquidity to a mega pool:

  • Multiple tokens: you should have all the tokens of the pool in your wallet; then you can invest a value in each token proportional to its weight. The service calculates the right amounts of tokens, you just need to move the slider to set a percentage of the maximum you can invest.
    For example, if you have 1 EGG with the current value of $250 and only 50 USDN. You can add a maximum of 0.8 EGG (or $200, which is 80% of you deposit’s value) and 50 USDN (20% of value). If you choose to invest 50% of the maximum, you will add 0.4 EGG and 25 USDN.
  • One token set by the service: for example, USDN for Waves DeFi Pool or EGG for Egg Uneven Pool. This option is just for your convenience, so you don’t have to hold all the tokens in your wallet before providing liquidity. However, note that the token you deposit is converted (with a fee) to other tokens of the pool, so your investment may be subject to price fluctuations.

When withdrawing liquidity, you receive back all the tokens from the pool, no matter what option you used to provide liquidity.

Liquidity provider’s income

Puzzle Swap mega pools generate a sustainable high yield based on high trading volumes and fees. We don’t mint any token for distribution to investors, which would lead to dependence of income on that token price.

Each time a swap occurs, the mega pool distributes the fee (1.2% by default) among the liquidity providers. For your convenience, most of the fee is converted to USDN; the rest stays in the token in which it is charged. So, you may get income in all tokens of the pool. We are working on converting 100% of the fees into USDN.

For Pool Farms 1 and Pool Farms 2, liquidity provider’s income also includes the rewards in EGG produced by collective farms of Waves Ducks.

You can claim your earnings whenever you want.

--

--

Puzzle Network

DEX 2.0 built on Waves to support mega pools and bring a new light to DeFi experience 🧩🏆