@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.mjs CHANGED
@@ -5047,6 +5047,17 @@ var openTradeV1 = (lavarageProgram, offer, jupInstruction, marginSOL, leverage,
5047
5047
  );
5048
5048
  const { blockhash } = yield lavarageProgram.provider.connection.getLatestBlockhash("finalized");
5049
5049
  const useReferral = discountBps !== void 0 && referralBps !== void 0;
5050
+ let partnerFeeRecipientCreateIx;
5051
+ if (partnerFeeRecipient && partnerFeeMarkupAsPkey) {
5052
+ const partnerAccountInfo = yield lavarageProgram.provider.connection.getAccountInfo(partnerFeeRecipient);
5053
+ if (!partnerAccountInfo) {
5054
+ partnerFeeRecipientCreateIx = SystemProgram2.transfer({
5055
+ fromPubkey: lavarageProgram.provider.publicKey,
5056
+ toPubkey: partnerFeeRecipient,
5057
+ lamports: 890880
5058
+ });
5059
+ }
5060
+ }
5050
5061
  const tradingOpenBorrowInstruction = useReferral ? yield lavarageProgram.methods.tradingOpenBorrowWithReferral(
5051
5062
  new BN2((marginSOL.toNumber() * leverage).toFixed(0)),
5052
5063
  marginSOL,
@@ -5122,8 +5133,9 @@ var openTradeV1 = (lavarageProgram, offer, jupInstruction, marginSOL, leverage,
5122
5133
  const setUpInstructions = [
5123
5134
  fromTokenAccount.instruction,
5124
5135
  toTokenAccount.instruction,
5136
+ partnerFeeRecipientCreateIx,
5125
5137
  ...setupInstructions.map(deserializeInstruction)
5126
- ];
5138
+ ].filter(Boolean);
5127
5139
  const allInstructions2 = [
5128
5140
  tradingOpenBorrowInstruction,
5129
5141
  deserializeInstruction(swapInstructionPayload),
@@ -5148,6 +5160,7 @@ var openTradeV1 = (lavarageProgram, offer, jupInstruction, marginSOL, leverage,
5148
5160
  const allInstructions = [
5149
5161
  fromTokenAccount.instruction,
5150
5162
  toTokenAccount.instruction,
5163
+ partnerFeeRecipientCreateIx,
5151
5164
  tradingOpenBorrowInstruction,
5152
5165
  ...jupiterIxs,
5153
5166
  openAddCollateralInstruction,
@@ -5250,6 +5263,26 @@ var openTradeV2 = (lavarageProgram, offer, jupInstruction, marginSOL, leverage,
5250
5263
  );
5251
5264
  const { blockhash } = yield lavarageProgram.provider.connection.getLatestBlockhash("finalized");
5252
5265
  const useReferral = discountBps !== void 0 && referralBps !== void 0;
5266
+ let partnerFeeRecipientTokenAccountCreateIx;
5267
+ if (partnerFeeRecipient && partnerFeeMarkupAsPkey) {
5268
+ const partnerTokenAccount = getAssociatedTokenAddressSync2(
5269
+ quoteToken,
5270
+ partnerFeeRecipient,
5271
+ false,
5272
+ quoteTokenProgram
5273
+ );
5274
+ const partnerTokenAccountInfo = yield lavarageProgram.provider.connection.getAccountInfo(partnerTokenAccount);
5275
+ if (!partnerTokenAccountInfo) {
5276
+ partnerFeeRecipientTokenAccountCreateIx = createAssociatedTokenAccountIdempotentInstruction2(
5277
+ lavarageProgram.provider.publicKey,
5278
+ partnerTokenAccount,
5279
+ partnerFeeRecipient,
5280
+ quoteToken,
5281
+ quoteTokenProgram,
5282
+ ASSOCIATED_TOKEN_PROGRAM_ID
5283
+ );
5284
+ }
5285
+ }
5253
5286
  const tradingOpenBorrowInstruction = useReferral ? yield lavarageProgram.methods.tradingOpenBorrowWithReferral(
5254
5287
  new BN2((marginSOL.toNumber() * leverage).toFixed(0)),
5255
5288
  marginSOL,
@@ -5371,8 +5404,9 @@ var openTradeV2 = (lavarageProgram, offer, jupInstruction, marginSOL, leverage,
5371
5404
  const setUpInstructions = [
5372
5405
  fromTokenAccount.instruction,
5373
5406
  toTokenAccount.instruction,
5407
+ partnerFeeRecipientTokenAccountCreateIx,
5374
5408
  ...setupInstructions.map(deserializeInstruction)
5375
- ];
5409
+ ].filter(Boolean);
5376
5410
  const allInstructions2 = [
5377
5411
  tradingOpenBorrowInstruction,
5378
5412
  deserializeInstruction(swapInstructionPayload),
@@ -5397,6 +5431,7 @@ var openTradeV2 = (lavarageProgram, offer, jupInstruction, marginSOL, leverage,
5397
5431
  const allInstructions = [
5398
5432
  fromTokenAccount.instruction,
5399
5433
  toTokenAccount.instruction,
5434
+ partnerFeeRecipientTokenAccountCreateIx,
5400
5435
  tradingOpenBorrowInstruction,
5401
5436
  ...jupiterIxs,
5402
5437
  openAddCollateralInstruction,