wip(core): platform aware trading

This commit is contained in:
smypmsa
2025-08-02 11:30:30 +00:00
parent bb35101a8f
commit 9ec9eeb793
19 changed files with 726 additions and 2038 deletions
+39 -17
View File
@@ -6,7 +6,7 @@ platform-specific implementations of the trading interfaces.
"""
from dataclasses import dataclass
from typing import Any, Dict, Optional, Type
from typing import Any
from core.client import SolanaClient
from interfaces.core import (
@@ -17,8 +17,6 @@ from interfaces.core import (
Platform,
)
from . import letsbonk, pumpfun
@dataclass
class PlatformImplementations:
@@ -145,21 +143,45 @@ class PlatformFactory:
self._setup_default_platforms()
def _setup_default_platforms(self) -> None:
"""Setup default platform registrations.
"""Setup default platform registrations."""
# Import platform implementations dynamically to avoid circular imports
try:
from platforms.pumpfun import (
PumpFunAddressProvider,
PumpFunCurveManager,
PumpFunEventParser,
PumpFunInstructionBuilder,
)
self.registry.register_platform(
Platform.PUMP_FUN,
PumpFunAddressProvider,
PumpFunInstructionBuilder,
PumpFunCurveManager,
PumpFunEventParser
)
except ImportError as e:
print(f"Warning: Could not register pump.fun platform: {e}")
This will be populated as we implement each platform.
"""
# Platforms will be registered here as they are implemented
# Example:
# from platforms.pumpfun import PumpFunAddressProvider, PumpFunInstructionBuilder, ...
# self.registry.register_platform(
# Platform.PUMP_FUN,
# PumpFunAddressProvider,
# PumpFunInstructionBuilder,
# PumpFunCurveManager,
# PumpFunEventParser
# )
pass
try:
from platforms.letsbonk import (
LetsBonkAddressProvider,
LetsBonkCurveManager,
LetsBonkEventParser,
LetsBonkInstructionBuilder,
)
self.registry.register_platform(
Platform.LETS_BONK,
LetsBonkAddressProvider,
LetsBonkInstructionBuilder,
LetsBonkCurveManager,
LetsBonkEventParser
)
except ImportError as e:
print(f"Warning: Could not register LetsBonk platform: {e}")
def create_for_platform(
self,
+3 -15
View File
@@ -1,27 +1,15 @@
"""
LetsBonk platform registration and exports.
LetsBonk platform exports.
This module registers all LetsBonk implementations with the platform factory
and provides convenient imports for the LetsBonk platform.
This module provides convenient imports for the LetsBonk platform implementations.
Platform registration is now handled by the main platform factory.
"""
from interfaces.core import Platform
from platforms import register_platform_implementations
from .address_provider import LetsBonkAddressProvider
from .curve_manager import LetsBonkCurveManager
from .event_parser import LetsBonkEventParser
from .instruction_builder import LetsBonkInstructionBuilder
# Register LetsBonk platform implementations
register_platform_implementations(
Platform.LETS_BONK,
LetsBonkAddressProvider,
LetsBonkInstructionBuilder,
LetsBonkCurveManager,
LetsBonkEventParser
)
# Export implementations for direct use if needed
__all__ = [
'LetsBonkAddressProvider',
+3 -15
View File
@@ -1,27 +1,15 @@
"""
Pump.Fun platform registration and exports.
Pump.Fun platform exports.
This module registers all pump.fun implementations with the platform factory
and provides convenient imports for the pump.fun platform.
This module provides convenient imports for the pump.fun platform implementations.
Platform registration is now handled by the main platform factory.
"""
from interfaces.core import Platform
from platforms import register_platform_implementations
from .address_provider import PumpFunAddressProvider
from .curve_manager import PumpFunCurveManager
from .event_parser import PumpFunEventParser
from .instruction_builder import PumpFunInstructionBuilder
# Register pump.fun platform implementations
register_platform_implementations(
Platform.PUMP_FUN,
PumpFunAddressProvider,
PumpFunInstructionBuilder,
PumpFunCurveManager,
PumpFunEventParser
)
# Export implementations for direct use if needed
__all__ = [
'PumpFunAddressProvider',