The rise of programmable intents by Alex Vinyas

ETHDubai 2024 · 21 Apr 2024 · 28:50

Alex Vinyas explains CoW Protocol’s move toward programmable intents. He discusses CoW Hooks, programmatic orders and CoW AMM as components of a more general transaction execution system.

Speakers

Topics

From ETHDubai 2024, hosted by DeFi Dubai.

Transcript

I'll go with this good morning everyone thank you for being here and making all the way through the week so I'm I'm Alex Vias I work at cow and today I'm going to give a talk about the rise of programmable intents which I guess it's a topic that has been like picking up lately and I've broken down the talk into four topics first like a bit of history of cow then what are the current problems with intents but more specifically with smart contract intents then I'm going to introduce you to the concept of ERC 1271 smart orders and then finish with the what we think is the era of programmable intents so first a little bit of of beef history H cow da

is a DA that was a spawn out of nosis nosis Dow in 2022 and it's on a mission to create the most Innovative and protective user products on ethereum and soon most likely more layers as well and there are three main products that belong to cow the first one is cow protocol which is the leading intent based trading protocol it's similar to an amm and a DEX aggregator but with a fundamental and yet much better difference because H instead of just acting like a router we add a thin batching layer on top of the amm and aggregators that allows us to combine multiple intents together and execute them in a single transaction not only from that we're able to gain H batching

efficiencies but we're also able to offer better optimizations in prices because we actually that's where the name comes from we're able to match users via Coincidence of on which are peer-to-peer trades and this ultimately leads to much better pricing and the best Meb protection because there's no actual way to uh play with your with your transaction then the second product that was recently launching is KM which is the first Meb capturing amm and km allows liquidity providers to protect themselves from AR arbitragers that take advantage of them by connecting uh their trades with centralized exchange and then tapping on to their liquidity at a much staler price this is called lbr and

km protects liquidity providers from lvr by leveraging smart intents in this case RC 1271 to trigger the transactions to actually protect the liquidity providers and lastly me blocker which is the the leading me protection RPC on ethereum and this product was mainly created for those let's say lost souls that don't trade on cow swap and trade still elsewhere that then if they don't want to have the best protection then at least they have uh some additional protection guarantees that come from from c as well but today I'm only going to focus on cow protocol and CM because the talk is about T and not just about me uh but how was C protocol it h you

know designed to work well C protocol was designed to work H from the beginning for all different types of users the first one was for retail right because the whole idea with uh the type of account abstraction that Co protocol has is that H nowadays it's very complicated to make a transaction on etherum you have to know what the right gas price is you have to be uh very informed in to where is the best amm pool to trade and and many different aspects to take into consideration so C protocol was designed with the with with this in mind in a way so that users instead of actually creating the transaction for themselves they just create an intent to Trend and a

professional party called the solvers are the ones in charge of you know H adding all these complex technical stuff that blockchains have the second one is for for smart contract wallets or smart contracts in general because until cow protocol the standard was that with a smart contract the moment you created the trade you actually had to compromise the exact amount of tokens that you wanted to get out which open the which open your trade to Meb because people already knew from the transaction the amount that you know the lowest amount that you were willing to take and not only that but because you are a smart contract wallet and you you you usually have more or less at least like three

signers or two out of three you had to spend time to connect with the other signers to execute the transaction so this time that elaps between the actual transaction creation and the final submission or execution of the trade also led to like sub optimal prices and lastly because of dows because Dows have been kind of like the promise of ethereum but they haven't truly like you know unleash their powers because if you add a because if a DA is a smart contract not only do you have the same problems as the smart contract wallets but you also have the addition of governance which 10x the problems because then you have to at least you know wait five days until the proposal is gone so it's just a horrible

