@lavarage/sdk 6.8.4 → 6.8.5

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
@@ -2884,7 +2884,8 @@ declare function withdrawFunds(lavarageProgram: Program<Lavarage$1> | Program<La
2884
2884
  declare function createOffer(lavarageProgram: Program<Lavarage$1> | Program<Lavarage>, params: {
2885
2885
  tradingPool: PublicKey;
2886
2886
  poolOwner: PublicKey;
2887
- mint?: string;
2887
+ mint: string;
2888
+ quoteMint: string;
2888
2889
  interestRate: number;
2889
2890
  maxExposure: number;
2890
2891
  }): Promise<VersionedTransaction>;
package/dist/index.d.ts CHANGED
@@ -2884,7 +2884,8 @@ declare function withdrawFunds(lavarageProgram: Program<Lavarage$1> | Program<La
2884
2884
  declare function createOffer(lavarageProgram: Program<Lavarage$1> | Program<Lavarage>, params: {
2885
2885
  tradingPool: PublicKey;
2886
2886
  poolOwner: PublicKey;
2887
- mint?: string;
2887
+ mint: string;
2888
+ quoteMint: string;
2888
2889
  interestRate: number;
2889
2890
  maxExposure: number;
2890
2891
  }): Promise<VersionedTransaction>;
package/dist/index.js CHANGED
@@ -1142,7 +1142,7 @@ function createNodeWallet(lavarageProgram, params) {
1142
1142
  return __async(this, null, function* () {
1143
1143
  const { blockhash } = yield lavarageProgram.provider.connection.getLatestBlockhash("finalized");
1144
1144
  let instruction, nodeWallet;
1145
- if (params.mint !== void 0) {
1145
+ if (params.mint !== void 0 && params.liquidationLtv !== void 0) {
1146
1146
  nodeWallet = getNodeWalletPDA(
1147
1147
  new import_web3.PublicKey(params.operator),
1148
1148
  new import_web3.PublicKey(params.mint),
@@ -1181,12 +1181,29 @@ function depositFunds(lavarageProgram, params) {
1181
1181
  }).instruction();
1182
1182
  } else {
1183
1183
  const mintPubkey = new import_web3.PublicKey(params.mint);
1184
- const mintOwner = yield lavarageProgram.provider.connection.getAccountInfo(mintPubkey);
1185
- const mintAccount = yield (0, import_spl_token.getMint)(lavarageProgram.provider.connection, mintPubkey, "confirmed", mintOwner == null ? void 0 : mintOwner.owner);
1184
+ const mintOwner = yield lavarageProgram.provider.connection.getAccountInfo(
1185
+ mintPubkey
1186
+ );
1187
+ const mintAccount = yield (0, import_spl_token.getMint)(
1188
+ lavarageProgram.provider.connection,
1189
+ mintPubkey,
1190
+ "confirmed",
1191
+ mintOwner == null ? void 0 : mintOwner.owner
1192
+ );
1186
1193
  instruction = (0, import_spl_token.createTransferCheckedInstruction)(
1187
- (0, import_spl_token.getAssociatedTokenAddressSync)(mintPubkey, new import_web3.PublicKey(params.funder), true, mintOwner == null ? void 0 : mintOwner.owner),
1194
+ (0, import_spl_token.getAssociatedTokenAddressSync)(
1195
+ mintPubkey,
1196
+ new import_web3.PublicKey(params.funder),
1197
+ true,
1198
+ mintOwner == null ? void 0 : mintOwner.owner
1199
+ ),
1188
1200
  new import_web3.PublicKey(params.mint),
1189
- (0, import_spl_token.getAssociatedTokenAddressSync)(mintPubkey, new import_web3.PublicKey(params.nodeWallet), true, mintOwner == null ? void 0 : mintOwner.owner),
1201
+ (0, import_spl_token.getAssociatedTokenAddressSync)(
1202
+ mintPubkey,
1203
+ new import_web3.PublicKey(params.nodeWallet),
1204
+ true,
1205
+ mintOwner == null ? void 0 : mintOwner.owner
1206
+ ),
1190
1207
  lavarageProgram.provider.publicKey,
1191
1208
  params.amount,
1192
1209
  mintAccount.decimals,
@@ -1263,14 +1280,37 @@ function withdrawFunds(lavarageProgram, params) {
1263
1280
  }
1264
1281
  function createOffer(lavarageProgram, params) {
1265
1282
  return __async(this, null, function* () {
1266
- const nodeWallets = yield lavarageProgram.account.nodeWallet.all();
1267
- const nodeWalletAccount = nodeWallets.find((wallet) => wallet.account.nodeOperator.equals(new import_web3.PublicKey(params.poolOwner)));
1268
- let nodeWalletSigner, createNodeWalletInstruction, nodeWalletPubKey;
1283
+ let nodeWalletAccount, nodeWalletSigner, createNodeWalletInstruction, nodeWalletPubKey;
1284
+ if (params.mint === "So11111111111111111111111111111111111111112") {
1285
+ const nodeWallets = yield lavarageProgram.account.nodeWallet.all();
1286
+ nodeWalletAccount = nodeWallets.find(
1287
+ (wallet) => wallet.account.nodeOperator.equals(new import_web3.PublicKey(params.poolOwner))
1288
+ );
1289
+ } else {
1290
+ const nodeWalletPda = getNodeWalletPDA(
1291
+ new import_web3.PublicKey(params.poolOwner),
1292
+ new import_web3.PublicKey(params.quoteMint),
1293
+ lavarageProgram.programId
1294
+ );
1295
+ const nodeWalletAccountInfo = yield lavarageProgram.provider.connection.getAccountInfo(nodeWalletPda);
1296
+ if (nodeWalletAccountInfo) {
1297
+ nodeWalletAccount = {
1298
+ publicKey: nodeWalletPda
1299
+ };
1300
+ }
1301
+ }
1269
1302
  if (!nodeWalletAccount) {
1270
- const { instruction: instruction2, nodeWallet, nodeWalletAccount: nodeWalletPublicKey } = yield createNodeWallet(lavarageProgram, {
1303
+ const isSOL = params.quoteMint === "So11111111111111111111111111111111111111112";
1304
+ const {
1305
+ instruction: instruction2,
1306
+ nodeWallet,
1307
+ nodeWalletAccount: nodeWalletPublicKey
1308
+ } = yield createNodeWallet(lavarageProgram, {
1271
1309
  operator: new import_web3.PublicKey(params.poolOwner.toBase58()),
1272
- mint: params.mint,
1273
- liquidationLtv: 90
1310
+ mint: isSOL ? void 0 : params.quoteMint,
1311
+ // Only pass mint for V2 (non-SOL)
1312
+ liquidationLtv: isSOL ? void 0 : 90
1313
+ // Only pass liquidationLtv for V2 (non-SOL)
1274
1314
  });
1275
1315
  nodeWalletSigner = nodeWallet;
1276
1316
  createNodeWalletInstruction = instruction2;
@@ -1283,7 +1323,8 @@ function createOffer(lavarageProgram, params) {
1283
1323
  tradingPool: params.tradingPool,
1284
1324
  operator: params.poolOwner,
1285
1325
  nodeWallet: nodeWalletPubKey,
1286
- mint: params.mint ? new import_web3.PublicKey(params.mint) : void 0,
1326
+ mint: new import_web3.PublicKey(params.mint),
1327
+ // Always required for both V1 and V2
1287
1328
  systemProgram: import_web3.SystemProgram.programId
1288
1329
  }).instruction();
1289
1330
  const updateMaxExposureInstruction = yield lavarageProgram.methods.lpOperatorUpdateMaxExposure(new import_anchor.BN(params.maxExposure)).accounts({
@@ -1295,7 +1336,12 @@ function createOffer(lavarageProgram, params) {
1295
1336
  const messageV0 = new import_web3.TransactionMessage({
1296
1337
  payerKey: lavarageProgram.provider.publicKey,
1297
1338
  recentBlockhash: blockhash,
1298
- instructions: [createNodeWalletInstruction === void 0 ? null : createNodeWalletInstruction, instruction, updateMaxExposureInstruction, computeFeeIx].filter(Boolean)
1339
+ instructions: [
1340
+ createNodeWalletInstruction === void 0 ? null : createNodeWalletInstruction,
1341
+ instruction,
1342
+ updateMaxExposureInstruction,
1343
+ computeFeeIx
1344
+ ].filter(Boolean)
1299
1345
  }).compileToV0Message();
1300
1346
  if (nodeWalletSigner) {
1301
1347
  const transaction = new import_web3.VersionedTransaction(messageV0);