@lavarage/sdk 8.0.14 → 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.d.mts CHANGED
@@ -7257,7 +7257,7 @@ declare namespace lavarageUSDC {
7257
7257
  * IDL can be found at `target/idl/user_vault.json`.
7258
7258
  */
7259
7259
  type UserVault = {
7260
- "address": "F7L3T5fjHbD13SH8UhNuYxCdabHX9CRg2zxbPjmiwU7R";
7260
+ "address": "FFe8xWs9iBdWB6vsxg8yBLirZHsbACFNbXqAM4K3fPPB";
7261
7261
  "metadata": {
7262
7262
  "name": "userVault";
7263
7263
  "version": "0.1.0";
@@ -8814,7 +8814,7 @@ declare const borrowV2: (lavarageProgram: Program<Lavarage>, offer: ProgramAccou
8814
8814
  * @param computeBudgetMicroLamports - Optional compute budget for priority fees
8815
8815
  * @param platformFeeRecipient - Optional wallet to receive platform fees (jup, okx)
8816
8816
  * @param splitTransactions - Optional boolean to split the transaction into multiple transactions (jito bundle)
8817
- * @param discountBps - Optional discount basis points for the referral program
8817
+ * @param discountBps - Optional discount basis points for the referral program and discount program
8818
8818
  * @param referralBps - Optional referral basis points for the referral program
8819
8819
  * @param optionalRPCResults - Optional RPC results to use for the transaction (speeds up the transaction building)
8820
8820
  *
@@ -8883,7 +8883,7 @@ declare const openTradeV1: (lavarageProgram: Program<Lavarage$1>, offer: Program
8883
8883
  * @param computeBudgetMicroLamports - Optional compute budget for priority fees
8884
8884
  * @param platformFeeRecipient - Optional wallet to receive platform fees (jup, okx)
8885
8885
  * @param splitTransactions - Optional boolean to split the transaction into multiple transactions (jito bundle)
8886
- * @param discountBps - Optional discount basis points for the referral program
8886
+ * @param discountBps - Optional discount basis points for the referral program and discount program
8887
8887
  * @param referralBps - Optional referral basis points for the referral program
8888
8888
  * @param optionalRPCResults - Optional RPC results to use for the transaction (speeds up the transaction building)
8889
8889
  *
@@ -9126,7 +9126,7 @@ declare const partialRepayV2: (lavarageProgram: Program<Lavarage>, position: Pro
9126
9126
  * @param computeBudgetMicroLamports - Optional compute budget for priority fees
9127
9127
  * @param platformFeeRecipient - Optional wallet to receive platform fees (jup, okx)
9128
9128
  * @param splitTransactions - Optional boolean to split the transaction into multiple transactions (jito bundle)
9129
- * @param discountBps - Optional discount basis points for the referral program
9129
+ * @param discountBps - Optional discount basis points for the referral program and discount program
9130
9130
  * @param referralBps - Optional referral basis points for the referral program
9131
9131
  *
9132
9132
  * @returns Transaction to close the position
@@ -9184,7 +9184,7 @@ declare const closeTradeV1: (lavarageProgram: Program<Lavarage$1>, position: Pro
9184
9184
  * @param computeBudgetMicroLamports - Optional compute budget for priority fees
9185
9185
  * @param platformFeeRecipient - Optional wallet to receive platform fees (jup, okx)
9186
9186
  * @param splitTransactions - Optional boolean to split the transaction into multiple transactions (jito bundle)
9187
- * @param discountBps - Optional discount basis points for the referral program
9187
+ * @param discountBps - Optional discount basis points for the referral program and discount program
9188
9188
  * @param referralBps - Optional referral basis points for the referral program
9189
9189
  *
9190
9190
  * @returns Transaction to close the position
package/dist/index.d.ts CHANGED
@@ -7257,7 +7257,7 @@ declare namespace lavarageUSDC {
7257
7257
  * IDL can be found at `target/idl/user_vault.json`.
7258
7258
  */
7259
7259
  type UserVault = {
7260
- "address": "F7L3T5fjHbD13SH8UhNuYxCdabHX9CRg2zxbPjmiwU7R";
7260
+ "address": "FFe8xWs9iBdWB6vsxg8yBLirZHsbACFNbXqAM4K3fPPB";
7261
7261
  "metadata": {
7262
7262
  "name": "userVault";
7263
7263
  "version": "0.1.0";
@@ -8814,7 +8814,7 @@ declare const borrowV2: (lavarageProgram: Program<Lavarage>, offer: ProgramAccou
8814
8814
  * @param computeBudgetMicroLamports - Optional compute budget for priority fees
8815
8815
  * @param platformFeeRecipient - Optional wallet to receive platform fees (jup, okx)
8816
8816
  * @param splitTransactions - Optional boolean to split the transaction into multiple transactions (jito bundle)
8817
- * @param discountBps - Optional discount basis points for the referral program
8817
+ * @param discountBps - Optional discount basis points for the referral program and discount program
8818
8818
  * @param referralBps - Optional referral basis points for the referral program
8819
8819
  * @param optionalRPCResults - Optional RPC results to use for the transaction (speeds up the transaction building)
8820
8820
  *
@@ -8883,7 +8883,7 @@ declare const openTradeV1: (lavarageProgram: Program<Lavarage$1>, offer: Program
8883
8883
  * @param computeBudgetMicroLamports - Optional compute budget for priority fees
8884
8884
  * @param platformFeeRecipient - Optional wallet to receive platform fees (jup, okx)
8885
8885
  * @param splitTransactions - Optional boolean to split the transaction into multiple transactions (jito bundle)
8886
- * @param discountBps - Optional discount basis points for the referral program
8886
+ * @param discountBps - Optional discount basis points for the referral program and discount program
8887
8887
  * @param referralBps - Optional referral basis points for the referral program
8888
8888
  * @param optionalRPCResults - Optional RPC results to use for the transaction (speeds up the transaction building)
8889
8889
  *
@@ -9126,7 +9126,7 @@ declare const partialRepayV2: (lavarageProgram: Program<Lavarage>, position: Pro
9126
9126
  * @param computeBudgetMicroLamports - Optional compute budget for priority fees
9127
9127
  * @param platformFeeRecipient - Optional wallet to receive platform fees (jup, okx)
9128
9128
  * @param splitTransactions - Optional boolean to split the transaction into multiple transactions (jito bundle)
9129
- * @param discountBps - Optional discount basis points for the referral program
9129
+ * @param discountBps - Optional discount basis points for the referral program and discount program
9130
9130
  * @param referralBps - Optional referral basis points for the referral program
9131
9131
  *
9132
9132
  * @returns Transaction to close the position
@@ -9184,7 +9184,7 @@ declare const closeTradeV1: (lavarageProgram: Program<Lavarage$1>, position: Pro
9184
9184
  * @param computeBudgetMicroLamports - Optional compute budget for priority fees
9185
9185
  * @param platformFeeRecipient - Optional wallet to receive platform fees (jup, okx)
9186
9186
  * @param splitTransactions - Optional boolean to split the transaction into multiple transactions (jito bundle)
9187
- * @param discountBps - Optional discount basis points for the referral program
9187
+ * @param discountBps - Optional discount basis points for the referral program and discount program
9188
9188
  * @param referralBps - Optional referral basis points for the referral program
9189
9189
  *
9190
9190
  * @returns Transaction to close the position
package/dist/index.js CHANGED
@@ -115,7 +115,7 @@ var import_anchor3 = require("@coral-xyz/anchor");
115
115
 
116
116
  // idl/userVault.json
117
117
  var userVault_default = {
118
- address: "F7L3T5fjHbD13SH8UhNuYxCdabHX9CRg2zxbPjmiwU7R",
118
+ address: "FFe8xWs9iBdWB6vsxg8yBLirZHsbACFNbXqAM4K3fPPB",
119
119
  metadata: {
120
120
  name: "user_vault",
121
121
  version: "0.1.0",
@@ -7612,14 +7612,10 @@ var lavarageSOL_default = {
7612
7612
 
7613
7613
  // utils.ts
7614
7614
  function u8ArrayToString(input) {
7615
- const end = input.indexOf(0);
7616
- const bytes = new Uint8Array(end === -1 ? input : input.slice(0, end));
7617
- const decoder = new TextDecoder("utf-8", { fatal: true });
7618
- try {
7619
- return decoder.decode(bytes);
7620
- } catch (e) {
7621
- return "0x" + Array.from(bytes).map((b) => b.toString(16).padStart(2, "0")).join("");
7615
+ if (input.length > 32) {
7616
+ throw new Error("Input has more than 32 bytes");
7622
7617
  }
7618
+ return "0x" + Buffer.from(input).toString("hex");
7623
7619
  }
7624
7620
  function isSolProgram(program) {
7625
7621
  return program.programId.toBase58() === lavarageSOL_default.address;
@@ -9229,7 +9225,6 @@ function getWithdrawalAccessList(lavarageProgram, params) {
9229
9225
  var lavarageUSDC_exports = {};
9230
9226
 
9231
9227
  // index.ts
9232
- var REFFERAL_VAULT_PROGRAM_ID = new import_web33.PublicKey("FFe8xWs9iBdWB6vsxg8yBLirZHsbACFNbXqAM4K3fPPB");
9233
9228
  var LAVARAGE_LOOKUP_TABLE = "CDPmKb5VggsHABwDCTaxiw5XXLjcgkqSJMNKRTzHWXwK";
9234
9229
  function getPda(seed, programId) {
9235
9230
  const seedsBuffer = Array.isArray(seed) ? seed : [seed];
@@ -9793,7 +9788,7 @@ var openTradeV1 = (lavarageProgram, offer, jupInstruction, marginSOL, leverage,
9793
9788
  ])
9794
9789
  );
9795
9790
  const blockhash = (_a = optionalRPCResults == null ? void 0 : optionalRPCResults.latestBlockhash) != null ? _a : (yield lavarageProgram.provider.connection.getLatestBlockhash("finalized")).blockhash;
9796
- const useReferral = discountBps !== void 0 && referralBps !== void 0;
9791
+ const shouldUseDiscountProgram = discountBps !== void 0 && discountBps > 0 || referralBps !== void 0;
9797
9792
  let partnerFeeRecipientCreateIx;
9798
9793
  let userVaultPda;
9799
9794
  if (partnerFeeRecipient && referralBps !== void 0 && referralVaultProgram) {
@@ -9811,11 +9806,11 @@ var openTradeV1 = (lavarageProgram, offer, jupInstruction, marginSOL, leverage,
9811
9806
  }).instruction();
9812
9807
  }
9813
9808
  }
9814
- const tradingOpenBorrowInstruction = useReferral ? yield lavarageProgram.methods.tradingOpenBorrowWithReferral(
9809
+ const tradingOpenBorrowInstruction = shouldUseDiscountProgram ? yield lavarageProgram.methods.tradingOpenBorrowWithReferral(
9815
9810
  new import_anchor3.BN((marginSOL.toNumber() * leverage).toFixed(0)),
9816
9811
  marginSOL,
9817
- new import_anchor3.BN(discountBps),
9818
- new import_anchor3.BN(referralBps)
9812
+ new import_anchor3.BN(discountBps || 0),
9813
+ new import_anchor3.BN(referralBps || 0)
9819
9814
  ).accountsStrict({
9820
9815
  nodeWallet: offer.account.nodeWallet,
9821
9816
  instructions: import_web33.SYSVAR_INSTRUCTIONS_PUBKEY,
@@ -10032,7 +10027,7 @@ var openTradeV2 = (lavarageProgram, offer, jupInstruction, marginSOL, leverage,
10032
10027
  switchboardLookupTables
10033
10028
  );
10034
10029
  const { blockhash } = yield program.provider.connection.getLatestBlockhash("finalized");
10035
- const useReferral = discountBps !== void 0 && referralBps !== void 0;
10030
+ const shouldUseDiscountProgram = discountBps !== void 0 && discountBps > 0 || referralBps !== void 0;
10036
10031
  let partnerFeeRecipientVaultCreateIx;
10037
10032
  let partnerFeeRecipientTokenAccountCreateIx;
10038
10033
  let userVaultPda;
@@ -10091,11 +10086,11 @@ var openTradeV2 = (lavarageProgram, offer, jupInstruction, marginSOL, leverage,
10091
10086
  );
10092
10087
  }
10093
10088
  }
10094
- const tradingOpenBorrowInstruction = useReferral ? yield program.methods.tradingOpenBorrow(
10089
+ const tradingOpenBorrowInstruction = shouldUseDiscountProgram ? yield program.methods.tradingOpenBorrow(
10095
10090
  new import_anchor3.BN((marginSOL.toNumber() * leverage).toFixed(0)),
10096
10091
  marginSOL,
10097
- new import_anchor3.BN(discountBps),
10098
- new import_anchor3.BN(referralBps)
10092
+ new import_anchor3.BN(discountBps || 0),
10093
+ new import_anchor3.BN(referralBps || 0)
10099
10094
  ).accountsStrict({
10100
10095
  nodeWallet: offer.account.nodeWallet,
10101
10096
  instructions: import_web33.SYSVAR_INSTRUCTIONS_PUBKEY,
@@ -10501,7 +10496,7 @@ var closeTradeV1 = (lavarageProgram, position, offer, jupInstruction, partnerFee
10501
10496
  });
10502
10497
  const addressLookupTableAccounts = [];
10503
10498
  const { blockhash } = yield lavarageProgram.provider.connection.getLatestBlockhash("finalized");
10504
- const useReferral = discountBps !== void 0 && referralBps !== void 0;
10499
+ const shouldUseDiscountProgram = discountBps !== void 0 && discountBps > 0 || referralBps !== void 0;
10505
10500
  let partnerFeeRecipientCreateIx;
10506
10501
  let userVaultPda;
10507
10502
  if (partnerFeeRecipient && referralBps !== void 0 && referralVaultProgram) {
@@ -10536,11 +10531,11 @@ var closeTradeV1 = (lavarageProgram, position, offer, jupInstruction, partnerFee
10536
10531
  let repaySolIx = null;
10537
10532
  let jupiterIxs = [];
10538
10533
  if (jupInstruction.instructions == void 0) {
10539
- repaySolIx = useReferral ? yield lavarageProgram.methods.tradingCloseRepaySolWithReferral(
10534
+ repaySolIx = shouldUseDiscountProgram ? yield lavarageProgram.methods.tradingCloseRepaySolWithReferral(
10540
10535
  new import_anchor3.BN(jupInstruction.quoteResponse.outAmount),
10541
10536
  new import_anchor3.BN(9997),
10542
- new import_anchor3.BN(discountBps),
10543
- new import_anchor3.BN(referralBps)
10537
+ new import_anchor3.BN(discountBps || 0),
10538
+ new import_anchor3.BN(referralBps || 0)
10544
10539
  ).accountsStrict({
10545
10540
  nodeWallet: pool.account.nodeWallet,
10546
10541
  positionAccount: positionAccountPDA,
@@ -10585,11 +10580,11 @@ var closeTradeV1 = (lavarageProgram, position, offer, jupInstruction, partnerFee
10585
10580
  ] : []
10586
10581
  ).instruction();
10587
10582
  } else {
10588
- repaySolIx = useReferral ? yield lavarageProgram.methods.tradingCloseRepaySolWithReferral(
10583
+ repaySolIx = shouldUseDiscountProgram ? yield lavarageProgram.methods.tradingCloseRepaySolWithReferral(
10589
10584
  new import_anchor3.BN(jupInstruction.quoteResponse.outAmount),
10590
10585
  new import_anchor3.BN(9998),
10591
- new import_anchor3.BN(discountBps),
10592
- new import_anchor3.BN(referralBps)
10586
+ new import_anchor3.BN(discountBps || 0),
10587
+ new import_anchor3.BN(referralBps || 0)
10593
10588
  ).accountsStrict({
10594
10589
  nodeWallet: pool.account.nodeWallet,
10595
10590
  positionAccount: positionAccountPDA,
@@ -10782,7 +10777,7 @@ var closeTradeV2 = (lavarageProgram, position, offer, jupInstruction, quoteToken
10782
10777
  });
10783
10778
  const addressLookupTableAccounts = [];
10784
10779
  const { blockhash } = yield lavarageProgram.provider.connection.getLatestBlockhash("finalized");
10785
- const useReferral = discountBps !== void 0 && referralBps !== void 0;
10780
+ const shouldUseDiscountProgram = discountBps !== void 0 && discountBps > 0 || referralBps !== void 0;
10786
10781
  let partnerFeeRecipientVaultCreateIx;
10787
10782
  let partnerFeeRecipientTokenAccountCreateIx;
10788
10783
  let userVaultPda;
@@ -10838,11 +10833,11 @@ var closeTradeV2 = (lavarageProgram, position, offer, jupInstruction, quoteToken
10838
10833
  let repaySolIx = null;
10839
10834
  let jupiterIxs = [];
10840
10835
  if (jupInstruction.instructions == void 0) {
10841
- repaySolIx = useReferral ? yield lavarageProgram.methods.tradingCloseRepaySol(
10836
+ repaySolIx = shouldUseDiscountProgram ? yield lavarageProgram.methods.tradingCloseRepaySol(
10842
10837
  new import_anchor3.BN(jupInstruction.quoteResponse.outAmount),
10843
10838
  new import_anchor3.BN(9997),
10844
- new import_anchor3.BN(discountBps),
10845
- new import_anchor3.BN(referralBps)
10839
+ new import_anchor3.BN(discountBps || 0),
10840
+ new import_anchor3.BN(referralBps || 0)
10846
10841
  ).accountsStrict({
10847
10842
  nodeWallet: pool.account.nodeWallet,
10848
10843
  positionAccount: positionAccountPDA,
@@ -10938,11 +10933,11 @@ var closeTradeV2 = (lavarageProgram, position, offer, jupInstruction, quoteToken
10938
10933
  ] : []
10939
10934
  ).instruction();
10940
10935
  } else {
10941
- repaySolIx = useReferral ? yield lavarageProgram.methods.tradingCloseRepaySol(
10936
+ repaySolIx = shouldUseDiscountProgram ? yield lavarageProgram.methods.tradingCloseRepaySol(
10942
10937
  new import_anchor3.BN(jupInstruction.quoteResponse.outAmount),
10943
10938
  new import_anchor3.BN(9998),
10944
- new import_anchor3.BN(discountBps),
10945
- new import_anchor3.BN(referralBps)
10939
+ new import_anchor3.BN(discountBps || 0),
10940
+ new import_anchor3.BN(referralBps || 0)
10946
10941
  ).accountsStrict({
10947
10942
  nodeWallet: pool.account.nodeWallet,
10948
10943
  positionAccount: positionAccountPDA,