Skip to content

Commit

Permalink
Merge pull request #251 from EveripediaNetwork/update-cmc-api
Browse files Browse the repository at this point in the history
Add SFRAXFraxtal
  • Loading branch information
Aliiiu authored May 9, 2024
2 parents 1c74fbc + 812ac59 commit 6e666d1
Show file tree
Hide file tree
Showing 17 changed files with 188 additions and 180 deletions.
2 changes: 1 addition & 1 deletion src/components/bridge/originInfo.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ const OriginInfo = ({
getSpecificBalance,
}: OriginInfoType) => {
const { data } = useGetIqPriceQuery('IQ')
const exchangeRate = +data?.response?.data?.IQ[0]?.quote?.USD?.price || 0.0
const exchangeRate = +data?.response?.[0]?.quote?.USD?.price || 0.0

return (
<Flex p="3" pr="5" rounded="lg" border="solid 1px" borderColor="divider">
Expand Down
2 changes: 1 addition & 1 deletion src/components/client/BridgePage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ const BridgePage = () => {
const { chain } = useNetwork()
const chainId = parseInt(config.chainId)
const { data } = useGetIqPriceQuery('IQ')
const exchangeRate = data?.response?.data?.IQ[0]?.quote?.USD?.price || 0.0
const exchangeRate = data?.response?.[0]?.quote?.USD?.price || 0.0
const inputRef = useRef<HTMLInputElement>(null)
const {
iqBalanceOnEth,
Expand Down
2 changes: 1 addition & 1 deletion src/components/client/StakePage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ const StakePage = () => {
const chainId = parseInt(config.chainId)
const { switchNetwork, isSuccess } = useSwitchNetwork()
const { data: iqData } = useGetIqPriceQuery('IQ')
const exchangeRate = iqData?.response?.data?.IQ[0]?.quote?.USD?.price || 0.0
const exchangeRate = iqData?.response?.[0]?.quote?.USD?.price || 0.0
const resetValues = () => {
setIsProcessingUnlock(false)
setTrxHash(undefined)
Expand Down
75 changes: 39 additions & 36 deletions src/components/client/StatsPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -129,43 +129,46 @@ const StatsPage = () => {
body="The numbers behind the IQ ecosystem."
/>
<SimpleGrid columns={{ base: 1, md: 2 }} spacingY="6" spacingX="30">
{Object.entries(STATS).map(([group, val]) => (
<Flex direction="column" key={group}>
<Text color="brandText" fontSize="md" fontWeight="medium">
{group}
</Text>
<Divider mt="1.5" mb="4" />
<Stack spacing="6">
{val.items.map((item, id) => (
<Flex key={id} align="center" gap="4">
{item.icon && (
<Flex alignItems="center" justifyContent="center">
<item.icon boxSize="6" />
{Object.entries(STATS).map(([group, val]) => {
return (
<Flex direction="column" key={group}>
<Text color="brandText" fontSize="md" fontWeight="medium">
{group}
</Text>
<Divider mt="1.5" mb="4" />
<Stack spacing="6">
{val.items.map((item, id) => {
let valuePrefix
if (item.label !== val.omitPrefix) {
valuePrefix = val.valuePrefix
}
return (
<Flex key={id} align="center" gap="4">
{item.icon && (
<Flex alignItems="center" justifyContent="center">
<item.icon boxSize="6" />
</Flex>
)}
<Text
fontSize={{ base: 'sm', md: 'md' }}
fontWeight="medium"
>
{item.label}
</Text>
<Text
ml="auto"
fontSize={{ base: 'sm', md: 'md' }}
fontWeight="semibold"
>
{showData(item.value, valuePrefix)}
</Text>
</Flex>
)}
<Text
fontSize={{ base: 'sm', md: 'md' }}
fontWeight="medium"
>
{item.label}
</Text>
<Text
ml="auto"
fontSize={{ base: 'sm', md: 'md' }}
fontWeight="semibold"
>
{showData(
item.value,
item.label === val.omitPrefix
? undefined
: val.valuePrefix,
)}
</Text>
</Flex>
))}
</Stack>
</Flex>
))}
)
})}
</Stack>
</Flex>
)
})}
</SimpleGrid>
</Flex>
</>
Expand Down
2 changes: 1 addition & 1 deletion src/components/client/TreasuryPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ const TreasuryPage: NextPage = () => {
if (treasuryValue && treasuryGraphData) {
treasuryGraphData[treasuryGraphData.length - 1] = {
amt: treasuryValue,
name: treasuryGraphData[treasuryGraphData.length - 1].name,
name: treasuryGraphData[treasuryGraphData.length - 1]?.name,
}
}

Expand Down
3 changes: 1 addition & 2 deletions src/components/dashboard/IQButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,7 @@ import { useGetIqPriceQuery } from '@/services/iqPrice'
export const IQButton = (props: ButtonProps) => {
const SIG_FIGS = 4
const { data, isLoading, error } = useGetIqPriceQuery('IQ')

const iqPrice = data?.response?.data?.IQ[0]?.quote?.USD?.price || 0.0
const iqPrice = data?.response?.[0]?.quote?.USD?.price || 0.0
return (
<>
<Button
Expand Down
2 changes: 1 addition & 1 deletion src/components/dashboard/TreasuryGraphTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ export const TreasuryGraphTable = ({
config.treasuryHiIQAddress,
)
const { data } = useGetIqPriceQuery('IQ')
const rate = data?.response?.data?.IQ[0]?.quote?.USD?.price || 0.0
const rate = data?.response?.[0]?.quote?.USD?.price || 0.0
const [tokenData, setTokenData] = useState<TreasuryTokenType[]>([])
const [tokenDataToShow, setTokenDataToShow] = useState<TreasuryTokenType[]>(
[],
Expand Down
2 changes: 1 addition & 1 deletion src/components/lock/LockOverview.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ const LockOverview = () => {
const [holders, setHolders] = useState(0)
const [averageLockTime, setAverageLockTime] = useState(0)
const { data } = useGetIqPriceQuery('IQ')
const rate = data?.response?.data?.IQ[0]?.quote?.USD?.price || 0.0
const rate = data?.response?.[0]?.quote?.USD?.price || 0.0

useEffect(() => {
const getHiIQHolders = async () => {
Expand Down
2 changes: 1 addition & 1 deletion src/components/lock/LockedDetails.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ const LockedDetails = ({
const { data } = useWaitForTransaction({ hash: trxHash })
const { isConnected, address } = useAccount()
const { data: iqData } = useGetIqPriceQuery('IQ')
const price = iqData?.response?.data?.IQ[0]?.quote?.USD?.price || 0.0
const price = iqData?.response?.[0]?.quote?.USD?.price || 0.0
const { showToast } = useReusableToast()

useEffect(() => {
Expand Down
2 changes: 1 addition & 1 deletion src/components/wallet/use-hiiiq-balance.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ export const useHiIQBalance = (address: string | undefined | null) => {
end: new Date(Number(locked[1]) * 1000),
}
const coinGeckoIqPrice = data?.response
? +data?.response?.data?.IQ[0]?.quote?.USD?.price
? +data?.response?.[0]?.quote?.USD?.price
: 0
updateHiIQDetails({
hiiqBalance,
Expand Down
1 change: 1 addition & 0 deletions src/config/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ const config = {
ensRPC: String(process.env.NEXT_PUBLIC_ENS_RPC),
publicDomain: String(process.env.NEXT_PUBLIC_DOMAIN),
treasuryAddress: process.env.NEXT_PUBLIC_TREASURY_ADDRESS,
fraxtalTreasuryAddress: process.env.NEXT_PUBLIC_FRAX_TREASURY_ADDRESS,
eosChainId:
process.env.NEXT_PUBLIC_EOS_CHAIN_ID ||
'aca376f206b8fc25a6ed44dbdc66547c36c6c33e3a119ffbeaef943642f0e906',
Expand Down
126 changes: 6 additions & 120 deletions src/data/treasury-data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -142,19 +142,16 @@ export const TOKENS: TokensType = {
},
CVX: {
id: 'convex_cvxfpis_staked',
// image: '/images/cvxFPIS.png',
name: 'CVX',
address: '0xfa87db3eaa93b7293021e38416650d2e666bc483',
},
ENS: {
id: 'convex_cvxfpis_staked',
// image: '/images/cvxFPIS.png',
name: 'ENS',
address: '0xfa87db3eaa93b7293021e38416650d2e666bc483',
},
CRV: {
id: 'convex_cvxfpis_staked',
// image: '/images/cvxFPIS.png',
name: 'CRV',
address: '0xfa87db3eaa93b7293021e38416650d2e666bc483',
},
Expand All @@ -169,6 +166,12 @@ export const TOKENS: TokensType = {
name: 'sFRAX',
address: '0x03cb4438d015b9646d666316b617a694410c216d',
},
'sFRAX Fraxtal': {
id: 'sFRAX Fraxtal',
image: '/images/sfrax.svg',
name: 'sFRAX Fraxtal',
address: '0xfc00000000000000000000000000000000000008',
},
cvxFXS: {
id: 'cvxFXS',
image: '/images/cvxFXS.png',
Expand Down Expand Up @@ -207,32 +210,6 @@ export const TOKENS: TokensType = {

export const tokenIds = Object.values(TOKENS).map((tok) => tok.id)

// export const PIE_CHART_COLORS = {
// IQ: { light: '#FF5CAA', dark: '#FF5CAA' },
// WETH: { light: '#3182CE', dark: '#3182CE' },
// FRAX: { light: '#1A202C', dark: '#fff' },
// 'IQ-ETH Sushiswap': { light: '#4A5568', dark: '#4A5568' },
// SLP: { light: '#90CDF4', dark: '#90CDF4' },
// sfrxETH: { light: '#805AD5', dark: '#805AD5' },
// 'Frax+IQ': { light: '#093687', dark: '#093687' },
// APE: { light: '#03fa6e', dark: '#065026' },
// 'IQ-FRAX Convex': { light: '#f7d58a ', dark: '#f3bc46' },
// WBTC: { light: '#f7d58a ', dark: '#f3bc46' },
// FraxLend: { light: '#38e4ff', dark: '#14707e' },
// cvxFXS: { light: '#38a4bf', dark: '#14e07e' },
// cvxFPIS: { light: '#b1fc87', dark: '#1c4d01 ' },
// FXS: { light: '#093687', dark: '#093687' },
// HiIQ: { light: '#FFB3D7', dark: '#FFB3D7' },
// convex_cvxfpis_staked: { light: '#FFB3D7', dark: '#FFB3D7' },
// FPIS: { light: '#FFB3D7', dark: '#FFB3D7' },
// CVX: { light: '#FFB3D7', dark: '#FFB3D7' },
// ENS: { light: '#FFB3D7', dark: '#FFB3D7' },
// CRV: { light: '#FFB3D7', dark: '#FFB3D7' },
// 'FraxlendV1 - FXS/FRAX': { light: '#FFB3D7', dark: '#FFB3D7' },
// convex_personal_staked: { light: '#FFB3D7', dark: '#FFB3D7' },
// convex_cvxfxs_staked: { light: '#FFB3D7', dark: '#FFB3D7' },
// frax_lending: { light: '#FFB3D7', dark: '#FFB3D7' },
// }
export const PIE_CHART_COLORS: { light: string; dark: string }[] = [
{ light: '#FF5CAA', dark: '#FF5CAA' },
{ light: '#3182CE', dark: '#3182CE' },
Expand Down Expand Up @@ -310,94 +287,3 @@ export const chain = {
Matic: 'matic',
Frax: 'frax',
}

export const fraxLendQueryObject = {
query: `
query fraxlendArbitrumPairs {
pairs {
...fraxlendPairDetail
dailyHistory(first: 1, orderBy: timestamp, orderDirection: desc) {
id
exchangeRate
totalAssetAmount
totalAssetShare
totalCollateral
totalBorrowAmount
totalBorrowShare
totalBorrowValue
totalAssetValue
totalCollateralValue
interestPerSecond
utilization
totalFeesAmount
totalFeesShare
lastAccrued
timestamp
}
}
}
fragment fraxlendPairDetail on Pair {
address
name
symbol
oracleDivideAddress {
id
decimals
}
oracleMultiplyAddress {
id
decimals
}
maxLTV
liquidationFee
maturity
pauseStatus
lenderWhitelistActive
borrowerWhitelistActive
asset {
symbol
decimals
address
name
}
collateral {
symbol
decimals
address
name
}
rateContract {
id
rateType
rateName
interestHalfLife
minInterest
maxInterest
minUtilization
maxUtilization
maxVertexUtilization
utilizationPrecision
maxFullUtilRate
maxTargetUtil
minFullUtilRate
minTargetUtil
rateHalfLife
ratePrec
utilPrec
vertexRatePercent
vertexUtil
zeroUtilRate
}
positions(orderBy: borrowedAssetShare, orderDirection: desc) {
user {
id
}
borrowedAssetShare
depositedCollateralAmount
lentAssetShare
timestamp
}
}
`,
operationName: 'fraxlendArbitrumPairs',
}
23 changes: 15 additions & 8 deletions src/services/iqPrice/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
import { HYDRATE } from 'next-redux-wrapper'
import { createApi, fetchBaseQuery } from '@reduxjs/toolkit/query/react'

type TResponseData = {
response?: any
status: boolean
message: string
}

export const iqPriceApi = createApi({
reducerPath: 'iqPriceApi',
extractRehydrationInfo(action, { reducerPath }) {
Expand All @@ -15,15 +21,16 @@ export const iqPriceApi = createApi({
refetchOnMountOrArgChange: 60,
refetchOnFocus: true,
endpoints: (builder) => ({
getIqPrice: builder.query<
{
response?: any
status: boolean
message: string
},
string
>({
getIqPrice: builder.query<TResponseData, string>({
query: (tokenName: string) => `?tokenName=${tokenName}`,
transformResponse: (response: TResponseData, _meta, arg: string) => {
const formatedResponse = response.response?.data?.[arg]
return {
response: formatedResponse,
status: response.status,
message: response.message,
}
},
}),
}),
})
Expand Down
Loading

0 comments on commit 6e666d1

Please sign in to comment.