2.1.1 • Published 3 days ago

flash-sdk v2.1.1

Weekly downloads
-
License
MIT
Repository
github
Last release
3 days ago

Flash SDK

Client SDK for interacting with FLASH.TRADE's smart-contracts

Install

npm i flash-sdk / yarn add flash-sdk 

Using the SDK

connect sdk locally

  import { AnchorProvider } from "@coral-xyz/anchor";
  import { ComputeBudgetProgram } from '@solana/web3.js'

  const provider : AnchorProvider = AnchorProvider.local(clusterUrl, {
    commitment: "confirmed",
    preflightCommitment: "confirmed",
    skipPreflight: true
  });
  const perpClient = new PerpetualsClient(provider, programId);

  const POOL_CONFIG = PoolConfig.fromIdsByName('Crypto.1','mainnet-beta')

   <!-- load ALT -->
   await perpClient.loadAddressLookupTable(POOL_CONFIG) 

   <!-- Add Liquidity  -->
    const payTokenSymbol = 'USDC'; // 'SOL' , 'BTC', 'ETH'  
    const { instructions : addLiqInstructions, additionalSigners : addLiqAdditionalSigners } = await perpClient.addLiquidity(
              payTokenSymbol,
              tokenAmountIn,
              minLpAmountOut, // new BN(0)
              POOL_CONFIG
          )
        const setCULimitIx = ComputeBudgetProgram.setComputeUnitLimit({ units: 600_000 })

    const txid =  perpClient.sendTransaction([setCULimitIx, ...addLiqInstructions ], {
            addLiqAdditionalSigners,
            alts: perpClient.addressLookupTables,
      })



  <!-- remove Liquidity  -->
    const recieveTokenSymbol = 'USDC'; // 'SOL' , 'BTC', 'ETH'  
    const { instructions : removeLiqInstructions, additionalSigners : removeLiqAdditionalSigners } = await  await perpClient.removeLiquidity(
            recieveTokenSymbol,
            lpAmountIn,
            minTokenAmountOut, // new BN(0)
            POOL_CONFIG
       )
      const setCULimitIx = ComputeBudgetProgram.setComputeUnitLimit({ units: 600_000 })
    const txid =  perpClient.sendTransaction([setCULimitIx, ...removeLiqInstructions ], {
            removeLiqAdditionalSigners,
            alts: perpClient.addressLookupTables,
      })



    <!-- to STAKE FLP.1 -->
    const { instructions: depositStakeInstructions, additionalSigners: depositStakeAdditionalSigners } =
              await perpClient.depositStake(.provider.wallet.publicKey, provider.wallet.publicKey, flpDepositAmount, POOL_CONFIG)

    const txid =  perpClient.sendTransaction([...depositStakeInstructions ], {
            depositStakeAdditionalSigners,
            alts: perpClient.addressLookupTables,
      })




  <!-- to STAKE FLP.1 -->
  const { instructions: depositStakeInstructions, additionalSigners: depositStakeAdditionalSigners } =
              await perpClient.depositStake(.provider.wallet.publicKey, provider.wallet.publicKey, flpDepositAmount, POOL_CONFIG)

    const txid =  perpClient.sendTransaction([...depositStakeInstructions ], {
            depositStakeAdditionalSigners,
            alts: perpClient.addressLookupTables,
      })



  <!-- to UN-STAKE FLP.1 -->

   const { instructions: unstakeInstantInstructions, additionalSigners : unstakeInstantAdditionalSigners } = await perpClient.unstakeInstant('USDC',flpUnstakeAmount,POOL_CONFIG)

  const { instructions: withdrawStakeInstructions } = await perpClient.withdrawStake(POOL_CONFIG, false)

  const txid =  perpClient.sendTransaction([...unstakeInstantInstructions, ...withdrawStakeInstructions ], {
          unstakeInstantAdditionalSigners,
          alts: perpClient.addressLookupTables,
    })



  <!-- collect fees -->

    const { instructions, additionalSigners } = await perpClient.collectStakeFees('USDC',POOL_CONFIG)

    const txid =  perpClient.sendTransaction([...instructions ], {
              additionalSigners,
              alts: perpClient.addressLookupTables,
        })
  
  
2.1.1

3 days ago

2.1.0

7 days ago

2.0.86

1 month ago

2.0.87

1 month ago

2.0.79

1 month ago

2.0.77

1 month ago

2.0.78

1 month ago

2.0.75

1 month ago

2.0.76

1 month ago

2.0.84

1 month ago

2.0.85

1 month ago

2.0.82

1 month ago

2.0.83

1 month ago

2.0.80

1 month ago

2.0.81

1 month ago

2.0.74

2 months ago

2.0.73

2 months ago

2.0.69

2 months ago

2.0.71

2 months ago

2.0.72

2 months ago

2.0.70

2 months ago

2.0.68

2 months ago

2.0.67

2 months ago

2.0.66

3 months ago

2.0.65

3 months ago

2.0.64

3 months ago

2.0.63

3 months ago

2.0.62

3 months ago

2.0.60

3 months ago

2.0.61

3 months ago

2.0.59

3 months ago

2.0.57

3 months ago

2.0.58

3 months ago

2.0.55

3 months ago

2.0.56

3 months ago

2.0.53

3 months ago

2.0.54

3 months ago

2.0.52

3 months ago

2.0.51

3 months ago

2.0.50

3 months ago

2.0.48

4 months ago

2.0.49

