sync: Update root scripts with latest versions from florida directory
This commit is contained in:
@ -817,6 +817,12 @@ def main():
|
||||
pnl_unrealized = current_pos_value_usd - initial_value
|
||||
total_pnl_usd = pnl_unrealized + total_fees_usd
|
||||
|
||||
# --- PERSIST PERFORMANCE TO JSON ---
|
||||
update_position_status(token_id, "OPEN", {
|
||||
"clp_fees": round(float(total_fees_usd), 2),
|
||||
"clp_TotPnL": round(float(total_pnl_usd), 2)
|
||||
})
|
||||
|
||||
pnl_text = f" | TotPnL: ${total_pnl_usd:.2f} (Fees: ${total_fees_usd:.2f})"
|
||||
logger.info(f"Position {token_id}: {status_msg} | Price: {current_price:.4f} [{lower_price:.4f} - {upper_price:.4f}]{pnl_text}")
|
||||
|
||||
@ -941,8 +947,10 @@ def main():
|
||||
if check_and_swap_for_deposit(w3, router, account, token0, token1, amt0, amt1, pool_data['sqrtPriceX96'], d0, d1):
|
||||
minted = mint_new_position(w3, npm, account, token0, token1, amt0, amt1, tick_lower, tick_upper, d0, d1)
|
||||
if minted:
|
||||
# Calculate entry price and amounts for JSON compatibility
|
||||
price_0_in_1 = price_from_sqrt_price_x96(pool_data['sqrtPriceX96'], d0, d1)
|
||||
# Calculate entry price from TICK to ensure consistency with Range
|
||||
# (SqrtPrice can sometimes slightly diverge or have precision artifacts)
|
||||
price_0_in_1 = price_from_tick(pool_data['tick'], d0, d1)
|
||||
|
||||
fmt_amt0 = float(Decimal(minted['amount0']) / Decimal(10**d0))
|
||||
fmt_amt1 = float(Decimal(minted['amount1']) / Decimal(10**d1))
|
||||
|
||||
|
||||
@ -42,7 +42,9 @@ console_handler.setFormatter(console_formatter)
|
||||
logger.addHandler(console_handler)
|
||||
|
||||
# File handler
|
||||
file_handler = logging.FileHandler(os.path.join(current_dir, 'logs', 'telegram_monitor.log'), encoding='utf-8')
|
||||
from clp_config import TARGET_DEX
|
||||
|
||||
file_handler = logging.FileHandler(os.path.join(current_dir, 'logs', f'{TARGET_DEX}_telegram_monitor.log'), encoding='utf-8')
|
||||
file_handler.setLevel(logging.INFO)
|
||||
file_handler.addFilter(UnixMsLogFilter())
|
||||
file_formatter = logging.Formatter('%(unix_ms)d, %(asctime)s - %(name)s - %(levelname)s - %(message)s')
|
||||
@ -56,9 +58,10 @@ TELEGRAM_ENABLED = os.getenv('TELEGRAM_MONITOR_ENABLED', 'False').lower() == 'tr
|
||||
TELEGRAM_BOT_TOKEN = os.getenv('TELEGRAM_BOT_TOKEN', '')
|
||||
TELEGRAM_CHAT_ID = os.getenv('TELEGRAM_CHAT_ID', '')
|
||||
TELEGRAM_CHECK_INTERVAL = int(os.getenv('TELEGRAM_CHECK_INTERVAL_SECONDS', '60'))
|
||||
from clp_config import STATUS_FILE
|
||||
TELEGRAM_STATE_FILE = os.getenv('TELEGRAM_STATE_FILE', 'telegram_monitor_state.json')
|
||||
TELEGRAM_TIMEOUT = int(os.getenv('TELEGRAM_TIMEOUT_SECONDS', '10'))
|
||||
HEDGE_STATUS_FILE = os.getenv('HEDGE_STATUS_FILE', 'hedge_status.json')
|
||||
HEDGE_STATUS_FILE = os.getenv('HEDGE_STATUS_FILE', STATUS_FILE)
|
||||
|
||||
class TelegramNotifier:
|
||||
"""Handles Telegram API communication"""
|
||||
|
||||
Reference in New Issue
Block a user