Options
All
  • Public
  • Public/Protected
  • All
Menu

Module "priceFeed"

Index

Functions

Functions

getPrice

  • getPrice(asset: string, inAsset?: string): Promise<number>
  • Gets an asset's price from the Venus Protocol open price feed. The price of the asset can be returned in any other supported asset value, including all vTokens and underlyings.

    example
    const venus = new Venus(window.ethereum);
    let price;
    
    (async function () {
    
      price = await venus.getPrice(Venus.BNB);
      console.log('BNB in USD', price);
    
      price = await venus.getPrice(Venus.SXP, Venus.USDC); // supports vTokens too
      console.log('SXP in USDC', price);
    
    })().catch(console.error);

    Parameters

    • asset: string

      A string of a supported asset in which to find the current price.

    • Default value inAsset: string = constants.USDC

    Returns Promise<number>

    Returns a string of the numeric value of the asset.