diff --git a/crypto/sol/app.py b/crypto/sol/app.py
index 25739d7..d5d03a1 100644
--- a/crypto/sol/app.py
+++ b/crypto/sol/app.py
@@ -119,6 +119,7 @@ async def send_telegram_message(message):
try:
await bot.send_message(chat_id=DEVELOPER_CHAT_ID, text=message, parse_mode=ParseMode.HTML)
logging.info(f"Telegram message sent: {message}")
+ # logging.info(f"Telegram message dummy sent: {message}")
except Exception as e:
logging.error(f"Error sending Telegram message: {str(e)}")
@@ -752,7 +753,7 @@ async def follow_move(move):
input_mint=move['token_in'],
output_mint=move['token_out'],
amount=int(amount_to_swap * 1e6), # Convert to lamports
- slippage_bps=1,
+ slippage_bps=50, # Increased to 0.5%
)
@@ -760,57 +761,29 @@ async def follow_move(move):
signature = private_key.sign_message(message.to_bytes_versioned(raw_transaction.message))
signed_txn = VersionedTransaction.populate(raw_transaction.message, [signature])
opts = TxOpts(skip_preflight=False, preflight_commitment=Processed)
+ # send the transaction
result = await async_client.send_raw_transaction(txn=bytes(signed_txn), opts=opts)
+
transaction_id = json.loads(result.to_json())['result']
print(f"Transaction sent: https://explorer.solana.com/tx/{transaction_id}")
-
-
- # # transaction_data is already a string, no need to json.loads()
- # raw_transaction = base64.b64decode(transaction_data)
- # # Send the raw transaction
- # opts = TxOpts(skip_preflight=False, preflight_commitment=Processed)
- # result = await async_client.send_raw_transaction(txn=raw_transaction, opts=opts)
- # transaction_id = result.value # This should be the transaction signature
-
+ # wait for the transaction to be confirmed
+ # await async_client.wait_for_confirmation(Signature.from_string(transaction_id))
+ # wait 10 seconds
+ await asyncio.sleep(10)
# Fetch the transaction details to get the output amount
- tx_details = await async_client.get_transaction(transaction_id)
+ tx_details = await get_transaction_details_rpc(transaction_id)
output_amount = tx_details.value.meta.post_balances[1] - tx_details.value.meta.pre_balances[1]
output_token_info = your_balances.get(move['token_out'], {'name': 'Unknown'})
output_token_name = output_token_info['name']
-
-
- # transaction_data = json.loads(transaction_data)
-
- # instructions = [transaction_data['instruction']] # Adjust as needed
- # message = Message(instructions, private_key.pubkey())
- # blockhash = await async_client.get_latest_blockhash()
- # tx = Transaction([private_key], message, blockhash.value)
-
- # result = await async_client.send_transaction(tx, private_key)
- # transaction_id = result.value
-
- # output_token_info = your_balances.get(move['token_out'], {'name': 'Unknown'})
- # output_token_name = output_token_info['name']
-
- # raw_transaction = VersionedTransaction.from_bytes(base64.b64decode(transaction_data))
- # tx_message = raw_transaction.message
- # signature = private_key.sign_message(tx_message.to_bytes_versioned())
- # signed_txn = VersionedTransaction.populate(tx_message, [signature])
- # opts = TxOpts(skip_preflight=False, preflight_commitment=Processed)
- # result = await async_client.send_raw_transaction(txn=bytes(signed_txn), opts=opts)
- # transaction_id = json.loads(result.to_json())['result']
-
- # output_token_info = your_balances.get(move['token_out'], {'name': 'Unknown'})
- # output_token_name = output_token_info['name']
-
notification = (
f"Move Followed:\n"
f"Swapped {amount_to_swap:.6f} {token_name} ({move['token_in']}) "
f"(same {move['percentage_swapped']:.2f}% as followed wallet)\n"
f"for {transaction_data['outputAmount'] / 1e6:.6f} {output_token_name} ({move['token_out']})"
+ f"\n\nTransaction: {transaction_id}"
)
logging.info(notification)
await send_telegram_message(notification)
@@ -848,16 +821,12 @@ async def subscribe_to_wallet():
reconnect_delay = 5 # Start with a 5-second delay
max_reconnect_delay = 60 # Maximum delay of 60 seconds
-
- await list_initial_wallet_states()
-
while True:
try:
async with websockets.connect(uri) as websocket:
logger.info("Connected to Solana websocket")
subscription_id = await load_subscription_id()
-
request = {
"jsonrpc": "2.0",
@@ -920,7 +889,8 @@ async def main():
# Initialize logging
logging.basicConfig(level=logging.DEBUG)
await send_telegram_message("Solana Agent Started. Connecting to mainnet...")
- # await subscribe_to_wallet()
+ # await list_initial_wallet_states()
+ await subscribe_to_wallet()
def run_flask():
# Run Flask app without the reloader, so we can run the async main function