Skip to content

Commit

Permalink
Merge pull request #56 from ar-io/develop
Browse files Browse the repository at this point in the history
Deploy to Production
  • Loading branch information
kunstmusik authored Jul 24, 2024
2 parents 5d6d934 + 7d59e32 commit 665eed9
Show file tree
Hide file tree
Showing 2 changed files with 76 additions and 14 deletions.
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

0 comments on commit 665eed9

Please sign in to comment.