Raydium SDK Liquidity Withdrawal Guide
To withdraw your liquidity without using the Novadex Frontend, follow the Raydium SDK guidelines:
Step 1: Clone the Repository
Clone the Raydium SDK V2 demo repository:
After cloning, navigate into the new directory and install dependencies:
cd raydium-sdk-V2-demo
yarn install
Step 2: Update Addresses
Search for the address CAMMCzo5YL8w4VFF8KVHrK22GGUsp5VTaW7grrKgrWqK in the directory and replace all instances with cLmhcuG6pHbGHLzEKphgq6DBJvSiiY4h8D4kAppw7jd. Be thorough, as this address will appear in multiple files.
Ensure this replacement is done especially in the node_modules file at:
raydium-sdk-V2-demo/node_modules/@raydium-io/raydium-sdk-v2/src/common/programId.ts
Step 3: Configure Settings
Update the config.ts.template file to match your configuration, then rename it to config.ts.
Replace the following placeholders:
<YOUR_WALLET_SECRET_KEY> with your own wallet secret key.
<YOUR_RPC_URL> with your preferred RPC URL.
<API_HOST> : usually, the Raydium API host isnβt needed unless youβre testing on devnet.
Step 4: Set Up Liquidity Withdrawal
Navigate to the decreaseLiquidity.ts script located at: https://github.com/raydium-io/raydium-sdk-V2-demo/blob/master/src/clmm/decreaseLiquidity.ts
Replace the poolId with the ID of the pool you wish to withdraw from. For example:
const poolId = '6UmmUiYoBjSrhakAobJw8BvkmJtDVxaeBtbt7rxWo1mg'; (for the RAY-USDC pool)
Update the following part of the script:
This enables the use of RPC instead of the Raydium API. If errors occur, consider switching to a different RPC or even a paid RPC.
Step 5: Run the Withdrawal Script
Execute the following command to withdraw your liquidity:
If your transaction is not successful, try switching RPC providers. If it is still not successful, it might be due to Solana network congestion. You can try adjusting the gas price or wait for an interval where network demand is lower.
Last updated