@lavarage/sdk 7.5.0 → 7.5.2

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/dist/index.js CHANGED
@@ -5079,6 +5079,17 @@ var openTradeV1 = (lavarageProgram, offer, jupInstruction, marginSOL, leverage,
5079
5079
  );
5080
5080
  const { blockhash } = yield lavarageProgram.provider.connection.getLatestBlockhash("finalized");
5081
5081
  const useReferral = discountBps !== void 0 && referralBps !== void 0;
5082
+ let partnerFeeRecipientCreateIx;
5083
+ if (partnerFeeRecipient && partnerFeeMarkupAsPkey) {
5084
+ const partnerAccountInfo = yield lavarageProgram.provider.connection.getAccountInfo(partnerFeeRecipient);
5085
+ if (!partnerAccountInfo) {
5086
+ partnerFeeRecipientCreateIx = import_web32.SystemProgram.transfer({
5087
+ fromPubkey: lavarageProgram.provider.publicKey,
5088
+ toPubkey: partnerFeeRecipient,
5089
+ lamports: 890880
5090
+ });
5091
+ }
5092
+ }
5082
5093
  const tradingOpenBorrowInstruction = useReferral ? yield lavarageProgram.methods.tradingOpenBorrowWithReferral(
5083
5094
  new import_anchor2.BN((marginSOL.toNumber() * leverage).toFixed(0)),
5084
5095
  marginSOL,
@@ -5100,11 +5111,6 @@ var openTradeV1 = (lavarageProgram, offer, jupInstruction, marginSOL, leverage,
5100
5111
  pubkey: partnerFeeRecipient,
5101
5112
  isSigner: false,
5102
5113
  isWritable: true
5103
- },
5104
- {
5105
- pubkey: partnerFeeMarkupAsPkey,
5106
- isSigner: false,
5107
- isWritable: false
5108
5114
  }
5109
5115
  ] : []
5110
5116
  ).instruction() : yield lavarageProgram.methods.tradingOpenBorrow(
@@ -5154,8 +5160,9 @@ var openTradeV1 = (lavarageProgram, offer, jupInstruction, marginSOL, leverage,
5154
5160
  const setUpInstructions = [
5155
5161
  fromTokenAccount.instruction,
5156
5162
  toTokenAccount.instruction,
5163
+ partnerFeeRecipientCreateIx,
5157
5164
  ...setupInstructions.map(deserializeInstruction)
5158
- ];
5165
+ ].filter(Boolean);
5159
5166
  const allInstructions2 = [
5160
5167
  tradingOpenBorrowInstruction,
5161
5168
  deserializeInstruction(swapInstructionPayload),
@@ -5180,6 +5187,7 @@ var openTradeV1 = (lavarageProgram, offer, jupInstruction, marginSOL, leverage,
5180
5187
  const allInstructions = [
5181
5188
  fromTokenAccount.instruction,
5182
5189
  toTokenAccount.instruction,
5190
+ partnerFeeRecipientCreateIx,
5183
5191
  tradingOpenBorrowInstruction,
5184
5192
  ...jupiterIxs,
5185
5193
  openAddCollateralInstruction,
@@ -5282,6 +5290,26 @@ var openTradeV2 = (lavarageProgram, offer, jupInstruction, marginSOL, leverage,
5282
5290
  );
5283
5291
  const { blockhash } = yield lavarageProgram.provider.connection.getLatestBlockhash("finalized");
5284
5292
  const useReferral = discountBps !== void 0 && referralBps !== void 0;
5293
+ let partnerFeeRecipientTokenAccountCreateIx;
5294
+ if (partnerFeeRecipient && partnerFeeMarkupAsPkey) {
5295
+ const partnerTokenAccount = (0, import_spl_token2.getAssociatedTokenAddressSync)(
5296
+ quoteToken,
5297
+ partnerFeeRecipient,
5298
+ false,
5299
+ quoteTokenProgram
5300
+ );
5301
+ const partnerTokenAccountInfo = yield lavarageProgram.provider.connection.getAccountInfo(partnerTokenAccount);
5302
+ if (!partnerTokenAccountInfo) {
5303
+ partnerFeeRecipientTokenAccountCreateIx = (0, import_spl_token2.createAssociatedTokenAccountIdempotentInstruction)(
5304
+ lavarageProgram.provider.publicKey,
5305
+ partnerTokenAccount,
5306
+ partnerFeeRecipient,
5307
+ quoteToken,
5308
+ quoteTokenProgram,
5309
+ import_spl_token2.ASSOCIATED_TOKEN_PROGRAM_ID
5310
+ );
5311
+ }
5312
+ }
5285
5313
  const tradingOpenBorrowInstruction = useReferral ? yield lavarageProgram.methods.tradingOpenBorrowWithReferral(
5286
5314
  new import_anchor2.BN((marginSOL.toNumber() * leverage).toFixed(0)),
5287
5315
  marginSOL,
@@ -5326,11 +5354,6 @@ var openTradeV2 = (lavarageProgram, offer, jupInstruction, marginSOL, leverage,
5326
5354
  ),
5327
5355
  isSigner: false,
5328
5356
  isWritable: true
5329
- },
5330
- {
5331
- pubkey: partnerFeeMarkupAsPkey,
5332
- isSigner: false,
5333
- isWritable: false
5334
5357
  }
5335
5358
  ] : []
5336
5359
  ).instruction() : yield lavarageProgram.methods.tradingOpenBorrow(
@@ -5403,8 +5426,9 @@ var openTradeV2 = (lavarageProgram, offer, jupInstruction, marginSOL, leverage,
5403
5426
  const setUpInstructions = [
5404
5427
  fromTokenAccount.instruction,
5405
5428
  toTokenAccount.instruction,
5429
+ partnerFeeRecipientTokenAccountCreateIx,
5406
5430
  ...setupInstructions.map(deserializeInstruction)
5407
- ];
5431
+ ].filter(Boolean);
5408
5432
  const allInstructions2 = [
5409
5433
  tradingOpenBorrowInstruction,
5410
5434
  deserializeInstruction(swapInstructionPayload),
@@ -5429,6 +5453,7 @@ var openTradeV2 = (lavarageProgram, offer, jupInstruction, marginSOL, leverage,
5429
5453
  const allInstructions = [
5430
5454
  fromTokenAccount.instruction,
5431
5455
  toTokenAccount.instruction,
5456
+ partnerFeeRecipientTokenAccountCreateIx,
5432
5457
  tradingOpenBorrowInstruction,
5433
5458
  ...jupiterIxs,
5434
5459
  openAddCollateralInstruction,