Options
All
  • Public
  • Public/Protected
  • All
Menu

synths-sdk

Index

Functions

getCurrentDexTokenPrice

  • getCurrentDexTokenPrice(poolLocation: string, poolAddress: string, tokenAddress: string, network?: string): Promise<undefined | number>
  • notice

    Helper function to get the current DEX token price.

    Parameters

    • poolLocation: string

      Location string of the DEX pool (e.g. "uni").

    • poolAddress: string

      Address of the DEX pool.

    • tokenAddress: string

      Address of the token.

    • Optional network: string

    Returns Promise<undefined | number>

    The DEX token price in WEI.

getInfoByIdentifier

  • getInfoByIdentifier(synthId: string, network: number, userConfig?: SynthsAssetsConfig): undefined | AssetConfigEMP | AssetConfigLSP
  • notice

    Helper function to get data from assets.json according to the synth id.

    Parameters

    • synthId: string

      The synth identifier.

    • network: number
    • Optional userConfig: SynthsAssetsConfig

    Returns undefined | AssetConfigEMP | AssetConfigLSP

    The synth info from the assets.json.

getPoolChartData

  • getPoolChartData(poolLocation: string, poolAddress: string, tokenAddress: string, network?: string): Promise<IPairData[]>
  • notice

    Helper function to get pool data.

    dev

    Since the subgraph only indexes data if something has changed we fill the data manually.

    Parameters

    • poolLocation: string

      The pool location to help choose the right subgraph endpoint.

    • poolAddress: string

      The pool address you want to get the data from.

    • tokenAddress: string

      The token of which you want to get the price.

    • Optional network: string

    Returns Promise<IPairData[]>

    An array of token market data.

getRecentSynthData

  • getRecentSynthData(networkId: number, userConfig?: SynthsAssetsConfig): Promise<ISynthsData[]>
  • notice

    Helper function to get the data for the most recent synths.

    dev

    Can be used on the front-end to display the most recent synths.

    Parameters

    • networkId: number

      The network / chain id of the synth deployment.

    • Optional userConfig: SynthsAssetsConfig

    Returns Promise<ISynthsData[]>

    The most recent synth market data.

getSynthData

  • getSynthData(poolLocation: string, poolAddress: string, collateralSymbol: string, network?: string, userConfig?: SynthsAssetsConfig): Promise<undefined | ISynthsData>
  • notice

    Helper function to get relevant synth market data.

    Parameters

    • poolLocation: string
    • poolAddress: string
    • collateralSymbol: string
    • Optional network: string
    • Optional userConfig: SynthsAssetsConfig

    Returns Promise<undefined | ISynthsData>

    An object with the synth market data.

getTotalMarketData

  • getTotalMarketData(networks: number[], userConfig?: SynthsAssetsConfig): Promise<{ total24hVolume: number; totalLiquidity: number; totalSynthCount: number; totalTVL: undefined }>
  • notice

    Helper function to get the total liquidity and volume of all synths in the last 24h.

    Parameters

    • networks: number[]

      Array of networks that the user wants to query.

    • Optional userConfig: SynthsAssetsConfig

    Returns Promise<{ total24hVolume: number; totalLiquidity: number; totalSynthCount: number; totalTVL: undefined }>

    The total synths market data.

getYamRewardsByPoolAddress

  • getYamRewardsByPoolAddress(poolAddress: string, userConfig?: SynthsAssetsConfig): Promise<undefined | string>
  • notice

    Helper function to get the rewards by pool address.

    dev

    Should be removed after api accepts a pool address instead of an id.

    Parameters

    Returns Promise<undefined | string>

    The rewards for the given pool.

roundNumber

  • roundNumber(number: number, decimals: number): number
  • notice

    Helper function to round a number to a certain number of decimals.

    Parameters

    • number: number

      The number to round.

    • decimals: number

      The number of decimals to round to.

    Returns number

    The rounded number.

Generated using TypeDoc