Summary
The Orca CLMM close-position endpoint returns incorrect values for:
baseFeeAmountCollected - incorrectly includes position rent refund
positionRentRefunded - shows ~0.002 SOL but actual rent paid/refunded is much higher
Root Cause
-
baseFeeAmountCollected: Uses collectFeesQuote() which calculates fees based on position data BEFORE the updateFeesAndRewards instruction executes on-chain. The returned value includes rent refund instead of actual fees.
-
positionRentRefunded: Only calculates rent for position mint, position data, and position ATA accounts (~0.002 SOL total), but misses other rent components. Actual position rent paid on open is ~0.015 SOL.
Example Transactions
Open Position
Close Position
Expected Behavior
baseFeeAmountCollected should reflect actual trading fees collected, not rent
positionRent (on open) should reflect all rent paid including tick arrays and other accounts
positionRentRefunded (on close) should reflect actual rent returned
Suggested Fix
- Use
extractBalanceChangesAndFee() to get actual token balance changes from confirmed transaction
- Calculate fees as:
totalReceived - liquidityRemoved
- Investigate what accounts contribute to the full position rent (~0.015 SOL) and update rent calculation accordingly
Affected Files
src/connectors/orca/clmm-routes/closePosition.ts
src/connectors/orca/clmm-routes/openPosition.ts (for positionRent calculation)
Summary
The Orca CLMM close-position endpoint returns incorrect values for:
baseFeeAmountCollected- incorrectly includes position rent refundpositionRentRefunded- shows ~0.002 SOL but actual rent paid/refunded is much higherRoot Cause
baseFeeAmountCollected: Uses
collectFeesQuote()which calculates fees based on position data BEFORE theupdateFeesAndRewardsinstruction executes on-chain. The returned value includes rent refund instead of actual fees.positionRentRefunded: Only calculates rent for position mint, position data, and position ATA accounts (~0.002 SOL total), but misses other rent components. Actual position rent paid on open is ~0.015 SOL.
Example Transactions
Open Position
Close Position
Expected Behavior
baseFeeAmountCollectedshould reflect actual trading fees collected, not rentpositionRent(on open) should reflect all rent paid including tick arrays and other accountspositionRentRefunded(on close) should reflect actual rent returnedSuggested Fix
extractBalanceChangesAndFee()to get actual token balance changes from confirmed transactiontotalReceived - liquidityRemovedAffected Files
src/connectors/orca/clmm-routes/closePosition.tssrc/connectors/orca/clmm-routes/openPosition.ts(for positionRent calculation)