How the 30-Day Moving Average Is Calculated

From Internet Computer Wiki
Revision as of 21:21, 22 January 2024 by Katie.peters (talk | contribs) (Added the CMC metrics page)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

The cycles minting canister (CMC, part of the NNS) fetches the ICP/XDR rate every 5 minutes from the exchange rate canister, which is our price oracle. The cycles canister also stores the start-of-day rates (UTC).

The 30-day-moving average uses the start-of-day rates for the past 30 days. Auditors look at the CMC's source code, which is publicly available here: https://github.com/dfinity/ic/blob/4344a924bcb12bc3d1510805dbb37391179df887/rs/nns/cmc/src/main.rs#L930

...and the function right below that as well: https://github.com/dfinity/ic/blob/4344a924bcb12bc3d1510805dbb37391179df887/rs/nns/cmc/src/main.rs#L964

These values are shown on the dashboard under "Conversion Rate." Details can also be seen on the CMC metrics page which shows the current rate. Here is an example from January 22, 2024:

# HELP cmc_icp_xdr_conversion_rate Amount of XDR corresponding to 1 ICP.
# TYPE cmc_icp_xdr_conversion_rate gauge
cmc_icp_xdr_conversion_rate 8.0854 1705957401066

# HELP cmc_icp_xdr_conversion_rate_timestamp_seconds Timestamp of the last ICP/XDR conversion rate, in seconds since the Unix epoch.
# TYPE cmc_icp_xdr_conversion_rate_timestamp_seconds gauge
cmc_icp_xdr_conversion_rate_timestamp_seconds 1705957140 1705957401066

As well as the 30-day average rate:

# HELP cmc_avg_icp_xdr_conversion_rate Average amount of XDR corresponding to 1 ICP.
# TYPE cmc_avg_icp_xdr_conversion_rate gauge
cmc_avg_icp_xdr_conversion_rate 8.9133 1705957401066

# HELP cmc_avg_icp_xdr_conversion_rate_timestamp_seconds Timestamp of the last update to the Average ICP/XDR conversion rate, in seconds since the Unix epoch.
# TYPE cmc_avg_icp_xdr_conversion_rate_timestamp_seconds gauge
cmc_avg_icp_xdr_conversion_rate_timestamp_seconds 1705881600 1705957401066