Created
July 20, 2024 09:19
-
-
Save vivekascoder/b8330dd6ffc72fc4ecd9dd0bcdff4ad0 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from pools.dex import Dex | |
from pools.heplers import plot_curves | |
k = 3 | |
x = 1 | |
price = 3000 | |
h = 5 | |
power = 3 | |
adjust_rate = 0 | |
adjust_period = 1 | |
dex = Dex(1, 0.0001, power, h, price, | |
assert_correct=True, | |
adjust_rate=adjust_rate, | |
) | |
def info(): | |
print(f'>> payoff | long {dex.pool.long_payoff(1)}, short {dex.pool.short_payoff(1)}') | |
print("LC: ", dex.pool.long_condition(), "SC: ", dex.pool.short_condition()) | |
print(f'LP value {dex.price_token_lp(1)}, liquidity {dex.pool.liquidity(1)}') | |
print(dex.pool) | |
# plot_curves(dex.pool, 0, 10) | |
print('--------------Init') | |
info() | |
dex.open_lp(1, price, 50) | |
print('--------------LP added') | |
info() | |
print('--------------OPEN SHORT') | |
short = dex.open_position(100, price, False, 2) | |
info() | |
print(f"position value: {dex.position_value(short, price)}") | |
print('-------------apply funding ') | |
dex.apply_funding(2, price) | |
info() | |
print(f"position value: {dex.position_value(short, price)}") | |
print('--------------CLOSE SHORT') | |
a = dex.close_position(short, price) | |
info() | |
print('-------------apply funding ') | |
dex.apply_funding(100, price) | |
info() | |
print(f"position value: {dex.position_value(short, price)}") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment