diff --git a/crypto/sol/.env b/crypto/sol/.env
index 7a60085..ab435f5 100644
--- a/crypto/sol/.env
+++ b/crypto/sol/.env
@@ -9,9 +9,8 @@ TELEGRAM_BOT_TOKEN="6805059978:AAHNJKuOeazMSJHc3-BXRCsFfEVyFHeFnjw"
DISPLAY_CURRENCY=USD
# Niki's to Sync: [PROD]
-# FOLLOWED_WALLET="7keSmTZozjmuX66gd9GBSJYEHnMqsyutWpvuuKtXZKDH"
-# YOUR_WALLET="7QXGLRjvyFAmxdRaP9Wk18KwWTMfspF4Na2sr3o3PzxV"
+ FOLLOWED_WALLET="7keSmTZozjmuX66gd9GBSJYEHnMqsyutWpvuuKtXZKDH" YOUR_WALLET="7QXGLRjvyFAmxdRaP9Wk18KwWTMfspF4Na2sr3o3PzxV"
# Sync to main [DEV]
-FOLLOWED_WALLET="7QXGLRjvyFAmxdRaP9Wk18KwWTMfspF4Na2sr3o3PzxV"
-YOUR_WALLET="65nzyZXTLC81MthTo52a2gRJjqryTizWVqpK2fDKLye5"
\ No newline at end of file
+# FOLLOWED_WALLET="7QXGLRjvyFAmxdRaP9Wk18KwWTMfspF4Na2sr3o3PzxV"
+# YOUR_WALLET="65nzyZXTLC81MthTo52a2gRJjqryTizWVqpK2fDKLye5"
\ No newline at end of file
diff --git a/crypto/sol/app.py b/crypto/sol/app.py
index c0a4899..ecb0814 100644
--- a/crypto/sol/app.py
+++ b/crypto/sol/app.py
@@ -940,7 +940,7 @@ async def process_log(log_result):
except Exception as e:
logging.error(f"Error aquiring log details and following: {e}")
- send_telegram_message(f"Not followed! Error following move.")
+ await send_telegram_message(f"Not followed! Error following move.")
return
except Exception as e:
@@ -1017,13 +1017,13 @@ async def follow_move(move):
amount_to_swap = your_balance * (move['percentage_swapped'] / 100)
# # always get 99% of the amount to swap
- amount_to_swap = amount_to_swap * 0.95
+ # amount_to_swap = amount_to_swap * 0.95
# Convert to lamports
# if decimals is 6, then amount = amount * 1e6; if 9, then amount = amount * 1e9
amount = int(amount_to_swap * 10**token_info.get('decimals') )
- if your_balance >= amount_to_swap:
+ if your_balance < amount_to_swap:
msg = (
f"Warning:\n"
f"Insufficient balance: {your_balance:.6f} {token_name_in}. We want to swap {amount_to_swap:.6f}\n({move['symbol_in']}, decimals {token_info.get('decimals')} amount {amount}).\n This will probably fail. But we will try anyway."
@@ -1182,7 +1182,7 @@ async def subscribe_to_wallet():
if conn_active:
conn_active = False
await send_telegram_message("Connection to Solana network was closed. Not listening for transactions right now.\n Attempting to reconnect...")
- break
+ break
except json.JSONDecodeError as e:
logger.error(f"Failed to decode JSON: {e}")
except Exception as e:
@@ -1205,29 +1205,31 @@ async def subscribe_to_wallet():
reconnect_delay = min(reconnect_delay * 2, max_reconnect_delay)
-
pk = os.getenv("PK")
-if not pk:
- try:
- script_dir = os.path.dirname(os.path.abspath(__file__))
- with open(os.path.join(script_dir, 'secret.pk'), 'r') as f:
- pk = f.read().strip()
- if pk:
- logging.info("Private key loaded successfully from file.")
- else:
- logging.warning("Private key file is empty.")
- except FileNotFoundError:
- logging.warning("Private key file not found.")
- except Exception as e:
- logging.error(f"Error reading private key file: {str(e)}")
-if not pk:
- logging.error("Private key not found in environment variables. Will not be able to sign transactions.")
- # send TG warning message
- send_telegram_message("Warning: Private key not found in environment variables. Will not be able to sign transactions.")
+async def check_PK():
+ global pk
+ if not pk:
+ try:
+ script_dir = os.path.dirname(os.path.abspath(__file__))
+ with open(os.path.join(script_dir, 'secret.pk'), 'r') as f:
+ pk = f.read().strip()
+ if pk:
+ logging.info("Private key loaded successfully from file.")
+ else:
+ logging.warning("Private key file is empty.")
+ except FileNotFoundError:
+ logging.warning("Private key file not found.")
+ except Exception as e:
+ logging.error(f"Error reading private key file: {str(e)}")
+ if not pk:
+ logging.error("Private key not found in environment variables. Will not be able to sign transactions.")
+ # send TG warning message
+ await send_telegram_message("Warning: Private key not found in environment variables. Will not be able to sign transactions.")
async def main():
await send_telegram_message("Solana Agent Started. Connecting to mainnet...")
+ await check_PK()
await subscribe_to_wallet()
def run_flask():