{"title": "VannaHooks: AI Infrastructure for Uniswap V4", "logoImg": "bafkreid2by23grdxbhpgj2ki2usckwknzl4qxlk6k7tgkuj7nlcx32i7om", "website": "https://vannalabs.ai", "bannerImg": "bafkreigvrfcvai4swa362paggtlmux6z3otqvotlcphvacrw2f5azmroee", "createdAt": 1701300630551, "userGithub": "", "credentials": {"twitter": {"type": ["VerifiableCredential"], "proof": {"jws": "eyJhbGciOiJFZERTQSIsImNyaXQiOlsiYjY0Il0sImI2NCI6ZmFsc2V9..Gzq3x54pXvPpz7h3Vf1DIcRveeWcGAAOQmZPC0cM-tEmJSnDV6-AjcEEMm453Tjc-fEY6PW0x-fImyiX-Q80AA", "type": "Ed25519Signature2018", "created": "2023-11-29T22:43:32.944Z", "proofPurpose": "assertionMethod", "verificationMethod": "did:key:z6MkghvGHLobLEdj1bgRLhS4LPGJAvbMA1tn2zcRyqmYU5LC#z6MkghvGHLobLEdj1bgRLhS4LPGJAvbMA1tn2zcRyqmYU5LC"}, "issuer": "did:key:z6MkghvGHLobLEdj1bgRLhS4LPGJAvbMA1tn2zcRyqmYU5LC", "@context": ["https://www.w3.org/2018/credentials/v1"], "issuanceDate": "2023-11-29T22:43:32.943Z", "expirationDate": "2024-02-27T22:43:32.943Z", "credentialSubject": {"id": "did:pkh:eip155:1:0x83FFe2cbe305cCD48836b64726BdfD1fB643A13a", "hash": "v0.0.0:6MoTL89x3vRNIsTjk2bQTiQEhIYwzvumshLq8kT1PRg=", "@context": [{"hash": "https://schema.org/Text", "provider": "https://schema.org/Text"}], "provider": "ClearTextTwitter#0xVannaLabs"}}}, "description": "# VannaHooks: AI Infrastructure for Uniswap V4\n\n**Short Description**: Building on-chain AI inference infrastructure for the Arbitrum Ecosystem + creating AI-driven Uniswap V4 hooks to reduce AMM impermanent loss.\n\n**Category**: Uniswap on Arbitrum Ecosystem + Open Contribution\n\n**Requested Funding**: $240,000 ARB\n\n**Core Team**:\n\n**Matthew Wang**\n- Background: Computer Engineering at Northwestern University\n- Experience: Building AI inference on decentralized infrastructure at Vanna Labs + research engineering in options market-making at Two Sigma.\n- Focus: Project Supervisor + Vanna Infrastructure\n\n**Manav Aggarwal**\n- Background: Computer Science at Stanford University\n- Experience: Protocol/infrastructure engineering at Celestia + data infrastructure engineering at Two Sigma.\n- Focus: Vanna Infrastructure + Arbitrum Integration\n\n**Tony Lee**\n- Background: Computer Science at Northwestern University\n- Experience: Quantitative research in crypto market-making at Ava Labs + quantitative options trader at Susquehanna International Group (SIG).\n- Focus: Uniswap LVR Modeling \n\n**Andrew Wang**\n- Background: Applied Mathematics at UT Austin\n- Experience: Machine learning research at Capital One + machine learning engineering at Oracle.\n- Focus: Uniswap LVR Modeling\n\n**Jeffrey Lin**\n- Background: Finance at National Taiwan University\n- Experience: Experience building blockchain infrastructure, smart contract development, web3 security auditing, has also won 10+ web3 awards through multiple hackathon projects like ZKAlpha.\n- Focus: Uniswap Hook Smart Contracts\n\n**Project Context**:\n\nBefore diving into our project proposal, articles and concepts to help establish familiarity with relevant subjects:\n- [Impermanent Loss — Half of Uniswap V3 Users Lose Money](https://hackernoon.com/half-of-uniswap-v3-users-lose-money-heres-why)\n- [LVR — Quantifying the Cost of Providing Liquidity](https://a16zcrypto.com/posts/article/lvr-quantifying-the-cost-of-providing-liquidity-to-automated-market-makers/)\n- Vanna Labs: [How on-chain ML models can reduce impermanent loss](https://medium.com/vanna-labs/protecting-amm-liquidity-with-on-chain-machine-learning-5aa1af546528)\n- [Uniswap V4 Vision](https://blog.uniswap.org/uniswap-v4#hooks-custom-pools): Call for V4 hooks like Dynamic Fees\n- Vanna Labs: [Applications of AI/ML on the Blockchain](https://medium.com/vanna-labs/applications-ai-ml-on-the-blockchain-dc4ef449179e)\n- [Introduction to zkML](https://blog.spectral.finance/the-state-of-zero-knowledge-machine-learning-zkml/)\n\n## Project Overview\n\nThe Vanna Labs team is developing blockchain infrastructure to run AI/ML inference trustlessly and natively on-chain. \n\nOur goals for UAGP are four-fold:\n1. Integrate Vanna’s trustless AI/ML inference features into an Arbitrum Orbit chain to bring the power of inference to the Arbitrum ecosystem. \n   - We want to make it super easy for developers on Arbitrum to develop intelligent applications that use AI models directly from their smart contracts powered by Vanna. \n2. Research and integrate AI models that quote dynamic fees into Uniswap V4 hooks to provably reduce impermanent loss for liquidity providers on Uniswap (Arbitrum).\n3. Provide a sandbox ecosystem to allow developers to research and develop their own AI/ML-driven hooks for Uniswap V4.\n4. Drive research and exploration for using AI/ML intelligent compute to benefit Uniswap (in addition to dynamic fees), this may include:\n   - Using market regime models (like Hidden Markov Models) to vary fees in different market environments\n   - Building AI/ML models to measure average toxicity of users’ trades as a way to vary fees using a Uniswap hook.\n   - Exploring collaboration with Spectral Finance to incorporate AI-generated credit scores to reduce fees with a Uniswap hook.\n   - Creating ONNX models for pricing derivatives of tokens on Uniswap.\n\n## Vanna Information\n\n*Vanna Labs is building blockchain infrastructure to support trustless native AI/ML inference directly computed, secured, and verified on-chain; all designed in a way that is so seamless that leveraging AI/ML in dApps is as easy as a simple function call.*\n\n**Vanna Blockchain**:\n\nWe currently have experimented with a blockchain testnet (currently used internally for testing and experimentation):\n- RPC Endpoint: [http://dev-rpc.vannalabs.ai:9545](http://dev-rpc.vannalabs.ai:9545)\n- Explorer url: [http://dev-rpc.vannalabs.ai:4000](http://dev-rpc.vannalabs.ai:4000)\n- ChainID: 901\n- Faucet: [https://vanna-faucet.vercel.app/](https://vanna-faucet.vercel.app/)\n\nVanna is building an Arbitrum Orbit Chain and bring the power of trustless AI and ML inference to the Arbitrum ecosystem, and we’re super excited to start with tackling use-cases we’ve already researched for Uniswap’s AMMs.\n\nVanna is a blockchain network that settles on Arbitrum, and will be able to utilize cross-chain messages to communicate with Uniswap on Arbitrum via ArbOS precompiles. The ArbOS precompiles are able to thus, expose the inference results compute on Vanna to the Uniswap contracts on Ethereum to adjust the fees dynamically within the AMM pools.\n\n*Architecture Diagram*\n![Architecture Diagram](https://raw.githubusercontent.com/VannaLabs/Vanna-UAGP-Proposal/main/VannaTXFlow.jpg)\n\t\n[Here is a demo of our testnet running an on-chain fee calculation model.](https://drive.google.com/file/d/1cRb3HNAH88VSRqKRlgwKyNJvdmB3Uaj5/view?usp=sharing)\n\n**Vanna's AMM Experimentation**:\n\nIn quant finance, market-makers typically increase the spreads and widen their quotes during periods of elevated volatility or risk. This makes sense because market makers want to be compensated more for taking on more risk.\n\nHowever, this mechanism doesn’t really exist in DeFi AMMs yet, but one can imagine a similar mechanism through dynamically adjusting fees for AMM pools depending on the market regime. Uniswap put “[dynamic fees based on volatility](https://blog.uniswap.org/uniswap-v4)” as a key feature they’d like to see implemented via hooks in Uniswap V4.\n\nBut why are dynamic fees important? Dynamic fees are important because in periods of high volatility, impermanent loss risk is elevated and opportunistic traders are able to profit by arbitraging the pool and rebalancing the ratio of the assets in the pool; by dynamically increasing fees charged by the AMM pool during these periods of elevated risk, we are able to deter arbitrage activity and/or compensate liquidity providers more (with higher fees) for taking on high-risk order flow. Arbitrageurs are a net harm to an AMM because when they profit, it incurs impermanent loss on the liquidity providers of the AMM pool.  \n\n![Dynamic Fees](https://miro.medium.com/v2/resize:fit:720/format:webp/1*GZgFveapPG23BGUrOCW5Nw.jpeg)\n\nNeedless to say, impermanent loss is one of the biggest pain-points of AMMs. [A16z Research introduced the idea of exploitable LVR](https://a16zcrypto.com/posts/article/lvr-quantifying-the-cost-of-providing-liquidity-to-automated-market-makers/), suggesting a new metric for benchmarking the “performance” of an AMM by quantifying the amount of net profit the AMM exposes to opportunistic arbitrageurs. There is also [published research](https://arxiv.org/abs/2111.09192?ref=hackernoon.com) that shows that for [more than half of Uniswap V3 liquidity providers](https://hackernoon.com/half-of-uniswap-v3-users-lose-money-heres-why), they lose more money via impermanent loss than they profit from fees.\n\n![Impermanent Loss](https://miro.medium.com/v2/resize:fit:1400/format:webp/0*auvql7rBAWRski5z.png)\n\nVanna enables native (on-chain) and trustless (zkML-secured) AI/ML inference, so we want to work with Uniswap to create a V4 hook on Arbitrum that uses price volatility to feed into an ML model on Vanna to trustlessly compute dynamic fees for Uniswap AMM pools. \n\nWe’ve already built a sample proof-of-concept regression model that we have running on the Vanna testnet that computes dynamic spreads; *however*, there is still a significant amount of room for improvement. In order to develop an effective model, we need to undergo significantly more thorough research, testing, and iterative model development; and we have planned to do as such as part of UAGP.\n\nFor the experiment model, we obtained orderbook data from the Kraken exchange and trained the model to quote like centralized market-makers. The model regresses different windows of price volatility on the top-of-the-book spread quoted by market-makers on Kraken. In other words, it uses moving-window volatility to predict spreads.\n\nWe then ran a simulation and modeled traders as purely opportunistic, in order to benchmark the performance of our spread calculation model. Note that the simulation time period is quite short, and only meant for demonstration purposes, we plan to create a more robust simulation platform as part of UAGP. The green line represents the ETH-USDT price while the red represents the volatility, which is the rolling standard deviation of the price.\n\n![Simulation](https://miro.medium.com/v2/resize:fit:1400/format:webp/1*S58TUXZGuoZlkto0bgrS7w.png)\n\nAs one can see from the results below, in this simulation, we are able to see the difference in liquidity provider balance increase over time (red: difference between dynamic fee model vs static fee model), especially when the exploitable LVR opportunity (represented as blue bars) was high. Empirically one can observe the dynamic fees protect user liquidity through charging higher fees to arbitrageurs during periods of elevated volatility.\n\n![Results](https://miro.medium.com/v2/resize:fit:1400/format:webp/1*cltuyKc3OmiBXZ84F0j_jg.png)\n\nThe key lies in reducing the net instantaneous exploitable LVR during periods of high volatility by increasing fees\n\nThe experiment was part of a hackathon project the Vanna team had worked on, [codebase linked here](https://github.com/jeff0723/VannaSwap).\n\n## Arbitrum Ecosystem Impact \n\n*Vanna aims to bring trustless AI/ML to the Arbitrum ecosystem by building an Arbitrum Orbit Chain that can run inference. This would allow for developers within the Arbitrum ecosystem to use Vanna’s infrastructure to leverage sophisticated models in a way that is trustless, secure, and scalable to build sophisticated dApps that are more intelligent.*\n\n![AI Use-Cases](https://miro.medium.com/v2/resize:fit:1400/format:webp/1*KQNIQ5ZZIs2trWyyvg1v_A.png)\n\n**Nerd-sniping for Arbitrum**:\n\nVanna opens entirely new verticals for nerd-sniping more engineers and researchers into the Arbitrum ecosystem to develop applications on Arbitrum with Vanna’s infrastructure as an orbit chain. Here I highlight multiple new areas of development that Vanna creates for the collective and can get engineers and researchers alike excited!\n\n1. Quantitative Research in DeFi \n   - With secure on-chain inference, we can leverage machine learning to enable sophisticated features within DeFi! Opens the door to quantitative research talent from quant funds like Two Sigma, Jane Street, Citadel…etc.\n   - Quant Research talent can help build DeFi risk-engines, AMM spread calculation models, quantitative trading models for vaults, price forecasting models, crypto derivative pricing models…etc that all live on-chain.\n2. AI Research\n   - Attracts researchers who are interested in building AI/ML models and researching the use of AI models in a Web3 context. New AI models could enable interesting use-cases like autonomous agents on-chain.\n   - Interesting Web3 x AI/ML specific research areas like decentralized federated learning or fully homomorphic encryption (for model privacy)!\n3. zkML R&D\n   - Attract developers and researchers who are interested in applied zkML, as Vanna is one of the first blockchain networks to enshrine zkML cryptography into the blockchain architecture.\n4. AI Application Developers\n   - Attracts blockchain developers who are excited by being able to develop new applications empowered by AI/ML. Like dynamic NFT art generation projects, use-specific language generation protocols, Web3 chatbots or agents…etc.\n\n![DefAI Meme](https://miro.medium.com/v2/resize:fit:828/format:webp/0*WhuzuE-LJxwi0o7t.jpg)\n\n## Uniswap Ecosystem Impact\n\n*Vanna plans to use machine learning models secured by zkML to intelligently compute dynamic fees for Uniswap pools using V4 hooks to reduce net impermanent loss for liquidity providers (LPs). We also plan to explore various other use-cases of intelligent compute and how Vanna can be used to further improve the Uniswap user experience.*\n\n![AMM Dynamic Fees](https://miro.medium.com/v2/resize:fit:1400/format:webp/1*tPMzEZHd0fPaiKkyjp4_XQ.png)\n\nFrom the simulation experiment we conducted above, we are able to see that there is a quantifiable benefit to dynamically varying fees for AMM pools by using a model to emulate how centralized market-makers quote on orderbook exchanges.\n\nThis model can prove to be extremely powerful for an AMM like Uniswap:\n- **Liquidity Providers win** because they will suffer from less impermanent loss in the long run.\n- **Regular traders win** because when folks trade normally most of the time they can actually benefit from lower fees.\n- **Opportunistic arbitrageurs lose** because they make less net profit (due to higher fees) when they arb a pool. \n\nWe wrote more about our experiment here, [this article](https://medium.com/vanna-labs/protecting-amm-liquidity-with-on-chain-machine-learning-5aa1af546528) contains high-level comments about our implementation and thoughts.\n\n**Vanna x Uniswap Synergies**:\n\nWe want to create a positive sum game for Vanna x Uniswap, here are some benefits that we think Uniswap will benefit from for this partnership.\n\n1. **Improving Uniswap (less LP impermanent loss)**\n   - The most obvious benefit for Uniswap is that Vanna’s models can help improve the liquidity provision experience for LPs on Uniswap, by reducing the impermanent loss they suffer from via dynamic fees.\n\n2. **Opening doors to AI on Uniswap**\n   - The Vanna x Uniswap integration opens the doors to new quant research and ML engineering talent that may be interested in building sophisticated models to help improve the initial fee calculation model, or build out other sophisticated models to help build more features or solve other problems on Uniswap. Examples:\n      - Systematic trading strategies \n      - AI-driven smart execution\n      - Models to predict trade toxicity for varying trading fees\n      - Using HMM market regime models to vary fees in different market environments\n      - Incorporate AI-generated credit scores to vary fees\n      - Creating models for pricing derivatives of tokens on Uniswap.\n\n3. **Opening doors to new applications on Uniswap**\n   - Kickstarting the Vanna x Uniswap integration will encourage more intelligent dApps to be developed on Uniswap in the future. AI driven vaults that use Uniswap for trading, ML driven risk management that uses Uniswap to de-risk or hedge portfolio exposure, ETFs that have smart rebalancing…etc.\n\n4. **Tech-forward PR**\n   - With AI and ML being increasingly popular and ubiquitous, having a progressive approach to integrating these technologies to improve the experience of users reflects well on the protocol team. It’s good to be a trailblazer in piloting new technology, demonstrating a forward-thinking culture.\n\n## Vanna's Planning\n\n**KPIs**:\n\n1. **AI/ML x Web3 Adoption**: Achieve 3000+ inference transactions a month after Sepolia Testnet launch.\n2. **Reduced Impermanent Loss in Uniswap pools**: Benchmark AMM performance with new Uniswap hooks that empirically demonstrate lower impermanent loss for liquidity providers.\n3. **Community Growth**: Grow community of AI x Web3 enthusiasts to 10K users and/or developers. Notably, we’d like to get the community excited about AI/ML use-cases with Uniswap V4 Hooks.\n4. **Partnerships**: Form strategic partnerships to collaborate with 2-3 other projects interested in building AI/ML dApps in Arbitrum or Uniswap with Vanna.\n\n**Milestones**:\n\n1. **Orbit Chain Development** (Months 1-3): Develop blockchain with AI/ML inference features available on-chain, exposed via precompile.\n   - Deliverable: Working blockchain testnet with secure on-chain AI/ML inference enabled in addition to being able to expose inference cross-chain with Arbitrum and other dApps on Arbitrum.\n   - Budget: 50K\n\n2. **Data Cleaning, Data Exploration, and Model Research** (Months 1-2): Acquire clean market data for key asset pairs and begin data exploration around spread calculation model development.\n   - Deliverable: N/A\n   - Budget: 20K\n\n3. **Simulation Platform and Model Development** (Months 2-4): Develop AMM trading simulation platform, and start iterative testing and development on different models.\n   - Deliverable: Comprehensive research article about the developed ML model and benchmark simulations in liquidity provision against popular AMM models like CPMM and CSMM.\n   - Budget: 35K\n\n4. **Uniswap Contract Development** (Months 3-4): Develop and deploy Uniswap V4 Contracts with the AI/ML enabled dynamic fee hooks\n   - Deliverable: Working Uniswap V4 hooks using AI/ML-enabled dynamic fee hooks + Uniswap V4 deployment on Vanna.\n   - Budget: 35K\n\n5. **Engineering Productionalization** (Months 5-6): Productionalization and deployment of the Vanna Network with robust hardware (like GPU inference nodes) along with all the relevant contracts and integrations. Seek security audit services to do a final security audit pass on our infrastructure and contracts.\n   - Deliverable: Production-ready blockchain network on the Sepolia Testnet deployed with block explorer and docs, supporting reasonable amounts of inference transaction throughput with production hardware.\n   - Budget: 65K\n\n6. **Marketing, Technical Writing, and Community Development** (Months 3-6): Author technical whitepaper with tech specs, write technical documentation, and conduct social media marketing for awareness.\n   - Deliverables: Technical whitepaper, tweets, medium articles, and technical documentation.\n   - Budget: 35K\n\nFor important milestones, we'll be authoring and publishing articles and thought pieces that outline our research, experience, and learnings as well. We'll also be tracking these milestones publicly in a [Github Project](https://github.com/orgs/VannaLabs/projects/2) for transparency.\n\n**Conclusion**:\n\nConclusively, we think on top of being tech-forward in researching and experimenting with more intelligent compute in a quantitative DeFi context, the Vanna <> UAGP project can bring about numerous benefits to the Uniswap and Arbitrum ecosystems alike. \n\nFor Arbitrum, we’d like to unlock doors to new tools, technology, and paradigms of programming that can enable developers to build AI-empowered dApps and features. \n\nFor Uniswap, we’d like to improve the user experience through intelligent features that can lead to protected user liquidity, more efficiency, and an increased frictionless experience; but more importantly, we’d like to create the tooling necessary for developers and researchers to continue iterating on use-cases of AI with Vanna for Uniswap’s AMMs.\n\n**Vanna Labs Links**:\n- [Vanna Testnet Demo](https://drive.google.com/file/d/1cRb3HNAH88VSRqKRlgwKyNJvdmB3Uaj5/view?usp=sharing)\n- [Vanna Labs Twitter](https://twitter.com/0xVannaLabs)\n- [Vanna Labs Github](https://github.com/orgs/VannaLabs/repositories)\n- Vanna Labs Article: [The State of Blockchain x AI Inference](https://medium.com/vanna-labs/the-state-of-blockchain-x-ai-inference-c0e386356d49) \n- Vanna Labs Article: [How on-chain ML models can reduce impermanent loss](https://medium.com/vanna-labs/protecting-amm-liquidity-with-on-chain-machine-learning-5aa1af546528)\n- Vanna Labs Article: [Applications of AI/ML on the Blockchain](https://medium.com/vanna-labs/applications-ai-ml-on-the-blockchain-dc4ef449179e) \n\n\n", "logoImgData": {}, "bannerImgData": {}, "projectGithub": "VannaLabs", "projectTwitter": "0xVannaLabs"}