mirror of
https://github.com/chainstacklabs/pumpfun-bonkfun-bot.git
synced 2026-08-06 12:07:45 +00:00
feat(core): cleanup address management system
This commit is contained in:
@@ -4,8 +4,9 @@ Event processing for pump.fun tokens using PumpPortal data.
|
||||
|
||||
from solders.pubkey import Pubkey
|
||||
|
||||
from core.pubkeys import PumpAddresses, SystemAddresses
|
||||
from trading.base import TokenInfo
|
||||
from core.pubkeys import SystemAddresses
|
||||
from interfaces.core import Platform, TokenInfo
|
||||
from platforms.pumpfun.address_provider import PumpFunAddresses
|
||||
from utils.logger import get_logger
|
||||
|
||||
logger = get_logger(__name__)
|
||||
@@ -14,13 +15,13 @@ logger = get_logger(__name__)
|
||||
class PumpPortalEventProcessor:
|
||||
"""Processes token creation events from PumpPortal WebSocket."""
|
||||
|
||||
def __init__(self, pump_program: Pubkey):
|
||||
def __init__(self, pump_program: Pubkey | None = None):
|
||||
"""Initialize event processor.
|
||||
|
||||
Args:
|
||||
pump_program: Pump.fun program address
|
||||
pump_program: Pump.fun program address (optional, will use default if None)
|
||||
"""
|
||||
self.pump_program = pump_program
|
||||
self.pump_program = pump_program or PumpFunAddresses.PROGRAM
|
||||
|
||||
def process_token_data(self, token_data: dict) -> TokenInfo | None:
|
||||
"""Process token data from PumpPortal and extract token creation info.
|
||||
@@ -71,6 +72,7 @@ class PumpPortalEventProcessor:
|
||||
symbol=symbol,
|
||||
uri=uri,
|
||||
mint=mint,
|
||||
platform=Platform.PUMP_FUN,
|
||||
bonding_curve=bonding_curve,
|
||||
associated_bonding_curve=associated_bonding_curve,
|
||||
user=user,
|
||||
@@ -118,6 +120,6 @@ class PumpPortalEventProcessor:
|
||||
"""
|
||||
derived_address, _ = Pubkey.find_program_address(
|
||||
[b"creator-vault", bytes(creator)],
|
||||
PumpAddresses.PROGRAM,
|
||||
PumpFunAddresses.PROGRAM,
|
||||
)
|
||||
return derived_address
|
||||
return derived_address
|
||||
@@ -9,9 +9,10 @@ from collections.abc import Awaitable, Callable
|
||||
import websockets
|
||||
from solders.pubkey import Pubkey
|
||||
|
||||
from interfaces.core import TokenInfo
|
||||
from monitoring.base_listener import BaseTokenListener
|
||||
from monitoring.pumpportal_event_processor import PumpPortalEventProcessor
|
||||
from trading.base import TokenInfo
|
||||
from platforms.pumpfun.address_provider import PumpFunAddresses
|
||||
from utils.logger import get_logger
|
||||
|
||||
logger = get_logger(__name__)
|
||||
@@ -22,18 +23,19 @@ class PumpPortalListener(BaseTokenListener):
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
pump_program: Pubkey,
|
||||
pump_program: Pubkey | None = None,
|
||||
pumpportal_url: str = "wss://pumpportal.fun/api/data",
|
||||
):
|
||||
"""Initialize token listener.
|
||||
|
||||
Args:
|
||||
pump_program: Pump.fun program address
|
||||
pump_program: Pump.fun program address (optional, will use default if None)
|
||||
pumpportal_url: PumpPortal WebSocket URL
|
||||
"""
|
||||
self.pump_program = pump_program
|
||||
super().__init__()
|
||||
self.pump_program = pump_program or PumpFunAddresses.PROGRAM
|
||||
self.pumpportal_url = pumpportal_url
|
||||
self.event_processor = PumpPortalEventProcessor(pump_program)
|
||||
self.event_processor = PumpPortalEventProcessor(self.pump_program)
|
||||
self.ping_interval = 20 # seconds
|
||||
|
||||
async def listen_for_tokens(
|
||||
@@ -171,4 +173,4 @@ class PumpPortalListener(BaseTokenListener):
|
||||
except Exception as e:
|
||||
logger.error(f"Error processing PumpPortal WebSocket message: {e}")
|
||||
|
||||
return None
|
||||
return None
|
||||
Reference in New Issue
Block a user