@lavarage/sdk 6.8.3 → 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 +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +66 -15
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +66 -15
- package/dist/index.mjs.map +1 -1
- package/lending.ts +84 -26
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -2884,8 +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
|
-
|
|
2888
|
-
|
|
2887
|
+
mint: string;
|
|
2888
|
+
quoteMint: string;
|
|
2889
2889
|
interestRate: number;
|
|
2890
2890
|
maxExposure: number;
|
|
2891
2891
|
}): Promise<VersionedTransaction>;
|
package/dist/index.d.ts
CHANGED
|
@@ -2884,8 +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
|
-
|
|
2888
|
-
|
|
2887
|
+
mint: string;
|
|
2888
|
+
quoteMint: string;
|
|
2889
2889
|
interestRate: number;
|
|
2890
2890
|
maxExposure: number;
|
|
2891
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),
|
|
@@ -1164,7 +1164,8 @@ function createNodeWallet(lavarageProgram, params) {
|
|
|
1164
1164
|
}
|
|
1165
1165
|
return {
|
|
1166
1166
|
instruction,
|
|
1167
|
-
nodeWallet: nodeWallet instanceof import_web3.Keypair ? nodeWallet : void 0
|
|
1167
|
+
nodeWallet: nodeWallet instanceof import_web3.Keypair ? nodeWallet : void 0,
|
|
1168
|
+
nodeWalletAccount: nodeWallet instanceof import_web3.Keypair ? nodeWallet.publicKey : nodeWallet
|
|
1168
1169
|
};
|
|
1169
1170
|
});
|
|
1170
1171
|
}
|
|
@@ -1180,12 +1181,29 @@ function depositFunds(lavarageProgram, params) {
|
|
|
1180
1181
|
}).instruction();
|
|
1181
1182
|
} else {
|
|
1182
1183
|
const mintPubkey = new import_web3.PublicKey(params.mint);
|
|
1183
|
-
const mintOwner = yield lavarageProgram.provider.connection.getAccountInfo(
|
|
1184
|
-
|
|
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
|
+
);
|
|
1185
1193
|
instruction = (0, import_spl_token.createTransferCheckedInstruction)(
|
|
1186
|
-
(0, import_spl_token.getAssociatedTokenAddressSync)(
|
|
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
|
+
),
|
|
1187
1200
|
new import_web3.PublicKey(params.mint),
|
|
1188
|
-
(0, import_spl_token.getAssociatedTokenAddressSync)(
|
|
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
|
+
),
|
|
1189
1207
|
lavarageProgram.provider.publicKey,
|
|
1190
1208
|
params.amount,
|
|
1191
1209
|
mintAccount.decimals,
|
|
@@ -1262,35 +1280,68 @@ function withdrawFunds(lavarageProgram, params) {
|
|
|
1262
1280
|
}
|
|
1263
1281
|
function createOffer(lavarageProgram, params) {
|
|
1264
1282
|
return __async(this, null, function* () {
|
|
1265
|
-
|
|
1266
|
-
|
|
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
|
+
}
|
|
1267
1302
|
if (!nodeWalletAccount) {
|
|
1268
|
-
const
|
|
1303
|
+
const isSOL = params.quoteMint === "So11111111111111111111111111111111111111112";
|
|
1304
|
+
const {
|
|
1305
|
+
instruction: instruction2,
|
|
1306
|
+
nodeWallet,
|
|
1307
|
+
nodeWalletAccount: nodeWalletPublicKey
|
|
1308
|
+
} = yield createNodeWallet(lavarageProgram, {
|
|
1269
1309
|
operator: new import_web3.PublicKey(params.poolOwner.toBase58()),
|
|
1270
|
-
mint: params.
|
|
1271
|
-
|
|
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)
|
|
1272
1314
|
});
|
|
1273
1315
|
nodeWalletSigner = nodeWallet;
|
|
1274
1316
|
createNodeWalletInstruction = instruction2;
|
|
1317
|
+
nodeWalletPubKey = nodeWalletPublicKey;
|
|
1318
|
+
} else {
|
|
1319
|
+
nodeWalletPubKey = nodeWalletAccount.publicKey;
|
|
1275
1320
|
}
|
|
1276
1321
|
const { blockhash } = yield lavarageProgram.provider.connection.getLatestBlockhash("finalized");
|
|
1277
1322
|
const instruction = yield lavarageProgram.methods.lpOperatorCreateTradingPool(new import_anchor.BN(params.interestRate)).accounts({
|
|
1278
1323
|
tradingPool: params.tradingPool,
|
|
1279
1324
|
operator: params.poolOwner,
|
|
1280
|
-
nodeWallet:
|
|
1281
|
-
mint:
|
|
1325
|
+
nodeWallet: nodeWalletPubKey,
|
|
1326
|
+
mint: new import_web3.PublicKey(params.mint),
|
|
1327
|
+
// Always required for both V1 and V2
|
|
1282
1328
|
systemProgram: import_web3.SystemProgram.programId
|
|
1283
1329
|
}).instruction();
|
|
1284
1330
|
const updateMaxExposureInstruction = yield lavarageProgram.methods.lpOperatorUpdateMaxExposure(new import_anchor.BN(params.maxExposure)).accounts({
|
|
1285
1331
|
tradingPool: params.tradingPool,
|
|
1286
|
-
nodeWallet:
|
|
1332
|
+
nodeWallet: nodeWalletPubKey,
|
|
1287
1333
|
operator: params.poolOwner,
|
|
1288
1334
|
systemProgram: import_web3.SystemProgram.programId
|
|
1289
1335
|
}).instruction();
|
|
1290
1336
|
const messageV0 = new import_web3.TransactionMessage({
|
|
1291
1337
|
payerKey: lavarageProgram.provider.publicKey,
|
|
1292
1338
|
recentBlockhash: blockhash,
|
|
1293
|
-
instructions: [
|
|
1339
|
+
instructions: [
|
|
1340
|
+
createNodeWalletInstruction === void 0 ? null : createNodeWalletInstruction,
|
|
1341
|
+
instruction,
|
|
1342
|
+
updateMaxExposureInstruction,
|
|
1343
|
+
computeFeeIx
|
|
1344
|
+
].filter(Boolean)
|
|
1294
1345
|
}).compileToV0Message();
|
|
1295
1346
|
if (nodeWalletSigner) {
|
|
1296
1347
|
const transaction = new import_web3.VersionedTransaction(messageV0);
|