Files
uniswap_auto_clp/gen_sim.py

57 lines
2.4 KiB
Python

from decimal import Decimal, getcontext
getcontext().prec = 60
P_entry = Decimal('3057.65')
capitals = [1000, 2000, 4000, 8000]
ranges = [0.005, 0.01, 0.02, 0.04, 0.05, 0.10]
tvl = Decimal('74530000')
vol24h = Decimal('23270000')
fee_tier = Decimal('0.0005')
hl_fee_rate = Decimal('0.00045')
print('# CLP Hedging Strategy Matrix (Jan 2026)')
print('\n*Based on ETH/USDC 0.05% Arbitrum Pool Stats: TVL $74.53M, 24h Vol $23.27M.*')
print('*Calculations include 0.045% round-trip Hyperliquid fees and concentration-adjusted Uniswap fees.*\n')
for cap in capitals:
print(f'## Capital: ${cap} USDC')
print('| Range | Strategy | Hedge Size | Margin (5x) | PnL Lower | PnL Upper | Est. Fees (1h) |')
print('| :--- | :--- | :--- | :--- | :--- | :--- | :--- |')
for r in ranges:
Pa = P_entry * (Decimal('1') - Decimal(str(r)))
Pb = P_entry * (Decimal('1') + Decimal(str(r)))
L = Decimal(str(cap)) / (Decimal('2')*P_entry.sqrt() - Pa.sqrt() - P_entry/Pb.sqrt())
V_low = L * Pa * (Decimal('1')/Pa.sqrt() - Decimal('1')/Pb.sqrt())
V_high = L * (Pb.sqrt() - Pa.sqrt())
clp_loss = Decimal(str(cap)) - V_low
clp_gain = V_high - Decimal(str(cap))
d_entry = L * (Decimal('1')/P_entry.sqrt() - Decimal('1')/Pb.sqrt())
conc = Decimal('1') / (Decimal('1') - (Pa/Pb).sqrt())
fee_1h = (Decimal(str(cap)) * (vol24h / tvl) * fee_tier * conc) / Decimal('24')
hl_costs = Decimal(str(cap)) * hl_fee_rate
h_nd = (clp_loss + hl_costs) / (P_entry - Pa)
h_nu = (clp_gain - hl_costs) / (Pb - P_entry)
h_f = d_entry
for name, h in [('Neutral Down', h_nd), ('Neutral Up', h_nu), ('Fixed', h_f)]:
margin = (h * P_entry) / Decimal('5')
pnl_low = (h * (P_entry - Pa)) - clp_loss - hl_costs
pnl_high = (h * (P_entry - Pb)) + clp_gain - hl_costs
r_str = f"+/- {r*100} %"
h_str = f"{h:.4f} ETH"
m_str = f"${margin:.2f}"
pl_str = f"{pnl_low:+.2f}"
ph_str = f"{pnl_high:+.2f}"
f_str = f"${fee_1h:.2f}"
display_r = r_str if name == 'Neutral Down' else ''
display_f = f_str if name == 'Neutral Down' else ''
print(f'| {display_r} | {name} | {h_str} | {m_str} | {pl_str} | {ph_str} | {display_f} |')
print('\n')