-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
49 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
47 changes: 47 additions & 0 deletions
47
site/src/pages/Overview/polkadot/treasuryDetail/mythToken.jsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> | ||
} | ||
/> | ||
); | ||
} |