Skip to content

Commit 03f2d00

Browse files
committed
special handling for ogv on coingecko since it is no longer present
1 parent 3494d2c commit 03f2d00

File tree

1 file changed

+14
-4
lines changed

1 file changed

+14
-4
lines changed

src/utils/coingecko.ts

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,12 @@ export async function applyCoingeckoData(
9393
const vsCurrency = props.vsCurrency || 'usd'
9494
console.log(`Found ${statsWithNoPrice.length} stats with no price`)
9595
// console.log(JSON.stringify(statsWithNoPrice.map((s) => s.id)))
96-
const coingeckoURL = `https://api.coingecko.com/api/v3/coins/${props.coinId}/market_chart?vs_currency=${vsCurrency}&days=365&interval=daily&precision=18`
96+
let conversionRate = props.coinId === 'origin-dollar-governance' ? 0.09173 : 1
97+
let urlCoinId = props.coinId
98+
if (props.coinId === 'origin-dollar-governance') {
99+
urlCoinId = 'origin-protocol'
100+
}
101+
const coingeckoURL = `https://api.coingecko.com/api/v3/coins/${urlCoinId}/market_chart?vs_currency=${vsCurrency}&days=365&interval=daily&precision=18`
97102
const coingeckoJson = await queryClient.fetchQuery({
98103
queryKey: [coingeckoURL],
99104
queryFn: async () => {
@@ -120,11 +125,16 @@ export async function applyCoingeckoData(
120125
const day = coingeckData[dayId]
121126

122127
if (stat && day.prices) {
123-
stat.tradingVolumeUSD = day.total_volumes || 0
124-
stat.marketCapUSD = day.market_caps || 0
128+
if (props.coinId === 'origin-dollar-governance') {
129+
stat.tradingVolumeUSD = 0
130+
stat.marketCapUSD = 0
131+
} else {
132+
stat.tradingVolumeUSD = day.total_volumes || 0
133+
stat.marketCapUSD = day.market_caps || 0
134+
}
125135
console.log('stat', stat)
126136
console.log('price data', day)
127-
stat.priceUSD = day.prices
137+
stat.priceUSD = day.prices * conversionRate
128138
updatedStats.push(stat)
129139
}
130140
}

0 commit comments

Comments
 (0)