
Security News
Feross on the 10 Minutes or Less Podcast: Nobody Reads the Code
Socket CEO Feross Aboukhadijeh joins 10 Minutes or Less, a podcast by Ali Rohde, to discuss the recent surge in open source supply chain attacks.
flash-sdk
Advanced tools
Client SDK for interacting with FLASH.TRADE's smart-contracts
autogenerated docs : https://flash-trade.github.io/flash-sdk-docs/
npm : https://www.npmjs.com/package/flash-sdk
npm i flash-sdk / yarn add flash-sdk
Client SDK for interacting with FLASH.TRADE's smart-contracts
autogenerated docs : https://flash-trade.github.io/flash-sdk-docs/
npm : https://www.npmjs.com/package/flash-sdk
code : https://github.com/flash-trade/flash-trade-sdk.git
import { AnchorProvider } from "@coral-xyz/anchor";
import { ComputeBudgetProgram , PublicKey, TransactionInstruction } from '@solana/web3.js'
const provider : AnchorProvider = AnchorProvider.local(clusterUrl, {
commitment: "confirmed",
preflightCommitment: "confirmed",
skipPreflight: true
});
const perpClient = new PerpetualsClient(provider, programId);
// NOTE: choose the correct POOL_CONFIG based on the pool you want to interact
// flp.1
const POOL_CONFIG = PoolConfig.fromIdsByName('Crypto.1','mainnet-beta')
// flp.2
// const POOL_CONFIG = PoolConfig.fromIdsByName('Virtual.1','mainnet-beta')
// flp.3
// const POOL_CONFIG = PoolConfig.fromIdsByName('Governance.1','mainnet-beta')
// flp.4
// const POOL_CONFIG = PoolConfig.fromIdsByName('Community.1','mainnet-beta')
// flp.5
// const POOL_CONFIG = PoolConfig.fromIdsByName('Community.2','mainnet-beta')
// flp.7
// const POOL_CONFIG = PoolConfig.fromIdsByName('Trump.1','mainnet-beta')
// flp.8
// const POOL_CONFIG = PoolConfig.fromIdsByName('Ore.1','mainnet-beta')
// flp.r
// const POOL_CONFIG = PoolConfig.fromIdsByName('Remora.1','mainnet-beta')
const poolAddress = POOL_CONFIG.poolAddress.toBase58()
const backupOracleData: any = await (await fetch(`https://flash.trade/api/backup-oracle?poolAddress=${poolAddress}`)).json()
const backUpOracleInstruction = new TransactionInstruction({
keys: backupOracleData.keys,
programId: new PublicKey(backupOracleData.programId),
data: Buffer.from(backupOracleData.data),
})
<!-- to get any token config from symbol-->
const USDC_TOKEN = POOL_CONFIG.tokens.find((t) => t.symbol == 'USDC')!
const BTC_TOKEN = POOL_CONFIG.tokens.find((t) => t.symbol == 'BTC')!
<!-- to get any token config from mint -->
const tokenMint = new PublicKey('EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v')
const USDC_TOKEN = POOL_CONFIG.tokens.find((t) => t.mintKey.equals(tokenMint))!
<!-- load ALT -->
await perpClient.loadAddressLookupTable(POOL_CONFIG)
<!-- Add Liquidity (USDC -> sFLP.1 ) -->
const payTokenSymbol = 'USDC'; // 'SOL' , 'BTC', 'ETH'
const { instructions : addLiqInstructions, additionalSigners : addLiqAdditionalSigners } = await perpClient.addLiquidityAndStake(
payTokenSymbol,
tokenAmountIn,
minLpAmountOut, // new BN(0)
POOL_CONFIG
)
const setCULimitIx = ComputeBudgetProgram.setComputeUnitLimit({ units: 600_000 })
let addresslookupTables: AddressLookupTableAccount[] = (
await flashClient.getOrLoadAddressLookupTable(POOL_CONFIG)
).addressLookupTables
const txid = perpClient.sendTransaction([backUpOracleInstruction, setCULimitIx, ...addLiqInstructions ], {
addLiqAdditionalSigners,
alts: addresslookupTables,
})
<!--addCompoundingLiquidity (USDC -> FLP.1 ) -->
const payTokenSymbol = 'USDC'; // 'SOL' , 'BTC', 'ETH'
const { instructions : addCompLiqInstructions, additionalSigners : addCompLiqAdditionalSigners } = await perpClient.addCompoundingLiquidity(
tokenAmountIn,
payTokenSymbol,
minLpAmountOut, // new BN(0)
USDC_TOKEN.mintKey,
POOL_CONFIG
)
const setCULimitIx = ComputeBudgetProgram.setComputeUnitLimit({ units: 600_000 })
const txid = perpClient.sendTransaction([backUpOracleInstruction, setCULimitIx, ...addCompLiqInstructions ], {
addCompLiqAdditionalSigners,
alts: perpClient.addressLookupTables,
})
<!-- remove Liquidity (FLP -> USDC) -->
const recieveTokenSymbol = 'USDC'; // 'SOL' , 'BTC', 'ETH'
const { instructions : removeCompLiqInstructions, additionalSigners : removeCompLiqAdditionalSigners } = await await perpClient.removeCompoundingLiquidity(
lpAmountIn,
minTokenAmountOut, // new BN(0)
recieveTokenSymbol,
USDC_TOKEN.mintKey,
POOL_CONFIG,
true
)
const setCULimitIx = ComputeBudgetProgram.setComputeUnitLimit({ units: 600_000 })
let addresslookupTables: AddressLookupTableAccount[] = (
await flashClient.getOrLoadAddressLookupTable(POOL_CONFIG)
).addressLookupTables
const txid = perpClient.sendTransaction([backUpOracleInstruction, setCULimitIx, ...removeCompLiqInstructions ], {
removeCompLiqAdditionalSigners,
alts: addresslookupTables,
})
<!-- remove Liquidity (sFLP -> USDC) -->
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 })
let addresslookupTables: AddressLookupTableAccount[] = (
await flashClient.getOrLoadAddressLookupTable(POOL_CONFIG)
).addressLookupTables
const txid = perpClient.sendTransaction([backUpOracleInstruction, setCULimitIx, ...removeLiqInstructions ], {
removeLiqAdditionalSigners,
alts: perpClient.addressLookupTables,
})
<!-- to STAKE sFLP.1 -->
const { instructions: depositStakeInstructions, additionalSigners: depositStakeAdditionalSigners } =
await perpClient.depositStake(.provider.wallet.publicKey, provider.wallet.publicKey, flpDepositAmount, POOL_CONFIG)
let addresslookupTables: AddressLookupTableAccount[] = (
await flashClient.getOrLoadAddressLookupTable(POOL_CONFIG)
).addressLookupTables
const txid = perpClient.sendTransaction([...depositStakeInstructions ], {
depositStakeAdditionalSigners,
alts: perpClient.addressLookupTables,
})
<!-- to UN-STAKE sFLP.1 -->
const { instructions: unstakeInstantInstructions, additionalSigners : unstakeInstantAdditionalSigners } = await perpClient.unstakeInstant('USDC',flpUnstakeAmount,POOL_CONFIG)
const { instructions: withdrawStakeInstructions } = await perpClient.withdrawStake(POOL_CONFIG, false)
let addresslookupTables: AddressLookupTableAccount[] = (
await flashClient.getOrLoadAddressLookupTable(POOL_CONFIG)
).addressLookupTables
const txid = perpClient.sendTransaction([...unstakeInstantInstructions, ...withdrawStakeInstructions ], {
unstakeInstantAdditionalSigners,
alts: perpClient.addressLookupTables,
})
<!-- collect fees -->
const { instructions, additionalSigners } = await perpClient.collectStakeFees('USDC',POOL_CONFIG)
let addresslookupTables: AddressLookupTableAccount[] = (
await flashClient.getOrLoadAddressLookupTable(POOL_CONFIG)
).addressLookupTables
const txid = perpClient.sendTransaction([...instructions ], {
additionalSigners,
alts: perpClient.addressLookupTables,
})
<!-- call any view function like so -->
const compoundingLPTokenPrice = await perpClient.getCompoundingLPTokenPrice(POOL_CONFIG.poolAddress, POOL_CONFIG)
yarn run doc FAQs
Client to interact with the Flash program on Solana
The npm package flash-sdk receives a total of 1,721 weekly downloads. As such, flash-sdk popularity was classified as popular.
We found that flash-sdk demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
Socket CEO Feross Aboukhadijeh joins 10 Minutes or Less, a podcast by Ali Rohde, to discuss the recent surge in open source supply chain attacks.

Research
/Security News
Campaign of 108 extensions harvests identities, steals sessions, and adds backdoors to browsers, all tied to the same C2 infrastructure.

Security News
OpenAI rotated macOS signing certificates after a malicious Axios package reached its CI pipeline in a broader software supply chain attack.