@lavarage/sdk 6.2.0 → 6.3.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/index.ts CHANGED
@@ -192,7 +192,7 @@ export const openTradeV1 = async (lavarageProgram: Program<Lavarage>, offer: Pro
192
192
 
193
193
  const addressLookupTableAccounts: AddressLookupTableAccount[] = []
194
194
 
195
- addressLookupTableAccounts.push(...(await getAddressLookupTableAccounts(addressLookupTableAddresses)))
195
+ addressLookupTableAccounts.push(...(await getAddressLookupTableAccounts(['5LEAB3owNUSKvECm7vkr58tDtQpzbngQ2NYpc7qmRFdi', ...addressLookupTableAddresses])))
196
196
 
197
197
  const { blockhash } = await lavarageProgram.provider.connection.getLatestBlockhash('finalized')
198
198
 
@@ -335,7 +335,7 @@ export const openTradeV2 = async (lavarageProgram: Program<LavarageV2>, offer: P
335
335
 
336
336
  const addressLookupTableAccounts: AddressLookupTableAccount[] = []
337
337
 
338
- addressLookupTableAccounts.push(...(await getAddressLookupTableAccounts(addressLookupTableAddresses)))
338
+ addressLookupTableAccounts.push(...(await getAddressLookupTableAccounts([...addressLookupTableAddresses, getQuoteCurrencySpecificAddressLookupTable(quoteToken.toBase58()), '5LEAB3owNUSKvECm7vkr58tDtQpzbngQ2NYpc7qmRFdi'])))
339
339
 
340
340
  const { blockhash } = await lavarageProgram.provider.connection.getLatestBlockhash('finalized')
341
341
 
@@ -350,13 +350,13 @@ export const openTradeV2 = async (lavarageProgram: Program<LavarageV2>, offer: P
350
350
  systemProgram: SystemProgram.programId,
351
351
  clock: SYSVAR_CLOCK_PUBKEY,
352
352
  randomAccountAsId: randomSeed.publicKey.toBase58(),
353
- feeTokenAccount: getAssociatedTokenAddressSync(quoteToken, new PublicKey('6JfTobDvwuwZxZP6FR5JPmjdvQ4h4MovkEVH2FPsMSrF')),
353
+ feeTokenAccount: getAssociatedTokenAddressSync(quoteToken, new PublicKey('6JfTobDvwuwZxZP6FR5JPmjdvQ4h4MovkEVH2FPsMSrF'), true, quoteTokenProgram),
354
354
  toTokenAccount: getAssociatedTokenAddressSync(quoteToken, lavarageProgram.provider.publicKey!, true, quoteTokenProgram),
355
- tokenProgram: tokenProgram!,
356
- fromTokenAccount: getAssociatedTokenAddressSync(quoteToken, offer.account.nodeWallet, true, tokenProgram),
355
+ tokenProgram: quoteTokenProgram!,
356
+ fromTokenAccount: getAssociatedTokenAddressSync(quoteToken, offer.account.nodeWallet, true, quoteTokenProgram),
357
357
  })
358
358
  .remainingAccounts(partnerFeeRecipient && partnerFeeMarkupAsPkey ? [{
359
- pubkey: partnerFeeRecipient,
359
+ pubkey: getAssociatedTokenAddressSync(quoteToken, partnerFeeRecipient, false, quoteTokenProgram),
360
360
  isSigner: false,
361
361
  isWritable: true,
362
362
  }, {
@@ -417,7 +417,7 @@ export const createTpDelegate = async (lavarageProgram: Program<Lavarage> | Prog
417
417
  delegatedAccount: position.publicKey,
418
418
  systemProgram: SystemProgram.programId,
419
419
  }).remainingAccounts(partnerFeeRecipient ? [{
420
- pubkey: quoteToken.toBase58() == 'So11111111111111111111111111111111111111112' ? partnerFeeRecipient : getAssociatedTokenAddressSync(quoteToken, partnerFeeRecipient, true),
420
+ pubkey: quoteToken.toBase58() == 'So11111111111111111111111111111111111111112' ? partnerFeeRecipient : getAssociatedTokenAddressSync(quoteToken, partnerFeeRecipient, false),
421
421
  isSigner: false,
422
422
  isWritable: true,
423
423
  }] : [])
@@ -460,7 +460,7 @@ export const modifyTpDelegate = async (lavarageProgram: Program<Lavarage> | Prog
460
460
  delegatedAccount: position.publicKey,
461
461
  systemProgram: SystemProgram.programId,
462
462
  }).remainingAccounts(partnerFeeRecipient ? [{
463
- pubkey: quoteToken.toBase58() == 'So11111111111111111111111111111111111111112' ? partnerFeeRecipient : getAssociatedTokenAddressSync(quoteToken, partnerFeeRecipient, true),
463
+ pubkey: quoteToken.toBase58() == 'So11111111111111111111111111111111111111112' ? partnerFeeRecipient : getAssociatedTokenAddressSync(quoteToken, partnerFeeRecipient, false),
464
464
  isSigner: false,
465
465
  isWritable: true,
466
466
  }] : [])
@@ -732,7 +732,7 @@ export const closeTradeV1 = async (lavarageProgram: Program<Lavarage>, position:
732
732
  deserializeInstruction(swapInstructionPayload),
733
733
  deserializeInstruction(cleanupInstruction),
734
734
  ]
735
- addressLookupTableAccounts.push(...(await getAddressLookupTableAccounts(addressLookupTableAddresses)))
735
+ addressLookupTableAccounts.push(...(await getAddressLookupTableAccounts(['5LEAB3owNUSKvECm7vkr58tDtQpzbngQ2NYpc7qmRFdi', ...addressLookupTableAddresses])))
736
736
  }
737
737
  const profit = new BN(jupInstruction.quoteResponse.outAmount).sub(position.account.amount).sub(position.account.userPaid)
738
738
  const allInstructions = [
@@ -871,7 +871,7 @@ export const closeTradeV2 = async (lavarageProgram: Program<LavarageV2>, positio
871
871
  mint: quoteToken,
872
872
  })
873
873
  .remainingAccounts(partnerFeeRecipient && partnerFeeMarkupAsPkey ? [{
874
- pubkey: partnerFeeRecipient,
874
+ pubkey: getAssociatedTokenAddressSync(quoteToken, partnerFeeRecipient, false, quoteTokenProgram),
875
875
  isSigner: false,
876
876
  isWritable: true,
877
877
  }, {
@@ -913,7 +913,7 @@ export const closeTradeV2 = async (lavarageProgram: Program<LavarageV2>, positio
913
913
  swapInstructionPayload ? deserializeInstruction(swapInstructionPayload) : null,
914
914
  cleanupInstruction ? deserializeInstruction(cleanupInstruction) : null,
915
915
  ].filter(i => !!i)
916
- addressLookupTableAccounts.push(...(await getAddressLookupTableAccounts(addressLookupTableAddresses)))
916
+ addressLookupTableAccounts.push(...(await getAddressLookupTableAccounts([...addressLookupTableAddresses, getQuoteCurrencySpecificAddressLookupTable(quoteToken.toBase58()), '5LEAB3owNUSKvECm7vkr58tDtQpzbngQ2NYpc7qmRFdi'])))
917
917
  }
918
918
  const profit = new BN(jupInstruction.quoteResponse.outAmount).sub(position.account.amount).sub(position.account.userPaid)
919
919
  const allInstructions = [
@@ -950,3 +950,13 @@ export const getDelegateAccounts = async (lavarageProgram: Program<Lavarage> | P
950
950
  }))
951
951
  }
952
952
 
953
+ const getQuoteCurrencySpecificAddressLookupTable = (quoteCurrency: string) => {
954
+ switch (quoteCurrency) {
955
+ case 'J9BcrQfX4p9D1bvLzRNCbMDv8f44a9LFdeqNE4Yk2WMD':
956
+ return '2EdNtwVhyjkEgkKDC7GShfSSczZYMKLuJraeoJzG4E4R'
957
+ case 'EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v':
958
+ return 'CxLE1LRaZg2eYygzFfVRhgmSACsvqzyhySDrMHq3QSab'
959
+ default:
960
+ return '2EdNtwVhyjkEgkKDC7GShfSSczZYMKLuJraeoJzG4E4R'
961
+ }
962
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lavarage/sdk",
3
- "version": "6.2.0",
3
+ "version": "6.3.1",
4
4
  "description": "Lavarage SDK",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.mjs",