Complete Protocol Markets

ETHCC 4 · July 2021 · 33:55

Victor Naumik develops a bottom-up design for markets in protocol parameters as a way to manage protocol risk. He moves from forwards and AMMs to gas options and the pricing of exotic derivatives with Cairo.

Speakers

Topics

From ETHCC 4, hosted by Ethereum France.

Transcript

okay hi everyone i'm on complete protocol markets by euler uh so they have two of us here uh euler engineers victor who is a co-cto at euler and myself thomas stanczyk and i'll introduce you today to the world of blockchain protocol markets prepare some construction and we'll go first through the challenges that we've seen that we see and then for some solutions that we provide okay so let's start with a question how do we value different blockchains like when you hear

somebody say that this blockchain is better than another blockchain what do you hear usually people tell about how many transactions are there per block or per day how much value is there how much how many people use it and all this different stuff that's kind of a outside perspective of value in the blockchain that you can go for example to etherscan and just check these values but what we are going to tell you today is more about how to value blockchains from the inside from the blocks perspective so i'll give the mic back to thomas

yeah so this is a big challenge possibly so first of all you want to you want to understand what what value is in the native cryptocurrency but you also want to have some view on the health of the protocol and ideally to introduce the way of trading that protocol to be able to read that within the transaction that it's in the defy defy system itself so like the d5 solution being able to understand how the environment of that defy solution behaves is it healthy does it process a lot of transactions is there value inside and if i go back a few years into when i was switching myself full time to the blockchain space

i was like taking some notes on the ideas of blockchain native derivatives and i think this is uh this is something that could be used as a name by many people for many different things uh but i try to define it for myself as something that's observable on chain when you think about the underlying of a derivative product uh it can be priced on chain not only because there is data their own chain to to price it but also because the the tooling and the algorithms are viable on chains you can execute them within the gas limit and it can be settled on chains so you have all the to link around the smart contracts uh that allows you to to use that price information to use the data from the blockchain and calculate what's the payout of the given financial

instrument and this is pretty achievable nowadays with ethereum and we'll show how uh so first we think how to get rid of this like uh being able to observe on chain uh how to get rid of the the risks of bringing data from outside of the chain so trying to go or lackless uh by first removing the any offchain oracles things that bring the data from the outside world so you you don't want to trade gas prices on chain but learn about what the gas prices are from the oracles that observe that blockchain from the outside world uh ideally so you want to have a look internally and

similarly for the transaction flows for any information about uh how how much that do we have there uh want to go on chain but even on chain you have some kind of like oracles that are wrapping some other off-chain oracles so there are there are things that are deriving its value based on some pegs or information about the value of the collateral uh simply uh the the data from the often world built to the on chain and then wrapped into a d5 protocol and then itself on chain things that does that do provide pricing like uni swap and they can be reliable they belong to the defy world but also they bring all the risks of the things like flashlights manipulation and so on so what we want to rely on is the

on-chain parameters or the engine parameters and the only parameters that are read from the protocol from the from the transaction environment from the block environment and they unfortunately also can be manipulated don't talk about it a bit today and we show also some some ways of preventing it and bring some better pricing and maybe victor will say about the work that's been done to extract that data yeah so usually like you know blockchains contains blocks which contain headers and headers contain some parameters and in ethereum you can extract the parameters from the block but the

limitation is that you can only extract the current block like difficulty or gas limit or timestamp so the problem is sometimes you need more than current blocks sometimes you need to look at the past so we developed a system that allows you to extract information from blocks back to 256 blocks in the past to use it a user needs to send a block header rlp encoded to the smart contract and then the smart contract will extract the parameters from header from llp verify and if the hash of the lp is

equals to the hash of the block then everything is correct and it's verified and proven that these parameters come from this exact block currently the limitation is last 256 blocks but there are aaps that propose to prolong it further in the past and that will be really great but currently it's this and also one more thing interesting thing that can provide internal values is from a smart contract and i want to ask you a question now what is the most important smart contract on the ethereum what are your

