fix: use Token-2022 positions for full rent recovery on close for Orca#600
Merged
rapcmia merged 1 commit intodevelopmentfrom Feb 16, 2026
Merged
fix: use Token-2022 positions for full rent recovery on close for Orca#600rapcmia merged 1 commit intodevelopmentfrom
rapcmia merged 1 commit intodevelopmentfrom
Conversation
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
fengtality
approved these changes
Feb 11, 2026
Contributor
fengtality
left a comment
There was a problem hiding this comment.
Tested and reviewed code, LGTM
rapcmia
approved these changes
Feb 16, 2026
Contributor
rapcmia
left a comment
There was a problem hiding this comment.
- Setup on source ok
- Use PYUSD/USDC, pool 9tXiuRRw7kbejLhZXtxDxYs2REe43uH2e7k1kocgdM9B
- ./connectors/orca/clmm routes ✅
- /connectors/orca/clmm/{quote-swap, execute-swap}
- /connectors/orca/clmm/{pool-info, quote-position, open-position, add-liquidity, position-info, positions-owned, collect-fees, close-position}
- ./trading/clmm routes ✅
- /trading/swap/{quote, execute}
- /trading/clmm/{pool-info, open, add, remove, collect-fees, close}
- /trading/clmm/{positions-owned, quote-position}
Test logs: 02162026.zip
Contributor
|
Merged to development and part of release version 2.13 |
2 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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
Fixes #584 — Orca CLMM positions now use Token-2022 instructions instead of Metaplex, enabling full rent recovery when positions are closed.
Problem: The old Metaplex-based
openPositionWithMetadataIxcreates a mint account that cannot be closed. On position close, only the position data PDA and token ATA rent could be reclaimed (~0.006 SOL), but the mint account rent (~0.004 SOL) was permanently locked. This meant ~$1.89 was spent opening a position but only ~$0.74 was returned on close.Solution: Switch to Token-2022's
openPositionWithTokenExtensionsIxwhich creates mints withMintCloseAuthorityextension, making all 3 position accounts (mint, PDA, ATA) fully reclaimable on close.Changes
openPosition.tsopenPositionWithMetadataIx(Metaplex) withopenPositionWithTokenExtensionsIx(Token-2022)TOKEN_2022_PROGRAM_IDgetBalance()queries on the 3 position accounts instead of unreliable wallet SOL change extractionexecuteSwap.tsWhirlpoolIx.swapIxwithWhirlpoolIx.swapV2Ixfor Token-2022 compatibilityclosePosition.tsgetBalance()queries on position accounts before the close TX (while accounts still exist)collectFeesQuotefrom on-chain position data instead of post-TX wallet SOL change extractionclosePositionWithTokenExtensionsIx(backward compatible with legacy viaisToken2022check)Tests
openPosition.test.ts: mockconnection.getBalanceinstead ofextractBalanceChangesAndFeeexecuteSwap.test.ts: mockswapV2Ixinstead ofswapIx