HederaExchangeRateAdapterLib
Title: HederaExchangeRateAdapterLib
Authors: David Dada <daveproxy80@gmail.com> (https://github.com/dadadave80), Modified from hiero-ledger/hiero-contracts (https://github.com/hiero-ledger/hiero-contracts)
Stateless wrapper around the Exchange Rate system contract — no storage, no admin, no staleness (the network itself refreshes the rate roughly hourly).
The two conversion calls are view-classified by the network, so staticcall is valid (probe on
testnet in the day-0 checklist before relying on it from a view).
Functions
__HederaExchangeRateAdapter_init
function __HederaExchangeRateAdapter_init() internal;registerInterface
function registerInterface() internal;tinycentsToTinybars
function tinycentsToTinybars(uint256 tinycents) internal view returns (uint256 tinybars);Parameters
| Name | Type | Description |
|---|---|---|
| tinycents | uint256 |
Returns
| Name | Type | Description |
|---|---|---|
| tinybars | uint256 |
tinybarsToTinycents
function tinybarsToTinycents(uint256 tinybars) internal view returns (uint256 tinycents);Parameters
| Name | Type | Description |
|---|---|---|
| tinybars | uint256 |
Returns
| Name | Type | Description |
|---|---|---|
| tinycents | uint256 |
usdCentsToWei
function usdCentsToWei(uint256 cents) internal view returns (uint256 weibar);Parameters
| Name | Type | Description |
|---|---|---|
| cents | uint256 |
Returns
| Name | Type | Description |
|---|---|---|
| weibar | uint256 |
hbarUsdWad
USD per HBAR, 18 decimals: tinycents per HBAR is USD * 1e10, so scale by 1e8.
function hbarUsdWad() internal view returns (uint256 priceWad);Returns
| Name | Type | Description |
|---|---|---|
| priceWad | uint256 |
_query
function _query(bytes memory data) private view returns (uint256 result);Parameters
| Name | Type | Description |
|---|---|---|
| data | bytes |
Returns
| Name | Type | Description |
|---|---|---|
| result | uint256 |