bingo bingo yes deposit contract so it has as you know money from ethereum deposited into this contract and this is this money is locked and kind of it brings us the thought of how people value this transition to eth2 and by observing how much value is there how quickly it grows we can observe how users really react to it too okay so now i will thomas will tell about how what was

what was in the past that enabled us to do all this that we do yeah sure so um when i think about the blockchain protocol markets uh if i say that a few years ago i was thinking about blockchain native derivatives and i was thinking about observing gas prices it was not really possible to observe gas prices without uh falling into a risk of uh of reading something that was massively manipulated by the and by the miners and also some other things were not available and this is a short path but actually last few years of uh obvious big things so amm stable coins and nowadays just around the corner on starting on fourth of august on mainnet uh the base fees are part of eip1559

so we needed all of those building blocks to be able to bring something that will be pricing for derivatives that will allow us to to trade and will allow us to to read the most important parts of the system and now let's think about this examples of the manipulation and how exactly they play out if we built uh some some products around it so for hash rate and for gas prices so hash rate after the merge after ethereum two happens does not exist anymore but it serves us as a great example of showing how we build the system how we'll build a uh something we'll show later as a forwards construction uh and uh and also like what kind of manipulation you can expect from from uh players on the

uh in the market and for gas prices similarly ip1559 changes a lot so you can no longer include any transactions of any value without bearing any costs as a miner but still after a p1559 and there are some things that can be manipulated you can simply push the base fee up or show it in a moment so as for hash rates these are these are results of the simulation that was running and it uses the actual algorithms from the protocol from the consensus in ethereum and it shows you that these charts are almost looking identical they're not identical but they show that we can use difficulty as a proxy for the hash rate so the when the

hash rate grows up the difficulty will go up when the heart rate goes down the difficulty will go down and this this is slightly delayed which we'll see but uh this example what happens if you have a miner switching off like mining pools switching off 10 percent a bigger mining pool that has 10 percent of the hash rate deciding to uh switch off their miners so they they remove the 10 percent of the hash rate and the difficulty slowly goes down over 24 hours it will adjust and will go ten percent down but what's the most important part is uh this first few hundred blocks uh they uh they cost not that much so if you look at the short term cost of the one percent drop of the difficulty it's

around 20 30 if to push it one percent down if you if you have uh like above one two percent of the um of the mining hash power then you can make some temporary adjustments to the difficulty that can manipulate the payouts based on the settlements of some derivatives that would be entirely uh traded on chain and similarly even if you would observe that from the outside of the chain you can do the same obvious and as for the gas price manipulation after eip1559 uh so you see at the bottom we have 30 blocks uh and just over 30 blocks which is 30 times 12 seconds it's uh around six minutes right over six

minutes we can push the gas prices from a base fee from 10 way to 400 so it's 40 times uh increase of the base fee and it costs around 200 thousand dollars in the nowadays ethereum value right so the cost is here really so [Music] it's uh for the temporary growth you pay around 500 per one way of the base fee growth and you can keep pushing it as long as you have money for that but obviously then the network immediately starts reverting back to the to the actual market basically so it's it's expensive but if you have settlement that is a settlement of a derivative that is relying on this value

then then it may actually bring a lot of value to whoever manipulates the price as for pushing the base fee down it requires collusion of the miners so this is less of a scenario that would be worried about because it has much wider ramifications than simply trading on d5 protocols as for deposit contract and this is particularly interesting scenario for us it's really hard to manipulate when you look at the numbers that are taken into account here so we have something like 0.7 million of eve deployed in the last month only uh so it's a huge amount of money like 1.5 billion dollars and the even like single deposit is 32 if so if we if we build the instrument that is uh

settling based on the change uh like over time changing the deposit contract value then we have quite quite reliable market that we can build uh derivative instruments on top of all right and yeah and now i will tell you how we can deal with this manipulations because as you've seen they're purely mostly just instantaneous and very short so to deal with that like the first thing that comes to mind is just averaging but as i've said we only can average 256 blocks so that's probably not enough

