Skip to content

Commit

Permalink
[rewards-chart] add rewards chart
Browse files Browse the repository at this point in the history
  • Loading branch information
mike-diamond committed Dec 14, 2023
1 parent 5e17844 commit 3e2cfe6
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 7 deletions.
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,8 @@ Daily rewards for the user who has made a deposit in the vault. With the help of
```ts
type UserReward = {
rewards: number
sumRewards: number
dailyRewards: number
}

type Output = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,12 @@ describe('modifyUserReward and modifyUserRewards functions', () => {
{
date: '1694908800',
sumRewards: '344379922475148628745',
dailyRewards: '344379922475148628745',
},
{
date: '1694995200',
sumRewards: '344382187878289278175',
dailyRewards: '0',
},
],
}
Expand All @@ -22,18 +24,21 @@ describe('modifyUserReward and modifyUserRewards functions', () => {
const result = modifyUserReward(userReward)

expect(result).toEqual({
rewards: 344.37992247514865,
sumRewards: 344.37992247514865,
dailyRewards: 344.37992247514865,
})
})

it('should correctly modify multiple rewards', () => {
const expectedResult = {
days: {
1694908800: {
rewards: 344.37992247514865,
sumRewards: 344.37992247514865,
dailyRewards: 344.37992247514865,
},
1694995200: {
rewards: 344.3821878782893,
sumRewards: 344.3821878782893,
dailyRewards: 0,
},
},
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,12 @@ import type { UserRewardsQueryPayload } from '../../../../graphql/backend/vault'


export const modifyUserReward = (reward: Omit<UserRewardsQueryPayload['userRewards'][number], 'date'>) => {
const totalRewards = String(reward.dailyRewards) || '0'
const sumRewards = String(reward.sumRewards) || '0'
const dailyRewards = String(reward.dailyRewards) || '0'

return {
rewards: Number(formatEther(totalRewards)),
sumRewards: Number(formatEther(sumRewards)),
dailyRewards: Number(formatEther(dailyRewards)),
}
}

Expand Down
3 changes: 2 additions & 1 deletion src/methods/vault/requests/getUserRewards/types.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
type UserReward = {
rewards: number
sumRewards: number
dailyRewards: number
}

export type ModifyUserReward = {
Expand Down

0 comments on commit 3e2cfe6

Please sign in to comment.