Position constructing
E V ā e q u i t y Ā v a l u e ; D V ā d e b t Ā v a l u e ; P V ā s u m Ā v a l u e Ā o f Ā a s s e t s Ā i n Ā l i q u i d i t y Ā p o o l Ā , a s s o c i a t e d Ā w i t h Ā p o s i t i o n ; C ā c o l l a t e r a l Ā v a l u e ; l ā l e v e r a g e ; S ā c u r r e n t Ā a s s e t Ā p r i c e ; S 0 ā a s s e t Ā p r i c e Ā a t Ā p o s i t i o n Ā o p e n i n g ; r B ā b o r r o w i n g Ā r a t e ; r Y ā y i e l d Ā f a r m i n g Ā r a t e ; T ā t i m e Ā f r o m Ā o p e n i n g ā
ā B o t t o m Ā i n d e x e s Ā c o r r e s p o n d Ā t o Ā 1 ā² s t Ā a n d Ā 2 ā² n d Ā s u b ā p o s i t i o n s EV - equity\ value;\\ DV - debt\ value;\\ PV - sum\ value\ of\ assets\ in\ liquidity\ pool\ , associated\ with\ position;\\
C - collateral\ value;\\
l - leverage; \\
S - current\ asset\ price; S_{0} - asset\ price\ at\ position\ opening;\\
r_{B} - borrowing\ rate; r_{Y} - yield\ farming\ rate;\\
T - time\ from\ opening\;
\\
\\
Bottom\ indexes\ correspond\ to\ 1'st\ and\ 2'nd\ sub-positions E V ā e q u i t y Ā v a l u e ; D V ā d e b t Ā v a l u e ; P V ā s u m Ā v a l u e Ā o f Ā a sse t s Ā in Ā l i q u i d i t y Ā p oo l Ā , a ssoc ia t e d Ā w i t h Ā p os i t i o n ; C ā co ll a t er a l Ā v a l u e ; l ā l e v er a g e ; S ā c u rre n t Ā a sse t Ā p r i ce ; S 0 ā ā a sse t Ā p r i ce Ā a t Ā p os i t i o n Ā o p e nin g ; r B ā ā b orro w in g Ā r a t e ; r Y ā ā y i e l d Ā f a r min g Ā r a t e ; T ā t im e Ā f ro m Ā o p e nin g B o tt o m Ā in d e x es Ā corres p o n d Ā t o Ā 1 ā² s t Ā an d Ā 2 ā² n d Ā s u b ā p os i t i o n s 1'st subPosition (borrowing notional)
D V 1 = C 1 Ć ( l ā 1 ) Ć e x p { r B 1 Ć T 365 } ; P V 1 = C 1 Ć l Ć S S 0 ; F a r m i n g Y i e l d V a l u e 1 = C 1 Ć l Ć e x p { r Y ā¾ Ć T 365 } ; D e l t a 1 = ā E V 1 ā S = ā P V 1 ā S = C 1 Ć l Ć 1 2 S Ć S 0 DV_{1}=C_{1}\times(l-1)\times exp\{\frac{r_{B1}\times T}{365}\};\\
PV_{1} = C_{1} \times l \times \sqrt{\frac{S}{S_{0}}};\\
Farming Yield Value_{1} = C_{1} \times l \times exp\{\frac{\overline{r_{Y}}\times T}{365}\};\\
Delta_{1} = \frac{\partial{EV_{1}}}{\partial{S}} = \frac{\partial{PV_{1}}}{\partial{S}} = C_{1} \times l \times
\frac{1}{2\sqrt{S\times S_{0}}} D V 1 ā = C 1 ā Ć ( l ā 1 ) Ć e x p { 365 r B 1 ā Ć T ā } ; P V 1 ā = C 1 ā Ć l Ć S 0 ā S ā ā ; F a r min g Yi e l d Va l u e 1 ā = C 1 ā Ć l Ć e x p { 365 r Y ā ā Ć T ā } ; De lt a 1 ā = ā S ā E V 1 ā ā = ā S ā P V 1 ā ā = C 1 ā Ć l Ć 2 S Ć S 0 ā ā 1 ā 2'nd subPosition (borrowing asset)
D V 2 = C 2 Ć ( l ā 1 ) Ć e x p { r B 2 Ć T 365 } Ć S S 0 ; P V 2 = C 2 Ć l Ć S S 0 ; F a r m i n g Y i e l d V a l u e 2 = C 2 Ć l Ć e x p { r Y ā¾ Ć T 365 } ; D e l t a 2 = ā E V 2 ā S = ā P V 2 ā S = C 2 Ć l 2 S Ć S 0 ā C 2 Ć ( l ā 1 ) S 0 Ć e x p { r B 2 Ć T 365 } ; DV_{2}=C_{2}\times(l-1)\times exp\{\frac{r_{B2}\times T}{365}\} \times \frac{S}{S_{0}};\\
PV_{2} = C_{2} \times l \times \sqrt{\frac{S}{S_{0}}};\\
Farming Yield Value_{2} = C_{2} \times l \times exp\{\frac{\overline{r_{Y}}\times T}{365}\};\\
Delta_{2} = \frac{\partial{EV_{2}}}{\partial{S}} = \frac{\partial{PV_{2}}}{\partial{S}} = \frac{C_{2} \times l}
{2\sqrt{S\times S_{0}}} - \frac{C_{2}\times (l-1)}{S_{0}}\times exp\{\frac{r_{B2}\times T}{365}\}; D V 2 ā = C 2 ā Ć ( l ā 1 ) Ć e x p { 365 r B 2 ā Ć T ā } Ć S 0 ā S ā ; P V 2 ā = C 2 ā Ć l Ć S 0 ā S ā ā ; F a r min g Yi e l d Va l u e 2 ā = C 2 ā Ć l Ć e x p { 365 r Y ā ā Ć T ā } ; De lt a 2 ā = ā S ā E V 2 ā ā = ā S ā P V 2 ā ā = 2 S Ć S 0 ā ā C 2 ā Ć l ā ā S 0 ā C 2 ā Ć ( l ā 1 ) ā Ć e x p { 365 r B 2 ā Ć T ā } ; Delta-neutrality condition
D e l t a = D e l t a 1 + D e l t a 2 ; D e l t a = l Ć ( C 1 + C 2 ) 2 S S 0 ā C 2 Ć ( l ā 1 ) S 0 Ć e x p { r B 2 Ć T 365 } ; Delta = Delta_{1} + Delta_{2};\\
Delta = \frac{l \times (C_{1}+C_{2})}{2\sqrt{S S_{0}}} - \frac{C_{2}\times (l-1)}{S_{0}}\times exp\{\frac{r_{B2}\times T}{365}\};
De lt a = De lt a 1 ā + De lt a 2 ā ; De lt a = 2 S S 0 ā ā l Ć ( C 1 ā + C 2 ā ) ā ā S 0 ā C 2 ā Ć ( l ā 1 ) ā Ć e x p { 365 r B 2 ā Ć T ā } ; Taken Delta = 0 at opening (T=0):
that's why we put N/4 in first subPosition and 3N/4 in second.
C 1 C 2 = l ā 2 l \frac{C_{1}}{C_{2}} = \frac{l-2}{l}
C 2 ā C 1 ā ā = l l ā 2 ā Generalized equation for delta of positionā
D e l t a = C Ć l 2 S 0 Ć ( S 0 S ā e x p { r B 2 Ć T 365 } ) Delta = \frac{C \times l}{2S_{0}}\times(\sqrt{\frac{S_{0}}{S}} - exp\{\frac{r_{B2}\times T}{365}\}) De lt a = 2 S 0 ā C Ć l ā Ć ( S S 0 ā ā ā ā e x p { 365 r B 2 ā Ć T ā }) Rebalancing
Definitions in terms of typical LYF-protocol interface (Tulip, Francium, Alpaca, Tarot)
P o s i t i o n Ā 1 ā p o s i t i o n Ā w i t h Ā b o r r o w e d Ā s t a b l e c o i n ; P o s i t i o n Ā 2 ā p o s i t i o n Ā w i t h Ā b o r r o w e d Ā a s s e t ; P V 1 ā p o s i t i o n Ā 1 Ā v a l u e Ā ( i n Ā s t a b l e c o i n s ) ; Ā D V 1 ā p o s i t i o n Ā 1 Ā d e b t Ā v a l u e Ā ( i n Ā s t a b l e c o i n s ) ; P V 2 ā p o s i t i o n Ā 2 Ā v a l u e Ā ( i n Ā a s s e t Ā q u a n t i t y ) ; Ā D V 2 ā p o s i t i o n Ā 2 Ā d e b t Ā v a l u e Ā ( i n Ā a s s e t Ā q u a n t i t y ) ; S ā s p o t Ā p r i c e ; Position\ 1 - position\ with\ borrowed\ stablecoin;\\
Position\ 2 - position\ with\ borrowed\ asset;\\
PV_{1} - position\ 1\ value\ (in\ stablecoins);\ DV_{1} - position\ 1\ debt\ value\ (in\ stablecoins);\\
PV_{2} - position\ 2\ value\ (in\ asset\ quantity);\ DV_{2} - position\ 2\ debt\ value\ (in\ asset\ quantity);\\
S - spot\ price; P os i t i o n Ā 1 ā p os i t i o n Ā w i t h Ā b orro w e d Ā s t ab l eco in ; P os i t i o n Ā 2 ā p os i t i o n Ā w i t h Ā b orro w e d Ā a sse t ; P V 1 ā ā p os i t i o n Ā 1 Ā v a l u e Ā ( in Ā s t ab l eco in s ) ; Ā D V 1 ā ā p os i t i o n Ā 1 Ā d e b t Ā v a l u e Ā ( in Ā s t ab l eco in s ) ; P V 2 ā ā p os i t i o n Ā 2 Ā v a l u e Ā ( in Ā a sse t Ā q u an t i t y ) ; Ā D V 2 ā ā p os i t i o n Ā 2 Ā d e b t Ā v a l u e Ā ( in Ā a sse t Ā q u an t i t y ) ; S ā s p o t Ā p r i ce ; ā
Positions' and debts' values after rebalancing:
P V 1 ā = P V 1 + Ī P V 1 ; Ā D V 1 ā = D V 1 + Ī D V 1 ; P V 2 ā = P V 2 + Ī P V 2 ; Ā D V 2 ā = D V 2 + Ī D V 2 ; PV_{1}^{*} = PV_{1} +\Delta PV_{1};\ DV_{1}^{*} = DV_{1} + \Delta DV_{1};\\
PV_{2}^{*} = PV_{2} +\Delta PV_{2};\ DV_{2}^{*} = DV_{2} + \Delta DV_{2};\\ P V 1 ā ā = P V 1 ā + Ī P V 1 ā ; Ā D V 1 ā ā = D V 1 ā + Ī D V 1 ā ; P V 2 ā ā = P V 2 ā + Ī P V 2 ā ; Ā D V 2 ā ā = D V 2 ā + Ī D V 2 ā ; How to calculate those value changes:
D V 1 ā P V 1 ā = 2 3 ; Ā ( s u b P O S 1 Ā l e v e r a g e Ā = = Ā 3 Ā a f t e r Ā r a b a l a n c e ) D V 2 ā P V 2 ā = 2 3 ; Ā ( s u b P O S 2 Ā l e v e r a g e Ā = = Ā 3 Ā a f t e r Ā r a b a l a n c e ) P V 2 ā 2 + P V 1 ā 2 S ā D V 2 ā = 0 Ā ( D e l t a ā n e u t r a l i t y Ā c o n d i t i o n ) Ī P V 1 + Ī P V 2 ā S ā Ī D V 1 ā Ī D V 2 ā S = 0 Ā ( W e Ā d o n ā² t Ā a d d Ā c a s h Ā f r o m Ā o u t s i d e ) \frac{DV_{1}^{*}}{PV_{1}^{*}} = \frac{2}{3};\ (subPOS1\ leverage\ ==\ 3\ after\ rabalance)\\
\frac{DV_{2}^{*}}{PV_{2}^{*}} = \frac{2}{3};\ (subPOS2\ leverage\ ==\ 3\ after\ rabalance)\\
\frac{PV_{2}^{*}}{2} + \frac{PV_{1}^{*}}{2S} - DV_{2}^{*} = 0\ (Delta-neutrality\ condition)\\
\Delta PV_{1} + \Delta PV_{2}*S - \Delta DV_{1} - \Delta DV_{2}*S =0 \ (We\ don't\ add\ cash\ from\ outside)\\ P V 1 ā ā D V 1 ā ā ā = 3 2 ā ; Ā ( s u b POS 1 Ā l e v er a g e Ā == Ā 3 Ā a f t er Ā r aba l an ce ) P V 2 ā ā D V 2 ā ā ā = 3 2 ā ; Ā ( s u b POS 2 Ā l e v er a g e Ā == Ā 3 Ā a f t er Ā r aba l an ce ) 2 P V 2 ā ā ā + 2 S P V 1 ā ā ā ā D V 2 ā ā = 0 Ā ( De lt a ā n e u t r a l i t y Ā co n d i t i o n ) Ī P V 1 ā + Ī P V 2 ā ā S ā Ī D V 1 ā ā Ī D V 2 ā ā S = 0 Ā ( W e Ā d o n ā² t Ā a dd Ā c a s h Ā f ro m Ā o u t s i d e ) The result
Ī P V 1 = 3 4 ( ā 1 3 P V 1 ā D V 1 + P V 2 Ć S ā D V 2 Ć S ) Ī D V 1 = 1 2 ( P V 1 ā 3 D V 1 + P V 2 Ć S ā D V 2 Ć S ) Ī P V 2 = 9 4 S ( P V 1 ā D V 1 + 5 9 P V 2 Ć S ā D V 2 Ć S ) Ī D V 2 = 3 2 S ( P V 1 ā D V 1 + P V 2 Ć S ā 5 3 D V 2 Ć S ) \Delta PV_{1} = \frac{3}{4}(-\frac{1}{3}PV_{1}-DV_{1}+PV_{2}\times S - DV_{2}\times S)\\
\Delta DV_{1} = \frac{1}{2}(PV_{1} - 3DV_{1} + PV_{2}\times S - DV_{2}\times S)\\
\Delta PV_{2} = \frac{9}{4S}(PV_{1} - DV_{1} + \frac{5}{9}PV_{2}\times S - DV_{2}\times S)\\
\Delta DV_{2} = \frac{3}{2S}(PV_{1} - DV_{1} + PV_{2}\times S - \frac{5}{3}DV_{2}\times S)\\ Ī P V 1 ā = 4 3 ā ( ā 3 1 ā P V 1 ā ā D V 1 ā + P V 2 ā Ć S ā D V 2 ā Ć S ) Ī D V 1 ā = 2 1 ā ( P V 1 ā ā 3 D V 1 ā + P V 2 ā Ć S ā D V 2 ā Ć S ) Ī P V 2 ā = 4 S 9 ā ( P V 1 ā ā D V 1 ā + 9 5 ā P V 2 ā Ć S ā D V 2 ā Ć S ) Ī D V 2 ā = 2 S 3 ā ( P V 1 ā ā D V 1 ā + P V 2 ā Ć S ā 3 5 ā D V 2 ā Ć S ) This cash flows totally define the algorythm of rebalancing in general. It can be implemented in any LYF protocol after fitting to protocol's interface.
Here is the backtesting result of sample strategy, using Francium's SOL-USD pool characteristics with 3'rd leverage:
The up-diagonal line return is the reason, why we here!