Skip to content

Conversation

@fengtality
Copy link
Contributor

Summary

Gateway improvements to support the LP Position Executor in Hummingbot.

Related PR: hummingbot/hummingbot#7948

Key Changes

  • Position status distinction - Distinguish "Position closed" vs "Position not found" using transaction history lookup
  • strategyType support - Pass connector-specific params (e.g., Meteora strategyType) through unified CLMM open endpoint
  • Transaction fee separation - Separate tx fees and rent from token amounts in Meteora responses
  • Bins parameter - Optional bins parameter for pool-info endpoint
  • Error handling - Add TRANSACTION_TIMEOUT error code for tx confirmation failures

Files Modified

  • src/connectors/meteora/meteora.ts - Position status check using getSignaturesForAddress
  • src/connectors/meteora/clmm-routes/*.ts - Fee/rent separation, strategyType support
  • src/trading/trading-clmm-routes/open.ts - Pass extraParams to connector
  • src/services/error-handler.ts - TRANSACTION_TIMEOUT error code

Test plan

  • Verify "Position closed" error for closed positions (has transaction history)
  • Verify "Position not found" error for non-existent positions (no transaction history)
  • Test strategyType parameter works for Meteora positions
  • Verify tx fees are correctly separated from token amounts

🤖 Generated with Claude Code

fengtality and others added 10 commits December 27, 2025 07:13
Adds optional defaultNetworks array to Solana and Ethereum chain configs
to allow specifying which networks to query for balance operations. This
optimizes performance by avoiding queries to all 9+ networks when only
1-2 are needed.

Changes:
- Add defaultNetworks to chain schemas with additionalProperties: true
  for backwards compatibility
- Add defaultNetworks to SolanaChainConfig and EthereumChainConfig interfaces
- Update config getter functions to include defaultNetworks
- Add commented examples in template files

Closes #581

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Add optional strategyType parameter to /trading/clmm/open endpoint
to support Meteora-specific position strategies (Spot vs Curve).
This parameter is ignored by other connectors (Uniswap, Raydium, etc.).

- Update UnifiedOpenPositionRequest schema with strategyType field
- Pass strategyType to meteoraOpenPosition function
- Maintains backward compatibility (optional parameter)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Add support for requesting bin liquidity data in the unified
/trading/clmm/pool-info endpoint. This parameter is only supported
by Meteora connector and ignored by others.

Changes:
- Add optional `bins` boolean parameter to UnifiedPoolInfoRequest schema
- Pass bins parameter through getSolanaPoolInfo to Meteora connector
- Update Meteora's getPoolInfo to conditionally fetch bins (default: false)
- Make bins field optional in MeteoraPoolInfoSchema

Backward compatibility:
- bins parameter defaults to false (existing clients unaffected)
- bins parameter is optional (existing clients don't need to send it)
- Non-Meteora connectors ignore this parameter
- Fetching bins is expensive, so only done when explicitly requested

Usage:
  GET /trading/clmm/pool-info?connector=meteora&chainNetwork=solana-mainnet-beta&poolAddress=xxx&bins=true

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Changed Meteora pool-info to always include bins field in response
without requiring it as a request parameter. This maintains backward
compatibility while providing richer data for Meteora pools.

Changes:
- Remove bins parameter from pool-info request schema
- Always fetch and include bins in Meteora pool-info responses
- Other CLMM connectors (Raydium, Uniswap, etc.) remain unchanged
- Bins field is optional in schema for cross-connector compatibility

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Add ErrorCode enum with TRANSACTION_TIMEOUT code
- Add transactionTimeout helper in httpErrors
- Include error code in HTTP error response
- Use transactionTimeout error in solana.ts for confirmation failures

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
When a transaction is sent but not confirmed within the timeout period,
the gateway now returns the signature with status=0 (pending) instead
of throwing TRANSACTION_TIMEOUT error. This preserves the transaction
hash so callers can track/poll the transaction instead of losing it.

Changes:
- sendAndConfirmTransaction now returns {signature, fee, confirmed} with
  confirmed=false when tx sent but not confirmed (instead of throwing)
- All Meteora CLMM routes updated to handle confirmed=false and return
  pending status with signature
- Error is only thrown when transaction was never sent (no signature)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
When SOL is base/quote token, wallet balance changes include the
transaction fee and position rent. This fix properly separates these:

- openPosition: Use requested amounts, calculate rent separately
- closePosition: Track rent refund separately from liquidity
- addLiquidity: Subtract fee from SOL token amount
- removeLiquidity: Add fee back to SOL token amount

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Check transaction history to determine if a position was closed
(had transactions) vs never existed (no transactions).

This helps clients recognize when a close operation timed out but
actually succeeded on-chain.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
fengtality and others added 9 commits February 4, 2026 15:13
- GET /config?namespace=solana-mainnet-beta now returns merged chain + network config
- POST /config/update routes chain-level fields (defaultWallet, defaultNetwork, rpcProvider) to parent chain namespace
- Add comprehensive tests for chain-network config merging and routing

Chain-level fields that get routed:
- solana: defaultNetwork, defaultWallet, rpcProvider
- ethereum: defaultNetwork, defaultWallet

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Uncomment defaultNetworks in ethereum.yml and solana.yml templates
- Remove 'namespace' from templateDirectories since conf/namespace is
  never used for validation (schemas are loaded from dist/src/templates)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Remove hardcoded CHAIN_LEVEL_FIELDS mapping
- Check if field exists in chain config to determine routing
- Add defaultNetworks to test mock data

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
ETH (native token) is not in the token list because it's not an ERC20
contract. This caused price queries for ETH pairs to fail or return 0.

The fix converts ETH to WETH before token resolution since they have
equivalent value. This matches the existing pattern used in addLiquidity.

- Add native token detection using ethereum.nativeTokenSymbol
- Convert ETH to WETH for both baseToken and quoteToken (case-insensitive)
- Add tests for ETH-to-WETH conversion scenarios

Fixes #598

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Fixes "SwapRouter.swapERC20CallParameters is not a function" error
that occurred due to version mismatch between smart-order-router and
universal-router-sdk.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Handle edge cases where no swap is needed:
- Same token quotes (e.g., USDC/USDC) return price=1
- Native to wrapped token (e.g., ETH/WETH) return price=1
- Wrapped to native token (e.g., WETH/ETH) return price=1

This avoids unnecessary DEX router calls for equivalent tokens
and prevents errors when fetching prices for stablecoins against
themselves.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
V4 pool addresses are not configured for all chains (e.g., Base),
causing "Invariant failed: ADDRESSES" error. Restrict routing to
V2 and V3 protocols only.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
fengtality and others added 6 commits February 4, 2026 16:48
Return price=1 for:
- Same token quotes (e.g., USDC/USDC)
- Native/wrapped equivalents (SOL/WSOL, WSOL/SOL)

Prevents "Input and output mints are not allowed to be equal" error
from Jupiter API.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Switch from parallel Promise.all to sequential for-loop when fetching
all token balances to avoid RPC rate limiting and timeout errors.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@rapcmia rapcmia moved this from Backlog to Under Review in Pull Request Board Feb 9, 2026
@rapcmia rapcmia moved this from Under Review to Backlog in Pull Request Board Feb 9, 2026
@fengtality fengtality changed the base branch from main to development February 9, 2026 17:45
fengtality and others added 3 commits February 9, 2026 11:42
…ax clamping

- Add priorityFeeLevel as request parameter to /chains/solana/estimate-gas (default: High)
- Add maxPriorityFeePerCU config option to cap priority fees (default: 1.0 lamports/CU)
- Add getHeliusApiKey helper to extract API key from config or nodeURL
- Return priorityFeeLevel and priorityFeePerCUEstimate in response for debugging
- Add comprehensive tests for priority fee functionality

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Use confirmRetryInterval * confirmRetryCount for WebSocket timeout
instead of hardcoded 60 seconds, matching REST polling behavior.
Default: 1s * 10 = 10 seconds.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@fengtality fengtality marked this pull request as ready for review February 11, 2026 02:29
- Add 10-second cache for priority fee estimates to reduce RPC calls
- Return detailed fee result including priorityFeeLevel and raw estimate
- Update estimate-gas route to use new estimateGasPriceDetailed method
- Update tests to match new API and fix URL pattern assertions

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Backlog

Development

Successfully merging this pull request may close these issues.

2 participants