Decentralised cross chain exchange that combines the best of Uniswap like AMMs and Coincidence of Wants dexes like CoWSwap
Prize Pool
IntegrumSwap is a decentralised cross chain exchange that inherits the best of two worlds: AMMs like Uniswap & Coincidence of Wants DEXes like CoWSwap.
In order to understand IntegrumSwap, let's have look at both advantages & disadvantages across Uniswap and CoWSwap.
Uniswap runs on-chain and thus is decentralised, however it is subject to MEV and front-running issues that have become an increasing concern. One of the main causes for this is the fact that AMMs do not work with fixed pricing of swaps and therefore someone can change the price of a token just before the order gets executed. IntegrumSwap is not impacted by these type of issues though, because like CoW Swap, it uses coincidence of wants to fulfill trade orders.
CoW Swap uses off-chain order matching, but that means it's not decentralised and is therefore vulnerable. ItegrumSwap runs the order matching engine on-chain using Arbitrum WASM VM. This is an order of magnitude that is faster than EVM and with significantly lower gas fees. That's due to the superior efficiency of WASM programs. As an added benefit to this, the memory resources can be 100-500 times cheaper.
Now if we look at both Uniswap & CoW Swap we can see that neither of them are cross chain. This reflects into liquidity fragmentation issues for any particular trading pair. IntegrumSwap uses LayerZero to implement interoperability and thus works cross-chain.
Let's take as an example a user holding tokens on Optimism who wants to trade with a user that holds tokens on Ethereum. With IntegrumSwap these users can avoid going through the hassle of bridging, swapping and bridging back to the source chain.
For this ETHGlobal hackathon we have deployed IntegrumSwap end-points to Ethereum, Celo, Base, Scroll, Optimism and Linea. They are all Solidity contracts that send limit or market orders using LayerZero to the matching engine that was deployed on Arbitrum Stylus. The order matching engine smart contract is written in Rust and its only job is to match buy and sell orders.
The interesting question is what happens if we reach the limit that Arbitrum Stylus supports through it’s WASM VM? The answer to this is that it would not be very difficult to implement sharding with multiple order matching engines each taking care of a slice of the orderbook.
Integrum also implements a Uniswap V4 hook. If the users get better prices in local liquidity pool, the default swap logic is executed locally. Otherwise, if the user can get a better market order price on a remote chain, they go through LayerZero and the tokens are bridged accordingly across chains.
To sum up, IntegrumSwap proposes a fresh solution that brings together the advantages from Uniswap & CoW Swap into a Decentralized Cross Chain Coincidence of Wants exchange.
IntegrumSwap uses Arbitrum Stylus to implement an order matching engine to which all the limit and market orders are sent. It is written as a smart contract in Rust.
To communitcate between chains, IntegrumSwap uses LayerZero. For the hackathon we have deployed end-points to Ethereum, Arbitrum, Optimism, Scroll, Base, Cello and Near. They are all Solidity contracts that send limit or market orders using LayerZero to the matching engine that lives on Arbitrum Stylus.
For market orders, IntegrumSwap implements a Uniswap hook. If the hooks see that there are better prices on other chains, instead of doing the swap with the local liquidity pool, it bypasses the default logic and sends a market order through LayerZero to the matching engine.
So what if we reach the limit that Arbitrum Stylus supports through it’s WASM VM? It should be easy to implement sharding with multiple matching engines each taking care of a slice of the orderbook.
After the orders are matched, each individual endpoint uses Stargate to settle the tokens.
More details in the README here: https://github.com/scarfish-dapps/integrum-swap/blob/main/README.md