@drift-labs/sdk 2.31.1-beta.10 → 2.31.1-beta.11

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.
@@ -0,0 +1,64 @@
1
+ import { AnchorProvider, BN, Program } from '@coral-xyz/anchor';
2
+ import { MarinadeFinance, IDL } from './types';
3
+ import {
4
+ PublicKey,
5
+ SystemProgram,
6
+ TransactionInstruction,
7
+ } from '@solana/web3.js';
8
+ import { TOKEN_PROGRAM_ID } from '@solana/spl-token';
9
+
10
+ const marinadeFinanceProgramId = new PublicKey(
11
+ 'MarBmsSgKXdrN1egZf5sqe1TMai9K1rChYNDJgjq7aD'
12
+ );
13
+
14
+ export function getMarinadeFinanceProgram(
15
+ provider: AnchorProvider
16
+ ): Program<MarinadeFinance> {
17
+ return new Program<MarinadeFinance>(IDL, marinadeFinanceProgramId, provider);
18
+ }
19
+
20
+ export function getMarinadeDepositIx({
21
+ program,
22
+ amount,
23
+ mSOLAccount,
24
+ transferFrom,
25
+ }: {
26
+ amount: BN;
27
+ mSOLAccount: PublicKey;
28
+ transferFrom: PublicKey;
29
+ program: Program<MarinadeFinance>;
30
+ }): Promise<TransactionInstruction> {
31
+ return program.methods
32
+ .deposit(amount)
33
+ .accountsStrict({
34
+ reservePda: new PublicKey('Du3Ysj1wKbxPKkuPPnvzQLQh8oMSVifs3jGZjJWXFmHN'),
35
+ state: new PublicKey('8szGkuLTAux9XMgZ2vtY39jVSowEcpBfFfD8hXSEqdGC'),
36
+ msolMint: new PublicKey('mSoLzYCxHdYgdzU16g5QSh3i5K3z3KZK7ytfqcJm7So'),
37
+ msolMintAuthority: new PublicKey(
38
+ '3JLPCS1qM2zRw3Dp6V4hZnYHd4toMNPkNesXdX9tg6KM'
39
+ ),
40
+ liqPoolMsolLegAuthority: new PublicKey(
41
+ 'EyaSjUtSgo9aRD1f8LWXwdvkpDTmXAW54yoSHZRF14WL'
42
+ ),
43
+ liqPoolMsolLeg: new PublicKey(
44
+ '7GgPYjS5Dza89wV6FpZ23kUJRG5vbQ1GM25ezspYFSoE'
45
+ ),
46
+ liqPoolSolLegPda: new PublicKey(
47
+ 'UefNb6z6yvArqe4cJHTXCqStRsKmWhGxnZzuHbikP5Q'
48
+ ),
49
+ mintTo: mSOLAccount,
50
+ transferFrom,
51
+ systemProgram: SystemProgram.programId,
52
+ tokenProgram: TOKEN_PROGRAM_ID,
53
+ })
54
+ .instruction();
55
+ }
56
+
57
+ export async function getMarinadeMSolPrice(
58
+ program: Program<MarinadeFinance>
59
+ ): Promise<number> {
60
+ const state = await program.account.state.fetch(
61
+ new PublicKey('8szGkuLTAux9XMgZ2vtY39jVSowEcpBfFfD8hXSEqdGC')
62
+ );
63
+ return state.msolPrice.toNumber() / 0x1_0000_0000;
64
+ }