LogoLogo
CommunityLaunch App
  • FLASH TRADE
    • Introduction
    • Our Mission
    • Getting Started
    • Tokenomics
      • FAF claim for beast NFT holders
      • Reward, Utility & Governance
      • Technical Architecture of Staking
      • FAF Rewards Multiplier
    • Technical Architecture
      • Pool-to-Peer Mechanism
      • Liquidity Providing
      • FLP Tokens
        • Minting and Burning FLP/sFLP
        • FLP
        • sFLP
      • Crypto Asset-Backed Pools
      • Synthetic (Pool 2)
      • Pricing Engine
      • Virtual PNL Delay
      • Fee Distribution
    • Perpetuals Specifications
      • Market Hours
      • Collateral Specification
      • Fees
      • Stop Loss/Take Profit Orders
      • Limit Orders
      • Liquidation
      • Margin Framework
    • Build On Flash
      • LP Interactions
      • Trader Interactions
    • FAQs
    • Audits
    • The Flash Beasts
    • Terms of Service
Powered by GitBook
LogoLogo

Resources

  • Github
  • Dune analytics
  • DeFi llama

Ecosystem

  • Home
  • App
  • Blog
  • Media kit

Community

  • Twitter
  • Discord
On this page
  • Introduction
  • Install the Flash SDK
  • Setting up the Flash SDK
  1. FLASH TRADE

Build On Flash

Integrating with Flash.trade made easy

Introduction

Flash.trade SDK written in typescript provides the easist way for developers, partners and others to integrate with flash.trade. This page will walk you through setting up the flash client, creating transactions and executing them.

Install the Flash SDK

npm install flash-sdk

yarn add flash-sdk

Setting up the Flash SDK

import { AnchorProvider, BN } from "@coral-xyz/anchor";
import { PerpetualsClient, PoolConfig } from 'flash-sdk';

const RPC_URL = process.env.RPC_URL;

// Configure the AnchorProvider
const provider: AnchorProvider = AnchorProvider.local(RPC_URL, {
    commitment: 'processed',
    preflightCommitment: 'processed',
    skipPreflight: true,
});

// Configure the pool you want to interact with 
// for devnet : devnet.1,devnet.2,devnet.3,devnet.4,devnet.5
// for mainnet : Crypto.1,Virtual.1,Governance.1,Community.1,Community.2
// all the pool details can be found by running `code ./node_modules/flash-sdk/dist/PoolConfig.json`
const POOL_CONFIG = PoolConfig.fromIdsByName('Crypto.1', 'mainnet-beta'); 

// You can now setup the Flash client
const flashClient = new PerpetualsClient(
    provider,
    POOL_CONFIG.programId,
    POOL_CONFIG.perpComposibilityProgramId,
    POOL_CONFIG.fbNftRewardProgramId,
    POOL_CONFIG.rewardDistributionProgram.programId,
    {
        prioritizationFee: 0, // this can be set dynamically by calling flashClient.setPrioritizationFee
    }
)

NOTE : if you are using AnchorProvider it is necessary to pass ANCHOR_WALLET as an environment variable. This wallet/keypair doesn't have to sign the transaction but if you are using it as part of the view functions then this wallet pubkey will be used for simulations. It also needs be initialized, i.e has to have some SOL in it.

PreviousMargin FrameworkNextLP Interactions

Last updated 2 months ago

for detailed example checkout the public repo here :

https://github.com/flash-trade/flash-trade-sdk/tree/main/examples