fix(governance): rewards decimals set per asset (#3941)
This commit is contained in:
parent
e4d4646878
commit
f5e67a0c2d
@ -8,6 +8,7 @@ const mockData = {
|
|||||||
{
|
{
|
||||||
asset: 'tDAI',
|
asset: 'tDAI',
|
||||||
totalAmount: '5',
|
totalAmount: '5',
|
||||||
|
decimals: 6,
|
||||||
rewardTypes: {
|
rewardTypes: {
|
||||||
ACCOUNT_TYPE_GLOBAL_REWARD: {
|
ACCOUNT_TYPE_GLOBAL_REWARD: {
|
||||||
amount: '0',
|
amount: '0',
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
import { formatNumber, toBigNum } from '@vegaprotocol/utils';
|
import { formatNumber, toBigNum } from '@vegaprotocol/utils';
|
||||||
import { Tooltip } from '@vegaprotocol/ui-toolkit';
|
import { Tooltip } from '@vegaprotocol/ui-toolkit';
|
||||||
import { useAppState } from '../../../contexts/app-state/app-state-context';
|
|
||||||
import {
|
import {
|
||||||
rowGridItemStyles,
|
rowGridItemStyles,
|
||||||
RewardsTable,
|
RewardsTable,
|
||||||
@ -13,7 +12,8 @@ interface EpochIndividualRewardsGridProps {
|
|||||||
}
|
}
|
||||||
|
|
||||||
interface RewardItemProps {
|
interface RewardItemProps {
|
||||||
value: string;
|
amount: string;
|
||||||
|
decimals: number;
|
||||||
percentageOfTotal?: string;
|
percentageOfTotal?: string;
|
||||||
dataTestId: string;
|
dataTestId: string;
|
||||||
last?: boolean;
|
last?: boolean;
|
||||||
@ -21,15 +21,14 @@ interface RewardItemProps {
|
|||||||
|
|
||||||
const DisplayReward = ({
|
const DisplayReward = ({
|
||||||
reward,
|
reward,
|
||||||
|
decimals,
|
||||||
percentageOfTotal,
|
percentageOfTotal,
|
||||||
}: {
|
}: {
|
||||||
reward: string;
|
reward: string;
|
||||||
|
decimals: number;
|
||||||
percentageOfTotal?: string;
|
percentageOfTotal?: string;
|
||||||
}) => {
|
}) => {
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
const {
|
|
||||||
appState: { decimals },
|
|
||||||
} = useAppState();
|
|
||||||
|
|
||||||
if (Number(reward) === 0) {
|
if (Number(reward) === 0) {
|
||||||
return <span className="text-vega-dark-300">-</span>;
|
return <span className="text-vega-dark-300">-</span>;
|
||||||
@ -64,7 +63,8 @@ const DisplayReward = ({
|
|||||||
};
|
};
|
||||||
|
|
||||||
const RewardItem = ({
|
const RewardItem = ({
|
||||||
value,
|
amount,
|
||||||
|
decimals,
|
||||||
percentageOfTotal,
|
percentageOfTotal,
|
||||||
dataTestId,
|
dataTestId,
|
||||||
last,
|
last,
|
||||||
@ -72,7 +72,11 @@ const RewardItem = ({
|
|||||||
<div data-testid={dataTestId} className={rowGridItemStyles(last)}>
|
<div data-testid={dataTestId} className={rowGridItemStyles(last)}>
|
||||||
<div className="h-full w-5 absolute right-0 top-0 bg-gradient-to-r from-transparent to-black pointer-events-none" />
|
<div className="h-full w-5 absolute right-0 top-0 bg-gradient-to-r from-transparent to-black pointer-events-none" />
|
||||||
<div className="overflow-auto p-5">
|
<div className="overflow-auto p-5">
|
||||||
<DisplayReward reward={value} percentageOfTotal={percentageOfTotal} />
|
<DisplayReward
|
||||||
|
reward={amount}
|
||||||
|
decimals={decimals}
|
||||||
|
percentageOfTotal={percentageOfTotal}
|
||||||
|
/>
|
||||||
</div>
|
</div>
|
||||||
<div className="h-full w-5 absolute left-0 top-0 bg-gradient-to-l from-transparent to-black pointer-events-none" />
|
<div className="h-full w-5 absolute left-0 top-0 bg-gradient-to-l from-transparent to-black pointer-events-none" />
|
||||||
</div>
|
</div>
|
||||||
@ -86,7 +90,7 @@ export const EpochIndividualRewardsTable = ({
|
|||||||
dataTestId="epoch-individual-rewards-table"
|
dataTestId="epoch-individual-rewards-table"
|
||||||
epoch={Number(data.epoch)}
|
epoch={Number(data.epoch)}
|
||||||
>
|
>
|
||||||
{data.rewards.map(({ asset, rewardTypes, totalAmount }, i) => (
|
{data.rewards.map(({ asset, rewardTypes, totalAmount, decimals }, i) => (
|
||||||
<div className="contents" key={i}>
|
<div className="contents" key={i}>
|
||||||
<div
|
<div
|
||||||
data-testid="individual-rewards-asset"
|
data-testid="individual-rewards-asset"
|
||||||
@ -98,13 +102,19 @@ export const EpochIndividualRewardsTable = ({
|
|||||||
([key, { amount, percentageOfTotal }]) => (
|
([key, { amount, percentageOfTotal }]) => (
|
||||||
<RewardItem
|
<RewardItem
|
||||||
key={key}
|
key={key}
|
||||||
value={amount}
|
amount={amount}
|
||||||
|
decimals={decimals}
|
||||||
percentageOfTotal={percentageOfTotal}
|
percentageOfTotal={percentageOfTotal}
|
||||||
dataTestId={key}
|
dataTestId={key}
|
||||||
/>
|
/>
|
||||||
)
|
)
|
||||||
)}
|
)}
|
||||||
<RewardItem dataTestId="total" value={totalAmount} last={true} />
|
<RewardItem
|
||||||
|
dataTestId="total"
|
||||||
|
amount={totalAmount}
|
||||||
|
decimals={decimals}
|
||||||
|
last={true}
|
||||||
|
/>
|
||||||
</div>
|
</div>
|
||||||
))}
|
))}
|
||||||
</RewardsTable>
|
</RewardsTable>
|
||||||
|
@ -8,7 +8,7 @@ describe('generateEpochIndividualRewardsList', () => {
|
|||||||
amount: '100',
|
amount: '100',
|
||||||
percentageOfTotal: '0.1',
|
percentageOfTotal: '0.1',
|
||||||
receivedAt: new Date(),
|
receivedAt: new Date(),
|
||||||
asset: { id: 'usd', symbol: 'USD', name: 'USD' },
|
asset: { id: 'usd', symbol: 'USD', name: 'USD', decimals: 6 },
|
||||||
party: { id: 'blah' },
|
party: { id: 'blah' },
|
||||||
epoch: { id: '1' },
|
epoch: { id: '1' },
|
||||||
};
|
};
|
||||||
@ -18,7 +18,7 @@ describe('generateEpochIndividualRewardsList', () => {
|
|||||||
amount: '50',
|
amount: '50',
|
||||||
percentageOfTotal: '0.05',
|
percentageOfTotal: '0.05',
|
||||||
receivedAt: new Date(),
|
receivedAt: new Date(),
|
||||||
asset: { id: 'eur', symbol: 'EUR', name: 'EUR' },
|
asset: { id: 'eur', symbol: 'EUR', name: 'EUR', decimals: 5 },
|
||||||
party: { id: 'blah' },
|
party: { id: 'blah' },
|
||||||
epoch: { id: '2' },
|
epoch: { id: '2' },
|
||||||
};
|
};
|
||||||
@ -28,7 +28,7 @@ describe('generateEpochIndividualRewardsList', () => {
|
|||||||
amount: '200',
|
amount: '200',
|
||||||
percentageOfTotal: '0.2',
|
percentageOfTotal: '0.2',
|
||||||
receivedAt: new Date(),
|
receivedAt: new Date(),
|
||||||
asset: { id: 'gbp', symbol: 'GBP', name: 'GBP' },
|
asset: { id: 'gbp', symbol: 'GBP', name: 'GBP', decimals: 7 },
|
||||||
party: { id: 'blah' },
|
party: { id: 'blah' },
|
||||||
epoch: { id: '2' },
|
epoch: { id: '2' },
|
||||||
};
|
};
|
||||||
@ -38,7 +38,7 @@ describe('generateEpochIndividualRewardsList', () => {
|
|||||||
amount: '100',
|
amount: '100',
|
||||||
percentageOfTotal: '0.1',
|
percentageOfTotal: '0.1',
|
||||||
receivedAt: new Date(),
|
receivedAt: new Date(),
|
||||||
asset: { id: 'usd', symbol: 'USD', name: 'USD' },
|
asset: { id: 'usd', symbol: 'USD', name: 'USD', decimals: 6 },
|
||||||
party: { id: 'blah' },
|
party: { id: 'blah' },
|
||||||
epoch: { id: '1' },
|
epoch: { id: '1' },
|
||||||
};
|
};
|
||||||
@ -48,7 +48,7 @@ describe('generateEpochIndividualRewardsList', () => {
|
|||||||
amount: '150',
|
amount: '150',
|
||||||
percentageOfTotal: '0.15',
|
percentageOfTotal: '0.15',
|
||||||
receivedAt: new Date(),
|
receivedAt: new Date(),
|
||||||
asset: { id: 'usd', symbol: 'USD', name: 'USD' },
|
asset: { id: 'usd', symbol: 'USD', name: 'USD', decimals: 6 },
|
||||||
party: { id: 'blah' },
|
party: { id: 'blah' },
|
||||||
epoch: { id: '3' },
|
epoch: { id: '3' },
|
||||||
};
|
};
|
||||||
@ -58,7 +58,7 @@ describe('generateEpochIndividualRewardsList', () => {
|
|||||||
amount: '50',
|
amount: '50',
|
||||||
percentageOfTotal: '0.05',
|
percentageOfTotal: '0.05',
|
||||||
receivedAt: new Date(),
|
receivedAt: new Date(),
|
||||||
asset: { id: 'eur', symbol: 'EUR', name: 'EUR' },
|
asset: { id: 'eur', symbol: 'EUR', name: 'EUR', decimals: 5 },
|
||||||
party: { id: 'blah' },
|
party: { id: 'blah' },
|
||||||
epoch: { id: '2' },
|
epoch: { id: '2' },
|
||||||
};
|
};
|
||||||
@ -99,6 +99,7 @@ describe('generateEpochIndividualRewardsList', () => {
|
|||||||
rewards: [
|
rewards: [
|
||||||
{
|
{
|
||||||
asset: 'USD',
|
asset: 'USD',
|
||||||
|
decimals: 6,
|
||||||
totalAmount: '100',
|
totalAmount: '100',
|
||||||
rewardTypes: {
|
rewardTypes: {
|
||||||
[AccountType.ACCOUNT_TYPE_FEES_INFRASTRUCTURE]: {
|
[AccountType.ACCOUNT_TYPE_FEES_INFRASTRUCTURE]: {
|
||||||
@ -167,6 +168,7 @@ describe('generateEpochIndividualRewardsList', () => {
|
|||||||
{
|
{
|
||||||
asset: 'GBP',
|
asset: 'GBP',
|
||||||
totalAmount: '200',
|
totalAmount: '200',
|
||||||
|
decimals: 7,
|
||||||
rewardTypes: {
|
rewardTypes: {
|
||||||
[AccountType.ACCOUNT_TYPE_FEES_INFRASTRUCTURE]: {
|
[AccountType.ACCOUNT_TYPE_FEES_INFRASTRUCTURE]: {
|
||||||
amount: '0',
|
amount: '0',
|
||||||
@ -197,6 +199,7 @@ describe('generateEpochIndividualRewardsList', () => {
|
|||||||
{
|
{
|
||||||
asset: 'EUR',
|
asset: 'EUR',
|
||||||
totalAmount: '50',
|
totalAmount: '50',
|
||||||
|
decimals: 5,
|
||||||
rewardTypes: {
|
rewardTypes: {
|
||||||
[AccountType.ACCOUNT_TYPE_FEES_INFRASTRUCTURE]: {
|
[AccountType.ACCOUNT_TYPE_FEES_INFRASTRUCTURE]: {
|
||||||
amount: '0',
|
amount: '0',
|
||||||
@ -232,6 +235,7 @@ describe('generateEpochIndividualRewardsList', () => {
|
|||||||
{
|
{
|
||||||
asset: 'USD',
|
asset: 'USD',
|
||||||
totalAmount: '200',
|
totalAmount: '200',
|
||||||
|
decimals: 6,
|
||||||
rewardTypes: {
|
rewardTypes: {
|
||||||
[AccountType.ACCOUNT_TYPE_FEES_INFRASTRUCTURE]: {
|
[AccountType.ACCOUNT_TYPE_FEES_INFRASTRUCTURE]: {
|
||||||
amount: '0',
|
amount: '0',
|
||||||
@ -279,6 +283,7 @@ describe('generateEpochIndividualRewardsList', () => {
|
|||||||
rewards: [
|
rewards: [
|
||||||
{
|
{
|
||||||
asset: 'USD',
|
asset: 'USD',
|
||||||
|
decimals: 6,
|
||||||
totalAmount: '150',
|
totalAmount: '150',
|
||||||
rewardTypes: {
|
rewardTypes: {
|
||||||
[AccountType.ACCOUNT_TYPE_FEES_INFRASTRUCTURE]: {
|
[AccountType.ACCOUNT_TYPE_FEES_INFRASTRUCTURE]: {
|
||||||
@ -315,6 +320,7 @@ describe('generateEpochIndividualRewardsList', () => {
|
|||||||
{
|
{
|
||||||
asset: 'GBP',
|
asset: 'GBP',
|
||||||
totalAmount: '200',
|
totalAmount: '200',
|
||||||
|
decimals: 7,
|
||||||
rewardTypes: {
|
rewardTypes: {
|
||||||
[AccountType.ACCOUNT_TYPE_FEES_INFRASTRUCTURE]: {
|
[AccountType.ACCOUNT_TYPE_FEES_INFRASTRUCTURE]: {
|
||||||
amount: '0',
|
amount: '0',
|
||||||
@ -345,6 +351,7 @@ describe('generateEpochIndividualRewardsList', () => {
|
|||||||
{
|
{
|
||||||
asset: 'EUR',
|
asset: 'EUR',
|
||||||
totalAmount: '50',
|
totalAmount: '50',
|
||||||
|
decimals: 5,
|
||||||
rewardTypes: {
|
rewardTypes: {
|
||||||
[AccountType.ACCOUNT_TYPE_FEES_INFRASTRUCTURE]: {
|
[AccountType.ACCOUNT_TYPE_FEES_INFRASTRUCTURE]: {
|
||||||
amount: '0',
|
amount: '0',
|
||||||
@ -390,6 +397,7 @@ describe('generateEpochIndividualRewardsList', () => {
|
|||||||
{
|
{
|
||||||
asset: 'USD',
|
asset: 'USD',
|
||||||
totalAmount: '200',
|
totalAmount: '200',
|
||||||
|
decimals: 6,
|
||||||
rewardTypes: {
|
rewardTypes: {
|
||||||
[AccountType.ACCOUNT_TYPE_FEES_INFRASTRUCTURE]: {
|
[AccountType.ACCOUNT_TYPE_FEES_INFRASTRUCTURE]: {
|
||||||
amount: '0',
|
amount: '0',
|
||||||
|
@ -9,6 +9,7 @@ export interface EpochIndividualReward {
|
|||||||
rewards: {
|
rewards: {
|
||||||
asset: string;
|
asset: string;
|
||||||
totalAmount: string;
|
totalAmount: string;
|
||||||
|
decimals: number;
|
||||||
rewardTypes: {
|
rewardTypes: {
|
||||||
[key in AccountType]?: {
|
[key in AccountType]?: {
|
||||||
amount: string;
|
amount: string;
|
||||||
@ -53,6 +54,7 @@ export const generateEpochIndividualRewardsList = ({
|
|||||||
const epochIndividualRewards = rewards.reduce((acc, reward) => {
|
const epochIndividualRewards = rewards.reduce((acc, reward) => {
|
||||||
const epochId = reward.epoch.id;
|
const epochId = reward.epoch.id;
|
||||||
const assetName = reward.asset.name;
|
const assetName = reward.asset.name;
|
||||||
|
const assetDecimals = reward.asset.decimals;
|
||||||
const rewardType = reward.rewardType;
|
const rewardType = reward.rewardType;
|
||||||
const amount = reward.amount;
|
const amount = reward.amount;
|
||||||
const percentageOfTotal = reward.percentageOfTotal;
|
const percentageOfTotal = reward.percentageOfTotal;
|
||||||
@ -73,6 +75,7 @@ export const generateEpochIndividualRewardsList = ({
|
|||||||
if (!asset) {
|
if (!asset) {
|
||||||
asset = {
|
asset = {
|
||||||
asset: assetName,
|
asset: assetName,
|
||||||
|
decimals: assetDecimals,
|
||||||
totalAmount: '0',
|
totalAmount: '0',
|
||||||
rewardTypes: Object.fromEntries(emptyRowAccountTypes),
|
rewardTypes: Object.fromEntries(emptyRowAccountTypes),
|
||||||
};
|
};
|
||||||
|
@ -52,6 +52,7 @@ const assetRewards: Map<
|
|||||||
assetRewards.set(assetId, {
|
assetRewards.set(assetId, {
|
||||||
assetId,
|
assetId,
|
||||||
name: 'tDAI TEST',
|
name: 'tDAI TEST',
|
||||||
|
decimals: 6,
|
||||||
rewards,
|
rewards,
|
||||||
totalAmount: '295',
|
totalAmount: '295',
|
||||||
});
|
});
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
import { formatNumber, toBigNum } from '@vegaprotocol/utils';
|
import { formatNumber, toBigNum } from '@vegaprotocol/utils';
|
||||||
import { Tooltip } from '@vegaprotocol/ui-toolkit';
|
import { Tooltip } from '@vegaprotocol/ui-toolkit';
|
||||||
import { useAppState } from '../../../contexts/app-state/app-state-context';
|
|
||||||
import {
|
import {
|
||||||
rowGridItemStyles,
|
rowGridItemStyles,
|
||||||
RewardsTable,
|
RewardsTable,
|
||||||
@ -12,16 +11,19 @@ interface EpochTotalRewardsGridProps {
|
|||||||
}
|
}
|
||||||
|
|
||||||
interface RewardItemProps {
|
interface RewardItemProps {
|
||||||
value: string;
|
amount: string;
|
||||||
|
decimals: number;
|
||||||
dataTestId: string;
|
dataTestId: string;
|
||||||
last?: boolean;
|
last?: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
const DisplayReward = ({ reward }: { reward: string }) => {
|
const DisplayReward = ({
|
||||||
const {
|
reward,
|
||||||
appState: { decimals },
|
decimals,
|
||||||
} = useAppState();
|
}: {
|
||||||
|
reward: string;
|
||||||
|
decimals: number;
|
||||||
|
}) => {
|
||||||
if (Number(reward) === 0) {
|
if (Number(reward) === 0) {
|
||||||
return <span className="text-vega-dark-300">-</span>;
|
return <span className="text-vega-dark-300">-</span>;
|
||||||
}
|
}
|
||||||
@ -33,11 +35,16 @@ const DisplayReward = ({ reward }: { reward: string }) => {
|
|||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
const RewardItem = ({ value, dataTestId, last }: RewardItemProps) => (
|
const RewardItem = ({
|
||||||
|
amount,
|
||||||
|
decimals,
|
||||||
|
dataTestId,
|
||||||
|
last,
|
||||||
|
}: RewardItemProps) => (
|
||||||
<div data-testid={dataTestId} className={rowGridItemStyles(last)}>
|
<div data-testid={dataTestId} className={rowGridItemStyles(last)}>
|
||||||
<div className="h-full w-5 absolute right-0 top-0 bg-gradient-to-r from-transparent to-black pointer-events-none" />
|
<div className="h-full w-5 absolute right-0 top-0 bg-gradient-to-r from-transparent to-black pointer-events-none" />
|
||||||
<div className="overflow-auto p-5">
|
<div className="overflow-auto p-5">
|
||||||
<DisplayReward reward={value} />
|
<DisplayReward reward={amount} decimals={decimals} />
|
||||||
</div>
|
</div>
|
||||||
<div className="h-full w-5 absolute left-0 top-0 bg-gradient-to-l from-transparent to-black pointer-events-none" />
|
<div className="h-full w-5 absolute left-0 top-0 bg-gradient-to-l from-transparent to-black pointer-events-none" />
|
||||||
</div>
|
</div>
|
||||||
@ -49,15 +56,25 @@ export const EpochTotalRewardsTable = ({
|
|||||||
return (
|
return (
|
||||||
<RewardsTable dataTestId="epoch-total-rewards-table" epoch={data.epoch}>
|
<RewardsTable dataTestId="epoch-total-rewards-table" epoch={data.epoch}>
|
||||||
{Array.from(data.assetRewards.values()).map(
|
{Array.from(data.assetRewards.values()).map(
|
||||||
({ name, rewards, totalAmount }, i) => (
|
({ name, rewards, totalAmount, decimals }, i) => (
|
||||||
<div className="contents" key={i}>
|
<div className="contents" key={i}>
|
||||||
<div data-testid="asset" className={`${rowGridItemStyles()} p-5`}>
|
<div data-testid="asset" className={`${rowGridItemStyles()} p-5`}>
|
||||||
{name}
|
{name}
|
||||||
</div>
|
</div>
|
||||||
{Array.from(rewards.values()).map(({ rewardType, amount }, i) => (
|
{Array.from(rewards.values()).map(({ rewardType, amount }, i) => (
|
||||||
<RewardItem key={i} dataTestId={rewardType} value={amount} />
|
<RewardItem
|
||||||
|
key={i}
|
||||||
|
dataTestId={rewardType}
|
||||||
|
amount={amount}
|
||||||
|
decimals={decimals}
|
||||||
|
/>
|
||||||
))}
|
))}
|
||||||
<RewardItem dataTestId="total" value={totalAmount} last={true} />
|
<RewardItem
|
||||||
|
dataTestId="total"
|
||||||
|
amount={totalAmount}
|
||||||
|
decimals={decimals}
|
||||||
|
last={true}
|
||||||
|
/>
|
||||||
</div>
|
</div>
|
||||||
)
|
)
|
||||||
)}
|
)}
|
||||||
|
@ -56,12 +56,14 @@ describe('generateEpochAssetRewardsList', () => {
|
|||||||
node: {
|
node: {
|
||||||
id: '1',
|
id: '1',
|
||||||
name: 'Asset 1',
|
name: 'Asset 1',
|
||||||
|
decimals: 18,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
node: {
|
node: {
|
||||||
id: '2',
|
id: '2',
|
||||||
name: 'Asset 2',
|
name: 'Asset 2',
|
||||||
|
decimals: 6,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
@ -101,6 +103,7 @@ describe('generateEpochAssetRewardsList', () => {
|
|||||||
{
|
{
|
||||||
node: {
|
node: {
|
||||||
epoch: 1,
|
epoch: 1,
|
||||||
|
decimals: 18,
|
||||||
assetId: '1',
|
assetId: '1',
|
||||||
rewardType: AccountType.ACCOUNT_TYPE_GLOBAL_REWARD,
|
rewardType: AccountType.ACCOUNT_TYPE_GLOBAL_REWARD,
|
||||||
amount: '123',
|
amount: '123',
|
||||||
@ -128,6 +131,7 @@ describe('generateEpochAssetRewardsList', () => {
|
|||||||
'1',
|
'1',
|
||||||
{
|
{
|
||||||
assetId: '1',
|
assetId: '1',
|
||||||
|
decimals: 0,
|
||||||
name: '',
|
name: '',
|
||||||
rewards: new Map([
|
rewards: new Map([
|
||||||
[
|
[
|
||||||
@ -196,12 +200,14 @@ describe('generateEpochAssetRewardsList', () => {
|
|||||||
node: {
|
node: {
|
||||||
id: '1',
|
id: '1',
|
||||||
name: 'Asset 1',
|
name: 'Asset 1',
|
||||||
|
decimals: 18,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
node: {
|
node: {
|
||||||
id: '2',
|
id: '2',
|
||||||
name: 'Asset 2',
|
name: 'Asset 2',
|
||||||
|
decimals: 6,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
@ -212,6 +218,7 @@ describe('generateEpochAssetRewardsList', () => {
|
|||||||
node: {
|
node: {
|
||||||
epoch: 1,
|
epoch: 1,
|
||||||
assetId: '1',
|
assetId: '1',
|
||||||
|
decimals: 18,
|
||||||
rewardType: AccountType.ACCOUNT_TYPE_REWARD_MAKER_PAID_FEES,
|
rewardType: AccountType.ACCOUNT_TYPE_REWARD_MAKER_PAID_FEES,
|
||||||
amount: '123',
|
amount: '123',
|
||||||
},
|
},
|
||||||
@ -220,6 +227,7 @@ describe('generateEpochAssetRewardsList', () => {
|
|||||||
node: {
|
node: {
|
||||||
epoch: 1,
|
epoch: 1,
|
||||||
assetId: '1',
|
assetId: '1',
|
||||||
|
decimals: 18,
|
||||||
rewardType: AccountType.ACCOUNT_TYPE_FEES_INFRASTRUCTURE,
|
rewardType: AccountType.ACCOUNT_TYPE_FEES_INFRASTRUCTURE,
|
||||||
amount: '100',
|
amount: '100',
|
||||||
},
|
},
|
||||||
@ -228,6 +236,7 @@ describe('generateEpochAssetRewardsList', () => {
|
|||||||
node: {
|
node: {
|
||||||
epoch: 2,
|
epoch: 2,
|
||||||
assetId: '1',
|
assetId: '1',
|
||||||
|
decimals: 18,
|
||||||
rewardType: AccountType.ACCOUNT_TYPE_REWARD_LP_RECEIVED_FEES,
|
rewardType: AccountType.ACCOUNT_TYPE_REWARD_LP_RECEIVED_FEES,
|
||||||
amount: '5',
|
amount: '5',
|
||||||
},
|
},
|
||||||
@ -254,6 +263,7 @@ describe('generateEpochAssetRewardsList', () => {
|
|||||||
'1',
|
'1',
|
||||||
{
|
{
|
||||||
assetId: '1',
|
assetId: '1',
|
||||||
|
decimals: 18,
|
||||||
name: 'Asset 1',
|
name: 'Asset 1',
|
||||||
rewards: new Map([
|
rewards: new Map([
|
||||||
[
|
[
|
||||||
@ -319,6 +329,7 @@ describe('generateEpochAssetRewardsList', () => {
|
|||||||
'1',
|
'1',
|
||||||
{
|
{
|
||||||
assetId: '1',
|
assetId: '1',
|
||||||
|
decimals: 18,
|
||||||
name: 'Asset 1',
|
name: 'Asset 1',
|
||||||
rewards: new Map([
|
rewards: new Map([
|
||||||
[
|
[
|
||||||
@ -387,12 +398,14 @@ describe('generateEpochAssetRewardsList', () => {
|
|||||||
node: {
|
node: {
|
||||||
id: '1',
|
id: '1',
|
||||||
name: 'Asset 1',
|
name: 'Asset 1',
|
||||||
|
decimals: 18,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
node: {
|
node: {
|
||||||
id: '2',
|
id: '2',
|
||||||
name: 'Asset 2',
|
name: 'Asset 2',
|
||||||
|
decimals: 6,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
@ -403,6 +416,7 @@ describe('generateEpochAssetRewardsList', () => {
|
|||||||
node: {
|
node: {
|
||||||
epoch: 1,
|
epoch: 1,
|
||||||
assetId: '1',
|
assetId: '1',
|
||||||
|
decimals: 18,
|
||||||
rewardType: AccountType.ACCOUNT_TYPE_REWARD_MAKER_PAID_FEES,
|
rewardType: AccountType.ACCOUNT_TYPE_REWARD_MAKER_PAID_FEES,
|
||||||
amount: '123',
|
amount: '123',
|
||||||
},
|
},
|
||||||
@ -411,6 +425,7 @@ describe('generateEpochAssetRewardsList', () => {
|
|||||||
node: {
|
node: {
|
||||||
epoch: 1,
|
epoch: 1,
|
||||||
assetId: '1',
|
assetId: '1',
|
||||||
|
decimals: 18,
|
||||||
rewardType: AccountType.ACCOUNT_TYPE_FEES_INFRASTRUCTURE,
|
rewardType: AccountType.ACCOUNT_TYPE_FEES_INFRASTRUCTURE,
|
||||||
amount: '100',
|
amount: '100',
|
||||||
},
|
},
|
||||||
@ -419,6 +434,7 @@ describe('generateEpochAssetRewardsList', () => {
|
|||||||
node: {
|
node: {
|
||||||
epoch: 2,
|
epoch: 2,
|
||||||
assetId: '1',
|
assetId: '1',
|
||||||
|
decimals: 18,
|
||||||
rewardType: AccountType.ACCOUNT_TYPE_REWARD_LP_RECEIVED_FEES,
|
rewardType: AccountType.ACCOUNT_TYPE_REWARD_LP_RECEIVED_FEES,
|
||||||
amount: '6',
|
amount: '6',
|
||||||
},
|
},
|
||||||
@ -427,6 +443,7 @@ describe('generateEpochAssetRewardsList', () => {
|
|||||||
node: {
|
node: {
|
||||||
epoch: 2,
|
epoch: 2,
|
||||||
assetId: '1',
|
assetId: '1',
|
||||||
|
decimals: 18,
|
||||||
rewardType: AccountType.ACCOUNT_TYPE_REWARD_LP_RECEIVED_FEES,
|
rewardType: AccountType.ACCOUNT_TYPE_REWARD_LP_RECEIVED_FEES,
|
||||||
amount: '27',
|
amount: '27',
|
||||||
},
|
},
|
||||||
@ -435,6 +452,7 @@ describe('generateEpochAssetRewardsList', () => {
|
|||||||
node: {
|
node: {
|
||||||
epoch: 3,
|
epoch: 3,
|
||||||
assetId: '1',
|
assetId: '1',
|
||||||
|
decimals: 18,
|
||||||
rewardType: AccountType.ACCOUNT_TYPE_FEES_INFRASTRUCTURE,
|
rewardType: AccountType.ACCOUNT_TYPE_FEES_INFRASTRUCTURE,
|
||||||
amount: '15',
|
amount: '15',
|
||||||
},
|
},
|
||||||
@ -467,6 +485,7 @@ describe('generateEpochAssetRewardsList', () => {
|
|||||||
{
|
{
|
||||||
assetId: '1',
|
assetId: '1',
|
||||||
name: 'Asset 1',
|
name: 'Asset 1',
|
||||||
|
decimals: 18,
|
||||||
rewards: new Map([
|
rewards: new Map([
|
||||||
[
|
[
|
||||||
AccountType.ACCOUNT_TYPE_GLOBAL_REWARD,
|
AccountType.ACCOUNT_TYPE_GLOBAL_REWARD,
|
||||||
@ -531,6 +550,7 @@ describe('generateEpochAssetRewardsList', () => {
|
|||||||
'1',
|
'1',
|
||||||
{
|
{
|
||||||
assetId: '1',
|
assetId: '1',
|
||||||
|
decimals: 18,
|
||||||
name: 'Asset 1',
|
name: 'Asset 1',
|
||||||
rewards: new Map([
|
rewards: new Map([
|
||||||
[
|
[
|
||||||
@ -608,6 +628,7 @@ describe('generateEpochAssetRewardsList', () => {
|
|||||||
'1',
|
'1',
|
||||||
{
|
{
|
||||||
assetId: '1',
|
assetId: '1',
|
||||||
|
decimals: 18,
|
||||||
name: 'Asset 1',
|
name: 'Asset 1',
|
||||||
rewards: new Map([
|
rewards: new Map([
|
||||||
[
|
[
|
||||||
|
@ -22,6 +22,7 @@ export type AggregatedEpochRewardSummary = {
|
|||||||
name: EpochSummaryWithNamedReward['name'];
|
name: EpochSummaryWithNamedReward['name'];
|
||||||
rewards: Map<RewardType, RewardItem>;
|
rewards: Map<RewardType, RewardItem>;
|
||||||
totalAmount: string;
|
totalAmount: string;
|
||||||
|
decimals: number;
|
||||||
};
|
};
|
||||||
|
|
||||||
export type EpochTotalSummary = {
|
export type EpochTotalSummary = {
|
||||||
@ -91,6 +92,7 @@ export const generateEpochTotalRewardsList = ({
|
|||||||
assetId: reward.assetId,
|
assetId: reward.assetId,
|
||||||
name: matchingAsset?.name || '',
|
name: matchingAsset?.name || '',
|
||||||
rewards: rewards || new Map(emptyRowAccountTypes),
|
rewards: rewards || new Map(emptyRowAccountTypes),
|
||||||
|
decimals: matchingAsset?.decimals || 0,
|
||||||
totalAmount: (
|
totalAmount: (
|
||||||
Number(reward.amount) + Number(assetWithRewards?.totalAmount || 0)
|
Number(reward.amount) + Number(assetWithRewards?.totalAmount || 0)
|
||||||
).toString(),
|
).toString(),
|
||||||
|
@ -4,6 +4,7 @@ fragment RewardFields on Reward {
|
|||||||
id
|
id
|
||||||
symbol
|
symbol
|
||||||
name
|
name
|
||||||
|
decimals
|
||||||
}
|
}
|
||||||
party {
|
party {
|
||||||
id
|
id
|
||||||
@ -67,6 +68,7 @@ query EpochAssetsRewards(
|
|||||||
node {
|
node {
|
||||||
id
|
id
|
||||||
name
|
name
|
||||||
|
decimals
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -3,7 +3,7 @@ import * as Types from '@vegaprotocol/types';
|
|||||||
import { gql } from '@apollo/client';
|
import { gql } from '@apollo/client';
|
||||||
import * as Apollo from '@apollo/client';
|
import * as Apollo from '@apollo/client';
|
||||||
const defaultOptions = {} as const;
|
const defaultOptions = {} as const;
|
||||||
export type RewardFieldsFragment = { __typename?: 'Reward', rewardType: Types.AccountType, amount: string, percentageOfTotal: string, receivedAt: any, asset: { __typename?: 'Asset', id: string, symbol: string, name: string }, party: { __typename?: 'Party', id: string }, epoch: { __typename?: 'Epoch', id: string } };
|
export type RewardFieldsFragment = { __typename?: 'Reward', rewardType: Types.AccountType, amount: string, percentageOfTotal: string, receivedAt: any, asset: { __typename?: 'Asset', id: string, symbol: string, name: string, decimals: number }, party: { __typename?: 'Party', id: string }, epoch: { __typename?: 'Epoch', id: string } };
|
||||||
|
|
||||||
export type DelegationFieldsFragment = { __typename?: 'Delegation', amount: string, epoch: number };
|
export type DelegationFieldsFragment = { __typename?: 'Delegation', amount: string, epoch: number };
|
||||||
|
|
||||||
@ -16,7 +16,7 @@ export type RewardsQueryVariables = Types.Exact<{
|
|||||||
}>;
|
}>;
|
||||||
|
|
||||||
|
|
||||||
export type RewardsQuery = { __typename?: 'Query', party?: { __typename?: 'Party', id: string, rewardsConnection?: { __typename?: 'RewardsConnection', edges?: Array<{ __typename?: 'RewardEdge', node: { __typename?: 'Reward', rewardType: Types.AccountType, amount: string, percentageOfTotal: string, receivedAt: any, asset: { __typename?: 'Asset', id: string, symbol: string, name: string }, party: { __typename?: 'Party', id: string }, epoch: { __typename?: 'Epoch', id: string } } } | null> | null } | null, delegationsConnection?: { __typename?: 'DelegationsConnection', edges?: Array<{ __typename?: 'DelegationEdge', node: { __typename?: 'Delegation', amount: string, epoch: number } } | null> | null } | null } | null };
|
export type RewardsQuery = { __typename?: 'Query', party?: { __typename?: 'Party', id: string, rewardsConnection?: { __typename?: 'RewardsConnection', edges?: Array<{ __typename?: 'RewardEdge', node: { __typename?: 'Reward', rewardType: Types.AccountType, amount: string, percentageOfTotal: string, receivedAt: any, asset: { __typename?: 'Asset', id: string, symbol: string, name: string, decimals: number }, party: { __typename?: 'Party', id: string }, epoch: { __typename?: 'Epoch', id: string } } } | null> | null } | null, delegationsConnection?: { __typename?: 'DelegationsConnection', edges?: Array<{ __typename?: 'DelegationEdge', node: { __typename?: 'Delegation', amount: string, epoch: number } } | null> | null } | null } | null };
|
||||||
|
|
||||||
export type EpochRewardSummaryFieldsFragment = { __typename?: 'EpochRewardSummary', epoch: number, assetId: string, amount: string, rewardType: Types.AccountType };
|
export type EpochRewardSummaryFieldsFragment = { __typename?: 'EpochRewardSummary', epoch: number, assetId: string, amount: string, rewardType: Types.AccountType };
|
||||||
|
|
||||||
@ -26,7 +26,7 @@ export type EpochAssetsRewardsQueryVariables = Types.Exact<{
|
|||||||
}>;
|
}>;
|
||||||
|
|
||||||
|
|
||||||
export type EpochAssetsRewardsQuery = { __typename?: 'Query', assetsConnection?: { __typename?: 'AssetsConnection', edges?: Array<{ __typename?: 'AssetEdge', node: { __typename?: 'Asset', id: string, name: string } } | null> | null } | null, epochRewardSummaries?: { __typename?: 'EpochRewardSummaryConnection', edges?: Array<{ __typename?: 'EpochRewardSummaryEdge', node: { __typename?: 'EpochRewardSummary', epoch: number, assetId: string, amount: string, rewardType: Types.AccountType } } | null> | null } | null };
|
export type EpochAssetsRewardsQuery = { __typename?: 'Query', assetsConnection?: { __typename?: 'AssetsConnection', edges?: Array<{ __typename?: 'AssetEdge', node: { __typename?: 'Asset', id: string, name: string, decimals: number } } | null> | null } | null, epochRewardSummaries?: { __typename?: 'EpochRewardSummaryConnection', edges?: Array<{ __typename?: 'EpochRewardSummaryEdge', node: { __typename?: 'EpochRewardSummary', epoch: number, assetId: string, amount: string, rewardType: Types.AccountType } } | null> | null } | null };
|
||||||
|
|
||||||
export type EpochFieldsFragment = { __typename?: 'Epoch', id: string, timestamps: { __typename?: 'EpochTimestamps', start?: any | null, end?: any | null, expiry?: any | null } };
|
export type EpochFieldsFragment = { __typename?: 'Epoch', id: string, timestamps: { __typename?: 'EpochTimestamps', start?: any | null, end?: any | null, expiry?: any | null } };
|
||||||
|
|
||||||
@ -42,6 +42,7 @@ export const RewardFieldsFragmentDoc = gql`
|
|||||||
id
|
id
|
||||||
symbol
|
symbol
|
||||||
name
|
name
|
||||||
|
decimals
|
||||||
}
|
}
|
||||||
party {
|
party {
|
||||||
id
|
id
|
||||||
@ -143,6 +144,7 @@ export const EpochAssetsRewardsDocument = gql`
|
|||||||
node {
|
node {
|
||||||
id
|
id
|
||||||
name
|
name
|
||||||
|
decimals
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -167,4 +167,4 @@ export function useMarketDataLazyQuery(baseOptions?: Apollo.LazyQueryHookOptions
|
|||||||
}
|
}
|
||||||
export type MarketDataQueryHookResult = ReturnType<typeof useMarketDataQuery>;
|
export type MarketDataQueryHookResult = ReturnType<typeof useMarketDataQuery>;
|
||||||
export type MarketDataLazyQueryHookResult = ReturnType<typeof useMarketDataLazyQuery>;
|
export type MarketDataLazyQueryHookResult = ReturnType<typeof useMarketDataLazyQuery>;
|
||||||
export type MarketDataQueryResult = Apollo.QueryResult<MarketDataQuery, MarketDataQueryVariables>;
|
export type MarketDataQueryResult = Apollo.QueryResult<MarketDataQuery, MarketDataQueryVariables>;
|
Loading…
Reference in New Issue
Block a user