Get Price
Gets an asset's price from the Onyx Protocol open price feed. The price of the asset can be returned in any other supported asset value, including all oTokens and underlyings.
asset
(string) A string of a supported asset in which to find the current price.[inAsset]
(string) A string of a supported asset in which to express theasset
parameter's price. This defaults to USD.RETURN
(string) Returns a string of the numeric value of the asset.
const onyx= new Onyx(window.ethereum);
let price;
(async function () {
price = await onyx.getPrice(onyx.WBTC);
console.log('WBTC in USD', price); // 6 decimals, see Open Price Feed docs
price = await onyx.getPrice(Onyx.ETH, Onyx.USDC); // supports oTokens too
console.log('ETH in USDC', price);
})().catch(console.error);
Last updated