Skip to content

Commit

Permalink
(govern) chore: improve votes accuracy, hide epoch section
Browse files Browse the repository at this point in the history
  • Loading branch information
Tanya-atatakai committed Nov 28, 2024
1 parent 6d23740 commit 2b936ba
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 12 deletions.
16 changes: 13 additions & 3 deletions apps/govern/components/Contracts/ContractsList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,13 @@ const getColumns = ({
dataIndex: 'currentWeight',
render: (currentWeight) => (
<Space size={2} direction="vertical">
<Text>{`${currentWeight?.percentage.toFixed(2)}%`}</Text>
<Text>{`${formatWeiNumber({
value: currentWeight?.percentage,
maximumFractionDigits: 3,
})}%`}</Text>
<Text type="secondary">{`${formatWeiNumber({
value: currentWeight?.value,
maximumFractionDigits: 3,
})} veOLAS`}</Text>
</Space>
),
Expand All @@ -71,8 +75,14 @@ const getColumns = ({
dataIndex: 'nextWeight',
render: (nextWeight) => (
<Space size={2} direction="vertical">
<Text>{`${nextWeight?.percentage.toFixed(2)}%`}</Text>
<Text type="secondary">{`${formatWeiNumber({ value: nextWeight?.value })} veOLAS`}</Text>
<Text>{`${formatWeiNumber({
value: nextWeight?.percentage,
maximumFractionDigits: 3,
})}%`}</Text>
<Text type="secondary">{`${formatWeiNumber({
value: nextWeight?.value,
maximumFractionDigits: 3,
})} veOLAS`}</Text>
</Space>
),
},
Expand Down
15 changes: 9 additions & 6 deletions apps/govern/components/Contracts/EditVotes/ConfirmModal.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { Alert, Modal, Typography } from 'antd';

import { MAX_ALLOCATED_POWER } from './utils';
import { formatWeiNumber } from 'libs/util-functions/src';

const { Paragraph } = Typography;

Expand Down Expand Up @@ -30,9 +31,10 @@ export const ConfirmModal = ({
confirmLoading={isLoading}
>
<Paragraph>
{`You're allocating ${parseFloat(
(allocatedPower / 100).toFixed(2),
)}% of your voting power to ${allocationsLength} staking contracts.`}
{`You're allocating ${formatWeiNumber({
value: allocatedPower / 100,
maximumFractionDigits: 3,
})}% of your voting power to ${allocationsLength} staking contracts.`}
</Paragraph>
<Paragraph>
{`After you confirm, you'll enter a 10 day cooldown period. You won't be able to update your weights during that time.`}
Expand All @@ -42,9 +44,10 @@ export const ConfirmModal = ({
<Alert
// TODO: add blue info alerts as in Pearl
className="mb-16"
message={`${parseFloat(
((MAX_ALLOCATED_POWER - allocatedPower) / 100).toFixed(2),
)}% of your voting power is unallocated - this will be applied to the Rollover Pool and may be used in future epochs.`}
message={`${formatWeiNumber({
value: (MAX_ALLOCATED_POWER - allocatedPower) / 100,
maximumFractionDigits: 3,
})}% of your voting power is unallocated - this will be applied to the Rollover Pool and may be used in future epochs.`}
showIcon
/>
)}
Expand Down
7 changes: 6 additions & 1 deletion apps/govern/components/Contracts/EditVotes/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import {
checkNoRemovedNominees,
checkNotNegativeSlope,
} from './validations';
import { formatWeiNumber } from 'libs/util-functions/src';

const { Paragraph, Text } = Typography;

Expand Down Expand Up @@ -72,6 +73,7 @@ const getColumns = (
step={0.01}
controls={false}
value={allocations[index].weight}
precision={3}
status={isError ? 'error' : undefined}
onChange={(value) => {
if (typeof value === 'number') {
Expand Down Expand Up @@ -190,7 +192,10 @@ export const EditVotes = ({ allocations, setAllocations, setIsUpdating }: EditVo
});
}, [account, allocations, dispatch, stakingContracts, allocatedPower, userVotes, setIsUpdating]);

const totalAllocatedPower = parseFloat((allocatedPower / 100).toFixed(2));
const totalAllocatedPower = formatWeiNumber({
value: allocatedPower / 100,
maximumFractionDigits: 3,
});

return (
<>
Expand Down
5 changes: 3 additions & 2 deletions apps/govern/components/Donate/index.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* eslint-disable @typescript-eslint/no-unused-vars */
import { Alert, Button, Card, Skeleton, Typography } from 'antd';
import { ethers } from 'ethers';
import isNumber from 'lodash/isNumber';
Expand Down Expand Up @@ -169,7 +170,7 @@ export const DonatePage = () => {
<DonateForm isLoading={isDonationLoading} onSubmit={onDepositServiceDonationSubmit} />
</Card>

<Card className="last-epoch-section">
{/* <Card className="last-epoch-section">
<Title level={2} className="mt-0">
Epoch Status
</Title>
Expand Down Expand Up @@ -197,7 +198,7 @@ export const DonatePage = () => {
</Button>
<Text type="secondary">New epochs must be manually triggered by community members</Text>
</EpochCheckpointRow>
</Card>
</Card> */}
</DonateContainer>
);
};

0 comments on commit 2b936ba

Please sign in to comment.