mirror of
https://github.com/kremalicious/asi-calculator.git
synced 2024-12-22 17:33:18 +01:00
20 lines
475 B
TypeScript
20 lines
475 B
TypeScript
'use client'
|
|
|
|
import { tokens } from '@/constants'
|
|
import { fetcher } from '@/utils'
|
|
import useSWR from 'swr'
|
|
|
|
export function usePrices(): { [key: string]: number } {
|
|
const { data: dataPrices } = useSWR(
|
|
`/api/prices/?tokens=${tokens.toString()}`,
|
|
fetcher
|
|
)
|
|
|
|
const ocean = dataPrices?.[tokens[0]]?.usd || 0
|
|
const fet = dataPrices?.[tokens[1]]?.usd || 0
|
|
const agix = dataPrices?.[tokens[2]]?.usd || 0
|
|
const asi = fet
|
|
|
|
return { ocean, fet, agix, asi }
|
|
}
|