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 all 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>(
env.subgraph.protocolMetrics,
`{
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
45 changes: 16 additions & 29 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,41 @@ 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.ramos,
`{
metrics {
treasuryPriceIndexUSD
templePriceUSD
spotPrice
}
}`
);

const {data: tpiData } = await fetchGenericSubgraph<any>(
env.subgraph.templeV2,
`{
tpiOracles {
currentTpi
}
}`
);
setMetrics({
price: parseFloat(ramosData.metrics[0].templePriceUSD),
tpi: parseFloat(ramosData.metrics[0].treasuryPriceIndexUSD),
price: parseFloat(ramosData.metrics[0].spotPrice),
tpi: parseFloat(tpiData.tpiOracles[0].currentTpi),
treasury:
parseFloat(treasuryData.metrics[0].treasuryValueUSD) +
parseFloat(arbitrumTreasuryData.metrics[0].treasuryValueUSD),
Expand Down Expand Up @@ -227,28 +236,6 @@ const Home = ({ tlc }: { tlc?: boolean }) => {
);
};

const LegacyLinkHeader = styled.div`
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

These are unrelated. I just noticed they weren't in use any longer.

position: absolute;
width: 100%;
display: flex;
flex-direction: row;
padding: 5px;
height: 70px;
background-color: black;
background-image: url('${footerTexture}');
background-size: cover;
border-bottom: 2px solid ${({ theme }) => theme.palette.brandDarker};
border-top: 2px solid ${({ theme }) => theme.palette.brandDarker};
font-size: 14px;
z-index: 3;
`;

const TempleLogoWrapper = styled.div`
display: flex;
justify-content: left;
width: 100%;
`;

const LaunchAppWrapper = styled.div`
display: flex;
justify-content: center;
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