feat: add geyser auth type, compare listeners for new tokens

This commit is contained in:
smypmsa
2025-05-06 08:39:09 +00:00
parent 9a26aa7532
commit aa145dc018
8 changed files with 674 additions and 13 deletions
+1
View File
@@ -60,6 +60,7 @@ async def start_bot(config_path: str):
# Geyser configuration (if applicable)
geyser_endpoint=cfg.get("geyser", {}).get("endpoint"),
geyser_api_token=cfg.get("geyser", {}).get("api_token"),
geyser_auth_type=cfg.get("geyser", {}).get("auth_type"),
# Priority fee configuration
enable_dynamic_priority_fee=cfg.get("priority_fees", {}).get("enable_dynamic", False),
+10 -5
View File
@@ -20,26 +20,31 @@ logger = get_logger(__name__)
class GeyserListener(BaseTokenListener):
"""Geyser listener for pump.fun token creation events."""
def __init__(self, geyser_endpoint: str, geyser_api_token: str, pump_program: Pubkey):
def __init__(self, geyser_endpoint: str, geyser_api_token: str, geyser_auth_type: str, pump_program: Pubkey):
"""Initialize token listener.
Args:
geyser_endpoint: Geyser gRPC endpoint URL
geyser_api_token: API token for authentication
geyser_auth_type: authentication type ('x-token' or 'basic')
pump_program: Pump.fun program address
"""
self.geyser_endpoint = geyser_endpoint
self.geyser_api_token = geyser_api_token
self.auth_type = geyser_auth_type or "x-token"
self.pump_program = pump_program
self.event_processor = GeyserEventProcessor(pump_program)
async def _create_geyser_connection(self):
"""Establish a secure connection to the Geyser endpoint."""
auth = grpc.metadata_call_credentials(
lambda context, callback: callback(
(("authorization", f"Basic {self.geyser_api_token}"),), None
if self.auth_type == "x-token":
auth = grpc.metadata_call_credentials(
lambda _, callback: callback((("x-token", self.geyser_api_token),), None)
)
else: # Default to basic auth
auth = grpc.metadata_call_credentials(
lambda _, callback: callback((("authorization", f"Basic {self.geyser_api_token}"),), None)
)
)
creds = grpc.composite_channel_credentials(
grpc.ssl_channel_credentials(), auth
)
+4 -1
View File
@@ -48,6 +48,7 @@ class PumpTrader:
listener_type: str = "logs",
geyser_endpoint: str | None = None,
geyser_api_token: str | None = None,
geyser_auth_type: str = "x-token",
extreme_fast_mode: bool = False,
extreme_fast_token_amount: int = 30,
@@ -90,6 +91,7 @@ class PumpTrader:
listener_type: Type of listener to use ('logs', 'blocks', or 'geyser')
geyser_endpoint: Geyser endpoint URL (required for geyser listener)
geyser_api_token: Geyser API token (required for geyser listener)
geyser_auth_type: Geyser authentication type ('x-token' or 'basic')
extreme_fast_mode: Whether to enable extreme fast mode
extreme_fast_token_amount: Maximum token amount for extreme fast mode
@@ -155,7 +157,8 @@ class PumpTrader:
self.token_listener = GeyserListener(
geyser_endpoint,
geyser_api_token,
geyser_api_token,
geyser_auth_type,
PumpAddresses.PROGRAM
)
logger.info("Using Geyser listener for token monitoring")