From b6148d99036e963454b7fec943c8d76e9085b6fd Mon Sep 17 00:00:00 2001 From: Xeonus Date: Tue, 17 Feb 2026 14:17:38 +0100 Subject: [PATCH] Fix: API-v3 and RPC endpoints --- .../graphql-balancer-v3-codegen-generated.ts | 9 ++- .../Tables/AuraPoolLeaderboardTable/index.tsx | 3 +- .../Tables/AuraPoolStakerTable/index.tsx | 3 +- src/components/Tables/LockerTable/index.tsx | 3 +- src/constants/networks.ts | 19 +++++ .../VotingIncentives/useGetEmissionPerVote.ts | 3 +- .../balancer-api-v3/BalancerV3ApiQueries.gql | 14 +--- .../useGetSimpleTokenPrices.ts | 14 ++-- .../useGetTokenPriceWithChange.ts | 36 +++++++++ src/data/balancer/useDecorateL1Gauges.ts | 6 +- src/data/balancer/useTokens.ts | 76 +++++-------------- src/pages/AuraBAL/index.tsx | 3 +- src/pages/AuraLocks/index.tsx | 3 +- src/pages/Emissions/index.tsx | 4 +- src/pages/Financials/index.tsx | 3 +- src/pages/IncentiveSimulator/index.tsx | 4 +- src/pages/Protocol/index.tsx | 3 +- src/utils/getProtocolFeeCollectorTokens.ts | 3 +- 18 files changed, 112 insertions(+), 97 deletions(-) create mode 100644 src/data/balancer-api-v3/useGetTokenPriceWithChange.ts diff --git a/src/apollo/generated/graphql-balancer-v3-codegen-generated.ts b/src/apollo/generated/graphql-balancer-v3-codegen-generated.ts index 8100f37..3379661 100644 --- a/src/apollo/generated/graphql-balancer-v3-codegen-generated.ts +++ b/src/apollo/generated/graphql-balancer-v3-codegen-generated.ts @@ -15856,7 +15856,7 @@ export type GetTokenPriceQuery = { }; export type TokenGetCurrentPricesQueryVariables = Exact<{ - chains?: InputMaybe | GqlChain>; + chains: Array | GqlChain; }>; export type TokenGetCurrentPricesQuery = { @@ -15871,6 +15871,7 @@ export type TokenGetCurrentPricesQuery = { export type GetDynamicTokenPricesQueryVariables = Exact<{ addresses: Array | Scalars["String"]["input"]; + chain: GqlChain; }>; export type GetDynamicTokenPricesQuery = { @@ -17588,7 +17589,7 @@ export type GetTokenPriceQueryResult = Apollo.QueryResult< GetTokenPriceQueryVariables >; export const TokenGetCurrentPricesDocument = gql` - query TokenGetCurrentPrices($chains: [GqlChain!]) { + query TokenGetCurrentPrices($chains: [GqlChain!]!) { tokenGetCurrentPrices(chains: $chains) { address chain @@ -17648,8 +17649,8 @@ export type TokenGetCurrentPricesQueryResult = Apollo.QueryResult< TokenGetCurrentPricesQueryVariables >; export const GetDynamicTokenPricesDocument = gql` - query GetDynamicTokenPrices($addresses: [String!]!) { - tokenGetTokensDynamicData(addresses: $addresses) { + query GetDynamicTokenPrices($addresses: [String!]!, $chain: GqlChain!) { + tokenGetTokensDynamicData(addresses: $addresses, chain: $chain) { price tokenAddress priceChange24h diff --git a/src/components/Tables/AuraPoolLeaderboardTable/index.tsx b/src/components/Tables/AuraPoolLeaderboardTable/index.tsx index f9bbcf5..1cc10c8 100644 --- a/src/components/Tables/AuraPoolLeaderboardTable/index.tsx +++ b/src/components/Tables/AuraPoolLeaderboardTable/index.tsx @@ -24,6 +24,7 @@ import { deepPurple } from '@mui/material/colors'; import { generateIdenticon } from '../../../utils/generateIdenticon'; import {useContractRead, useEnsName} from "wagmi"; import {ethers} from "ethers"; +import {DRPC_ETHEREUM_URL} from "../../../data/balancer/constants"; import isDev from "../../../constants"; import StyledTableCell from "../StyledTableCell"; @@ -187,7 +188,7 @@ export default function AuraPoolLeaderboardTable({ leaderboardInfo }: React.useEffect(() => { if (leaderboardInfo && leaderboardInfo.leaderboard.length > 0) { - const provider = new ethers.providers.JsonRpcProvider('https://eth.llamarpc.com'); + const provider = new ethers.providers.JsonRpcProvider(DRPC_ETHEREUM_URL); const updateENSMap = async () => { const ensLocalMap = { ...localEnsMap }; diff --git a/src/components/Tables/AuraPoolStakerTable/index.tsx b/src/components/Tables/AuraPoolStakerTable/index.tsx index ec16244..bb0293c 100644 --- a/src/components/Tables/AuraPoolStakerTable/index.tsx +++ b/src/components/Tables/AuraPoolStakerTable/index.tsx @@ -24,6 +24,7 @@ import { deepPurple } from '@mui/material/colors'; import { generateIdenticon } from '../../../utils/generateIdenticon'; import {useContractRead, useEnsName} from "wagmi"; import {ethers} from "ethers"; +import {DRPC_ETHEREUM_URL} from "../../../data/balancer/constants"; import isDev from "../../../constants"; import StyledTableCell from "../StyledTableCell"; @@ -186,7 +187,7 @@ export default function AuraPoolStakerTable({ leaderboardInfo, pricePerBPT }: { React.useEffect(() => { if (leaderboardInfo && leaderboardInfo.leaderboard.length > 0) { - const provider = new ethers.providers.JsonRpcProvider('https://eth.llamarpc.com'); + const provider = new ethers.providers.JsonRpcProvider(DRPC_ETHEREUM_URL); const updateENSMap = async () => { const ensLocalMap = { ...localEnsMap }; diff --git a/src/components/Tables/LockerTable/index.tsx b/src/components/Tables/LockerTable/index.tsx index e5c38e9..ac3907f 100644 --- a/src/components/Tables/LockerTable/index.tsx +++ b/src/components/Tables/LockerTable/index.tsx @@ -21,6 +21,7 @@ import {formatDollarAmount, formatNumber} from "../../../utils/numbers"; import {generateIdenticon} from "../../../utils/generateIdenticon"; import {deepPurple} from "@mui/material/colors"; import {ethers} from "ethers"; +import {DRPC_ETHEREUM_URL} from "../../../data/balancer/constants"; import isDev from "../../../constants"; import StyledTableCell from "../StyledTableCell"; @@ -218,7 +219,7 @@ export default function LockerTable({ React.useEffect(() => { if (lockerAccounts && lockerAccounts.length > 0) { - const provider = new ethers.providers.JsonRpcProvider('https://eth.llamarpc.com'); + const provider = new ethers.providers.JsonRpcProvider(DRPC_ETHEREUM_URL); const updateENSMap = async () => { const ensLocalMap = { ...localEnsMap }; diff --git a/src/constants/networks.ts b/src/constants/networks.ts index 936e32f..0d16fde 100644 --- a/src/constants/networks.ts +++ b/src/constants/networks.ts @@ -252,6 +252,25 @@ export const AvalancheNetworkInfo: NetworkInfo = { blurb: 'Beta' } +/** + * Maps a NetworkInfo's chainId to the corresponding GqlChain string + * used by the Balancer V3 API. Falls back to the v3NetworkID field. + */ +const CHAIN_ID_TO_GQL_CHAIN: Record = { + '1': 'MAINNET', + '42161': 'ARBITRUM', + '137': 'POLYGON', + '100': 'GNOSIS', + '1101': 'POLYGONZKEVM', + '10': 'OPTIMISM', + '8453': 'BASE', + '43114': 'AVALANCHE', +}; + +export function chainIdToGqlChain(chainId: string): string { + return CHAIN_ID_TO_GQL_CHAIN[chainId] ?? 'MAINNET'; +} + export const SUPPORTED_NETWORK_VERSIONS: NetworkInfo[] = [ EthereumNetworkInfo, ArbitrumNetworkInfo, diff --git a/src/data/VotingIncentives/useGetEmissionPerVote.ts b/src/data/VotingIncentives/useGetEmissionPerVote.ts index c534fb9..0d786e6 100644 --- a/src/data/VotingIncentives/useGetEmissionPerVote.ts +++ b/src/data/VotingIncentives/useGetEmissionPerVote.ts @@ -13,6 +13,7 @@ import {useActiveNetworkVersion} from "../../state/application/hooks"; import useGetSimpleTokenPrices from "../balancer-api-v3/useGetSimpleTokenPrices"; import useGetHistoricalTokenPrice from "../balancer-api-v3/useGetHistoricalTokenPrice"; import {GqlChain} from "../../apollo/generated/graphql-codegen-generated"; +import {chainIdToGqlChain} from "../../constants/networks"; import {unixToDate} from "../../utils/date"; const auraAddress = AURA_TOKEN_MAINNET; @@ -27,7 +28,7 @@ export const useGetEmissionPerVote = (timestampCurrentRound: number) => { const [emissionValuePerVote, setEmissionValuePerVote] = useState(0); const [emissionsPerDollarSpent, setEmissionsPerDollarSpent] = useState(0) //const coinData = useCoinGeckoSimpleTokenPrices([auraAddress, balAddress]); - const coinData = useGetSimpleTokenPrices([auraAddress, balAddress], activeNetwork.chainId); + const coinData = useGetSimpleTokenPrices([auraAddress, balAddress], chainIdToGqlChain(activeNetwork.chainId) as GqlChain); const { data: auraCompletePrice } = useAuraPrice(); const { data: historicalBALCoinData } = useGetHistoricalTokenPrice(balAddress, GqlChain.Mainnet) const auraGlobalStats = useAuraGlobalStats(); diff --git a/src/data/balancer-api-v3/BalancerV3ApiQueries.gql b/src/data/balancer-api-v3/BalancerV3ApiQueries.gql index 2296bb9..a27e70b 100644 --- a/src/data/balancer-api-v3/BalancerV3ApiQueries.gql +++ b/src/data/balancer-api-v3/BalancerV3ApiQueries.gql @@ -21,15 +21,7 @@ query VeBalGetVotingGauges { } } -query GetTokenPrice($address: String!, $chain: GqlChain!){ - tokenGetPriceChartData(address: $address, chain: $chain, range: NINETY_DAY) - { - price - timestamp - } -} - -query TokenGetCurrentPrices($chains: [GqlChain!]) { +query TokenGetCurrentPrices($chains: [GqlChain!]!) { tokenGetCurrentPrices(chains: $chains) { address chain @@ -37,8 +29,8 @@ query TokenGetCurrentPrices($chains: [GqlChain!]) { } } -query GetDynamicTokenPrices($addresses: [String!]!) { - tokenGetTokensDynamicData(addresses: $addresses) { +query GetDynamicTokenPrices($addresses: [String!]!, $chain: GqlChain!) { + tokenGetTokensDynamicData(addresses: $addresses, chain: $chain) { price tokenAddress priceChange24h diff --git a/src/data/balancer-api-v3/useGetSimpleTokenPrices.ts b/src/data/balancer-api-v3/useGetSimpleTokenPrices.ts index 5e30fc9..000f96a 100644 --- a/src/data/balancer-api-v3/useGetSimpleTokenPrices.ts +++ b/src/data/balancer-api-v3/useGetSimpleTokenPrices.ts @@ -2,18 +2,15 @@ import { balancerV3APIClient } from "../../apollo/client"; import {TokenPrices} from "../balancer/balancerTypes"; import {useGetDynamicTokenPricesQuery} from "../../apollo/generated/graphql-balancer-v3-codegen-generated"; +import {GqlChain} from "../../apollo/generated/graphql-codegen-generated"; -export default function useGetSimpleTokenPrices(addresses: string[], chainId: string) { +export default function useGetSimpleTokenPrices(addresses: string[], chain: GqlChain) { const { data, loading, error } = useGetDynamicTokenPricesQuery({ client: balancerV3APIClient, variables: { - addresses: addresses + addresses: addresses, + chain: chain, }, - context: { - headers: { - chainId: chainId - } - } }); // Transform the array of token data into an object indexed by tokenAddress @@ -27,10 +24,9 @@ export default function useGetSimpleTokenPrices(addresses: string[], chainId: st return acc; }, {} as TokenPrices) ?? {}; - //console.log("tokenData", tokenPrices); return { loading, error, - data: tokenPrices, // Return the mapped data + data: tokenPrices, }; } diff --git a/src/data/balancer-api-v3/useGetTokenPriceWithChange.ts b/src/data/balancer-api-v3/useGetTokenPriceWithChange.ts new file mode 100644 index 0000000..998d0cf --- /dev/null +++ b/src/data/balancer-api-v3/useGetTokenPriceWithChange.ts @@ -0,0 +1,36 @@ +import { GqlChain } from "../../apollo/generated/graphql-codegen-generated"; +import { balancerV3APIClient } from "../../apollo/client"; +import { useGetDynamicTokenPricesQuery } from "../../apollo/generated/graphql-balancer-v3-codegen-generated"; +import useGetCurrentTokenPrices from "./useGetCurrentTokenPrices"; + +export interface TokenPriceWithChange { + price: number; + priceChange24h: number; // percentage +} + +export default function useGetTokenPriceWithChange( + address: string, + chain: GqlChain = "MAINNET" as GqlChain, +): TokenPriceWithChange | undefined { + const { data: currentPrices } = useGetCurrentTokenPrices([chain]); + const { data: dynamicData } = useGetDynamicTokenPricesQuery({ + client: balancerV3APIClient, + variables: { addresses: [address], chain }, + }); + + const basePrice = currentPrices?.find( + t => t.address.toLowerCase() === address.toLowerCase() + ); + if (!basePrice) return undefined; + + const dynamicToken = dynamicData?.tokenGetTokensDynamicData?.find( + d => d.tokenAddress.toLowerCase() === address.toLowerCase() + ); + + const absoluteChange = dynamicToken?.priceChange24h ?? 0; + const price24hAgo = basePrice.price - absoluteChange; + const priceChangePercent = price24hAgo !== 0 + ? (absoluteChange / price24hAgo) * 100 : 0; + + return { price: basePrice.price, priceChange24h: priceChangePercent }; +} diff --git a/src/data/balancer/useDecorateL1Gauges.ts b/src/data/balancer/useDecorateL1Gauges.ts index 8d92d1c..6f45dba 100644 --- a/src/data/balancer/useDecorateL1Gauges.ts +++ b/src/data/balancer/useDecorateL1Gauges.ts @@ -6,6 +6,7 @@ import rootGaugeL2 from "../../constants/abis/rootGaugeL2.json"; import {useEffect, useState} from "react"; import {Multicall} from 'ethereum-multicall'; import {EthereumNetworkInfo} from "../../constants/networks"; +import {DRPC_ETHEREUM_URL} from "./constants"; import {useAccount} from 'wagmi'; const useDecorateL1Gauges = (stakingGaugeData: BalancerStakingGauges[] | undefined): BalancerStakingGauges[] => { @@ -19,14 +20,13 @@ const useDecorateL1Gauges = (stakingGaugeData: BalancerStakingGauges[] | undefin if (gaugeData && gaugeData.length > 0) { const multicalls = []; - const providerUrl = 'https://eth.llamarpc.com'; const multicall = new Multicall({ - ethersProvider: new ethers.providers.JsonRpcProvider(providerUrl), + ethersProvider: new ethers.providers.JsonRpcProvider(DRPC_ETHEREUM_URL), tryAggregate: true }); const multicallRoots = new Multicall({ - ethersProvider: new ethers.providers.JsonRpcProvider('https://eth.llamarpc.com'), + ethersProvider: new ethers.providers.JsonRpcProvider(DRPC_ETHEREUM_URL), tryAggregate: true }); //Obtain mainnet gauge working and total supplies diff --git a/src/data/balancer/useTokens.ts b/src/data/balancer/useTokens.ts index 48ad1c8..21e6a13 100644 --- a/src/data/balancer/useTokens.ts +++ b/src/data/balancer/useTokens.ts @@ -12,6 +12,8 @@ import { BalancerChartDataItem, TokenData } from './balancerTypes'; import { useActiveNetworkVersion } from '../../state/application/hooks'; import { useState } from 'react'; import useGetSimpleTokenPrices from "../balancer-api-v3/useGetSimpleTokenPrices"; +import {chainIdToGqlChain} from "../../constants/networks"; +import {GqlChain} from "../../apollo/generated/graphql-codegen-generated"; import {CG_KEY} from "./constants"; //Coingecko Token price Interface @@ -78,7 +80,7 @@ export function useBalancerTokens(first = 100) { const [block24, block48, blockWeek] = blocks ?? []; const [getTokenData, { data }] = useGetTokenDataLazyQuery(); const tokenAddresses = data?.tokens.map(token => token.address) ?? []; - const { data: tokenPrices, loading: pricesLoading, error: pricesError } = useGetSimpleTokenPrices(tokenAddresses, activeNetwork.chainId); + const { data: tokenPrices, loading: pricesLoading, error: pricesError } = useGetSimpleTokenPrices(tokenAddresses, chainIdToGqlChain(activeNetwork.chainId) as GqlChain); useEffect(() => { if (block24) { @@ -154,8 +156,12 @@ export function useBalancerTokenSingleData(address: string): TokenData | null { const { blocks, error: blockError } = useBlocksFromTimestamps([t24, t48, tWeek]); const [block24, block48, blockWeek] = blocks ?? []; const [getTokenData, { data }] = useGetTokenSingleDataLazyQuery(); - const tokenAddresses: Array = []; - const [coingeckoData, setCoingeckoData] = useState(); + + // Use V3 API for real 24h price change + const { data: tokenPrices } = useGetSimpleTokenPrices( + [address], + chainIdToGqlChain(activeNetwork.chainId) as GqlChain + ); useEffect(() => { if (block24) { @@ -171,71 +177,23 @@ export function useBalancerTokenSingleData(address: string): TokenData | null { } }, [block24]); - useEffect(() => { - //V2: repopulate formatted token data with coingecko data - if (data && data.tokens.length === 1) { - data.tokens.forEach(token => { - tokenAddresses.push(token.address); - }) - - const getTokenPrices = async (addresses: string) => { - const baseURI = 'https://api.coingecko.com/api/v3/simple/token_price/'; - const queryParams = activeNetwork.coingeckoId + '?contract_addresses=' + addresses + - '&vs_currencies=usd&include_24hr_change=true' + '&x_cg_demo_api_key=' + CG_KEY; - try { - const coingeckoResponse = await fetch(baseURI + queryParams); - const json = await coingeckoResponse.json(); - //TODO: find way to append to interface object? - const spread = { - ...coingeckoData, - json - } - setCoingeckoData(json); - } catch { - console.log("Coingecko: token_price API not reachable") - } - } - const tokenAddresses1 = tokenAddresses.slice(1, 150); - const tokenAddresses2 = tokenAddresses.slice(151, 300); - //raw batch call in hook: - let addressesString1 = ''; - tokenAddresses1.forEach(el => { - addressesString1 = addressesString1 + el + ',' - }) - - getTokenPrices(addressesString1); - - let addressesString2 = ''; - tokenAddresses2.forEach(el => { - addressesString2 = addressesString2 + el + ',' - }) - - //getTokenPrices(addressesString2); - } - }, [data]); - if (!data || (data.tokens && data.tokens.length === 0)) { return null; } const { tokens, tokens24 } = data; - //const singleToken = tokens.find(t => t.address === address) - //const singleToken24 = tokens.find(t => t.address === address) - let tokenData = getTokenValues(tokens[0].address, tokens); let tokenData24 = getTokenValues(tokens[0].address, tokens24); let priceData = { price: tokens[0].latestUSDPrice ? Number(tokens[0].latestUSDPrice) : 0 }; - let priceData24 = getTokenPriceValues(tokens[0].address, tokens24); - //override: - let priceChange = 0 - if (coingeckoData && coingeckoData[tokens[0].address]) { - tokenData = getTokenValues(tokens[0].address, tokens, coingeckoData); - tokenData24 = getTokenValues(tokens[0].address, tokens24, coingeckoData); - priceData = getTokenPriceValues(tokens[0].address, tokens24, coingeckoData); - priceData24 = getTokenPriceValues(tokens[0].address, tokens24, coingeckoData); - priceChange = coingeckoData[tokens[0].address].usd_24h_change; + + // Override with V3 API price data if available + let priceChange = 0; + if (tokenPrices && tokenPrices[tokens[0].address]) { + const { price, priceChangePercentage24h } = tokenPrices[tokens[0].address]; + priceData.price = price; + priceChange = priceChangePercentage24h; } const valueUSDCollected = 0; @@ -255,7 +213,7 @@ export function useBalancerTokenSingleData(address: string): TokenData | null { tvlUSDChange: (tokenData.tvl - tokenData24.tvl) / tokenData24.tvl, priceUSD: priceData.price, priceUSDChange: priceChange, - isCoingeckoPriceSource: priceChange !== 0 ? true : false, + isCoingeckoPriceSource: false, }; } diff --git a/src/pages/AuraBAL/index.tsx b/src/pages/AuraBAL/index.tsx index 0d4aed5..dd5b20d 100644 --- a/src/pages/AuraBAL/index.tsx +++ b/src/pages/AuraBAL/index.tsx @@ -34,6 +34,7 @@ import AuraBALMultiAreaChart from "../../components/Echarts/auraBAL/AuraBALMulti import {ArbitrumNetworkInfo, EthereumNetworkInfo, PolygonNetworkInfo} from "../../constants/networks"; import React from "react"; import useGetSimpleTokenPrices from "../../data/balancer-api-v3/useGetSimpleTokenPrices"; +import {GqlChain} from "../../apollo/generated/graphql-codegen-generated"; import {isMobile} from "react-device-detect"; @@ -72,7 +73,7 @@ export default function AuraBAL() { startTimeStamp = 1690495200 } //const coinData = useCoinGeckoSimpleTokenPrices([auraBALMainnet], true); - const coinData = useGetSimpleTokenPrices([auraBALMainnet], '1'); + const coinData = useGetSimpleTokenPrices([auraBALMainnet], "MAINNET" as GqlChain); //Image banner resources const auraBalBannerDark = require('../../assets/png/aurabal-dark.png'); const auraBalBannerLight = require('../../assets/png/aurabal-light.png'); diff --git a/src/pages/AuraLocks/index.tsx b/src/pages/AuraLocks/index.tsx index f219f6c..2563ed9 100644 --- a/src/pages/AuraLocks/index.tsx +++ b/src/pages/AuraLocks/index.tsx @@ -23,6 +23,7 @@ import CustomLinearProgress from "../../components/Progress/CustomLinearProgress import AuraDailyUnlocksChart from "../../components/Echarts/AuraDailyUnlocksChart"; import {useAuraGlobalStats} from "../../data/aura/useAuraGlobalStats"; import useGetSimpleTokenPrices from "../../data/balancer-api-v3/useGetSimpleTokenPrices"; +import {GqlChain} from "../../apollo/generated/graphql-codegen-generated"; import {isMobile} from "react-device-detect"; @@ -33,7 +34,7 @@ export default function AuraLocks() { const [rowsPerPage, setRowsPerPage] = React.useState(10); const lockers = useGetLeadingLockers(); //const coinData = useCoinGeckoSimpleTokenPrices([auraAddress]); - const coinData = useGetSimpleTokenPrices([auraAddress], '1'); + const coinData = useGetSimpleTokenPrices([auraAddress], "MAINNET" as GqlChain); const auraGlobalStats = useAuraGlobalStats(); let unlockAmounts: BalancerChartDataItem[] = []; let filteredChartData: ChartDataItem[] = [] diff --git a/src/pages/Emissions/index.tsx b/src/pages/Emissions/index.tsx index d527d97..da7a88d 100644 --- a/src/pages/Emissions/index.tsx +++ b/src/pages/Emissions/index.tsx @@ -27,6 +27,8 @@ import { formatPercentageAmount } from '../../utils/numbers'; import { getBalTokenAddress } from '../../data/balancer/useLatestPrices'; import { EthereumNetworkInfo } from '../../constants/networks'; import useGetSimpleTokenPrices from "../../data/balancer-api-v3/useGetSimpleTokenPrices"; +import {GqlChain} from "../../apollo/generated/graphql-codegen-generated"; +import {chainIdToGqlChain} from "../../constants/networks"; export default function Emissions() { @@ -55,7 +57,7 @@ export default function Emissions() { const balAddress = getBalTokenAddress(activeNetwork.id); //Data //const coinData = useCoinGeckoSimpleTokenPrices([balAddress]); - const coinData = useGetSimpleTokenPrices([balAddress], activeNetwork.chainId); + const coinData = useGetSimpleTokenPrices([balAddress], chainIdToGqlChain(activeNetwork.chainId) as GqlChain); const balPrice = coinData && coinData.data[balAddress] ? coinData.data[balAddress].price : 0; diff --git a/src/pages/Financials/index.tsx b/src/pages/Financials/index.tsx index b6e56e7..f500239 100644 --- a/src/pages/Financials/index.tsx +++ b/src/pages/Financials/index.tsx @@ -20,6 +20,7 @@ import {Handshake, HandshakeOutlined} from "@mui/icons-material"; import {USDC} from "../../constants"; import {useCoinGeckoSimpleTokenPrices} from "../../data/coingecko/useCoinGeckoSimpleTokenPrices"; import useGetSimpleTokenPrices from "../../data/balancer-api-v3/useGetSimpleTokenPrices"; +import {GqlChain} from "../../apollo/generated/graphql-codegen-generated"; export default function Financials() { const homeNav: NavElement = { @@ -35,7 +36,7 @@ export default function Financials() { const txnHistoryAef: TransactionHistory | null = useGetAddressTransactionsHistorically(AEF) //const coinData = useCoinGeckoSimpleTokenPrices([AURA_TOKEN_MAINNET]); - const coinData = useGetSimpleTokenPrices([AURA_TOKEN_MAINNET], '1'); + const coinData = useGetSimpleTokenPrices([AURA_TOKEN_MAINNET], "MAINNET" as GqlChain); const {totalBalances : totalBalancesTreasury} = useGetTotalBalances(TREASURY_CONFIG.treasury); const {totalBalances : totalBalancesAef} = useGetTotalBalances(AEF); diff --git a/src/pages/IncentiveSimulator/index.tsx b/src/pages/IncentiveSimulator/index.tsx index d274890..c11a6ad 100644 --- a/src/pages/IncentiveSimulator/index.tsx +++ b/src/pages/IncentiveSimulator/index.tsx @@ -43,6 +43,8 @@ import {AURA_TIMESTAMPS} from "../../data/hidden-hand/constants"; import {useGetEmissionPerVote} from "../../data/VotingIncentives/useGetEmissionPerVote"; import {AddShoppingCart, ShoppingCartCheckout} from "@mui/icons-material"; import {unixToDate} from "../../utils/date"; +import {GqlChain} from "../../apollo/generated/graphql-codegen-generated"; +import {chainIdToGqlChain} from "../../constants/networks"; import TableContainer from "@mui/material/TableContainer"; import Paper from "@mui/material/Paper"; import {useTheme} from "@mui/material/styles"; @@ -124,7 +126,7 @@ export default function BribeSimulator() { //BAL and AURA Stats //const coinData = useCoinGeckoSimpleTokenPrices([balAddress, auraAddress], true); - const coinData = useGetSimpleTokenPrices([balAddress, auraAddress], activeNetwork.chainId); + const coinData = useGetSimpleTokenPrices([balAddress, auraAddress], chainIdToGqlChain(activeNetwork.chainId) as GqlChain); const now = Math.round(new Date().getTime() / 1000); const weeklyEmissions = balEmissions.weekly(now); const totalLockedAmount = auraGlobalStats?.auraTotalLockedAmount; diff --git a/src/pages/Protocol/index.tsx b/src/pages/Protocol/index.tsx index 46c5d9e..879858c 100644 --- a/src/pages/Protocol/index.tsx +++ b/src/pages/Protocol/index.tsx @@ -20,6 +20,7 @@ import {CapturedTVL} from "../../data/aura/auraTypes"; import {ProtocolMultiLineChart} from '../../components/Echarts/ProtocolCharts/ProtocolMultiLineChart'; import useGetSimpleTokenPrices from "../../data/balancer-api-v3/useGetSimpleTokenPrices"; import {BalancerChartDataItem, TokenPrices} from "../../data/balancer/balancerTypes"; +import {GqlChain} from "../../apollo/generated/graphql-codegen-generated"; type Network = 'eth' | 'arb' | 'opt' | 'poly' | 'gnosis' | 'base' | 'zkevm' | 'avalanche'; @@ -64,7 +65,7 @@ export default function Protocol() { const auraAddress = '0xc0c293ce456ff0ed870add98a0828dd4d2903dbf'; // Hooks to fetch data - const coinData = useGetSimpleTokenPrices([auraAddress], '1'); + const coinData = useGetSimpleTokenPrices([auraAddress], "MAINNET" as GqlChain); const auraGlobalStats = useAuraGlobalStats(); const poolTransactions = { diff --git a/src/utils/getProtocolFeeCollectorTokens.ts b/src/utils/getProtocolFeeCollectorTokens.ts index acf421f..ca5cc25 100644 --- a/src/utils/getProtocolFeeCollectorTokens.ts +++ b/src/utils/getProtocolFeeCollectorTokens.ts @@ -2,9 +2,10 @@ import { useEffect, useState } from "react"; import { TokenData } from "../data/balancer/balancerTypes"; import { ethers } from "ethers"; import ERC20_INTERFACE from "../constants/abis/erc20"; +import {DRPC_ETHEREUM_URL} from "../data/balancer/constants"; const collectorAddress = '0xce88686553686da562ce7cea497ce749da109f9f'; -const mainnetProvider = new ethers.providers.InfuraProvider("homestead" ,'bd237506d816456797b7bede8375e021'); +const mainnetProvider = new ethers.providers.JsonRpcProvider(DRPC_ETHEREUM_URL); export function GetProtocolFeeTokenSet (formattedTokens: TokenData[]) { const [tokenData, setTokenData] = useState("");