experience because if you already craft the swap 7 days in advance then you kind of leave H the door open for the market to completely exploit you because it's kind of very well anticipated like what you want to get and the talk focuses on these two because these two are the ones that so far have suffered the most because with EOS it has actually been somewhat easy to to create intents so what is the problem right the problem with a smart contracts is that there is no way to actually create the signature in the same way with with EAS but there are two main problems there are execution issues and technical issues but from the execution side as I said right you have the me problem you have to compromise your minimum amount

already beforehand you also have to gather all the signers of the transaction which delays to to the process and lastly you well sorry lastly not you also don't have the the onchain guarantees because there's no one to like especially if you can't play this offchain system there's no easy way to add the guarantees within your transaction that is going to trigger how how how you want to do it and then if you're a doubt then if you have the governance process then all these problems kind of like escalate even more but then you also have the technical issue right because EAS can create EIP 71 12 and each type of signatures you can actually create like an approval transaction via an intent that authorizes this third party to kind of

do this computation of chain and submit your transaction of your behalf but if you're a smart contract because smart contracts don't have signators you don't have private Keys you're not able to create the actual signature right so then the smart contracts or any Dow is actually forc to trade on the onchain route and also we do this what we used to do this via the pre signature route which basically is just creating a transaction that like uh submits all the parameters of your orders on chain who then like a offchain system like picks up but this is pro this is not problematic but it's a worse ux because then you actually have to pay for the transaction to to to place the order and you cannot leverage the advantage of H

intents like like an EA so how is this get fixed well uh with RC 1271 uh we enabled the smart orders and this is actually like um Rising a lot because the it opens up a lot of possibilities right and uh ER ERC 1271 is basically like a smart contract order interactive signature verification so instead of using e recover which is the what is used by regular orders you used a um a function called isic signator and basically what this function does is that it allows your smart contract to actually authorize someone else to place the order on on your behalf not only that but because you're the smart

contract you can actually like add guarantees on top of your order like uh where is the block time that you don't want the swap to execute until what I don't know check the Oracle price or don't execute this swap until the current balance is whatever and this is very interesting because then it truly enables a smart contracts to actually Place intense systems because the way it works is then you have this offchain sort of Bot called a watch Tower or call I don't know whatever you want to call it that basically like acts as your butler let's say from the smart contract and what this botler does or Watchtower is just placing the order inside the cow protocol order book and then it it's passed on to the solvers and then whatever the solver wins H submits the

actual transaction and then at the moment that the transaction is actually validated your smart contract is being called to this signature to the is valid signature kind of like hey someone else posted this transaction of your behalf according to your parameters are you okay with it yes or no and then if the Watchtower has behaved correctly because then it's kind of like read all the parameters that the smart contract wanted it should be correct and the smart contract would say yes and then we have the swap or we have the intent already placed so the first use of smart orders that cab or C protocol implemented was actually like the e flow right in Kao at the beginning you couldn't sell e directly why because e is the native

token of the chain and it's not a nc20 so you actually have to wrap it into we and even though that's I don't know quite a simple thing to do just rubp your e there were still many people that complain and wanted to wanted to trade e directly so be the we develop this intermediary contract that leverages smart orders to basically allow users this and basically the flow is that the user sends the E directly to this intermediary contract and then this intermediary contract is the one that's connected to the wat Tower who actually ignites all the transactions it basically like picks up the information that the User submitted via VIA CA it initiates the order to wrap the E and then it places the smart order into the into the C protocol order book and then

solver compete and at the moment of um and at the moment of like submission on chain then the swap happens and the the user gets the in this case the die that they wanted the Second Use case was developed H by by year in collaboration with the c grants program and and it was actually a a specific U use case for unleashing like the governance D powers and this was the product that ens leverage well ens a and Nexus mutal have already leveraged this product and basically is the idea that you can pre condition the swap for your governance kind of boat or your governance process and the whole idea is again what I said before right if I want to make like

