Skip to content
Lattice

HederaExchangeRateAdapterLib

Git Source

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

NameTypeDescription
tinycentsuint256

Returns

NameTypeDescription
tinybarsuint256

tinybarsToTinycents

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

Parameters

NameTypeDescription
tinybarsuint256

Returns

NameTypeDescription
tinycentsuint256

usdCentsToWei

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

Parameters

NameTypeDescription
centsuint256

Returns

NameTypeDescription
weibaruint256

hbarUsdWad

USD per HBAR, 18 decimals: tinycents per HBAR is USD * 1e10, so scale by 1e8.

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

Returns

NameTypeDescription
priceWaduint256

_query

function _query(bytes memory data) private view returns (uint256 result);

Parameters

NameTypeDescription
databytes

Returns

NameTypeDescription
resultuint256