-
Notifications
You must be signed in to change notification settings - Fork 5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Update Balanc3 API #5744
Update Balanc3 API #5744
Conversation
const query = pairs.join('&') | ||
if (this._tokens.length > 0) { | ||
try { | ||
const response = await fetch(`https://exchanges.demo.balanc3.net/pie?${query}&autoConversion=true`) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What's the demo part of this URL? Is this a temporary API?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looking at #5741 (comment) we should be able to drop it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good! Just one minor comment and I also think @whymarrh has a point about the url, unless we're both missing some context.
if (!token) return log.error(`TokenRatesController - invalid tokens state:\n${JSON.stringify(tokens, null, 2)}`) | ||
const address = token.address | ||
contractExchangeRates[address] = await this.fetchExchangeRate(address) | ||
const pairs = this._tokens.map(token => `pairs[]=${token.address}/ETH`) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not a 100% sure about this but since we support any base currency now (under settings). Shouldn't we use the selected currency instead of hardcoding ETH?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch. Looks like our token pricing has been broken since we landed that functionality (if the user changed their native currency from ETH.)
Thanks for the quick review @brunobar79 and @whymarrh. It's a little worrisome to me that token rates were seemingly broken if a user changed their native currency. I verified a few places in the UI and it does look like the |
This pull request updates the Balanc3 URL used by the TokenRatesController to fetch token-to-ETH exchange rates. The controller now uses a bulk pricing endpoint that allows all exchange rates to be fetched in a single HTTP request.
Resolves #5741
Resolves #5062