@lavarage/sdk 7.0.3 → 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/dist/index.js CHANGED
@@ -1151,29 +1151,45 @@ function getWithdrawalAccessListPDA(programId) {
1151
1151
  function createNodeWallet(lavarageProgram, params) {
1152
1152
  return __async(this, null, function* () {
1153
1153
  const { blockhash } = yield lavarageProgram.provider.connection.getLatestBlockhash("finalized");
1154
- let instruction, nodeWallet;
1154
+ let instructions = [];
1155
+ let nodeWallet;
1155
1156
  if (params.mint !== void 0 && params.liquidationLtv !== void 0) {
1156
1157
  nodeWallet = getNodeWalletPDA(
1157
1158
  new import_web3.PublicKey(params.operator),
1158
1159
  new import_web3.PublicKey(params.mint),
1159
1160
  lavarageProgram.programId
1160
1161
  );
1161
- instruction = yield lavarageProgram.methods.lpOperatorCreateNodeWallet(new import_anchor.BN(params.liquidationLtv)).accounts({
1162
+ instructions.push(yield lavarageProgram.methods.lpOperatorCreateNodeWallet(new import_anchor.BN(params.liquidationLtv)).accounts({
1162
1163
  nodeWallet,
1163
1164
  operator: new import_web3.PublicKey(params.operator),
1164
1165
  systemProgram: import_web3.SystemProgram.programId,
1165
1166
  mint: new import_web3.PublicKey(params.mint)
1166
- }).instruction();
1167
+ }).instruction());
1167
1168
  } else {
1168
- nodeWallet = import_web3.Keypair.generate();
1169
- instruction = yield lavarageProgram.methods.lpOperatorCreateNodeWallet().accounts({
1170
- nodeWallet: nodeWallet.publicKey,
1169
+ const seed = params.operator.toBase58().slice(0, 32);
1170
+ const auxAccountPubkey = yield import_web3.PublicKey.createWithSeed(
1171
+ params.operator,
1172
+ seed,
1173
+ lavarageProgram.programId
1174
+ );
1175
+ nodeWallet = auxAccountPubkey;
1176
+ instructions.push(import_web3.SystemProgram.createAccountWithSeed({
1177
+ fromPubkey: params.operator,
1178
+ basePubkey: params.operator,
1179
+ seed,
1180
+ newAccountPubkey: auxAccountPubkey,
1181
+ lamports: 13e5,
1182
+ space: 58,
1183
+ programId: lavarageProgram.programId
1184
+ }));
1185
+ instructions.push(yield lavarageProgram.methods.lpOperatorCreateNodeWallet().accounts({
1186
+ nodeWallet: auxAccountPubkey,
1171
1187
  operator: new import_web3.PublicKey(params.operator),
1172
1188
  systemProgram: import_web3.SystemProgram.programId
1173
- }).instruction();
1189
+ }).instruction());
1174
1190
  }
1175
1191
  return {
1176
- instruction,
1192
+ instructions,
1177
1193
  nodeWallet: nodeWallet instanceof import_web3.Keypair ? nodeWallet : void 0,
1178
1194
  nodeWalletAccount: nodeWallet instanceof import_web3.Keypair ? nodeWallet.publicKey : nodeWallet
1179
1195
  };
@@ -1323,7 +1339,7 @@ function withdrawFunds(lavarageProgram, params) {
1323
1339
  function createOffer(lavarageProgram, params) {
1324
1340
  return __async(this, null, function* () {
1325
1341
  var _a;
1326
- let nodeWalletAccount, nodeWalletSigner, createNodeWalletInstruction, nodeWalletPubKey;
1342
+ let nodeWalletAccount, nodeWalletSigner, createNodeWalletInstruction = [], nodeWalletPubKey;
1327
1343
  if (params.quoteMint === "So11111111111111111111111111111111111111112") {
1328
1344
  const nodeWallets = yield lavarageProgram.account.nodeWallet.all();
1329
1345
  nodeWalletAccount = nodeWallets.find(
@@ -1345,7 +1361,7 @@ function createOffer(lavarageProgram, params) {
1345
1361
  if (!(nodeWalletAccount == null ? void 0 : nodeWalletAccount.account)) {
1346
1362
  const isSOL = params.quoteMint === "So11111111111111111111111111111111111111112";
1347
1363
  const {
1348
- instruction: instruction2,
1364
+ instructions,
1349
1365
  nodeWallet,
1350
1366
  nodeWalletAccount: nodeWalletPublicKey
1351
1367
  } = yield createNodeWallet(lavarageProgram, {
@@ -1356,7 +1372,7 @@ function createOffer(lavarageProgram, params) {
1356
1372
  // Only pass liquidationLtv for V2 (non-SOL)
1357
1373
  });
1358
1374
  nodeWalletSigner = nodeWallet;
1359
- createNodeWalletInstruction = instruction2;
1375
+ createNodeWalletInstruction = instructions;
1360
1376
  nodeWalletPubKey = nodeWalletPublicKey;
1361
1377
  } else {
1362
1378
  nodeWalletPubKey = nodeWalletAccount.publicKey;
@@ -1388,18 +1404,13 @@ function createOffer(lavarageProgram, params) {
1388
1404
  payerKey: lavarageProgram.provider.publicKey,
1389
1405
  recentBlockhash: blockhash,
1390
1406
  instructions: [
1391
- createNodeWalletInstruction === void 0 ? null : createNodeWalletInstruction,
1407
+ ...createNodeWalletInstruction,
1392
1408
  instruction,
1393
1409
  updateMaxExposureInstruction,
1394
1410
  transferInstruction,
1395
1411
  computeFeeIx
1396
1412
  ].filter(Boolean)
1397
1413
  }).compileToV0Message();
1398
- if (nodeWalletSigner) {
1399
- const transaction = new import_web3.VersionedTransaction(messageV0);
1400
- transaction.sign([nodeWalletSigner]);
1401
- return transaction;
1402
- }
1403
1414
  return new import_web3.VersionedTransaction(messageV0);
1404
1415
  });
1405
1416
  }