Skip to content

sync / Gateway development -> staging 2.13.0#609

Open
nikspz wants to merge 53 commits intostagingfrom
development
Open

sync / Gateway development -> staging 2.13.0#609
nikspz wants to merge 53 commits intostagingfrom
development

Conversation

@nikspz
Copy link
Contributor

@nikspz nikspz commented Feb 24, 2026

Before submitting this PR, please make sure:

  • Your code builds clean without any errors or warnings
  • You are using approved title ("feat/", "fix/", "docs/", "refactor/")

A description of the changes proposed in the pull request:

Tests performed by the developer:

Tips for QA testing:

fengtality and others added 30 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>
- 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>
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>
fengtality and others added 23 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>
- 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>
Switch from Metaplex-based openPositionWithMetadataIx to Token-2022
openPositionWithTokenExtensionsIx so position mint accounts have
MintCloseAuthority and can be fully closed, recovering all rent.

Changes:
- openPosition: use Token-2022 instructions and derive ATA with
  TOKEN_2022_PROGRAM_ID; calculate rent via direct getBalance queries
  on the 3 position accounts (mint, PDA, ATA)
- executeSwap: use swapV2Ix for Token-2022 token compatibility
- closePosition: calculate rent refund via direct getBalance queries
  before close TX; use collectFeesQuote for fee amounts instead of
  unreliable wallet SOL change extraction

Fixes #584
The Orca API can return stale price data. This change fetches the
whirlpool data directly from the blockchain and calculates the price
from sqrtPrice for accurate real-time pricing.

- Fetch on-chain whirlpool data using getWhirlpool()
- Calculate price from sqrtPrice using PriceMath.sqrtPriceX64ToPrice()
- Fetch vault balances for accurate token amounts
- Keep API data for analytics fields (tvlUsdc, yieldOverTvl)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Update tests to mock new dependencies:
- Mock Solana.getInstance for connection access
- Mock getMint from @solana/spl-token for decimal info
- Mock PriceMath.sqrtPriceX64ToPrice for price calculation
- Mock getWhirlpool for on-chain pool data
- Use valid Solana base58 addresses for vault mocks
- Add proper beforeEach reset for mock isolation

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Add _fetchTransactionWithRetry method with configurable retries
- Use retry logic in WebSocket and polling confirmation flows
- Use configurable timeout for WebSocket monitoring
- Apply retry to extractBalanceChangesAndFee for reliability

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
fix: use Token-2022 positions for full rent recovery on close for Orca
feat / Add defaultNetworks parameter to chain configs
Replace getMint from @solana/spl-token with fetchAllMint from
@solana-program/token-2022 to support both standard SPL Token and
Token2022 (Token Extensions) programs.

This fixes TokenInvalidAccountOwnerError when querying pools with
Token2022 tokens like PYUSD.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
fix / use on-chain data for real-time Orca pool price
…t/gateway into feat/connector-specific-params
…ra CLMM

Previously, rent was calculated by subtracting the requested liquidity amount
from the wallet's SOL balance change, which was incorrect. Now we extract
the actual rent from the position account's balance in the transaction:
- openPosition: uses position account's postBalance (newly created = rent)
- closePosition: uses position account's preBalance (before closing = refunded rent)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
feat: CLMM improvements for LP Position Executor
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.

4 participants