flash-sdk 2.0.67 → 2.0.68
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/package.json +1 -1
- package/readme.md +56 -7
package/package.json
CHANGED
package/readme.md
CHANGED
@@ -11,6 +11,7 @@ npm i flash-sdk / yarn add flash-sdk
|
|
11
11
|
### connect sdk locally
|
12
12
|
```
|
13
13
|
import { AnchorProvider } from "@coral-xyz/anchor";
|
14
|
+
import { ComputeBudgetProgram } from '@solana/web3.js'
|
14
15
|
|
15
16
|
const provider : AnchorProvider = AnchorProvider.local(clusterUrl, {
|
16
17
|
commitment: "confirmed",
|
@@ -21,18 +22,64 @@ npm i flash-sdk / yarn add flash-sdk
|
|
21
22
|
|
22
23
|
const POOL_CONFIG = PoolConfig.fromIdsByName('Crypto.1','mainnet-beta')
|
23
24
|
|
24
|
-
|
25
|
+
<!-- load ALT -->
|
25
26
|
await perpClient.loadAddressLookupTable(POOL_CONFIG)
|
26
27
|
|
28
|
+
<!-- Add Liquidity -->
|
29
|
+
const payTokenSymbol = 'USDC'; // 'SOL' , 'BTC', 'ETH'
|
30
|
+
const { instructions : addLiqInstructions, additionalSigners : addLiqAdditionalSigners } = await perpClient.addLiquidity(
|
31
|
+
payTokenSymbol,
|
32
|
+
tokenAmountIn,
|
33
|
+
minLpAmountOut, // new BN(0)
|
34
|
+
POOL_CONFIG
|
35
|
+
)
|
36
|
+
const setCULimitIx = ComputeBudgetProgram.setComputeUnitLimit({ units: 600_000 })
|
37
|
+
|
38
|
+
const txid = perpClient.sendTransaction([setCULimitIx, ...addLiqInstructions ], {
|
39
|
+
addLiqAdditionalSigners,
|
40
|
+
alts: perpClient.addressLookupTables,
|
41
|
+
})
|
42
|
+
|
43
|
+
|
44
|
+
|
45
|
+
<!-- remove Liquidity -->
|
46
|
+
const recieveTokenSymbol = 'USDC'; // 'SOL' , 'BTC', 'ETH'
|
47
|
+
const { instructions : removeLiqInstructions, additionalSigners : removeLiqAdditionalSigners } = await await perpClient.removeLiquidity(
|
48
|
+
recieveTokenSymbol,
|
49
|
+
lpAmountIn,
|
50
|
+
minTokenAmountOut, // new BN(0)
|
51
|
+
POOL_CONFIG
|
52
|
+
)
|
53
|
+
const setCULimitIx = ComputeBudgetProgram.setComputeUnitLimit({ units: 600_000 })
|
54
|
+
const txid = perpClient.sendTransaction([setCULimitIx, ...removeLiqInstructions ], {
|
55
|
+
removeLiqAdditionalSigners,
|
56
|
+
alts: perpClient.addressLookupTables,
|
57
|
+
})
|
58
|
+
|
59
|
+
|
60
|
+
|
61
|
+
<!-- to STAKE FLP.1 -->
|
62
|
+
const { instructions: depositStakeInstructions, additionalSigners: depositStakeAdditionalSigners } =
|
63
|
+
await perpClient.depositStake(.provider.wallet.publicKey, provider.wallet.publicKey, flpDepositAmount, POOL_CONFIG)
|
64
|
+
|
65
|
+
const txid = perpClient.sendTransaction([...depositStakeInstructions ], {
|
66
|
+
depositStakeAdditionalSigners,
|
67
|
+
alts: perpClient.addressLookupTables,
|
68
|
+
})
|
69
|
+
|
70
|
+
|
71
|
+
|
27
72
|
|
28
73
|
<!-- to STAKE FLP.1 -->
|
29
|
-
|
30
|
-
|
74
|
+
const { instructions: depositStakeInstructions, additionalSigners: depositStakeAdditionalSigners } =
|
75
|
+
await perpClient.depositStake(.provider.wallet.publicKey, provider.wallet.publicKey, flpDepositAmount, POOL_CONFIG)
|
76
|
+
|
77
|
+
const txid = perpClient.sendTransaction([...depositStakeInstructions ], {
|
78
|
+
depositStakeAdditionalSigners,
|
79
|
+
alts: perpClient.addressLookupTables,
|
80
|
+
})
|
81
|
+
|
31
82
|
|
32
|
-
const txid = perpClient.sendTransaction([...depositStakeInstructions ], {
|
33
|
-
depositStakeAdditionalSigners,
|
34
|
-
alts: perpClient.addressLookupTables,
|
35
|
-
})
|
36
83
|
|
37
84
|
<!-- to UN-STAKE FLP.1 -->
|
38
85
|
|
@@ -45,6 +92,8 @@ npm i flash-sdk / yarn add flash-sdk
|
|
45
92
|
alts: perpClient.addressLookupTables,
|
46
93
|
})
|
47
94
|
|
95
|
+
|
96
|
+
|
48
97
|
<!-- collect fees -->
|
49
98
|
|
50
99
|
const { instructions, additionalSigners } = await perpClient.collectStakeFees('USDC',POOL_CONFIG)
|