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

Loading player…

UMA 🛠 Getting started with UMA's Optimistic Oracle

ETHGlobalSun, Oct 9, 2022, 12:00 AM

Join Chandler de Koch of UMA for a workshop titled "Getting started with UMA's Optimistic Oracle." Optimistic Oracle allows any developer the opportunity to bring any form of verifiable data on-chain. With a simple escalation game and an Optimistic liveness period, contracts can have economically guaranteed data brought on-chain. This workshop will walk through how to get started with the Optimistic Oracle. This workshop is part of ETHAmsterdam, the first in-person hackathon for ETHGlobal since ETHLondon in 2019. Join over 800 likeminded engineers, designers, and creators to build and learn over one full weekend at the Beurs Van Berlage in Amsterdam. ETHAmsterdam is taking place as part of Devconnect, the week-long in-person gathering in Amsterdam. We're back to build, we hope you'll join us. ---------------------------------------------------- Follow us: https://twitter.com/ETHGlobal​ Check us out: https://ethglobal.co​m Email us at: hello@ethglobal.com

Transcript

[Music] [Applause] all right how's it sound you good cool all right hello everyone um my name is chandler i'm really excited to be here today talking about how to get started with the optimistic article i am from the uma team um just a quick intro to the idea when putting together this presentation i'm limited by 20 to 30 minutes this was originally meant to be at least half an hour more so a lot of the details in here are going to be very high level very quick overview if you need more details please find me on the floor reach out to me on telegram and discord we at the uma team are really here to support you and make sure that you can integrate with the optimistic oracle in the quickest and most efficient way all right the outcome from what you are going to get from this workshop is a quick overview of what the optimistic article is uh how does the oracle work at a mechanical level and a demo of the oracle request and then also just some insights of what other teams are using the oracle for this will give you a nice introduction on to like some brainstorming ideas and what you can play around with um and then at the end of the session if you are interested in hearing more about uh what we're interested in building like our ideas bank feel free to come and bother me about that so what is an oracle uh oracles are a key part of the blockchain infrastructure um that allows external data to talk with unchained environments that's a really important thing for how this space works and we see kind of two distinctive types of articles emerging one is the one that we all know these are price feeds data gets brought unchained in a way kind of periodically and deterministically and that process is really easy to work with [Music] this has basically been the way that most oracles work right now and has been the powerhouse of how d5 has grown one of the things that we want to try and create a narrative around is this idea of a optimistic style oracle where the creation of different types of methodologies on bringing data on chain allows for a lot more long tail types of data i'll get into a little bit more about what that is but it basically has the same essence of being able to bring any verifiable state on in the world on chain um it is a lot more flexible and can adapt we'll kind of go through them that process on like how does a request come unchained in a way that everyone can trust um and the other part of it is it adds some sort of recourse uh most of the price fees that we work with today you take the price or you leave it um and if there is any sort of like tampering data breach hack uh manipulation of the price gas gets too expensive and you can't get any requests on chain um most of these contracts that rely on these will execute irrelevant um so what we're looking at wanting to try and talk about a bit more is that these are optimistic style articles by the nature allow people to have some recourse or dispute an outcome that doesn't fit the intention of how the contract or the particular product that you're building was designed to be used so a little bit more technical a little bit more in depth but what does an optimistic article look like i like to describe it as very similar to an optimistic roll-up but just for the data layer instead of the actual consensus layer and this process works by you as a requester wants to request some data and someone will propose that just like in an optimistic rollup you propose a series of transactions you wait a small period of time for people to check that these transactions are valid using some sort of fraud proof and at some point in time you can kind of assume them to be true that process at a very high level works the same with our optimistic article so there are a couple actors there's a requester there's a proposer there's a disputer and in this case we have a requester who'll ask a question this question is normally what a we call a price request or oracle request and we'll say i'm willing to pay someone a certain amount of money a bond to be able to bring that data on chain this bond is what we use to incentivize a proposal to put that price on chain and this proposal really is uh what the proposal believes is the right outcome and the right price for that particular outcome this um proposal is what we would go through a what we call like a liveness period this liveness period is really for a bunch of other decentralized parties in our network to say is this proposal actually valid or not or if it's not um can we dispute it if it's correct no one disputes it it's assumed to be true but there is this dispute process where you as a person can say i don't think that that is true and we will dispute that a little bit more later down the line we'll talk about how the dvm works the dvm is the arbitrator of any disputes how does this process of us actually resolving a a dispute how does that work and what do we what do we do about making sure that um even in a case of a dispute that prices and resolutions of data outcomes can can be verified unchained so part of that process is also just to get you as developers a quick demo on how uh how to get started right how to actually call these functions and so we're going to go through an example and this example uh is going to be a fairly simple one right so so to set the scene um first things first you've got to clone the monorepo at uma project that you can find that on our github do the initial commands you just make sure that you get everything set up um just a small note make sure you're using node version 14.14 and above that's been a common mistake that we've seen so you've cloned the repo you've gone through the quick start guide um this tutorial is also linked to our docs so this is the exact tutorial we'll use i've changed the questions up a bit but you'll get a flavor of what we're trying to do here so i'm going to ask the article a question this question is going to be formed um at a very high level in terms of it the question's going to resolve to a point where you can answer yes or no and if you don't know there's an option for i don't know so what this is what we call res and no identifier i'll get into what an identifier is in a little while but basically we're going to ask this article any kind of question that the way the question is asked we'll make sure that anyone can resolve that in a yes or no fashion so question that we're going to ask is did amsterdam start on the 22nd of april if it didn't you can answer no if it did you answer yes you can also answer i don't know so the first thing that we want to do is let's get a contract to actually interact with this this optimistic article so uh in this demo we're using our long short pair um token contract but you can kind of in your own product space think of this contract as the contract that's going to call the optimistic article so the first things first i am going to uh uh just run a little bit of a script this you when you see the demo you'll see that each of these scripts are laid out in detail but first things first let's just deploy a contract this is going to deploy an lsp contract and this is the contract that's going to call the optimistic oracle for a request you can see it's going to go through a uh it's going to deploy it's going to set up itself at some parameters this part part's not so important um just think of this as some arbitrary contract that is going to basically resolve the outcome of a yes or no question so we've got a contract the next step i want to do is just mint some tokens i most of the time projects use tokens so we're just going to mint a couple tokens so that there is some sort of like value attached to each of these price requests or these resolution requests so what i'm doing here is i'm going to mint one token that is gonna pay out one dollar if uh if i answered right um or yes and payout zero if i answered wrong so basically what's gonna happen is we're gonna decide uh it did is this question um does the does the resolution of this product actually resolve to a point where you can build something out with it and you know transfer value from one token to another uh works really well in prediction markets this is actually something that we use at umr as well which we'll get into a little bit later as well but yeah this is basically a prediction market outcome so i've deployed i've minted now some time goes on we want to resolve this contract we want to figure out did this actually happen so the deploy the mint i am going to request the price that first step is hey oracle can you resolve this price so this script will take you through the request element you can see in the actual script here some of the details around what goes into a request this is the demo request there are important elements to this that i think that are in the documentation but really what you're asking for here is you have called the optimistic article and you are requesting for a price right so if we look at what that means uh in the real world we have a ui where you can see a list of all previous past requests uh you can see i've done some testing here around a couple other ones you can see there's another one here who will win uh seattle mariners versus texas rangers i don't watch american sports i'm not exactly sure what that is but somebody could answer that question and you can see the status of of where that where these contracts are so some of them have been settled some have proposed some prices and there's been a request this request looks particularly interesting because this is the actual request that i just made in the terminal a little while ago and you can see some of the details around this request kind of all right let me just this is some testing some more right hold on let's go one more time click my wallet just let it load up so this is what a request will look like um each request can have a series of data points in them those data points uh it can be the request timestamp uh the identifier that you're using uh as well as some sort of ancillary data and this ancillary data is kind of important because that's how you package the question right each request will be packaged in such a way that if you're using this identifier in that ancillary data you can ask the question so think about it as each time you do a request you can ask a different question each time so it's a generalized way of asking a yes or no type question if the question is badly formed you can also answer i don't know you can also answer yes or no if it is well-formed and i think this one's fairly straightforward to kind of get wrap your head around the idea that a question that results in yes or no just kind of really is a binary outcome so that was the request that i made not not too long ago i want to be able to submit a proposal right i want to answer this question so it's telling me here did eat amsterdam start on the 22nd of april um 0 p1 or outcome 1 is 0 outcome two is one and outcome three zero point five where one corresponds to yes uh two corresponds to no and uh point five is i don't know so let's let's kind of figure out the answer to this one just by a show of hand in the crowd um did did eat amsterdam start on the 22nd of april what would we say we'd say yes right okay so we're going to submit a proposal and i'm going to i'm going to in this case it can be anyone in your network that you can request the price and propose your own price and you can also request that any sort of um third-party decentralized entity can actually request this price um and there are two important parts to note here they're currently set to zero but there is a proposal award and a proposal bond each proposal reward is for the requester they're willing to give some sort of value to you as a as a proposer to say i would like this piece of information i will give x amount of reward to that person for that the proposer bond is the proposer who will say i'm willing to stake i'm required to stake this amount of money to be able to actually resolve this request and you can kind of think of it if the question's as simple as amsterdam everyone kind of knows that low risk market no real need for too many rewards if you have a really high risk market those the game theory around rewards bonds and proposal bonds and disputed bonds becomes quite important so kind of think of that as a parameter when you're designing your market so i'm going to submit a proposal and sign this off and we'll see by the way this is all on covant so um there are some distinctions on how this works on on mainnet um but i have now submitted this proposal and it's gonna load up and you can see that's the transaction right so we spoke about the idea of proposing a a data point and deciding if it's right or wrong what you can see here is that the status of this actual request has gone from proposed uh sorry from requested to proposed anyone here and on the audience can look at that and say okay i have a certain period of time to disagree with that if i disagree with that i think we'd only disagree with it so we're not going to go through that dispute process but if i did i can go ahead and dispute this we can do this automatically through some bot infrastructure or in kind of these more nuanced type markets like this you can you can do it manually and you can see the custom liveness period that i set for this particular transaction is two minutes so i've basically got two minutes to talk till this market resolves and if i can convince you all not to log on to this contract and dispute me this basically will resolve by itself if there is a dispute in that time period we will actually escalate that to the data verification machine that data verification machine is a token weighted voting system that is a a kind of implementation of italics shelling point theory where the uh the kind of source of truth people will aggregate to actually voting towards that and so the dispute and resolve um uh kind of process happens uh with the with the token weighted voting system and that process is a little bit slower so this liveness period really is just the uh the slowest way that these markets can sorry the quickest way that these markets can resolve and if in the event of a dispute it's a hold on let's go and make sure that this outcome is is is correct and the dvm uh arbitrates that dispute the important parts here to actually remember is that the proposal bond in that disputed bond comes into play in the event of a dispute if i propose something i get my bond back if no one disputes me meaning i as the proposer did something correct and no one could no one was willing to dispute me on that if i am disputed that disputer has to put an equal bond for that dispute and whoever wins the resolution if the proposal was correct they when both the proposer uh bond back the reward and the disputer reward um the disputed bond and the vice versa if the other happened so it really is a game of of staking your um putting your money your your mouth is to say i i believe that this is correct or i believe that this person's done it incorrectly so we've got 10 seconds left and that's basically what the liveness period will run out and you'll see this transaction will go from uh proposed to resolved and settled um so i'm sure i'll have to reload the page it's settled right and so the outcome of these tokens is that anyone who vote anyone who held a yes token uh that person now is uh one dollar richer um because the outcome resolved yes now if you're thinking about how your development project would work is in every so we we define this yes or no element as just simply a a question right what's actually kind of important um to realize in this process is that that yes or no question was just a way to formulate a question to the oracle there are many other ways to do that we also answer that question you can do that there's a script to do that you can do it on our ui you can do it directly on covan directly on etherscan and then once we proposed that we waited for some time we then accepted the information is correct because no one wanted to dispute that and that's kind of the resolution process on on on how uma's oracle's optimistic article works and that's really important for you to realize when you're asking a question it's ask a question somebody gives you an answer you let some period of time pass before you accept it as true so that liveness period when deciding on how to handle what comes about after you make a an oracle request is kind of important to take into consideration when when you're designing your products so what do you need to know about asking questions for the article and i think the one that kind of comes to mind for me personally is how do we define what the question should be how how we're going to arrive at some sort of truth and in our example we use the yes no question where we laid out a methodology which we call an umip or a pneuma improvement proposal where this defines the source of truth and the source of truth is for us to say we're going to follow this methodology to and you can use this identifier if you follow that methodology in the yes no question we simply said ask a question in the form of yes or no it'll resolve to yes if um if the outcome is yes and no if the outcome is no and if you formulate a poor question when the answer is unresolvable we'll get to an unresolvable state that's the methodology at a very high level i'll show you an example of what that looks like in a second but you as a developer can actually define what that is you can maybe ask some other types of question is what's what's the sunny what what days of the year are sunny and then you use yahoo historical weather you can use um unchained data if you'd like say what's the tvl of a certain project and we're going to use defile armor as that source of truth what is some other type of metric that is is arbitrary for for kind of a price feed to to want to like create and push on chain you want to just be able to say all right we're just going to look at this series of actions on chain and we'll kind of just use that as a as a resolution process and i'll go through what like other teams are doing in there in a in a bit but the the ump um or in this case is the methodology of arriving at the outcome it's it's the document that people will use to arrive to that shelling point um for your use cases if you're if you're building on on test net don't worry too much about actually creating this umip it's really just for mainnet we'll simulate a lot of um the answers and how to go about actually resolving your own price proposals um when when you're working on test net that liveness period is quite customizable so i set it for three minutes for the sake of this demo we usually set it for two hours you can set it for a couple days uh that i think is just something important for you as um as hackers to realize that just just play around with that liveness type period and you can kind of work with that a little bit more and the other one is that this is decentralized resolution the requester the proposer and the disputer all don't have to be the same person specifically with the proposer and the requester and that decentralized resolution has a game that incentivizes everyone to arrive at the right price if you're looking at a price proposal and you look and it seems wrong to you it's basically free money for anyone that wants to dispute and you know as a proposal that if you put something down wrong somebody's looking at your your proposal ready to dispute you so things that are currently been built uh on this sort of kind of oracle system is uh we have something a lot of the prediction markets were from poly market actually all of them are being resolved with umar at the moment d5 insurance platforms where uh the outcome based on the the unchain insurance contract needs some sort of check to see did this outcome happen sometimes can be off-chain data or off-chain events that trigger an insurance breach and you can use our oracle to work with that optimistic governance is quite interesting optimistic governance is simply community votes on an outcome you need someone to basically implement that and so you can write you can write these governance processes to be a lot more efficient than the traditional snapshot somebody has to execute it you can create uh decentralized ways of doing that using optimistic governance we've recently just put in a um a module called the zodiac module that kind of does this and it's a first use case that we're looking forward to developers building on at a later time rewards as a service basically action reaction in most uh most of the time rewards that you get is you do something for a protocol they reward you in some way right you do an action they give you a reward how can you create systems where that action is is triggers some sort of um event um whether it doesn't have to be on chain it can be off chain uh kpi options is an example of that it's probably boomer's most famously used product at the moment um it's a it's a really a tokenized incentive mechanism for communities um and then you can also build synthetic asset markets right synthetic acids are just derivatives derivatives don't need to be priced every five minutes uh you really just need a price of synthetic acid at the time of expiry and so it really works well for these sorts of use cases some of the teams i mentioned poly market the insurance protocol that you're that we're working with right now sherlock the other one that i haven't quite mentioned a lot is a cross across as an l2 to l1 relay and the question that it's asking is is the relay valid did this action on l2 happen if yes let me do something on l1 what is that thing that happens on l1 that thing that happens on l1 is i as the user get my funds immediately and so you don't have to wait the seven day um the seven day roll-up time for the optimistic roll-up uh to to resolve and what you we're what we're saying here with across is i'll front someone the money take on the seven day risk if um if they don't and give the the user their funds now and i'll charge a small fee for that and that risk is allows people to relay out of l2 really quickly while some liquidity providers take that seven day risk it's really efficient protocol i'd highly recommend if you're using l2s give that a try synthetic tokens um uh fox what was the price of a fox token we uh we created a fundraising um contract the lsp contract that we're using for for the demo we also use that to create a success token for fox um where they basically use that to hand tokenized a tokenized payout function to their investors that if the fox token rallied while the investor was part of the fundraising around with a vesting schedule that the investor would get more tokens a way to like tokenize that incentive and to really align the the session uh let's say the the incentives between investor and uh the shapeshift dial uh quite nicely and another one is what was boba's tvl right you can say you can create a kpi option that pays out you know double the amount of rewards if boba's tvl triples or quadruples in that period of time and all of these are actually real-life use cases that we have you know articles talking about another plug here is uh we're growing our team's looking for a lot of talent um you can apply for any position and we would welcome anyone to kind of join our team we're super global decentralized looking for just really smart people to come come on board these roles that we have here are like our most pressing ones so um highly recommend if you have skills in that area to take a look one of the things that is quite interesting to talk about here is that we're not necessarily wanting to poach from anyone or if you want your own project that's perfectly fine we're willing to support you in any way but what i would recommend is that if you have a friend that you think might enjoy um a bit of time working for a protocol like uma we pay out a pretty decent referral program so you can be sitting here you have a friend that wants to come into the defy space pass in my way and you could get paid to do that so yeah just have a look at this and we'll it kind of details the the um the qr code takes you to an article that explains our referral program uh written by our very own melissa and yeah if you want to stay in touch reach out to me on twitter you can visit umaproject.org and then for the hackathon specifically you can reach out to me on telegram at chanda dk or just use the youth global discord squad and tagney and i'll be more than happy to help you with any of your support queries cool any questions guys a number of views that's the value that's constantly changing and often it isn't correct and even goes up and down would it be possible to implement something like that yeah so each request is tied to a time so prices also change all the time right so how do you how do you find out what you know what the price was at a particular point in time each of the requests that come through are time boxed uh and so you'd say what were the youtube views at that point in time right now i'm not sure if you can really look at historical views on youtube videos but let's say for example you can and you can you know that you know at three o'clock on tuesday this this video had you know 10 000 views but then at four o'clock on tuesday at twelve thousand your request would specifically ask for the timestamp at a point in time yeah yeah indeed um and i think unless you're like an actual you youtube i stand on the correction because i don't actually know this but i think only the youtube like channel owner can view the historical data right yeah and so that's actually a limitation that's worth while exploring here is that if this data because it's decentralized participation anyone that wants to partake in it uh needs to be able to verify the information themselves so it's like somewhat publicly verifiable right so some to ask a question like um the youtube views like you know depending on if that works if you can get that data it's perfectly viable if you can't it doesn't really work but what you can maybe say is let's take prices from like you know the top five d5 assets bundle them together and then uh create like some sort of price index and you know do some calculations on that right so that's something that's possible because like you can easily get historical prices from multiple sources right but yeah it's a good way of thinking of off chain data and how you can bring that on chain yeah cool right [Music] [Applause]

Automatic transcript — names and jargon may be misspelled.