@drift-labs/sdk 2.31.1-beta.9 → 2.32.0
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/VERSION +1 -1
- package/lib/constants/perpMarkets.js +20 -0
- package/lib/dlob/orderBookLevels.js +2 -2
- package/lib/driftClient.d.ts +51 -4
- package/lib/driftClient.js +195 -194
- package/lib/idl/drift.json +31 -1
- package/lib/index.d.ts +3 -0
- package/lib/index.js +3 -0
- package/lib/marinade/index.d.ts +11 -0
- package/lib/marinade/index.js +36 -0
- package/lib/marinade/types.d.ts +1963 -0
- package/lib/marinade/types.js +1965 -0
- package/lib/math/spotBalance.d.ts +9 -2
- package/lib/math/spotBalance.js +54 -6
- package/lib/math/superStake.d.ts +22 -0
- package/lib/math/superStake.js +108 -0
- package/lib/math/utils.d.ts +1 -0
- package/lib/math/utils.js +5 -1
- package/lib/orderParams.d.ts +18 -5
- package/lib/orderParams.js +17 -1
- package/lib/user.d.ts +45 -1
- package/lib/user.js +227 -9
- package/package.json +1 -1
- package/src/assert/assert.js +9 -0
- package/src/constants/perpMarkets.ts +20 -0
- package/src/dlob/orderBookLevels.ts +3 -2
- package/src/driftClient.ts +373 -223
- package/src/idl/drift.json +31 -1
- package/src/index.ts +3 -0
- package/src/marinade/idl/idl.json +1962 -0
- package/src/marinade/index.ts +64 -0
- package/src/marinade/types.ts +3925 -0
- package/src/math/spotBalance.ts +83 -5
- package/src/math/superStake.ts +148 -0
- package/src/math/utils.ts +4 -0
- package/src/orderParams.ts +35 -5
- package/src/token/index.js +38 -0
- package/src/user.ts +453 -15
- package/src/util/computeUnits.js +27 -0
- package/src/util/promiseTimeout.js +14 -0
- package/src/util/tps.js +27 -0
- package/tests/spot/test.ts +156 -0
|
@@ -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
|
+
}
|