You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
if (raydium.cluster === 'mainnet') {
const data = await raydium.api.fetchPoolById({ ids: poolId })
poolInfo = data[0] as ApiV3PoolInfoConcentratedItem
if (!isValidClmm(poolInfo.programId)) throw new Error('target pool is not CLMM pool')
} else {
const data = await raydium.clmm.getPoolInfoFromRpc(poolId)
poolInfo = data.poolInfo
poolKeys = data.poolKeys
}
const allPosition = await raydium.clmm.getOwnerPositionInfo({ programId: poolInfo.programId })
if (!allPosition.length) throw new Error('user do not have any positions')
const position = allPosition.find((p) => p.poolId.toBase58() === poolInfo.id)
if (!position) throw new Error(user do not have position in pool: ${poolInfo.id})
const { txId } = await execute({ sendAndConfirm: true })
console.log('clmm position liquidity increased:', { txId: https://explorer.solana.com/tx/${txId} })
process.exit() // if you don't want to end up node execution, comment this line
}
`
error
simulate tx string: [ 'AXQaKNLWWR1DL9zTW8I81xa7U+C1kfreAsAHnOPWsARxAGVupIfscSVX6giHO6mwFN5NcfucIg0+jn0ea+D1Gw2AAQAECzZTalWxHrgW1wPnpEcytvk0gy9ATdhlsNYWg+l8tv7bJxxSzz1c6ez3gCVtOVY6MdLumV7uIoz7lHXzm6KuqCx8Msexar/oOI+lZq5y1M0cSv9xCoWGI1Lpc4o1GmQoCwgqHPXynecqmmMPcz4JvvFOYmjGhmbUAtT2xgyHy6jvfc/ojZP+5Vf0K5P/kZZ/I4Yiy8+VXuy1BXdkyb2KuIQTSstrEG9TpJeId4V4eN8DMo4i1VMvzD1VRCDAp72NL+gcZABYeEJz+CgK0VzpEJ++FNcO0zBkxLTm7JFedAVRAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAG3fbh12Whk9nL4UbO63msHLSF7V9bN5E6jPWFfv8AqaXVyp4Ez121kLcUui/jLLFZEz/BwZK3Ilf9B9OcsEAeIiWxq0EDFy7Ln1uaU31mluSA8jBjgQU9u8v52m3ZKilYWItNajMwH8GaxcLnO2HqTTpaOeBavZ8qDTghHTXsgAQHAgABfAMAAAA2U2pVsR64FtcD56RHMrb5NIMvQE3YZbDWFoPpfLb+2yAAAAAAAAAAOThxMkhoejE2QWtEemNzRzV1MlRoQVBRblRMWHI3WEIARR8AAAAAAKUAAAAAAAAABt324ddloZPZy+FGzut5rBy0he1fWzeROoz1hX7/AKkIBAEQAA4BAQkPAAoLAgMEBQEGDA0IDxARKoUdWd9F7rAKxOIFAAAAAAAAAAAAAAAAABAnAAAAAAAA4BIAAAAAAAAAAAgDAQAAAQkCGY8fTDpFImPUE7LNF+vLwaDliHNk5iYaEqgXkuoWWj4AAgUDVWSoAFUnNo24UIeBcJII+ztQuiG2ju0xA/+LSGiFrXADxcjJAhAC' ] UnhandledPromiseRejection: This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). The promise rejected with the reason "undefined". at throwUnhandledRejectionsMode (node:internal/process/promises:392:7) at processPromiseRejections (node:internal/process/promises:475:17) at processTicksAndRejections (node:internal/process/task_queues:106:32) [ERROR] 20:53:04 UnhandledPromiseRejection: This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). The promise rejected with the reason "undefined".
The text was updated successfully, but these errors were encountered:
`
import { ApiV3PoolInfoConcentratedItem, CLMM_PROGRAM_ID, ClmmKeys, DEVNET_PROGRAM_ID, PoolUtils, Raydium, TxVersion } from '@raydium-io/raydium-sdk-v2'
import { Connection, Keypair } from '@solana/web3.js'
import BN from 'bn.js'
import Decimal from 'decimal.js'
const VALID_PROGRAM_ID = new Set([CLMM_PROGRAM_ID.toBase58(), DEVNET_PROGRAM_ID.CLMM.toBase58()])
export const isValidClmm = (id: string) => VALID_PROGRAM_ID.has(id)
const connection = new Connection("https://mainnet.helius-rpc.com/?api-key=xxxx")
export const increaseLiquidity = async (owner: Keypair, poolId: string) => {
const raydium = await Raydium.load({
owner,
connection,
cluster: 'mainnet',
disableFeatureCheck: true,
disableLoadToken: true,
blockhashCommitment: 'finalized',
})
let poolInfo: ApiV3PoolInfoConcentratedItem
let poolKeys: ClmmKeys | undefined
if (raydium.cluster === 'mainnet') {
const data = await raydium.api.fetchPoolById({ ids: poolId })
poolInfo = data[0] as ApiV3PoolInfoConcentratedItem
if (!isValidClmm(poolInfo.programId)) throw new Error('target pool is not CLMM pool')
} else {
const data = await raydium.clmm.getPoolInfoFromRpc(poolId)
poolInfo = data.poolInfo
poolKeys = data.poolKeys
}
const allPosition = await raydium.clmm.getOwnerPositionInfo({ programId: poolInfo.programId })
if (!allPosition.length) throw new Error('user do not have any positions')
const position = allPosition.find((p) => p.poolId.toBase58() === poolInfo.id)
if (!position) throw new Error(
user do not have position in pool: ${poolInfo.id}
)const inputAmount = 0.00001 // SOL UI amount
const slippage = 0.05
const epochInfo = await raydium.fetchEpochInfo()
const res = await PoolUtils.getLiquidityAmountOutFromAmountIn({
poolInfo,
slippage: 0,
inputA: true,
tickUpper: Math.max(position.tickLower, position.tickUpper),
tickLower: Math.min(position.tickLower, position.tickUpper),
amount: new BN(new Decimal(inputAmount || '0').mul(10 ** poolInfo.mintA.decimals).toFixed(0)),
add: true,
amountHasFee: true,
epochInfo: epochInfo,
})
const { execute } = await raydium.clmm.increasePositionFromLiquidity({
poolInfo,
poolKeys,
ownerPosition: position,
ownerInfo: {
useSOLBalance: true,
},
liquidity: new BN(new Decimal(res.liquidity.toString()).mul(1 - slippage).toFixed(0)),
amountMaxA: new BN(new Decimal(inputAmount || '0').mul(10 ** poolInfo.mintA.decimals).toFixed(0)),
amountMaxB: new BN(new Decimal(res.amountSlippageB.amount.toString()).mul(1 + slippage).toFixed(0)),
checkCreateATAOwner: true,
txVersion: TxVersion.V0,
})
const { txId } = await execute({ sendAndConfirm: true })
console.log('clmm position liquidity increased:', { txId:
https://explorer.solana.com/tx/${txId}
})process.exit() // if you don't want to end up node execution, comment this line
}
`
error
simulate tx string: [ 'AXQaKNLWWR1DL9zTW8I81xa7U+C1kfreAsAHnOPWsARxAGVupIfscSVX6giHO6mwFN5NcfucIg0+jn0ea+D1Gw2AAQAECzZTalWxHrgW1wPnpEcytvk0gy9ATdhlsNYWg+l8tv7bJxxSzz1c6ez3gCVtOVY6MdLumV7uIoz7lHXzm6KuqCx8Msexar/oOI+lZq5y1M0cSv9xCoWGI1Lpc4o1GmQoCwgqHPXynecqmmMPcz4JvvFOYmjGhmbUAtT2xgyHy6jvfc/ojZP+5Vf0K5P/kZZ/I4Yiy8+VXuy1BXdkyb2KuIQTSstrEG9TpJeId4V4eN8DMo4i1VMvzD1VRCDAp72NL+gcZABYeEJz+CgK0VzpEJ++FNcO0zBkxLTm7JFedAVRAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAG3fbh12Whk9nL4UbO63msHLSF7V9bN5E6jPWFfv8AqaXVyp4Ez121kLcUui/jLLFZEz/BwZK3Ilf9B9OcsEAeIiWxq0EDFy7Ln1uaU31mluSA8jBjgQU9u8v52m3ZKilYWItNajMwH8GaxcLnO2HqTTpaOeBavZ8qDTghHTXsgAQHAgABfAMAAAA2U2pVsR64FtcD56RHMrb5NIMvQE3YZbDWFoPpfLb+2yAAAAAAAAAAOThxMkhoejE2QWtEemNzRzV1MlRoQVBRblRMWHI3WEIARR8AAAAAAKUAAAAAAAAABt324ddloZPZy+FGzut5rBy0he1fWzeROoz1hX7/AKkIBAEQAA4BAQkPAAoLAgMEBQEGDA0IDxARKoUdWd9F7rAKxOIFAAAAAAAAAAAAAAAAABAnAAAAAAAA4BIAAAAAAAAAAAgDAQAAAQkCGY8fTDpFImPUE7LNF+vLwaDliHNk5iYaEqgXkuoWWj4AAgUDVWSoAFUnNo24UIeBcJII+ztQuiG2ju0xA/+LSGiFrXADxcjJAhAC' ] UnhandledPromiseRejection: This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). The promise rejected with the reason "undefined". at throwUnhandledRejectionsMode (node:internal/process/promises:392:7) at processPromiseRejections (node:internal/process/promises:475:17) at processTicksAndRejections (node:internal/process/task_queues:106:32) [ERROR] 20:53:04 UnhandledPromiseRejection: This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). The promise rejected with the reason "undefined".
The text was updated successfully, but these errors were encountered: