New Ethereum talks, every Monday. The week's conference uploads by event, in your inbox.

Loading player…

Contract-fillable Liquidity Made Simple with David Sun

ETHGlobalFri, Oct 9, 2020, 12:00 AM

Contract-fillable Liquidity Made Simple with David Sun from 0x

Transcript

everybody I'm David's son I'm his engineer as directs I've been working on a lot of varying projects some of the things that we talked about today I've kind of I've worked on it for a good chunk so it just like kind of like my little baby so you guys tear it apart it's gonna burn but I'm open to feedback so today we're going to talk about contract fillable liquidity specifically in the context of 0x so this kind of start it's one engage the crowd is how familiar are everybody here with like defy and in that space I guess if you are very familiar just like it's strongly raise your hand if you're not just just half way alright cool so yeah so just to kind of give a glimpse of what contract fillable liquidity kind of means I'm not gonna go to a very technical definition more so highlight what that implies to you guys as smart contract developers really you could start thinking oh I didn't come out I'm sorry okay we ought to like this somehow I just the graphics didn't come through but you guys think of defy as like a ton of money Legos right just like standard Legos you can build them around and build really really awesome stuff right a singular Lego component really doesn't do much right but 10 Lego parts now you got yourself something really cool right so this kind of defy dual toolbox has really been starting to build up over the last year or two right so 0x you could think of it as just another money langa Lego we just describe ourselves as contract fillable liquidity but that's kind of our way of saying this is our Lego part that's the name of our legal part which is enabling exchange for all of your oliver smart contracts so yeah this is kind of a new kind of like this is not a necessary position which is a way of how we like to describe ourselves we're a community you own the quiddity API meaning that will allow you to do all the exchange you do and and it's it's meant to be owned by the users through 0x and then this kind of really creates this kind of context that like we really do want you get want you guys to treat 0x kind of like this like the one-stop-shop money let go for all the exchange needs you want so if you guys are very familiar with our protocol we have v3 coming out with v3 we got some really awesome stuff coming through it we got our mesh peer-to-peer network we're gonna start powering a hue a global peer-to-peer network of global liquidity we're gonna start integrating khyber and uni swap into our liquidity pools as well so you can get the best price from everywhere all right so we're really trying to like extrapolate all of this kind of complex nuanced you would have with getting the best price getting the right assets we're gonna all wrapped it up into 0x so all you have to think about is let's get let's get 0x working as a Lego part instead of getting ten Lego parts which should be doing all the same thing to work together right so you can see we want to give you the best legal part metaphorically cool so yeah I kind of already highlighted this but we do want the main goal with the community own API language here is to really move remove as much of the headache as we possibly can right and 0x has been and we spent a large chunk of our year really working hard to give you guys the best price right we are in exchange protocol and one of our definitive product features that give your users the best market prize you could get for a lot of these assets right so here's kind of like you could see this diagram or this I guess just all the data here on 0 X org slash assets whopper if I remembered but here you can see that we actually have some always competitive price for $10,000 buys for if died markets and this is due to the work of a number of market makers on our platform so yeah just kind of before I go into how actually we could power CFL or a lot of you guys familiar with khyber or uni swap just again hands cool cool so yeah we kind of built out a number like our protocol is actually quite synonymous with how those two work so I'm just kind of like give you guys on what it's like if you guys know uni swap you could actually translate that knowledge grab it easily over to to 0x ID right so for a uni swap if you were to perform a market by which just means like hey I want to buy like 10 die right I'm gonna I'm going to pay this X this ambiguous amount of ether right so we're gonna try to get you the best price for that 10 died right that's a market buy in our context but you could think of it for a uni swab which is the second line that's just a token token swap output right that same kind of functionality you would expect from that function on Union swap just done through Xerox and in the context of sky-bird they don't actually have and market by functionality instead they just have a market sell functionality but you can think of it the same kite case I want to sell ten ether give me the most amount of dye right that's a market sell at the same kind of equivalent in uni swap is token token swap input and for Khyber that would be swap token to token right and they have their different kind of parameter configuration they use a different kind of design but that's kind of you guys have already used there was kind of protocol this is the kind of same exact fundamental thing that's happening behind the scenes right but we would actually start to we would actually do for you actually is look out for Kyra prices uni swap prices prices on the 0x mesh network and then aggregate those all in the future so you get the best price so instead of saying choosing between these three you only have to do 0x and you have peace of mind to say that 0x is working on your behalf and going out and finding all the best prices available so yeah direct CFL in a nutshell this kind of a very high-level overview I'm kind gonna go over some of the technical stuff but just I'm definitely gonna be a lot more brief about it so you guys just feel free to talk to me in person if you really want to learn the nuance about it and we have a number of great resources to help out with that but 0x CFL in a nutshell if you guys are very familiar with the zero protocol unlike uni swap or khyber where everything is on chain we use a kind of like a promise called a order that that that is I guess distributed off chain and the main reason we do that is for speed people this means that you know the price in a market can adjust to at the pace of the internet instead of waiting for consensus on the blockchain so that's why I think we've been able to enable such great prices for the diamond market for us Dec to die market right so with that though I think compared to uni swap they're just as we do have to add this extra kind of parameter you would have the passed on chain right because all of our liquidity lives in off chain orders right so in the context of you know traditional like CFL integrations you would make with uni swap you only really had smart contract parameters right it's happened to Xerox liquidity you would also want to pass an additional parameter that literally is just a bundle of Xerox orders which is our representation of liquidity and and that's kind of like the main fundamental difference and you would wonder is like how in the heck would I generate 0 X orders where do I get these how do we how do I get these in and I guess the main question is where right so with that this kind of comes in we built the package called assets whopper ask the swapper you could really think of it as this kind of this massive convenient package that says give me a place to look for orders and I will give you all the orders you want a bundle I'll bundle it up for you in the way you want and all you have to do is just pass it on will do all the hard work for you on your front end right so this is kind of a diagram of kind of the three steps we have highlighted on our marketing website sources orders right and the future is going to be coming through mesh it's gonna come through any other end points you want to pass into it and then we take these orders and transform them in a way that you would like to consume it with right so yeah this kind of gives you a good deeper dive what's actually happening at this whopper to be clear is an off chain library it makes interacting with the smart contracts of the Xerox protocol on chain incredibly incredibly incredibly easy right so you could imagine you still have your web 3 code that you're using to interact with your own smart contracts you would just now have an additional package called assets whopper and with assets whopper you could pass in like a radar relay endpoint and then all of a sudden now you could tap into radars liquidity which has a number of market makers creating some really awesome prices there right so you take as the swapper with your web 3 code and now you can effectively pass in both 0 x orders and your own parameters on chain right so this is an assets whopper I think we can give you a number of different output but the most easiest one to work with is called data well literally just give you here's and call data here's even the address to call it you could and then just pass it on chain right and then you could just do a one-liner call but if you actually want to know what's inside there's also we have devi utils there's a number of ways to interact with this your X protocol swapper makes it as easy as possible or also as customizable as possible if you guys really want to get like build something that's right plugs very gas efficient swapping could also help there too so yeah I'm just going to go over it he's kind of the main kind of like golden path of using swapper swapper comes in with a number of tools mainly there's two large components of swapper called one called a swap quoter and one called a swap coke consumer right so these you could think of it as two parts I've got factory right so swap quarter quotes you it gives you a quote right so you give it a endpoint from radar relay or from mesh and then it's gonna go out there find you the liquidity package it all up for you in a way you can render it out maybe to you ion react or just or like monitor your prices right and then the consumer will take that quote in and then convert it into a form your smart contracts with wanted use right you can imagine it's not quote so what quoted comes like here's a quote right this is actually what you want and if you will actually want to make an execution then you use consumer right so that's kind of two-part relationship of assets whopper so yeah here's just kind of the quote the code related to consumer you would instantiate it and then you could literally just pass in a quote and then we'll just give you call data right and with that cold a you could just call in your smart contracts which a little bit hard to read here but the salt all this code is on and github link you just call it with one line all the other code here is just kind of doing some double checks like check-ins like it does actually happen should we revert revert if the order failed or whatever but really there's only one line of code you really should be concerned with which is how we're call zero to call this one contracts and that is already given to you through swapper so right so you only had to pass it in as an additional parameter and your smart contracts right so in the case of like what's a simple example let's just say you want to create like a basket token like set right you could set has an additional parameter called order information and it's an arbitrary bytes call data parameter so that's their way of saying like I could take an arbitrary liquidity information and in their in the context of 0 X they take a ton of bytes that's as orders right and then date then they decode it and then they fill it out they fill it with a 0x protocol right so you could kind of imagine what's happening here is does that one extra parameter you want to expose and swapper will make it as easy as possible to get you that parameter just just send up so yeah kind of to go back and do almost my pitch sales mode I think so so I guess many people to be addressed which is like this definitely has a little bit more complexity compared to Union swap or Khyber and I think one of the biggest compelling reasons you would ever tap and do building this into your protocol is that one is the future of 0x is gonna be very very very very cool in the context that we're gonna aggravate all your liquidity right and then we have a number of awesome extension contracts that's going to allow people to tap into other novel assets like GRC 720 ones 11:55 s if augers can start supporting 777s we can propose a Z IP and you could tap in all these different liquidity right yeah you mean so what do you mean by representing yourself on multiple Dex's yeah yeah yeah yeah that's actually great the point you brought up so currently and v2 protocol that would probably be a very jank thing to pull off but in the v3 protocol we have something called bridge contracts and with these bridge contracts you could theoretically tap into liquidity that is metaphorically locked up in another contract or another liquidity protocol right so I think there's been a lot of ideas playing around that like you know you have to lock up your money and dy/dx to margin trade we could find a way to use a bridge contract to allow you to effectively use that same token that you're using to put up as margin and dy/dx but also use it for the direct liquidity right so we can actually the same exact token but using two places almost and it's all power to bridge contracts which is all in v3 which is coming in a few weeks so yes it's possible I think that's really where the cool stuff comes in so yeah I kind of already alluded to this but you could support a number of different assets 720 oh there's a two seas there 27:21 1155 we also have this thing called a multi asset proxy allowing to bundle assets almost like in the context of like a hearthstone like like the booster pack of cards we could do all of that which most of the other protocols can't do we also have these bridge contracts which I kind of alluded to is you could tap in your liquidity that is previously like untap Abul in the context set it could be a collateral locked up in your dy/dx margin account and compound or whatever we could create token abstractions around stable coins a lot of these cool stuff are all powered they're just kind of think we just generally labeled it as a bridge contract and that's also how we give you like khyber aggregation you need swap aggregation all of that so that's all coming in v3 but if you upgrade but like for the most part interface is not gonna change with the three so if you you know integrate it with v2 right now you get all these features with it in the future and a future upgrades we made it a very very big part of our upgrade pipeline is not to like screw up the interface for you guys so just one integration and get all the power of zero X as we grow cool so what can you build this is kind of just like this is actually I would say like not even touching like the actual I guess cool parts of what you'll be able to swap her with CFL but you go build stable coin converters just from like different of all volatile base volatility stable coins from die just us DC whatever you do stuff like that you could build defy banks this is what kind of instant at Sawle ready been building and using our liquidity to maybe make us to move us DC to die and I'm putting that CDP there's smart contract wallet stuff you could do let's just say like argent right and also I guess with a new multi collateral die I think it'll be really cool if I could say I sent ether and immediately diversifies my ether into the eight other collateral assets and then and it makes a make your vault for me and I pull out die right you could Auto diversify my collateral that could be stuff we could power with the 0x liquidity right and then also many of these other defy protocols except dy/dx maker they all have these different liquidation systems where you could write it I get it but that liquidates I guess margin or whatever and then you can immediately sell that with 0x liquidity for a profit right I'll it's almost in the arbitrage so that could all be powered through swapper as well cool so resources we have our marketing pages are out QR codes may just take a picture so you have these all with you we have assets whopper docks I think one of the better resources are actually out getting started project code it's the golden path of how to use swapper with your code base it currently uses the cove on network on radar relay but I'll feel free to ask me if you want to give it custom orders or you want to use it with main net we also have some code that actually I that is used in production by other protocols so you could kind of check that out it's like set protocol stuff dy/dx stuff you just actually see it happening in the wild like millions of dollars pipe through yeah so also other resources we have a discord we're all very active on it feel free to ping us with any questions there and if your project really starts to take off the ground we're always happy to help we have an EAP program that helps kind of really bootstrap projects using 0x we also give a ton of infrastructure credits like AWS stuff digital ocean alchemy is kind of like an in fira we also have rivet we have a number of ways to help you guys both you know one-to-one and also giving you guys some support on getting your stuff to the next level cool is there any questions for me yes yes yes yeah we've been working very hard on it since the summer we have coined a term internally for a very long time we have definitely made in very active effort to make it as awesome as possible in v3 because we have this opportunity to actually start upgrading 0x protocol so hey we have learned a lot from CFL how do we make v3 better also to cater towards CFL stuff but yes it has what always worked for super v2 for v1 like dy/dx has been doing it for a very long time yes yes yeah yeah so so so you're here if you're asking the context of light for uni swapping really the CFL relationship here is that smart contracts is almost the demand side right they're just consuming that liquidity right so for unis WAP look every trade going through unis off the guys providing the liquidity pool makes a little bit of a profit right so for us it's all on-off chain order books so theoretically the relayer of the charge of feed they'll cut to take a cut right market makers are running a hopefully a profitable business v3 also will give a rebate to market makers as well so yes there's a lot of work that there's a lot of a lot of apparatus that makes it like functional for the guys is actually providing like the liquidity and we'd make it hard we make it a very big effort on our side to make swap or kind of hide at all for you is there X height at all for you so you don't have to care about that all you care about the best price that we could get into you yep cool I'll go here and here yeah that's a great question so one is it's a representation of governance in the context it's a it's our big way of saying it's it's our kind of way of saying this is a community owned API in that all future upgrades as we start to move ourselves more and more into a Dao it's our way of kind of saying that you get an own a share of this and number two is with v3 upgrade is this it's also our staking token in that if you're our market maker you get a stake your token six zero X into a pool and you get a share of the protocol fee and get rebates for giving a profitable service to this or are not profitable a good service a public good service effectively to the protocol into everybody right so it's a our what kind of like it's kind of doing two parts now it's a staking system and also we do it for governance mostly so if we don't answer your question yeah yeah yeah that's actually a great question on the protocol level as of I my understanding is it's on the protocol level we don't do a lot of that work but swapper does in the context that we would Pat up your orders just enough that like we would give you a slippage protection right so swapper handles a lot of that work because our protocol is agnostic to a lot of that stuff right it's because we built it in a more generalized way so swapper handles a lot of work and from my understanding of people using it it has not been a very big issue and we have been thinking about upgrading the swapper slippage interface to be more intuitive but I'm not too concerned about it but I'm not happy to help out if that's is a concern yeah cool yep so ad hoc order books so you're pretty much saying is how do I boost a build up an order book just for my own token right so there's a number ways we do this the more productionize version is we have an open source sra we layered that you could just boot up and that could you just boot it up for your own token it's actually rather easy it's like literally three four like commands on docker you just get it going ask to swap it allows you to take custom orders orders that you have created right so instead of saying I'm gonna go to an order book like like radar I'm just gonna feed in my own my own orders that I've I've signed on my own beat on my own or or I've found in my own ways right so we do give you a custom route to say here's my own custom liquidity now so opera go take it and do stuff with it or you can launch your own real later which is really easy with launch kit hopefully the answers your question ah no no there is none because everything's off Shane I think that's also the beauty it's your ex as well is that we don't have to interact with on Shane stuff you could start getting liquidity going yeah missing me other questions Oh think that's about as much time we have cool so if you guys still have questions I'm gonna be here at all this weekend feel free to ask we'll get you guys going with swapper cool [Applause]

Automatic transcript — names and jargon may be misspelled.