fix(governance): validator tables - user staking fixes (#3533)
This commit is contained in:
parent
77582a62a8
commit
613582ee00
@ -6,6 +6,7 @@ import { usePreviousEpochQuery } from '../__generated__/PreviousEpoch';
|
|||||||
import { ValidatorTables } from './validator-tables';
|
import { ValidatorTables } from './validator-tables';
|
||||||
import { useRefreshAfterEpoch } from '../../../hooks/use-refresh-after-epoch';
|
import { useRefreshAfterEpoch } from '../../../hooks/use-refresh-after-epoch';
|
||||||
import { useVegaWallet } from '@vegaprotocol/wallet';
|
import { useVegaWallet } from '@vegaprotocol/wallet';
|
||||||
|
import { ENV } from '../../../config';
|
||||||
|
|
||||||
export const EpochData = () => {
|
export const EpochData = () => {
|
||||||
// errorPolicy due to vegaprotocol/vega issue 5898
|
// errorPolicy due to vegaprotocol/vega issue 5898
|
||||||
@ -14,11 +15,23 @@ export const EpochData = () => {
|
|||||||
data: nodesData,
|
data: nodesData,
|
||||||
error: nodesError,
|
error: nodesError,
|
||||||
loading: nodesLoading,
|
loading: nodesLoading,
|
||||||
refetch,
|
refetch: nodesRefetch,
|
||||||
} = useNodesQuery();
|
} = useNodesQuery();
|
||||||
const { data: userStakingData } = useStakingQuery({
|
|
||||||
|
const { delegationsPagination } = ENV;
|
||||||
|
const {
|
||||||
|
data: userStakingData,
|
||||||
|
error: userStakingError,
|
||||||
|
loading: userStakingLoading,
|
||||||
|
refetch: userStakingRefetch,
|
||||||
|
} = useStakingQuery({
|
||||||
variables: {
|
variables: {
|
||||||
partyId: pubKey || '',
|
partyId: pubKey || '',
|
||||||
|
delegationsPagination: delegationsPagination
|
||||||
|
? {
|
||||||
|
first: Number(delegationsPagination),
|
||||||
|
}
|
||||||
|
: undefined,
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
const { data: previousEpochData } = usePreviousEpochQuery({
|
const { data: previousEpochData } = usePreviousEpochQuery({
|
||||||
@ -28,10 +41,17 @@ export const EpochData = () => {
|
|||||||
skip: !nodesData?.epoch.id,
|
skip: !nodesData?.epoch.id,
|
||||||
});
|
});
|
||||||
|
|
||||||
useRefreshAfterEpoch(nodesData?.epoch.timestamps.expiry, refetch);
|
useRefreshAfterEpoch(nodesData?.epoch.timestamps.expiry, () => {
|
||||||
|
nodesRefetch();
|
||||||
|
userStakingRefetch();
|
||||||
|
});
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<AsyncRenderer loading={nodesLoading} error={nodesError} data={nodesData}>
|
<AsyncRenderer
|
||||||
|
loading={nodesLoading || userStakingLoading}
|
||||||
|
error={nodesError || userStakingError}
|
||||||
|
data={nodesData}
|
||||||
|
>
|
||||||
{nodesData?.epoch &&
|
{nodesData?.epoch &&
|
||||||
nodesData.epoch.timestamps.start &&
|
nodesData.epoch.timestamps.start &&
|
||||||
nodesData?.epoch.timestamps.expiry && (
|
nodesData?.epoch.timestamps.expiry && (
|
||||||
|
@ -211,7 +211,7 @@ export const ConsensusValidatorsTable = ({
|
|||||||
: undefined,
|
: undefined,
|
||||||
[ValidatorFields.PENDING_USER_STAKE]: pendingUserStake,
|
[ValidatorFields.PENDING_USER_STAKE]: pendingUserStake,
|
||||||
[ValidatorFields.USER_STAKE_SHARE]: userStakeShare
|
[ValidatorFields.USER_STAKE_SHARE]: userStakeShare
|
||||||
? stakedTotalPercentage(userStakeShare)
|
? formatNumberPercentage(new BigNumber(userStakeShare))
|
||||||
: undefined,
|
: undefined,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@ -59,9 +59,9 @@ export const addUserDataToValidator = (
|
|||||||
: undefined,
|
: undefined,
|
||||||
[ValidatorFields.USER_STAKE_SHARE]:
|
[ValidatorFields.USER_STAKE_SHARE]:
|
||||||
currentEpochUserStaking && Number(currentEpochUserStaking.amount) > 0
|
currentEpochUserStaking && Number(currentEpochUserStaking.amount) > 0
|
||||||
? new BigNumber(currentEpochUserStaking.amount).dividedBy(
|
? new BigNumber(currentEpochUserStaking.amount)
|
||||||
new BigNumber(currentUserStakeAvailable)
|
.dividedBy(new BigNumber(currentUserStakeAvailable))
|
||||||
)
|
.times(100)
|
||||||
: undefined,
|
: undefined,
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
@ -26,7 +26,11 @@ import {
|
|||||||
import type { AgGridReact } from 'ag-grid-react';
|
import type { AgGridReact } from 'ag-grid-react';
|
||||||
import type { ColDef } from 'ag-grid-community';
|
import type { ColDef } from 'ag-grid-community';
|
||||||
import type { ValidatorsTableProps } from './shared';
|
import type { ValidatorsTableProps } from './shared';
|
||||||
import { formatNumber, toBigNum } from '@vegaprotocol/utils';
|
import {
|
||||||
|
formatNumber,
|
||||||
|
formatNumberPercentage,
|
||||||
|
toBigNum,
|
||||||
|
} from '@vegaprotocol/utils';
|
||||||
|
|
||||||
interface StandbyPendingValidatorsTableProps extends ValidatorsTableProps {
|
interface StandbyPendingValidatorsTableProps extends ValidatorsTableProps {
|
||||||
stakeNeededForPromotion: string | undefined;
|
stakeNeededForPromotion: string | undefined;
|
||||||
@ -163,7 +167,7 @@ export const StandbyPendingValidatorsTable = ({
|
|||||||
: undefined,
|
: undefined,
|
||||||
[ValidatorFields.PENDING_USER_STAKE]: pendingUserStake,
|
[ValidatorFields.PENDING_USER_STAKE]: pendingUserStake,
|
||||||
[ValidatorFields.USER_STAKE_SHARE]: userStakeShare
|
[ValidatorFields.USER_STAKE_SHARE]: userStakeShare
|
||||||
? stakedTotalPercentage(userStakeShare)
|
? formatNumberPercentage(new BigNumber(userStakeShare))
|
||||||
: undefined,
|
: undefined,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user