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

Conversation

@fengtality
Copy link
Contributor

Summary

  • Fixed TokenInvalidAccountOwnerError when fetching pool info for Meteora pools with Token2022 reserve accounts
  • Added unified getTokenAccountBalance method in Solana class to handle both Token and Token2022 programs
  • Migrated Meteora connectors from deprecated getBalance to optimized getBalances method
  • Updated all pool info methods (Meteora, Raydium CLMM, Raydium AMM) to use unified balance fetching
  • Removed deprecated getBalance method to reduce code duplication

Technical Details

Root Cause

The error occurred because pool 2iUtrQHmMZjJoiRTXuxnwJCp4bg1FHwqpLnnoz534dBY and other Token2022 pools have reserve accounts owned by TOKEN_2022_PROGRAM_ID instead of TOKEN_PROGRAM_ID. The standard connection.getTokenAccountBalance() only works with Token Program accounts.

Solution

  1. Unified Token Account Balance Method: Created getTokenAccountBalance() in Solana class that:

    • First tries standard getTokenAccountBalance()
    • On TokenInvalidAccountOwnerError, checks if account is Token2022
    • Falls back to parsing Token2022 accounts using getParsedAccountInfo()
  2. Updated Pool Info Methods:

    • Meteora: meteora.ts:137-138
    • Raydium CLMM: raydium.ts:170-171
    • Raydium AMM: amm-routes/removeLiquidity.ts:129, amm-routes/positionInfo.ts:51
  3. Balance Method Migration:

    • Migrated Meteora addLiquidity.ts and openPosition.ts from getBalance(wallet, tokens) to getBalances(address, tokens)
    • Removed deprecated 200+ line getBalance method

Test plan

  • TypeScript compilation passes
  • Meteora pool info should now work for Token2022 pools like 2iUtrQHmMZjJoiRTXuxnwJCp4bg1FHwqpLnnoz534dBY
  • Existing balance functionality maintained for both Token and Token2022
  • Meteora add/open position operations use optimized balance checking

🤖 Generated with Claude Code

fengtality and others added 6 commits September 23, 2025 17:18
- Add unified getTokenAccountBalance method in Solana class to handle both Token and Token2022 programs
- Update Meteora pool info to use unified method, fixing TokenInvalidAccountOwnerError for Token2022 pools
- Update Raydium CLMM and AMM pool info methods to use unified method
- Migrate Meteora connectors from deprecated getBalance to optimized getBalances method
- Remove deprecated getBalance method to reduce code duplication

Fixes TokenInvalidAccountOwnerError when fetching pool info for pools with Token2022 reserve accounts.

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

Co-Authored-By: Claude <noreply@anthropic.com>
…port

- Override connection.getTokenAccountBalance to handle Token2022 accounts
- This fixes TokenInvalidAccountOwnerError when Meteora SDK calls it internally
- Applied during Solana initialization to catch all internal SDK calls
- Patch Connection.prototype.getTokenAccountBalance globally
- This should catch ALL calls regardless of which connection instance is used
- Added extensive error logging to debug the process
@rapcmia rapcmia requested a review from nikspz September 24, 2025 02:57
@rapcmia rapcmia moved this to Backlog in Pull Request Board Sep 24, 2025
@fengtality fengtality changed the base branch from main to development September 24, 2025 17:21
@fengtality fengtality closed this Sep 24, 2025
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.

2 participants