@lavarage/sdk 7.5.0 → 7.5.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/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,
@@ -5154,8 +5165,9 @@ var openTradeV1 = (lavarageProgram, offer, jupInstruction, marginSOL, leverage,
5154
5165
  const setUpInstructions = [
5155
5166
  fromTokenAccount.instruction,
5156
5167
  toTokenAccount.instruction,
5168
+ partnerFeeRecipientCreateIx,
5157
5169
  ...setupInstructions.map(deserializeInstruction)
5158
- ];
5170
+ ].filter(Boolean);
5159
5171
  const allInstructions2 = [
5160
5172
  tradingOpenBorrowInstruction,
5161
5173
  deserializeInstruction(swapInstructionPayload),
@@ -5180,6 +5192,7 @@ var openTradeV1 = (lavarageProgram, offer, jupInstruction, marginSOL, leverage,
5180
5192
  const allInstructions = [
5181
5193
  fromTokenAccount.instruction,
5182
5194
  toTokenAccount.instruction,
5195
+ partnerFeeRecipientCreateIx,
5183
5196
  tradingOpenBorrowInstruction,
5184
5197
  ...jupiterIxs,
5185
5198
  openAddCollateralInstruction,
@@ -5282,6 +5295,26 @@ var openTradeV2 = (lavarageProgram, offer, jupInstruction, marginSOL, leverage,
5282
5295
  );
5283
5296
  const { blockhash } = yield lavarageProgram.provider.connection.getLatestBlockhash("finalized");
5284
5297
  const useReferral = discountBps !== void 0 && referralBps !== void 0;
5298
+ let partnerFeeRecipientTokenAccountCreateIx;
5299
+ if (partnerFeeRecipient && partnerFeeMarkupAsPkey) {
5300
+ const partnerTokenAccount = (0, import_spl_token2.getAssociatedTokenAddressSync)(
5301
+ quoteToken,
5302
+ partnerFeeRecipient,
5303
+ false,
5304
+ quoteTokenProgram
5305
+ );
5306
+ const partnerTokenAccountInfo = yield lavarageProgram.provider.connection.getAccountInfo(partnerTokenAccount);
5307
+ if (!partnerTokenAccountInfo) {
5308
+ partnerFeeRecipientTokenAccountCreateIx = (0, import_spl_token2.createAssociatedTokenAccountIdempotentInstruction)(
5309
+ lavarageProgram.provider.publicKey,
5310
+ partnerTokenAccount,
5311
+ partnerFeeRecipient,
5312
+ quoteToken,
5313
+ quoteTokenProgram,
5314
+ import_spl_token2.ASSOCIATED_TOKEN_PROGRAM_ID
5315
+ );
5316
+ }
5317
+ }
5285
5318
  const tradingOpenBorrowInstruction = useReferral ? yield lavarageProgram.methods.tradingOpenBorrowWithReferral(
5286
5319
  new import_anchor2.BN((marginSOL.toNumber() * leverage).toFixed(0)),
5287
5320
  marginSOL,
@@ -5403,8 +5436,9 @@ var openTradeV2 = (lavarageProgram, offer, jupInstruction, marginSOL, leverage,
5403
5436
  const setUpInstructions = [
5404
5437
  fromTokenAccount.instruction,
5405
5438
  toTokenAccount.instruction,
5439
+ partnerFeeRecipientTokenAccountCreateIx,
5406
5440
  ...setupInstructions.map(deserializeInstruction)
5407
- ];
5441
+ ].filter(Boolean);
5408
5442
  const allInstructions2 = [
5409
5443
  tradingOpenBorrowInstruction,
5410
5444
  deserializeInstruction(swapInstructionPayload),
@@ -5429,6 +5463,7 @@ var openTradeV2 = (lavarageProgram, offer, jupInstruction, marginSOL, leverage,
5429
5463
  const allInstructions = [
5430
5464
  fromTokenAccount.instruction,
5431
5465
  toTokenAccount.instruction,
5466
+ partnerFeeRecipientTokenAccountCreateIx,
5432
5467
  tradingOpenBorrowInstruction,
5433
5468
  ...jupiterIxs,
5434
5469
  openAddCollateralInstruction,