Closed Sadhill94 closed 2 years ago
Also, you will likely want to submit a twin PR to sync the new values in ETH and its tokens: https://github.com/X9Developers/eth-indexer/blob/master/src/main/scala/io/stakenet/eth/explorer/services/CurrencyService.scala#L25
Problem
For the feature #117 (trello ref), we would like to add more currencies. Since the dex use the block explorer to get the currency rates, we have to add these currencies in the block explorer repo first.
NB: This is not an urgent feature
Solution
After looking around in the project, i realized that by just adding a new line to the object Currency extends Enum[Currency] with the correct(recognized) currency code provided by CMC, it will make the conversion rates works.
Also seeing this api endpoint format, it kindly confirm the process to works and it shouldn't impact too much the current application state.
getPrice in CurrencyService.scala
s"v1/tools/price-conversion?id=${coinMarketCapConfig.coinID.string}&amount=1&convert=${currency.entryName}"
Result
I've aswell had a discussion with @AlexITC regarding the implementation, as he told me, he has to verify the current CMC API plan in place to see if adding more currencies won't overwhelm your calls quotas.
I've made some tests with the api payload to make sure the currencies were correct: