Error closing a position in Raydium CLMM pool with priority fees
I am writing this article to help users troubleshoot a common issue when closing positions in Raydium CLMM pools with priority fees on Solana.
The issue is due to a known limitation in the Raydium SDK, which prevents it from correctly retrieving and identifying transactions associated with closed positions. This error is not specific to any particular API or functionality, but rather a design choice made by the Raydium team to optimize performance and reduce latency.
Understanding the issue
When you close a position in a CLMM pool with priority fees on Solana, the SDK creates a new transaction (or “Transaction”) that represents the closing action. However, due to the way transactions are stored and retrieved from the blockchain, the Raydium SDK cannot identify or access this transaction.
This is likely an attempt by the team to reduce the number of transactions on the chain and minimize storage requirements. Unfortunately, this means that users like you must manually retrieve the transaction object to close the position.
Workaround
To resolve this issue, users can use the getTransaction
function of the Raydium SDKs
txManagermodule to retrieve a transaction associated with the closed position:
const { txManager } = require('raydium-sdk');
// Create a new transaction object for the closed position
const transaction = await txManager.createTransaction({
clmmPool: 'CLMM_Pool',
closePosition: true,
});
// Get the transaction object
const transactionObj = await txManager.getTxByHash(transaction.hash);
// Close the position
transactionObj.close();
Please note that you will need to import the txManager` module from the Raydium SDK and use it in your code.
Additional Tips
- Please ensure that you are using the latest version of the Raydium SDK, as the workaround might not be available in older versions.
- If you are still experiencing issues, try increasing the transaction timeout or enabling debug logging to help diagnose the issue.
- Please note that this workaround assumes that you have already retrieved the transaction object manually. To avoid errors in the future, consider using a more robust approach, such as storing transactions in a database or using a centralized storage solution.
By following these steps and understanding the limitations of the Raydium SDK, users can resolve the “Cannot find name ‘Transaction'” error when closing positions in Raydium CLMM pools using priority fees.