@lavarage/sdk 8.0.15 → 8.0.16

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
@@ -9756,7 +9756,7 @@ var openTradeV1 = (lavarageProgram, offer, jupInstruction, marginSOL, leverage,
9756
9756
  ])
9757
9757
  );
9758
9758
  const blockhash = (_a = optionalRPCResults == null ? void 0 : optionalRPCResults.latestBlockhash) != null ? _a : (yield lavarageProgram.provider.connection.getLatestBlockhash("finalized")).blockhash;
9759
- const useReferral = discountBps !== void 0 && referralBps !== void 0;
9759
+ const shouldUseDiscountProgram = discountBps !== void 0 && discountBps > 0 || referralBps !== void 0;
9760
9760
  let partnerFeeRecipientCreateIx;
9761
9761
  let userVaultPda;
9762
9762
  if (partnerFeeRecipient && referralBps !== void 0 && referralVaultProgram) {
@@ -9774,11 +9774,11 @@ var openTradeV1 = (lavarageProgram, offer, jupInstruction, marginSOL, leverage,
9774
9774
  }).instruction();
9775
9775
  }
9776
9776
  }
9777
- const tradingOpenBorrowInstruction = useReferral ? yield lavarageProgram.methods.tradingOpenBorrowWithReferral(
9777
+ const tradingOpenBorrowInstruction = shouldUseDiscountProgram ? yield lavarageProgram.methods.tradingOpenBorrowWithReferral(
9778
9778
  new BN2((marginSOL.toNumber() * leverage).toFixed(0)),
9779
9779
  marginSOL,
9780
- new BN2(discountBps),
9781
- new BN2(referralBps)
9780
+ new BN2(discountBps || 0),
9781
+ new BN2(referralBps || 0)
9782
9782
  ).accountsStrict({
9783
9783
  nodeWallet: offer.account.nodeWallet,
9784
9784
  instructions: SYSVAR_INSTRUCTIONS_PUBKEY,
@@ -9995,7 +9995,7 @@ var openTradeV2 = (lavarageProgram, offer, jupInstruction, marginSOL, leverage,
9995
9995
  switchboardLookupTables
9996
9996
  );
9997
9997
  const { blockhash } = yield program.provider.connection.getLatestBlockhash("finalized");
9998
- const useReferral = discountBps !== void 0 && referralBps !== void 0;
9998
+ const shouldUseDiscountProgram = discountBps !== void 0 && discountBps > 0 || referralBps !== void 0;
9999
9999
  let partnerFeeRecipientVaultCreateIx;
10000
10000
  let partnerFeeRecipientTokenAccountCreateIx;
10001
10001
  let userVaultPda;
@@ -10054,11 +10054,11 @@ var openTradeV2 = (lavarageProgram, offer, jupInstruction, marginSOL, leverage,
10054
10054
  );
10055
10055
  }
10056
10056
  }
10057
- const tradingOpenBorrowInstruction = useReferral ? yield program.methods.tradingOpenBorrow(
10057
+ const tradingOpenBorrowInstruction = shouldUseDiscountProgram ? yield program.methods.tradingOpenBorrow(
10058
10058
  new BN2((marginSOL.toNumber() * leverage).toFixed(0)),
10059
10059
  marginSOL,
10060
- new BN2(discountBps),
10061
- new BN2(referralBps)
10060
+ new BN2(discountBps || 0),
10061
+ new BN2(referralBps || 0)
10062
10062
  ).accountsStrict({
10063
10063
  nodeWallet: offer.account.nodeWallet,
10064
10064
  instructions: SYSVAR_INSTRUCTIONS_PUBKEY,
@@ -10464,7 +10464,7 @@ var closeTradeV1 = (lavarageProgram, position, offer, jupInstruction, partnerFee
10464
10464
  });
10465
10465
  const addressLookupTableAccounts = [];
10466
10466
  const { blockhash } = yield lavarageProgram.provider.connection.getLatestBlockhash("finalized");
10467
- const useReferral = discountBps !== void 0 && referralBps !== void 0;
10467
+ const shouldUseDiscountProgram = discountBps !== void 0 && discountBps > 0 || referralBps !== void 0;
10468
10468
  let partnerFeeRecipientCreateIx;
10469
10469
  let userVaultPda;
10470
10470
  if (partnerFeeRecipient && referralBps !== void 0 && referralVaultProgram) {
@@ -10499,11 +10499,11 @@ var closeTradeV1 = (lavarageProgram, position, offer, jupInstruction, partnerFee
10499
10499
  let repaySolIx = null;
10500
10500
  let jupiterIxs = [];
10501
10501
  if (jupInstruction.instructions == void 0) {
10502
- repaySolIx = useReferral ? yield lavarageProgram.methods.tradingCloseRepaySolWithReferral(
10502
+ repaySolIx = shouldUseDiscountProgram ? yield lavarageProgram.methods.tradingCloseRepaySolWithReferral(
10503
10503
  new BN2(jupInstruction.quoteResponse.outAmount),
10504
10504
  new BN2(9997),
10505
- new BN2(discountBps),
10506
- new BN2(referralBps)
10505
+ new BN2(discountBps || 0),
10506
+ new BN2(referralBps || 0)
10507
10507
  ).accountsStrict({
10508
10508
  nodeWallet: pool.account.nodeWallet,
10509
10509
  positionAccount: positionAccountPDA,
@@ -10548,11 +10548,11 @@ var closeTradeV1 = (lavarageProgram, position, offer, jupInstruction, partnerFee
10548
10548
  ] : []
10549
10549
  ).instruction();
10550
10550
  } else {
10551
- repaySolIx = useReferral ? yield lavarageProgram.methods.tradingCloseRepaySolWithReferral(
10551
+ repaySolIx = shouldUseDiscountProgram ? yield lavarageProgram.methods.tradingCloseRepaySolWithReferral(
10552
10552
  new BN2(jupInstruction.quoteResponse.outAmount),
10553
10553
  new BN2(9998),
10554
- new BN2(discountBps),
10555
- new BN2(referralBps)
10554
+ new BN2(discountBps || 0),
10555
+ new BN2(referralBps || 0)
10556
10556
  ).accountsStrict({
10557
10557
  nodeWallet: pool.account.nodeWallet,
10558
10558
  positionAccount: positionAccountPDA,
@@ -10745,7 +10745,7 @@ var closeTradeV2 = (lavarageProgram, position, offer, jupInstruction, quoteToken
10745
10745
  });
10746
10746
  const addressLookupTableAccounts = [];
10747
10747
  const { blockhash } = yield lavarageProgram.provider.connection.getLatestBlockhash("finalized");
10748
- const useReferral = discountBps !== void 0 && referralBps !== void 0;
10748
+ const shouldUseDiscountProgram = discountBps !== void 0 && discountBps > 0 || referralBps !== void 0;
10749
10749
  let partnerFeeRecipientVaultCreateIx;
10750
10750
  let partnerFeeRecipientTokenAccountCreateIx;
10751
10751
  let userVaultPda;
@@ -10801,11 +10801,11 @@ var closeTradeV2 = (lavarageProgram, position, offer, jupInstruction, quoteToken
10801
10801
  let repaySolIx = null;
10802
10802
  let jupiterIxs = [];
10803
10803
  if (jupInstruction.instructions == void 0) {
10804
- repaySolIx = useReferral ? yield lavarageProgram.methods.tradingCloseRepaySol(
10804
+ repaySolIx = shouldUseDiscountProgram ? yield lavarageProgram.methods.tradingCloseRepaySol(
10805
10805
  new BN2(jupInstruction.quoteResponse.outAmount),
10806
10806
  new BN2(9997),
10807
- new BN2(discountBps),
10808
- new BN2(referralBps)
10807
+ new BN2(discountBps || 0),
10808
+ new BN2(referralBps || 0)
10809
10809
  ).accountsStrict({
10810
10810
  nodeWallet: pool.account.nodeWallet,
10811
10811
  positionAccount: positionAccountPDA,
@@ -10901,11 +10901,11 @@ var closeTradeV2 = (lavarageProgram, position, offer, jupInstruction, quoteToken
10901
10901
  ] : []
10902
10902
  ).instruction();
10903
10903
  } else {
10904
- repaySolIx = useReferral ? yield lavarageProgram.methods.tradingCloseRepaySol(
10904
+ repaySolIx = shouldUseDiscountProgram ? yield lavarageProgram.methods.tradingCloseRepaySol(
10905
10905
  new BN2(jupInstruction.quoteResponse.outAmount),
10906
10906
  new BN2(9998),
10907
- new BN2(discountBps),
10908
- new BN2(referralBps)
10907
+ new BN2(discountBps || 0),
10908
+ new BN2(referralBps || 0)
10909
10909
  ).accountsStrict({
10910
10910
  nodeWallet: pool.account.nodeWallet,
10911
10911
  positionAccount: positionAccountPDA,