Skip to content
This repository was archived by the owner on Nov 15, 2024. It is now read-only.

Commit e2f02d3

Browse files
committed
update
1 parent 5776da6 commit e2f02d3

File tree

1 file changed

+52
-49
lines changed

1 file changed

+52
-49
lines changed

src/utils/liquidity.ts

Lines changed: 52 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -201,27 +201,27 @@ export async function addLiquidity(
201201
transaction.add(
202202
poolInfo.version === 5
203203
? addLiquidityInstructionStable(
204-
new PublicKey(poolInfo.programId),
205-
new PublicKey(poolInfo.ammId),
206-
new PublicKey(poolInfo.ammAuthority),
207-
new PublicKey(poolInfo.ammOpenOrders),
208-
new PublicKey(poolInfo.ammTargetOrders),
209-
new PublicKey(poolInfo.lp.mintAddress),
210-
new PublicKey(poolInfo.poolCoinTokenAccount),
211-
new PublicKey(poolInfo.poolPcTokenAccount),
212-
new PublicKey(poolInfo.modelDataAccount ?? ''),
213-
new PublicKey(poolInfo.serumMarket),
214-
wrappedCoinSolAccount ? wrappedCoinSolAccount : userCoinTokenAccount,
215-
wrappedSolAccount ? wrappedSolAccount : userPcTokenAccount,
216-
userLpTokenAccount,
217-
owner,
218-
219-
coinAmount,
220-
pcAmount,
221-
fixedCoin === poolInfo.coin.mintAddress ? 0 : 1
222-
)
204+
new PublicKey(poolInfo.programId),
205+
new PublicKey(poolInfo.ammId),
206+
new PublicKey(poolInfo.ammAuthority),
207+
new PublicKey(poolInfo.ammOpenOrders),
208+
new PublicKey(poolInfo.ammTargetOrders),
209+
new PublicKey(poolInfo.lp.mintAddress),
210+
new PublicKey(poolInfo.poolCoinTokenAccount),
211+
new PublicKey(poolInfo.poolPcTokenAccount),
212+
new PublicKey(poolInfo.modelDataAccount ?? ''),
213+
new PublicKey(poolInfo.serumMarket),
214+
wrappedCoinSolAccount ? wrappedCoinSolAccount : userCoinTokenAccount,
215+
wrappedSolAccount ? wrappedSolAccount : userPcTokenAccount,
216+
userLpTokenAccount,
217+
owner,
218+
219+
coinAmount,
220+
pcAmount,
221+
fixedCoin === poolInfo.coin.mintAddress ? 0 : 1
222+
)
223223
: poolInfo.version === 4
224-
? addLiquidityInstructionV4(
224+
? addLiquidityInstructionV4(
225225
new PublicKey(poolInfo.programId),
226226

227227
new PublicKey(poolInfo.ammId),
@@ -233,6 +233,7 @@ export async function addLiquidity(
233233
new PublicKey(poolInfo.poolPcTokenAccount),
234234

235235
new PublicKey(poolInfo.serumMarket),
236+
new PublicKey(poolInfo.serumEventQueue!),
236237

237238
wrappedCoinSolAccount ? wrappedCoinSolAccount : userCoinTokenAccount,
238239
wrappedSolAccount ? wrappedSolAccount : userPcTokenAccount,
@@ -243,7 +244,7 @@ export async function addLiquidity(
243244
pcAmount,
244245
fixedCoin === poolInfo.coin.mintAddress ? 0 : 1
245246
)
246-
: addLiquidityInstruction(
247+
: addLiquidityInstruction(
247248
new PublicKey(poolInfo.programId),
248249

249250
new PublicKey(poolInfo.ammId),
@@ -359,33 +360,33 @@ export async function removeLiquidity(
359360
transaction.add(
360361
poolInfo.version === 5
361362
? removeLiquidityInstructionStable(
362-
new PublicKey(poolInfo.programId),
363-
364-
new PublicKey(poolInfo.ammId),
365-
new PublicKey(poolInfo.ammAuthority),
366-
new PublicKey(poolInfo.ammOpenOrders),
367-
new PublicKey(poolInfo.ammTargetOrders),
368-
new PublicKey(poolInfo.lp.mintAddress),
369-
new PublicKey(poolInfo.poolCoinTokenAccount),
370-
new PublicKey(poolInfo.poolPcTokenAccount),
371-
new PublicKey(poolInfo.modelDataAccount ?? ''),
372-
new PublicKey(poolInfo.serumProgramId),
373-
new PublicKey(poolInfo.serumMarket),
374-
new PublicKey(poolInfo.serumCoinVaultAccount),
375-
new PublicKey(poolInfo.serumPcVaultAccount),
376-
new PublicKey(poolInfo.serumVaultSigner),
377-
378-
new PublicKey(lpAccount),
379-
newFromTokenAccount,
380-
newToTokenAccount,
381-
owner,
382-
383-
poolInfo,
384-
385-
lpAmount
386-
)
363+
new PublicKey(poolInfo.programId),
364+
365+
new PublicKey(poolInfo.ammId),
366+
new PublicKey(poolInfo.ammAuthority),
367+
new PublicKey(poolInfo.ammOpenOrders),
368+
new PublicKey(poolInfo.ammTargetOrders),
369+
new PublicKey(poolInfo.lp.mintAddress),
370+
new PublicKey(poolInfo.poolCoinTokenAccount),
371+
new PublicKey(poolInfo.poolPcTokenAccount),
372+
new PublicKey(poolInfo.modelDataAccount ?? ''),
373+
new PublicKey(poolInfo.serumProgramId),
374+
new PublicKey(poolInfo.serumMarket),
375+
new PublicKey(poolInfo.serumCoinVaultAccount),
376+
new PublicKey(poolInfo.serumPcVaultAccount),
377+
new PublicKey(poolInfo.serumVaultSigner),
378+
379+
new PublicKey(lpAccount),
380+
newFromTokenAccount,
381+
newToTokenAccount,
382+
owner,
383+
384+
poolInfo,
385+
386+
lpAmount
387+
)
387388
: poolInfo.version === 4
388-
? removeLiquidityInstructionV4(
389+
? removeLiquidityInstructionV4(
389390
new PublicKey(poolInfo.programId),
390391

391392
new PublicKey(poolInfo.ammId),
@@ -413,7 +414,7 @@ export async function removeLiquidity(
413414

414415
lpAmount
415416
)
416-
: removeLiquidityInstruction(
417+
: removeLiquidityInstruction(
417418
new PublicKey(poolInfo.programId),
418419

419420
new PublicKey(poolInfo.ammId),
@@ -535,6 +536,7 @@ export function addLiquidityInstructionV4(
535536
poolPcTokenAccount: PublicKey,
536537
// serum
537538
serumMarket: PublicKey,
539+
marketEventQueue: PublicKey,
538540
// user
539541
userCoinTokenAccount: PublicKey,
540542
userPcTokenAccount: PublicKey,
@@ -560,7 +562,8 @@ export function addLiquidityInstructionV4(
560562
{ pubkey: userCoinTokenAccount, isSigner: false, isWritable: true },
561563
{ pubkey: userPcTokenAccount, isSigner: false, isWritable: true },
562564
{ pubkey: userLpTokenAccount, isSigner: false, isWritable: true },
563-
{ pubkey: userOwner, isSigner: true, isWritable: false }
565+
{ pubkey: userOwner, isSigner: true, isWritable: false },
566+
{ pubkey: marketEventQueue, isSigner: true, isWritable: false }
564567
]
565568

566569
const data = Buffer.alloc(dataLayout.span)

0 commit comments

Comments
 (0)