BitDEX: Building a Decentralized BitMEX Using Priceless Financial Contracts by Hart Lambur (Devcon5)
Devcon·Fri, Oct 9, 2020, 12:00 AM
Speaker
Visit the https://archive.devcon.org/ to gain access to the entire library of Devcon talks with the ease of filtering, playlists, personalized suggestions, decentralized access on IPFS and more. https://archive.devcon.org/archive/watch/5/building-a-decentralized-bitmex-using-an-optimistic-financial-contract-ofc-framework-new-tools-for-fast-and-secure-financial-contracts-on-ethereum We introduce the Optimistic Financial Contract (OFC) framework, a novel approach to financial contract design that allows for hyper fast, secure, and scalable DeFi contracts *without* requiring an on-chain price feed. This framework makes it easy for developers to build otherwise complex synthetic financial derivatives on Ethereum. We show how this design can be used to build a decentralized derivatives exchange (aka BitMEX) that can be as performant as the centralized alternatives. How it works: optimistic contracts work by assuming contract participants will act optimistically to avoid penalties. This formalization borrows heavily from Plasma and state channel research. “Long” contract participants enforce that “shorts” remargin contracts on a timely basis (and vice versa). Surprisingly, no on-chain price feed is required—an oracle is *only* needed to resolve disputes in what is conceptually similar to Plasma’s exit games. This simple framework works at both the L1 and L2 levels and can be extended to create almost any type of financial contract developers can imagine. Speaker(s): Hart Lambur, Allison Lu Skill level: intermediate Track: Developer Infrastructure Keywords: technical Follow us: https://twitter.com/efdevcon, https://twitter.com/ethereum Learn more about devcon: https://www.devcon.org/ Learn more about ethereum: https://ethereum.org/ Devcon is the Ethereum conference for developers, researchers, thinkers, and makers. Devcon 5 was held in Osaka, Japan on Oct 8 - 11, 2019. Devcon is organized and presented by the Ethereum Foundation, with the support of our sponsors. To find out more, please visit https://ethereum.foundation/
Transcript
[Applause] you yes my name is carl ember your project called universal market access or every month and i'm quite pleased to present you guys this recently paper we just put out it's fresh to draft along a bit decks and this is our design or decentralized effects easy what we're calling priceless financial contracts so goals of this talk just to give you an overview when you guys about it decks works I wanna explain this concept of priceless financial contracts and then go to some details will be impacting enable so as a starting point was to talk about what the next is and I'm not really picking on Big Mac cos I've got any centralized futures exchange anything that has levered transactions and so we've acts like the CME trading futures ur or any CFD provider is a lever derivative trading platform institution exchange and the exchange itself provides a bunch of functions that make it usable to the people that trade on those functions are require a trusted third party operator and so those are things like custody margin for all the positions moving margin backing for clearing and ensuring the solvency of all the positions in the exchange what's really important notice reminded of is that when like Bob and Alice trade on baymax Bob and Alice might actually end up having offsetting positions but they don't face each other everyone faces the exchange the exchange functions is what's called like a central clearing counterparty and they're the ones that ensure the solvency of all the positions so the next doesn't do things all these exchanges that's time of Hornets training we like that with high leverage just as things that people want I think max is going on a big business you need you to change big distances these are services people want but they've are completely custodial and the exchange sets the rules of game so the exchange decides what leverage you get how you trade on it up but importantly they also decide when positions get liquidated you know like they have that power and so this is like really centralized it's not just like a centralized point base or whatever area whether it's just Estonia there's also this whole aspect of centralization around trusting Big Macs or whatever exchange to monitor your position solvency correctly and to not let the date you have a long time so this is bad it's a number one so the question is certainly why is decentralizing picnics so hard what makes it so difficult why can't we just like run this on the blockchain and the things that there's just so many damn transactions you have to check so the idea is that bid next functions as this somewhat of a black box that has all the position and margin data for everybody of all the trades of the system and they go through and they check the solvency of all trades with each price tick so every price update they're checking the the solvency of every position in the system and that's just a lot of transactions you can't run that chain and the data is available to do so if you get have it so what are we gonna do so we're gonna try to solve this with block chains but more importantly with some later to thinking's and later to concepts that we're gonna look to a financial contract design so okay good idea our observation on a futures exchange like index position data does not change that often the data can actually it's changes be frequent enough that it can be recorded on chain allowing anyone to monitor positions to verify their solvency and it's missus pretty interesting right we can actually put the position data on chain when you design a system where anyone can monitor the solvency of that data off chain allowing us to have a design with no centralized proceed and no centralized arbiter proper authorization so index does this by allowing any Janata Party to dispute any opposite position so any long dispute any short and in short in dispute any long and Oracle is only used to resolve these disputes when they happen so this is very much like an Oracle minimize design we only use an Oracle when a dispute happens and I'll go into more detail on that in a second penalties are then paid to the disputer by the disputed position if the dispute is deemed valid by water so there's common consensus here to correctly dispute one of course but wait efficient rates okay so a core idea here we are going to ask people off chain to monitor the exchange to see this properly collateralized that's like the big idea and there is no on chain high-speed important one all right so let's just talk about what's happening on chain I'll change details here and why this can be fast so um the decks only puts a data on chain that needs to be on chain put some pretty democratic or exchange functions so margin deposits and withdrawals those happen very rarely people contributing the margin or withdrawing margin from their account like on Big Macs that happens very frequently that can easily be supported with on chain transactions recording nutrients how many new traits actually happen a second it's a perfect that's exactly what happens like that next to it but it's like low single digits or you believe that it's a pop to some border on the three right now wait you could get pretty close so we can also record that data on chain the interesting part and where the scales is all the measuring created solvency so checking all the positions good next has like ten tens of thousands of transactions per second to check all the positions of their system and every price tick but we are pushing that off gene because now we've recorded that trade and position data off chain so anyone off change and check the solvency position that's where I stay ability going from one point of women clear is that these X does not solve like a decentralized order book problems that's not what we're starting at salt belongs and shorts in this treating systems still need a mechanism to find each other that would be in a workbook we are building on there's great Senate trusted designs what peer-to-peer work what designs that 0x mesh that are pretty interesting approaches to solving at all okay so let's let's go into an example just to try to illustrate what's happening with this this design so remember on the tree the deposit the trim position data is recorded on chain and anyone can check the positions so would start see we're going to leave all of our lungs l1 through Ln over here and our shorts s1 through SN the important point l1 does not face s1 and s2 does not face l2 they all based on contract an exchange so they're not directly offsetting but we're gonna record we're gonna also define a market here we're going to create the price of Bitcoin and let's just say there's a starting price of Bitcoin at $10,000 per coin and so our EB function for what Long's and shorts get paid out is going to eat current price minus 10,000 so our initial price of 10,000 wants and shorts both made zero dollars all flat and we have a margin requirement here of 10% of the current price which means we got two tanks leveraged for $1,000 you get $10,000 exposure jump into some details okay so we're throwing B report this data on chain everybody agrees that the price of Bitcoin is $10,000 they've checked the energy gain margin and everybody looks good they'll check out everybody thinks everyone is correctly march into the system insolvent so let's now say that LT thinks the price of Bitcoin might drop to 9500 and if that were to happen l2 knows that they will be under collateralized that will lose my dollars because they're long the lose of their dollars and they'll no longer meet their margin requirement of ten personal price so what else he does deposit additional margin they're doing this to make sure they don't get disputed and liquidated in their cool easy this is exactly how we're going to get next to where if you didn't if you're ready to get your partner department you don't deposit more margin you'll get to put it let's go through another example where l 2 does not deposit additional margin but s1 does indeed think the break price of Bitcoin has brought to 9500 note that I said it's this is expose with me there is no one chain crispy for them to point to basically it's like a bring their own price neat concept s1 is looking at the world and says hey I think the press bitcoins 95 underneath they're then going on to our auction data and they see that out of price of 9500 l2 would actually be under clad lies according to our MPBN margin functions and so what one does is they go ahead and dispute l2 they say hey I think you're under clutter lives your default and at that point that dispute goes to Oracle that's going to resolve this this disagreement was this issue and s1 is right LT will be a penalty to s1 this Depot penalty if s1 was wrong according to the Oracle the penalty will go the other way to compensate l2 for being unfairly disputed ok core design core idea so these are the core function signatures in are just initial simple design I'll actually just jump ahead to the slide even second that agreed is pretty bright so you can't read that but basically says we got have-nots situation so imagine you're now a position in this big deck system at any given time you can do one of four things you can do nothing if you think you're correctly correctly collateralized and you want to sit there and you're happy you can deposit additional margin in your position which you would do if you think that trade is going to move against you and your you might get liquid or you can with you can withdraw we've requested withdrawal at margin so the trade has moved a lot in your finger and you're up a lot of money you did make a request to withdraw that money note that you cannot immediately withdraw the money because we need to have a time lock to allow other participants to verify edit that request it's valid that you're not trying to take up too much money out of your position or you can dispute someone else's position and say that under paralyzed so in order to be here is that in the optimistic path in the happy path they're just depositing or withdrawing margin and making sure your position stays perfectly finalized there is no need for an Oracle and Oracle price while you're staying at happy path the only time we would even or a boulder an Oracle price is when there's a dispute when somebody says hey this position is under cloud wise so just to go back to that last slide for a second these are like the core core functions of this simplistic design the markets happen anytime withdraws can happen anytime again I'm walked by this delay this lightness requirement and once that passes that anybody can withdraw that mark then the other drop request goes through disputes remember any long can dispute any short and vice versa what's interesting about this is that because we have many Watchers of the system we've got many Long's and many shorts and they're all watching with each other we can actually have a pretty short liveness requirement our time law on disputes can be pretty short because we can be pretty confident that somebody's going to be there to watch the system the last two things here are really about entering and exiting trades in the position so we have a simple design where anytime you want to enter a new position you can create a pair so any long and short find each other say hey we want to do a trade this price and negotiate that off chain and they come to the system they're like hey here's our new pair of Long's and shorts we want to enter the system the bids X contract just has to check that that new pair of long shorts these correctly margined and you can do that at the club track this is a little bit contagious he'll but we do with a clever trick of having that new pair points to an existing long and short position that it is equally collateralized two or more plasma this is detailed in white paper but really it's a shortcut for us to have an instant entry through the system and then we have a simple mechanism where you can instantaneously exit a trade in the position to draw your margin if you're a long you do that by an offset in short position and then you're immediately able to withdraw they combined long and short deposits so those are detailing bit more detail the white paper just a quick overview so again that's in slide this kind of looks ugly or - that's the idea this is meant to be a bit of a like a layer to your financial contract design where we are assuming that things stay in the happy path and you're only using our Oracle when there is an unhappy dispute when sort of something goes wrong so we're calling this the priceless financial contract design and the quality here is that if everyone behaves as they're supposed to if everyone doesn't default in adds margin appropriately that we don't actually need an Unchained price it's bracelets this is the habitat we stay in the happy path we need no prices on chain other coral kind of concepts of this is this framework that were proposing is that when someone behaves badly it needs to be observable off chain we need rewards to the correctly reward participants for disputing bad behavior and that dispute is proven valid we need that behavior to be punished to be penalized and we only need on chain prices to resolve disputes which means that the Oracle functions as a sort of dispute resolution mechanism which should be relatively infrequently used so these are the sort of priceless Mitchell contra design this is something new that we're gonna write more about we would really love feedback on this idea but again it's all about how we can minimize Oracle usage to allow us to do higher leverage higher speed things with defy and with venture contracts so going touch deeper on what this means for Oracle design itself so reading contracts priceless late I'm repeating the point my last slide ready to put contracts baselessly means Oracle's become dispute resolution mechanisms that only need to be used with counterparties fail to agree that we didn't find interesting and novel and the example here is to point to like the fiat world where me and would enter into a legal contract financial contracts a lot more like legal contracts we're going to turn the legal contract let me do that privately we've no intention of litigating that contract we only litigate it if something goes wrong we fail to maintain the terms of trade the same concepts being applied here where we're saying hey let's enter into a financial contract that we both know the terms and we're going to do what we've gotta do but we're only pointed to see you only to use an Oracle it's something this long three Oracle's as dispute resolution mechanisms arguably buildings of the design space for decentralized Oracle's since we can do things a little bit differently we no longer need like an auction price team that's constantly pushing of a lag or real time price to the chain we can instead the Oracle speech relatively slowly expensive and potentially late far more decentralized because they should be relatively rarely used again like you for technology you don't go to court for every contract you write you only go to work when there's a major dispute and it also lets our Oracle's be cigarettes we don't need the dispute resolution process to be happening at the same time as the rest of the contract system so we must built a design for this type of Oracle that we call our data verification mechanism that actually puts economic guarantees early on profitability that design you gotta weigh paper and it's actually been built it's on test net it's well suited to support this type of priceless financial contract so just to wrap up really quickly we introduced this idea bit index which is decentralizing bit max something that has but it really hard to do it define and we did this using this concept of presence financial contracts where we are pushing all of the work off chain so we are getting greater scalability by having positions there solving CV monitor off chain and force via this piece we're doing this with out and Auntie priced feed people bring your own press PETA off chain and we're minimizing Oracle usage so we're reframing the use of an Oracle as purely a dispute resolution function this lets us build what we're calling the ask to eat by products like a Dex an exchange with leverage it also lets us build synthetic tokens were we're big on synthetic token suggest can go to our website we don't like that we can do this with Lola flower apartments because we can be much more efficient with our margin usage by not having a leg to press feed or any kind of delay and what kind of swaps options all sorts other angel contracts and this is sort of stuff that frankly we love talking to all you about you want to build and how can go a building okay so wrapping up we've got a lot research out there that would love feedback on this video text paper we just published last week it's it's a research paper it's a draft we love feedback on this design we also have our designed for our Oracle our dispute resolution style horrible that we published a couple months ago that we was left feedback on and the response of us here at Def Con please join our developer slack let's go get up links to where you find various things and find us thanks very much [Applause] you
Automatic transcript — names and jargon may be misspelled.