JavPriceAggregator

General Description

The JavPriceAggregator contract used for manage and query price data for LeverageX. It allows initialization of price aggregators, updates to collateral price feeds, management of price lifetimes, and retrieval of pricing details for various assets. The functions are divided into management setters for configuration and getters for querying price-related data.

Core Functionalities

initializePriceAggregator

  • Initializes the price aggregator with the provided oracle, alternative oracle, reward token USD feed, collateral indices, and their respective USD price feeds.

  • Parameters:

    • _oracle: Primary oracle for price data.

    • _alternativeOracle: Backup oracle for price data.

    • _rewardsTokenUsdFeed: Feed identifier for the rewards token in USD.

    • _collateralIndices: Array of indices representing collateral types.

    • _collateralUsdPriceFeeds: Array of feed identifiers for collateral prices in USD.

updateCollateralUsdPriceFeed

  • Updates the USD price feed associated with a specific collateral index.

  • Parameters:

    • _collateralIndex: Index of the collateral.

    • _value: New feed identifier for the collateral price in USD.

  • Access Control: onlyRole(Role.GOV).

setPriceLifetime

  • Sets the lifetime duration for price data.

  • Parameters:

    • _lifetime: New lifetime value in seconds.

  • Access Control: onlyRole(Role.GOV).

getPriceLifetime

  • Retrieves the configured price lifetime.

  • Returns: The price lifetime in seconds.

getPrice

  • Retrieves the price for a specific pair index.

  • Parameters:

    • _pairIndex: Index of the price pair.

  • Returns: Price of the pair.

updatePrices

  • Updates price data based on a multi-dimensional array input.

  • Parameters:

    • _priceUpdate: Array of price update data.

    • _user: Address initiating the price update.

  • Access Control: onlySelf.

getCollateralPriceUsd

  • Retrieves the USD price for a specific collateral index.

  • Parameters:

    • _collateralIndex: Index of the collateral.

  • Returns: USD price of the collateral.

getCollateralFeed

  • Retrieves the feed identifier for a specific collateral index.

  • Parameters:

    • _collateralIndex: Index of the collateral.

  • Returns: Feed identifier.

getRewardsTokenUsdFeed

  • Retrieves the USD feed identifier for the rewards token.

  • Returns: Feed identifier for the rewards token price in USD.

getUsdNormalizedValue

  • Converts collateral value to its normalized USD equivalent.

  • Parameters:

    • _collateralIndex: Index of the collateral.

    • _collateralValue: Collateral value to normalize.

  • Returns: Normalized USD value.

getCollateralFromUsdNormalizedValue

  • Converts a normalized USD value back to its collateral equivalent.

  • Parameters:

    • _collateralIndex: Index of the collateral.

    • _normalizedValue: Normalized USD value.

  • Returns: Collateral equivalent value.

getRewardsTokenPriceUsd

  • Retrieves the USD price of the rewards token.

  • Returns: USD price of the rewards token.

Last updated