Use network as connector_name for Gateway executors#8150
Use network as connector_name for Gateway executors#8150nikspz merged 62 commits intodevelopmentfrom
Conversation
6d6da0d to
e497ff7
Compare
- Add retry logic with error code classification in gateway_base.py - Retryable: TRANSACTION_TIMEOUT (network issues) - Non-retryable: SIMULATION_FAILED, INSUFFICIENT_BALANCE, SLIPPAGE_EXCEEDED, etc. - Move retry handling from executors to connectors for consistency - Add gateway_utils.py for shared connector validation - Update gateway_lp.py and gateway_swap.py to return event objects Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- New executor for single swap operations on Gateway AMM connectors - Uses GatewaySwap connector's place_order for proper order tracking - Handles retry logic at connector level - Stores executed orders for position tracking (keep_position support) - State flow: NOT_STARTED -> EXECUTING -> COMPLETED/FAILED Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Add position tracking via held_position_orders (like GridExecutor) - Store ADD events as SELL, REMOVE events as BUY for standard P&L - Use tx_hash as deduplication key (unique per transaction) - Add connector validation with auto-normalization (/clmm suffix) - Support keep_position for position hold aggregation - Fix P&L calculation for failed executors - Use asdict(event) pattern for consistent serialization Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Add autoswap feature for automatic token swapping when balance insufficient - Add negative offset support for in-range positions - Fix _initial_position_created flag to only set when position is active - Add swap_provider and swap_buffer_pct config options - Improve status display with position tracking info - Ensure rebalance always uses side 1 or 2, never side 0 Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Add SwapExecutor to executor orchestrator registry - Fix orchestrator exit hang (break vs continue in stop loop) - Fix position hold edge cases (division by zero, NaN handling) - Add LP history JSON API via MQTT endpoint - Add lphistory JSON export for API consumption - Add simple_xemm_gateway example script Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
44ae7f1 to
a7119fe
Compare
- Change connector_name from DEX format (orca/clmm) to network format (solana-mainnet-beta) - Add dex_name field for DEX protocol name (e.g., "orca", "meteora") - Rename dex parameter to dex_name throughout for clarity - Combined GatewaySwap and GatewayLp into unified Gateway class - Update gateway swap command to use network format and auto-fetch default swap provider - Update gateway LP and pool commands for new architecture - Update all tests for new parameter naming Architecture: - connector_name: Network identifier (e.g., "solana-mainnet-beta") - dex_name: DEX protocol name (e.g., "orca", "jupiter") - trading_type: Pool type (e.g., "clmm", "amm", "router") Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Missed renaming dex field in the controller config. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Add get_default_swap_provider(network) method to GatewayHttpClient that auto-detects the default swap provider (router) for a network - Update lp_rebalancer to use the helper for autoswap feature - Make swap_provider config optional - uses network default if not set - Fix Gateway connector response parsing (networks/trading_types arrays) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Rename parameter from 'connector' to 'dex_type' throughout gateway LP command to prevent confusion with network connector. The dex_type parameter represents the DEX type in format 'dex_name/trading_type' (e.g., 'orca/clmm'), not the network connector. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
…ectors feat: refactor gateway connector architecture to use network format
GatewayHttpClient methods (quote_swap, execute_swap, execute_quote) expect
dex and trading_type as separate parameters, not connector.
- Add _parse_dex_name() helper to split "jupiter/router" into ("jupiter", "router")
- Update get_quote_price() to use dex and trading_type params
- Update _create_order() to use dex and trading_type params
- Require dex_name for swap operations on unified Gateway connector
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Update test_gateway_lp_command.py error message to match new "DEX type" wording - Rewrite test_gateway_lp.py to use new network-based connector architecture - Fix test_lp_executor.py to pass dex_name and trading_type to get_pool_info_by_address - Update test_swap_executor.py for new SwapExecutorConfig schema (connector_name as network, swap_provider field) - Fix test_executor_orchestrator.py incorrect NaN assertion for buy_amount_quote - Fix swap_executor.py to use config.connector_name instead of removed config.network Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Fix swap executor stuck in RUNNING state due to missing dex_name in place_order() and get_quote_price() calls - Refactor provider config: use lp_provider (format: "dex/trading_type") instead of separate dex_name + trading_type fields - Make swap_provider optional - resolves network default if not provided - Add parse_provider() utility to gateway_utils.py - Update lp_rebalancer controller to use new lp_provider field Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
When an order fails quickly (e.g., insufficient balance), the order tracker emits MarketOrderFailureEvent and removes the order. If the executor misses the event, it would get stuck in EXECUTING state forever. Now if the order is not found for 3 consecutive checks, the executor assumes the order failed and transitions to FAILED state. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
When connector lookup fails in _create_position() or _close_position(), the executor would return early without changing state, causing infinite retries. Now properly transitions to FAILED state. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
When keep_position=False, LP executor now executes a swap to return to the original position after closing the LP position, similar to how grid executor handles spot positions. Changes: - Add SWAPPING state to LPExecutorStates - Add active_swap_order tracking to LPExecutorState - Add _execute_closeout_swap() method to sell excess base or buy back base - Include fees in base diff calculation (consistent with position_hold) - Handle swap order status and failures The calculation matches position_hold tracking: - ADD stores: base_amount, quote_amount (initial deposit) - REMOVE stores: base_amount + base_fee, quote_amount + quote_fee (received) - Swap amount: (received_base) - initial_base Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Rate Oracle fixes: - Return None instead of Decimal(0) in _safe_get_last_traded_price on error - Filter out None values in _safe_get_last_traded_prices before setting prices - Add defensive checks in find_rate to skip division when price is zero Gateway LP command fixes: - Rename parser argument from 'connector' to 'dex_type' to match function signature - Add get_pool_info method to Gateway class that takes trading_pair, dex_name, trading_type - Update fetch_and_display_pool_info to accept dex_name and trading_type parameters - Derive is_clmm from trading_type instead of passing as separate parameter Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
The test now correctly expects {} instead of {"BTC-USDT": Decimal("0")}
when price fetch fails, matching the fix to avoid division by zero in rate oracle.
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
|
@nikspz both issues you found should be fixed now |
|
Commit 78777bc
Test
|
| @@ -84,41 +132,54 @@ async def control_task(self): | |||
| await self._create_position() | |||
|
|
|||
| case LPExecutorStates.OPENING: | |||
There was a problem hiding this comment.
in the future we might want to remove the extra state management and eval conditions when is running and when is shutting down as the rest of the executors
|
@rapcmia I think the I will check the |
Gateway LP command fixes: - Change connector=dex_type to dex=dex_name with trading_type in: - clmm_quote_position - amm_quote_liquidity - clmm_collect_fees Market data provider fixes: - Simplify gateway connector detection using chain-network format - Parse dex and trading_type from gateway_price_provider_by_chain - Fix get_price call to use dex/trading_type instead of connector Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Gateway LP command fixes: - Change connector=dex_type to dex=dex_name with trading_type in: - clmm_quote_position - amm_quote_liquidity - clmm_collect_fees Market data provider fixes: - Simplify gateway connector detection using chain-network format - Parse dex and trading_type from gateway_price_provider_by_chain - Fix get_price call to use dex/trading_type instead of connector Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Gateway connector now uses its _swap_provider (from network config) when dex_name is not explicitly provided. This allows arbitrage and other executors to call get_quote_price without passing dex_name. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Remove dex_name parameter from get_quote_price and get_order_price. Gateway connector now always uses its _swap_provider from network config. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Add get_dex_info() for DEX-format connectors (e.g., "orca/clmm") Returns (dex_name, trading_type, chain, network, error) - Simplify get_connector_chain_network() for network-format only (e.g., "solana-mainnet-beta") - Fix _parse_network() to use hardcoded chains instead of GATEWAY_CHAINS which may be empty before gateway connects - Update gateway commands to use appropriate helper based on connector format - Update tests to mock get_dex_info instead of get_connector_chain_network Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
nikspz
left a comment
There was a problem hiding this comment.
- latest commit ef065e0
- gateway lp issue fixed ✅
- added position successfully ✅
- gateway swap: ok
- gateway lp meteora/clmm position-info ❌ issue: No liquidity positions found for SOL-USDC (I'll create separate issue)
- gateway lp meteora/clmm remove-liquidity ❌ issue: No liquidity positions found for SOL-USDC (I'll create separate issue)
- gateway lp issue fixed ✅
- Convert markPx from string to float in hyperliquid _get_last_traded_price - Remove invalid pool_address argument from clmm_positions_owned call Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
|
Commit 118fd92
Logs, config and sqlite 17042026a.zip |
|
While wrapping up the PR, i also observed that quickstart issue still exist for both source and docker ❌
Previous comment #8150
Steps to reproduce:
|
- trading_core: Wait for gateway and register connectors before creating network-format connectors (e.g., "solana-mainnet-beta") in initialize_markets - start_command: Make _strategy_uses_gateway_connector async to register connectors before checking if they're gateway connectors This fixes the KeyError when using network-format connectors in quickstart because connectors weren't registered in AllConnectorSettings yet. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Fixes: - Remove dead code: duplicate self._name assignment in GatewayBase.__init__ - Fix mutable default argument: trading_pairs List[str]=[] -> Optional[List[str]]=None - Fix NO_ROUTE_FOUND comment contradiction (remove "can retry" mention) - Fix LPExecutor using stale pool_info.price, use self._current_price instead - Make SOL buffer configurable: add native_currency and native_currency_buffer config fields - Fix object.__setattr__ -> use Pydantic model_copy(update=...) for config updates - Fix type mismatch: _pending_swap_side typed as Optional[TradeType] not Optional[int] - Initialize _swap_not_found_count in __init__ instead of using getattr pattern - Fix Dict[Any] -> Dict[str, Any] type hint in get_gas_estimates - Extract hardcoded 'SOL' fallback to DEFAULT_NATIVE_CURRENCY constant - Fix _check_autoswap_needed parameter type: side should be TradeType not int Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
…traction After changing trading_pairs default to None, the token extraction loop would crash since it iterates over the raw parameter. Must use self._trading_pairs which has already been converted to empty list. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Instead of config fields in lp_rebalancer, add get_native_currency_buffer() method to GatewayBase that returns chain-specific buffer values: - SOL: 0.1 (~$15, covers rent + multiple txs) - ETH: 0.01 (~$25) - Others: 0.01 (conservative default) lp_rebalancer now fetches native_currency and buffer from the connector. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- SOL: 0.1 (~$15) - ETH: 0.005 (~$12) - Others: 0.005 Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
nikspz
left a comment
There was a problem hiding this comment.
- commit e89837e + gw-dev
- Test gateway lp commands
- gateway lp
meteora/clmmadd-liquidity SOL-USDC ✅ - gateway lp meteora/clmm position-info ✅
- gateway lp meteora/clmm remove-liquidity ✅
- gateway lp
- Test generic.lp_rebalancer
- quickstart: review issue fixed ✅
- docker started successfully ✅
- source: started successfully with bin/hummingbot_quickstart.py -p a --v2 conf_v2_with_controllers_1.yml ✅
- quickstart: review issue fixed ✅
- Test gateway lp commands




Summary
Refactors Gateway executors to use network identifier as
connector_name(e.g.,solana-mainnet-beta) instead of DEX format. Updates OrderExecutor and LPExecutor to work with this architecture, and updates lp_rebalancer controller to use both executors with autoswap support.Key Changes
Gateway Connector Architecture
connector_name: Now uses network identifier (e.g.,solana-mainnet-beta)lp_provider: New field for LP executor in formatdex/trading_type(e.g.,meteora/clmm)swap_provider: Auto-resolved from network config duringstart_network()OrderExecutor
_create_order()falls back toswap_providerwhendex_namenot providedexecuted_amount_base,average_executed_price,filled_amount_quotepropertiesLPExecutor
lp_providerfield instead of separatedex_name+trading_typekeep_position=False)gateway_base.pylp_providerto getdex_nameandtrading_typefor Gateway API callslp_rebalancer Controller
swap_providerconfig (uses network config automatically)Removed
gateway_lp.py,gateway_swap.pyclassesRelated PRs
Test plan