currently either you appoint a treasury management if you're a dow and then kind of like the treasury managers have full control of the swaps that they want to execute in the treasury but there's no really like more opinion within the D because you know you canot give full power within the certain amount of assets of the treasury to that treasury team but now with Milkman what you can do is say like okay we're going to create this proposal and because this proposal unlike others uses ear of 71 and doesn't compromise on the exact amount of the tokens that we want then we can still go through governance and get like the most optimal price why because the way that basically this works is that you say okay you specify

an oracle price and you spe you specify the time preference that you want the trade executed so basically what you're saying is like hey I want to sell 10,000 e and using this Oracle price and this is going to tell me that like at the moment that the governance if in case the proposal passes and the S has to be executed then this bot is going to submit this transaction to the C protocol order book and the guarantees that the Dow has is that at the moment of settlement right it's going to ask this is valid signature hey this this this bot proposed this order to sell 10,000 e and if not mistaken this is within the current price that you wanted which can be like I don't know 1% of whatever unisa pool you decide or 1% off

like you know not to be farther than 1% than a chain link Oracle or or whatever Oracle you want to pick and then this way is the allowing a smart contracts to actually like put the swaps back into the governance process without having to worry about like signatures compatibility or or Meb and still getting the the best possible price but the problem is that these examples are single smart orders and they have drawbacks the first drawback is that they're like quite costly in terms of gas because you have to you know do so many computations and do the onchain guarantees they're a little bit costly like they're not they're not the most optimized like gas H settlement the second one is that they require the the

money to go to this intermediary contract who who can then like talk with The Watchtower and of course this is not like a major drawback but I don't know if you're a dow and you're not very risky you might not want to have to deal with sending the funds to this intermediary contract and lastly is that there's single order base right if you want to automate any process as a dow or you want to do recuring swap it's going to be very annoying to have to design the transaction or like craft the transaction every single time so this is where the programmable ints come to play right in C protocol we created a programmatic order framework which is a conditional smart order framework that allows you to indicate many intes to trade with a single transaction created

in the beginning right and the beautiful thing is that you can create without any trust assumptions and you can actually like add these onchain guarantees for the moment it's very focused on the safe wallet so this is interesting because right now also like soon next week the safe is going to release the toket so there's a lot of things to to see how the market behaves and there are a lot of new things that you can do and actually like the programmatic order framework allows the safe to become a first Clan CZ in for Trad and because you can actually turn it into I mean I don't know but people would say an AI agent because you can kind of condition all the orders or all the different strategies that you want to trigger and then with with the help of this spot it

will just basically use the funds in your safe to actually trade on on your behalf since it has your intent permission and and we're already using this for tab for example in tab this is the architecture for tab if you leverage the safe you have basically this uh middle contract which is the composable car which is the programmatic order one and here is the famous Watchtower that we have right and in tab which is time weighted average price in case anyone is aware you you want to create a set of recurring orders so like say I don't know buy e at during 10 times for the next six hours and the current process that you could do that

is that you would have to sign the 10 orders but with a with the smart programmatic order framework intents you can do is simply create this major intent to Trend that then is going to give the permission to this Watchtower to actually create all the orders on your behalf and basically like the flow would the same right you you create the order then the complete order structure the conditional order is created is deposited in here which can be like any decentralized storage Network ipfs like whatever you want or it you can also skip that if you run your own Watchtower and then the Watchtower is the one in charge of creating the discrete orders at the time that your smart contract has specified and then from here the watcht just post the order VI an API directly

on the order book and then from here downward is as as normal has any like regular order on cowo this is also very similar because in cimm it also leverages the proof of uh sorry the proof of the programmatic order framework because in this case basically like you deposit your tokens that you want to LP on your on your safe and you do it at 50/50 and from there you specify the wat Tower H which price checker or Oracle you're going to compare or you're going to reference your pull from and basically what the watch to is going to be doing at all time is comparing if the Bal like if the position in your safe is completely balanced 50/50 based on the reference

