Skip to content

Commit

Permalink
improve operator details
Browse files Browse the repository at this point in the history
  • Loading branch information
marc-aurele-besner committed Aug 7, 2024
1 parent 08a648d commit 1ec2738
Show file tree
Hide file tree
Showing 4 changed files with 75 additions and 6 deletions.
2 changes: 1 addition & 1 deletion explorer/gql/types/staking.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5159,7 +5159,7 @@ export type OperatorByIdQueryVariables = Exact<{
}>;


export type OperatorByIdQuery = { __typename?: 'query_root', operator_by_pk?: { __typename?: 'operator', id: string, account_id: string, domain_id: string, current_epoch_rewards: any, current_total_stake: any, current_total_shares: any, minimum_nominator_stake: any, nomination_tax: number, signing_key: string, status: string, raw_status?: string | null, updated_at?: number | null, domain?: { __typename?: 'domain', id: string, sort_id: number } | null } | null };
export type OperatorByIdQuery = { __typename?: 'query_root', operator_by_pk?: { __typename?: 'operator', id: string, account_id: string, domain_id: string, bundle_count: number, current_epoch_rewards: any, current_total_stake: any, current_total_shares: any, current_storage_fee_deposit: any, minimum_nominator_stake: any, total_rewards_collected: any, total_consensus_storage_fee: any, total_domain_execution_fee: any, total_burned_balance: any, total_tax_collected: any, nomination_tax: number, signing_key: string, status: string, raw_status?: string | null, last_bundle_at: number, updated_at?: number | null, domain?: { __typename?: 'domain', id: string, sort_id: number } | null, nominators_aggregate: { __typename?: 'nominator_aggregate', aggregate?: { __typename?: 'nominator_aggregate_fields', count: number } | null }, deposits_aggregate: { __typename?: 'deposit_aggregate', aggregate?: { __typename?: 'deposit_aggregate_fields', count: number } | null }, withdrawals_aggregate: { __typename?: 'withdrawal_aggregate', aggregate?: { __typename?: 'withdrawal_aggregate_fields', count: number } | null } } | null };

export type OperatorNominatorsByIdQueryVariables = Exact<{
limit: Scalars['Int']['input'];
Expand Down
2 changes: 1 addition & 1 deletion explorer/src/components/Staking/Operator.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
'use client'

import { useConsensusData } from '@/hooks/useConsensusData'
import { Spinner } from 'components/common/Spinner'
import { NotFound } from 'components/layout/NotFound'
import { Routes } from 'constants/routes'
import type { OperatorByIdQuery, OperatorByIdQueryVariables } from 'gql/types/staking'
import { useConsensusData } from 'hooks/useConsensusData'
import useMediaQuery from 'hooks/useMediaQuery'
import { useSquidQuery } from 'hooks/useSquidQuery'
import { useWindowFocus } from 'hooks/useWindowFocus'
Expand Down
54 changes: 50 additions & 4 deletions explorer/src/components/Staking/OperatorDetailsCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import useChains from 'hooks/useChains'
import useMediaQuery from 'hooks/useMediaQuery'
import Link from 'next/link'
import { FC } from 'react'
import { bigNumberToNumber } from 'utils/number'
import { bigNumberToFormattedString } from 'utils/number'
import { operatorStatus } from 'utils/operator'
import { capitalizeFirstLetter, shortString } from 'utils/string'
import { AccountIcon } from '../common/AccountIcon'
Expand Down Expand Up @@ -69,11 +69,57 @@ export const OperatorDetailsCard: FC<Props> = ({ operator, isDesktop = false })
</CopyButton>
</StyledListItem>
<StyledListItem title='Minimum Stake'>
{bigNumberToNumber(operator.minimum_nominator_stake)} {TOKEN.symbol}
{bigNumberToFormattedString(operator.minimum_nominator_stake)} {TOKEN.symbol}
</StyledListItem>
<StyledListItem title='Nominator Tax'>{operator.nomination_tax} %</StyledListItem>
<StyledListItem title='Current Stake'>
{bigNumberToNumber(operator.current_total_stake)} {TOKEN.symbol}
<StyledListItem title='Bundle count'>{operator.bundle_count}</StyledListItem>
<StyledListItem title='Last bundle'>
<Link
className='flex gap-2 hover:text-purpleAccent'
href={INTERNAL_ROUTES.blocks.id.page(
network,
Routes.consensus,
operator.last_bundle_at,
)}
>
<div>#{operator.last_bundle_at}</div>
</Link>
</StyledListItem>
<StyledListItem title='Current total stake'>
{bigNumberToFormattedString(operator.current_total_stake)} {TOKEN.symbol}
</StyledListItem>
<StyledListItem title='Current storage fee deposits'>
{bigNumberToFormattedString(operator.current_storage_fee_deposit)} {TOKEN.symbol}
</StyledListItem>
<StyledListItem title='Total staked'>
{bigNumberToFormattedString(
BigInt(operator.current_total_stake) + BigInt(operator.current_storage_fee_deposit),
)}{' '}
{TOKEN.symbol}
</StyledListItem>
<StyledListItem title='Total rewards collected'>
{bigNumberToFormattedString(operator.total_rewards_collected)} {TOKEN.symbol}
</StyledListItem>
<StyledListItem title='Total consensus storage fee'>
{bigNumberToFormattedString(operator.total_consensus_storage_fee)} {TOKEN.symbol}
</StyledListItem>
<StyledListItem title='Total domain execution fee'>
{bigNumberToFormattedString(operator.total_domain_execution_fee)} {TOKEN.symbol}
</StyledListItem>
<StyledListItem title='Total burned balance'>
{bigNumberToFormattedString(operator.total_burned_balance)} {TOKEN.symbol}
</StyledListItem>
<StyledListItem title='Total tax collected'>
{bigNumberToFormattedString(operator.total_tax_collected)} {TOKEN.symbol}
</StyledListItem>
<StyledListItem title='Nominators count'>
{bigNumberToFormattedString(operator.nominators_aggregate.aggregate?.count ?? '0')}
</StyledListItem>
<StyledListItem title='Deposits count'>
{bigNumberToFormattedString(operator.deposits_aggregate.aggregate?.count ?? '0')}
</StyledListItem>
<StyledListItem title='Withdrawals count'>
{bigNumberToFormattedString(operator.withdrawals_aggregate.aggregate?.count ?? '0')}
</StyledListItem>
<StyledListItem title='Status'>
{capitalizeFirstLetter(operatorStatus(operator.raw_status))}
Expand Down
23 changes: 23 additions & 0 deletions explorer/src/components/Staking/staking.query.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,15 +54,38 @@ export const QUERY_OPERATOR_BY_ID = gql`
id
sort_id
}
bundle_count
current_epoch_rewards
current_total_stake
current_total_shares
current_storage_fee_deposit
minimum_nominator_stake
total_rewards_collected
total_consensus_storage_fee
total_domain_execution_fee
total_burned_balance
total_tax_collected
nomination_tax
signing_key
status
raw_status
last_bundle_at
updated_at
nominators_aggregate {
aggregate {
count
}
}
deposits_aggregate {
aggregate {
count
}
}
withdrawals_aggregate {
aggregate {
count
}
}
}
}
`
Expand Down

0 comments on commit 1ec2738

Please sign in to comment.