fix(trading): reward pot total value (#5531)

Co-authored-by: Matthew Russell <mattrussell36@gmail.com>
This commit is contained in:
Art 2023-12-21 14:41:37 +01:00 committed by GitHub
parent 4cffee29f8
commit 95775679ca
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 14 additions and 6 deletions

View File

@ -69,11 +69,13 @@ describe('RewardPot', () => {
balance: '100',
asset: rewardAsset,
},
// should include this in total:
{
type: AccountType.ACCOUNT_TYPE_VESTED_REWARDS,
balance: '100',
asset: rewardAsset,
},
// should include this in total:
{
type: AccountType.ACCOUNT_TYPE_VESTED_REWARDS,
balance: '50',
@ -138,20 +140,20 @@ describe('RewardPot', () => {
renderComponent(props);
expect(screen.getByTestId('total-rewards')).toHaveTextContent(
`7.00 ${rewardAsset.symbol}`
);
expect(screen.getByText(/Locked/).nextElementSibling).toHaveTextContent(
'2.50'
);
expect(screen.getByText(/Vesting/).nextElementSibling).toHaveTextContent(
'4.50'
);
expect(
screen.getByText(/Available to withdraw/).nextElementSibling
).toHaveTextContent('1.50');
// should be sum of the above
expect(screen.getByTestId('total-rewards')).toHaveTextContent(
`8.50 ${rewardAsset.symbol}`
);
});
});

View File

@ -62,6 +62,10 @@ export const RewardsContainer = () => {
},
// Inclusion of activity streak in query currently fails
errorPolicy: 'ignore',
// polling here so that as rewards are are moved to ACCOUNT_TYPE_VESTED_REWARDS the vesting stats information stays
// almost up to sync with accounts updating from subscriptions. There is a chance the data could be out
// of sync for 10s if you happen to be on the page at the end of an epoch
pollInterval: 10000,
});
if (!epochData?.epoch || !assetMap) return null;
@ -295,7 +299,9 @@ export const RewardPot = ({
: [0];
const totalVesting = BigNumber.sum.apply(null, vestingBalances);
const totalRewards = totalLocked.plus(totalVesting);
const totalRewards = totalLocked
.plus(totalVesting)
.plus(totalVestedRewardsByRewardAsset);
let rewardAsset = undefined;