Skip to content

Instantly share code, notes, and snippets.

@vivekascoder
Created July 20, 2024 09:19
Show Gist options
  • Save vivekascoder/5d6767a3a4ce3f41aea01639a28a2a90 to your computer and use it in GitHub Desktop.
Save vivekascoder/5d6767a3a4ce3f41aea01639a28a2a90 to your computer and use it in GitHub Desktop.
--------------Init
>> payoff | long 5e-05, short 5e-05
LC: 1.0 SC: 1.0
LP value 3000, liquidity 0.0
K 3 Reserve: 0.0001 alpha:5e-05 beta:5e-05
LC 1.0 SC 1.0
x %s p %s 1.0 3000
--------------LP added
>> payoff | long 5e-05, short 5e-05
LC: 79.37010551174308 SC: 0.012599202099486268
LP value 0.027777888888809076, liquidity 50.0
K 3 Reserve: 50.0001 alpha:5e-05 beta:5e-05
LC 79.37010551174308 SC 0.012599202099486268
--------------OPEN SHORT
>>>x 1.0
>>> new_psi: 100.00005, psi: 5e-05, delta_rl: 100
before adjusting beta, 5e-05
after adjusting beta, 5e-05
1. after adjusting beta, 5e-05
1. after adjusting beta, 5e-05
>> payoff | long 5e-05, short 100.00005
LC: 114.47144969342179 SC: 1.1447141153629734
LP value 1.1111058286773311e-07, liquidity 50.0
K 3 Reserve: 150.0001 alpha:5e-05 beta:112.5000375000125
LC 114.47144969342179 SC 1.1447141153629734
๐Ÿซ  psi: 100.00005 amt: 100.0, totalS: 100.00005
position value: 100.00000000000001
-------------apply funding
{'dt': 1} {'phi': 5e-05} {'psi': 100.00005}
๐Ÿ—๏ธ aa 0.8705505632961241 dt: 1, h: 5
๐Ÿ—๏ธ pp 0.12944943670387588 cc 0.6666662222225185
๐Ÿ˜… prem: 8.629961008598942 & prem_co: 9.99999000001e-07
{'new_phi': 5.8629952378646565e-05} {'new_psi': 91.37008899140106}
>> payoff | long 5.8629952378646565e-05, short 91.37008899140106
LC: 108.55437647880147 SC: 1.0855434029403346
LP value 1.3028839634532055e-07, liquidity 58.629952378646564
K 3 Reserve: 150.0001 alpha:5.8629952378646565e-05 beta:95.9407546278221
LC 108.55437647880147 SC 1.0855434029403346
๐Ÿซ  psi: 91.37008899140106 amt: 100.0, totalS: 100.00005
position value: 91.3700433063794
--------------CLOSE SHORT
>>>SHORT: 100.0
self.pool.short(x): 91.37008899140106 x: 1.0, self.short: 100.00005
>>>redeemed value: 91.3700433063794
perp_tokens: 100.0, short_qty: 100.00005
>>> new_psi: 4.5685021660801794e-05, psi: 91.37008899140106, delta_rl: -91.3700433063794
before adjusting beta, 91.37008899140106
after adjusting beta, 91.37008899140106
1. after adjusting beta, 91.37008899140106
1. after adjusting beta, 91.37008899140106
>> payoff | long 5.8629952378646565e-05, short 4.5685021660801794e-05
LC: 79.37009967036852 SC: 0.011593854316219086
LP value 0.04180173310076657, liquidity 58.629952378646564
K 3 Reserve: 58.6300566936206 alpha:5.8629952378646565e-05 beta:4.5685021660801794e-05
LC 79.37009967036852 SC 0.011593854316219086
-------------apply funding
{'dt': 98} {'phi': 5.8629952378646565e-05} {'psi': 4.5685021660801794e-05}
๐Ÿ—๏ธ aa 1.2583808047989777e-06 dt: 98, h: 5
๐Ÿ—๏ธ pp 0.9999987416191952 cc 2.207900085358996e-07
๐Ÿ˜… prem: 1.294489139651741e-11 & prem_co: 7.792089914652724e-07
{'new_phi': 5.862993943375517e-05} {'new_psi': 4.5685021660811884e-05}
>> payoff | long 5.862993943375517e-05, short 4.5685021660811884e-05
LC: 79.37010551173702 SC: 0.01159385431621994
LP value 0.04180173310076657, liquidity 58.62995237865951
K 3 Reserve: 58.6300566936206 alpha:5.862993943375517e-05 beta:4.5685021660811884e-05
LC 79.37010551173702 SC 0.01159385431621994
๐Ÿซ  psi: 4.5685021660811884e-05 amt: 100.0, totalS: 5.000000000165983e-05
position value: 91.37004331859059
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment