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

Deploy to Production #56

Merged
merged 2 commits into from
Jul 24, 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
42 changes: 34 additions & 8 deletions src/pages/Gateways/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,9 @@ interface TableData {
operatorStake: number; // IO
totalStake: number; // IO
status: string;
rewardRatio: number;
performance: number;
passedEpochCount: number;
totalEpochCount: number;
streak: number;
}

Expand All @@ -36,6 +38,10 @@ const Gateways = () => {
useEffect(() => {
const tableData: Array<TableData> = Object.entries(gateways ?? {}).reduce(
(acc: Array<TableData>, [owner, gateway]) => {

const passedEpochCount = gateway.stats.passedEpochCount;
const totalEpochCount = (gateway.stats as any).totalEpochCount;

return [
...acc,
{
Expand All @@ -53,9 +59,12 @@ const Gateways = () => {
.toIO()
.valueOf(),
status: gateway.status,
rewardRatio: gateway.settings.allowDelegatedStaking
? gateway.settings.delegateRewardShareRatio
: -1,
performance:
totalEpochCount > 0
? passedEpochCount / totalEpochCount
: -1,
passedEpochCount,
totalEpochCount,
streak:
gateway.stats.failedConsecutiveEpochs > 0
? -gateway.stats.failedConsecutiveEpochs
Expand Down Expand Up @@ -134,12 +143,29 @@ const Gateways = () => {
header: 'Status',
sortDescFirst: false,
}),
columnHelper.accessor('rewardRatio', {
id: 'rewardRatio',
header: 'Reward Share Ratio',
columnHelper.accessor('performance', {
id: 'performance',
header: 'Performance',
sortDescFirst: true,
cell: ({ row }) =>
row.original.rewardRatio >= 0 ? `${row.original.rewardRatio}%` : 'N/A',
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',
Expand Down
48 changes: 42 additions & 6 deletions src/pages/Staking/DelegateStakeTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,10 @@ interface TableData {
domain: string;
owner: string;
failedConsecutiveEpochs: number;
rewardRatio: number;
rewardShareRatio: number;
performance: number;
passedEpochCount: number;
totalEpochCount: number;
totalDelegatedStake: number;
totalStake: number;
operatorStake: number;
Expand Down Expand Up @@ -55,6 +58,9 @@ const DelegateStake = () => {
? []
: Object.entries(gateways).reduce((acc, [owner, gateway]) => {
if (gateway.settings.allowDelegatedStaking) {
const passedEpochCount = gateway.stats.passedEpochCount;
const totalEpochCount = (gateway.stats as any).totalEpochCount;

return [
...acc,
{
Expand All @@ -63,8 +69,13 @@ const DelegateStake = () => {
owner,
failedConsecutiveEpochs:
gateway.stats.failedConsecutiveEpochs,
rewardRatio: gateway.settings.delegateRewardShareRatio,

rewardShareRatio: gateway.settings.allowDelegatedStaking
? gateway.settings.delegateRewardShareRatio
: -1,
performance: totalEpochCount > 0 ? gateway.stats.passedEpochCount / totalEpochCount : -1,
passedEpochCount,
totalEpochCount,
totalDelegatedStake: new mIOToken(gateway.totalDelegatedStake)
.toIO()
.valueOf(),
Expand Down Expand Up @@ -142,16 +153,41 @@ const DelegateStake = () => {
</Tooltip>
),
}),
columnHelper.accessor('rewardShareRatio', {
id: 'rewardShareRatio',
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('rewardRatio', {
id: 'rewardRatio',
header: 'Reward Share Ratio',
columnHelper.accessor('performance', {
id: 'performance',
header: 'Performance',
sortDescFirst: true,
cell: ({ row }) => `${row.original.rewardRatio}%`,
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('eay', {
id: 'eay',
Expand Down
Loading