price that you said and in the case that it's not balanced then it's going to propose a trade on the C up order book so that the assets are rebalanced again and the beautiful thing is that you once you've done that you don't have to worry about this because you can you can have the Watchtower basically rebalance your position at at at at all times but another way which actually like the intents come to play is that now also if you don't want to have the Watchtower or if you're a solver and you you know you're more advanced than the rest and you want to actually take advantage of these several cment pools what you can do is once you place the order sorry once you're aware that this liquidity pool exist you can just treat them like

any other amm and liquidity pools and basically leverage the CM as a as a liquidity pool with much better rates because the only way that this liquidity can be accessed is either through the solers or through the ca bat and therefore if you as a solare are indexing this liquidity you can offer better rates for those orders that are coming through CA and then from there it's the same as like the T up or the EAS right it it's just the transaction gets submitted at at settlement contract and then in the moment that the settlement contract actually pushes the transaction on chain then basically like a your your smart contract wallet or smart contract validates if you're okay and and like this trade that is being proposed on

your behalf is uh accurate based on the conditions or the guarantees that you you established so what are the use cases for the programmatic order framework the first one is uh kind of like a major one like a fee crop recollection if you are a doubt that has to like collect fees from swaps or from on the any other different activity you can actually use this framework to automate like a weekly or monthly swap to Simply like H you know once let's say once the balance of this contract hits a certain threshold execute the swap into whatever token I want and then send it elsewhere so that we're always secure then like you know there's not more funds in the wallet that we want to in the wallet in the

smart contract that we want to H not put in danger the second one for example is payroll if you're a dow and you want to uh automate the payroll of your Dow contributors you can actually like create a create a a swap order that says okay for the next 12 month at the end of the at the end of each month basically create a swap that grabs my native token sell it to a stable coin and automatically distribute it to the contributors and the beautiful thing is that also because the programmatic order the framework uses mer three for storing the conditional orders you can actually like uh create unlimited discrete orders not only that but it's very easy to update

because then you can just replace the the New Order with just a new Merle tree and then and then for example in the case of contributors if when you created the swap you had 12 contributors but by the six month you only have seven instead of having to ditch the entire order and create a new one you can just update the new Merle tree and the Watchtower will pick it up and it will know that now we're only like five contributors the other one is is the case of for example a CM but this can be taken like much further apart is basically portfolio rebalancing right like you have an strategy within your safe wallet and you want to say I don't know in the case like keep the keep the portfolio 50/50 at all times based on

this price reference or if you want to do like multiple assets you can also do it I mean this is different than km but you could do it basically say like I want to assign weights to this portfolio and as long as one weight becomes more Val like one type of asset becomes more valuable than the other just basically like rebalance so that the weights are constant at all times then also you can do like collateral position manager right if I have a CDP open right now and I'm here and I don't have some sort of script or bot that uses that is in place maybe I'm going to get wrecked because I I don't have my private keys and I'm here in Dubai and I don't want to like even have to think about it but with the programmatic ORD framework you can have

the guarantee that you know as soon as certain thresholds are hit the the bot in this case the Watchtower will just trigger the transaction on your behalf and and you can just enjoy calmly wherever you are then tab which is the case that I already explained and then also you can do like conditional order such as a stop- loss right hey again if you want to protect yourselves from volatility but you don't want to have to carry the computer at all times you can basically just program the order to trigger based on certain outside conditions and the Watchtower will do actually the job for you so where is the conclusion of all this well the conclusion is that intents are entering like Mass adoption because the programmatic G framework expands the way in which intents H can operate

within a smart contracts which ultimately is kind of the dream because we've always within ethereum talk about like the programmability of and auto and auto execution of all these kind of financial transactions but with EAS H we have someone achieved that but not with the smart contracts and the beautiful thing is that then with a smart contracts you can also Place simultaneous conditional uh in T all in one go and that in combination with cow hooks basically is they allow to H is it gives you the ability to express any intent in combination with your swap right and and and the good thing is that then also it allows to make it like the such interaction with intents recurring because basically with C with cow hooks

