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

Release to production #71

Merged
merged 2 commits into from
Aug 20, 2024
Merged
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
114 changes: 74 additions & 40 deletions src/pages/Staking/DelegateStakeTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,14 @@ import AddressCell from '@src/components/AddressCell';
import Button, { ButtonType } from '@src/components/Button';
import TableView from '@src/components/TableView';
import Tooltip from '@src/components/Tooltip';
import { InfoIcon } from '@src/components/icons';
import {
InfoIcon,
StreakDownArrowIcon,
StreakUpArrowIcon,
} from '@src/components/icons';
import ConnectModal from '@src/components/modals/ConnectModal';
import StakingModal from '@src/components/modals/StakingModal';
import {
EAY_TOOLTIP_FORMULA,
EAY_TOOLTIP_TEXT,
} from '@src/constants';
import { EAY_TOOLTIP_FORMULA, EAY_TOOLTIP_TEXT } from '@src/constants';
import useGateways from '@src/hooks/useGateways';
import useProtocolBalance from '@src/hooks/useProtocolBalance';
import { useGlobalState } from '@src/store';
Expand All @@ -24,7 +25,7 @@ interface TableData {
label: string;
domain: string;
owner: string;
failedConsecutiveEpochs: number;
streak: number;
rewardShareRatio: number;
performance: number;
passedEpochCount: number;
Expand Down Expand Up @@ -70,13 +71,18 @@ const DelegateStake = () => {
label: gateway.settings.label,
domain: gateway.settings.fqdn,
owner,
failedConsecutiveEpochs:
gateway.stats.failedConsecutiveEpochs,
streak:
gateway.stats.failedConsecutiveEpochs > 0
? -gateway.stats.failedConsecutiveEpochs
: gateway.stats.passedConsecutiveEpochs,

rewardShareRatio: gateway.settings.allowDelegatedStaking
? gateway.settings.delegateRewardShareRatio
: -1,
performance: totalEpochCount > 0 ? gateway.stats.passedEpochCount / totalEpochCount : -1,
performance:
totalEpochCount > 0
? gateway.stats.passedEpochCount / totalEpochCount
: -1,
passedEpochCount,
totalEpochCount,
totalDelegatedStake: new mIOToken(gateway.totalDelegatedStake)
Expand Down Expand Up @@ -121,7 +127,7 @@ const DelegateStake = () => {
href={`https://${row.getValue('domain')}`}
target="_blank"
rel="noreferrer"
onClick={(e) => e.stopPropagation()}
onClick={(e) => e.stopPropagation()}
>
{row.getValue('domain')}
</a>{' '}
Expand Down Expand Up @@ -162,37 +168,11 @@ const DelegateStake = () => {
header: 'Reward Share Ratio',
sortDescFirst: true,
cell: ({ row }) =>
row.original.rewardShareRatio >= 0 ? `${row.original.rewardShareRatio}%` : 'N/A',
}),
columnHelper.accessor('failedConsecutiveEpochs', {
id: 'failedConsecutiveEpochs',
header: 'Offline Epochs',
sortDescFirst: true,
}),
columnHelper.accessor('performance', {
id: 'performance',
header: 'Performance',
sortDescFirst: true,
cell: ({ row }) =>
row.original.performance < 0 ? (
'N/A'
) : (
<Tooltip
message={
<div>
<div>
Passed Epoch Count: {row.original.passedEpochCount}
</div>
<div className="mt-1">
Total Epoch Participation Count: {row.original.totalEpochCount}
</div>
</div>
}
>
{`${(row.original.performance * 100).toFixed(2)}%`}
</Tooltip>
),
row.original.rewardShareRatio >= 0
? `${row.original.rewardShareRatio}%`
: 'N/A',
}),

columnHelper.accessor('eay', {
id: 'eay',
header: () => (
Expand All @@ -219,6 +199,60 @@ const DelegateStake = () => {
</div>
),
}),
columnHelper.accessor('performance', {
id: 'performance',
header: 'Performance',
sortDescFirst: true,
cell: ({ row }) =>
row.original.performance < 0 ? (
'N/A'
) : (
<Tooltip
message={
<div>
<div>Passed Epoch Count: {row.original.passedEpochCount}</div>
<div className="mt-1">
Total Epoch Participation Count:{' '}
{row.original.totalEpochCount}
</div>
</div>
}
>
{`${(row.original.performance * 100).toFixed(2)}%`}
</Tooltip>
),
}),

columnHelper.accessor('streak', {
id: 'streak',
header: 'Streak',
sortDescFirst: true,
cell: ({ row }) => {
const streak = row.original.streak;
if (streak === 0) {
return '';
}

const colorClasses =
streak > 0
? 'border-streak-up/[.56] bg-streak-up/[.1] text-streak-up'
: 'border-text-red/[.56] bg-text-red/[.1] text-text-red';
const icon =
streak > 0 ? (
<StreakUpArrowIcon className="size-3" />
) : (
<StreakDownArrowIcon className="size-3" />
);

return (
<div
className={`flex w-fit items-center gap-1 rounded-xl border py-0.5 pl-[.4375rem] pr-[.5625rem] ${colorClasses}`}
>
{icon} {Math.abs(streak)}
</div>
);
},
}),

columnHelper.display({
id: 'action',
Expand Down
Loading