Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use updated templeCirculatingSupply #919

Merged
merged 4 commits into from
Dec 5, 2023
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -272,15 +272,16 @@ export default function useDashboardV2Metrics(dashboardType: DashboardType) {
};

const getTempleCirculatingSupply = async (): Promise<string> => {
const response = await fetchSubgraph<any>(
const response = await fetchGenericSubgraph<any>(
'https://api.thegraph.com/subgraphs/name/medariox/temple-metrics',
Copy link
Contributor

@pocin pocin Nov 30, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

isnt there appropriate config in the constants/env/types.ts Subgraph?

e: here https://github.com/TempleDAO/temple/blob/stage/apps/dapp/src/constants/env/production.tsx#L133

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a new subgraph, let me check with @medariox and if nothing else will add it to the config properly.

`{
protocolMetrics(first: 1, orderBy: timestamp, orderDirection: desc) {
metrics(first: 1, orderBy: timestamp, orderDirection: desc) {
templeCirculatingSupply
}
}`
);

const data = response?.data?.protocolMetrics?.[0] || {};
const data = response?.data?.metrics?.[0] || {};

return data.templeCirculatingSupply;
};
Expand Down
15 changes: 8 additions & 7 deletions apps/dapp/src/components/Pages/Core/NewUI/Home.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import { RAMOSMetrics } from './RAMOSMetrics';
import { Button } from 'components/Button/Button';
import { useEffect, useState } from 'react';
import { fetchGenericSubgraph } from 'utils/subgraph';
import env from 'constants/env';

interface Metrics {
price: number;
Expand Down Expand Up @@ -92,33 +93,33 @@ const Home = ({ tlc }: { tlc?: boolean }) => {
useEffect(() => {
const fetchMetrics = async () => {
const { data: treasuryData } = await fetchGenericSubgraph<any>(
'https://api.thegraph.com/subgraphs/name/medariox/temple-metrics',
env.subgraph.protocolMetrics,
`{
metrics {
treasuryValueUSD
}
}`
);
const { data: arbitrumTreasuryData } = await fetchGenericSubgraph<any>(
'https://api.thegraph.com/subgraphs/name/medariox/temple-metrics-arbitrum',
env.subgraph.protocolMetricsArbitrum,
`{
metrics {
treasuryValueUSD
}
}`
);
const { data: ramosData } = await fetchGenericSubgraph<any>(
'https://api.thegraph.com/subgraphs/name/templedao/templedao-ramos',
env.subgraph.protocolMetrics,
`{
metrics {
treasuryPriceIndexUSD
templePriceUSD
treasuryPriceIndex
templePrice
}
}`
);
setMetrics({
price: parseFloat(ramosData.metrics[0].templePriceUSD),
tpi: parseFloat(ramosData.metrics[0].treasuryPriceIndexUSD),
price: parseFloat(ramosData.metrics[0].templePrice),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please use the ramos subgraph for the price, see example query.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done 4d01631

tpi: parseFloat(ramosData.metrics[0].treasuryPriceIndex),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please use the templeV2 subgraph for TPI, see example query.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done 4d01631

treasury:
parseFloat(treasuryData.metrics[0].treasuryValueUSD) +
parseFloat(arbitrumTreasuryData.metrics[0].treasuryValueUSD),
Expand Down
5 changes: 4 additions & 1 deletion apps/dapp/src/constants/env/local.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,12 @@ const env: Environment = {
},
infuraId: '4cd22916292d4fb6be156454978c326b',
subgraph: {
// TODO: These need updated to the templedao organization subgraphs once they are deployed
templeCore: 'http://localhost:8000/subgraphs/name/templedao-core',
protocolMetrics: 'https://api.thegraph.com/subgraphs/name/templedao/templedao-metrics',
protocolMetrics: 'https://api.thegraph.com/subgraphs/name/medariox/temple-metrics',
protocolMetricsArbitrum: 'https://api.thegraph.com/subgraphs/name/medariox/temple-metrics-arbitrum',
balancerV2: 'https://api.thegraph.com/subgraphs/name/templedao/templedao-balancer-v2',
// TODO: Will be deprecated
ramos: 'https://api.thegraph.com/subgraphs/name/templedao/templedao-ramos',
// templeV2: 'https://api.studio.thegraph.com/query/520/v2-sepolia/version/latest',
templeV2: 'https://api.thegraph.com/subgraphs/name/medariox/v2-mainnet'
Expand Down
5 changes: 4 additions & 1 deletion apps/dapp/src/constants/env/preview.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,12 @@ const env: Environment = {
}
},
subgraph: {
// TODO: These need updated to the templedao organization subgraphs once they are deployed
templeCore: 'https://api.thegraph.com/subgraphs/name/templedao/templedao-core-goerli',
protocolMetrics: 'https://api.thegraph.com/subgraphs/name/templedao/templedao-metrics',
protocolMetrics: 'https://api.thegraph.com/subgraphs/name/medariox/temple-metrics',
protocolMetricsArbitrum: 'https://api.thegraph.com/subgraphs/name/medariox/temple-metrics-arbitrum',
balancerV2: 'https://api.thegraph.com/subgraphs/name/templedao/templedao-balancer-v2',
// TODO: Will be deprecated
ramos: 'https://api.thegraph.com/subgraphs/name/templedao/templedao-ramos',
// TODO: restore this
// templeV2: 'https://api.studio.thegraph.com/query/520/v2-sepolia/version/latest',
Expand Down
5 changes: 4 additions & 1 deletion apps/dapp/src/constants/env/production.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -135,9 +135,12 @@ const env: Environment = {
network: 1,
etherscan: 'https://etherscan.io',
subgraph: {
// TODO: These need updated to the templedao organization subgraphs once they are deployed
templeCore: 'https://api.thegraph.com/subgraphs/name/templedao/templedao-core',
protocolMetrics: 'https://api.thegraph.com/subgraphs/name/templedao/templedao-metrics',
protocolMetrics: 'https://api.thegraph.com/subgraphs/name/medariox/temple-metrics',
protocolMetricsArbitrum: 'https://api.thegraph.com/subgraphs/name/medariox/temple-metrics-arbitrum',
balancerV2: 'https://api.thegraph.com/subgraphs/name/templedao/templedao-balancer-v2',
// TODO: Will be deprecated
ramos: 'https://api.thegraph.com/subgraphs/name/templedao/templedao-ramos',
templeV2: 'https://api.thegraph.com/subgraphs/name/medariox/v2-mainnet',
// Original Balancer Subgraph
Expand Down
1 change: 1 addition & 0 deletions apps/dapp/src/constants/env/types.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
interface Subgraphs {
templeCore: string;
protocolMetrics: string;
protocolMetricsArbitrum: string;
balancerV2: string;
ramos: string;
templeV2: string;
Expand Down
Loading