Formal Methods in Tokenomics Design
EDCON 2023 · 23 May 2023 · 23:04
Silur applies formal methods and control theory to tokenomics design, arguing that copying successful token models overlooks financial engineering. He explains simulation and feedback-control approaches for treasury and supply decisions, including linear and nonlinear models, and stresses that these methods depend on sound assumptions rather than guaranteeing stability in every market.
Speakers
Topics
From EDCON 2023, hosted by EDCON.
Transcript
uh thank you all for making this kind of early presentation It's relatively early for me so as I'm trying to keep the old school way of crypto talks and not have any logos and project chilling especially since I'm an independent developer and I in like 12 projects simultaneously I cannot represent any so I'm always trying to bring independent topics which are usually personally driven personal driven ones okay um and this is also a personally driven motivation so being an independent I
work in an independent contractor Network and usually when there is the misunderstanding with one of my partners that I'm an expert in tokenomics too which I'm not I always reached out to this um expert Economist friend of mine a pair actually a physicist who died the actual modeling and the young guy who always did the making up to date in the crypto market and since I've lost them I had to find a way as a developer like a Quantum researcher without all the necessary knowledge in economics that how do I make that economic system works and the only tool I had at my disposal is that I'm I suppose I'm good in mathematics so today's talk is formal methods and control theory onto
economics design and the advantage is how I hacked this on the agenda I'll formalize the problem that I saw like lacking in tokenomics design generally then like key components most importantly the simulation tactic and I will list a couple methods in control theory that you can incorporate when you are making a new erc20 tokens and then at the very end I'm gonna explain a little about that you're introducing a tackleberg competition into your tokenomics and how do you solve that so the problem I've seen with many of my partners is that most people did realize that making an ERC from scratch is engineering but it's only like 20
percent I.T engineering programming engineering yeah where I think smart contracts is hard uh writing safe smart contracts is even harder but in a product product development term it's only 20 of the work the rest is mostly Financial engineering and then product development and that people tend to forget this that yeah it's hard engineering and the financial engineering part is mostly missing the methodology I've seen is that we're just gonna copy the best performing tokens from Ico drops because they did money and they never realized that it doesn't fit your model here you have to like do something special just for yourself so heuristics and statistics won't work like even the total Supply doesn't work
like that most clients of mine selected the total supply for their tokens because it looked nice psychologically it's like an even number and stuff it it shouldn't work like that so one key component that's irrelevant of control theory and should be a key stuff in any kind of financial engineering is to use the Monte Carlo simulation methods and I just listed a couple distributions you can sample from your Martingale from when you are sampling the price that okay what price I'm gonna simulate on according to latest research crypto prices follow mostly normal inverse Gauss distributions contrary to Forex and like
Common Stocks which follow mostly Gauss distribution as crypto follows the Gauss bell curve usually but there are some times when it's like kicking in One Direction a huge candle and then everything breaks but normal inverse gaussian can capture these very weird high-level volatile Behavior so you can sample your Martingale you with your Monte Carlo simulation mostly using normal inverter inverse cows I brought some code example by the way the slides will be available as a website at the very end and you can copy the codes I may even add it and add some more examples at the very end here
you can see that I just pulled from binance the latest usdt prices and just fit I don't even know the correct parameters for distribution I want to simulate I just used ckit learn fit and it fits the ethereum behavior in prices perfectly and I can just generate three years of projections into the future with the assumption that it's gonna work the same as ethereum Market did and also since I sold tendency this year's stock that you had to have AI in your talk I also made it one with an O2 encoder using pytorch you don't really need this but if you have some
super countless distribution maybe a super low volume Market with a very low liquidity they tend to behave weirdly then you can capture it shortly with an O2 encoder in a couple lines next stuff is the example I told you that you shouldn't capture the total supply of your token based on psychology and statistics alone this has is also something that has been addressed way before actually the first um the first example I saw Regard in regards to crypto is from vitalik from his blog he modified the quantity theory of money to some crypto way I personally like to
use the Cambridge equation more which basically says that the total supply of your token should be equal the holding period this is the one that captures utility Theory which we are going to talk about a super important part in financial engineering so it should be the product of the hold average holding time of a person of a wallet on the network the price level in tokens and the real aggregate value of transactions made and if you like did your homework in product design when you prior releasing your erc20 token PQ so the price level and the aggregate value of transaction is visible in your market
research because you did a historical statistics that hey I'm covering this Market I'm tokenizing real estate I don't know average price in tokens that I want to release p and people purchase that much real estate the last 10 10 years so PQ is known you only have to figure out K but in crypto Market you just go to etherscan select a bunch of tokens this you can do with Statistics and heuristics and you just check how often a wallet changes tokens so K here is not volume it's just how many times a single ether changes hands so for the following for the actual
control theory part I'm gonna use an example the treasury model which was super popular since defy went to a rocket and it's interesting because it also follows the burn mint equilibrium model so even if your token contract doesn't really burn or Mint new tokens introducing the treasury model mathematically is the same because you're pulling or putting back tokens into circuit public circulation so it doesn't matter from the financial engineering aspect whether you burn the tokens actually or meet new ones or just pull into some treasury because you are also present on a Fiat Market which is mostly true so most clients I work with
are tokenizing something from The Real World from the Fiat word they say uh and trying to reflect it in some kind of erc20 which is hard because with this treasury we have to play some kind of stackable game and involve lots of oracles for that and this game does have an equilibrium of course when you burn the exact amount of tokens you need to sustain your business and mint the exact amount that your economy needs that your token economy needs is fine but it's not really realistic in an actual Market scenario because you can't maintain the theoretical equilibrium like Black Swan events com an FDX collapse come and
that's when startups really have to shine like you have to prove your adaptability to the Real World Market and that's when control theory comes back like you have a trajectory you want to follow which is the equilibrium in this model and you have to when you're diverting from that trajectory you have to super quick go back to that so we need something that captures utility Theory not just the formal game theory of the burn mint equilibrium for our example because and it's super useful because utility theory is the part that captures um subjectivity like personal subjectivity how much this token is worth to you and it differs for every
person like the more cookies you eat the less satisfaction you give get from the next cookie and it's the same with money like a thousand dollar won't motivate a billionaire anymore and it's uh it can be Quantified mathematically even though it's subjective and when you do you reach uh very interesting stability properties in your Morton Carlo simulation the example here and actually some techniques too comes from a free ebook that I really recommend you can download from Stanford's website foundations of reinforcement learning with applications and finance so the example uh the treasury example I described in words is formally this one
so the total supply of our token let's say varies or changes as I withdraw tokens from the circulation so the tokens purchased back this is TP in the formal model so the tokens I purchased back and I give back some like the buyback uh divided by the price and I have to offer a premium for my network other Advantage because they're just gonna dump the tokens on unit swap so I offer a premium here so I'm the rational Choice when it comes that comes to how do I maintain equilibrium so this is the example we're gonna use and stabilize in various forms of control theory the example comes from
actually the paper I listed here which is kind of the motivating Source how I got into Financial engineering and control theory in regards for tokenomics design so method one kind of the most naive one is a linear quadratic regulator Pros it's time invariant anytime you are it doesn't matter if it's your first year of your projection you want to stabilize or desert one it's gonna work the same you only have to do the QR Matrix one and every time there something happens you just run the same algorithm like you just do the same matrix multiplication on your state and it's gonna be the most stable version
achievable on your Market currently it's also super deterministic which can be a problem too on financial markets because people are gonna speculate on it the biggest problem is that most defy logic especially since cdps and all became a trend are not timing variant or linear anymore and lqrs uh the name suggests that you have a linear system of you have a linear dynamic system so your total supplier price your treasure sizes changes linearly which is usually not true anymore and your constraints are quadratic so the formal problem is that we have the
state X and we have the control vectors which are our purchase back and are premium how much premium I gave or or I want to give to the network to sufficiently motivate them but still not lose too much so this is what we want to optimize here the code example looks like um looks ugly but this is everything you need here so it's like nine lives you can optimize the treasury model I used mits and Boston Dynamics open source library for robotics to optimize here you see X the X variables are my total Supply the USD pool my token pool and my
price and the control where I have like the little sliders that I wanna stabilize is how much um how much tokens I buy back how much USD I buy back from tokens and the premium I do and I expected every year a 10 percent increase in my Revenue model and the result is a matrix that every time you do the multiplication it just stabilizes you like tells you exactly how much premium you have to offer to follow the 10 percent increase this is still not a guarantee but very useful and still better than heuristics here I calculated uh here I did a trick because as I told most D5 models are not linear so I just did the second order Taylor
approximation at any point to make it look like it's linear so the technique is still approachable and the actual actual optimization part method 2 module predictive control it's a little more evolved because now we can have a little uncertainty which we do have a lot in crypto now in crypto networks so you can have like a range a boundary that I don't know exactly how much tokens I want to have or where the price will go like let's have a worst case and the best case scenario a boundary and model predictive control can account for this within its own limits of course the problem with this is that it's just like with AI it's tend
to under fit or like reach a local optimality that you can't really get it out from and it's very slow to compute and you have to compute it like every time you wanna account for a Black Swan event so for this I use the open source um do NPC Library I have to step up with the code examples that are gonna be available so yeah it's the same equation that I started with the example how the token pool or the total Supply changes according to the Cambridge equation the USD pull and the only questionable part is here the S i0 which is my projection so my demand how much demand I projected
for my actual product in the Fiat word um our constraints for the changes and then I set up the controller using to do NPC the horizons I want robustness of course that's my whole plan put into the parameters and start state which is like the token generation event State and just let's see what's the next control parameter has to be PID we are getting closer to real word because PID has been used in the wild it is also the easiest to implement because PID is just a very engineering eqa to express present past future p is the part that how wrong are
we right now with our tokenomics model compared to what we projected the I part the integral part captures how long have been wrong about it and the D part is how sensitive are we with the parameters if I try to change how but Direction and how much will I go basically here is a a very hardly seen visual representation of what I just told like the three components prosperous present and future the problem with pids that tends to like overshoot especially if you cancel one of the terms which did happen in the while there so right stabilized its
stable coin price using a PID controller more like a p controller because they did realize the biggest problem with it in defy and in web3 is that the D part especially is prone to adversarial speculation because if it's if it captures the sensitivity of your token it can be used for trading because if you know exactly how much premium you are gonna get with the treasure model in the next block you have you don't have an Arbitrage Free Net uh Market anymore so people are have a deterministic way to speculate on your prices with here and that's why Rai actually nulled out the D part
the last method I'm gonna cover is my favorite that is not contained in the original paper I list it here I just found it through experiment that this is the best is a Markov decision processes which is kind of the hardest to implement but the good part is it is that the output here is not a single point optimization in time it's a whole policy you can give to your client and and as an independent it's very nice because I don't have to maintain my tokenomics designs anymore I give a ready policy and I just tell that hey follow this anytime something happens you just rerun it and it will reach equilibrium and it also has many open source libraries and you don't need to deal
with nasty ordinary differential equations because those are hard even though like web3 is super closed optimally or web3 model that's why you are going into smart contracts because you realized that your business model is so contained so market clearing and close that it can be sold fully automatically with smart contracts and usually those are hard to model with ordinary differential equations so you can solve a marker Markov decision process using policy iteration value iteration uh kind of average case in Q learning the state-of-the-art methods to solve mdps are deep Q Network or proximal policy optimization but I note here I
found that when it gets to that that you have to solve um the tokenomics mdp using these two it's likely your whole business model is faulty so you just reiterate it shouldn't be that hard on a web3 CDP model or the treasury model it never should reach the complexity where you have to reach equilibrium with the mdp using deep Q learning so here are actually asked chat GPT to write me a value iteration solution and I put it put in my invert normal inverse goals distribution from the ethereum example as a start State and ask the forward
variable iteration to give me the optimal policy the problems with all of them as I stated is that everyone can solve this problem because all the data is public on chain the algorithm I just gave you away freely and everyone can run it so everyone can speculate on your price because everyone knows what's the nastic next equilibrium is gonna be or a more formal formally we have a leader follower came that thankfully has been formulated it's called the stackle bar game so the rules are not symmetric anymore like in chess because there is a leader and there is a follower not the same amount of power for the game and thankfully it has an equilibrium
that slightly screw skewed towards the leader in terms of like staying idle so you can solve this kind of stackable games like you have the optimization algorithm your clients and your Market will have the buyers will also have the same but since you are the controller here you can force the other party into equilibrium at any time using because you move first every time they can see the rules they can see what you what moves you made in the game because it's on chain on etherscan but still with this knowledge you can force them into the equilibrium so conclusion because I ran out of time use iterated lqr or there is a typo
there iterated lqr when your models are easy most of the time they are if you can't linearize your tokenomics for whatever reason the first to go for is model predictive control and if you have even more uncertainty you are absolutely not sure about one dimension you are moving on then use a mark of decision processes and whichever one you used like techniques always solve the resulting stackable game because your speculators are gonna solve the same game so use the cloud School stacker conditions to solve your stackable game here and also publish that in your white paper that hey we used ilqr or MPC to solve our tokenomics model because first
it's great marketing that you are not doing heuristics and statistics that you actually had some financial model there and because you're not gonna able to hide the moves you make it's better to tell them ahead that here here is our policy please follow plus because then it's a win-win situation even though it's a zero-sum game and of course this all relies on that you have a stable projection so it's not magic like it won't mathematically prove that you are stable in any kind of Market environment it just follows the trajectory and you have to have a very sound uh business uh projection for your upcoming like quarters and stuff because that's all I presented here is useful
so as I said the slides are available online uh I may edit or add some new examples here and the code is copyable here and here are my contacts where you can reach me with questions or outside thank you for your attention [Applause]