flash-sdk 2.0.66 → 2.0.67

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.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/readme.md +38 -5
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "flash-sdk",
3
- "version": "2.0.66",
3
+ "version": "2.0.67",
4
4
  "main": "dist/index.js",
5
5
  "types": "dist/index.d.ts",
6
6
  "files": [
package/readme.md CHANGED
@@ -9,7 +9,7 @@ npm i flash-sdk / yarn add flash-sdk
9
9
  ## Using the SDK
10
10
 
11
11
  ### connect sdk locally
12
- `
12
+ ```
13
13
  import { AnchorProvider } from "@coral-xyz/anchor";
14
14
 
15
15
  const provider : AnchorProvider = AnchorProvider.local(clusterUrl, {
@@ -17,9 +17,42 @@ npm i flash-sdk / yarn add flash-sdk
17
17
  preflightCommitment: "confirmed",
18
18
  skipPreflight: true
19
19
  });
20
- client = new PerpetualsClient(provider, programId);
21
-
22
- `
20
+ const perpClient = new PerpetualsClient(provider, programId);
21
+
22
+ const POOL_CONFIG = PoolConfig.fromIdsByName('Crypto.1','mainnet-beta')
23
+
24
+ <!-- load ALT -->
25
+ await perpClient.loadAddressLookupTable(POOL_CONFIG)
26
+
27
+
28
+ <!-- to STAKE FLP.1 -->
29
+ const { instructions: depositStakeInstructions, additionalSigners: depositStakeAdditionalSigners } =
30
+ await perpClient.depositStake(.provider.wallet.publicKey, provider.wallet.publicKey, flpDepositAmount, POOL_CONFIG)
31
+
32
+ const txid = perpClient.sendTransaction([...depositStakeInstructions ], {
33
+ depositStakeAdditionalSigners,
34
+ alts: perpClient.addressLookupTables,
35
+ })
36
+
37
+ <!-- to UN-STAKE FLP.1 -->
23
38
 
39
+ const { instructions: unstakeInstantInstructions, additionalSigners : unstakeInstantAdditionalSigners } = await perpClient.unstakeInstant('USDC',flpUnstakeAmount,POOL_CONFIG)
24
40
 
25
- ### To fetch all the pool data
41
+ const { instructions: withdrawStakeInstructions } = await perpClient.withdrawStake(POOL_CONFIG, false)
42
+
43
+ const txid = perpClient.sendTransaction([...unstakeInstantInstructions, ...withdrawStakeInstructions ], {
44
+ unstakeInstantAdditionalSigners,
45
+ alts: perpClient.addressLookupTables,
46
+ })
47
+
48
+ <!-- collect fees -->
49
+
50
+ const { instructions, additionalSigners } = await perpClient.collectStakeFees('USDC',POOL_CONFIG)
51
+
52
+ const txid = perpClient.sendTransaction([...instructions ], {
53
+ additionalSigners,
54
+ alts: perpClient.addressLookupTables,
55
+ })
56
+
57
+
58
+ ```