@lavarage/sdk 7.0.1 → 7.0.3

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
@@ -3487,7 +3487,7 @@ declare const openTradeV1: (lavarageProgram: Program<Lavarage$1>, offer: Program
3487
3487
  swapInstruction: Record<string, unknown>;
3488
3488
  addressLookupTableAddresses: string[];
3489
3489
  };
3490
- }, marginSOL: BN, leverage: number, randomSeed: Keypair, tokenProgram: PublicKey, partnerFeeRecipient?: PublicKey, partnerFeeMarkup?: number, computeBudgetMicroLamports?: number) => Promise<VersionedTransaction>;
3490
+ }, marginSOL: BN, leverage: number, randomSeed: Keypair, tokenProgram: PublicKey, partnerFeeRecipient?: PublicKey, partnerFeeMarkup?: number, computeBudgetMicroLamports?: number, platformFeeRecipient?: PublicKey) => Promise<VersionedTransaction>;
3491
3491
  declare const openTradeV2: (lavarageProgram: Program<Lavarage>, offer: ProgramAccount<{
3492
3492
  nodeWallet: PublicKey;
3493
3493
  interestRate: number;
@@ -3498,7 +3498,7 @@ declare const openTradeV2: (lavarageProgram: Program<Lavarage>, offer: ProgramAc
3498
3498
  swapInstruction: Record<string, unknown>;
3499
3499
  addressLookupTableAddresses: string[];
3500
3500
  };
3501
- }, marginSOL: BN, leverage: number, randomSeed: Keypair, quoteToken: PublicKey, tokenProgram: PublicKey, partnerFeeRecipient?: PublicKey, partnerFeeMarkup?: number, computeBudgetMicroLamports?: number) => Promise<VersionedTransaction>;
3501
+ }, marginSOL: BN, leverage: number, randomSeed: Keypair, quoteToken: PublicKey, tokenProgram: PublicKey, partnerFeeRecipient?: PublicKey, partnerFeeMarkup?: number, computeBudgetMicroLamports?: number, platformFeeRecipient?: PublicKey) => Promise<VersionedTransaction>;
3502
3502
  declare const createTpDelegate: (lavarageProgram: Program<Lavarage$1> | Program<Lavarage>, position: ProgramAccount<{
3503
3503
  pool: PublicKey;
3504
3504
  seed: PublicKey;
@@ -3547,7 +3547,7 @@ declare const closeTradeV1: (lavarageProgram: Program<Lavarage$1>, position: Pro
3547
3547
  tokenLedgerInstruction?: Record<string, unknown>;
3548
3548
  };
3549
3549
  quoteResponse: any;
3550
- }, partnerFeeRecipient?: PublicKey, partnerFeeMarkup?: number, computeBudgetMicroLamports?: number) => Promise<VersionedTransaction>;
3550
+ }, partnerFeeRecipient?: PublicKey, partnerFeeMarkup?: number, computeBudgetMicroLamports?: number, platformFeeRecipient?: PublicKey) => Promise<VersionedTransaction>;
3551
3551
  declare const closeTradeV2: (lavarageProgram: Program<Lavarage>, position: ProgramAccount<{
3552
3552
  pool: PublicKey;
3553
3553
  seed: PublicKey;
@@ -3566,7 +3566,7 @@ declare const closeTradeV2: (lavarageProgram: Program<Lavarage>, position: Progr
3566
3566
  tokenLedgerInstruction?: Record<string, unknown>;
3567
3567
  };
3568
3568
  quoteResponse: any;
3569
- }, quoteToken: PublicKey, partnerFeeRecipient?: PublicKey, partnerFeeMarkup?: number, computeBudgetMicroLamports?: number) => Promise<VersionedTransaction>;
3569
+ }, quoteToken: PublicKey, partnerFeeRecipient?: PublicKey, partnerFeeMarkup?: number, computeBudgetMicroLamports?: number, platformFeeRecipient?: PublicKey) => Promise<VersionedTransaction>;
3570
3570
  declare const getDelegateAccounts: (lavarageProgram: Program<Lavarage$1> | Program<Lavarage>, userPubKey?: PublicKey) => Promise<{
3571
3571
  parsed: {
3572
3572
  tpPrice: any;
package/dist/index.d.ts CHANGED
@@ -3487,7 +3487,7 @@ declare const openTradeV1: (lavarageProgram: Program<Lavarage$1>, offer: Program
3487
3487
  swapInstruction: Record<string, unknown>;
3488
3488
  addressLookupTableAddresses: string[];
3489
3489
  };
3490
- }, marginSOL: BN, leverage: number, randomSeed: Keypair, tokenProgram: PublicKey, partnerFeeRecipient?: PublicKey, partnerFeeMarkup?: number, computeBudgetMicroLamports?: number) => Promise<VersionedTransaction>;
3490
+ }, marginSOL: BN, leverage: number, randomSeed: Keypair, tokenProgram: PublicKey, partnerFeeRecipient?: PublicKey, partnerFeeMarkup?: number, computeBudgetMicroLamports?: number, platformFeeRecipient?: PublicKey) => Promise<VersionedTransaction>;
3491
3491
  declare const openTradeV2: (lavarageProgram: Program<Lavarage>, offer: ProgramAccount<{
3492
3492
  nodeWallet: PublicKey;
3493
3493
  interestRate: number;
@@ -3498,7 +3498,7 @@ declare const openTradeV2: (lavarageProgram: Program<Lavarage>, offer: ProgramAc
3498
3498
  swapInstruction: Record<string, unknown>;
3499
3499
  addressLookupTableAddresses: string[];
3500
3500
  };
3501
- }, marginSOL: BN, leverage: number, randomSeed: Keypair, quoteToken: PublicKey, tokenProgram: PublicKey, partnerFeeRecipient?: PublicKey, partnerFeeMarkup?: number, computeBudgetMicroLamports?: number) => Promise<VersionedTransaction>;
3501
+ }, marginSOL: BN, leverage: number, randomSeed: Keypair, quoteToken: PublicKey, tokenProgram: PublicKey, partnerFeeRecipient?: PublicKey, partnerFeeMarkup?: number, computeBudgetMicroLamports?: number, platformFeeRecipient?: PublicKey) => Promise<VersionedTransaction>;
3502
3502
  declare const createTpDelegate: (lavarageProgram: Program<Lavarage$1> | Program<Lavarage>, position: ProgramAccount<{
3503
3503
  pool: PublicKey;
3504
3504
  seed: PublicKey;
@@ -3547,7 +3547,7 @@ declare const closeTradeV1: (lavarageProgram: Program<Lavarage$1>, position: Pro
3547
3547
  tokenLedgerInstruction?: Record<string, unknown>;
3548
3548
  };
3549
3549
  quoteResponse: any;
3550
- }, partnerFeeRecipient?: PublicKey, partnerFeeMarkup?: number, computeBudgetMicroLamports?: number) => Promise<VersionedTransaction>;
3550
+ }, partnerFeeRecipient?: PublicKey, partnerFeeMarkup?: number, computeBudgetMicroLamports?: number, platformFeeRecipient?: PublicKey) => Promise<VersionedTransaction>;
3551
3551
  declare const closeTradeV2: (lavarageProgram: Program<Lavarage>, position: ProgramAccount<{
3552
3552
  pool: PublicKey;
3553
3553
  seed: PublicKey;
@@ -3566,7 +3566,7 @@ declare const closeTradeV2: (lavarageProgram: Program<Lavarage>, position: Progr
3566
3566
  tokenLedgerInstruction?: Record<string, unknown>;
3567
3567
  };
3568
3568
  quoteResponse: any;
3569
- }, quoteToken: PublicKey, partnerFeeRecipient?: PublicKey, partnerFeeMarkup?: number, computeBudgetMicroLamports?: number) => Promise<VersionedTransaction>;
3569
+ }, quoteToken: PublicKey, partnerFeeRecipient?: PublicKey, partnerFeeMarkup?: number, computeBudgetMicroLamports?: number, platformFeeRecipient?: PublicKey) => Promise<VersionedTransaction>;
3570
3570
  declare const getDelegateAccounts: (lavarageProgram: Program<Lavarage$1> | Program<Lavarage>, userPubKey?: PublicKey) => Promise<{
3571
3571
  parsed: {
3572
3572
  tpPrice: any;
package/dist/index.js CHANGED
@@ -1251,10 +1251,12 @@ function withdrawFundsV1(lavarageProgram, params) {
1251
1251
  return __async(this, null, function* () {
1252
1252
  var _a;
1253
1253
  const { blockhash } = yield lavarageProgram.provider.connection.getLatestBlockhash("finalized");
1254
- const instruction = yield lavarageProgram.methods.lpOperatorWithdrawFromNodeWallet(new import_anchor.BN(params.amount)).accounts({
1254
+ const withdrawalAccessList = getWithdrawalAccessListPDA(lavarageProgram.programId);
1255
+ const instruction = yield lavarageProgram.methods.lpOperatorWithdrawFromNodeWallet(new import_anchor.BN(params.amount)).accountsStrict({
1255
1256
  nodeWallet: params.nodeWallet,
1256
1257
  funder: params.funder,
1257
- systemProgram: import_web3.SystemProgram.programId
1258
+ systemProgram: import_web3.SystemProgram.programId,
1259
+ withdrawalAccessList
1258
1260
  }).instruction();
1259
1261
  const computeFeeIx = import_web3.ComputeBudgetProgram.setComputeUnitPrice({
1260
1262
  microLamports: (_a = params.computeBudgetMicroLamports) != null ? _a : 15e4
@@ -1274,14 +1276,16 @@ function withdrawFundsV2(lavarageProgram, params) {
1274
1276
  const mintPubkey = new import_web3.PublicKey(params.mint);
1275
1277
  const fromTokenAccount = params.fromTokenAccount || (0, import_spl_token.getAssociatedTokenAddressSync)(mintPubkey, params.nodeWallet, true);
1276
1278
  const toTokenAccount = params.toTokenAccount || (0, import_spl_token.getAssociatedTokenAddressSync)(mintPubkey, params.funder);
1277
- const instruction = yield lavarageProgram.methods.lpOperatorWithdrawFromNodeWallet(new import_anchor.BN(params.amount)).accounts({
1279
+ const withdrawalAccessList = getWithdrawalAccessListPDA(lavarageProgram.programId);
1280
+ const instruction = yield lavarageProgram.methods.lpOperatorWithdrawFromNodeWallet(new import_anchor.BN(params.amount)).accountsStrict({
1278
1281
  nodeWallet: params.nodeWallet,
1279
1282
  funder: params.funder,
1280
1283
  systemProgram: import_web3.SystemProgram.programId,
1281
1284
  mint: mintPubkey,
1282
1285
  fromTokenAccount,
1283
1286
  toTokenAccount,
1284
- tokenProgram: import_spl_token.TOKEN_PROGRAM_ID
1287
+ tokenProgram: import_spl_token.TOKEN_PROGRAM_ID,
1288
+ withdrawalAccessList
1285
1289
  }).instruction();
1286
1290
  const computeFeeIx = import_web3.ComputeBudgetProgram.setComputeUnitPrice({
1287
1291
  microLamports: (_a = params.computeBudgetMicroLamports) != null ? _a : 15e4
@@ -4739,7 +4743,7 @@ var getLiquidatedPositions = (lavarageProgram) => {
4739
4743
  var getAllPositions = (lavarageProgram) => {
4740
4744
  return lavarageProgram.account.position.all([{ dataSize: 178 }]);
4741
4745
  };
4742
- var openTradeV1 = (lavarageProgram, offer, jupInstruction, marginSOL, leverage, randomSeed, tokenProgram, partnerFeeRecipient, partnerFeeMarkup, computeBudgetMicroLamports) => __async(void 0, null, function* () {
4746
+ var openTradeV1 = (lavarageProgram, offer, jupInstruction, marginSOL, leverage, randomSeed, tokenProgram, partnerFeeRecipient, partnerFeeMarkup, computeBudgetMicroLamports, platformFeeRecipient) => __async(void 0, null, function* () {
4743
4747
  let partnerFeeMarkupAsPkey;
4744
4748
  if (partnerFeeMarkup) {
4745
4749
  const feeBuffer = Buffer.alloc(8);
@@ -4765,6 +4769,12 @@ var openTradeV1 = (lavarageProgram, offer, jupInstruction, marginSOL, leverage,
4765
4769
  offer.account.collateralType,
4766
4770
  tokenProgram
4767
4771
  );
4772
+ const platformFeeRecipientAccount = platformFeeRecipient ? yield getTokenAccountOrCreateIfNotExists(
4773
+ lavarageProgram,
4774
+ platformFeeRecipient,
4775
+ offer.account.collateralType,
4776
+ tokenProgram
4777
+ ) : void 0;
4768
4778
  const tokenAccountCreationTx = new import_web32.Transaction();
4769
4779
  if (fromTokenAccount.instruction) {
4770
4780
  tokenAccountCreationTx.add(fromTokenAccount.instruction);
@@ -4772,6 +4782,9 @@ var openTradeV1 = (lavarageProgram, offer, jupInstruction, marginSOL, leverage,
4772
4782
  if (toTokenAccount.instruction) {
4773
4783
  tokenAccountCreationTx.add(toTokenAccount.instruction);
4774
4784
  }
4785
+ if (platformFeeRecipientAccount == null ? void 0 : platformFeeRecipientAccount.instruction) {
4786
+ tokenAccountCreationTx.add(platformFeeRecipientAccount.instruction);
4787
+ }
4775
4788
  const instructionsJup = jupInstruction.instructions;
4776
4789
  const {
4777
4790
  setupInstructions,
@@ -4874,7 +4887,7 @@ var openTradeV1 = (lavarageProgram, offer, jupInstruction, marginSOL, leverage,
4874
4887
  const tx = new import_web32.VersionedTransaction(messageV0);
4875
4888
  return tx;
4876
4889
  });
4877
- var openTradeV2 = (lavarageProgram, offer, jupInstruction, marginSOL, leverage, randomSeed, quoteToken, tokenProgram, partnerFeeRecipient, partnerFeeMarkup, computeBudgetMicroLamports) => __async(void 0, null, function* () {
4890
+ var openTradeV2 = (lavarageProgram, offer, jupInstruction, marginSOL, leverage, randomSeed, quoteToken, tokenProgram, partnerFeeRecipient, partnerFeeMarkup, computeBudgetMicroLamports, platformFeeRecipient) => __async(void 0, null, function* () {
4878
4891
  let partnerFeeMarkupAsPkey;
4879
4892
  if (partnerFeeMarkup) {
4880
4893
  const feeBuffer = Buffer.alloc(8);
@@ -4902,6 +4915,12 @@ var openTradeV2 = (lavarageProgram, offer, jupInstruction, marginSOL, leverage,
4902
4915
  offer.account.collateralType,
4903
4916
  tokenProgram
4904
4917
  );
4918
+ const platformFeeRecipientAccount = platformFeeRecipient ? yield getTokenAccountOrCreateIfNotExists(
4919
+ lavarageProgram,
4920
+ platformFeeRecipient,
4921
+ offer.account.collateralType,
4922
+ tokenProgram
4923
+ ) : void 0;
4905
4924
  const tokenAccountCreationTx = new import_web32.Transaction();
4906
4925
  if (fromTokenAccount.instruction) {
4907
4926
  tokenAccountCreationTx.add(fromTokenAccount.instruction);
@@ -4909,6 +4928,9 @@ var openTradeV2 = (lavarageProgram, offer, jupInstruction, marginSOL, leverage,
4909
4928
  if (toTokenAccount.instruction) {
4910
4929
  tokenAccountCreationTx.add(toTokenAccount.instruction);
4911
4930
  }
4931
+ if (platformFeeRecipientAccount == null ? void 0 : platformFeeRecipientAccount.instruction) {
4932
+ tokenAccountCreationTx.add(platformFeeRecipientAccount.instruction);
4933
+ }
4912
4934
  const instructionsJup = jupInstruction.instructions;
4913
4935
  const {
4914
4936
  setupInstructions,
@@ -5196,7 +5218,7 @@ var partialRepayV2 = (lavarageProgram, position, repaymentBps) => __async(void 0
5196
5218
  }).compileToV0Message();
5197
5219
  return new import_web32.VersionedTransaction(messageV0);
5198
5220
  });
5199
- var closeTradeV1 = (lavarageProgram, position, offer, jupInstruction, partnerFeeRecipient, partnerFeeMarkup, computeBudgetMicroLamports) => __async(void 0, null, function* () {
5221
+ var closeTradeV1 = (lavarageProgram, position, offer, jupInstruction, partnerFeeRecipient, partnerFeeMarkup, computeBudgetMicroLamports, platformFeeRecipient) => __async(void 0, null, function* () {
5200
5222
  var _a, _b;
5201
5223
  let partnerFeeMarkupAsPkey;
5202
5224
  if (partnerFeeMarkup) {
@@ -5228,6 +5250,12 @@ var closeTradeV1 = (lavarageProgram, position, offer, jupInstruction, partnerFee
5228
5250
  tokenAddressPubKey,
5229
5251
  tokenProgram
5230
5252
  );
5253
+ const platformFeeRecipientAccount = platformFeeRecipient ? yield getTokenAccountOrCreateIfNotExists(
5254
+ lavarageProgram,
5255
+ platformFeeRecipient,
5256
+ offer.account.collateralType,
5257
+ tokenProgram
5258
+ ) : void 0;
5231
5259
  const jupiterSellIx = jupInstruction.instructions;
5232
5260
  const deserializeInstruction = (instruction) => {
5233
5261
  return new import_web32.TransactionInstruction({
@@ -5359,6 +5387,7 @@ var closeTradeV1 = (lavarageProgram, position, offer, jupInstruction, partnerFee
5359
5387
  microLamports: computeBudgetMicroLamports != null ? computeBudgetMicroLamports : 1e5
5360
5388
  });
5361
5389
  const allInstructions = [
5390
+ jupInstruction.instructions && (platformFeeRecipientAccount == null ? void 0 : platformFeeRecipientAccount.instruction) ? platformFeeRecipientAccount.instruction : null,
5362
5391
  ((_a = jupInstruction.instructions) == null ? void 0 : _a.tokenLedgerInstruction) ? createAssociatedTokenAccountInstruction2 : null,
5363
5392
  ((_b = jupInstruction.instructions) == null ? void 0 : _b.tokenLedgerInstruction) ? deserializeInstruction(
5364
5393
  jupInstruction.instructions.tokenLedgerInstruction
@@ -5377,7 +5406,7 @@ var closeTradeV1 = (lavarageProgram, position, offer, jupInstruction, partnerFee
5377
5406
  const tx = new import_web32.VersionedTransaction(messageV0);
5378
5407
  return tx;
5379
5408
  });
5380
- var closeTradeV2 = (lavarageProgram, position, offer, jupInstruction, quoteToken, partnerFeeRecipient, partnerFeeMarkup, computeBudgetMicroLamports) => __async(void 0, null, function* () {
5409
+ var closeTradeV2 = (lavarageProgram, position, offer, jupInstruction, quoteToken, partnerFeeRecipient, partnerFeeMarkup, computeBudgetMicroLamports, platformFeeRecipient) => __async(void 0, null, function* () {
5381
5410
  var _a, _b;
5382
5411
  let partnerFeeMarkupAsPkey;
5383
5412
  if (partnerFeeMarkup) {
@@ -5411,6 +5440,12 @@ var closeTradeV2 = (lavarageProgram, position, offer, jupInstruction, quoteToken
5411
5440
  tokenAddressPubKey,
5412
5441
  tokenProgram
5413
5442
  );
5443
+ const platformFeeRecipientAccount = platformFeeRecipient ? yield getTokenAccountOrCreateIfNotExists(
5444
+ lavarageProgram,
5445
+ platformFeeRecipient,
5446
+ offer.account.collateralType,
5447
+ tokenProgram
5448
+ ) : void 0;
5414
5449
  const jupiterSellIx = jupInstruction.instructions;
5415
5450
  const deserializeInstruction = (instruction) => {
5416
5451
  return new import_web32.TransactionInstruction({
@@ -5586,6 +5621,7 @@ var closeTradeV2 = (lavarageProgram, position, offer, jupInstruction, quoteToken
5586
5621
  microLamports: computeBudgetMicroLamports != null ? computeBudgetMicroLamports : 1e5
5587
5622
  });
5588
5623
  const allInstructions = [
5624
+ jupInstruction.instructions && (platformFeeRecipientAccount == null ? void 0 : platformFeeRecipientAccount.instruction) ? platformFeeRecipientAccount.instruction : null,
5589
5625
  ((_a = jupInstruction.instructions) == null ? void 0 : _a.tokenLedgerInstruction) ? createAssociatedTokenAccountInstruction2 : null,
5590
5626
  ((_b = jupInstruction.instructions) == null ? void 0 : _b.tokenLedgerInstruction) ? deserializeInstruction(
5591
5627
  jupInstruction.instructions.tokenLedgerInstruction