mirror of
https://github.com/chainstacklabs/pumpfun-bonkfun-bot.git
synced 2026-07-27 23:37:45 +00:00
removed unused imports, minor fixes
This commit is contained in:
@@ -7,7 +7,6 @@ import argparse
|
||||
import asyncio
|
||||
import os
|
||||
import sys
|
||||
from typing import Any, Dict
|
||||
|
||||
import config
|
||||
from src.trading.trader import PumpTrader
|
||||
|
||||
+2
-3
@@ -3,13 +3,12 @@ Solana client abstraction for blockchain operations.
|
||||
"""
|
||||
|
||||
import asyncio
|
||||
from typing import Any, Dict
|
||||
from typing import Any
|
||||
|
||||
from solana.rpc.async_api import AsyncClient
|
||||
from solana.rpc.commitment import Confirmed
|
||||
from solana.rpc.types import TxOpts
|
||||
from solders.hash import Hash
|
||||
from solders.keypair import Keypair
|
||||
from solders.pubkey import Pubkey
|
||||
from solders.transaction import Transaction
|
||||
|
||||
@@ -46,7 +45,7 @@ class SolanaClient:
|
||||
await self._client.close()
|
||||
self._client = None
|
||||
|
||||
async def get_account_info(self, pubkey: Pubkey) -> Dict[str, Any]:
|
||||
async def get_account_info(self, pubkey: Pubkey) -> dict[str, Any]:
|
||||
"""Get account info from the blockchain.
|
||||
|
||||
Args:
|
||||
|
||||
@@ -6,7 +6,6 @@ import struct
|
||||
from typing import Final
|
||||
|
||||
from construct import Flag, Int64ul, Struct
|
||||
from solana.rpc.async_api import AsyncClient
|
||||
from solders.pubkey import Pubkey
|
||||
|
||||
from src.core.client import SolanaClient
|
||||
|
||||
@@ -5,7 +5,7 @@ Event processing for pump.fun tokens.
|
||||
import base64
|
||||
import json
|
||||
import struct
|
||||
from typing import Any, Dict, List, Optional
|
||||
from typing import Any
|
||||
|
||||
from solders.pubkey import Pubkey
|
||||
from solders.transaction import VersionedTransaction
|
||||
@@ -31,7 +31,7 @@ class PumpEventProcessor:
|
||||
self.pump_program = pump_program
|
||||
self._idl = self._load_idl()
|
||||
|
||||
def _load_idl(self) -> Dict[str, Any]:
|
||||
def _load_idl(self) -> dict[str, Any]:
|
||||
"""Load IDL from file.
|
||||
|
||||
Returns:
|
||||
@@ -56,7 +56,7 @@ class PumpEventProcessor:
|
||||
]
|
||||
}
|
||||
|
||||
def process_transaction(self, tx_data: str) -> Optional[TokenInfo]:
|
||||
def process_transaction(self, tx_data: str) -> TokenInfo | None:
|
||||
"""Process a transaction and extract token info.
|
||||
|
||||
Args:
|
||||
@@ -130,8 +130,8 @@ class PumpEventProcessor:
|
||||
return None
|
||||
|
||||
def _decode_create_instruction(
|
||||
self, ix_data: bytes, ix_def: Dict[str, Any], accounts: List[Pubkey]
|
||||
) -> Dict[str, Any]:
|
||||
self, ix_data: bytes, ix_def: dict[str, Any], accounts: list[Pubkey]
|
||||
) -> dict[str, Any]:
|
||||
"""Decode create instruction data.
|
||||
|
||||
Args:
|
||||
|
||||
@@ -4,7 +4,7 @@ WebSocket monitoring for pump.fun tokens.
|
||||
|
||||
import asyncio
|
||||
import json
|
||||
from typing import Awaitable, Callable, Optional
|
||||
from collections.abc import Awaitable, Callable
|
||||
|
||||
import websockets
|
||||
from solders.pubkey import Pubkey
|
||||
@@ -138,7 +138,7 @@ class PumpTokenListener:
|
||||
except Exception as e:
|
||||
logger.error(f"Ping error: {str(e)}")
|
||||
|
||||
async def _wait_for_token_creation(self, websocket) -> Optional[TokenInfo]:
|
||||
async def _wait_for_token_creation(self, websocket) -> TokenInfo | None:
|
||||
"""Wait for token creation event.
|
||||
|
||||
Args:
|
||||
|
||||
+3
-4
@@ -4,10 +4,9 @@ Base interfaces for trading operations.
|
||||
|
||||
from abc import ABC, abstractmethod
|
||||
from dataclasses import dataclass
|
||||
from typing import Any, Dict, List, Optional, Tuple
|
||||
from typing import Any
|
||||
|
||||
from solders.pubkey import Pubkey
|
||||
from solders.signature import Signature
|
||||
|
||||
|
||||
@dataclass
|
||||
@@ -23,7 +22,7 @@ class TokenInfo:
|
||||
user: Pubkey
|
||||
|
||||
@classmethod
|
||||
def from_dict(cls, data: Dict[str, Any]) -> "TokenInfo":
|
||||
def from_dict(cls, data: dict[str, Any]) -> "TokenInfo":
|
||||
"""Create TokenInfo from dictionary.
|
||||
|
||||
Args:
|
||||
@@ -42,7 +41,7 @@ class TokenInfo:
|
||||
user=Pubkey.from_string(data["user"]),
|
||||
)
|
||||
|
||||
def to_dict(self) -> Dict[str, str]:
|
||||
def to_dict(self) -> dict[str, str]:
|
||||
"""Convert to dictionary.
|
||||
|
||||
Returns:
|
||||
|
||||
@@ -2,20 +2,13 @@
|
||||
Buy operations for pump.fun tokens.
|
||||
"""
|
||||
|
||||
import asyncio
|
||||
import struct
|
||||
from typing import Final, List, Optional
|
||||
from typing import Final
|
||||
|
||||
import spl.token.instructions as spl_token
|
||||
from solana.rpc.async_api import AsyncClient
|
||||
from solana.rpc.commitment import Confirmed
|
||||
from solana.rpc.types import TxOpts
|
||||
from solders.hash import Hash
|
||||
from solders.instruction import AccountMeta, Instruction
|
||||
from solders.keypair import Keypair
|
||||
from solders.message import Message
|
||||
from solders.pubkey import Pubkey
|
||||
from solders.system_program import TransferParams, transfer
|
||||
from solders.transaction import Transaction
|
||||
from spl.token.instructions import create_associated_token_account
|
||||
|
||||
|
||||
@@ -2,9 +2,8 @@
|
||||
Sell operations for pump.fun tokens.
|
||||
"""
|
||||
|
||||
import asyncio
|
||||
import struct
|
||||
from typing import Final, Optional
|
||||
from typing import Final
|
||||
|
||||
from solders.hash import Hash
|
||||
from solders.instruction import AccountMeta, Instruction
|
||||
|
||||
@@ -7,7 +7,6 @@ import asyncio
|
||||
import json
|
||||
import os
|
||||
from datetime import datetime
|
||||
from typing import Dict, Optional, Set
|
||||
|
||||
import config
|
||||
from src.core.client import SolanaClient
|
||||
@@ -74,13 +73,13 @@ class PumpTrader:
|
||||
self.buy_slippage = buy_slippage
|
||||
self.sell_slippage = sell_slippage
|
||||
self.max_retries = max_retries
|
||||
self.max_token_age = max_token_age
|
||||
self.max_token_age = 1 # seconds
|
||||
|
||||
# Token processing state
|
||||
self.token_queue = asyncio.Queue()
|
||||
self.processing = False
|
||||
self.processed_tokens: Set[str] = set()
|
||||
self.token_timestamps: Dict[str, float] = {}
|
||||
self.processed_tokens: set[str] = set()
|
||||
self.token_timestamps: dict[str, float] = {}
|
||||
|
||||
async def start(
|
||||
self,
|
||||
@@ -139,7 +138,6 @@ class PumpTrader:
|
||||
async def _process_token_queue(self, marry_mode: bool, yolo_mode: bool) -> None:
|
||||
"""Continuously process tokens from the queue, only if they're fresh."""
|
||||
while True:
|
||||
# Get next token
|
||||
token_info = await self.token_queue.get()
|
||||
token_key = str(token_info.mint)
|
||||
|
||||
@@ -156,16 +154,13 @@ class PumpTrader:
|
||||
self.token_queue.task_done()
|
||||
continue
|
||||
|
||||
# Mark as processing
|
||||
self.processed_tokens.add(token_key)
|
||||
|
||||
# Process token
|
||||
logger.info(
|
||||
f"Processing fresh token: {token_info.symbol} (age: {token_age:.1f}s)"
|
||||
)
|
||||
await self._handle_token(token_info, marry_mode, yolo_mode)
|
||||
|
||||
# Mark queue task as done
|
||||
self.token_queue.task_done()
|
||||
|
||||
async def _handle_token(
|
||||
|
||||
+1
-2
@@ -4,10 +4,9 @@ Logging utilities for the pump.fun trading bot.
|
||||
|
||||
import logging
|
||||
import sys
|
||||
from typing import Dict
|
||||
|
||||
# Global dict to store loggers
|
||||
_loggers: Dict[str, logging.Logger] = {}
|
||||
_loggers: dict[str, logging.Logger] = {}
|
||||
|
||||
|
||||
def get_logger(name: str, level: int = logging.INFO) -> logging.Logger:
|
||||
|
||||
Reference in New Issue
Block a user