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

chore: update status page #168

Merged
merged 2 commits into from
Aug 27, 2024
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
35 changes: 10 additions & 25 deletions src/xgov-dapp/src/features/status/InformationBox.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,33 +8,18 @@
<strong>Voting Sessions</strong>
</Typography>
<Typography>
In this version of the xGov Voting Tool, <strong>you can vote one time only</strong>. Be sure to check your vote allocation before
submitting your vote.
During the Alpha phase governors were required to vote to maintain eligibility. If you missed a vote your eligibility was revoked.
For each Voting Session, the Voting Status confirms eligibility, where: You voted = Eligible You didn't vote = Not eligible At the
end of the Term Pool, the Algos forfeited by the ineligible xGovs are distributed amongst all eligible xGovs.
</Typography>
<Typography className="mt-4 mb-3">
<strong>Maintaining your xGov eligilbility</strong>
</Typography>
<Typography>
<strong>Your xGov duty is to vote in all voting sessions during the 12 months of the Term Pool duration.</strong> That maintains
your eligibility to receive the Algo deposit (your original governance rewards) back at the end of the term pool.{' '}
</Typography>
<Typography>
<br />
<strong>You will become ineligible if fail to vote on a session.</strong> If you are stacking voting power by participating in
more than one Term Pool simultaneously, and miss a voting session, the total of Algos across all pools will be forfeited.
</Typography>
<Typography>
<br />
At the end of the Term Pool, the Algos forfeited by the ineligible xGovs will be distributed amongst all eligible xGovs.
</Typography>
<Typography className="mt-4 mb-4">
<strong>Your xGov Current Balance</strong>
</Typography>
<Typography>
Your xGov Current Balance is equal to the sum of the Governance Rewards of the periods you opted in to xGov plus your Term Pool
forfeited Algo share. It is displayed in µA (or microAlgo) because smart contracts cannot handle decimal numbers. You will receive
your Deposit, plus the forfeited Algo share, after 12 months from the commitment.

Check warning on line 15 in src/xgov-dapp/src/features/status/InformationBox.tsx

View workflow job for this annotation

GitHub Actions / xGov Dapp / node-ci

Delete `⏎`
<Typography className="my-3">
<strong>Term Pools</strong>
</Typography>
Term pools (TP) funds are held by the Algorand Foundation for 12 months from inception. Once a Term Pool matures the funds are
transferred to the original wallet used in governance or, if indicated at the time of commitment, to the governor's controller
address. The Duration column displays the creation and maturation dates for each term pool. Once a term pool matures, funds are
distributed within 14 days.
</div>
</Box>
)
Expand Down
22 changes: 13 additions & 9 deletions src/xgov-dapp/src/features/status/TermPoolsTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,11 @@ interface TermPoolsTableProps {
govenorData: GovenorTermPoolData[]
isLoading: boolean
}

