New Exchange Rate Mechanism

No, there is no (hard-coded) list. The exchange rate canister simply collects all the symbols that the forex data providers return.

There is only a small number of providers that support “XDR”, so it is possible that you don’t get any rates for specific timestamps.

Since we need support for XDR, there is a “computed XDR” rate (symbol “CXDR”), which is artificially added. It is derived from the rates and weights defined by the IMF (the weights are shown in the screenshot).

In short, if you need the IMF SDR asset conversion rate, the preferred way is to use the “CXDR” symbol.

2 Likes

Is there any way to receive multiple assets in one go? I feel like having to make 3 separate async calls per 3 different assets could cause some kind of reentrancy attack if thats the right term. Basically, if you need to calculate the amount of you hold in USD for five different assets simultanously, would this current exchange rate canister make that feasible?

or if not now, will there be plans to do this?

Oh yea, is this supposed to be the defacto one source exchange rate shop for the ic, similar to how chainlink is and its bad practice to use any other price feed sources or should this be looked at just as another source that could be faulty and its good to have backups? On localnet, I have quite a bit of random failures but so far none on the mainnet so I am curious?

1 Like

No, there is not. Note that the exchange rate canister needs to make calls to all exchanges for each requested asset individually anyway, so there is no way to reduce the number of HTTPS outcalls in this scenario. Moreover, if you don’t want to make the requests sequentially, you can choose to make multiple calls in parallel and await the completion of all these calls.
However, you should only request a small number of rates at any given time because there is rate limiting in place to make sure there aren’t too many HTTPS outcalls at the same time. If you are requesting too may rates, you’ll get a response containing the ExchangeRateError::RateLimited error.

As mentioned above, adding such an endpoint wouldn’t add a lot of value in my opinion. I agree that it would make things more convenient for developers. I will discuss it with the rest of the exchange rate canister team to see how they feel about it.

It is just one canister that acts as an oracle for cryptocurrency and fiat currency exchange rates. There can definitely be many others, for example, interacting with other/more sources, providing exchange rates for other assets such as stocks and so on.
Everybody is free to develop their own oracle services and use whichever service suits their needs.

Just to be clear, the exchange rate canister is more than “just another source” because it interacts with multiple data sources and consolidates the received rates to provide a rate that is likely to be accurate. Note that the cycle-minting canister will soon receive the ICP/XDR rate from the exchange rate canister.
There is no guarantee that the rate is correct, however, so you may choose to get the rate from other oracles as well (but they may be faulty, too).

4 Likes

Extremely helpful. :pray:

Just in case somebody missed it: The NNS proposal to upgrade the cycle-minting canister (CMC) is open, so please cast your vote!

If the proposal is accepted, the CMC will start using the exchange rate canister to get the ICP/XDR rate after the upgrade.

4 Likes

The CMC has been upgraded!

The dashboard of the exchange rate canister shows that the CMC (rkp4c-7iaaa-aaaaa-aaaca-cai) requests the rate from the exchange rate canister.
You can verify that the conversion rate proposals stopped a few hours ago on the Internet Computer dashboard (by looking at the Exchange Rate topic) and that the CMC updates the rate successfully using the get_icp_xdr_conversion_rate endpoint.

5 Likes

This is extremely awesome

1 Like

What are the privileged canister ids?

rkp4c-7iaaa-aaaaa-aaaca-cai is the Cycles-Minting canister (CMC).

ewh3f-3qaaa-aaaap-aazjq-cai is the Total Value Locked (TVL) canister, used to provide Total ICP Value Locked to the NNS front-end dapp.

1 Like

Thanks, I should have asked “what does it mean to be a privileged canister”, and then knowing which those are would be great.

I’m assuming they just don’t have to pay cycles?

They do not pay for cycles and can bypass the XRC’s rate limiting mechanism.

3 Likes

The final privileged canister is the NNS dapp: qoctq-giaaa-aaaaa-aaaea-cai.

4 Likes

Awesome, thanks for the replies. So the canister is fully open for usage, the CMC is using it live, and any canister can now rely on it (and has been able to for some time)?

The canister is open for usage (it has been for some time :slight_smile:).

4 Likes

The XRC demo works like a charm deployed locally. Is anyone able to guide a noob like me with an example call on the live canister via dfx/terminal or even better some kind of inter canister call example from within motoko. Either way, awesome work seems really useful.

When you say XRC demo, do you mean this sample code?

If that’s what you mean and your demo canister is deployed on the Internet Computer, you can test it using the following dfx command:

dfx canister call --network ic xrc_demo get_exchange_rate "ICP"

You can also use the Candid UI canister to test your canister in a web browser.

Thanks, yes this is the sample code I tested with. This worked fine via candid in a browser but if I wanted to call the live canister on the ic? I presume this is possible from within my own Dapp?

I think maybe I was looking at this in an incorrect way, is your xrc demo an interim dapp that is contacting the exchange rate canister with a degree of separation rather than retrieving the live data directly from market makers. This makes more sense. I’ll have a another look at the example and try to adapt that to my environment.

Thanks again!

Yes, exactly! The demo shows how a canister can conveniently use the exchange rate canister rather than collecting rates itself using HTTPS outcalls.