这是indexloc提供的服务,不要输入任何密码
Skip to content

Conversation

@fengtality
Copy link
Contributor

Summary

This PR fixes two critical issues with Solana token account handling and Meteora position creation:

  1. StructError from Helius mixed responses - When Helius RPC returns token accounts with mixed parsed/base64 data, the Solana web3.js library throws a StructError during validation
  2. Meteora InvalidPositionWidth error handling - Position width constraint violations now return clear error messages to users

Changes

Helius Mixed Response Handling

  • Added fetchTokenAccountsBase64() fallback method that uses base64 encoding exclusively
  • Updated fetchTokenAccounts() to catch StructError and fall back to base64 encoding
  • Updated deprecated getBalance() method to handle mixed responses
  • Ensures compatibility with Helius RPC's occasional base64 fallback for unparseable token accounts

Meteora Position Width Error Handling

  • Added specific error handler for InvalidPositionWidth (error code 6040/0x1798)
  • Returns clear message: "Error Code: InvalidPositionWidth. Error Number: 6040. Error Message: Invalid position width. Please use a position width of 69 bins or lower."
  • Fixed Meteora openPosition route to preserve actual error messages instead of generic "Request failed"

Code Quality Improvements

  • Removed balance validation from Meteora openPosition to align with PancakeSwap-Sol behavior
  • Balance checks now happen at transaction execution time (cleaner approach)
  • Avoids deprecated getBalance() method in connector code

Test Plan

  • Tested Meteora position opening with valid narrow range (120-170) - succeeds
  • Tested Meteora position opening with invalid wide range (100-200) - returns proper error message
  • Verified quote-position endpoint still works correctly
  • Confirmed StructError no longer occurs with Helius RPC

🤖 Generated with Claude Code

rapcmia and others added 4 commits September 23, 2025 21:43
sync / Gateway staging -> master for Hummingbot version 2.9.0
…position width errors

- Add fallback to base64 encoding when Helius returns mixed parsed/base64 token account data
- Fix StructError validation failures in deprecated getBalance() method
- Remove balance validation from Meteora openPosition (aligns with PancakeSwap-Sol)
- Add proper error handling for InvalidPositionWidth (error 6040) with user guidance
- Preserve actual error messages in Meteora openPosition route handler

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

Co-Authored-By: Claude <noreply@anthropic.com>
@fengtality fengtality requested a review from rapcmia November 15, 2025 01:40
@rapcmia rapcmia moved this to Under Review in Pull Request Board Nov 17, 2025
@rapcmia
Copy link
Contributor

rapcmia commented Nov 17, 2025

Commit 2b0f924

  • Setup on lInux with hummingbot on bot dev and secure mode via source build ✅
    • Built local docker images still work as expected ✅
  • Added solana wallet and use rpcProvide helius (free ver)
  • I have not seen any StructError while using Helius PRC on logs nor when executing gateway trading/clmm or meteora/clmm routes ✅

Test meteora position opening with valid and invalid ranges ✅

  • Current price is 0.278 on Meteora's JUP-USDC pool
  • POST /connectors/meteora/clmm/open-position : Able to produce 400 and response for bin more than 69 ✅
    curl -sS -X POST http://localhost:15888/connectors/meteora/clmm/open-position \
     -H 'Content-Type: application/json' \
     -d '{"network":"mainnet-beta","walletAddress":"GiooMWkHziPuXhfRar2ChBxU6VhQSrAh7xJTG2zHcxWV","lowerPrice":0.24,"upperPrice":0.34,"poolAddress":"HfgjZDmexhFVD28Vkb1NbQwWeXP3uDcVTLPjSGHmRHhL","baseTokenAmount":8.5,"quoteTokenAmount":3,"slippagePct":1,"strategyType":0}' \
     | jq
    response:
    {
      "statusCode": 400,
      "error": "BadRequestError",
      "message": "Error Code: InvalidPositionWidth. Error Number: 6040. Error Message: Invalid position width. Please use a position width of 69 bins or lower."
    }
    
  • Test with bin below 69 and works as expected
    • Test around this lower and upper bound price ✅
      image
      route : POST /connectors/meteora/clmm/open-position
      curl -sS -X POST http://localhost:15888/connectors/meteora/clmm/open-position \
       -H 'Content-Type: application/json' \
       -d '{"network":"mainnet-beta","walletAddress":"GiooMWkHziPuXhfRar2ChBxU6VhQSrAh7xJTG2zHcxWV","lowerPrice":0.26,"upperPrice":0.3,"poolAddress":"HfgjZDmexhFVD28Vkb1NbQwWeXP3uDcVTLPjSGHmRHhL","baseTokenAmount":8.5,"quoteTokenAmount":3,"slippagePct":1,"strategyType":0}' \
       | jq
      response:
      {
        "signature": "VnxhzWR6rJu3utBMvyjx5HX8vN3biAB3Pv2nThSig2aPZPJKWptwDoC46CshHRrgRu4KTzJKLCTSafG8Ms516QZ",
        "status": 1,
        "data": {
          "fee": 0.0022467150000000003,
          "positionAddress": "G5tm97AH3P7DotRbvZQLsmfMQLiHe4usf538REgDp5Vt",
          "positionRent": 0.0022467150000000003,
          "baseTokenAmountAdded": -8.499993,
          "quoteTokenAmountAdded": -2.9999899999999995
        }
      }
      
    • All opened positions are successfully closed using trading/clmm and meteora/clmm routes ok

Test if quote-position endpoint works expected ✅

curl -sS "http://localhost:15888/trading/clmm/quote-position?connector=meteora&chainNetwork=solana-mainnet-beta&lowerPrice=0.26&upperPrice=0.3&poolAddress=HfgjZDmexhFVD28Vkb1NbQwWeXP3uDcVTLPjSGHmRHhL&baseTokenAmount=8.5&quoteTokenAmount=3&slippagePct=1" \
 | jq
response:
{
  "baseLimited": true,
  "baseTokenAmount": 8.5,
  "quoteTokenAmount": 2.370866586604424,
  "baseTokenAmountMax": 8.585,
  "quoteTokenAmountMax": 2.394575252470468,
  "liquidity": "4489138"
}

Gateway tests and logs here: 11172025.zip

@rapcmia rapcmia merged commit 694371e into development Nov 17, 2025
5 checks passed
@rapcmia rapcmia deleted the fix/meteora-struct-error-and-position-width branch November 17, 2025 10:28
@rapcmia
Copy link
Contributor

rapcmia commented Nov 17, 2025

Merged to development and part of release v2.11.0

@rapcmia rapcmia moved this from Under Review to Development v2.11.0 in Pull Request Board Nov 17, 2025
fengtality added a commit that referenced this pull request Nov 19, 2025
- Add Collect Fees and Close Position buttons to LiquidityPositionCard
- Add confirmation dialogs for all position operations (Add, Collect Fees, Close)
- Add Trading API namespace with collectFees and closePosition methods
- Replace position card layout with step area chart visualization
  - Quote liquidity shown in accent color (left of current price)
  - Base liquidity shown in primary color (right of current price)
  - Current price marked with vertical reference line
- Always display unclaimed fees section (even when 0)
- Re-apply PR #555 fix for Meteora InvalidPositionWidth error handling

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

Co-Authored-By: Claude <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: Development v2.11.0

Development

Successfully merging this pull request may close these issues.

3 participants