feat: add Token2022 support and balance method migration #518
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
TokenInvalidAccountOwnerErrorwhen fetching pool info for Meteora pools with Token2022 reserve accountsgetTokenAccountBalancemethod in Solana class to handle both Token and Token2022 programsgetBalanceto optimizedgetBalancesmethodgetBalancemethod to reduce code duplicationTechnical Details
Root Cause
The error occurred because pool
2iUtrQHmMZjJoiRTXuxnwJCp4bg1FHwqpLnnoz534dBYand other Token2022 pools have reserve accounts owned byTOKEN_2022_PROGRAM_IDinstead ofTOKEN_PROGRAM_ID. The standardconnection.getTokenAccountBalance()only works with Token Program accounts.Solution
Unified Token Account Balance Method: Created
getTokenAccountBalance()in Solana class that:getTokenAccountBalance()TokenInvalidAccountOwnerError, checks if account is Token2022getParsedAccountInfo()Updated Pool Info Methods:
meteora.ts:137-138raydium.ts:170-171amm-routes/removeLiquidity.ts:129,amm-routes/positionInfo.ts:51Balance Method Migration:
addLiquidity.tsandopenPosition.tsfromgetBalance(wallet, tokens)togetBalances(address, tokens)getBalancemethodTest plan
2iUtrQHmMZjJoiRTXuxnwJCp4bg1FHwqpLnnoz534dBY🤖 Generated with Claude Code