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 <[email protected]>
@fengtality fengtality requested a review from rapcmia November 15, 2025 01:40
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.

3 participants