project screenshot 1
project screenshot 2
project screenshot 3
project screenshot 4
project screenshot 5
project screenshot 6

VannaSwap

An ML-driven AMM DEX on the Vanna Blockchain that uses on-chain regression models to compute optimal fees/spreads to protect liquidity providers from impermanent loss and reduce LVR.

VannaSwap

Created At

ETHGlobal New York

Winner of

🏊‍♂️ The Graph — Pool Prize

🏊‍♂️ Filecoin & IPFS — Pool Prize

Project Description

We built VannaSwap, an AMM DEX that leverages the power of live on-chain AI/ML inference on the Vanna chain* to create an intelligent AMM that can vary the spreads/fees to protect LPs from arbitrageurs and more generically, from Loss-Versus-Rebalancing(LVR*) risk during periods of elevated volatility. LVR risk is an attempt to quantify the loss that liquidity providers face when being arbitraged by traders.

Using cross-chain communication protocols (e.g. CCIP, Axelar), we can further set up cross-chain volatility oracles to service inference requests on other EVM-compatible chains.

To demonstrate the effectiveness of the method, we additionally built off-chain and on-chain simulation code to benchmark the performance of VannaSwap (in terms of minimizing LVR and protecting against net IL) against regular constant-product market-making (CPMM) functions. The results of the continuous simulation we ran across 20,000+ historical data points indicate that VannaSwap’s dynamic fee mechanism does indeed significantly reduce LVR and protect LPs during periods of elevated volatility against static fee CPMMs.

*Vanna chain: an open-source L2 blockchain that allows machine learning models saved on IPFS to be run as a single opcode.

*LVR: a new way to quantify the costs suffered by the LPs of an AMM. Intuitively, it calculates the loss incurred by executing the trades via the AMM rather than on the open market. For more information on LVR, we referenced research conducted by a16z crypto: https://arxiv.org/pdf/2208.06046.pdf

How it's Made

VannaSwap is built on the cutting-edge Uniswap v4 hook contracts and Vanna blockchain to really empower the traditional constant product market maker (CPMM). When executing a trade, the trading fee for the pool is dynamically calculated (enabled by the Uniswap v4 hook) through the inference that is run by the volatility oracles (VOs). We make use of The Graph API and Quicknode's API to query on-chain historical pricing data, and subsequently compute the rolling volatility to use as inference parameters for the inference call.

The volatility oracle (VO) on the Vanna blockchain periodically inferences a machine learning model which inferences with data parameters obtained from the Graph, Quicknode, and other sources. The VOs on other EVM-compatible chains (e.g. Gnosis, Polygon zkEVM, FVM, Arbitrum, Scroll, Base, XDC, Mantle, Celo, Linea, Neon EVM) can also benefit from the inference of the Vanna blockchain by receiving cross-chain messages (with CCIP/Axelar) from the VO on the Vanna chain.

For the machine learning model, we obtained historical L2 book data from Kraken and trained a lasso-regularized regression model that regresses rolling windows of mid-price volatility on the average top-of-the-book spread. We chose to use L1 lasso regression to create a sparser model that addresses multicollinearity between the volatility features. The model is uploaded to IPFS (CID=QmXQpupTphRTeXJMEz3BCt9YUF6kikcqExxPdcVoL1BBhy) for inference on the Vanna Blockchain and is used to compute dynamic market-making fees through ML inference with rolling mid-price volatility. Deploying the Vanna Blockchain allows us to perform native, on-chain inference seamlessly and directly through a solidity smart contract function call.

Lastly, we proceed to conduct an on-chain simulation of the AMM through dates 11/09/2022-11/12/2022 to observe the difference in liquidity provider balance and the difference between aggregate LVR between VannaSwap (with dynamic ML-generated fees) and a standard AMM (with static fees equal to the median fee of the ML model to ensure we are not making an unfair competition). We designed the trading simulation program to assume that all traders are rational and make mathematically optimal trades against the pool to guarantee the maximum profit. After the simulation, the results make it abundantly clear that the dynamic fees do minimize aggregate LVR and shield AMM liquidity providers from toxic flow and arbitrage during periods of high volatility.

Technologies we use: Vanna Blockchain (open source): an Eth L2 supporting on-chain inference IPFS: decentralized model hosting Scikit-learn: volatility modeling and backtesting Web3.py: onchain simulation Foundry: Uniswap v4 deployment deployment Ethers.js: frontend interaction and some automation CCIP, Axelar: cross-chain message passing The Graph: data source Quicknode: data source and debugging Next.js, React.js: frontend Uniswap v4 hooks: Solidity smart contract EVM-compatible blockchains (Gnosis, Polygon zkEVM, FVM, Arbitrum, Scroll, Base, XDC, Mantle, Celo, Linea, Neon EVM): acquire more liquidity

background image mobile

Join the mailing list

Get the latest news and updates