because you've seen the graphs and it we need more so we have two ideas two solutions right now one is just piggybacking on user transactions like when somebody trades or something we just add some instructions to store the values on chain and use it later for averaging or we also were working with a solution on cairo in contribution with starkware and it's a zero-knowledge proof of program execution so you can just push a lot of blocks there it will prove

it and contract will verify it and that way you can do averaging so right now let's uh take a break from theory and tell about the binary options this is the product we were working on for the last several months and why binary options there have many pros many cons the pros are for example that the payout is same for everyone and also they can be exercised simultaneously for everyone if just one person pushes the exercise transaction that saves a

lot of gas that saves a lot of nerves for people they don't have to monitor just it's like crowd mind pushing one transaction and that's it they're all exercised also binary options can be fully collateralized which means that for one option for example is one dollar collateral and you have no risk of overpaying if you just pay this one dollar but also there are cons for example for this fully collateralized thing it requires uh to lock capital upfront also the liquidity providers take a lot of risk here because

option no matter which price it starts like half a dollar or whatever at the end of the expiration it goes or exercisement it goes either up to one dollar or down to zero so the price never comes back to where it started so liquidity providers have a lot of losses and also there are possibilities to manipulate this amm by for example flash loans meeting a lot of options and training it against the pool so liquidity providers suffer suffer again we tried several approaches to mitigate these problems like the data functions or just raising the

fees of the pool so liquidity providers get more of the fees and traders trade like have to pay more for these manipulations but anyway we have the product we just launch it like we deployed it maybe like 15 minutes ago and you can test it right now if you go to alpha.euler.network from your mobile or laptop okay and this is for binary options and now we are working on another product which is more complicated more interesting and it's about forwards all right okay so uh with the with the binary options we

we kept talking to people who are doing market making who are trading uh ideas of cash rates and gas prices and what we kept hearing was we need to market make it we need to start with some more basic products when you start maybe futures forwards and keep building from from there to the top and also like working with the traditional finance specialists we said like okay when we start with options and and it feels a bit like everyone started with options in the in the markets in ethereum and it's it's really hard to build from there and do the proper market making so we introduced the construction of forwards so agreements to buy or sell something in the future at the pre-agreed price so we're talking here

about buying or selling hash rate or gas prices or even more interesting buying or selling the validators count which if you think about a belonger gives you the ability to switch like the the floats to fixed on your exposure to the validators uh yield on if two deposits so how do we construct the forwards first we'll start with the idea of the lambda which is simply the exponent of the of the function that represents the forward price uh so so we just showed that for the hash rate we have the hash rate growth which is representing a bit of the technological progress over time right so you you assume that the hash rate is growing slowly over time because of gpu is

getting faster because of asics being introduced to the market that are more efficient and so on and so on and these lambda can be higher or lower than you'll have faster growth lower growth if lambda is negative which can be then it will be a fall of hash rate over some periods of time when you actually have the the market slowly withdrawing from from interior space and now if you look at the historical lambdas on ethereum so looking uh something every single block in the past looking at difficulty as we said is good proxy for hashrate rate those monthly lambdas uh like were somewhere between minus eighty percent plus eighty percent

and uh recently they are stabilized over the last two years in between like twenty pl uh minus 0.2 plus 0.2 so you would expect that over a month the hush rate will grow around up to around 20 percent 25 percent something like that and if you look at the daily lambdas again their uh their mean over time is around zero and they probably go up or down around five percent during the day the hash rate uh with obviously some standard deviations and some some extreme movements uh over time uh but what is important is that lambda itself is normally distributed and the hash rate itself as a result is log normally distributed and we can start building products based on that

knowledge and we use something for pricing lambda so what we introduce is will be ammm so the automatic pricer but what we'll be pricing will be pricing lambda itself so the same way as you trade if versus usd and if you buy if then the price of if expressed in usd goes up if you sell if then it goes down what we'll be doing here is if you'll be going long forward so if you'll be going long hash rate one month from now then the lambda will move up so you'll be just pushing up this function the exponential function and then if you're selling so if you shorting your uh position uh forward position then the lambda will go be going down while we do

