Skip to content

fix / correct Gateway connector import, save_pool content-type, and FastAPI redirect_slashes#159

Merged
fengtality merged 1 commit into
mainfrom
fix/gateway-lp-executor-and-pool-save
May 18, 2026
Merged

fix / correct Gateway connector import, save_pool content-type, and FastAPI redirect_slashes#159
fengtality merged 1 commit into
mainfrom
fix/gateway-lp-executor-and-pool-save

Conversation

@fengtality

Copy link
Copy Markdown
Contributor

Summary

Three small but impactful fixes to the gateway integration layer.

1. services/unified_connector_service.py — Gateway connector instantiates wrong class

Previously: from hummingbot.connector.gateway.gateway_base import GatewayBase as Gateway

The alias made _create_trading_connector instantiate GatewayBase for every Solana/EVM network connector. GatewayBase lacks the CLMM and swap methods that live on the Gateway subclass, so all LP executor operations on Gateway networks fail with errors like:

AttributeError: 'GatewayBase' object has no attribute 'get_pool_info_by_address'
AttributeError: 'GatewayBase' object has no attribute '_clmm_add_liquidity'

Fix: import the real Gateway subclass. Its __init__ is *args, **kwargssuper().__init__(), so the existing Gateway(connector_name=..., trading_pairs=[], trading_required=True) call site is unchanged.

2. services/gateway_client.pysave_pool triggers 415 Unsupported Media Type

save_pool was the only POST in this client that didn't pass json=. Without a JSON body, aiohttp sends no Content-Type header, and Fastify on the Gateway side rejects with:

{"detail": "Failed to save pool: Unsupported Media Type: application/octet-stream"}

This broke POST /gateway/networks/{network_id}/pools/save/{pool_address} entirely (the endpoint the Swagger UI fronts directly). Fix: pass json={} so aiohttp sets Content-Type: application/json.

3. main.py — disable trailing-slash redirects

Set redirect_slashes=False on the FastAPI app. Trailing-slash variants of routes were 307-redirecting, which interferes with Mintlify-driven docs routes that need to resolve cleanly without redirect indirection.

Test plan

  • Start the API and create an lp_executor against a Solana CLMM pool (e.g., Meteora) — verify the executor reaches OPENING state and successfully submits add_liquidity (previously failed with AttributeError on first control-task tick).
  • POST /gateway/networks/solana-mainnet-beta/pools/save/<known-pool-address> from the Swagger UI — verify a 200 response with pool data (previously returned 400 with the octet-stream error).
  • Verify trailing-slash routes (e.g., GET /accounts vs GET /accounts/) no longer 307-redirect.

🤖 Generated with Claude Code

…e, and FastAPI redirect_slashes

Three small but impactful fixes to gateway integration:

1. services/unified_connector_service.py: import the Gateway subclass, not
   GatewayBase. The previous `GatewayBase as Gateway` alias instantiated the
   base class for Solana/EVM network connectors, which lacks every CLMM and
   swap method. All LP executor operations failed with
   `AttributeError: 'GatewayBase' object has no attribute
   'get_pool_info_by_address'` / `_clmm_add_liquidity`.

2. services/gateway_client.py: pass `json={}` to the save_pool POST. Without
   it aiohttp sends no Content-Type, and Fastify rejects with HTTP 415
   "Unsupported Media Type: application/octet-stream". This broke
   POST /gateway/networks/{network_id}/pools/save/{pool_address} entirely.

3. main.py: set `redirect_slashes=False` on the FastAPI app so trailing-slash
   variants of routes are not 307-redirected (needed for Mintlify-driven docs
   routes to resolve cleanly).

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@fengtality fengtality requested a review from rapcmia May 15, 2026 14:00
@rapcmia rapcmia self-assigned this May 15, 2026
@rapcmia rapcmia changed the title fix(gateway): correct Gateway connector import, save_pool content-type, and FastAPI redirect_slashes fix / correct Gateway connector import, save_pool content-type, and FastAPI redirect_slashes May 15, 2026

@rapcmia rapcmia left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • Test LP executor on Meteora CLMM ✅
    • Started from a live Meteora SOL-USDC CLMM pool on solana-mainnet-beta
    • Created the lp_executor successfully through POST /executors/ ok
    • Executor logs showed the open-position flow calling Gateway successfully
    • Gateway returned a transaction signature instead of failing on the first control-task tick
    • A live position was created at aRSXTycuNLZ9jVY4aynPPa447Q69Q8rpmxvgtSNshyZ
    • No AttributeError related to missing Gateway LP methods was seen in the executor logs
  • Test save Solana CLMM pool ✅
    • Called POST /gateway/networks/solana-mainnet-beta/pools/save/3C5YE97HADPDxZehYq9Cis8AXr9aNyrUsczKzE1nDbW9 (TRUMP-USDC)
    • Route returned success with pool data for the Meteora TRUMP-USDC CLMM pool
    • Response included the saved pool metadata instead of the earlier unsupported media type failure
    • Gateway auto-added the TRUMP token during the save flow
  • Test trailing-slash behavior
    • GET /accounts returned 404 and GET /accounts/ returned 200
    • POST /portfolio/state returned 200 and POST /portfolio/state/ returned 404
    • GET /accounts/master_account/credentials returned 200 and GET /accounts/master_account/credentials/ returned 404
    • GET /bot-orchestration/status returned 200 and GET /bot-orchestration/status/ returned 404
    • No 307 redirects were observed on these sampled routes ✅
    • GET /docker/available-images/ returned 500, which appears to be a separate existing route issue ❌
      • Created separate issue #160

@fengtality

Copy link
Copy Markdown
Contributor Author

@rapcmia Thanks - the issue below is caused by the / at end of certain routes. I will address it later.

GET /docker/available-images/ returned 500, which appears to be a separate existing route issue ❌

@fengtality fengtality merged commit 8152d09 into main May 18, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants