Skip to content

flash-trade/flash-sdk-v2

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

@flash_trade/flash-sdk-v2

The TypeScript client for Flash — perpetuals trading, liquidity provision, and FAF staking on Solana.

Full guides: docs.flash.trade. Runnable, copy-pasteable scripts: examples/ — start with examples/README.md.

Install

npm install @flash_trade/flash-sdk-v2
# peer deps
npm install @coral-xyz/anchor @solana/web3.js @solana/spl-token

Setup

Everything hangs off a single FlashPerpetualsClient. It takes two endpoints: your own Solana RPC, and Flash's trading endpoint (provided by Flash) where trades execute.

import { AnchorProvider, Wallet } from '@coral-xyz/anchor'
import { Connection, Keypair } from '@solana/web3.js'
import { FlashPerpetualsClient, PoolConfig, PROGRAM_ID, type Cluster } from '@flash_trade/flash-sdk-v2'

const CLUSTER: Cluster = 'mainnet-beta' // or 'devnet'

const connection = new Connection(process.env.RPC_URL!, 'confirmed')
const provider = new AnchorProvider(connection, new Wallet(walletKeypair), {
  commitment: 'confirmed',
})

export const poolConfig = PoolConfig.fromIdsByName('Crypto.1', CLUSTER) // devnet: 'devnet.1'

export const flashClient = new FlashPerpetualsClient(
  provider,
  undefined,             // use the bundled IDL
  PROGRAM_ID[CLUSTER],
  { prioritizationFee: 5000 },
  process.env.ER_RPC!,   // Flash's trading endpoint
)

Sending transactions

Two send paths, depending on the operation:

  • flashClient.sendAndConfirmTransaction(ixs, opts?) — setup, deposits, liquidity, staking.
  • flashClient.sendAndConfirmErTransaction(ixs, signers) — trading (positions and orders).

What you can do

Area Methods Guide
Trade open / close / modify positions, limit & trigger orders, quotes Trader Interactions
Provide liquidity FLP (auto-compounding) & sFLP (staked) mint/burn, rewards LP Interactions
Stake FAF stake, unstake, claim rewards / revenue / rebates Revenue Interactions

Examples

The examples/ folder has one runnable script per method — every mutating script is dry-run by default (SEND=1 to submit). See examples/README.md for the quickstart and examples/TROUBLESHOOTING.md when something errors.

License

MIT

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors