跳到主要内容

addFeedFor

Contract: JBPrices​‌

Interface: IJBPrices

Add a price feed for a currency in terms of the provided base currency.

Current feeds can't be modified.

Definition

function addFeedFor(
uint256 _currency,
uint256 _base,
IJBPriceFeed _feed
) external override onlyOwner { ... }
  • Arguments:
    • _currency is the currency that the price feed is for.
    • _base is the currency that the price feed is based on.
    • _feed is the IJBPriceFeed contract being added.
  • Through the onlyOwner modifier, this function can only be accessed by the address that owns this contract.
  • The function overrides a function definition from the IJBPrices interface.
  • The function doesn't return anything.

Body

  1. Make sure there isn't already a price feed set for the currency base pair.

    // There can't already be a feed for the specified currency.
    if (
    feedFor[_currency][_base] != IJBPriceFeed(address(0)) ||
    feedFor[_base][_currency] != IJBPriceFeed(address(0))
    ) revert PRICE_FEED_ALREADY_EXISTS();

    Internal references:

  2. Store the provided feed for the currency base pair.

    // Store the feed.
    feedFor[_currency][_base] = _feed;

    Internal references:

  3. Emit an AddFeed event with the relevant parameters.

    emit AddFeed(_currency, _base, _feed);

    Event references: