@lavarage/sdk 7.0.4 → 7.1.0

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/lending.ts CHANGED
@@ -69,14 +69,15 @@ async function createNodeWallet(
69
69
  liquidationLtv?: number; // Required for V2, optional for V1
70
70
  }
71
71
  ): Promise<{
72
- instruction: TransactionInstruction;
72
+ instructions: TransactionInstruction[];
73
73
  nodeWallet: Keypair | undefined;
74
74
  nodeWalletAccount: PublicKey;
75
75
  }> {
76
76
  const { blockhash } =
77
77
  await lavarageProgram.provider.connection.getLatestBlockhash("finalized");
78
78
 
79
- let instruction, nodeWallet;
79
+ let instructions: TransactionInstruction[] = [];
80
+ let nodeWallet;
80
81
 
81
82
  // Check if this is V2 program (has mint and liquidationLtv parameters)
82
83
  if (params.mint !== undefined && params.liquidationLtv !== undefined) {
@@ -86,7 +87,7 @@ async function createNodeWallet(
86
87
  lavarageProgram.programId
87
88
  );
88
89
  // V2 version
89
- instruction = await (lavarageProgram as Program<LavarageV2>).methods
90
+ instructions.push(await (lavarageProgram as Program<LavarageV2>).methods
90
91
  .lpOperatorCreateNodeWallet(new BN(params.liquidationLtv))
91
92
  .accounts({
92
93
  nodeWallet: nodeWallet,
@@ -94,22 +95,41 @@ async function createNodeWallet(
94
95
  systemProgram: SystemProgram.programId,
95
96
  mint: new PublicKey(params.mint),
96
97
  })
97
- .instruction();
98
+ .instruction());
98
99
  } else {
99
- nodeWallet = Keypair.generate();
100
+ const seed = params.operator.toBase58().slice(0, 32);
101
+
102
+ const auxAccountPubkey = await PublicKey.createWithSeed(
103
+ params.operator,
104
+ seed,
105
+ lavarageProgram.programId
106
+ );
107
+
108
+ nodeWallet = auxAccountPubkey;
109
+
110
+ instructions.push(SystemProgram.createAccountWithSeed({
111
+ fromPubkey: params.operator,
112
+ basePubkey: params.operator,
113
+ seed,
114
+ newAccountPubkey: auxAccountPubkey,
115
+ lamports: 1300000,
116
+ space: 58,
117
+ programId: lavarageProgram.programId,
118
+ }));// Some code
119
+
100
120
  // V1 version
101
- instruction = await (lavarageProgram as Program<Lavarage>).methods
121
+ instructions.push(await (lavarageProgram as Program<Lavarage>).methods
102
122
  .lpOperatorCreateNodeWallet()
103
123
  .accounts({
104
- nodeWallet: nodeWallet.publicKey,
124
+ nodeWallet: auxAccountPubkey,
105
125
  operator: new PublicKey(params.operator),
106
126
  systemProgram: SystemProgram.programId,
107
127
  })
108
- .instruction();
128
+ .instruction());
109
129
  }
110
130
 
111
131
  return {
112
- instruction,
132
+ instructions ,
113
133
  nodeWallet: nodeWallet instanceof Keypair ? nodeWallet : undefined,
114
134
  nodeWalletAccount:
115
135
  nodeWallet instanceof Keypair ? nodeWallet.publicKey : nodeWallet,
@@ -338,7 +358,7 @@ export async function createOffer(
338
358
  }
339
359
  ): Promise<VersionedTransaction> {
340
360
 
341
- let nodeWalletAccount, nodeWalletSigner, createNodeWalletInstruction, nodeWalletPubKey;
361
+ let nodeWalletAccount, nodeWalletSigner, createNodeWalletInstruction: TransactionInstruction[] =[], nodeWalletPubKey;
342
362
 
343
363
  if (params.quoteMint === "So11111111111111111111111111111111111111112") {
344
364
  const nodeWallets = await lavarageProgram.account.nodeWallet.all();
@@ -364,7 +384,7 @@ export async function createOffer(
364
384
  const isSOL = params.quoteMint === "So11111111111111111111111111111111111111112";
365
385
 
366
386
  const {
367
- instruction,
387
+ instructions,
368
388
  nodeWallet,
369
389
  nodeWalletAccount: nodeWalletPublicKey,
370
390
  } = await createNodeWallet(lavarageProgram, {
@@ -373,7 +393,7 @@ export async function createOffer(
373
393
  liquidationLtv: isSOL ? undefined : 90, // Only pass liquidationLtv for V2 (non-SOL)
374
394
  });
375
395
  nodeWalletSigner = nodeWallet;
376
- createNodeWalletInstruction = instruction;
396
+ createNodeWalletInstruction = instructions;
377
397
  nodeWalletPubKey = nodeWalletPublicKey;
378
398
  } else {
379
399
  nodeWalletPubKey = nodeWalletAccount.publicKey;
@@ -418,9 +438,7 @@ export async function createOffer(
418
438
  payerKey: lavarageProgram.provider.publicKey!,
419
439
  recentBlockhash: blockhash,
420
440
  instructions: [
421
- createNodeWalletInstruction === undefined
422
- ? null
423
- : createNodeWalletInstruction,
441
+ ...createNodeWalletInstruction,
424
442
  instruction,
425
443
  updateMaxExposureInstruction,
426
444
  transferInstruction,
@@ -428,12 +446,6 @@ export async function createOffer(
428
446
  ].filter(Boolean) as TransactionInstruction[],
429
447
  }).compileToV0Message();
430
448
 
431
- if (nodeWalletSigner) {
432
- const transaction = new VersionedTransaction(messageV0);
433
- transaction.sign([nodeWalletSigner]);
434
- return transaction;
435
- }
436
-
437
449
  return new VersionedTransaction(messageV0);
438
450
  }
439
451
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lavarage/sdk",
3
- "version": "7.0.4",
3
+ "version": "7.1.0",
4
4
  "description": "Lavarage SDK",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.mjs",