How Mayan Finance Made Serum Accessible To EVM Chains

Mayan Finance
Mayan Finance
Published in
3 min readApr 22, 2022

--

In the DeFi ecosystem when a new chain arrives and gets some traction, DEX protocols face the question of whether to deploy to the new chain and attract users or not.
The reimplementation and redeploying of protocols usually come with two kinds of issues: technical issues and liquidity issues and the latter is usually much more challenging.

In some cases it is not even feasible to implement a protocol on other chains, for example with the magnitude of on-chain transactions and computation required for a CLOB, reimplementing an order book like Serum in Ethereum is not reasonable.

What is the solution?

Interoperability. We believe that communication between chains must be seamless and most of the technical details can be transparent to the user, to this end we built Mayan, Mayan is the gateway for cross-chain DeFi that enables users from other chains to interact with their favorite protocols and therefore redeploying to new chains is no longer necessary for protocols.

The first protocol that we chose to interconnect is Serum, Serum is the main order book on Solana. After their call for building a cross-chain exchange using the liquidity of Serum we thought it was a good opportunity to show the potential of Mayan Finance by making orderbook of Serum available across chains.

So now users can use Serum from Ethereum, Polygon, and BSC and soon it will be available on all the chains supported by Wormhole.

You can try it out here: https://swap.mayan.finance

How did we do it?

Mayan Finance is powered by Wormhole, Many may know Wormhole as a bridge that transfers tokens between chains but the fact is that wormhole at it’s core is a generic message passing protocol and token bridge is just one of many applications of it. We combined the generic message passing of Wormhole with the token bridge and it became so powerful that almost any DeFi action can become cross-chain!

Single Click Cross-chain Swap Powered By Wormhole

Now let’s deep into more technical details: With wormhole generic message passing you can pass arbitrary data between chains but to use the current liquidity of wormhole tokens on serum we have to use the Token Bridge this creates a challenge:

To do a swap and then bridging back the output token we need data about swap details like what markets are involved, slippage, deadline, fees and more, But current structure for token bridge messages only contains data for bridging token and does not allow sending extra data (According to their plans this is going to change in near future)

So to this end we used generic message passing of wormhole to create a second message with our own structure that contains this information plus a reference to the first message so upon delivery of this messages in the Solana that happens by relayers we have all necessary data to do the swap and bridge back the output tokens.

The whole process for a cross-chain swap from BSC takes only around two minutes and at the time of writing this costs less than a dollar! right now the Solana side of process takes consumes most of the time and that is Because of the current limitations of Solana for transaction size we had to break the process into multiple steps and transactions. Hopefully when Quic arrives these limitations will be lifted and the whole process will then can be done much faster.

What is next?

More protocols will be accessible to evm chains by Mayan Finance and our smart router will find the best route to swap across chains.

Join our community at Discord: https://discord.gg/h5HUzkqrXK

--

--