# netting smaller Purpose: a scaffold of a potential model to guide a rough framework to think about the complicated process of building a new model **Model Definitions **First we need to outline all the variables (this is nice and long ) EthTvl> tvl in eth vault UsdcTvl> tvl in uscc vault BtcTvl > tvl in btc vault R= ratio of external to internal hedges // vault specific buffer factor and how these change needs to be added BA=buffer adjust= x (0-1 buffer factor) LA=leverage adjust= x (0-1 levearge factor) Glp= mkt glp GlpE (eth Vault glp) GlpU (usdc vault glp) GlpB (btc Vault glp) GC (glp composition) GE (eth weight in glp)= ( glpE+ethWeight*mktGlp)%(mktGlp+glpE+GlpS+GlpB) GB (btc weight in glp)= ( glpB+btcWeight*mktGlp)%(mktGlp+glpE+GlpS+GlpB) GS (stable weight in glp sum of usdc frax tether dai weights)=( glpS+stableWeight*mktGlp)%(mktGlp+glpE+GlpS+GlpB) GL (Link weight in glp)= LinkWeight*Glp GU (uni weight in glp)= uniWeight*Glp (when we add alt vaultsGL and GUni becomes like GE etc ie a function of current GLP + the incremantal GLP bought by the vault ie ( glpL+linkWeight*mktGlp)%(mktGlp+glpE+GlpU+GlpB+glpL) ) Composition adjust SE=slippage factor eth vault = f(1- GlpE/(Glp+GlpE+GlpU+GlpB)) SU=slippage factor usdc vault = f(1- GlpU/(Glp+GlpE+GlpU+GlpB)) SB=slippage factor btc vault = f(1- GlpB/(Glp+GlpE+GlpU+GlpB)) Deltas (we can produce deltas and hedge with internal or a perp) EthD BtcD LinkD UniD Perps EthP BtcP LinkP UniP EthC> capital deployed to margin perp>EthC(btc)> capital deployed for eth hedges for the btc vault (subscript to help ) BtcC> capital deployed to margin perp LinkC> capital deployed to margin perp UniC> capital deployed to margin perp Internal Hedges EthI BtcI LinkI UniI EthIC> capital deployed to margin interals (can be 0)>EthCI(btc)> capital deployed for eth hedges for the btc vault (subscript to help ) BtcIC> capital deployed to margin interals LinkIC> capital deployed to margin interals UniIC> capital deployed to margin interals vault deltas produced glpU=UD (usdc deltas)= btcD=-GB*GlpU linkD=-GL*GlpU* uniD=-GU*GlpU ethD=- GE*GlpU (are we doing anything with stable depeg?) glpE=ED (eth deltas)= btcD=-GB*GlpE linkD=-GL*GlpE uniD=-GU*GlpE ethD=(GB+GL+GU+GS)*GlpE glpB=BD (btc deltas)= ethD=-GE*GlpB linkD=-GL*GlpB uniD=-GU*GlpB btcD=(GS+GL+GU+GE)*GlpB Constraints (what we want to solve) TVL deployment ( we use all our tvl) UsdcTvl*BA=EthC(Usdc)+BtcC(Usdc)+LinkC(Usdc)+UniC(Usdc)+GlpU+EthCI(Usdc)+BtcCI(Usdc) EthTvl*BA=EthC(eth)+BtcC(eth)+LinkC(eth)+UniC(eth)+GlpU+EthCI(eth)+BtcCI(eth) BtcTvl*BA=EthC(btc)+BtcC(btc)+LinkC(btc)+UniC(btc)+GlpU+EthCI(btc)+BtcCI(btc) Second Leverage Constraint (face value of hedges and glp is within bounds of tvl) UsdcTvl*(1+LA)>= EthC +BtcC+LinkC+UniC+EthI+BtcI+GlpU EthTvl*(1+LA)>= EthC +BtcC+LinkC+UniC+EthI+BtcI+GlpE BtcTvl*(1+LA)>= EthC +BtcC+LinkC+UniC+EthI+BtcI+GlpB Delta Constraints (each asset) USDC Vault slippage adjusted hedges = glp owned by vault * asset composition factor SU*ethC(Usdc)+SU*ethI(Usdc)= -GE*glpS =ethD(usdc) SU*btcC(Usdc)+SU*btcI(Usdc)= -GB*glpS =btcD(usdc) SU*LinkC(Usdc)+SU*LinkI(Usdc)= -GL*glpS =linkD(usdc) SU*UniC(Usdc)+SU*UniI(Usdc)= -GU*glpS =uniD(usdc) eth Vault slippage adjusted hedges = glp owned by vault * asset composition factor SE*ethC(Eth)+SE*ethI(Eth)= (1-GE)*glpE SE*btcC(Eth)+SE*btcI(Eth)= -GB*glpE SE*LinkC(Eth)+SE*LinkI(Eth)= -GL*glpE SE*UniC(Eth)+SE*UniI(Eth)= -GU*glpE btc Vault slippage adjusted hedges = glp owned by vault * asset composition factor SB*ethC(btc)+SB*ethI(btc)= -GE*glpB SB*btcC(btc)+SB*btcI(btc)= (1-GB)*glpB SB*LinkC(btc)+SB*LinkI(btc)= -GL*glpB SB*UniC(btc)+SB*UniI(btc)= -GU*glpB max glp ownership sbuject to glp ownership having a positive yield expectation E[glpYield]*T > E[openingCosts]+E[fundingCosts]*T +E[closingCosts]%(1+E[glpYield-fundingCosts]*T) T is a time horizon hyperparmeter A conservative point here is to just use glpYield in the constraint and not include E[traderLoses] E[glpYield]= EWMA on GLP yield history ? or min yield over some lookback E[fundingCosts]= either EWMA on funding or max funding over some lookback? We can also add to the rhs something like E[aave yield] ie the glp yield post netting needs to not just be + but better than the a easy substitution source? **Fitting deltas**- This tells you the deltas you want to execute (it doesnt execute it just tells you what you would like to), we probably combine and simplify these steps but lets agree on a logic framework first 0- Work out which way each vault needs to fit (ie buy or sell glp) post rebalance and withdrawls/deposits. This isnt needed in the initial fit but after we start rebalancing it needs to be done. We first want to compare tvl post buffer of each vault compared to its open positions using the leverage checks to compare whether vaults need to buy or sell glp and hedges (the below is written for buying but we could have the case of 2 vaults buying and 1 vault selling ie reversing sign) The reason why we want the rebalancing effect here is to extract as much netting as we can. Leverage checks we can use are in steps 10-12 1-First we set a step size SS=step size = defines an equal increment of glp that each vault will try and purchase and then see if it can hedge that increment of deltas. max(a, (min (EthTvl, btcTvl,usdcTvl))%x)) max(a, (min ( btcTvl,usdcTvl))%x)) max(a, (min ( btcTvl))%x)) a is the exit size ie when tvl gets trained such that stepsize a doesnt work the fit is done x is % tvl post buffer reduction that you try and buy glp with and hedge for each vault N vaults will use there availabe tvl at differnt paces so each time you exit because of A you restart with a new constraint wrt to the N-1 vaults (note we cant just sort by tvl as a higher tvl vault may have higher external hedging costs and drain first) 2-Get the latest vault TVL that is free to allocate to the strategy. Ie at iniation this is tvl reduced by buffer (For all below assume this is the case). At this step we also need to account for changes in vault assets due to rebalaning these are not tvl to spend this is new hedges and glp that contribute to a glp+ delta equation we want to flatten usdcTvl(i)=usdcTvl(i-1)-SS ethTvl(i)=ethTvl(i-1)-SS btcTvl(i)=btcTvl(i-1)-SS newGLP (additional glp from rebalancing) and new hedges usdcGlp ethGlp btcgLp 4- buy a step size of glp for each vault 4- adjust glp compostion weights for the purchases this is a 3 vault setup for 5 vaults GL and GU goes in the denominator GE (eth weight in glp)> ( glpE+ethWeight*mktGlp)%(mktGlp+glpE+GlpS+GlpB) GB (btc weight in glp)> ( glpB+btcWeight*mktGlp)%(mktGlp+glpE+GlpS+GlpB) GS (stable weight in glp sum of usdc frax tether dai weights)>( glpS+stableWeight*mktGlp)%(mktGlp+glpE+GlpU+GlpB) GL (Link weight in glp)> LinkWeight*Glp GU (uni weight in glp)> uniWeight*Glp 5- calculate hedge ratios and vault deltas needed at this point glpU=UD (usdc deltas)= -GB*GlpU -GL*GlpU -GU*GlpU - GE*GlpU = -btcD(usdc) -linkD(usdc)-uniD(usdc)-ethD(usdc) glpE=ED (eth deltas)= -GB*GlpE -GL*GlpE-GU*GlpE +(GB+GL+GU+GE)*GlpE = -btcD(eth) +linkD(eth)-uniD(eth)-ethD(eth) glpB=BD (btc deltas)= -GE*GlpB -GL*GlpB-GU*GlpB +(GU+GL+GU+GE)*GlpB = -ethD(btc) -linkD(ntc)-uniD(Btc)-btcD(Btc) 6- (not on iniation this step is 0), this step is how you calulcate the incremetnal delta change to the T-1,2,3,4,N fits for the new glp purchased USDC Vault ethD=GE(timeT)-GE(timeT-1)*(glpU-ss*glp) ie the glp we already purchased adjust for the change in ratios btcD=GB(timeT)-GB(timeT-1)*(glpU-ss*glp) linkD=GL(timeT)-GL(timeT-1)*(glpU-ss*glp) uniD=GU(timeT)-GU(timeT-1)*(glpU-ss*glp) eth Vault ethD=(1-GE(timeT)-GE(timeT-1))*(glpE-ss*glp) ie the glp we already purchased adjust for the change in ratios btcD=GB(timeT)-GB(timeT-1)*(glpE-ss*glp) linkD=GL(timeT)-GL(timeT-1)*(glpE-ss*glp) uniD=GU(timeT)-GU(timeT-1)*(glpE-ss*glp) btc Vault ethD=GE(timeT)-GE(timeT-1)*(glpB-ss*glp) ie the glp we already purchased adjust for the change in ratios btcD=(1-GB(timeT)-GB(timeT-1))*(glpB-ss*glp) linkD=GL(timeT)-GL(timeT-1)*(glpB-ss*glp) uniD=GU(timeT)-GU(timeT-1)*(glpB-ss*glp) 7- add the deltas from 6 to the deltas from 5 and get full deltas 7- check what nets amongst hedges eg for eth NettingE= abs min(abs eth longs,abs eth shorts) Nettingb= abs min(abs btc longs,abs btc shorts) (this is the + notional value of internal netting we can do in a asset) 8- pro rata netting to each vault based on TVL (so when a vault runs out of tvl we cant net which makes sense ) usdcBtcShare= usdcTvl% (usdcTvL+ethTvl) ethBtcShare= ethTvl% (usdcTvL+ethTvl) usdcEthShare= usdcTvl% (usdcTvL+BtcTvl) btcEtcShare= ethTvl% (usdcTvL+BtcTvl) NettingE*usdcEthShare = usdcd vault internal eth hedge= EthI(usdc) NettingE*btcEthShare = btc vault internal eth hedge= EthI(btc) NettingB*usdcBtcShare usdc vault internal btc hedge= EthI(usdc) NettingB*ethBtcShare = eth vault internal btc hedge= EthI(eth) 9- subtract internal hedges from vault deltas needed also record internal hedges (this is probly a big maxtrix for each vault where each row is a new calibration and each column an asset, glp, internal hedges, external hedges ) ie usdc vault = -btcD(usdc) -linkD(usdc)-uniD(usdc)-ethD(usdc) +ethI +btcI 10- perpetuals to hedge balance of the delta equation and compute the cost of hedges with slippage and drain tvl to allocate by cost of hedges ie usdcTvl(i)= usdcTvl(i-1) -1*( EthC+btcC+uniC+linkC) ethTvl(i)= ethTvl(i-1) -1*( EthC+btcC+uniC+linkC) btcTvl(i)= btcTvl(i-1) -1*( EthC+btcC+uniC+linkC) We need a sanity check if tvl goes negative (then you need to go back to the start and reduce the step size and see if you can drain a smaller amouint of tvl to allocate) Sanity check usdcTvl(i)>0 11- Positive yield expectation: is the increment we buy expected to make money if not dont do it (ie stop) E[glpYield]*T > E[openingCosts]+E[fundingCosts]*T +E[closingCosts]%(1+E[glpYield-fundingCosts]*T) 11- second leverage check - note here the tvl is the full deposits not the tvl re incrmetnally decrease in the loop (apols i re used subscipt like a idiot) ill specify that this is tvl at i =0 ie start of fit ) UsdcTvl(i0)*(1+LA)>= EthC +BtcC+LinkC+UniC+EthI+BtcI+GlpU EthTvl(i0)*(1+LA)>= EthC +BtcC+LinkC+UniC+EthI+BtcI+GlpE BtcTvl(i0)*(1+LA)>= EthC +BtcC+LinkC+UniC+EthI+BtcI+GlpB if any of these fail go back to start and reduce step size ie SS= SS%x 12 ratio of external to internal hedges per vault E= sum of notional value of perpetual positions for a vault I= sum of notional for internal netting for each vault E%I>threshold This is a check per vault if this fails exit the fit This is what you asked to add but lets discuss as i think + yield of glp might work better 13- We are now hedged for deltas for our new glp we have new tvl for the loop (not the leverage check) and we go back to 1 and start again **Rebalance Process (delta fit is part of it)** Position tracker: ( i think you might need a full position tracker to do fees properly as its not as simple as glp owned and weights as slippage per vault matters)- So i think for each vault position tracker takes the output of delta fit ie (glp, internal hedges , external hedges, glp compostion ) 1- Assign Fees to each vault for last epoch for funding based on perp positions (ie use t-1 ownership) and use the fee charge to top up the margin that will have been depleted from funding - are we doing funding on internal trades? care fees on topping 2- assign pnl to perp hedges for each vault and internal hedges use the gmx spot oracle change to calulate pnl (spot oracle T-T-1) also look at your change in margin ethC(T)-ethC(T-1) is the charge each vault needs to pass back this probably needs logic on once margin goes below x% of full margin top up ( is it fee per position or can we top up multiple positions) also the margin top up needs to look at net margin over vaults ie Internal hedges the mtm each vault needs to settle (note at this point we still dont trade anything) each vault can pass GLP and useful hedges to settle thier balance. There are multiple ways to settle ione way is if pass glp and all associated hedges to the new vault ie the btc vault passes glp eth short uni short link short and btc long to the usdc vault (the logic being we do a group delta calculation and its cheaper to change perp hedges than it is to burn glp and we dont want to deal with a vault having too much glp?) This part needs work can we do better than the above ie something like look at difference in weights of the uncommon hedges to pass weight neutral baskets eg weightBtc and weight eth difference ie whats the cheapest way to pass is it cheaper to have 2 slightly inblanced vaults than one balanced and one inbalanced 3- run delta model above with the fee adjusted tvls to allocate post buffer and the rebalance changes in position 4- now you have the snapshot of what needs to change to be inline ie the difference in perp positions between T, T-1 and the difference in overall glp ownership **Executing the deltas** 1- compare the asset distribution change for vaults - you dont actually need interal netting hedges as by definition we are aligned for the next cycle for those So USDC Vault- owns glp +ethP+btcP+uniP+linkP eth Vault- owns glp +ethP+btcP+uniP+linkP btc Vault- owns glp +ethP+btcP+uniP+linkP So we compare the difference in GLP sums and the difference in Perp positions ie ethP(T)-ethP(T-1) GLP(T)-GLP(T-1) etc This gives what we want to adjust in terms of GLP and perps One thing to think on is we may be doing a perpetual adjustment to move trades into internal netting but we could chose to keep a long pos and short pos open in the same perp (ie if funding is low and closing costs high). We might want to add a sanity check here as a fee reduction tool need to think on the right check ? 2- Execute the trades (order matters) 1- execute anything we need to sell/burn (this way we top up buffers get asset to do stuff with) 2- execute everything we need to buy/mint and pay withdrawals other thoughts The above is missing how we charge fees on new deposits and withdrawals Buffer need some logic around buffer float for new deposits we need a lock or fee mechanism (ie new deposits let us net but its bad if we close a bunch of positions and then people withdraw and we re open) reduce fees on vaults you want people to enter?? scaling strategies use treasury for weak vault build alt vaults aswell and maybe use treasury to seed (and do options elsewhere?? is that possible) Uni/Link Vault capacity Purpose: Correlation hedging: they will need to be a back stop to generate a way to hedge once alt coin liquidty runs out and we still want to externally hedge LinkD UniD needs to be turned into a delta we can execute eg ethD So we need a method to transform deltas below is an outline to one hypotethical framework we can base around (its not neccasrily the best solution it is one solution and a guide) 1- Decision rule on when this occurs (can re use cost constraint model) or it can be a static rule based on link/uni liquidity availabe on gmx (ie we know their margin rule we can define wrt to that). Some example decsion rule policies Rules 1. ie there is only x % left to the gmx rule banning new hedges in link so we dont make new link hedges 1. funding +opening fees > x 1. the cost constraint above where we estimated E[yield]-E[Costs], this one isnt static 2- To move to a correlation hedge we need to define a hedge ratio p*sigma(asset1)%*sigma(asset2) ie eth and link are 0.6 correlated and eth standard deviation is 15% and link 30% 0.6*(0.30%0.15) = 1.2 so for every 1 usd of link we need to buy 1.2 units of eth so now we have a way to turn linkD to ethD ie linkD*p*(link sigma % eth sigma) 3- important point p, and sigma are forward estimates so you need a model to estimate, some ideas 1. use our data and pick some static numbers, pros is simple, cons its a bad model 1. use some moving average, ewma etc of vol and correlation, pros it adjusts to changes in vol, cons its a bit harder to implement 1. build a corr and vol prediciton model that has oos good r squared- pros its the right way, cons we dont have time 2. if their is a vaguely liquid options mkt somewhere we can use implied corrs So its probably 1 or 2 4- Once you have eth hedges to execute you also need to adjust your eth hedges wrt to glp ownership of the corr asset vault (link or uni) eg GE (eth weight in glp)> ( glpE+ethWeight*mktGlp)%(mktGlp+glpE+GlpS+GlpB+GlpU+GlpS) -GE*glpL ie we get deltas and givel the eth composition weight in the index and the glp owned by the link vault we get a further adjustment to external deltas (We need to execute a bit more as the hedge is against our self) 5- this then give and ethDelta we can substitute in for link or uni Summary Thoughts conceptual point do we track this as a link hedge made up of eth (ie sperate to the other eth hedges). I think we might need to the hardest bit is how to estimate vol and p, the second hardest bit is the decision rule of where to do this (it needs to go in the delta model), probably pre fitting we chose whether we try and fit link or uni external or corr hedges based on a rule and the third hardest is slightly modifying the detla fit but with the conversion above it not hard the delta fit basically just pretends link is eth based on the corr adjust