How to send multiple tokens request to exchange rate canister (XRC) for fetching multiple exchange rates?

How can we send multiple token requests to an exchange rate canister (XRC) for fetching multiple exchange rates?

Currently, we have support for sending a single base asset and quote asset request to the ‘get_exchange_rate’ service. If we have a list of 100 tokens to request at a time then how will we fetch that?

Hi @Tano.icp !
Unfortunately this is not currently possible with the XRC and would not be easy to do.
Every time the XRC is called for a single rate, if the rates for the exact timestamp are not cached, the XRC would make a set of HTTPS outcalls to different crypto exchanges to get the rate of the requested asset(s) for the requested timestamp (rounded to the nearest minute).
So if you’d requested 100 rates the XRC would need to make several hundreds of HTTPS outcalls (as most exchanges public APIs would only let you query one rate at a time). This would be both very expensive and might result in timeouts (the more outcalls - the higher the chance of timeouts).

Could you share some info on the use case? Why would you need so many rates for a single timestamp?
It might be that there are other solutions for the specific use case…

Best regards,

1 Like is providing something like that (in one call), but it decides which prices to collect from the XRC canister.