// Indexes of the TermPoll which have been distributed
const DISTRIBUTED_TERM_POOLS = [0]
PhearZero marked this conversation as resolved.
Show resolved Hide resolved
function indexColor(idx: number): string {
return DISTRIBUTED_TERM_POOLS.includes(idx) ? 'bg-green-light' : 'bg-white'
}
function TermPoolsTable({ termPools, govenorData, isLoading }: TermPoolsTableProps) {
return (
<>
Expand Down Expand Up @@ -36,28 +40,28 @@ function TermPoolsTable({ termPools, govenorData, isLoading }: TermPoolsTablePro

{!isLoading &&
termPools?.length &&
termPools.map((termPool) => {
termPools.map((termPool, idx) => {
const termPoolGovenorData = govenorData.find((item) => item.pool === termPool.id)
return (
<div key={termPool.id} className="table-row invisible lg:visible">
<div className="table-cell bg-white pb-2 rounded-l-lg ">
<div className={`table-cell pb-2 rounded-l-lg ${indexColor(idx)}`}>
<div className="py-4 pl-4">{termPool.name}</div>
</div>
<div className="table-cell bg-white">
<div className={`table-cell ${indexColor(idx)}`}>
<div className="pl-2 py-4">{parseInt(termPool.total_pool).toLocaleString()} µA</div>
</div>
<div className="table-cell bg-white ">
<div className={`table-cell ${indexColor(idx)}`}>
<div className="pl-2 py-4">
{termPoolGovenorData ? parseInt(termPoolGovenorData?.original_reward).toLocaleString() : 0} µA
</div>
</div>
<div className="table-cell bg-white ">
<div className={`table-cell ${indexColor(idx)}`}>
<div className="pl-2 py-4">
{dayjs(parseInt(termPool.start_date) * 1000).format('DD-MM-YYYY')} -{' '}
{dayjs(parseInt(termPool.end_date) * 1000).format('DD-MM-YYYY')}
</div>
</div>
<div className="table-cell bg-white rounded-r-lg">
<div className={`table-cell rounded-r-lg ${indexColor(idx)}`}>
<div className="pl-2 py-4">
{termPoolGovenorData && termPoolGovenorData?.current_reward
? `${Math.floor(
Expand All @@ -75,10 +79,10 @@ function TermPoolsTable({ termPools, govenorData, isLoading }: TermPoolsTablePro
<div className="lg:hidden">
{!isLoading &&
termPools?.length &&
termPools.map((termPool) => {
termPools.map((termPool, idx) => {
const termPoolGovenorData = govenorData.find((item) => item.pool === termPool.id)
return (
<div key={termPool.id} className="grid grid-cols-3 mb-4 bg-white rounded-lg p-4 gap-2">
<div key={termPool.id} className={`grid grid-cols-3 mb-4 rounded-lg p-4 gap-2 ${indexColor(idx)}`}>
<div>
<strong>Name</strong>
</div>
Expand Down
39 changes: 0 additions & 39 deletions src/xgov-dapp/src/features/status/index.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import LaunchIcon from '@mui/icons-material/Launch'
import { Alert, Box, Button, Link as MuiLink, Skeleton, Typography } from '@mui/material'

Check warning on line 2 in src/xgov-dapp/src/features/status/index.tsx

View workflow job for this annotation

GitHub Actions / xGov Dapp / node-ci

'Skeleton' is defined but never used
import { Link } from 'react-router-dom'
import { VotingRoundGlobalState } from '../../../../dapp/src/shared/VotingRoundContract'

Expand All @@ -8,7 +8,7 @@
import { fetchVotingRoundGlobalStatesByCreators } from '../../../../dapp/src/shared/VotingRoundContract'
import { GovenorTermPoolData, TermPool, fetchGovenorData, fetchTermPools } from '../../shared/xGovApi'
import { useCreatorAddresses, useSetShowConnectWalletModal } from '../wallet/state'
import EligibilityStatus from './EligibilityStatus'

Check warning on line 11 in src/xgov-dapp/src/features/status/index.tsx

View workflow job for this annotation

GitHub Actions / xGov Dapp / node-ci

'EligibilityStatus' is defined but never used
import InformationBox from './InformationBox'
import TermPoolsTable from './TermPoolsTable'
import VotingSessionsTable from './VotingSessionsTable'
Expand Down Expand Up @@ -145,51 +145,12 @@
</div>
<div className="grid grid-cols-1 lg:grid-cols-2 gap-4">
<Box className="bg-white flex rounded-xl px-4 py-2 items-center">
<MuiLink className="no-underline hover:underline" href="https://forum.algorand.org/t/xgov-guide-post-alpha-pilot/12153" target="_blank">

Check warning on line 148 in src/xgov-dapp/src/features/status/index.tsx

View workflow job for this annotation

GitHub Actions / xGov Dapp / node-ci

Replace `·className="no-underline·hover:underline"·href="https://forum.algorand.org/t/xgov-guide-post-alpha-pilot/12153"·target="_blank"` with `⏎··············className="no-underline·hover:underline"⏎··············href="https://forum.algorand.org/t/xgov-guide-post-alpha-pilot/12153"⏎··············target="_blank"⏎············`
xGov Guide
<LaunchIcon className="ml-2 text-grey-light align-bottom" />
</MuiLink>
</Box>
</div>
<EligibilityStatus isEligible={isEligible} isLoading={isLoadingXgovData} />
{isLoadingXgovData ? (
<Skeleton className="h-40 w-full" variant="rectangular" />
) : (
<Box className="bg-white flex rounded-xl px-4 py-6">
<div className="w-full">
<Typography className="mb-3">
<strong>Your xGov Current Balance</strong>
</Typography>
<Typography variant="h3">
{govenorData.reduce((sum, item) => sum + parseInt(item.current_reward), 0).toLocaleString()} µA
</Typography>
</div>
</Box>
)}
{isLoadingXgovData ? (
<Skeleton className="h-40 w-full" variant="rectangular" />
) : (
<Box className="bg-white flex rounded-xl px-4 py-6">
<div className="w-full">
<Typography className="mb-3">
<strong>Potential earnings from xGov participation</strong>
</Typography>
<Typography variant="h3">
{govenorData
.reduce(
(prev, current) =>
prev +
(current?.current_reward
? Math.floor(Number(current?.current_reward) - parseInt(current?.original_reward)) / 1_000_000
: 0),
0,
)
.toLocaleString()}{' '}
ALGO
</Typography>
</div>
</Box>
)}
</div>
<div className="grid grid-cols-1 lg:grid-cols-3 gap-4 mt-4">
<div className="col-span-1 lg:col-span-2">
Expand Down
Loading