Accessing the exchange rate on the IC, Locally

Thank you, that’s what I was looking for

3 Likes

very helpful @Ori . I just saw this thread.

1 Like

Does anyone know why theres a get_average_icp_xdr ex rate as well?

Right now ICP is 7.07 ish dollars and from google 1 xdr is about 1.334 some dollars. So xdr to icp function is giving me the correct answer of about 5.19ish xdr per icp.

But the avg_xdr to icp exchange rate is giving me 7.6680. I dont know where this is coming from.

That’s the average ICP/XDR rate over the past 30 days. This is used to calculate node provider rewards. You can also see this on the IC dashboard Conversion Rate chart.

2 Likes

is this working on a local replica? I tried using it on my local dev env:

Reject text: Canister rkp4c-7iaaa-aaaaa-aaaca-cai not found

unless you have the NNS installed locally and adopted the currency conversion proposals this won’t work

how can I achieve this, can you provide a list of steps please?

l.e: done, found a docker image for it.

I am running into this problem right now

Panicked at ‘icp_xdr_conversion_rate is not set’, nns/cmc/src/main.rs:258:10

Yep, if you do not have a conversion rate set, there’s nothing to report. You’ll have to create a proposal to adopt a conversion rate and adopt the proposal first. It might be easier to just mock the function for local development.

FYI, the graph on the IC dashboard is labeled incorrectly. It should be “Cycles/ICP” , not “ICP/Cycles” as shown below. It is only possible to convert ICP to cycles and not the other way around, so, by definition, the conversion rate = cycles per ICP.

1 Like

Thanks, @Sabr, I reported it to the dashboard team

2 Likes