Skip to content

Commit

Permalink
Update eth prices seeder
Browse files Browse the repository at this point in the history
  • Loading branch information
uditdc committed Oct 11, 2024
1 parent df1d661 commit 13da69a
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 8 deletions.
6 changes: 4 additions & 2 deletions packages/seeder/src/metrics/seedMetricsTvl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -175,9 +175,11 @@ async function loopTick(
r.status === 'fulfilled' &&
r.value.strategyAddress.toLowerCase() === strategyAddress.toLowerCase()
)
if (foundStrategyIndex === -1 || results[foundStrategyIndex].status !== 'fulfilled') continue

const shares = results[foundStrategyIndex].value.totalShares as bigint
const result = results[foundStrategyIndex]
if (foundStrategyIndex === -1 || result.status !== 'fulfilled') continue

const shares = result.value.totalShares as bigint
const sharesToUnderlying = sharesToUnderlyingList.find(
(s) => s.strategyAddress.toLowerCase() === strategyAddress.toLowerCase()
)
Expand Down
11 changes: 5 additions & 6 deletions packages/seeder/src/seedEthPricesDaily.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,6 @@ import { getPrismaClient } from './utils/prismaClient'
import { bulkUpdateDbTransactions } from './utils/seeder'

const CMC_API = 'https://pro-api.coinmarketcap.com/v1/cryptocurrency/quotes/historical'
const apiKey = process.env.CMC_API_KEY
const CMC_TOKEN_IDS = [
8100, 21535, 27566, 23782, 29035, 24277, 28476, 15060, 23177, 8085, 25147, 24760, 2396, 4039
]
const keysStr = CMC_TOKEN_IDS.join(',')

export async function seedEthPricesDaily() {
const prismaClient = getPrismaClient()
Expand All @@ -28,10 +23,14 @@ export async function seedEthPricesDaily() {
}

try {
const tokens = await prismaClient.tokens.findMany()
const cmcTokenIds = tokens.map((t) => t.cmcId)
const keysStr = cmcTokenIds.join(',')

const response = await fetch(
`${CMC_API}?id=${keysStr}&convert=eth&interval=daily&time_start=${startAt.toISOString()}&time_end=${endAt.toISOString()}`,
{
headers: { 'X-CMC_PRO_API_KEY': `${apiKey}` }
headers: { 'X-CMC_PRO_API_KEY': process.env.CMC_API_KEY! }
}
)
const payload = await response.json()
Expand Down

0 comments on commit 13da69a

Please sign in to comment.