tick
This commit is contained in:
@ -12,7 +12,7 @@ import json
|
||||
from config import LIQUIDITY_TOKENS
|
||||
|
||||
from modules import storage, utils, SolanaAPI
|
||||
from modules.utils import async_safe_call
|
||||
from modules.utils import async_safe_call, decode_instruction_data
|
||||
import os
|
||||
import logging
|
||||
from datetime import datetime
|
||||
@ -75,7 +75,7 @@ def init_app(tr_handler=None):
|
||||
await utils.telegram_utils.send_telegram_message(notification)
|
||||
|
||||
# Store the notified transaction in the database
|
||||
await storage.store_transaction(wallet, "SWAP", tr['symbol_in'] , tr['amount_in'], tr['value_in_USD'], tr['symbol_out'], tr['amount_out'], tr['value_out_USD'],tx_signature)
|
||||
await storage.store_transaction(wallet, "SWAP", tr['symbol_in'] , tr['amount_in'], tr['value_in_USD'], tr['symbol_out'], tr['amount_out'], tr['value_out_USD'], tx_signature)
|
||||
# Attempt to execute the copytrade transaction
|
||||
try:
|
||||
await SolanaAPI.SAPI.follow_move(tr)
|
||||
@ -100,12 +100,34 @@ def init_app(tr_handler=None):
|
||||
request_data = request.get_json() if request.is_json else None
|
||||
if not request_data:
|
||||
return jsonify({"error": "No data in request"}), 400
|
||||
logger.info(f"Webhook data: {request_data}")
|
||||
if "description" in request_data[0] and request_data[0]["description"]:
|
||||
logger.info(request_data[0]["description"])
|
||||
else:
|
||||
logger.info(f"Webhook data: {request_data}")
|
||||
# save dump to /cache/last-webhook-{datetime}.json
|
||||
|
||||
with open( os.path.join(SolanaAPI.root_path, 'logs', f'wh_{current_time}.json') , 'w') as f:
|
||||
json.dump(request_data, f)
|
||||
|
||||
|
||||
if "meta" in request_data[0]:
|
||||
meta = request_data[0]["meta"]
|
||||
|
||||
# Parse inner instructions
|
||||
for inner_ix in meta.get("innerInstructions", []):
|
||||
for instruction in inner_ix.get("instructions", []):
|
||||
decoded = decode_instruction_data(instruction["data"])
|
||||
logger.info(f"Instruction data decoded: {decoded}")
|
||||
|
||||
# Example of pattern matching for specific instruction types
|
||||
if decoded["instruction_type"] == 1: # Example: swap instruction
|
||||
# Parse parameters based on program type
|
||||
# Different DEXes will have different parameter layouts
|
||||
pass
|
||||
|
||||
|
||||
|
||||
|
||||
# await process_wh(request_data)
|
||||
# don't wait for the process to finish
|
||||
asyncio.create_task(process_wh(request_data ))
|
||||
@ -214,7 +236,8 @@ def init_app(tr_handler=None):
|
||||
logging.error(f"Copytrade transaction failed: {e}")
|
||||
# ToDo - probably optimize
|
||||
await SolanaAPI.DEX.save_token_info()
|
||||
|
||||
else:
|
||||
logger.info("wh transaction is not a swap. skipping...")
|
||||
except Exception as e:
|
||||
logging.error(f"Error processing transaction notification: {str(e)}")
|
||||
# Log the full traceback for debugging
|
||||
|
Reference in New Issue
Block a user