diff --git a/crypto/sol/.env b/crypto/sol/.env index 305104b..e14028e 100644 --- a/crypto/sol/.env +++ b/crypto/sol/.env @@ -22,7 +22,7 @@ DEVELOPER_CHAT_ID="777826553" TELEGRAM_BOT_TOKEN="6749075936:AAHUHiPTDEIu6JH7S2fQdibwsu6JVG3FNG0" DISPLAY_CURRENCY=USD -FOLLOW_AMOUNT=2 +FOLLOW_AMOUNT=3 #FOLLOW_AMOUNT=percentage LIQUIDITY_TOKENS=EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v,So11111111111111111111111111111111111111112 diff --git a/crypto/sol/modules/SolanaAPI.py b/crypto/sol/modules/SolanaAPI.py index edaf12f..b383a68 100644 --- a/crypto/sol/modules/SolanaAPI.py +++ b/crypto/sol/modules/SolanaAPI.py @@ -768,8 +768,11 @@ class SolanaAPI: slippage_bps=300, # Increased to 3% ) logging.info(f"Initiating move. Transaction data:\n {transaction_data}") - - fee = async_client.get_fee_for_message(transaction_data.message) + + raw_transaction = VersionedTransaction.from_bytes(base64.b64decode(transaction_data)) + priority_fee = await async_client.get_fee_for_message(raw_transaction.message) + + # fee = await async_client.get_fee_for_message(transaction_data) # priority_fee = 0 # if PRIORITY: # priority_fee = 100 * PRIORITY # defalt if we can't get current rate @@ -779,9 +782,16 @@ class SolanaAPI: # logging.warning(f"Failed to get priority fee. Using default value: {priority_fee}") # error_logger.info(f"Initiating move. Transaction data:\n {transaction_data}") - raw_transaction = VersionedTransaction.from_bytes(base64.b64decode(transaction_data)) # message = raw_transaction.message + # Add compute budget instruction to set priority fee + from solders.compute_budget import set_compute_unit_price + compute_budget_instruction = set_compute_unit_price(priority_fee) + + # Add compute budget instruction to the transaction + raw_transaction.message.add_instruction(compute_budget_instruction) + + # signature = private_key.sign_message( bytes(message) ) signature = private_key.sign_message(message.to_bytes_versioned(raw_transaction.message)) signed_txn = VersionedTransaction.populate(raw_transaction.message, [signature]) @@ -789,16 +799,16 @@ class SolanaAPI: skip_preflight=False, preflight_commitment=Processed, # max_retries=10, - # priority_fee =priority_fee + # priority_fee =fee.value ) # send the transaction - result = await async_client.send_raw_transaction(txn=bytes(signed_txn), opts=opts) + result = await async_client.send_raw_transaction(txn=bytes(signed_txn), opts=opts ) transaction_id = json.loads(result.to_json())['result'] notification = f"Follow Transaction Sent:\nTransaction: swapping {amount_to_swap:.2f} {token_name_in}" logging.info(notification) await telegram_utils.send_telegram_message(notification) - tx_details = await SAPI.get_transaction_details_with_retry(transaction_id, retry_delay=5, max_retries=6, backoff=False) + tx_details = await SAPI.get_transaction_details_with_retry(transaction_id, retry_delay=5, max_retries=10, backoff=False) if tx_details is not None: break diff --git a/crypto/sol/modules/webui.py b/crypto/sol/modules/webui.py index 69e4dca..00ad411 100644 --- a/crypto/sol/modules/webui.py +++ b/crypto/sol/modules/webui.py @@ -237,7 +237,8 @@ def init_app(tr_handler=None): token_out = token_outputs[0] tr["token_out"] = token_out["mint"] tr["token_out_decimals"] = get_decimals(token_out) - + tr["amount_out"] = calculate_amount(token_out) + # Store transaction in database if tr["type"] in ["BUY", "SELL"]: is_buy = tr["type"] == "BUY" diff --git a/modules/log_processor.py b/modules/log_processor.py new file mode 100644 index 0000000..e69de29