@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.mjs CHANGED
@@ -1120,29 +1120,45 @@ function getWithdrawalAccessListPDA(programId) {
1120
1120
  function createNodeWallet(lavarageProgram, params) {
1121
1121
  return __async(this, null, function* () {
1122
1122
  const { blockhash } = yield lavarageProgram.provider.connection.getLatestBlockhash("finalized");
1123
- let instruction, nodeWallet;
1123
+ let instructions = [];
1124
+ let nodeWallet;
1124
1125
  if (params.mint !== void 0 && params.liquidationLtv !== void 0) {
1125
1126
  nodeWallet = getNodeWalletPDA(
1126
1127
  new PublicKey(params.operator),
1127
1128
  new PublicKey(params.mint),
1128
1129
  lavarageProgram.programId
1129
1130
  );
1130
- instruction = yield lavarageProgram.methods.lpOperatorCreateNodeWallet(new BN(params.liquidationLtv)).accounts({
1131
+ instructions.push(yield lavarageProgram.methods.lpOperatorCreateNodeWallet(new BN(params.liquidationLtv)).accounts({
1131
1132
  nodeWallet,
1132
1133
  operator: new PublicKey(params.operator),
1133
1134
  systemProgram: SystemProgram.programId,
1134
1135
  mint: new PublicKey(params.mint)
1135
- }).instruction();
1136
+ }).instruction());
1136
1137
  } else {
1137
- nodeWallet = Keypair.generate();
1138
- instruction = yield lavarageProgram.methods.lpOperatorCreateNodeWallet().accounts({
1139
- nodeWallet: nodeWallet.publicKey,
1138
+ const seed = params.operator.toBase58().slice(0, 32);
1139
+ const auxAccountPubkey = yield PublicKey.createWithSeed(
1140
+ params.operator,
1141
+ seed,
1142
+ lavarageProgram.programId
1143
+ );
1144
+ nodeWallet = auxAccountPubkey;
1145
+ instructions.push(SystemProgram.createAccountWithSeed({
1146
+ fromPubkey: params.operator,
1147
+ basePubkey: params.operator,
1148
+ seed,
1149
+ newAccountPubkey: auxAccountPubkey,
1150
+ lamports: 13e5,
1151
+ space: 58,
1152
+ programId: lavarageProgram.programId
1153
+ }));
1154
+ instructions.push(yield lavarageProgram.methods.lpOperatorCreateNodeWallet().accounts({
1155
+ nodeWallet: auxAccountPubkey,
1140
1156
  operator: new PublicKey(params.operator),
1141
1157
  systemProgram: SystemProgram.programId
1142
- }).instruction();
1158
+ }).instruction());
1143
1159
  }
1144
1160
  return {
1145
- instruction,
1161
+ instructions,
1146
1162
  nodeWallet: nodeWallet instanceof Keypair ? nodeWallet : void 0,
1147
1163
  nodeWalletAccount: nodeWallet instanceof Keypair ? nodeWallet.publicKey : nodeWallet
1148
1164
  };
@@ -1292,7 +1308,7 @@ function withdrawFunds(lavarageProgram, params) {
1292
1308
  function createOffer(lavarageProgram, params) {
1293
1309
  return __async(this, null, function* () {
1294
1310
  var _a;
1295
- let nodeWalletAccount, nodeWalletSigner, createNodeWalletInstruction, nodeWalletPubKey;
1311
+ let nodeWalletAccount, nodeWalletSigner, createNodeWalletInstruction = [], nodeWalletPubKey;
1296
1312
  if (params.quoteMint === "So11111111111111111111111111111111111111112") {
1297
1313
  const nodeWallets = yield lavarageProgram.account.nodeWallet.all();
1298
1314
  nodeWalletAccount = nodeWallets.find(
@@ -1314,7 +1330,7 @@ function createOffer(lavarageProgram, params) {
1314
1330
  if (!(nodeWalletAccount == null ? void 0 : nodeWalletAccount.account)) {
1315
1331
  const isSOL = params.quoteMint === "So11111111111111111111111111111111111111112";
1316
1332
  const {
1317
- instruction: instruction2,
1333
+ instructions,
1318
1334
  nodeWallet,
1319
1335
  nodeWalletAccount: nodeWalletPublicKey
1320
1336
  } = yield createNodeWallet(lavarageProgram, {
@@ -1325,7 +1341,7 @@ function createOffer(lavarageProgram, params) {
1325
1341
  // Only pass liquidationLtv for V2 (non-SOL)
1326
1342
  });
1327
1343
  nodeWalletSigner = nodeWallet;
1328
- createNodeWalletInstruction = instruction2;
1344
+ createNodeWalletInstruction = instructions;
1329
1345
  nodeWalletPubKey = nodeWalletPublicKey;
1330
1346
  } else {
1331
1347
  nodeWalletPubKey = nodeWalletAccount.publicKey;
@@ -1357,18 +1373,13 @@ function createOffer(lavarageProgram, params) {
1357
1373
  payerKey: lavarageProgram.provider.publicKey,
1358
1374
  recentBlockhash: blockhash,
1359
1375
  instructions: [
1360
- createNodeWalletInstruction === void 0 ? null : createNodeWalletInstruction,
1376
+ ...createNodeWalletInstruction,
1361
1377
  instruction,
1362
1378
  updateMaxExposureInstruction,
1363
1379
  transferInstruction,
1364
1380
  computeFeeIx
1365
1381
  ].filter(Boolean)
1366
1382
  }).compileToV0Message();
1367
- if (nodeWalletSigner) {
1368
- const transaction = new VersionedTransaction(messageV0);
1369
- transaction.sign([nodeWalletSigner]);
1370
- return transaction;
1371
- }
1372
1383
  return new VersionedTransaction(messageV0);
1373
1384
  });
1374
1385
  }