Skip to content

Commit

Permalink
Merge pull request #8 from stratosnet/feat/qb-2037/change-metrics
Browse files Browse the repository at this point in the history
Feat/qb 2037/change metrics
  • Loading branch information
alexstratos authored Nov 1, 2023
2 parents 0429a67 + c561259 commit 9db7d8d
Show file tree
Hide file tree
Showing 103 changed files with 7,357 additions and 22 deletions.
565 changes: 565 additions & 0 deletions .pnp.cjs

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion apps/web-multiversx/src/graphql/useApollo/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ export function profileApi() {
return 'https://gql.mainnet.desmos.network/v1/graphql';
}

export const BIG_DIPPER_NETWORKS = 'https://raw.githubusercontent.com/forbole/big-dipper-networks/main/';
export const BIG_DIPPER_NETWORKS = 'https://raw.githubusercontent.com/stratosnet/big-dipper-networks/main/';

/**
* It creates a new Apollo Client, and sets the default options for it
Expand Down
5 changes: 5 additions & 0 deletions apps/web-stratos/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,19 @@
"@mui/icons-material": "^5.11.16",
"@mui/material": "^5.12.3",
"@socialgouv/matomo-next": "^1.6.1",
"@tanstack/react-query": "^5.0.0",
"@walletconnect/client": "^1.8.0",
"@walletconnect/encoding": "^1.0.2",
"@yarnpkg/pnpify": "^4.0.0-rc.43",
"apollo-link-rest": "^0.9.0",
"axios": "^1.5.1",
"bech32": "^2.0.0",
"big.js": "^6.2.1",
"color": "^4.2.3",
"copy-to-clipboard": "^3.3.3",
"d3-scale": "^4.0.2",
"dayjs": "^1.11.7",
"ethers": "5.7.2",
"framer-motion": "^10.12.8",
"graphql": "^16.6.0",
"graphql-ws": "^5.12.1",
Expand Down Expand Up @@ -91,6 +95,7 @@
"@testing-library/react": "^14.0.0",
"@types/big.js": "^6.1.6",
"@types/color": "^3.0.3",
"@types/d3-scale": "^4",
"@types/eslint": "^8.37.0",
"@types/esprima": "^4.0.3",
"@types/jest": "^29.5.1",
Expand Down
8 changes: 6 additions & 2 deletions apps/web-stratos/src/chain.json
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,9 @@
"tokenomics": {
"one": "#43A1BE",
"two": "#E3BB55",
"three": "#20D292"
"three": "#20D292",
"four": "#2070D2",
"five": "#C220D2"
},
"condition": {
"zero": "#E6E6E6",
Expand Down Expand Up @@ -152,7 +154,9 @@
"tokenomics": {
"one": "#2FB6E0",
"two": "#FFC93D",
"three": "#20D494"
"three": "#20D494",
"four": "#2070D2",
"five": "#C220D2"
},
"condition": {
"zero": "#E6E6E6",
Expand Down
40 changes: 40 additions & 0 deletions apps/web-stratos/src/components/nav/components/title_bar/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
import Typography from '@mui/material/Typography';
import useAppTranslation from '@/hooks/useAppTranslation';
import { FC } from 'react';
import { useRecoilValue } from 'recoil';
import ChainIcon from '@/components/ChainIcon';
import useStyles from '@/components/nav/components/title_bar/styles';
import { useFormatMarket } from '@/components/nav/components/title_bar/utils';
import { readMarket } from '@/recoil/market';

type TitleBarProps = {
className?: string;
title: string;
};

const TitleBar: FC<TitleBarProps> = ({ className, title }) => {
const { t } = useAppTranslation('common');
const { classes, cx } = useStyles();
const marketState = useRecoilValue(readMarket);

const market = useFormatMarket(marketState);

return (
<div className={cx(classes.root, className)}>
{!title && <ChainIcon type="logo" className={classes.logo} alt="logo" />}
{!!title && <Typography variant="h1">{title}</Typography>}
<div className={classes.content}>
{market.map((x) => (
<div key={x.key} className={classes.item}>
<Typography variant="body1" className="label">
{t(x.key)}
</Typography>
<Typography variant="body1">{x.data}</Typography>
</div>
))}
</div>
</div>
);
};

export default TitleBar;
59 changes: 59 additions & 0 deletions apps/web-stratos/src/components/nav/components/title_bar/utils.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
import numeral from 'numeral';
import chainConfig from '@/chainConfig';
import { type AtomState } from '@/recoil/market';
import { formatNumber } from '@/utils/format_token';
import { useTokenomics } from '@/screens/home/components/tokenomics/hooks';
import { prettyFormat } from '@/screens/home/components/tokenomics/utils';

const { primaryTokenUnit, tokenUnits } = chainConfig();

export const useFormatMarket = (data: AtomState) => {
const { data: tokenomics } = useTokenomics();
const exludedItems = [null, 0];
const marketCap = exludedItems.includes(data.marketCap)
? 'N/A'
: `$${formatNumber(data.marketCap?.toString() ?? '', 2)}`;

const miningReward = tokenomics?.miningReward
? `${prettyFormat(tokenomics?.miningReward, 18, 0)} ${tokenUnits[
primaryTokenUnit
].display.toUpperCase()}/epoch`
: 'N/A';

const apr =
tokenomics?.miningReward && tokenomics?.bonded
? `${prettyFormat(
tokenomics?.miningReward
.mul(6 * 24 * 365)
.mul(1_000_000)
.div(tokenomics?.bonded),
4,
2
)}%`
: 'N/A';

return [
{
key: 'marketCap',
data: marketCap,
},
{
key: 'miningReward',
data: miningReward,
},
{
key: 'apr',
data: apr,
},
{
key: 'supply',
data: `${formatNumber(data.supply.value, 2)} ${data.supply.displayDenom.toUpperCase()}`,
},
{
key: 'communityPool',
data: `${numeral(data.communityPool.value).format(
'0,0.00'
)} ${data.communityPool.displayDenom.toUpperCase()}`,
},
];
};
18 changes: 18 additions & 0 deletions apps/web-stratos/src/pages/withGetServerSideProps.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import { GetServerSidePropsContext } from 'next';
import { UserConfig } from 'next-i18next';
import { serverSideTranslations } from 'next-i18next/serverSideTranslations';

function withGetServerSideProps(nextI18NextConfig: UserConfig, ...namespacesRequired: string[]) {
const namespaceForApp = process.env.NEXT_PUBLIC_APP_NAME ?? '';
return async ({ locale }: GetServerSidePropsContext) => ({
props: {
...(await serverSideTranslations(
locale || 'en',
['common', namespaceForApp, ...namespacesRequired],
nextI18NextConfig
)),
},
});
}

export default withGetServerSideProps;
27 changes: 27 additions & 0 deletions apps/web-stratos/src/pages/withGetStaticProps.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import { GetStaticPropsContext } from 'next';
import { UserConfig } from 'next-i18next';
import { serverSideTranslations } from 'next-i18next/serverSideTranslations';
import { dehydrate, QueryClient } from '@tanstack/react-query';
import { getMetrics } from '@/screens/home/components/tokenomics/queries';

function withGetStaticProps(nextI18NextConfig: UserConfig, ...namespacesRequired: string[]) {
const namespaceForApp = process.env.NEXT_PUBLIC_APP_NAME ?? '';

return async ({ locale }: GetStaticPropsContext) => {
const queryClient = new QueryClient();
const dehydratedState = dehydrate(queryClient);
await queryClient.prefetchQuery({ queryKey: ['metrics'], queryFn: getMetrics });
return {
props: {
dehydratedState,
...(await serverSideTranslations(
locale || 'en',
['common', namespaceForApp, ...namespacesRequired],
nextI18NextConfig
)),
},
};
};
}

export default withGetStaticProps;
Loading

0 comments on commit 9db7d8d

Please sign in to comment.