This commit is contained in:
Dobromir Popov 2024-11-12 12:07:44 +02:00
parent d4a7c0b653
commit cd3e9e79ec
4 changed files with 19 additions and 8 deletions

View File

@ -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

View File

@ -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:\n<b>Transaction:</b> <a href='https://solscan.io/tx/{transaction_id}'>swapping {amount_to_swap:.2f} {token_name_in}</a>"
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

View File

@ -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"

0
modules/log_processor.py Normal file
View File