try even if we report no ballance

This commit is contained in:
Dobromir Popov 2024-10-09 14:11:47 +03:00
parent 3471f6aa6d
commit 12769cd3cc

View File

@ -58,8 +58,6 @@ error_logger.setLevel(logging.ERROR)
error_logger.addHandler(error_file_handler)
app = Flask(__name__)
ENV_FILE = '.env'
@ -911,7 +909,7 @@ async def process_log(log_result):
logging.error(f"Error fetching token prices: {e}")
message_text = (
f"<b>Swap detected:</b>\n"
f"<b>Swap detected: </b>\n"
f"Token In: {tr_details['symbol_in']} ({tr_details['token_in']})\n"
f"Token Out: {tr_details['symbol_out']} ({tr_details['token_out']})\n"
f"Amount In USD: {tr_details['amount_in_USD']:.2f}\n"
@ -990,6 +988,12 @@ async def follow_move(move):
# amount_to_swap = amount_to_swap * 0.99
if your_balance >= amount_to_swap:
msg = (
f"<b>Warning:</b>\n"
f"We have {your_balance:.6f} {token_name_in}. Insufficient balance to swap {amount_to_swap:.6f} ({move['token_in']}). This will probably fail. But we will try anyway."
)
logging.warning(msg)
await send_telegram_message(msg)
try:
# Convert to lamports
# if decimals is 6, then amount = amount * 1e6; if 9, then amount = amount * 1e9
@ -1068,13 +1072,13 @@ async def follow_move(move):
error_logger.error(error_message)
error_logger.exception(e)
# await send_telegram_message(error_message)
else:
msg = (
f"<b>Move Not Followed:</b>\n"
f"Insufficient balance to swap {amount_to_swap:.6f} {token_name_in} ({move['token_in']})"
)
logging.warning(msg)
await send_telegram_message(msg)
# else:
# msg = (
# f"<b>Move Not Followed:</b>\n"
# f"Insufficient balance to swap {amount_to_swap:.6f} {token_name_in} ({move['token_in']})"
# )
# logging.warning(msg)
# await send_telegram_message(msg)
# Helper functions (implement these according to your needs)
@ -1181,7 +1185,6 @@ if not pk:
async def main():
# Initialize logging
await send_telegram_message("Solana Agent Started. Connecting to mainnet...")
asyncio.create_task( list_initial_wallet_states())
await subscribe_to_wallet()