跳到主要内容

JBPrices

Git Source

Inherits: JBControlled, JBPermissioned, Ownable, IJBPrices

Manages and normalizes price feeds. Price feeds are contracts which return the "pricing currency" cost of 1 "unit currency".

State Variables

DEFAULT_PROJECT_ID

The ID to store default values in.

uint256 public constant override DEFAULT_PROJECT_ID = 0;

PROJECTS

Mints ERC-721s that represent project ownership and transfers.

IJBProjects public immutable override PROJECTS;

priceFeedFor

The available price feeds.

The feed returns the pricingCurrency cost for one unit of the unitCurrency.

mapping(uint256 projectId => mapping(uint256 pricingCurrency => mapping(uint256 unitCurrency => IJBPriceFeed)))
public
override priceFeedFor;

Functions

constructor

constructor(
IJBDirectory directory,
IJBPermissions permissions,
IJBProjects projects,
address owner
)
JBControlled(directory)
JBPermissioned(permissions)
Ownable(owner);

Parameters

NameTypeDescription
directoryIJBDirectoryA contract storing directories of terminals and controllers for each project.
permissionsIJBPermissionsA contract storing permissions.
projectsIJBProjectsA contract which mints ERC-721s that represent project ownership and transfers.
owneraddressThe address that will own the contract.

pricePerUnitOf

Gets the pricingCurrency cost for one unit of the unitCurrency.

function pricePerUnitOf(
uint256 projectId,
uint256 pricingCurrency,
uint256 unitCurrency,
uint256 decimals
)
public
view
override
returns (uint256);

Parameters

NameTypeDescription
projectIduint256The ID of the project to check the feed for. Feeds stored in ID 0 are used by default for all projects.
pricingCurrencyuint256The currency the feed's resulting price is in terms of.
unitCurrencyuint256The currency being priced by the feed.
decimalsuint256The number of decimals the returned fixed point price should include.

Returns

NameTypeDescription
<none>uint256The pricingCurrency price of 1 unitCurrency, as a fixed point number with the specified number of decimals.

addPriceFeedFor

Add a price feed for the unitCurrency, priced in terms of the pricingCurrency.

Price feeds can only be added, not modified or removed.

This contract's owner can add protocol-wide default price feed by passing a projectId of 0.

function addPriceFeedFor(
uint256 projectId,
uint256 pricingCurrency,
uint256 unitCurrency,
IJBPriceFeed feed
)
external
override;

Parameters

NameTypeDescription
projectIduint256The ID of the project to add a feed for. If projectId is 0, add a protocol-wide default price feed.
pricingCurrencyuint256The currency the feed's output price is in terms of.
unitCurrencyuint256The currency being priced by the feed.
feedIJBPriceFeedThe address of the price feed to add.

Errors

JBPrices_PriceFeedAlreadyExists

error JBPrices_PriceFeedAlreadyExists(IJBPriceFeed feed);

JBPrices_PriceFeedNotFound

error JBPrices_PriceFeedNotFound();

JBPrices_ZeroPricingCurrency

error JBPrices_ZeroPricingCurrency();

JBPrices_ZeroUnitCurrency

error JBPrices_ZeroUnitCurrency();