Hello everybody. We're going to get started on the talk. My name is Tanner. I am a technical account manager at 1 in. And today's talk is going to be reimagining the AMM with 1-in Aqua.
So the talk today we're first going to talk about the current landscape of dexes and a lot of the assumptions that we have when we just think about DeFi and Dexes in general. We're going to talk about what Aqua is and how it reimagines the AMM. We will then talk about extending beyond AMMs using Aqua and finally we'll briefly talk about just the benefits and LPS uh benefits for LPS, traders and builders alike. So let's get started with an example. So we have Bob.
He's a liquidity provider, also known as an LP, and he has some Ether and USDC, and he wants to earn some fees on this in DeFi. He would go to something like the Uniswap V2 W USDC pool, something very simple that everyone remembers, I would assume, and he would deposit his Ether and his USDC into this pool. Once he deposits it into this pool, he waits for traders to come along and swap tokens against his liquidity. So, Alice comes in, she has Ether, and she is interested in some USDC. So she will go to the unis swap pool through finding it one way or another and she will send her ether into this pool and she will get USDC back.
She's happy. Bob gets some USDC as a fee for being a liquidity provider and he's happy as well. And that's kind of the most basic classic example of AMMs as we all know them. But obviously there's more than one AMM and there's more than one LP and the ecosystem quickly gets much more complicated and much more fragmented over time. Um, as many of you know, one in solved this quite a while ago by saying, "Hey, Alice, instead of having to figure this out on your own, which is actually a pretty hard thing to do on your own, I think a lot of people just end up going to like unis swap or something very basic because it's kind of hard to find the right place to go."
We created the 1-in aggregator, which obviously kept the experience from Alice's point of view extremely simple. She just has to go to an aggregator like 1 in. She gets exactly what she wants and she does not have to realize how complex the system is behind the scenes. So to her the entire ecosystem feels like the liquidity is quite unified but in reality fragmentation only accelerated from here because we kind of uh abstracted the problem away from the users and just let everybody go crazy on the implementation side and there were many many many AMs that all competed for everybody's attention from the liquidity provider perspective and this led to a lot of reimplementation of custody accounting settlement anything you can think of there was a lot of copying and pasting going around a lot of just reimplementing the same stuff and it's just kind of kept growing and growing in that direction over time. So, the drawbacks of this system, as I kind of alluded to already, from the LP perspective, not from the user perspective, from the LP perspective, is choosing where to deposit your liquidity really sucks.
Um, if there were only four decks, this would already be a hard problem where Bob has to say like where do I actually want to go to earn fees on my liquidity. The second one is LP participation has a really high opportunity cost when you actually look at the broader uh landscape of DeFi in general. So, if Bob says, "Okay, well, I'm just going to put my liquidity inside of Uni uh unis swap," he loses access to all the yield opportunities from all other AMMs that he could be depositing his funds into. And if he were to be providing a liquidity uh providing liquidity for a ether or any other governance token in Ether, he also loses access to Dowo governance because a lot of these protocols, at least back in the day, would just use your balance on your wallet to give you voting power inside of governance. Moving funds is actually pretty high friction.
So if you choose to go into a specific AMM, you have to make sure that the contract you're talking to is safe. Make sure the front end hasn't been compromised. If you're really security conscious, you will probably like simulate this in a tool like Tenderly, which is a tool that I find very cool that if you guys don't use, you should try out. And then if you want to remove your funds from Uniswap to go into something new, you have to do the whole process again. Then if you go to Dodo, you're now verifying their front end, their contracts, simulating it.
actually is pretty high friction if you are doing anything other than just kind of yoloing your funds around the ecosystem which a lot of people do but I digress. Um and then if you want to move out of dodo same thing happens again you have to go through all of this process again. Um and then the fourth one is new projects only increased fragmentation over time and they even materially incentivized it. So, if we had four AMMs and a fifth AMM comes along, they're actually going to try to like give you boosted pools or maybe share some of their governance token with you or maybe tease an airdrop to actually continue to fragment the ecosystem more and more and more as these grow. And all the while, these LPs are trying to decide where do I actually want to put my funds to earn the most yield possible in the safest way possible.
So if we look at kind of the AMM design as we just discussed so far, there's always this central contract in the middle that is holding the funds. So the liquidity provider deposits their funds into an AMM and traders come in and they trade against this AMM. So one of the questions we asked when we started developing 1-in Aqua was, can we create the AMM experience without actually having the AMM in the middle? and something facilitate Alice's AMM experience to go directly into Bob's funds on his wallet, push funds in, pull funds out, and make both sides happy. And that is where 1in Aqua kind of was born.
So in 1in Aqua, liquidity stays inside of the LP's wallet. Uh the liquidity is not bound to any specific trading strategy. Um, if Bob wants to sell his ether or send his ether to a centralized exchange or share it with some other uh some other user on Ethereum, he can do all of that without having to worry about any previous commitments he has with Aqua because it's just funds sitting in his wallet. Uh, settlement is at top uh atomic from the perspective of the user. So again, they do not experience anything differently than what they know when it comes to AMM swapping.
The transaction completes, the transaction is over and funds are on both sides happy. So the architecture of Aqua can kind of simply be uh split into three different sections. One would be the Aqua router. The second is Aqua applications and the third is Aqua Strategies. And we're going to go through each of those now.
So the Aqua router you can think of as just a very simple 80line smart contract. It is responsible for the three core functions of Aqua in general and that is LP registrations. So what strategies is Bob interested in? what tokens does he want to uh allocate to various aspects of the Aqua ecosystem his balances. So how much of his total balance does he give access in Aqua?
Like he does you don't necessarily have to give it your full entire balance in your wallet. You can tell it how much access you want to actually give it. And then responsible for the swap settlement. So this means approvals, this means permits, the actual permissions of getting those funds back and forth between the users. Aqua applications are the swap logic implementations.
So think of constant product, concentrated liquidity, stable swap, all the things that have gotten very popular over the previous years of actual AMM design. And the third side is the strategies themselves. So these are the LP commitments to Aqua apps. So this isn't a contract in itself. This is basically the accounting of hey this LP wants to use this strategy like constant product wrapped ether USDC one ether 1500 USDC or maybe stable swap USDT USDS a thousand of each.
So this is just kind of the bookkeeping of how much participation this particular LP is going to be giving in an Aqua app. So if we go back to the example we showed earlier with unis swap and a very simple example of LPS on one side, traders on the other side and we kind of adapt this to the Aqua ecosystem. It gets a little bit more complicated but we're going to go through it. So now there are two layers. There is the Aqua router and there is the AMM.
And we'll call this the constant product AMM aqua app. So Bob starts by giving an approve or a permit for the Aqua router to use his funds. And he does this via uh and then after he gives the approval or the permit, he calls aqua.ship. And this ship call is just going to have all the information about the strategy he's actually subscribing to.
So in this case, it would be ether USDC and some amount of both. And this state would then be stored inside of the Aqua router. So the Aqua router now knows about the strategy. It knows about Bob. It knows about the permit and approval so it can access his tokens and it's ready to now use this for any traders that come along on the other side.
At this exact time it will also be emitting this data uh as a log in Ethereum and this will be picked up by any indexer. We are obviously going to run our own indexers but this is Ethereum. If somebody else wants to run their own indexer for this stuff they absolutely can. And this indexer will also keep track of Bob his liquidity and the strategy that he's subscribing to. Now, when a trader comes along, they will get this information from some indexer, in this case ours, and they will know that Bob is participating in the strategy.
They will send a quote to the constant product AMM Aqua app, and if they're happy with the quote, they will send their ether through just like a traditional AMM. At this point, the AMM will then talk to Aqua, and it will verify Bob's commitment on chain. If that is all true, if everything that Alice said to the Aqua app is true and can be verified by the Aqua router, it will then reach into Bob's wallet. It will pull the ether out and it will start move or push the ether in and it will start pulling the USDC back out and it'll give it to Alice. So from again from Alice's perspective, this is just a normal AMM, but this is a diagram to really show you kind of the moving parts that are going on behind the scenes.
So what do we get with this design actually? Well, LPs can sell and send committed tokens whenever they want. There's no commitments to doing this uh long term, and they don't need permission from Aqua to actually exit the ecosystem at all. They can participate in things like governance where token balances are checked at the time of a proposal going live because they now have these funds physically in their wallets. This is something that is not true if you're depositing into an actual pool contract.
Uh that's not totally true, but there are some nuances there and a lot of them do not support this kind of stuff. I actually don't know if anybody supports that, but technically they could support that. And LPS can reuse tokens for other Aqua apps and strategies at the same time. And this third one is a pretty big one, and that's where we're going to go next. So, if we were to give a more complex example of Bob having four tokens, $1,000 of each, Ether, USDC, A, and Tether.
This is $4,000 of total liquidity. But let's see what Bob can do in our example now using the Aqua ecosystem. So, first he'll use $1,000 of each ether and USDC and he'll put it into a strategy in Aqua via the constant product example that we had earlier. That's $2,000. He could also do the same thing with the same $1,000 of Ether and $1,000 of a for a second strategy.
And he could do a third strategy with another $1,000 of Ether and $1,000 of Tether. So his actual liquidity in his wallet is $4,000, but his effective liquidity inside of Aqua is $6,000. Now, if somebody comes on the other side and they're trying to trade with this exact Aqua app and they have USDC and they have Aqua and they have Tether, they can do all of this through Aqua through Bob's wallet without having to worry or know anything about the complexity of this setup. It just then looks like three pools, three places to trade liquidity and in this case uh get Ether back on the other side. Now, if there were two traders that tried to trade large balances that would throw off the math for any individual trade at the exact same moment, then whoever comes second would lose obviously because if you take all of Bob's Ether and trade one, then trade two is not going to actually succeed.
So if there are a lot of pressure on the same LP in a very short amount of time, it will cause reverts later on. But we'll have to see in practice how much that actually happens. We we don't think this will actually be a very big problem. So the example we went through so far was an aqua app using the constant product strategy. Uh there is also concentrated liquidity that you could do for an Aqua app.
There's stable swaps that you could do for an Aqua app. There's a lot of different reimplementations of AMMs as we know them that could all be their standalone Aqua apps. And we started to see that this obviously is going to have a ton of overlap, right? Other than the price curve itself, there's probably like a lot of overlap across any AMM you would design, at least in the traditional DeFi space. So, we developed another thing in parallel with Aqua that we call swap VM.
And this is an actual VM inside of the Ethereum virtual machine that is one layer below the Aqua ecosystem that tries to abstract away and make any AMM design much much simpler rather than reimplementing the same thing over and over and over. So these can be thought of inside of SwapVM as like building block functions for swaps. So maybe you have a specific price curve that you want to use. Maybe you want taker restrictions like some sort of NFT whitelisting so only specific people can swap inside of it. Maybe you want to add a 25 bits fee onto this process to uh pay out the LPS who are participating in this particular uh uh aqua amm and maybe you want to add a decay function.
That's what swap vim is trying to do is basically say hey we don't need you to rewrite the solidity over and over and over. Let's create something where you can actually build amm in a way that does lets you focus on the actual logic and flow rather than the code itself. So don't worry about reading the actual code. This is just trying to show a very simple example. On the left side would be a simple explanation or a simple example of the constant product formula implemented in solidity inside of Aqua and the right side is constant product in swap VM and yeah in swap VM.
So on the right side you're seeing JavaScript, the left side you're seeing solidity. That is because again the swap VM is an Aqua app. It's deployed solidity code and all you need to do is actually organize the instructions to build the AMM of your choosing. So it's much much simpler if you use swap VM, but you lose a little bit of functionality obviously or you have to extend swap VM if you're trying to do something pretty creative. So building blocks uh are actual op codes under the hood.
Like I said earlier, it is an EVM or it is a its own virtual machine inside of Aqua. And you can additionally go beyond the op codes that are inside a swapvm. You can call external contracts if you want to access oracles or do anything with additional de data that extends beyond it. And if you want to do something very creative, you can write custom op codes. Uh this is has an asterisk next to it because you need to redeploy the swap VM app if you want to go further than what it exist uh what it supports today.
But we encourage people to do that at hackathons because we're trying to see what the boundaries that can be pushed are. So we encourage people to redeploy and break things and try to push this system as far as it can go. Uh the next thing I want to mention is that Aqua extends beyond AMMs. The examples I went through so far are purely AMMs because it's a really good way to show the power of Aqua and kind of what it can do beyond what we know today as traditional AMM design. Um, in previous hackathons, we did this once before in Buenos Iris last year and people had created prediction markets, they created privacy pools, they created flash loans because at the end of the day, you just need to follow the rules of the Aqua ecosystem.
You don't just need to be doing simple token swaps. You can go much further than that. And a lot of these designs were and can be developed using swap VM. So you can do just Aqua apps if you want to or you can use swap VM which is quite a bit cooler little bit more technical but has a lot of potential to save everybody time. So if we look back at the example I showed earlier of a constant product AMM as an Aqua app and we just kind of switch this over to flash loans.
We can go through an example of how that would look like inside of the Aqua ecosystem. So Alice would get this information from an indexer and she would say hey here's the amount I want to borrow. Here's the payload I want to execute with my flash loan. The flash loan would then talk to the Aqua router, verify commitments, make sure Bob is participating, make sure the approvals are good, make sure his balances are good enough, and then it would execute that strategy for him. Well, sorry, I got ahead of myself.
It would pull the USDC out of his wallet, send it back to the application that is the flash loan app, and then it would execute that payload. It would pay him back, it would give him his fee for being an LP for a flash loan system, and then again, everybody's happy again. So it's very important to emphasize that although AMMs are kind of like the beginning of Aqua, it certainly is not the end. So another point to emphasize is if Bob wants to partate participate in flash loans with his USDC and he wants to participate in constant product A&M market making with his Ether and USDC and he wants to take all of his stable coins and participate in his stable swap. He can do all of these things in parallel because the liquidity is never leaving his wallet.
he is able to kind of extend and expand as far as he wants to go with his liquidity to optimize yield far beyond what people are used to when they think about this stuff in general. So just some thoughts of mine on the impact on the DeFi market that this will have. Um for liquidity providers, this means higher utilization of funds and better yields. Just full stop. This will actually happen if there's enough liquidity inside of this system.
For DeFi users, same thing. This would mean better prices for all kinds of DeFi apps. This would be swapping, flash loans, anything you can think of. This would just further efficient uh make the market much more efficient. And for builders, this is a much faster path to production and users.
So you don't have to go trying to re audit everything like everybody does. You can leverage the existing tools inside of Aqua and get a huge head start and then eventually have much more access to users as well. Uh so now to talk briefly about our bounties. Um we have uh building new apps using Aqua. That's going to be $5,000 split across the top three entries uh this hackathon.
And then we're also going to be participating in extending any existing app if you guys are building on top of those. And that will be $2,000 split across two teams. So, thank you everybody for listening. Uh here is a QR code which will take you straight to our hackathon page. This will have links to uh all the documentation, our white paper for Aqua, our white paper for swap VM, our SDKs for both of them, as well as the contracts themselves.
So, this should be links to everything you guys need to know. And uh that is it for me and if anybody has any questions.
Yes.
Oh, here. Hold on. Let's get a mic for you. Yeah, thank you for the presentation. Um, does the maker have to have his USDC in the balance uh from AQUA or can it be like whatever in DeFi?
Like can we pull the USDC from uh other sources or does it have to be uh linked at the balance of
Oh, I see. So you're saying does does the balance inside of Aqua need to match his physical balance on the address? I do not believe that it is strictly tied there. And and uh one concept that I didn't mention in the presentation is Aqua does have the concept of virtual balances which actually touches exactly on what you're talking about. So they are independent of the the underlying funds.
Thank you.
But obviously it would just fail if the funds weren't there, right? So yeah, it works out in the end. Okay.
Thank you.
All right. Any other qu Oh yeah, one in the back. Oh, hey. Um, just wanted to ask if you had any example of how we could utilize op codes for the uh swap VM or maybe just like a brief workflow like to your view how would like custom up codes be integrated into any swap whether it's u maybe for like bridging wrapping tokens before even utilizing in DeFi or is it only specifically just for the up quotes to be utilized in a swap and that's it? Um, since the op codes are just kind of free form and you'd be extending the router, you could do I think as much as I don't think there'd be many limitations at all.
So since you would be writing the code and kind of redeploying the router, I think you can get as creative as you want to. Um, if you want to see examples of people who have done that, I can link you to the previous hackathon where people did create custom op codes. And if you look at those and their repos plus our existing repos uh for swap VM itself, it would give you a really good idea of how to create your own op codes and and push that as far as you can.
Awesome. Yeah, I'll I'll get back to you on the de
I'll be at the booth too if you want to just meet me there. Yeah, if if we don't talk here. Yeah. Yes. Oh, one sec.
So this swap VM is an interpreter written in Solidity. It is I don't want to me mess up my words, but it is a VM in Solidity that kind of operates like one layer below Aqua. So, it does actually have a program counter. You can do jump instructions. It's pretty crazy.
Yeah.
But it's limited by the EVM. So, Yeah. Yeah. Hey, and just to clarify, like when the user wants to swap against Aqua Aqua, it's just like unis swap v3 or something. Uh, sorry, when the user wants to LP into Aqua, it's just like unis swap v3 where they can specify like the spreads uh for the token prices.
It's not just
you mean like in in like uh liquidity ranges if you want to have liquidity ranges.
Yes, you can do that because uh it it's it wouldn't just be like kind of an Aqua thing. it would be the Aqua app or the swapvm program that you are interacting with and yes concentrated liquidity is a thing there. So uh depending on the strategy yes but not all strategies support that obviously but yes the answer is yes in short
yes
does the LP have to be an EOA address or could it be a contract?
That is a great question. My guess right now is no, but let me verify that for you. My guess is it would support both, but I haven't thought of that question yet. So, I would need to double check for you. All right, any last questions?
All right, thank you guys.
Automatic transcript — names and jargon may be misspelled.