Batched Bonding Curves: Grieving DEX Frontrunners by Billy Rennekamp (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/batched-bonding-curves-grieving-dex-frontrunners It's been widely publicized that front-running is rampant across decentralized exchanges. Billy Rennekamp describes the technique developed to stop the parasitic behavior by using batched orders in tandem with bonding curves and how it's being used in a new fundraising app by Aragon Black. Speaker(s): Billy Rennekamp Skill level: Intermediate Track: Security 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] [Music] bonkers about creating an expert Mars is really about me Buffalo's Network founder creator of the clovers network also done it before curiously with Paragon black and notice the author of mt 1603 of the refundable token s nifty which was a hackathon project that inspired an estimated of teas and of course founder of Lawrence the majestic creation market Williams today I'll be talking about market makers from earning and going over mitigation techniques and match-funding hurts there's your three different versions and curious if people have opinions about which links and then we can so bikers are automated marketing measures you might be familiar to these concepts in the context prediction markets a mechanism invented by Robert Hanssen that's used for basically gambling on prevents Bank or which uses a technique ratio or and or the slope formula version of bioterrorist kind of created by Simon Taylor media but all these parking makers provides the query which is a very important concept and any sort of token base or asset based system whenever you have some asset you're trying to sell or buy there's not a lot of other people out there trying to fight or sell it you're gonna have a lot of problems agreeing on price and so there's many situations in which you have the clarity there's just not a lot of buyers a lot seminarian each topic or something like that and so you have designated parties who are willing to buy or sell at something redefine formula or agreement or system and those are market makers in a prediction market you have situation because the tokens that you're dealing with are attached to outcome events this is the sort of gambling on future events and often these are very liquid markets that there's not a lot of participants so there's not a lot of token circulation so if say the prediction market is about the future headquarters of Amazon and I think it's in New York you think it's in Chicago I think it could be in Chicago but your lecture then so we don't really necessarily agree on what I should sell much in public tokens team Ford so it might be nice to have something that market maker who's willing to buy this back the logarithmic spiral is the market maker use and prediction markets usually and it's really nice because it's calculator weights so that at the end of all of these sort of events the tokens that did not occur the prediction that did not occur marking zero and there's just enough money inside the contract to pay out all people about the Kobe incentive to exist micro economies in general which could take place in absolute Civic tokens like token curated registries or my private quarters network in which there's just you know a very niche clientele for this token but you don't want them to be sort limited by the aspect probably won't have access to exchanges this is not love people buying and selling and so there's very large spread and we're - there's no agreement about the current prices this is actually looking into this topic again with making my project lovers network it's a game and I didn't want my users to kind of be stuck with the point and not being written it but there's no some exchange was going to list me so I wanted to be able to offer them the ability to offload the coin for ether and so I was able to employ my own body curve in the contract so users are constantly buying sell at a price that's changing but the general concepts for finding curves which have indefinite token supplies are that the tokens themselves come from the contract which is the market maker itself as well so you could send some collateral to get adopted either into this contract and it will mend some new tokens for you the price that it means it is designated from a predefined formula or an adjustable formula the situation it would be basically total supply squared C the total supplies on the x-axis is this sort of defect that is how many tokens are currently in existence and that determines the price which is on the y-axis I really you can imagine when the when the total supplies that are getting in is almost zero the price is very low as you purchase the price gets moved up so let's say the first ten that you buy will be less expensive than the next ten after that and the next thing after that if you want to get rid of those tokens you can come back send them the contract they will burn them which will decrease the total supply pushing the price back down and a really convenient aspect of this visualization is that the area under the curve is actually the amount of collateral that's needed to populate that contract in order to generate those tokens that collateral is always staying in that contract which means that when you come back and try and cash out that money's there waiting for you it's a bit like an IC except for the company have the money flex locked up and it's there for by vechs mercy of our Lord so that's right so the top right there's some kind of math and this is the two ways that are often used for thinking about these and calculating these which is the price formula it's kind of basic slope formula this is really useful for visualizing and designing is several mechanisms but what actually comes to implementing I kind of prefer the way Bank or Sonic which uses a concept of the reserve ratio that's with our artists so they think about the price as the reserve to the month level divided by the supply times some reserve ratio is going to be some number under one its what percentage of that supply is actually backed by collateral which you can rearrange and see that the reserve ratio is actually the reserve divided by the market cap so that's kind of like how much is actually backed and market cap of courses and price times the supply so those are the two sort of ways that I thought that you can actually program it in the original format or there's nice properties of the reserve ratio that lets you do some sort of adjustments while it's moving I had supplies and then at the end we can go over put a time bite Club part of the tongue example use case that this new batch body care techniques being used it is in a continuous organization and this is an idea where you would basically have a Dao has body pair of attach to it and when that money goes into the contract it actually can be used by the dial for operational cost or something like so the shares are the tokens their thoughts on this body curve and walked collateral and some portion might be used working capital and the token holders might receive something like shareholder rights or receive dividends as being a participant inside of this sort of more like a traditional company it's been implemented with Paragon black called the fundraising app which should be coming out soon there's also some other organizations working around it seorak from team of Barbara it's really new things working to get these types of organizations classified as Rexy in America so that participate them without a service fee work is also building similar mechanisms using the Dow stack framework for gnosis is DX stuff and give us in the common stack is working something similar so there's continuous organization instead of going through and hanging out dividends I mentioned this might be sort of a feature that you would want and now because it's done like this there's a really convenient workaround instead of sending out a bunch of transactions for all the several state quarters to give them dividends you can actually just put money back into the collateral pool and this is sort of will increase the value all the tokens that already exist so if you're a stakeholder and having these tokens by injecting collaterals back into this contract the value per token will increase for everybody sort of like paying everybody dividends with just one transactions that each person because if the level increases of the token supply stays the same you can imagine that the price will get boosted up in that previous round similarly when you remove collateral this is a way to basically increase the value of the tokens because you've gotta spend money to make money but these are kind of the two actions that you'd expect in a continuous organization using a bonding curve like this so front-running as most people know aetherium and the left public block chains are kind of slow and they're their process of transactions and blocks and for a moment there's this bin full of non process transactions and so in that moment you kind of have full sight of all the other activities that people are taking place on the blockchain and if you can see that some of these transactions are buys or sells and when it's bonding occurs you'll know that there's going to be a price movement and whatever there's a guarantee price limit running as possible and the active front running mentioned in a buy orders coming in you as the front runners would be able to make another buy order and lose the gas price which might make the at first depending on the how that might works or you might be a miner yourself you would make a buy order in front of them with a new guest they would make one after you and then you make a cell one so when you make your by the prices pushed up they think there by the prices push you further up you make yourself and your back down here so this is kind of bad because there's no risk and that that buyer interacting this market and so they're basically just scraping off some of your money and the buyers do you like going into a store buying the outfit got somebody else turning around and selling to them a markup when they could just buy from the store similarly in a sell order if you see yourself coming in you can make a sell in front of them push the price down we make you make a cell which the price further down and then you can buy that so this is a way to increase your current position with no risk sort of scraping off their money and using it for yourself in those two dividend and working capital situations you can similarly front-run so the transaction that might inject collateral under the pool this is similar to a buy because you know there's going to be a guarantee price move it up so you might decide to buy right before that rejection happens in the cell right afterwards or if the working capital is about two or four nodes you wouldn't want to have a situation that you can just sell the code that's right before they withdrawal that capital and then buy back afterwards in the same transaction so front-running in the wild is rather rampant these are some statistics from last year's talk I feel dying about it so they were doing most of the work on sort of publishing this in a while and putting the 17 on HR Delta alone just not very popular exchange there was four thousand five hundred dollars a day in August he and others recently released a paper called flash boys - she's a reference to flash boys the high-frequency traders who would sort of built their online internet across the new jersey to the stock exchange in order to prevent order to prevent mental activity like that and by their estimates there's thirty percent of all walks in some manic programmatic arbitration transactions which would be included a sort of drama if you want to see more data on that you've got a front run dummy there's a there so this is this is obviously ramp in the wild and it's only going to get worse and so we can do need to address this because we can't really ask anybody to use and on chain exchange if we know that it's not going to be able to deliver quality service so patch borders with common clearing crisis is one proposed solution with three versions here calling them ordered batches matching fill and a common clearing price and again the each other sort of benefits and drawbacks and I'd be curious with the general sort of feeling that's weak so the first one passionate orders I'm sorry well they all sort of follow a similar idea which is that you take some span of blocks and you collect all the buys you click all the cells and that span and in order to make things will be easy just combine them and one big buy and one big sell keeping track of course of all the individuals who actually put in those in those orders and then you clear them together with some price and then you redistribute it to those users based on that price in the percentage of decay so the first version of that is has have a drawback in that one party to award it over the other although you can think of it as a feature not a bug you want to reward one of the parties more together for instance the buyers so in order batches it kind of takes most simplistic approach which is why we just execute all the buys using the body curve and then execute all the cells or the away or do all the cells and then execute all the pies but this does reward one or the other so imagine the execution buys first so let's say we're starting out in the blue line that's the current spot price we execute the buys first the price moves up to the red this is really good for the sellers because they want to sell in a high price and so they've now sort of keeping giving this Lisa price position of having a high sell price person moves the price back down overall if you were to execute the same orders by first and sell first the final price would be lower when you do execute the vice versa you're next to the cell surge you can imagine starting to light again it's going to push it down with a green s which is great for buyers so they want to buy at low prices so now they're sort of the privileged party in the situation the final price is going to be higher than average or higher than the self version which other two sort of features but if you want to reward buyers and your system you kind of think they're putting money into the system they're they're you know tributing I want to make sure that they're rewarded for this capacity you might say this is a feature and you want to make sure it happens this way maybe you have an idea of 40 70 people to the other one so the second method is called matching fill and iviva that's it for Tamar government from gnosis 4l muses and this idea is that you have the original spot price the current on and of course ways the body curve as soon as you start buying or selling you will start moving it but in that moment you have an exact price to theoretical exact price so why don't you take that one and match orders as much as possible you got a speaker device you've got speaker the cells at that spot price one half of them is going to get completely consumed by the other half you're gonna have some leftover buys there was actually more buy orders and some liver cells and their action or sell orders so whatever's left over and execute was a normal monitor transaction so you have this entire side that gets taken care of just at the spot price disappears the other side is a combination of that spot price plus whatever is left over essence body the third one is a common clearing price this is kind of the way you would imagine mystical this is where you can find some fair price for the entire group of buys and sells however it's a little mystery complicated is comforting on the EBM and then there have to notice this member Tom altar for helping you with this but you can see the formula for getting this is rather hard to find it is possible it ends up resulting in one solution that's zero one imaginary number solution and then one correct solution what is convenient is that even though it's hard to find when they protect the dummy man it is easy to verify in the video so if you were to take that price which was the correct price in that formula provided with the transaction execute the borders to be able to check to dis mess up the slope at all did this change the market maker is it it was an incorrect price alert modified that so it's easy to verify so there is a solution for that this is inspired by the notes of diffusion exchange which has something similar very complicated executions but it's easy to verify that they were done correctly off chain and this my topic you nice walkers been working with batching orders and trades so that's from Dan Robinson and paid ads I just found out about this did today they might be talking about it later today of for twenty and thirty seven you can see that when you use in the constant product it actually comes much easier to make this batch order calculation in yourself great product and it's used specifically for token to already have sort of fixed supplies or supplies that exist in a while whereas I think that bond occurs get much more interesting much more useful when there's a situation that the token is actually generated from the same place as the market maker correct situations like predictive marketing curation markets like if you don't have that requirement that you need swap is a definitely like relation so there's a link to the github perfect concept there it also links to the art on black implementation it's still your going final audits and there's also a link to the particle that has a bit more details but all these topics if you want to check that out again later wait while I see bones by now [Music] and this is interesting you come and say hello talk to me me on Twitter email github yeah that's it we have any question for some few minutes some of the three approaches that you described you have a personal favorite my yeah so for the most part while working on this I was really looking forward to this concert there in crisis is universal one for everybody but after sort of finishing it and finding it I can assign favor in the second one and because I think that it's sort of the prices it's more reflective of the way that mark is actually acting you know like if there are more buyers and sellers that buyers should handle the sort of price movement whereas the sellers are sort of the minority in that system a situation so maybe they should actually just have the spot price which is comparable but I don't know I mean the common claim price is also kind of it feels good and that's what I meant sort of I think carries about girls opinions and one of those fields better course with you the first one also for the use case up for where the buyers make sense but I ask you towards the middle a little bit the sir that I may be going to show hence first curve as the like best one for general use case anybody at second version got some hands we got and third version okay we got a couple as I'd say general consensus a second kind of makes sense but yeah in that second version you're talking about for the best month where there's leftover heat the buyer's or seller's and distribute like the prices additionally between that target group or is it like a set of buyers to get screwed or set of sellers get screwed even in between that attacker good talk so did you look at heuristics or optimizations for the price we found the formula that has all the like necessary variables that you want to solve for but I have just using like Wolfram Alpha to like to solve it I know there's like some Python libraries that are good for that sort of symbolic subbing out but when you actually solve it for the variable you actually won it becomes this really nasty nasty formula that I don't know how to deal with so I'm sure there are ways something like that map but at the end of it that's all sort of caught off chain data so it doesn't so that you can be optimized with all the really matters instead it easy to verify the changes [Music] so what was the mention about your last slide that because new small bright doesn't have the same constraints that you were looking at what does there perhaps morning it's the same kind of bachelor quarters and they choose the comparing prices kind of fair version so I think anything to do it just easier cloud was exactly protect is the constant product partners like and appointments whether it be common patterns like the size of the orders that a to be the front-runner orders for since it's a neutron would like to detect these small orders went running large orders or image or performance like burning in the wild again yeah I'm not sure about that I wouldn't say a check from Ron dummy that I kind of data but I don't know I've talked to some people and it seems thing it's easy pickings but there's actually just such little it would be on chain that there's not it's maybe not worth putting in the effort to proper everybody I don't know so I vote for frontrunner the reality not have a lot of talks with different shops by the short version is what you were saying there's just not enough money in making two thousand hours a day all right barely complicated even though those dollars sounds like a lot people are talking to say I mean we do actually give the quiddity and continues Inc Texas where some probably a different case well I would assume that at some point there will be a product differentiation between the ducts is where you say you know no to the front-runner Phil right and so he would have to just fix the problem with this it's an entirely fixable problem in the neck software itself that allows for the front right there's no well I think we're at that time you want to talk later [Applause]
Automatic transcript — names and jargon may be misspelled.