you can add like pre and post interactions to your to your swap intent and this would allow you to for example say like okay Bridge a a stake a token or restake a token swap then stake it again or claim a token swap it into the coin that I want to put again into the lp and then reput the position or meet swap approve like you can add basically any sort of interaction that you want in before and after your swap so this allows to H kind of push the intent language or intent kind of Market Beyond just uh swaps and yeah the sky is the limit if you're interested in integrating into T please reach out at bdia cafi and if

you're interested in building C grants is is there for you ready to give grants so thank you very much well thank you we we have a couple minutes for for questions if you have anyone has question rest your hand it was so clear that no one has questions very clear thank you so much um no question okay um so we've heard quite um a lot about um intent today oh question uh it seems there's a lot of work to do so is there any expected timeline to reach a usability for for

for the intents in C swap I mean this is already life like you can already use this today the problem the the I mean okay well yeah it's it's already live from the like engineering point of view what is missing right now and we're working on it is the UI so basically we're expecting that like by end of this quarter if not a three like Q3 that you'll be able to actually like very easily within the UI kind of combine this intents within your swaps as well but technically it has been already live for a for a long time you just needed to know a little bit to code which not that many people so it's a tricky

uh I was uh wondering a bit about the sustainability like do you do you guys see people trying to attack uh this this model you've got uh have you seen uh have you seen people trying to take advantage like trying to break your your model so far no I mean in general the most type of attacks that we get is more like spamming to clock the system like just sending many orders but in General that's basically it because the at least with the wat Tower you can actually make it very private because currently there are very few watchtowers running and like the team the core team like has one running but this is completely free for anyone to run so if you're like you know paranoic

and don't want to rely on centralization you can actually run your wat Tower and make your orders completely like private to you and then therefore there's no way because it's within your local storage or your local system or setup that you have that the information of the orders are there so there's no easy way to break it right but for example you could be dsed yeah yeah exactly but but you can D but but you DS the C protocol I couldn't do do you because if you're running it in within your own system I don't know where that is right right well unless you do find me but yes uh I assume it's um it's going to be hard okay I have another sustainability question question uh do you when do you expect to run out

of cow jokes um I don't know keep keep keep on going for the moment keep on moving hi uh I just want to make sure I understood what what makes it programmatical uh programmatic as as far as I understood you're making intents that are conditional on Smart contract values as well as intents that are time dependent like recurring or occur at a certain time yes so basically the the idea is that instead of treading the orders like like single like you know only like taking care of one case you can basically create like a conditional tree of order that then has end discrete orders that these discrete orders behave

according to guarantees that you want to do so for example like I don't know unless balance is above this certain threshold and price is not this don't trigger and then this is is replicated for each kind of discrete order that you have created within the conditional order yeah yeah but but but the way it's the way it's programmed um is the condition like General it's any condition like any value in a smart contract yeah yeah this is like the you can sort of think of like the the whole point of the framework is that um I mean we have some implementations but the whole idea was for any developer to kind of come up with their own conditions and focus of focus on their own like condition logic and then like the framework takes care of all the rest in

terms of submission submitting to C protocol order book connecting and then you know like H putting all the parameters or like the order digest in the correct way for the protocol to kind of you know kick it in and like pass it on to solvers okay thank you okay one last question so this is actually a followup to the previous question that if everybody can write their own condition conditions how do you deal with the halting problem like how can you keep the complexity of evaluating the conditions in check well the the the conditions that are um it's basically I guess like the harder you make it the

more you have to Signal The Watch Tower to take into consideration and then maybe there's like I mean I guess we haven't really like tested with a thousand conditions no because I don't I don't know if you want to make a financial order with a thousand conditions but technically like this is handled by the Watchtower so if your Watchtower can like you know absorve the the the the amount of conditions that you've put then there's no limitations but maybe this is more Technical and there