Skip to content

Commit

Permalink
adjust token amount by mint decimals in params view (#2297)
Browse files Browse the repository at this point in the history
  • Loading branch information
asktree committed May 10, 2024
1 parent b8503ec commit 9f5fa0d
Showing 1 changed file with 17 additions and 3 deletions.
20 changes: 17 additions & 3 deletions pages/dao/[symbol]/params/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ import { useRealmQuery } from '@hooks/queries/realm'
import { useRealmConfigQuery } from '@hooks/queries/realmConfig'
import { useRealmCommunityMintInfoQuery } from '@hooks/queries/mintInfo'
import { useRealmGovernancesQuery } from '@hooks/queries/governance'
import useFormatTokenAmount from '@hooks/useFormatTokenAmount'
import { BN } from 'bn.js'

const Params = () => {
const mint = useRealmCommunityMintInfoQuery().data?.result
Expand All @@ -48,6 +50,7 @@ const Params = () => {
const mintGovernancesWithMintInfo = assetAccounts.filter((x) => {
return x.type === AccountType.MINT
})
const formatTokenAmount = useFormatTokenAmount(realm?.account.communityMint)

const hasAuthorityGovernances = governancesArray?.filter((governance) => {
const filteredMintGovernances = mintGovernancesWithMintInfo.filter(
Expand Down Expand Up @@ -109,6 +112,7 @@ const Params = () => {
DISABLED_VOTER_WEIGHT.eq(realmConfig.minCommunityTokensToCreateGovernance)
? 'Disabled'
: realmConfig?.minCommunityTokensToCreateGovernance &&
mint &&
fmtMintAmount(mint, realmConfig.minCommunityTokensToCreateGovernance)

useEffect(() => {
Expand Down Expand Up @@ -214,12 +218,22 @@ const Params = () => {
{communityMintMaxVoteWeightSource && (
<AddressField
padding
label="Community mint max vote weight source"
label="Community max vote weight source"
val={`${
communityMintMaxVoteWeightSource.type ===
MintMaxVoteWeightSourceType.SupplyFraction
? `${communityMintMaxVoteWeightSource.fmtSupplyFractionPercentage()}%`
: fmtBNAmount(communityMintMaxVoteWeightSource.value)
? `${communityMintMaxVoteWeightSource.fmtSupplyFractionPercentage()}% of supply`
: formatTokenAmount
? fmtBNAmount(
new BN(
formatTokenAmount(
communityMintMaxVoteWeightSource.value
)
)
)
: `${fmtBNAmount(
communityMintMaxVoteWeightSource.value
)} (raw)`
}`}
/>
)}
Expand Down

0 comments on commit 9f5fa0d

Please sign in to comment.