addFeedFor
Contract: JBPrices
Interface: IJBPrices
- Step by step
- Code
- Errors
- Events
- Bug bounty
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 theIJBPriceFeed
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
-
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:
-
Store the provided feed for the currency base pair.
// Store the feed.
feedFor[_currency][_base] = _feed;Internal references:
-
Emit an
AddFeed
event with the relevant parameters.emit AddFeed(_currency, _base, _feed);
Event references:
/**
@notice
Add a price feed for a currency in terms of the provided base currency.
@dev
Current feeds can't be modified.
@param _currency The currency that the price feed is for.
@param _base The currency that the price feed is based on.
@param _feed The price feed being added.
*/
function addFeedFor(
uint256 _currency,
uint256 _base,
IJBPriceFeed _feed
) external override onlyOwner {
// 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();
// Store the feed.
feedFor[_currency][_base] = _feed;
emit AddFeed(_currency, _base, _feed);
}
String | Description |
---|---|
PRICE_FEED_ALREADY_EXISTS | Thrown if the specified currency already has an associated price feed. |
Name | Data |
---|---|
AddFeed |
|
Category | Description | Reward |
---|---|---|
Optimization | Help make this operation more efficient. | 0.5ETH |
Low severity | Identify a vulnerability in this operation that could lead to an inconvenience for a user of the protocol or for a protocol developer. | 1ETH |
High severity | Identify a vulnerability in this operation that could lead to data corruption or loss of funds. | 5+ETH |