Skip to content

Commit

Permalink
fix lyra price retrieval
Browse files Browse the repository at this point in the history
  • Loading branch information
ethboi committed Apr 2, 2023
1 parent c305145 commit 77c6a3b
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 9 deletions.
1 change: 1 addition & 0 deletions app/src/constants/contractAddresses.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ export const LYRA_TOKENS = {
STKLYRA_ARB: '0x5b237ab26ced47fb8ed104671819c801aa5ba45e',
}

export const LYRA_OP = '0x50c5725949a6f0c72e6c4a641f24049a917db0cb'
export const ETH_OP = '0x4200000000000000000000000000000000000006'
export const BTC_OP = '0x68f180fcce6836688e9084f035309e29bf0a2095'

Expand Down
21 changes: 12 additions & 9 deletions app/src/integrations/prices.ts
Original file line number Diff line number Diff line change
@@ -1,29 +1,32 @@
import axios from 'axios'
import { ETH_OP, BTC_OP, LYRA_TOKENS } from '../constants/contractAddresses'
import { ETH_OP, BTC_OP, LYRA_OP } from '../constants/contractAddresses'
import { urls } from '../constants/urls'
import { Dexscreener } from '../types/dexscreener'

export async function GetPrices(): Promise<void> {
try {
const addresses = [ETH_OP, BTC_OP, LYRA_TOKENS.LYRA_OP]
const dexscreenerData = (await axios.get(`${urls.dexscreenerUrl}${addresses.join(',')}`)).data as Dexscreener
console.log(dexscreenerData)
addresses.map((address) => {
const addresses = [LYRA_OP, ETH_OP, BTC_OP]
addresses.map(async (address) => {
const dexscreenerData = (await axios.get(`${urls.dexscreenerUrl}${address}`)).data as Dexscreener
const pair = dexscreenerData.pairs.find((pair) => pair.baseToken.address.toLowerCase() == address.toLowerCase())
if (pair) {
if (address.toLowerCase() == ETH_OP) {
if (address.toLowerCase() == ETH_OP.toLowerCase()) {
global.ETH_PRICE = Number(pair.priceUsd)
global.ETH_24HR = Number(pair.priceChange.h24)
//console.log(`New ETH PRICE: ${global.ETH_PRICE}`)
}
if (address.toLowerCase() == BTC_OP) {
if (address.toLowerCase() == BTC_OP.toLowerCase()) {
global.BTC_PRICE = Number(pair.priceUsd)
global.BTC_24HR = Number(pair.priceChange.h24)
//console.log(`New BTC PRICE: ${global.BTC_PRICE}`)
}
if (address.toLowerCase() == LYRA_TOKENS.LYRA_OP) {
if (address.toLowerCase() == LYRA_OP.toLowerCase()) {
global.LYRA_PRICE = Number(pair.priceUsd)
//console.log(`LYRA: ${global.LYRA_PRICE}`)
global.LYRA_24HR = Number(pair.priceChange.h24)
//console.log(`New LYRA PRICE: ${global.LYRA_PRICE}`)
}
} else {
console.log(`Pair not found: ${address.toLowerCase()}`)
}
})
} catch (error) {
Expand Down

0 comments on commit 77c6a3b

Please sign in to comment.