feat(clmm): bin_count, CLMM liquidity methods, and orphan-closable positions (1.5.8) - #25
Open
fengtality wants to merge 9 commits into
Open
feat(clmm): bin_count, CLMM liquidity methods, and orphan-closable positions (1.5.8)#25fengtality wants to merge 9 commits into
fengtality wants to merge 9 commits into
Conversation
get_pool_info could not request the per-tick liquidity distribution, so callers wanting bins had to bypass the client and hit the endpoint directly. It now forwards bin_count, which hummingbot-api passes to Gateway. Meteora always returns its bins and ignores it; orca, raydium, uniswap and pancakeswap compute them on request, so the default of 0 keeps pool-info cheap. Also drops the stale note about Raydium rejecting Standard AMM pools — that came from hummingbot-api's direct-Raydium-API path, which has been removed in favour of routing every CLMM connector through Gateway. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This was referenced Aug 13, 2026
…ct_fees The API has POST /gateway/clmm/add and /remove, but this router never exposed them — the only way to shed CLMM liquidity through the client was a full close. Adds add_liquidity() and remove_liquidity(), and documents the distinction that matters: remove_liquidity(percentage=100) empties a position but leaves the account open, while close_position() closes it. close_position() and collect_fees() gain an optional pool_address. The API reads a position's pool from its own database; positions opened by an lp_executor are never in it, because the bot opens those straight against Gateway. Without pool_address those calls now fail with a 400, so recovering an orphaned position requires passing it — GET /executors/positions/orphaned reports it per orphan. Folded into the unreleased 1.5.8. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Mt84XBEMVxbbyMG8fDxDKj
3 tasks
The API's pool_address parameter was a silent no-op (Gateway's positions-owned route has no pool filter), removed there; drop it here too. Each returned row carries its own pool_address. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0166iQoxKce23GkUwuQJxdkr
…tion_info Mirrors the new hummingbot-api endpoints closing the gaps against Gateway's unified trading routes: pre-trade position quoting, CLMM pool creation (AMM had it, CLMM did not), and fetching one position by address. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0166iQoxKce23GkUwuQJxdkr
Both AMM and CLMM create_pool take extra_params (Gateway-native key names: configAddress, feeConfigIndex, openTime, binStep, feeBps, ammConfigIndex, fee, tickSpacing, ammConfig, gasPrice, maxGas, slippagePct) instead of per-connector named kwargs — the same contract as clmm open. Unknown keys are rejected by the API. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0166iQoxKce23GkUwuQJxdkr
…e_to_remove; extras coverage - Never force slippage to 1.0: omit the field when the caller omits it so the connector-configured slippage applies; an explicit 0 is preserved (swap quote/execute, clmm open/add, amm execute-swap/add-liquidity). - Send search filters as query parameters on /gateway/swaps/search and /gateway/clmm/positions/search — hapi reads query params on those POSTs and silently ignored the JSON body, so filters, pagination, and refresh never applied. - Rename CLMM remove_liquidity's percentage to percentage_to_remove (hapi's field name; the old key 422s) and expose slippage_pct (orca honors it). - Expose extra_params on swap quote/execute (approximateIfNoExactOut for the jupiter/dflow/okx/titan routers) and clmm add_liquidity; add slippage_pct to amm create_pool. - Correct create-pool docstrings to the accepted extra_params vocabulary (binStep/feeBps/ammConfigIndex/configAddress) and drop keys hapi rejects; fix the swaps-summary example to volume_by_quote_token. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0166iQoxKce23GkUwuQJxdkr
hapi removed /gateway/amm/quote-swap and execute-swap after Gateway folded them into the unified /trading/swap route; use gateway_swap.get_swap_quote/execute_swap with connector as name/type (e.g. 'raydium/amm', 'meteora/clmm'). Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0166iQoxKce23GkUwuQJxdkr
hapi's /gateway/clmm/pools takes a network parameter instead of assuming mainnet-beta; without it here, no caller could reach any other network. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0166iQoxKce23GkUwuQJxdkr
add_pool POSTed to /gateway/pools, which exists only as a deprecated GET,
and omitted the required base_address/quote_address; delete_pool called
/gateway/pools/{address}, which hapi does not serve at all. Both were
404/405s. The network-scoped add_network_pool/delete_network_pool already
cover the same ground correctly and are what every caller uses.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0166iQoxKce23GkUwuQJxdkr
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Two additions to
gateway_clmm, both in the unreleased 1.5.8:bin_countonget_pool_info, and the missing liquidity methods needed to manage a CLMM position.Until now the method could not ask for bins at all. Meteora returns its own
binsunconditionally, so it appeared to work — but every other CLMM connector computes them only on request, and there was no way to make that request through the client. Callers who wanted bins had to bypass the typed method and hit the endpoint directly.The parameter is only sent when non-zero, so existing calls are byte-identical on the wire.
Also drops a stale note in the docstring claiming Raydium returns 400 for Standard AMM pools — that behaviour came from hummingbot-api's direct-Raydium-API path, which hummingbot/hummingbot-api#217 removes in favour of routing every CLMM connector through Gateway.
CLMM liquidity:
add_liquidity,remove_liquidity, andpool_addressThe API has had
POST /gateway/clmm/addand/removeall along, but this router never exposed them — the only way to shed CLMM liquidity through the client was a full close.remove_liquidity(percentage=100)empties a position but leaves the account open;close_position()closes it. The docstrings now say so, because picking the wrong one is how an "already closed" position keeps showing up on-chain.close_position()andcollect_fees()also gain an optionalpool_address. The API reads a position's pool from its own database, and positions opened by anlp_executorare never in it — the bot opens those straight against Gateway. Withoutpool_addressthose calls fail with a400, so recovering an orphaned LP position requires passing it;GET /executors/positions/orphanedreports it per orphan. This is what lets condor's newmanage_clmmtool close an orphan at all.Requires
pool_addresson close/collect-fees is accepted by hummingbot/hummingbot-api#217; against an older API server those calls still404for positions it never recorded.bin_countis forwarded by hummingbot/hummingbot-api#217 to Gateway's unified/trading/clmm/pool-info, which learnsbinCountin hummingbot/gateway#679. Against an older API server the parameter is ignored, not an error.Companion PRs
docs/retry-architecture.md(in the gateway PR)binCounton unified CLMM pool-infoPOSITION_HOLD, fresh position reads, bounded pending-tx pollingbin_countpassthrough, Raydium routed through Gatewaybin_countonget_pool_info(1.5.8)bin_countonget_pool_infoValidation
Verified against a live mainnet stack (Gateway + hummingbot-api deployed from the companion branches):
bin_count=61returns 61 populated bins for orca, raydium, uniswap and pancakeswap, while Meteora keeps returning its own 141 and ignores the parameter.bin_count=0returns none for all of them.The liquidity methods are wire-compatible additions over endpoints the API already served; they are exercised through condor's
manage_clmmtests rather than live here.🤖 Generated with Claude Code
https://claude.ai/code/session_01Mt84XBEMVxbbyMG8fDxDKj