Skip to content
Lattice

IHederaExchangeRateAdapter

Git Source

Title: IHederaExchangeRateAdapter

Author: Modified from hiero-ledger/hiero-contracts (https://github.com/hiero-ledger/hiero-contracts)

Interface for the HederaExchangeRateAdapter Diamond facet — the network's own USD/HBAR rate (Exchange Rate system contract, file 0.0.112) exposed like the other Lattice price adapters.

Units: 1 tinycent = 1e-8 US cent (1e-10 USD); 1 tinybar = 1e-8 HBAR = 1e10 weibar (msg.value units).

Functions

tinycentsToTinybars

Converts USD tinycents to HBAR tinybars at the current network rate.

function tinycentsToTinybars(uint256 tinycents) external view returns (uint256 tinybars);

Parameters

NameTypeDescription
tinycentsuint256

Returns

NameTypeDescription
tinybarsuint256

tinybarsToTinycents

Converts HBAR tinybars to USD tinycents at the current network rate.

function tinybarsToTinycents(uint256 tinybars) external view returns (uint256 tinycents);

Parameters

NameTypeDescription
tinybarsuint256

Returns

NameTypeDescription
tinycentsuint256

usdCentsToWei

Converts whole USD cents to weibar (the msg.value unit) — e.g. to price a fee in USD.

function usdCentsToWei(uint256 cents) external view returns (uint256 weibar);

Parameters

NameTypeDescription
centsuint256

Returns

NameTypeDescription
weibaruint256

hbarUsdWad

Current HBAR/USD rate scaled to 18 decimals (USD per 1 HBAR, WAD), matching latestAnswer conventions of the other oracle adapters.

function hbarUsdWad() external view returns (uint256 priceWad);

Returns

NameTypeDescription
priceWaduint256

Errors

HederaExchangeRateCallFailed

The Exchange Rate system contract halted or returned malformed data.

error HederaExchangeRateCallFailed();