Skip to content

Commit

Permalink
Init TreasuryDetailMythToken, #1423
Browse files Browse the repository at this point in the history
  • Loading branch information
leocs2417 committed Nov 14, 2024
1 parent 3264bfb commit 15f3d1b
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 0 deletions.
2 changes: 2 additions & 0 deletions site/src/pages/Overview/polkadot/treasuryDetail/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import TreasuryDetailFellowship from "./fellowship";
import { mdcss, smcss } from "../../../../styles/responsive";
import TreasuryDetailLoans from "./loans";
import TreasuryDetailAssets from "./assets";
import TreasuryDetailMythToken from "./mythToken";

const Wrapper = styled(Card)`
padding: 24px;
Expand All @@ -27,6 +28,7 @@ export default function OverviewTreasuryDetail() {
<TreasuryDetailFellowship />
<TreasuryDetailLoans />
<TreasuryDetailHydration />
<TreasuryDetailMythToken />
</Wrapper>
);
}
47 changes: 47 additions & 0 deletions site/src/pages/Overview/polkadot/treasuryDetail/mythToken.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
import AssetValueDisplay from "./common/assetValueDisplay";
import AssetWrapper from "./common/assetWrapper";
import TreasuryDetailItem from "./common/item";
import BigNumber from "bignumber.js";
import { toPrecision } from "../../../../utils";
import ValueDisplay from "../../../../components/ValueDisplay";
import useAssetHubForeignAssets from "../../../../hooks/assetHub/useAssetHubForeignAssets";
import { MYTH } from "../../../../constants/foreignAssets";
import { MYTH_TOKEN_ACCOUNT } from "../../../../constants/foreignAssets";
import useFiatPrice from "../../../../hooks/useFiatPrice";

export default function TreasuryDetailMythToken() {
const mythTokenAssetsBalance = useAssetHubForeignAssets(MYTH_TOKEN_ACCOUNT);
const { price: mythTokenPrice, isLoading: isFiatPriceLoading } =
useFiatPrice("mythos");

const totalMythToken = mythTokenAssetsBalance.balance;

const total = BigNumber.sum(
BigNumber(toPrecision(totalMythToken, MYTH.decimals)).multipliedBy(
mythTokenPrice,
),
).toString();

const isLoading = isFiatPriceLoading || mythTokenAssetsBalance.isLoading;

return (
<TreasuryDetailItem
title="Myth Token"
titleTooltipContent="Airdrop & distribution of Myth tokens"
iconSrc="/imgs/data-asset-myth.svg" // TODO
content={<ValueDisplay value={total} precision={0} />}
isLoading={isLoading}
footer={
<AssetWrapper>
{/* TODO link */}
<AssetValueDisplay
value={totalMythToken}
isLoading={isLoading}
precision={MYTH.decimals}
symbol={MYTH.symbol}
/>
</AssetWrapper>
}
/>
);
}

0 comments on commit 15f3d1b

Please sign in to comment.