@lavarage/sdk 8.0.15 → 8.0.17

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/index.ts CHANGED
@@ -846,6 +846,7 @@ export const borrowV2 = async (
846
846
  tradingPool: offer.publicKey,
847
847
  trader: lavarageProgram.provider.publicKey!,
848
848
  mint: offer.account.collateralType,
849
+ quoteMint: quoteToken,
849
850
  toTokenAccount: toTokenAccount.account!.address,
850
851
  systemProgram: SystemProgram.programId,
851
852
  positionAccount,
@@ -907,7 +908,7 @@ export const borrowV2 = async (
907
908
  * @param computeBudgetMicroLamports - Optional compute budget for priority fees
908
909
  * @param platformFeeRecipient - Optional wallet to receive platform fees (jup, okx)
909
910
  * @param splitTransactions - Optional boolean to split the transaction into multiple transactions (jito bundle)
910
- * @param discountBps - Optional discount basis points for the referral program
911
+ * @param discountBps - Optional discount basis points for the referral program and discount program
911
912
  * @param referralBps - Optional referral basis points for the referral program
912
913
  * @param optionalRPCResults - Optional RPC results to use for the transaction (speeds up the transaction building)
913
914
  *
@@ -1078,7 +1079,7 @@ export const openTradeV1 = async (
1078
1079
  const blockhash =
1079
1080
  optionalRPCResults?.latestBlockhash ?? (await lavarageProgram.provider.connection.getLatestBlockhash("finalized")).blockhash;
1080
1081
 
1081
- const useReferral = discountBps !== undefined && referralBps !== undefined;
1082
+ const shouldUseDiscountProgram = (discountBps !== undefined && discountBps > 0) || referralBps !== undefined;
1082
1083
 
1083
1084
  // Check if partner fee recipient vault needs to be initialized via referralVaultProgram
1084
1085
  let partnerFeeRecipientCreateIx: TransactionInstruction | undefined;
@@ -1103,13 +1104,13 @@ export const openTradeV1 = async (
1103
1104
  }
1104
1105
  }
1105
1106
 
1106
- const tradingOpenBorrowInstruction = useReferral
1107
+ const tradingOpenBorrowInstruction = shouldUseDiscountProgram
1107
1108
  ? await lavarageProgram.methods
1108
1109
  .tradingOpenBorrowWithReferral(
1109
1110
  new BN((marginSOL.toNumber() * leverage).toFixed(0)),
1110
1111
  marginSOL,
1111
- new BN(discountBps),
1112
- new BN(referralBps)
1112
+ new BN(discountBps || 0),
1113
+ new BN(referralBps || 0)
1113
1114
  )
1114
1115
  .accountsStrict({
1115
1116
  nodeWallet: offer.account.nodeWallet,
@@ -1207,12 +1208,12 @@ export const openTradeV1 = async (
1207
1208
  fromTokenAccount.instruction!,
1208
1209
  toTokenAccount.instruction!,
1209
1210
  partnerFeeRecipientCreateIx,
1210
- ...setupInstructions.map(deserializeInstruction),
1211
1211
  ].filter(Boolean) as TransactionInstruction[];
1212
1212
 
1213
1213
  const allInstructions = [
1214
1214
  tradingOpenBorrowInstruction!,
1215
- deserializeInstruction(swapInstructionPayload), ,
1215
+ ...setupInstructions.map(deserializeInstruction),
1216
+ deserializeInstruction(swapInstructionPayload),
1216
1217
  openAddCollateralInstruction!,
1217
1218
  computeBudgetMicroLamports ? computeFeeIx : undefined,
1218
1219
  ].filter(Boolean) as TransactionInstruction[];
@@ -1283,7 +1284,7 @@ export const openTradeV1 = async (
1283
1284
  * @param computeBudgetMicroLamports - Optional compute budget for priority fees
1284
1285
  * @param platformFeeRecipient - Optional wallet to receive platform fees (jup, okx)
1285
1286
  * @param splitTransactions - Optional boolean to split the transaction into multiple transactions (jito bundle)
1286
- * @param discountBps - Optional discount basis points for the referral program
1287
+ * @param discountBps - Optional discount basis points for the referral program and discount program
1287
1288
  * @param referralBps - Optional referral basis points for the referral program
1288
1289
  * @param optionalRPCResults - Optional RPC results to use for the transaction (speeds up the transaction building)
1289
1290
  *
@@ -1471,7 +1472,7 @@ export const openTradeV2 = async (
1471
1472
  const { blockhash } =
1472
1473
  await program.provider.connection.getLatestBlockhash("finalized");
1473
1474
 
1474
- const useReferral = discountBps !== undefined && referralBps !== undefined;
1475
+ const shouldUseDiscountProgram = (discountBps !== undefined && discountBps > 0) || referralBps !== undefined;
1475
1476
 
1476
1477
  // Check if partner fee recipient vault and token account need to be created
1477
1478
  let partnerFeeRecipientVaultCreateIx: TransactionInstruction | undefined;
@@ -1546,13 +1547,14 @@ export const openTradeV2 = async (
1546
1547
  }
1547
1548
  }
1548
1549
 
1549
- const tradingOpenBorrowInstruction = useReferral
1550
+
1551
+ const tradingOpenBorrowInstruction = shouldUseDiscountProgram
1550
1552
  ? await program.methods
1551
1553
  .tradingOpenBorrow(
1552
1554
  new BN((marginSOL.toNumber() * leverage).toFixed(0)),
1553
1555
  marginSOL,
1554
- new BN(discountBps),
1555
- new BN(referralBps)
1556
+ new BN(discountBps || 0),
1557
+ new BN(referralBps || 0)
1556
1558
  )
1557
1559
  .accountsStrict({
1558
1560
  nodeWallet: offer.account.nodeWallet,
@@ -1676,6 +1678,7 @@ export const openTradeV2 = async (
1676
1678
  tradingPool: offer.publicKey,
1677
1679
  trader: program.provider.publicKey!,
1678
1680
  mint: offer.account.collateralType,
1681
+ quoteMint: quoteToken,
1679
1682
  toTokenAccount: toTokenAccount.account!.address,
1680
1683
  systemProgram: SystemProgram.programId,
1681
1684
  positionAccount,
@@ -2193,7 +2196,7 @@ export const partialRepayV2 = async (
2193
2196
  * @param computeBudgetMicroLamports - Optional compute budget for priority fees
2194
2197
  * @param platformFeeRecipient - Optional wallet to receive platform fees (jup, okx)
2195
2198
  * @param splitTransactions - Optional boolean to split the transaction into multiple transactions (jito bundle)
2196
- * @param discountBps - Optional discount basis points for the referral program
2199
+ * @param discountBps - Optional discount basis points for the referral program and discount program
2197
2200
  * @param referralBps - Optional referral basis points for the referral program
2198
2201
  *
2199
2202
  * @returns Transaction to close the position
@@ -2336,7 +2339,7 @@ export const closeTradeV1 = async (
2336
2339
  const { blockhash } =
2337
2340
  await lavarageProgram.provider.connection.getLatestBlockhash("finalized");
2338
2341
 
2339
- const useReferral = discountBps !== undefined && referralBps !== undefined;
2342
+ const shouldUseDiscountProgram = (discountBps !== undefined && discountBps > 0) || referralBps !== undefined;
2340
2343
 
2341
2344
  // Check if partner fee recipient vault needs to be initialized via referralVaultProgram
2342
2345
  let partnerFeeRecipientCreateIx: TransactionInstruction | undefined;
@@ -2382,13 +2385,13 @@ export const closeTradeV1 = async (
2382
2385
  let repaySolIx: TransactionInstruction | null = null;
2383
2386
  let jupiterIxs: TransactionInstruction[] = [];
2384
2387
  if (jupInstruction.instructions == undefined) {
2385
- repaySolIx = useReferral
2388
+ repaySolIx = shouldUseDiscountProgram
2386
2389
  ? await lavarageProgram.methods
2387
2390
  .tradingCloseRepaySolWithReferral(
2388
2391
  new BN(jupInstruction.quoteResponse.outAmount),
2389
2392
  new BN(9997),
2390
- new BN(discountBps),
2391
- new BN(referralBps)
2393
+ new BN(discountBps || 0),
2394
+ new BN(referralBps || 0)
2392
2395
  )
2393
2396
  .accountsStrict({
2394
2397
  nodeWallet: pool.account.nodeWallet,
@@ -2445,13 +2448,13 @@ export const closeTradeV1 = async (
2445
2448
  )
2446
2449
  .instruction();
2447
2450
  } else {
2448
- repaySolIx = useReferral
2451
+ repaySolIx = shouldUseDiscountProgram
2449
2452
  ? await lavarageProgram.methods
2450
2453
  .tradingCloseRepaySolWithReferral(
2451
2454
  new BN(jupInstruction.quoteResponse.outAmount),
2452
2455
  new BN(9998),
2453
- new BN(discountBps),
2454
- new BN(referralBps)
2456
+ new BN(discountBps || 0),
2457
+ new BN(referralBps || 0)
2455
2458
  )
2456
2459
  .accountsStrict({
2457
2460
  nodeWallet: pool.account.nodeWallet,
@@ -2621,7 +2624,7 @@ export const closeTradeV1 = async (
2621
2624
  * @param computeBudgetMicroLamports - Optional compute budget for priority fees
2622
2625
  * @param platformFeeRecipient - Optional wallet to receive platform fees (jup, okx)
2623
2626
  * @param splitTransactions - Optional boolean to split the transaction into multiple transactions (jito bundle)
2624
- * @param discountBps - Optional discount basis points for the referral program
2627
+ * @param discountBps - Optional discount basis points for the referral program and discount program
2625
2628
  * @param referralBps - Optional referral basis points for the referral program
2626
2629
  *
2627
2630
  * @returns Transaction to close the position
@@ -2770,7 +2773,7 @@ export const closeTradeV2 = async (
2770
2773
  const { blockhash } =
2771
2774
  await lavarageProgram.provider.connection.getLatestBlockhash("finalized");
2772
2775
 
2773
- const useReferral = discountBps !== undefined && referralBps !== undefined;
2776
+ const shouldUseDiscountProgram = (discountBps !== undefined && discountBps > 0) || referralBps !== undefined;
2774
2777
 
2775
2778
  // Check if partner fee recipient vault and token account need to be created
2776
2779
  let partnerFeeRecipientVaultCreateIx: TransactionInstruction | undefined;
@@ -2845,13 +2848,13 @@ export const closeTradeV2 = async (
2845
2848
  let repaySolIx: TransactionInstruction | null = null;
2846
2849
  let jupiterIxs: TransactionInstruction[] = [];
2847
2850
  if (jupInstruction.instructions == undefined) {
2848
- repaySolIx = useReferral
2851
+ repaySolIx = shouldUseDiscountProgram
2849
2852
  ? await lavarageProgram.methods
2850
2853
  .tradingCloseRepaySol(
2851
2854
  new BN(jupInstruction.quoteResponse.outAmount),
2852
2855
  new BN(9997),
2853
- new BN(discountBps),
2854
- new BN(referralBps)
2856
+ new BN(discountBps || 0),
2857
+ new BN(referralBps || 0)
2855
2858
  )
2856
2859
  .accountsStrict({
2857
2860
  nodeWallet: pool.account.nodeWallet,
@@ -2958,13 +2961,13 @@ export const closeTradeV2 = async (
2958
2961
  )
2959
2962
  .instruction();
2960
2963
  } else {
2961
- repaySolIx = useReferral
2964
+ repaySolIx = shouldUseDiscountProgram
2962
2965
  ? await lavarageProgram.methods
2963
2966
  .tradingCloseRepaySol(
2964
2967
  new BN(jupInstruction.quoteResponse.outAmount),
2965
2968
  new BN(9998),
2966
- new BN(discountBps),
2967
- new BN(referralBps)
2969
+ new BN(discountBps || 0),
2970
+ new BN(referralBps || 0)
2968
2971
  )
2969
2972
  .accountsStrict({
2970
2973
  nodeWallet: pool.account.nodeWallet,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lavarage/sdk",
3
- "version": "8.0.15",
3
+ "version": "8.0.17",
4
4
  "description": "Lavarage SDK",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.mjs",