Skip to content

Commit

Permalink
fix: ts sdk switch to initialize_lb_pair2
Browse files Browse the repository at this point in the history
  • Loading branch information
codewithgun committed Jun 10, 2024
1 parent dcbc559 commit ebd9b19
Showing 1 changed file with 18 additions and 2 deletions.
20 changes: 18 additions & 2 deletions ts-client/src/dlmm/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down Expand Up @@ -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,
Expand All @@ -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,
Expand Down

0 comments on commit ebd9b19

Please sign in to comment.