A cutting edge DEX taking advantage of the Lachesis consensus mechanism and cross-chain compatibility.
Fantom blockchain offers the benefits of using the Lachesis consensus. We adopt this consensus mechanism and build a DEX on top. The popular exchange Uniswap is our starting point for the DEX, which we augment by implementing cross-chain compatibility powered by the SWING api. The first brick is laid by deploying the Uniswap FactoryV3 contract on Fantom. Considering the lack of initial liquidity and for the scope of this hackathon, we continue our project on Polygon Mumbai, where the Uniswap contracts are officially deployed and liquidity for 3 tokepairs is available. Polygon shares similarity with Fantom by using the PoS consensus, yet it does not provide the asynchronous aspect. Using the SWING api, we provide corss-chain swaps and in future updates also inter-chain liquidity. Given the option to select a receiver network, the user can choose to send his swapped token to a different chain. For analytic purposes, we add an interactive dashboard which visualises in real time the swaps between tokens on Uniswap. The data is fetched from TheGraph, specifically the UniswapV3 subgraph. Future work will include creating our own subgraph and displaying cross-token and inter-chain liquidity. Last but not least on our bucket list is to issue our own ERC-20 token which is distributed as a singular token to each first time user. Fraud and abuse is avoided by the power Worldcoin api, which verifies an addresses ‘personhood’. This token allows one swap without gas fees, therefore enables users with tokens from different chains but without the native chain token to acquire said token to and continue swapping/interacting with the Lachesis powered blockchain, now paying the gas fees him/herself. This is meant to facilitate the migration from less efficient chains (Ethereum mainnet) for existing users.
How it's made
We started by spinning up our own blockchain and testing out throughput and block-minting time for different consensus algorithms. This was mainly made possible by the Polygon Zero project, where we used the Plonky2 repo to compare consensus performance. Lachesis outperformed all remaining algos. Running our own blockchain showed to be too cumbersome for this hackathon, thus we chose Fantom as our home network. Here we deployed the DEX contracts, based on Uniswap FactoryV3 and Openzeppelin. This was a success and we managed to connect the existing Uniswap dapp with our contracts. To continue developing liquidity was necessary, thus we moved to Polygon (Mumbai) were Uniswap has it’s contract verified and provides liquidity. To make our DEX inter-chain compatible and in future leverage liquidity to a united pool, we made use of the SWING API. The user can select a different receiver chain and gets prompted with the best possible ‘routes’ provided by SWING. Since SWING mostly supports native and stable coins, it makes sense in the case of a rare-token-to-popular-token-swap to first swap on-chain and then use the inter-chain functionality, likewise vice-versa. With a machine learning background, it is impossible to resist the urge to visualize this huge amount of data. Real-time swaps and liquidity are fetched from theGraph with graphQL, mutated and displayed as interactive, responsive and colorful SVG with the powerful data vis library D3.