Skip to content

Commit

Permalink
CU-86a5p8cv0 - NEON2 - Upgrade to new Flamingo APIs
Browse files Browse the repository at this point in the history
  • Loading branch information
dustr94 committed Nov 24, 2024
1 parent 0c17ecb commit 9d5bc89
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions app/actions/pricesActions.js
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ async function getPrices(useFallbackApi = false) {
async function getPricesFromFlamingo() {
const settings = await getSettings()
const { currency } = settings
const EXCHANGE_RATE_URL = `https://api.flamingo.finance/fiat/exchange-rate?pair=USD_${currency.toUpperCase()}`
const EXCHANGE_RATE_URL = `https://neo-api.b-cdn.net/flamingo/live-data/fiat-exchange-rate/USD_${currency.toUpperCase()}`
let exchangeRate = 1

if (currency !== 'usd') {
Expand All @@ -143,13 +143,17 @@ async function getPricesFromFlamingo() {

// Because all pairs are returned in their USD value
// we first check the exchange rate for all currency other than USD
const url = 'https://api.flamingo.finance/token-info/prices'
const url = 'https://neo-api.b-cdn.net/flamingo/live-data/prices/latest'
const results = await axios.get(url).catch(error => {
console.error(`Unable to retrieve prices from the api ${url}`, error)
return undefined
})
if (!results) return {}
return results.data.reduce((accum, curr) => {
if (curr.symbol === 'bNEO') {
accum.NEO = curr.usd_price * exchangeRate
}

accum[curr.symbol] = curr.usd_price * exchangeRate
return accum
}, {})
Expand Down

0 comments on commit 9d5bc89

Please sign in to comment.