fix / extract positionRent from transaction balances for Orca CLMM#610
Open
mlguys wants to merge 1 commit intodevelopmentfrom
Open
fix / extract positionRent from transaction balances for Orca CLMM#610mlguys wants to merge 1 commit intodevelopmentfrom
mlguys wants to merge 1 commit intodevelopmentfrom
Conversation
rapcmia
approved these changes
Feb 25, 2026
Contributor
rapcmia
left a comment
There was a problem hiding this comment.
- Setup with hummingbot development branch on source
- Setup with Helius nodeURL (free ver) and tested with {PYUSD, SOL}-USDC pair
- Successfully open and close LP positions
- Compared logs from recent gateway logs (archived files)
- Observed print rent-breakdown in addtiion to existing position rent summary
- Also added rent refund when closing position ok
- Tests on PYUSD-USDC returned 0 fees because no active occured from the time it was open to close
- Had SOL-USDC LP closed with some swaps happened while it was active:
2026-02-25 05:43:49 | info | 🚀 Sent transaction 5LRg6fe81eVoweaUZsZHYEFeE1eYoYyqhL1iQWQeS7fAv5iDXs1gLNyCYFneFu99Y7q3N65Gbemz2mvyNJCJD2ZM, polling for confirmation... 2026-02-25 05:43:51 | info | ✅ Transaction 5LRg6fe81eVoweaUZsZHYEFeE1eYoYyqhL1iQWQeS7fAv5iDXs1gLNyCYFneFu99Y7q3N65Gbemz2mvyNJCJD2ZM confirmed after 2 attempts 2026-02-25 05:43:51 | info | Transaction 5LRg6fe81eVoweaUZsZHYEFeE1eYoYyqhL1iQWQeS7fAv5iDXs1gLNyCYFneFu99Y7q3N65Gbemz2mvyNJCJD2ZM confirmed with total fee: 0.000016 SOL 2026-02-25 05:43:51 | info | Rent refunded from BLtNrQVacaw3Fq2Km8DMHvLSCoP7HKDwHTdwJ21vX41G: 4029840 lamports 2026-02-25 05:43:51 | info | Rent refunded from EpCnP5h2bJudWDufQuFx12snRVB4DzvmddjvVm2fAfGA: 3953280 lamports 2026-02-25 05:43:51 | info | Rent refunded from FR2vbpkuaee8ffNheMg3EMGpzT4Cxgpi2mdApzqVcJyx: 2074080 lamports 2026-02-25 05:43:51 | info | Position closed: removed=0.000000 tokenA + 5.870924 tokenB, fees=0.000024 tokenA + 0.003026 tokenB, rent refunded=0.010057 SOL
fengtality
requested changes
Feb 25, 2026
Contributor
There was a problem hiding this comment.
Looks like position rent and refunds are now correct. However, the fee field only contains base fee, but not priority fees paid.
Fees from tx
- Fee: 0.000025619 SOL
- Priority Fee: 0.000015619 SOL
Gateway response:
{
"signature": "4mELKQadVieTjBcxSajYp3Ht74LX2EkT4Loou9uJqw6hmAiYvuEk3AKFpEEa81nL7gWdyeYXXhz1Ha2dqjEUvCT6",
"status": 1,
"data": {
"fee": 0.000025619000000000003,
"positionAddress": "AQspembSyEkUMym88XQzwYFPZNbVM9xoaYEgWMKsM2wR",
"positionRent": 0.0100572,
"baseTokenAmountAdded": 0.099515736,
"quoteTokenAmountAdded": 8.887790999999998
}
}
Fees from tx:
- Fee: 0.000016117 SOL
- Priority Fee: 0.000011117 SOL
Gateway response:
{
"signature": "u5MqJrhnkea63AXDcZtm8pQZ6GJWNyy4qAhs2XFrA29Y7Vn3zMw6eiDjxWXPLjA4TuKhGuEhjR83uTFoA88u98e",
"status": 1,
"data": {
"fee": 0.000016117000000000002,
"positionRentRefunded": 0.0100572,
"baseTokenAmountRemoved": 0.09392957,
"quoteTokenAmountRemoved": 9.361866,
"baseFeeAmountCollected": 0,
"quoteFeeAmountCollected": 0.007337000000001481
}
}
In addition to tx fees, it looks like the base and quote fees collected weren't exactly what the transaction returned (0.000002059 SOL and 0.000344 USDC)
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 #608 — Orca CLMM connector was reporting incorrect
positionRent/positionRentRefundedvalues and incorrectbaseFeeAmountCollectedon close.Related fix: #591 (same approach applied to Meteora, commit
e9b15fb)Key Changes
Correct rent calculation on open — Previously only summed rent for 3 position accounts (~0.002 SOL), missing tick array initialization rent (~0.013 SOL each). Now extracts rent from the confirmed transaction's
postBalancesfor ALL newly-created accounts (position mint + PDA + ATA + tick arrays).Correct rent refund on close — Extracts rent refund from the transaction's
preBalancesfor closed position accounts. Tick arrays are shared resources and not closed, so their rent is correctly excluded.Correct fee calculation on close — Previously used
collectFeesQuote()which reads position data BEFORE theupdateFeesAndRewardsinstruction executes on-chain, returning stale/incorrect values. Now derives fees from actual balance changes:fees = totalReceived - liquidityRemoved.Refactored
initializeTickArrays()— Now returnsPublicKey[]of newly-created tick array accounts so their rent can be tracked.Files Modified
src/connectors/orca/clmm-routes/openPosition.ts— Rent from TX postBalances, token amounts fromextractBalanceChangesAndFee()src/connectors/orca/clmm-routes/closePosition.ts— Rent refund from TX preBalances, fee derivation from actual balance changestest/connectors/orca/clmm-routes/openPosition.test.ts— Updated mocks for newgetTransaction/extractBalanceChangesAndFeecalls