@lavarage/sdk 6.8.7 → 6.8.9
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/abi/borrowerOperations.ts +1 -1
- package/dist/index.d.mts +10 -2
- package/dist/index.d.ts +10 -2
- package/dist/index.js +55 -24
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +55 -24
- package/dist/index.mjs.map +1 -1
- package/evm.ts +2 -2
- package/index.ts +6 -4
- package/lending.ts +49 -11
- package/package.json +1 -1
package/evm.ts
CHANGED
|
@@ -198,7 +198,7 @@ export async function getClosedPositionsEvm(
|
|
|
198
198
|
|
|
199
199
|
return Promise.all(
|
|
200
200
|
allEvents.map(async (event: any) => {
|
|
201
|
-
const { buyer, tokenCollateral, loanId, closingPositionSize, profit } =
|
|
201
|
+
const { buyer, tokenHolder, tokenCollateral, loanId, closingPositionSize, profit } =
|
|
202
202
|
event.args as unknown as any;
|
|
203
203
|
|
|
204
204
|
const block = await provider.getBlock(event.blockNumber);
|
|
@@ -206,7 +206,7 @@ export async function getClosedPositionsEvm(
|
|
|
206
206
|
|
|
207
207
|
return {
|
|
208
208
|
trader: buyer,
|
|
209
|
-
tokenCollateral,
|
|
209
|
+
tokenCollateral: tokenHolder,
|
|
210
210
|
loanId,
|
|
211
211
|
closingPositionSize,
|
|
212
212
|
profit,
|
package/index.ts
CHANGED
|
@@ -1443,7 +1443,8 @@ export const splitPositionV2 = async (
|
|
|
1443
1443
|
collateralType: PublicKey;
|
|
1444
1444
|
}>,
|
|
1445
1445
|
quoteToken: PublicKey,
|
|
1446
|
-
propotionBps: number
|
|
1446
|
+
propotionBps: number,
|
|
1447
|
+
computeBudgetMicroLamports?: number
|
|
1447
1448
|
) => {
|
|
1448
1449
|
const positionAccountPDA = position.publicKey;
|
|
1449
1450
|
|
|
@@ -1523,7 +1524,7 @@ export const splitPositionV2 = async (
|
|
|
1523
1524
|
.instruction();
|
|
1524
1525
|
|
|
1525
1526
|
const computeBudgetIx = ComputeBudgetProgram.setComputeUnitPrice({
|
|
1526
|
-
microLamports: 100000,
|
|
1527
|
+
microLamports: computeBudgetMicroLamports ?? 100000,
|
|
1527
1528
|
});
|
|
1528
1529
|
|
|
1529
1530
|
const allInstructions = [
|
|
@@ -1566,7 +1567,8 @@ export const mergePositionV2 = async (
|
|
|
1566
1567
|
interestRate: number;
|
|
1567
1568
|
collateralType: PublicKey;
|
|
1568
1569
|
}>,
|
|
1569
|
-
quoteToken: PublicKey
|
|
1570
|
+
quoteToken: PublicKey,
|
|
1571
|
+
computeBudgetMicroLamports?: number
|
|
1570
1572
|
) => {
|
|
1571
1573
|
const positionAccountPDA1 = position1.publicKey;
|
|
1572
1574
|
const positionAccountPDA2 = position2.publicKey;
|
|
@@ -1627,7 +1629,7 @@ export const mergePositionV2 = async (
|
|
|
1627
1629
|
.instruction();
|
|
1628
1630
|
|
|
1629
1631
|
const computeBudgetIx = ComputeBudgetProgram.setComputeUnitPrice({
|
|
1630
|
-
microLamports: 100000,
|
|
1632
|
+
microLamports: computeBudgetMicroLamports ?? 100000,
|
|
1631
1633
|
});
|
|
1632
1634
|
|
|
1633
1635
|
const allInstructions = [
|
package/lending.ts
CHANGED
|
@@ -48,10 +48,6 @@ export function getTradingPoolPDA(
|
|
|
48
48
|
);
|
|
49
49
|
}
|
|
50
50
|
|
|
51
|
-
const computeFeeIx = ComputeBudgetProgram.setComputeUnitPrice({
|
|
52
|
-
microLamports: 150000,
|
|
53
|
-
});
|
|
54
|
-
|
|
55
51
|
async function createNodeWallet(
|
|
56
52
|
lavarageProgram: Program<Lavarage> | Program<LavarageV2>,
|
|
57
53
|
params: {
|
|
@@ -114,6 +110,7 @@ export async function depositFunds(
|
|
|
114
110
|
mint?: string; // Required for V2, optional for V1
|
|
115
111
|
funder: PublicKey;
|
|
116
112
|
amount: number;
|
|
113
|
+
computeBudgetMicroLamports?: number;
|
|
117
114
|
}
|
|
118
115
|
): Promise<VersionedTransaction> {
|
|
119
116
|
const { blockhash } =
|
|
@@ -121,6 +118,9 @@ export async function depositFunds(
|
|
|
121
118
|
|
|
122
119
|
let instruction;
|
|
123
120
|
if (params.mint === undefined) {
|
|
121
|
+
const computeFeeIx = ComputeBudgetProgram.setComputeUnitPrice({
|
|
122
|
+
microLamports: params.computeBudgetMicroLamports ?? 150000,
|
|
123
|
+
});
|
|
124
124
|
instruction = await lavarageProgram.methods
|
|
125
125
|
.lpOperatorFundNodeWallet(new BN(params.amount))
|
|
126
126
|
.accounts({
|
|
@@ -140,6 +140,9 @@ export async function depositFunds(
|
|
|
140
140
|
"confirmed",
|
|
141
141
|
mintOwner?.owner
|
|
142
142
|
);
|
|
143
|
+
const computeFeeIx = ComputeBudgetProgram.setComputeUnitPrice({
|
|
144
|
+
microLamports: params.computeBudgetMicroLamports ?? 150000,
|
|
145
|
+
});
|
|
143
146
|
instruction = createTransferCheckedInstruction(
|
|
144
147
|
getAssociatedTokenAddressSync(
|
|
145
148
|
mintPubkey,
|
|
@@ -162,6 +165,10 @@ export async function depositFunds(
|
|
|
162
165
|
);
|
|
163
166
|
}
|
|
164
167
|
|
|
168
|
+
const computeFeeIx = ComputeBudgetProgram.setComputeUnitPrice({
|
|
169
|
+
microLamports: params.computeBudgetMicroLamports ?? 150000,
|
|
170
|
+
});
|
|
171
|
+
|
|
165
172
|
const messageV0 = new TransactionMessage({
|
|
166
173
|
payerKey: lavarageProgram.provider.publicKey!,
|
|
167
174
|
recentBlockhash: blockhash,
|
|
@@ -177,6 +184,7 @@ export async function withdrawFundsV1(
|
|
|
177
184
|
nodeWallet: PublicKey;
|
|
178
185
|
funder: PublicKey;
|
|
179
186
|
amount: number;
|
|
187
|
+
computeBudgetMicroLamports?: number;
|
|
180
188
|
}
|
|
181
189
|
): Promise<VersionedTransaction> {
|
|
182
190
|
const { blockhash } =
|
|
@@ -191,6 +199,10 @@ export async function withdrawFundsV1(
|
|
|
191
199
|
})
|
|
192
200
|
.instruction();
|
|
193
201
|
|
|
202
|
+
const computeFeeIx = ComputeBudgetProgram.setComputeUnitPrice({
|
|
203
|
+
microLamports: params.computeBudgetMicroLamports ?? 150000,
|
|
204
|
+
});
|
|
205
|
+
|
|
194
206
|
const messageV0 = new TransactionMessage({
|
|
195
207
|
payerKey: lavarageProgram.provider.publicKey!,
|
|
196
208
|
recentBlockhash: blockhash,
|
|
@@ -209,6 +221,7 @@ export async function withdrawFundsV2(
|
|
|
209
221
|
amount: number;
|
|
210
222
|
fromTokenAccount?: PublicKey; // Optional, will be derived if not provided
|
|
211
223
|
toTokenAccount?: PublicKey; // Optional, will be derived if not provided
|
|
224
|
+
computeBudgetMicroLamports?: number;
|
|
212
225
|
}
|
|
213
226
|
): Promise<VersionedTransaction> {
|
|
214
227
|
const { blockhash } =
|
|
@@ -237,6 +250,10 @@ export async function withdrawFundsV2(
|
|
|
237
250
|
})
|
|
238
251
|
.instruction();
|
|
239
252
|
|
|
253
|
+
const computeFeeIx = ComputeBudgetProgram.setComputeUnitPrice({
|
|
254
|
+
microLamports: params.computeBudgetMicroLamports ?? 150000,
|
|
255
|
+
});
|
|
256
|
+
|
|
240
257
|
const messageV0 = new TransactionMessage({
|
|
241
258
|
payerKey: lavarageProgram.provider.publicKey!,
|
|
242
259
|
recentBlockhash: blockhash,
|
|
@@ -256,6 +273,7 @@ export async function withdrawFunds(
|
|
|
256
273
|
mint?: string; // Required for V2, optional for V1
|
|
257
274
|
fromTokenAccount?: PublicKey; // Only used for V2
|
|
258
275
|
toTokenAccount?: PublicKey; // Only used for V2
|
|
276
|
+
computeBudgetMicroLamports?: number;
|
|
259
277
|
}
|
|
260
278
|
): Promise<VersionedTransaction> {
|
|
261
279
|
// Check if mint is provided to determine if this is V2
|
|
@@ -267,12 +285,14 @@ export async function withdrawFunds(
|
|
|
267
285
|
amount: params.amount,
|
|
268
286
|
fromTokenAccount: params.fromTokenAccount,
|
|
269
287
|
toTokenAccount: params.toTokenAccount,
|
|
288
|
+
computeBudgetMicroLamports: params.computeBudgetMicroLamports,
|
|
270
289
|
});
|
|
271
290
|
} else {
|
|
272
291
|
return withdrawFundsV1(lavarageProgram as Program<Lavarage>, {
|
|
273
292
|
nodeWallet: params.nodeWallet,
|
|
274
293
|
funder: params.funder,
|
|
275
294
|
amount: params.amount,
|
|
295
|
+
computeBudgetMicroLamports: params.computeBudgetMicroLamports,
|
|
276
296
|
});
|
|
277
297
|
}
|
|
278
298
|
}
|
|
@@ -288,6 +308,7 @@ export async function createOffer(
|
|
|
288
308
|
quoteMint: string;
|
|
289
309
|
interestRate: number;
|
|
290
310
|
maxExposure: number;
|
|
311
|
+
computeBudgetMicroLamports?: number;
|
|
291
312
|
}
|
|
292
313
|
): Promise<VersionedTransaction> {
|
|
293
314
|
|
|
@@ -357,6 +378,10 @@ export async function createOffer(
|
|
|
357
378
|
})
|
|
358
379
|
.instruction();
|
|
359
380
|
|
|
381
|
+
const computeFeeIx = ComputeBudgetProgram.setComputeUnitPrice({
|
|
382
|
+
microLamports: params.computeBudgetMicroLamports ?? 150000,
|
|
383
|
+
});
|
|
384
|
+
|
|
360
385
|
const messageV0 = new TransactionMessage({
|
|
361
386
|
payerKey: lavarageProgram.provider.publicKey!,
|
|
362
387
|
recentBlockhash: blockhash,
|
|
@@ -372,10 +397,7 @@ export async function createOffer(
|
|
|
372
397
|
|
|
373
398
|
if (nodeWalletSigner) {
|
|
374
399
|
const transaction = new VersionedTransaction(messageV0);
|
|
375
|
-
transaction.
|
|
376
|
-
nodeWalletSigner.publicKey,
|
|
377
|
-
nodeWalletSigner.secretKey
|
|
378
|
-
);
|
|
400
|
+
transaction.sign([nodeWalletSigner]);
|
|
379
401
|
return transaction;
|
|
380
402
|
}
|
|
381
403
|
|
|
@@ -389,6 +411,7 @@ export async function updateMaxExposure(
|
|
|
389
411
|
nodeWallet: string;
|
|
390
412
|
poolOwner: PublicKey;
|
|
391
413
|
maxExposure: number;
|
|
414
|
+
computeBudgetMicroLamports?: number;
|
|
392
415
|
}
|
|
393
416
|
): Promise<VersionedTransaction> {
|
|
394
417
|
const { blockhash } =
|
|
@@ -404,10 +427,14 @@ export async function updateMaxExposure(
|
|
|
404
427
|
})
|
|
405
428
|
.instruction();
|
|
406
429
|
|
|
430
|
+
const computeFeeIx = ComputeBudgetProgram.setComputeUnitPrice({
|
|
431
|
+
microLamports: params.computeBudgetMicroLamports ?? 150000,
|
|
432
|
+
});
|
|
433
|
+
|
|
407
434
|
const messageV0 = new TransactionMessage({
|
|
408
435
|
payerKey: lavarageProgram.provider.publicKey!,
|
|
409
436
|
recentBlockhash: blockhash,
|
|
410
|
-
instructions: [instruction],
|
|
437
|
+
instructions: [instruction, computeFeeIx],
|
|
411
438
|
}).compileToV0Message();
|
|
412
439
|
|
|
413
440
|
return new VersionedTransaction(messageV0);
|
|
@@ -420,6 +447,7 @@ export async function updateInterestRate(
|
|
|
420
447
|
nodeWallet: string;
|
|
421
448
|
poolOwner: PublicKey;
|
|
422
449
|
interestRate: number;
|
|
450
|
+
computeBudgetMicroLamports?: number;
|
|
423
451
|
}
|
|
424
452
|
): Promise<VersionedTransaction> {
|
|
425
453
|
const { blockhash } =
|
|
@@ -435,10 +463,14 @@ export async function updateInterestRate(
|
|
|
435
463
|
})
|
|
436
464
|
.instruction();
|
|
437
465
|
|
|
466
|
+
const computeFeeIx = ComputeBudgetProgram.setComputeUnitPrice({
|
|
467
|
+
microLamports: params.computeBudgetMicroLamports ?? 150000,
|
|
468
|
+
});
|
|
469
|
+
|
|
438
470
|
const messageV0 = new TransactionMessage({
|
|
439
471
|
payerKey: lavarageProgram.provider.publicKey!,
|
|
440
472
|
recentBlockhash: blockhash,
|
|
441
|
-
instructions: [instruction],
|
|
473
|
+
instructions: [instruction, computeFeeIx],
|
|
442
474
|
}).compileToV0Message();
|
|
443
475
|
|
|
444
476
|
return new VersionedTransaction(messageV0);
|
|
@@ -453,6 +485,7 @@ export async function updateOffer(
|
|
|
453
485
|
mint: string;
|
|
454
486
|
interestRate: number;
|
|
455
487
|
maxExposure: number;
|
|
488
|
+
computeBudgetMicroLamports?: number;
|
|
456
489
|
//includeCreatePool?: boolean; // Optional flag to include pool creation
|
|
457
490
|
}
|
|
458
491
|
): Promise<VersionedTransaction> {
|
|
@@ -499,9 +532,14 @@ export async function updateOffer(
|
|
|
499
532
|
})
|
|
500
533
|
.instruction();
|
|
501
534
|
|
|
535
|
+
const computeFeeIx = ComputeBudgetProgram.setComputeUnitPrice({
|
|
536
|
+
microLamports: params.computeBudgetMicroLamports ?? 150000,
|
|
537
|
+
});
|
|
538
|
+
|
|
502
539
|
instructions.push(
|
|
503
540
|
updateMaxExposureInstruction,
|
|
504
|
-
updateInterestRateInstruction
|
|
541
|
+
updateInterestRateInstruction,
|
|
542
|
+
computeFeeIx
|
|
505
543
|
);
|
|
506
544
|
|
|
507
545
|
const messageV0 = new TransactionMessage({
|