4 months ago

2.0.46

4 months ago

2.0.47

4 months ago

2.0.44

4 months ago

2.0.45

4 months ago

2.0.42

4 months ago

2.0.43

4 months ago

2.0.41

4 months ago

2.0.40

4 months ago

2.0.39

4 months ago

2.0.37

4 months ago

2.0.38

4 months ago

2.0.35

4 months ago

2.0.36

4 months ago

2.0.33

4 months ago

2.0.34

4 months ago

2.0.31

4 months ago

2.0.32

4 months ago

2.0.30

4 months ago

2.0.28

4 months ago

2.0.29

4 months ago

2.0.26

4 months ago

2.0.27

4 months ago

2.0.25

4 months ago

2.0.24

4 months ago

2.0.23

4 months ago

2.0.22

4 months ago

2.0.20

4 months ago

2.0.21

4 months ago

2.0.7

4 months ago

2.0.9

4 months ago

2.0.8

4 months ago

2.0.15

4 months ago

2.0.16

4 months ago

2.0.13

4 months ago

2.0.14

4 months ago

2.0.11

4 months ago

2.0.12

4 months ago

2.0.10

4 months ago

2.0.19

4 months ago

2.0.17

4 months ago

2.0.18

4 months ago

2.0.3

4 months ago

2.0.2

4 months ago

2.0.5

4 months ago

2.0.4

4 months ago

2.0.6

4 months ago

2.0.1

4 months ago

2.0.0

4 months ago

1.0.134

5 months ago

1.0.133

5 months ago

1.0.132

5 months ago

1.0.131

5 months ago

1.0.130

5 months ago

1.0.107

7 months ago

1.0.106

7 months ago

1.0.109

7 months ago

1.0.108

7 months ago

1.0.103

7 months ago

1.0.102

7 months ago

1.0.105

7 months ago

1.0.104

7 months ago

1.0.121

7 months ago

1.0.120

7 months ago

1.0.123

7 months ago

1.0.122

7 months ago

1.0.129

6 months ago

1.0.128

6 months ago

1.0.125

6 months ago

1.0.124

7 months ago

1.0.127

6 months ago

1.0.126

6 months ago

1.0.110

7 months ago

1.0.112

7 months ago

1.0.111

7 months ago

1.0.118

7 months ago

1.0.117

7 months ago

1.0.119

7 months ago

1.0.114

7 months ago

1.0.113

7 months ago

1.0.116

7 months ago

1.0.115

7 months ago

1.0.62

8 months ago

1.0.61

8 months ago

1.0.60

8 months ago

1.0.66

8 months ago

1.0.65

8 months ago

1.0.64

8 months ago

1.0.63

8 months ago

1.0.69

8 months ago

1.0.68

8 months ago

1.0.67

8 months ago

1.0.73

8 months ago

1.0.72

8 months ago

1.0.71

8 months ago

1.0.70

8 months ago

1.0.77

8 months ago

1.0.76

8 months ago

1.0.75

8 months ago

1.0.74

8 months ago

1.0.79

8 months ago

1.0.78

8 months ago

1.0.39

8 months ago

1.0.38

8 months ago

1.0.40

8 months ago

1.0.44

8 months ago

1.0.43

8 months ago

1.0.42

8 months ago

1.0.41

8 months ago

1.0.48

8 months ago

1.0.47

8 months ago

1.0.46

8 months ago

1.0.45

8 months ago

1.0.49

8 months ago

1.0.51

8 months ago

1.0.50

8 months ago

1.0.55

8 months ago

1.0.54

8 months ago

1.0.53

8 months ago

1.0.52

8 months ago

1.0.59

8 months ago

1.0.58

8 months ago

1.0.57

8 months ago

1.0.56

8 months ago

1.0.101

7 months ago

1.0.100

7 months ago

1.0.26

8 months ago

1.0.25

8 months ago

1.0.24

8 months ago

1.0.23

8 months ago

1.0.29

8 months ago

1.0.28

8 months ago

1.0.27

8 months ago

1.0.33

8 months ago

1.0.31

8 months ago

1.0.30

8 months ago

1.0.37

8 months ago

1.0.36

8 months ago

1.0.35

8 months ago

1.0.34

8 months ago

1.0.80

7 months ago

1.0.84

7 months ago

1.0.82

7 months ago

1.0.81

7 months ago

1.0.88

7 months ago

1.0.87

7 months ago

1.0.86

7 months ago

1.0.85

7 months ago

1.0.89

7 months ago

1.0.91

7 months ago

1.0.90

7 months ago

1.0.95

7 months ago

1.0.94

7 months ago

1.0.93

7 months ago

1.0.92

7 months ago

1.0.99

7 months ago

1.0.98

7 months ago

1.0.97

7 months ago

1.0.96

7 months ago

1.0.19

9 months ago

1.0.18

9 months ago

1.0.17

9 months ago

1.0.16

9 months ago

1.0.22

9 months ago

1.0.21

9 months ago

1.0.20

9 months ago

1.0.15

9 months ago

1.0.14

11 months ago

1.0.8

12 months ago

1.0.7

12 months ago

1.0.6

12 months ago

1.0.5

12 months ago

1.0.11

12 months ago

1.0.10

12 months ago

1.0.13

12 months ago

1.0.12

12 months ago

1.0.4

1 year ago

1.0.3

1 year ago

1.0.2

1 year ago

1.0.1

1 year ago

1.0.0

1 year ago