From 00c3f470b800ed6e9db09eb792031bcd7a9b631f Mon Sep 17 00:00:00 2001 From: dev-bhaskar8 <43923435+dev-bhaskar8@users.noreply.github.com> Date: Sat, 8 Jun 2024 04:43:50 +0530 Subject: [PATCH] Added priority fees option and fixed removePositionLiquidity function with updated sdk channges --- ts-client/src/example.ts | 26 ++++++++++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) diff --git a/ts-client/src/example.ts b/ts-client/src/example.ts index 7ad74bf2..df7bf60b 100644 --- a/ts-client/src/example.ts +++ b/ts-client/src/example.ts @@ -5,6 +5,7 @@ import { sendAndConfirmTransaction, SYSVAR_CLOCK_PUBKEY, ParsedAccountData, + ComputeBudgetProgram, } from "@solana/web3.js"; import { bs58 } from "@coral-xyz/anchor/dist/cjs/utils/bytes"; import { DLMM } from "./dlmm"; @@ -74,6 +75,11 @@ async function createBalancePosition(dlmmPool: DLMM) { }, }); + // createPositionTx.add(ComputeBudgetProgram.setComputeUnitPrice({ + // microLamports: 100000, + // })) + // Add this line if you are on producton or mainnet or your tx will fail. + try { const createBalancePositionTxHash = await sendAndConfirmTransaction( connection, @@ -111,6 +117,11 @@ async function createImbalancePosition(dlmmPool: DLMM) { }, }); + // createPositionTx.add(ComputeBudgetProgram.setComputeUnitPrice({ + // microLamports: 100000, + // })) + // Add this line if you are on producton or mainnet or your tx will fail. + try { const createImbalancePositionTxHash = await sendAndConfirmTransaction( connection, @@ -148,6 +159,11 @@ async function createOneSidePosition(dlmmPool: DLMM) { }, }); + // createPositionTx.add(ComputeBudgetProgram.setComputeUnitPrice({ + // microLamports: 100000, + // })) + // Add this line if you are on producton or mainnet or your tx will fail. + try { const createOneSidePositionTxHash = await sendAndConfirmTransaction( connection, @@ -221,8 +237,7 @@ async function removePositionLiquidity(dlmmPool: DLMM) { position: publicKey, user: user.publicKey, binIds: binIdsToRemove, - liquiditiesBpsToRemove: new Array(binIdsToRemove.length).fill( - new BN(100 * 100) + bps: new BN(100 * 100) ), shouldClaimAndClose: true, // should claim swap fee and close position together }); @@ -232,6 +247,8 @@ async function removePositionLiquidity(dlmmPool: DLMM) { try { for (let tx of removeLiquidityTxs) { + // tx.add(ComputeBudgetProgram.setComputeUnitPrice({microLamports: 100000 * 5 ,})) + // Add this line if you are on producton or mainnet or your tx will fail. const removeBalanceLiquidityTxHash = await sendAndConfirmTransaction( connection, tx, @@ -295,6 +312,11 @@ async function swap(dlmmPool: DLMM) { outToken: dlmmPool.tokenY.publicKey, }); + // swapTx.add(ComputeBudgetProgram.setComputeUnitPrice({ + // microLamports: 100000, + // })) + // Add this line if you are on producton or mainnet or your tx will fail. + try { const swapTxHash = await sendAndConfirmTransaction(connection, swapTx, [ user,