need a favor see this code here import asyncio
import json
import base64
import struct
from typing import List, Dict, Any
from solana.rpc.async_api import AsyncClient
from solana.rpc.commitment import Commitment
from solana.publickey import Pubkey
from solana.transaction import Transaction
from solana.system_program import transfer, TransferParams
from solana_rust_bot import TradingCore, TradeParams
from config_loader import config
from solana_logger import logger

async def debug_raydium_setup():
    """Comprehensive Raydium debugging suite"""
    
    class RaydiumDebugger:
        def __init__(self):
            self.network_config = config.get_network_config()
            self.client = AsyncClient(self.network_config["rpc_url"])
            self.trading_core = TradingCore(
                rpc_url=self.network_config["rpc_url"],
                keypair_bytes=config.get_keypair_bytes()
            )
            self.results = {
                "account_checks": [],
                "order_tests": [],
                "data_validation": [],
                "error_analysis": []
            }

        # [Previous methods remain the same...]

        async def test_account_orders(self):
            """Test various account orderings"""
            test_orders = [
                # Standard Raydium order
                [0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16],
                # From transaction dump
                [0,14,1,1,13,7,3,5,7,6,4,8,5,2,12,11,9],
                # Other permutations
                [0,14,1,2,13,7,3,5,7,6,4,8,5,2,12,11,9],
                [0,1,2,3,13,7,4,5,7,6,4,8,5,2,12,11,9]
            ]

            market_accounts = config.get_market_accounts()
            base_accounts = [
                config.get("wallet"),
                config.get("raydium"),
                config.get("wsol_token_account"),
                config.get("wsol_token_account"),
                market_accounts["amm_authority"],
                market_accounts["market"],
                market_accounts["amm_open_orders"],
                market_accounts["pool_temp_lp"],
                market_accounts["serum_market"],
                market_accounts["serum_bids"],
                market_accounts["serum_asks"],
                market_accounts["event_queue"],
                market_accounts["base_vault"],
                market_accounts["quote_vault"],
                market_accounts["vault_signer"],
                config.get("token"),
                config.get("system")
            ]

            for order_idx, order in enumerate(test_orders):
                try:
                    test_accounts = [base_accounts[i] for i in order]
                    result = await self.simulate_trade(test_accounts)
                    self.results["order_tests"].append({
                        "order_index": order_idx,
                        "order": order,
                        "accounts": {i: base_accounts[acc_idx] for i, acc_idx in enumerate(order)},
                        "result": result
                    })
                except Exception as e:
                    logger.error(f"Order test {order_idx} failed: {e}")

        # [Rest of the class methods remain the same...]

async def main():
    """Run the debugger"""
    logger.info("Starting Raydium debugger...")
    debugger = RaydiumDebugger()
    await debugger.run_full_debug()

if __name__ == "__main__":
    asyncio.run(main()) i need it in this script so replace the parts of the 2nd script with the 1st script okay import asyncio
import json
import base64
import struct
from typing import List, Dict, Any
from solana.rpc.async_api import AsyncClient
from solana.rpc.commitment import Commitment
from solana.publickey import Pubkey
from solana.transaction import Transaction
from solana.system_program import transfer, TransferParams
from solana_logger import logger

async def debug_raydium_setup():
   """Comprehensive Raydium debugging suite"""
   
   class RaydiumDebugger:
       def __init__(self):
           self.network_config = config.get_network_config()
           self.client = AsyncClient(self.network_config["rpc_url"])
           self.trading_core = TradingCore(
               rpc_url=self.network_config["rpc_url"],
               keypair_bytes=config.get_keypair_bytes()
           )
           self.results = {
               "account_checks": [],
               "order_tests": [],
               "data_validation": [],
               "error_analysis": []
           }

       async def verify_account_ownership(self):
           """Verify ownership and data of all accounts"""
           accounts = {
               "amm": {
                   "id": "HWHvQhFmJB3NUcu1aihKmrKegfVxBEHzwVX6yZCKEsi1",
                   "expected_owner": "675kPX9MHTjS2zt1qfr1NYHuzeLXfQM9H24wFSUt1Mp8"
               },
               "authority": {
                   "id": "5Q544fKrFoe6tsEbD7S8EmxGTJYAKtTVhAW5Q5pge4j1",
                   "expected_owner": "675kPX9MHTjS2zt1qfr1NYHuzeLXfQM9H24wFSUt1Mp8"
               },
               "open_orders": {
                   "id": "6MxERzqEY8gqvz1NmYMjKZsxewt4RdrRyNndiEQXS1kz",
                   "expected_owner": "675kPX9MHTjS2zt1qfr1NYHuzeLXfQM9H24wFSUt1Mp8"
               }
           }

           for name, info in accounts.items():
               try:
                   acc = await self.client.get_account_info(Pubkey.from_string(info["id"]))
                   actual_owner = str(acc.value.owner)
                   is_correct = actual_owner == info["expected_owner"]
                   self.results["account_checks"].append({
                       "account": name,
                       "address": info["id"],
                       "expected_owner": info["expected_owner"],
                       "actual_owner": actual_owner,
                       "is_correct": is_correct,
                       "data_size": len(acc.value.data)
                   })
               except Exception as e:
                   logger.error(f"Failed to verify {name}: {e}")

       async def analyze_amm_data(self):
           """Parse and validate AMM account data"""
           try:
               amm = await self.client.get_account_info(
                   Pubkey.from_string("HWHvQhFmJB3NUcu1aihKmrKegfVxBEHzwVX6yZCKEsi1")
               )
               data = amm.value.data
               
               # AMM data structure analysis
               amm_data = {
                   "status": struct.unpack_from("<I", data, 0)[0],
                   "nonce": struct.unpack_from("<B", data, 4)[0],
                   "order_num": struct.unpack_from("<Q", data, 5)[0],
                   "depth": struct.unpack_from("<Q", data, 13)[0],
                   "base_decimals": struct.unpack_from("<B", data, 21)[0],
                   "quote_decimals": struct.unpack_from("<B", data, 22)[0],
               }
               
               self.results["data_validation"].append({
                   "amm_data": amm_data,
                   "total_size": len(data)
               })
           except Exception as e:
               logger.error(f"AMM data analysis failed: {e}")

       async def test_account_orders(self):
           """Test various account orderings"""
           test_orders = [
               # Standard Raydium order
               [0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16],
               # Current failing order
               [0,14,1,1,13,7,3,5,7,6,4,8,5,2,12,11,9],
               # Alternative orders based on Raydium docs
               [0,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,1],
               [0,2,3,4,14,5,6,7,8,9,10,11,12,13,15,16,1]
           ]

           market_accounts = config.get_market_accounts()
           base_accounts = [
               config.get("wallet"),
               config.get("raydium"),
               config.get("wsol_token_account"),
               config.get("wsol_token_account"),
               market_accounts["amm_authority"],
               market_accounts["market"],
               market_accounts["amm_open_orders"],
               market_accounts["pool_temp_lp"],
               market_accounts["serum_market"],
               market_accounts["serum_bids"],
               market_accounts["serum_asks"],
               market_accounts["event_queue"],
               market_accounts["base_vault"],
               market_accounts["quote_vault"],
               market_accounts["vault_signer"],
               config.get("token"),
               config.get("system")
           ]

           for order_idx, order in enumerate(test_orders):
               try:
                   test_accounts = [base_accounts[i] for i in order]
                   result = await self.simulate_trade(test_accounts)
                   self.results["order_tests"].append({
                       "order_index": order_idx,
                       "account_mapping": {i: base_accounts[acc_idx] for i, acc_idx in enumerate(order)},
                       "result": result
                   })
               except Exception as e:
                   logger.error(f"Order test {order_idx} failed: {e}")

       async def simulate_trade(self, accounts: List[str]) -> Dict[str, Any]:
           """Simulate trade with given account order"""
           test_size = 0.01
           test_data = bytearray([9])
           test_data.extend(int(test_size * 1e9).to_bytes(8, "little"))
           test_data.extend(bytearray([0] * 32))

           params = TradeParams(
               accounts=accounts,
               amount_in=test_size,
               is_buy=True,
               victim_data=base64.b64encode(test_data).decode(),
               reuse_blockhash=False,
               token_a_mint="So11111111111111111111111111111111111111112",
               token_b_mint="So11111111111111111111111111111111111111112"
           )

           try:
               sim_response = await self.client.simulate_transaction(
                   await self.trading_core.create_transaction(params),
                   sig_verify=False,
                   commitment=Commitment("confirmed")
               )
               return {
                   "success": sim_response.value.err is None,
                   "error": str(sim_response.value.err) if sim_response.value.err else None,
                   "logs": sim_response.value.logs,
                   "units_consumed": sim_response.value.units_consumed
               }
           except Exception as e:
               return {"success": False, "error": str(e)}

       async def analyze_errors(self):
           """Analyze common error patterns"""
           for test in self.results["order_tests"]:
               if not test["result"]["success"]:
                   error = test["result"]["error"]
                   logs = test["result"].get("logs", [])
                   
                   analysis = {
                       "error_code": error,
                       "possible_causes": [],
                       "suggested_fixes": []
                   }

                   if "0x1b" in error:
                       analysis["possible_causes"].extend([
                           "AMM authority mismatch",
                           "Incorrect account owner",
                           "Wrong account order"
                       ])
                       analysis["suggested_fixes"].extend([
                           "Verify AMM authority",
                           "Check account ownership",
                           "Review account ordering"
                       ])

                   self.results["error_analysis"].append(analysis)

       async def run_full_debug(self):
           """Run complete debug suite"""
           logger.info("Starting comprehensive Raydium debug...")
           
           await self.verify_account_ownership()
           await self.analyze_amm_data()
           await self.test_account_orders()
           await self.analyze_errors()
           
           self.print_results()

       def print_results(self):
           """Print formatted debug results"""
           logger.info("\n=== Raydium Debug Results ===")
           
           logger.info("\n1. Account Ownership Verification:")
           for check in self.results["account_checks"]:
               status = "✅" if check["is_correct"] else "❌"
               logger.info(f"{status} {check['account']}: {check['actual_owner']}")

           logger.info("\n2. AMM Data Analysis:")
           for data in self.results["data_validation"]:
               logger.info(f"AMM Structure: {json.dumps(data['amm_data'], indent=2)}")

           logger.info("\n3. Account Order Tests:")
           for test in self.results["order_tests"]:
               status = "✅" if test["result"]["success"] else "❌"
               logger.info(f"\nOrder #{test['order_index']}: {status}")
               if not test["result"]["success"]:
                   logger.info(f"Error: {test['result']['error']}")

           logger.info("\n4. Error Analysis:")
           for analysis in self.results["error_analysis"]:
               logger.info(f"\nError Code: {analysis['error_code']}")
               logger.info("Possible causes:")
               for cause in analysis["possible_causes"]:
                   logger.info(f"- {cause}")
               logger.info("Suggested fixes:")
               for fix in analysis["suggested_fixes"]:
                   logger.info(f"- {fix}")

   debugger = RaydiumDebugger()
   await debugger.run_full_debug()

if __name__ == "__main__":
   asyncio.run(debug_raydium_setup())