Docs
Search…
⌃K

Price Oracle

Smart contract using Chainlink Data Feeds to get the underlying price, and scale it to PalTokens using the their exchangeRates.
The Price Oracle contract allows to retrieve prices for palTokens.
The prices are based on Chainlink Data Feeds, both for ETH and USD prices. In the case one of the price feed is not listed for an asset, or does not exist, the other price feed (is there is one) is used with the ETH/USD price feed (baseSource in the contract) to calculate the price. The price is then scaled to the palToken, using the exchange rate between the palToken and the underlying token (the underlying associated with the price feed).
This contract is experimental. It's strongly advised to use that contract as an updatable component to replace it with newer versions if needed.

Price methods:

For usage through another smart contract, it is strongly advised to use the getUpdatedAssetPrice & getUpdatedAssetUSDPrice methods to fetch prices, as those methods will update the PalPool state before fetching the exchange rate.
getAssetPrice
function getAssetPrice(address asset) public view returns (uint256, uint256)
Returns the ETH price of the asset given, based on the ETH price source and the palToken exchangeRate. If no ETH price source is set, the USD price source is used, and conversion using the base (ETH/USD) source price is used.
Returns both the price, and the decimals for the price value
getAssetUSDPrice
function getAssetUSDPrice(address asset) public view returns (uint256, uint256)
Returns the USD price of the asset given, based on the USD price source and the palToken exchangeRate. If no USD price source is set, the ETH price source is used, and conversion using the base (ETH/USD) source price is used.
Returns both the price, and the decimals for the price value
getUpdatedAssetPrice
function getUpdatedAssetPrice(address asset) public returns (uint256, uint256)
Returns the ETH price of the asset given, based on the ETH price source and the updated palToken exchangeRate (by updating the PalPool state when fetching the exchangeRate). If no ETH price source is set, the USD price source is used, and conversion using the base (ETH/USD) source price is used.
Returns both the price, and the decimals for the price value
getUpdatedAssetUSDPrice
function getUpdatedAssetUSDPrice(address asset) public returns (uint256, uint256)
Return the USD price of the asset given, based on the USD price source and the updated palToken exchangeRate (by updating the PalPool state when fetching the exchangeRate). If no USD price source is set, the ETH price source is used, and conversion using the base (ETH/USD) source price is used
Returns both the price, and the decimals for the price value

Other methods:

getAssetSource
function getAssetSource(address asset) external view returns(address)
Returns the ETH source price for the given asset
getAssetUSDSource
function getAssetUSDSource(address asset) external view returns(address)
Returns the USD source price for the given asset
Following methods use the last updated exchangeRate stored in the Pools. If used in a contract, it is advised to update the Pool state to have an up-to-date exchangeRate for the current block.
(see _updateInterest() in PalPool contract)
underlyingForPalToken
function underlyingForPalToken(address palToken, uint256 amount) public view returns(uint256)
Returns underlying amount for a given PalToken amount, based on the last updated exchangeRate
palTokenForUnderlying
function palTokenForUnderlying(address palToken, uint256 amount) public view returns(uint256)
Returns PalToken amount for a given underlying amount, based on the last updated exchangeRate