From ebd9b19dff918ebac07b1f24c97684c0bcbae45e Mon Sep 17 00:00:00 2001 From: codewithgun Date: Mon, 10 Jun 2024 22:45:07 +0800 Subject: [PATCH] fix: ts sdk switch to initialize_lb_pair2 --- ts-client/src/dlmm/index.ts | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/ts-client/src/dlmm/index.ts b/ts-client/src/dlmm/index.ts index 0041cbf6..8f3fa54c 100644 --- a/ts-client/src/dlmm/index.ts +++ b/ts-client/src/dlmm/index.ts @@ -95,6 +95,7 @@ import { deriveLbPair2, derivePosition, deriveLbPair, + deriveTokenBadge, } from "./helpers"; import { bs58 } from "@coral-xyz/anchor/dist/cjs/utils/bytes"; import Decimal from "decimal.js"; @@ -1181,8 +1182,20 @@ export class DLMM { ? deriveBinArrayBitmapExtension(lbPair, program.programId)[0] : null; + const [tokenXBadge, tokenYBadge] = [tokenX, tokenY].map((token) => { + return deriveTokenBadge(token, program.programId)[0]; + }); + + const [mintXAccountInfo, mintYAccountInfo, mintXBadge, mintYBadge] = + await program.provider.connection.getMultipleAccountsInfo([ + tokenX, + tokenY, + tokenXBadge, + tokenYBadge, + ]); + return program.methods - .initializeLbPair(activeId.toNumber(), binStep.toNumber()) + .initializeLbPair2(activeId.toNumber(), binStep.toNumber()) .accounts({ funder, lbPair, @@ -1192,7 +1205,10 @@ export class DLMM { binArrayBitmapExtension, tokenMintX: tokenX, tokenMintY: tokenY, - tokenProgram: TOKEN_PROGRAM_ID, + tokenBadgeX: mintXBadge ? tokenXBadge : program.programId, + tokenBadgeY: mintYBadge ? tokenYBadge : program.programId, + tokenProgramX: mintXAccountInfo.owner, + tokenProgramY: mintYAccountInfo.owner, oracle, presetParameter, systemProgram: SystemProgram.programId,