that because similarly like in traditional amms we want the pull to not move far away from the initial price because this is the most efficient thing for the liquidity providers they can collect fees at the same time without getting too much risk exposure in any direction and the way we price lambda is we we just apply a tangent function that will allow us to move it uh to slide it between negative and positive infinity uh and the way we build it is by introducing something we call a m automatic nft maker so each time you uh you buy forward or sell it forward what happens is we are minting an nft that represents the contract the forward contract and that

nft has to be collateralized and it represents your forward position and the pull itself adjusts the lambda and in a way invites the market to trade against this position so if someone goes long the lambda goes up and you try to do the market making you apply the spread and it'll be short short long short long positions and one very very important thing is the constant maturity on the pool so um what we've seen that was a big problem with any of the polls that are trading the derivatives was that very often they were trading something that was expiring right so so you would have an expiring uh instrument that has like one month from now and then the pool closes and you have this massive volatility towards the

close uh what we do is like whenever you mean the forward in that pool is always one month from now so it's not some date one month from now and then we're getting closer and closer to it like after some time it will be just one week to expiry what happens is like every time you trade on this pool you're taking a forward position that is one month from now or if the ten or the maturity of the pull is different it can be one week or one day and the longer the uh the tenor the bigger there is the exposure to the lambda function change and the shorter the more you're expressing the risk of the spot hash rates changing how it's settling like so for any of the

blockchain protocol parameters so they are not really deliverable so if you think about hash rate or gas prices most of you think you imagine that you cannot deliver those there are some solutions for physical delivery of hash rate or maybe like gas tokens for physical delivery of gas but what we do is just introduce the cash settled forwards where you trade the difference between the pre-agreed difficulties expressing hash rate and the actual harsh rate as it happens on the settlement date cool so as we said there is a collateralization requirement for the for the trades that are entering the space so any any trader who'll be trading against the pool will have a

requirement for the uh for posting collateral for whether you're going long or short you need to ensure that uh that you won't be liquidated so the protocol will be uh will be ensuring that the liquidations may happen if you're under collateralized or of this is uh it's just calculated to see depending on the what probability you want to have to cover all the potential harsh rate movement uh this will be wider or more narrow branch and and this is also related to the former volatility of the of the lambdas so again because because of uh either either we can approach it but slowly collecting the data uh as we mentioned before by piggybacking on orders like the same way as many protocols are doing that or we can start

using the uh cable proofs to bring to the chain uh data like once per day to refresh the volatilities to refresh the past averages uh to to the more complex calculations of the of the products that are built on top of it so this is morocc as a visualization for for like long term discount the shape looks on the right side this is actual numbers with the one month one month lambdas they look almost linear but this is actually this exponential function and again what what are the two types of risks one is the lambda change so the change in the

actual like long-term behavior of the of the curve how the heart rate changes over time the second thing is the spot change risks uh so this is the uh short term hash rate drops like immediate reaction to the market the market change of the difficulty and uh and practically this is this is the kind of risk that the pool acquires if somebody trades against the pulse so the liquidity provider has exposure to these risks and they have to uh through the pool there is a requirement to really manage the spot change risk uh and one approach to that is to uh combining two pulls together one would be with one month uh one month ten or the other one will be one day or one hour some very short

term expiries and and hedging one with the other uh how the pool liquidity behaves so first of all we have to think of the pull liquidity nowadays so as it is like you start a pool you provide liquidity of a few million usdc for example and that liquidity is available to ensure the collateralization of any trades that are happening from uh on behalf of traders but there is also like a future liquidity of the poll that we can think of whenever we start trading then there'll be some unsettled forwards uh that we can start projecting of what the payouts will be so we can extrapolate the current lambda calculations we can

calculate uh how much time to expiry they have and we can plan what really will be the liquidity that will be available for collateralization of the trades that happen afterwards and the way we calculate the price the the lambda of the amm is ideally is based on the future liquidity because we want to make sure that the pool doesn't acquire more and more exposure as it cannot really uh collateralize this positions we can use as a proxy now the current liquidity but ideally we we pre-calculate all of those like er every now and then i mean like we can recalculate all the open positions so

every single forward is open do the projections on the current lambdas and see what exactly the pull position is and again this can be calculated every now and then with clear resolutions what we can build on top of it so having having built this construction uh we can also start to do trading of different types of parameters so we not only can trade lambda but we can start trading some parameters that uh that are proper representations of the of the volatility in the market and having had built the uh forwards construction and the volatility that you would trade you can start actually recreating the exposures uh

that you have when you trade options and this starts to properly introduce the basic building blocks for the derivatives markets uh on the protocol and potentially not only on the protocol parameters but later on any digital assets and yeah please visit alphatoiler.network uh please see the binary options solutions and i think the forward solution should be there uh pretty soon i think uh also there will be a follow-up paper like research paper describing this forward construction coming soon and yeah we're open to any questions from the audience [Applause] what would be the common use cases for

this uh-huh so you can think of the i mean when you think about the hash rate so this would be a minor potentially rolling their position to have the predictable cash flows because with the constant maturity of one month you can simply keep rolling the contract every every month so you uh you enter long position and then you after one month you settle it and you enter another position and so on so on so you have a rolling contract so it's all about managing cash flows if you have exposure to hash rate so if you're a miner the for the gas price similarly if you have the exposure to the regular big gas price payments so think of some exchanges that will have uh massive

withdrawals like month monthly withdrawals some kind of predictable pattern of withdrawals that they can measure you can start building some more predictable cash flows you can hedge your future costs of withdrawals future costs of gas payments so there's lots of defy protocols that have regular payouts or or miners mining pools paying out the the rewards among the all the pool participants and so on so on so you create the market for uh for all the institutional clients that need to have uh more predictable cash flow so this is what in traditional finance what so you have traditional user of the market which is someone who participates in the operation that is having direct exposure

to those parameters and as for uh as for the deposits if deposit this creates also the market of a capital market when you want to move between the the like floating or fixed exposure between like you you set up validators and you don't know really how many more validators will be coming to the network uh so you want to uh you want to offset that uncertainty you want to hedge it and remove it and you say okay so i know what my cash flows will be from setting up the validators so you can have like a bit more predictable costs uh for for ranging operations and the revenue flow cool that's good do you guys have a token or something yeah actually yes there is the oil token for the other project

so just a quick question uh so this is only about gas prices or cash rates or same for a wider options derivatives and also all that yeah so we like our niche our place is everything that is related to protocols so it's things that are measurable on protocol which would be potential gas limits like the block sizes maybe as ethereum 2 appears maybe like the health of the the sharding solutions things related to deposits the helpful validators behaviors how many slashings are happening gas prices so many of those parameters will have a direct financial uh effect on operations

on many market participants whether they are like uh if someone is running a form of validators so like 2000 validators and they want to protect themselves against slashing so everything that's observable from the chain related to the health of the chain uh this is this is what we're going to explore i want to produce the deliver the products around this we're starting with the harsh rate gas prices and pollinators so so not uh external data fed by oracles yeah so to to avoid to avoid any oracle sector okay got it thank you so you can as well make an insurance market uh yeah so like when whenever you talk about options derivatives so when you think about hedging the risk so you start to think that this is insurance market in a

way uh and then it's it's all automated so it's not like the mutual insurance as you would see with nexus but i know that there are some other solutions with the insurance now that it's more algorithmical uh so so yes but this is algorithmical hedging your risks so in this way it is insurance but we wouldn't call it insurance uh great talk i have a question do you have any plans for layer 2 derivatives like amount of call data posted from let's say arbitrary more optimism to layer one yes like this is this naturally extending to both the side chains and layer two so uh if you think that uh something works

on magnet there are some particular parameters that are important for for side chains behaviors imagine that you that you want to participate in some side chain operations uh let it be x die or other solution so you want to make sure that there is no event that would normally be treated as something something very risky for the for the chain similarly for the layer 2 you may want to try predicting of how popular the layer 2 behaves like start to monitor the the amount of settlements of particular protocol on on layer one or yeah analyze the batches flowing from from layer two whether it's dark or other solution again

so something it all falls under this thank scheme [Applause] you