UMA | How to Get Started with UMA
ETHGlobal·Sat, Oct 9, 2021, 12:00 AM
Watch Chandler de Kock, John Shutt, and Alex Gaines of UMA in a workshop titled, "How to Get Started with UMA," part of ETHOnline 2021, a month-long virtual hackathon with over 1,000 engineers, designers, and creators building new protocols, learning at summits and workshops, and gaining valuable feedback from ecosystem professionals along the way. ---------------------------------------------------- Follow us: https://twitter.com/ETHGlobal Check us out: https://ethglobal.co Email us at: hello@ethglobal.co
Transcript
[Music] hello and welcome to this year's eve online hackathon event i'll be taking you through how to get started with uma in this workshop we'll be running through a few topics a quick introduction done by myself a tutorial on how to deploy and work with uma's optimistic oracle done by a launch engineer on the uma team john and as well as alex taking us through how to deploy and interact with the long short pair contract some useful information for anyone who wants to know more about how to work with uma you can visit our website where you can get through to our doc site medium article posts and our discourse for more information if you are working through something that you want to um ask someone from the team uh feel free to reach out to us on our discords and on twitter for any team that wants to continue building up their idea post this event the uma team has grants available for any team wanting to continue and if you've enjoyed working with ume tech stack and want to join the team we have a few open positions and you can go ahead and visit our careers page to find out more right that's a very short introduction from my side and i'll hand it over to the rest of the team hi i'm john schutt i'm a senior engineer at uma today i'm going to describe buma's optimistic oracle and show you how to use it to build new financial products let me share my other screen for you all right so there are two important things to understand about the optimistic oracle which is right here this part of uma stack the first is that it's extremely flexible you can ask it pretty much any question that has a publicly verifiable answer and receive the correct answer if you're thinking about integrating um's oracle with your project there's a good chance we already have a price identifier that will suit your needs but it's also very easy to pass new price identifiers in through uma's governance process the second thing to understand is that the oracle works optimistically and what i'm about to say might sound familiar if you know about optimistic roll-ups which work in a similar way with the optimistic oracle a user or contract requests a piece of data like a crypto price a proposer submits a response along with a bond and then there's a wait period for anyone else to raise a dispute about what the proposer said if a dispute is raised it goes to a vote of all of uma's token holders to determine who is correct if the original response was wrong the disputer gets the proposer's bond and if the original response was correct the proposer gets the disputer's bond in practice disputes on um are raised extremely rarely since submitting incorrect prices or raising spurious disputes will cost you money so the game theory basically works to keep people in check so i'm going to walk you through a demo script here this is for a really simple optimistic oracle integration this tutorial is basically going to spin up a local blockchain it's going to deploy uma's contracts and then it's going to deploy a contract we call the deposit box that receives deposits of wealth and allows withdrawals denominated in usd and you actually need an oracle for this and we'll use the optimistic oracle since that's the only way to find out the ethereum usd exchange rate so let's walk through here in order to run the demo first we need to spin up the local blockchain we're going to use ganache here in this terminal window there's some additional prerequisite setup steps but we're just going to assume that that's already done not particularly interesting to show right now and we're going to start deploying some contracts so first we have to migrate and these are just all of uma's basic contracts so if you're launching this on a test net or on mainnet you're not going to have to do this migration step all of our contracts are already there but you see things like the finder the timer this is for testing uh the voting token the uma token voting related contracts a registry for different collateral types and so on that are registered a store for fees etc etc this is just um's whole stack this is the oracle itself getting deployed too just give this a minute and then we'll be able to actually run the demo script and take a look at some of the logs which you can actually preview here but we'll walk through what it all means okay cool so let's do it let's run the demo it's pretty straightforward just a test demo script then we'll talk about the logs and we'll talk about the code so i'm not going to read through everything that happens here initially we need to deploy a collateral token do a bunch of setup stuff but let's pay some special attention to number three and four the user starts with ten wealth and deposits all of it in the deposit box then they make a withdrawal request for ten thousand dollars worth of left the deposit box then requests the eth usc exchange rate from the optimistic oracle and since this is a local script we can fast forward past the dispute period and settle the withdrawal request at an ethereum price of 2000 usd the user withdraws five west as you can see 2000 usd this tutorial was created a little bit ago so this is intentionally a very simple implementation it's just to show how the optimistic oracle works but the mechanism is powerful and could easily be extended so let's take a look at the code so this is the code for the optimistic deposit box script you can find the example code in the protocol repo this is a mono repo it includes a lot of other good stuff including our smart contracts tests and bot infrastructure so this is a great starting point for building your own optimistic oracle implementation and understanding how the optimistic oracle functions actually work so as you walk through here you can see you know real integrations with optimistic oracle on this local blockchain as well as all the steps and this is you know too much to go through in the video but i really highly encourage you to check this out again this is at uma protocol protocol and packages core scripts demo optimistic deposit box and i believe there's also a link in here if you look through and if there's not there should be so we'll add it all right um let's see here uh i i'd also encourage you to look at the optimistic oracle interface itself um there's a lot of good comments in here we do our best to add lots of comments to our code to make it easy to walk through and understand what's going on so in here you can see comments that explain the functions and parameters uh requests proposals disputes and settlement all of these things are explained in here so this point is where you would request the price either as an individual user as a contract you're requesting a particular price or just a particular piece of data from the optimistic oracle you're setting a bond that you want the proposer to post some other you know customization details you can have longer shorter liveness for instance let's say that you don't have any bots up and running to respond to these price proposals or dispute them you want to do this all manually you might want to set a longer custom liveness for that give it like uh you know a certain number of additional hours to give it a day or two just to make sure that you catch anything that goes wrong price proposals disputes etc all this in here definitely go and check this out [Music] so another thing that we should talk about is price identifiers [Music] so as you think about price identifiers for your project you probably want to look at identifiers that have already been approved through our governance and a really cool one that i want to highlight here that might be relevant to you is token price so token price is a generic identifier it allows you to get the exchange rate between any two tokens and before you can see a lot of other custom price identifiers we put in for like uma usd uni to usd etc vice versa uh you no longer have to pass these anymore ever since this unit passed this governance proposal token price lets you get anything to anything so that's really great another really good and useful uh generic identifier is yes or no query and yes or no query lets you ask the oracle any natural language question like you could ask did the philadelphia eagles win the super bowl in 2022 or did open c average one billion dollars in trading volume per month over the past six months pretty much anything like that as long as it's some information that anybody could go and look up in case of a dispute and voters could verify what the true answer is this identifier works for that if it's something a little bit harder to calculate if there's some ambiguity about what the result should be you probably want to propose a custom price identifier that's also not that hard just reach out to us we're happy to help you create a new identifier and help you pass it through governance we make the process pretty painless especially with the super um q crew sorry our community team which is really incredible that can kind of help you guide through the process one other thing to look at if you're going into production and we won't dive too deep into this right now is actually setting up bots and bots could propose prices and dispute prices automatically so you don't have to worry about price requests coming in when you're asleep or incorrect price proposals going through and not getting disputed um all really awesome uh you know you can spin up a docker container to do this you can launch this in the cloud there's a lot of details in here um definitely recommend that uh but we're not gonna dive too much into it so i hope that's all really helpful um you know there's a lot here just to circle back on the price identifiers for a minute to spur a little bit of inspiration you can see how some of these things are really customized so x sushi apy for instance this is tracking the average uh yield from x sushi over a certain number of days you can track dominance of ripple or btc or eth i know that there's multiple dominance price identifiers in this uh the price of gold kpi options this is a whole other open field so if you have some particular kpi for a project that you want to incentivize you can create a custom api and the oracle can enforce the payout to people that receive those tokens which is really great for airdrops it's really great for community incentivization you know there's a lot of really cool stuff so the place to check this out is docs.uma project.org go to tokenholders go to price ids and collateral currencies you can also check out our collateral currencies here lots already approved we kind of preemptively approved some stuff too 85 so far and similar to price identifiers it's very easy to add so basically what we're trying to do is just give you a toolkit as flexible as possible we have some contracts you can work with we have an oracle you can ask any question to get a correct answer and you can create pretty much any product you want sky's the limit please reach out to us we'd love to help hi everyone my name is alex i am a launch engineer at uma and today i am going to walk you through the lsp contract we are going to do a quick demo of deploying a contract and then we're also going to go through some of the lsp interactions so a little overview of the lsp contract it allows anyone to create financial contracts that can't be liquidated and can easily be customized for various payouts so developers that are familiar with the emp contracts might be excited about there's no liquidations there's no bots there's no collateral ratios not only does this allow for more passive lps but it also creates a new suite of products aimed at treasury management and other use cases but i really want to highlight how flexible the lsp contracts can be and john is really going to walk in and go through the integrating with the optimistic oracle but the root of this flexibility comes from how the optimistic oracle is able to easily provide access to data regardless of how unique or bespoke that data is that data can then be read by the lsp contracts and be used by the lsp contracts to compute and determine financial payouts but the bottom line is for the optimistic oracle the same level of effort is made for settling a price request on something like usd uh it's spot price from ftx versus something very unique in bespoke so it that's really powerful in itself um while today we're going to do a demo on something uh relatively simple the more there are more complex calculations that can be seen in our implementation files so before we go into our demo i just kind of want to jump over and look at some of these unique implementations a good one i think is yes bdi flip so this is i mean the calculation actually tracks the market cap of bdi relative to the d5 pulse index um so we have a little summary here um we have our ancillary data here which actually is deployed within the deployment script and then we have our uh implementation steps down here what's great about these implementation steps is that it removes a lot of uncertainty for voters and if there's any disputes then also helps to walk through how to calculate the price for proposers so i encourage anyone that's thinking about building something on uma just to kind of explore these documents and see what's been created and use this as a as a really powerful reference so going back into the slides our next step we are going to create an lsp contract so what we're going to do today is just basically make a contract that does it pay out based on whether openc will launch a token in 2021 so this is something that can easily be used by prediction markets but what we want to do is uh or how we want to set it up is if there is a token an open c token released in 2021 the collateral payout will go to the long token orders and if there is not a token uh release the payout will go to the short token holders so kind of the steps how we're going to do this is first we're going to find a price identifier and then we're going to choose a financial product library to use and then we're going to write our appointment script and launch our contract so the first step in um finding our price identifiers is is to go over to the docs thing we have all of our price identifiers that are approved are listed in here i already know which one i'm going to use so i'm going to skip down to the yes or no query identifier um so this really is just a yes or no question and it's intended to be used with the ancillary data but if you come into this dock it kind of explains um so the price settlement can happen in three links uh it's p1 if it's no p2 value if it's yes and p3 if the price cannot be determined and if you come down to this ancillary data spec i mean this question is pretty much what we're going to use this asks if the dallas mavericks won the nba finals in 2021 um we're just going to change this to did open c release of token to 2021 and then we are going to convert this to bytes and we can pass this longer uh deployment script so now we have our prize identifier next we want to go over to the launch lsp repo and uh kind of look at the deployment scripts and the different ftl um different financial product libraries that you use so if you haven't been to this repo before um this kind of outweighs how to write your deployment script it goes through all the different financial product libraries that we offer and it even outlines at the bottom how to create your custom across a custom uh fdl so there's a lot to work with here um today for our example we're going to use the linear fpl contract and so how we're going to use that with the yes or no query is you
Automatic transcript — names and jargon may be misspelled.