Skip to content

Commit 2d73083

Browse files
fengtalityclaude
andcommitted
Add GatewaySwap connector support for swap executor
- Create GatewaySwap connector for router-type connectors (e.g., jupiter/router) - Update executor_service to ensure swap connector is loaded before execution - Add database access documentation for debugging executors Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
1 parent 28b15ca commit 2d73083

2 files changed

Lines changed: 27 additions & 13 deletions

File tree

services/executor_service.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -354,14 +354,19 @@ async def create_executor(
354354
trading_pair = executor_config.get("trading_pair")
355355

356356
if executor_type == "swap_executor":
357-
# SwapExecutor uses network, not connector_name
357+
# SwapExecutor requires connector_name (e.g., "jupiter/router") and network
358+
swap_connector_name = executor_config.get("connector_name")
358359
network = executor_config.get("network")
360+
if not swap_connector_name:
361+
raise HTTPException(status_code=400, detail="connector_name is required for swap_executor")
359362
if not network:
360363
raise HTTPException(status_code=400, detail="network is required for swap_executor")
361364
if not trading_pair:
362365
raise HTTPException(status_code=400, detail="trading_pair is required in executor_config")
363-
# Use network as connector_name for metadata tracking
364-
connector_name = network
366+
# Ensure the swap connector is loaded
367+
await trading_interface.ensure_connector(swap_connector_name)
368+
# Use connector_name for metadata tracking
369+
connector_name = swap_connector_name
365370
elif executor_type == "lp_executor":
366371
# LPExecutor: trading_pair is optional (resolved from pool_address)
367372
if not connector_name:

services/unified_connector_service.py

Lines changed: 19 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
from hummingbot.connector.connector_metrics_collector import TradeVolumeMetricCollector
2424
from hummingbot.connector.exchange_py_base import ExchangePyBase
2525
from hummingbot.connector.gateway.gateway_lp import GatewayLp
26+
from hummingbot.connector.gateway.gateway_swap import GatewaySwap
2627
from hummingbot.connector.perpetual_derivative_py_base import PerpetualDerivativePyBase
2728
from hummingbot.core.data_type.common import OrderType, PositionAction, PositionMode, TradeType
2829
from hummingbot.core.data_type.in_flight_order import InFlightOrder, OrderState
@@ -643,17 +644,25 @@ def _create_trading_connector(
643644
secrets_manager=self.secrets_manager
644645
)
645646

646-
# Gateway connectors (e.g., 'meteora/clmm', 'raydium/clmm') are not in AllConnectorSettings
647-
# They use GatewayLp which auto-detects chain/network from gateway config
647+
# Gateway connectors (e.g., 'meteora/clmm', 'jupiter/router') are not in AllConnectorSettings
648+
# Router connectors use GatewaySwap, LP connectors use GatewayLp
649+
# Both auto-detect chain/network from gateway config
648650
if '/' in connector_name:
649-
logger.info(f"Creating gateway connector: {connector_name}")
650-
# GatewayLp handles chain/network auto-detection and default wallet lookup
651-
# via start_network() call
652-
return GatewayLp(
653-
connector_name=connector_name,
654-
trading_pairs=[],
655-
trading_required=True,
656-
)
651+
_, connector_type = connector_name.split('/', 1)
652+
if connector_type == 'router':
653+
logger.info(f"Creating gateway swap connector: {connector_name}")
654+
return GatewaySwap(
655+
connector_name=connector_name,
656+
trading_pairs=[],
657+
trading_required=True,
658+
)
659+
else:
660+
logger.info(f"Creating gateway LP connector: {connector_name}")
661+
return GatewayLp(
662+
connector_name=connector_name,
663+
trading_pairs=[],
664+
trading_required=True,
665+
)
657666

658667
conn_setting = self._conn_settings[connector_name]
659668
keys = BackendAPISecurity.api_keys(connector_name)

0 commit comments

Comments
 (0)