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

Loading player…

Anton Cheng | How to build DeFi with "DeFi lego"

Taipei Ethereum MeetupSat, Oct 9, 2021, 12:00 AM

The talk will discuss some of the choices we made at Opyn when designing a dev-friendly, fair, and composable option protocol. Speaker Introduction Anton Cheng Anton Cheng is a full stack engineer at Opyn, focusing on protocol design, external integration, and some front end. Website: https://www.opyn.co/

Transcript

uh hello everyone my name is anton and i'm from uh i'm currently working at open and today i'm gonna share like this is a very ambitious type of uh topic but i'll come back like uh basically i just wanna share some of our choices that we made at oakland when we were when we were building our v2 of the protocol and hopefully you guys can learn something either from it or like give me some feedback so we can build better v3 or whatever that's coming so a little bit about myself and obviously at open right now and before i open i work at a horrible company called hoopits at taipei so yeah that's all my experience so um anyone here heard of open before okay so we're a option protocol and do people know what option means okay pretty good so we can faster the process so option is actually a very uh not trivial but yeah i think it's a very easy financial contract and it's also very very easy to build on ethereum if you just think of the base cases the definition of option is the right but the obligation to do a certain certain trade at a predefined price which we call strike price before expiry and there are two kinds of options which is call option and put option crops your co-option to give the right to buy something or option give you the right to sell something so those are pretty trivial and the most basic use case is that as an option seller you're pretty much just putting down some collateral and then try to collect this premium because a very interesting property about option is that it's always worth something this is pretty different from other derivative contracts because option is a right and it's not an obligation to do anything so if you hold it hold this option then basically means you can were to do things or only do things when it's like uh beneficial to you so like this it's always like an option always worth something this is i think pretty interesting so as option buyer you can use options to hedge your portfolio or just to like i don't know make up some portfolio you want to make and also it's a very good tool to speculate the price if you think like each price or bitcoin price is like going dramatically or you want to bet on volatility option is a very easy not easy very like trivial instrument to consider so at this point this is if this is all you know about options it's actually pretty trivial for you to build an option pro for launch um because this is like probably one of the easiest contract you can build basically what you have to do is only two functions the first one is as a as a seller if you want to admit this option token and then sell it i don't know i don't care where but to to mint this option you just need to put down collateral and the collateral is actually just the amount of the underlying assets that you're willing to like you're willing to sell right and then after you meet this token this is kind of like the right you can sell this right to anyone else and then say hey before this expiry you can just come to this contract and then i'll sell you my collateral with this price so this is easy and as a buyer if you buy an option token you just decide where i want to exercise before expiry right so if i want to exercise i just would uh i just kind of like sell this or just make this trade i sell the underlying token back to the contract with this o token and then i can get the collateral so it's like just say kind of like a predefined trade or or also kind of like an order that you can't really reverse or cancel before x3 so this is rv1 and also lots of different protocols are trying to build this option like exchanger systems whatever on ethereum this is basically we're basically doing this we were basically doing the same thing which is all the logics are probably the same but the but the biggest problem we see in our v1 this is how we build our v1 and the biggest problem we see is capital inefficiency uh because consider this case like if if it's at 2 000 right now selling a 1 000 put is actually not gonna give you a lot of premium because it's very like let's say it expires in a month so it's very unlikely that it will crash 50 in a month so you can't really well maybe well but i don't know like personally i don't want to pay too much for it right if it's selling at a hundred dollars you won't buy it it's probably like 0.1 as a fair premium so as a seller you're putting down 1000 usd but you're only generating generating zero like 10 cents of income stream so this is extremely capital inefficient so that is something we want to solve because we believe that solving this question can bring more market makers on board and then just bring more liquidities into whatever exchange we're using so keep that in mind that's why we were trying to build a v2 okay so what we really solve in v2 right now like it's just we add one more feature which is called script a spread is basically telling you like okay so it's still fully collateralized but somehow you can reduce your capital by buying another option from one other person right so let's say originally you have to put down 2 000 usdc to maintain 2000 2000 usdc put right now you can buy one thousand put from other people it will only cost you like 10 cents and then you can just put down 1000 usd so this is like creating a separate kind of like separating the market for someone who really wants extremely safe and low risk um his investment strategy kind of like meant this very low risk options and then sell it to other people and some market maker can use this kind of strategy to reduce the amount of capital they have to put down the system and they're also something like you can put you can like the the third one here is like you can buy another you can buy a higher strike price production and then sell another lower strike price one so this is like sacrifice some of your payout because if each price dropped to zero dollars you only get two thousand two hundred because you're like you're both a holder and uh you're at this point you're like both the holder and the seller and you're sacrificing some payouts but you can get you don't have to pay that much premium so this is like a very um traditional way international finance that people use grant to like create what they call credit spread or debit spread to like reduce reduce collateral or just like reduce the premium they have to pay so yeah and we're also working on the second one which is allowing our partial collateralization means just like if we record this scenario just like maybe we can add a liquidation mechanism that somehow tells that the option is not worth that much money so you you can take out like 900 of your usdc so this is something we're working on any questions so far yeah any questions yeah um what's the counterparty behind underwriting these options is it like you know an amm or is it like specific people taking the other side of the chain or something yeah like the counterparty is really just like seller and bothers buyers so if there's buying an option you have to find someone who's willing to write you this contract you know so uh we don't have any amn right now so we're using order book system which is like a very trivial uh order book buyer by buyer and seller like matching kind of like a matching engine so does that answer your question like we don't have it maybe so our v2 protocol is called ghana we want to have a very cool name but we kind of failed at the marketing because people got confused about gamma versus open so we just called it openv2 anyway but if you if you want to if you go to our github you can find all the code under gamma protocol which i think is cooler yeah because that's confusion great and okay so one thing that i can uh mention first is like with our v1 protocol it's called uh it is so-called physical settlement physical setup options which means when you're exercising an option uh you don't need an oracle right because just send this option token and the underlying access back to our contract and we'll just send you collateral assets so that's fair and it's easy and you don't really need any trust so that's great that's working pretty well um but the one problem there is it's harder to implement spread because you can imagine like if i'm exercising one option against a seller but that seller actually don't have all the collateral but that seller have some collateral plus another token that is somehow kind of like a chain exercise uh had to happen on chain at least that's like when we were originally thinking about this problem we thought this is probably going to be problematic and the second and another thing about introducing the oracle is that lots of users were complaining about about our v1 and said like oh we can't get through we can't get the transaction to got confirmed before your x-ray date maybe because the network injection or just like some front-end box because there is one time that very close to the expertise and then like within half an hour like maybe two users visit our website and we should our website just crash and you know like those kind of centralization risk it's also like a risk even it's not on the smart contract level uh there are still so many factors that can prevent people from successfully cleaning their uh clean their proceeds so we like lots of users got angry so we're like okay maybe maybe using the oracle is actually easier because you don't have to handle that much user issues you just have to figure out a way to like report the price fairly and transparently so that's like the two two things we consider to decide to introduce an oracle uh because after we have an oracle we can just say okay this is the price at next free and then we can we can that people actually uh actually exercise after expert you don't have to rush during that busy hour or gas like if the gas is higher you can wait for whatever you want and then you can uh yeah just exercise later so this is one thing and yeah one other thing like i kind of already mentioned is like the exercise constraint it's actually as we were integrating with more projects we realized that it's a actually a hard assumption to make because imagine like everyone anyone else who wrapped our own token into their own product they have to make sure they can exercise before this expiry time so this risk kind of inherit like when we and also like kind of prevent us our token to be used by lots of different projects because they don't want to have this time constraints and somehow like with cash settlement it's easier in a sense because we just have this very complicated formula on chain actually it's not that complicated but we just have this formula on chain and then we say okay x after x3 after we got the price on the oracle this is the amount of money you can take out and you can just like you can just chill and wait for a month and hold your tokens and after like the gas price is like lower you can claim your profit or whatever and this is actually a very uh good feature that feature property that we want to have because we think this will lower the boundary of integrations and innovation so even though that means we will be having an oracle we think like this is the right direction to go [Music] yeah so i actually have a question regarding oracle um so i was in my mind like the general idea or like the edge cases that we're looking for actually is like when the oracle is not updating properly for some time and uh what would happen so what i'm thinking is for example in the case of 3d actually being attacked or when when there is like um you know high enough payout there is actually incentive for an attacker to flood the network right and so that it's kind of filled there and then you know since the oracle or you know anything else like cannot update it properly then he can execute those kind of stuff right and so um of course like it may not happen in the regular case but then when uh some rewards or maybe some options like big enough um maybe that creates some incentives that so i'm wondering how you're using the oracle and whether this is yeah um let me jump to the next it's there's not lots of information here but just here if you want to read it um yeah that's a really good question i mean like right now we are worried about this situation so one thing we do is we we define the expert price to be the first fight that submitted after the actually after the x-ray so well it's kind of unfair in another way but at least we can prevent people from like stopping our oracle to submit any price because in that case we'll just wait until the oracle actually had the price so that is um one of the ways to prevent like you know like people who is like preventing oracle from submitting anything and the other way the other thing is like we're working with chain link and specifically because with their oracle they kind of they kind of have this mechanism to submit a historical press so what they're not doing is like is that we don't need a live price at the moment we only need the exact price at the time stamp when option expires so that that will reduce a lot of risk i guess so let me go back a little bit this is like there are two kind of options which is people call american option and european options and european options basically means you can only settle on expiry date and we could decide to go this route because they only mean european option means that we only have to submit this very precise price at x3 we don't have to care about like if chainline is working like 23 hours a day we just have to care about that particular rs they that they have to submit the prize and also with chain link yeah they have this historical like mechanism they can write historical price back like so if someone attacked the oracle they cannot submit the price for an hour we would just wait for an hour and then until someone submitted the price they will submit the price that's like uh an hour earlier so they will say okay in our earlier this is the price this is the bitcoin price and we will use that price as settlement price this is still a concern because basically means that channeling has a great power controlling our system so we very easily add another dispute system which is super centralized right now because we're like uh using a multisig to actually have the right to override any price that people summit that chain link to summit uh but yeah you know like maybe in the future we have tokens we'll have to centralize government and we can uh extend this this view period to be longer so maybe like have a three day dispute period so people can like come and discuss see if the price is fair and then decide if we want to disappear them or not follow our question and so so when you're saying that you can dispute or changing can go back to h3 and change the price uh i was wondering because previously we also mentioned that the cash uh sorry i forgot the name but it was instantaneous right the chaos and i was wondering if it's instantaneous then it can already take if sorry well so actually no it's not instantaneous there will be a locking or we have to wait until this whole price settlement thing is finalized to actually let people take out the the pristine so yeah i hope that answered a question so maybe we can pause here and take more questions for francine yeah like i have a little um like final comments on the previous section is pretty much just like i think oracle is not necessarily bad and especially in our cases we want to be very precise about the settlement price and actually we're convinced that in our cases having oracle actually can make our system fair because you don't have to care about uh exercising the last minute and then complaining about gas price so um yeah i think this opinion may be very different from lots of lots of other protocols because you know people are afraid of oracles because yeah centralization and risk and all that kind of stuff but our take is that lots of our users complains about not being able to exercise or not being able to like take out their collateral properly instead of like centralized services nobody ever like complains about that so maybe if you're deciding uh designing and for a code that's something um to to to to keep in mind yeah so it's about the yeah but the provider of the person who wrote that option like they they want to get their money so yeah is it like a race them like no so like this is that that question is not uh related to like either american or european it's like cassette or physical setup so basically what we did is like with cash settlement we just at a price uh at a certain times then well okay it's like kind of related but like at x pretty we'll define a price and with that price defined both the writer uh the seller and the buyer will have a well we'll have a amount that they can take out right so as a seller after that price is submitted you can your your your collateral left is kind of decided and you can also come here anytime later and to claim your platform do you think that the order booking was sustainable because right now like aspects are really expensive but on l2 do you think they'll be cheap enough or like what's the efficiency of that versus like being a day in that model that's a that's a really question good question we ask ourselves every day and i mean like we're not we're currently exploring all the l2 solutions and we're moving or trying to move their asap but the problem right now like i mentioned is that we're using an external order book you know so we're kind of depending on xerox right now so we'll be waiting for them to choose a l2 solution so we can move there with them or we have to find some other partners because our protocol actually just handle maintain an option but never handles like selling or anything else and about the aiming question i don't think like that is gonna replace order book because audiobook is a very traditional and more efficient and safer trading venue for lots of sophisticated traders so like big institutions they're probably not going to use it or like amn they're probably going to stick with order book um but it's also very clear that they're like audible is not working on player one so yeah we're kind of both doing the same thing right up doing the both doing both things right now versus like trying to design at a m that's not too obvious for sellers to lose or market makes to lose money and the second one just like moved to l2 with with the order does that answer a question yeah you know do you have any uh like metrics or like number that's that's a question i've had in general i really looked into it is the efficiency of like um the market on a m versus or i guess it's more generalizable the problem we see right now with amm is that we did use unisoft for our v1 options but um we can't really tell if the volume is actually higher because there are lots of arbitrage arbitrage opportunity so you can't really tell that really users using your or buying your options or just like bots like trading like every trunk rving between like centralized exchanges and your protocols so i guess like one of the fundamental question is we don't know anything about option amen because none of us or none of the easily existing teams have ever designed a profitable mm for the market makers so all the emm's right now are losing money so we can't really use that as a matrix to compare to whatever someone's familiar with how syrix works but like how much of the autobook and i said something where there is room to improve so like more kickstarter downloading you mean oh of course in terms of like because you mentioned like the issues of oh i mean like at least the settlement part had to be unchained yeah and also the cancellation had to be unchained if you don't want to trust anyone so that's like already a pretty big not it's better than that's different that's how xerox currently work on their one but that's still too expensive for every switcher so i guess i um wanted to point out that there are some player ones that have full organs [Laughter] [Music] i know [Music]

Automatic transcript — names and jargon may be misspelled.