Mango v4: Feature Preview

Brian Smith
Mango Markets
Published in
4 min readAug 12, 2022

Almost one year ago, Mango v3 introduced the first on-chain perpetual exchange to Solana. The program has successfully executed over $28bn in volume since that launch and remains the leading Solana DEX for spot and perp assets.

Mango’s founding ethos was “long & short everything”. Many upgrades were implemented since v3’s launch but the design could not support Mango’s ultimate goal. The team has been working quietly for many, many months on our next iteration and Mango v4 is finally within reach.

We are now ready to introduce our v4 product and below we highlight some of the expected feature upgrades. Note, it’s still under development and we have not reached the alpha release yet, which means everything said here is tentative and subject to change.

Unlimited Tokens

The most painful limitation in v3 was the restriction to 15 oracle slots, meaning at most 15 tokens (including spot and perps) could be available on Mango. This is solved: v4 supports an arbitrary number of each.

Mango is a cross-margining system, so we cannot make adding tokens fully permissionless for safety reasons. To make adding tokens easier and faster in spite of that, v4 adds a new category of “untrusted” token that can be deposited, borrowed, traded, etc. — but do not count as collateral and are not covered by the insurance fund. With that, the risk of adding tokens is highly reduced.

There will be a streamlined process for adding tokens, markets and perps to v4 and we expect the Mango DAO to regularly list new tokens without much delay in the future.

Margin Trade Everywhere

Mango v4 supports generalized flash loans, which allow margin trades through any external program that offers swap-like functionality — without needing any adaptations to the Mango program code.

For a start, the UI supports Jupiter meaning you can use tokens on Mango to margin trade through Jupiter. For example:

  • Let’s say ETH is at $1500 and SOL is at $40.
  • You have 100 USDC deposited in your Mango account.
  • You use Jupiter through Mango to swap 0.2 ETH for SOL.
  • Afterwards, you have 100 USDC, 7.5 SOL and a 0.2 ETH borrow in your Mango account.

Thus you traded $300 worth of ETH for SOL with only $100 in collateral.

Constraints in Solana mean that not all Jupiter routes can be supported right now, but upcoming Solana features will alleviate that issue.

No More Cache

In the past, users sometimes were not able to trade on Mango when Solana congestion was high. Mango’s cranks couldn’t land the transactions required to update the cache of oracle prices. We completely removed the cache for v4, making Mango more usable in these situations.

Dynamic Interest Rates

With many more tokens being tradable through Mango, updating interest rate curves via DAO proposal would be a bottleneck. Instead, v4 will automatically update interest rates to target an optimal utilization rate.

More Serum Markets

Previously only Serum Markets with USDC quote currency were supported. Now, Serum markets for any registered token pair can be added to Mango. For example, the ETH/SOL market is very liquid and will be available in v4.

Extensibility

Solana improvements (in particular account realloc) allow us to make each user’s Mango account extensible. This has two benefits: the initial SOL cost for creating a small account can be lower and we can expand user accounts when Mango adds new features.

The latter is particularly useful. In the future, Mango might add auctioning mechanisms, term futures, etc. without disturbing existing accounts or functionality.

Schedule

Reminder: Everything here is tentative and based on current plans, estimates and guesses.

We are close to the first alpha release with a limited subset of features: unlimited tokens, dynamic interest rates and flash loans for external swaps. It looks like this could happen in August or September.

The next step is the full release, which primarily adds Serum and perp markets. At this point, we will publish the source code and invite everyone to find bugs. The goal is for it to happen this year.

Once the contracted and open-source audits are done, the DAO will provide an insurance fund.

We will be announcing participation details for alpha testers once the launch date is known. Stay tuned.

— Article written by the Mango dev team —

Additional Resources

--

--