How to create a trustless synthetic token in 30 minutes with UMA
ETHGlobal·Wed, Oct 9, 2019, 12:00 AM
The team from UMA explains building synthetic tokens with UMA at a workshop at ETHNewYork. ETHNewYork was a hackathon organized by ETHGlobal and a team of hackers, developers and enthusiasts interested in building and creating in the ethereum ecosystem. ETHNewYork ethereum focused hackathon took place May 8-10, 2019 at New Lab at the Brooklyn Navy Yard. For more information visit https://ethnewyork.com/ and https://ethglobal.co/
Transcript
you've written solidity before could you just raise your hand okay cool and if you are familiar with synthetic tokens or what they are could you raise your hand cool and if you could if you think you could explain what swap is as in like a type of derivative raise your hand okay cool that's pretty good then so the title this workshop is how to create a synthetic token with um a in 30 minutes so originally I was going to have this be like a workshop style talk where I would go through the actual process but one of my colleagues updated the readme and it's pretty comprehensive in terms of how to start up one of our smart contracts how to deploy it on a test net and how to interact with it through our DAP so instead I wanted to focus more on kind of like high-level what we're doing why we're doing it and then also the mechanics of the derivative and I think that would be a lot more enlightening in terms of figuring out how to use it and then afterwards if you have any questions I'll leave point in time and also be here throughout the day so you can always ask me any questions cool so yeah going back to what I said earlier you can go to our repository go through the readme we also have a public slack and then I'll be here all day you can reach me out in the slack or you can just find me on Twitter or find me here I also have a colleague Ross who will be here as well cool yeah so first of all what is the defect okay and it seems like most of you are fairly familiar with it but I'll just go through it real quickly Alys for our definitions of synthetic tokens we mean any kind of token typically in ERC 20 token where the value is pegged to a real-world acid strictly speaking it doesn't mess have to be an asset but that's probably the easiest way to understand it so an example would be an S&P 500 synthetic token which just means that it tracks the S&P 500 index right so we already have some synthetic tokens according to this definition die and tether probably the two most famous ones and they're all pegged to the u.s. dollar another way of looking at it is that these these are called stable coins of course and I would consider stable coins as a subset of synthetic tokens where it's pegged to some relatively stable asset which is useful obviously as a medium exchange or a heat of account right are these no they're not so right now we just deployed an S&P 500 token about two or three months ago and we're still ramping out our product to figure out how to market it yep die uses their own smart contract system tether I think they have multiple versions tether but the one that is primarily used as built on top of Bitcoin which is kind of interesting [Music] yeah definitely yeah so there are all kinds of different ways to structure a synthetic token and one is what you just described right tethers it's backed by a central counterparty supposedly and there's less transparency let's just call it that and dies backed by a smart contract you can see the collateralization ratio and the rules for liquidation are all on the smart contracts you can kind of audit it yourself yep and if you have any questions part with you feel free to ask yeah no worries so why do we think synthetic tokens are important we think it's important because it'll give owners or cryptocurrencies exposures to real-world assets so you know if you own eath over the past few months you've been doing fine but in a bear market and not so much maybe you want to hedge your exposure to something that's less correlated to eath which seems fairly reasonable even if you're a whole blur maybe you're the owner of a Treasury and you have to manage your funds according to some roadmap so you may want to have some exposure to things other than II or 90 or C 20 tokens we also think it's fairly important bit primitive or defy so it's synthetic tokens could use dye as collateralization so it can end up being used as a dye sink and it could also be used to create different kinds of tokens that were possible for yep so how does it actually work so our synthetic token structure fundamentally it uses a swap which is a kind of dirt and I'll just try and explain what a swap is very quickly so SWAT sir using traditional finance world fairly commonly generally speaking it has two counterparties and you're trying to evaluate price movements between two assets so what an example you could use is the S&P 500 on one side and US dollars on the other side so you have one counterparty that once expose wants to bet for the price increase of S&P 500 relative to the US dollar and the other counterparty would do the opposite and generally speaking they agree in a margin currency in this case we can just see you use the US dollar and then both parties agree on an expiry date so let's just say that this swap lasts for a month there are special cases where there are no expiry dates the well-known one of course is bit Mex which isn't built on top of ethereum it's on a centralized exchange in Hong Kong but they have perpetual swaps and all that means is that you enter into an agreement for a swap for them it would be something like Bitcoin - US Dollars and there is no expiry date well underneath the hood there are expires and there are expires but then it just rolls over and you're not exposed to it you can just hold on to a swap where you're exposed to Bitcoin all alongside US dollars on the short side and get out of it I believe whenever you want yes so generally speaking the two counterparties they put up collateral and then once the contract starts you process how the price moves and then depending on how the price moves the the balance for each counterparty shifts so does that roughly make sense cool yes so I'll definitely get into that later but generally speaking there's going to be so they're different setups right but generally speaking you'll have a third party or a set of third parties that are going to publish the price feed from some external source yep and then generally speaking there's going to be an expiry date at then at the end of the expiry date each counterparty is able to redeem whatever they earned yep yes I'll give like a very simple example I think well yeah I'll give a very simple example so roughly speaking you have two parties a and B they want to swap for an asset against US dollars which means that if the price of the asset goes up you'll have one counterparty a who is long position who has a long position which means that as the price goes up they gain money and the other position counterparty B has a short position as the price goes up they'll lose money right fairly simple to understand yeah yes that's a good question so there's definitely a potential that the price moves past what's been collateralized at which point say party a if the price goes above twenty dollars they won't be able to you can't you can't rebalance anymore because there's not enough collateral on party B side which means that the contract would have to be stopped out which means the contract path be frozen so generally speaking and there are different ways to solve this one way to do it is to force each party to over collateralize and then if you get close enough to the stop out point then the contract is frozen and then the other party has to pay a default penalty which comes out of what was collateralized initially generally speaking that's how it's done whether it be on bit max or maker gal there's some kind of penalty that you have to pay and you got stopped out yep so yeah now that we kind of understand how swaps work what are the pieces for creating synthetic tokens so the first part is a price view that you mentioned someone has to supply the price feed it could be a third party it could be a party a set of third parties we have an on chain swap that's a smart contract and then we want to tokenize one side so what does that exactly mean let's say we'll go back to the previous example we have party eight who has ten dollars of exposure all that means is they have exposure it's a long side of the asset but instead of having $10 exposure what if they split up what if party a splits up that $10 exposure to ten separate pieces crates tokens for them and then sells them to whoever is interested in having that same exposure so I could just like take these ten tokens say that I'm party a take these ten tokens and then sell them to you each token will be worth $1 and then if the price of the asset goes up by one dollar then each token will gain ten cents and in that sense of course with ERC 20 tokens you have a lot of precision ten to the 18 so you can cut it out fairly granularly yeah does that make sense cool yeah and then also yesterday Vitalik mentioned collusion and that's definitely an issue with what we're trying to solve as well so the the price feed right the price for you has a lot of control what if the real asset was $10 but then the third party occluded with one of the counterparties and then claimed that it was $20 so in reality is $10 their party price feed claims it's $20 and then party a can run out with $10 extra right so with the current iteration we um a control the Oracle which is similar to the set up that say maker Dow has but our general plan is to relinquish or at least give some of the control to other third parties and that's kind of where the decentralized oracle idea comes from and there are a few challenges and a few benefits from going at this approach this is something that i can definitely talk about after this talk but for now the price feed is controlled by um a yeah but then there is also a possibility that the price feed is controlled by a third party and what happens if it's corrupted so there is also dispute resolution protocol within our smart contract generally speaking what that means is if one of the counter party disagrees with a price that was published by the price feed they can dispute it and then go to an Oracle which will resolve the price generally speaking what happens is if there's a dispute then the contract is frozen and then the Oracle will come in and resolve a correct price and then at that point the contract is finished and the powder the counterparties are able to redeem whatever their Oh similar to as if the contract was once you expire yeah but yeah so definitely so you're talking about as opposed to party a in the price third party price feed including what if the party a and the Oracle colluded yeah so this is like going back to kind of roughly speaking what Alex is talking about if there's no way to if there's no way to guarantee that there is in collusion between say the two counterparties and the Oracle it's hard to guarantee that there will be collusion or there won't be an opportunity to profit from collusion so our current iteration uses we control the Oracle the dispute resolution Oracle yeah and there has to be an element of trust there definitely so let me like answer that more fully indeed like decentralized version at that in this talk but that's definitely in a foreign point yeah right right yeah you can't you can't own the tokens and forget out the parts feed there's always a possibility that it corrupts definitely yep so I'll just like give an example of something interesting that you could do with our synthetic tokens instead of something boring like the S&P 500 let's just say that you want to create a synthetic token that tracks Andrew Yang's polling numbers right we'll call it math coin yeah thank you it could be anything else it could be like de Blasio's you're a fan of de la Co so what would it look like so first you have to figure out what the source the price feed is let's just say that will take 538 if they aggregate the polling numbers and they update it every single day or once a week we can use that and then we'll just say that it expires at the Democratic Iowa caucus next year in February and then we'll say that the synthetic token will increase in value one dollar for every basis point movement which is just like a hundredth of a percentage point and currently I heard that he was tracking at around 3 percent so let's just say that initially it's 3 percent and every point zero one percent that it moves a synthetic token will increase in value in by dollar let me what I meant synthetic token I'm when I met token I meant just the overall position will increase in value by a dollar so party a will take a long position they have to provide three hundred dollars in collateral because the most that I can go down is by through is by is 3% and then party B can take the short position and let's just say that they have to provide $5,000 in collateral in case his numbers go up to 53% so this just sets a ceiling in terms of how much they can lose is that roughly make sense yeah anyone it's arbitrary so I just picked it as in you mentioned earlier right if let's just say that the provided collateral was a thousand dollars but then his polling numbers went up to 15% then there isn't enough collateral to pay out the other side so yeah definitely out betrayed because yep so theory like party yeah yeah definitely so like so like one thing you do if your cuz you definitely bring up a good point where there is an asymmetry so in a more realistic example maybe so right now this is these are just like linear returns right one dollar for every basis point but maybe you would want to be make it a little more fair where every percentage let's see we could probably do something like yep so it could be like good yeah so as an example I guess we can make it like linear if it's above three percent but quadratic it's below three percent and then we could probably do some kind of we can probably figure something out where both the long and the short will provide similar amounts of collateral yep good yeah so I can get into that right after this but that's a good question too yeah and then finally we can say that party a sells a hundred pieces and then tries to find other people that are interested in taking the long side of this math coin yeah so I mean this is just the last slide just thought up of some interesting things that you could potentially build oh yeah definitely well so I mean I can't because I don't pay for Bloomberg terminals and they're pretty expensive but if you own them if you have access to it definitely yes if chain link provides it yeah yeah yeah I mean the the source can be from anything as long as you have access to it generally speaking if it's a Bloomberg terminal those are fairly expensive so you could probably charge something rates for it but you can do a price feed for Bitcoin hash rate you can do a price feed for the feds target interest rate you can do a price feed for the maker CDP collateralization ratio something else that's interesting is creating perpetual swaps that's one thing that I mentioned earlier and then outside of price feeds something that could be interesting is like just analytics force these synthetic tokens you can do things like trading activity or collateralization ratio something that we're interested in yeah yeah so I'm gonna there is like a minute and a half I'll try and go through the questions I think one of them was [Music] one of them is select trustless oracles how do they work generally speaking our position is that trustless Oracle's are definitely hard compared to if you consider say like proof of work consensus or proof of state consensus as a type of Oracle problem the one that we're trying to solve is definitely harder for various reasons and I think that at least I think that part of the solution is part of the solution is like controlling how token distribution works I think if it's truly permissionless it would be very hard another thing is requiring some kind of stake if you want to participate as a price feed you have to put up some kind of stake and you have to be at risk of losing it yeah and then what was the question that you mentioned yeah so yeah finding the counterparty in token distribution are definitely two challenges so finding the counterparty there is a way to modify the swap example that it created where instead of having two initial counterparties you can just have one counterparty that provides all the collateral token eise's the other side and then finds people that are willing to buy those tokens so that partially solves a problem but you still have to find people that are looking for these tokens with specific exposure to them and that's almost like a I call like a meatspace problem which is yes yeah I can see that honestly that wasn't that wasn't something that we've considered so yeah that's yeah yes yeah so there is I did I didn't really go over the corner cases that have to be dealt with but there are a decent amount of corner cases to deal with there's dispute resolution there's also how to upload prices just frankly speaking I wouldn't really recommend trying to create a one-off synthetic token unless it's something that's like fairly centralized kind of like a tether I think would be fine but it would also be reasonable to just fork our source code and do it yourself yeah [Music] maybe the network okay I can definitely answer this offline I think we're like three minutes over so but I can definitely answer that for you yeah [Applause]
Automatic transcript — names and jargon may be misspelled.