Skip to content

Commit

Permalink
StationModules: Add voyager rewards (#1824)
Browse files Browse the repository at this point in the history
* StationModules: Add voyager rewards

* add voyager payout to chart
  • Loading branch information
juliangruber authored Sep 17, 2024
1 parent 081395b commit c65eb09
Show file tree
Hide file tree
Showing 3 changed files with 4,369 additions and 5 deletions.
4 changes: 2 additions & 2 deletions renderer/src/hooks/StationModules.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -120,8 +120,8 @@ export const modules = {
logoBackgroundColor: 'black',
stats: {
totalJobs: 0, // TODO: Updater after data export
totalRewards: 0, // TODO: Update after airdrop
rewardsEnabled: false
totalRewards: 1359.54,
rewardsEnabled: true
},
links: {
github: 'https://github.com/filecoin-station/voyager',
Expand Down
31 changes: 28 additions & 3 deletions renderer/src/hooks/StationRewards.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { useEffect, useMemo, useState } from 'react'
import { getScheduledRewards } from 'src/lib/station-config'
import useWallet from 'src/hooks/StationWallet'
import { formattedFilToBigInt } from 'src/lib/utils'
import { voyagerAirdrop } from './voyagerAirdrop'

type ScheduledRewardsResponse = {
day: string;
Expand Down Expand Up @@ -70,12 +71,36 @@ async function getHistoricalRewardsData (address: string) {
})
}
}
if (Object.keys(voyagerAirdrop).includes(address)) {
const timestamp = new Date('2024-09-17').toISOString()
const existingStat = stats.find(s => s.timestamp === timestamp)
if (existingStat) {
existingStat.totalRewardsReceived.voyager = voyagerAirdrop[address]
} else {
stats.push({
timestamp,
totalRewardsReceived: {
spark: 0n,
voyager: voyagerAirdrop[address]
},
totalScheduledRewards: {
spark: 0n,
voyager: 0n
}
})
}
}
stats.sort((a, b) => a.timestamp.localeCompare(b.timestamp))

let currentTotalSparkRewards = 0n
const currentTotalRewards = {
spark: 0n,
voyager: 0n
}
for (const stat of stats) {
currentTotalSparkRewards += stat.totalRewardsReceived.spark
stat.totalRewardsReceived.spark = currentTotalSparkRewards
currentTotalRewards.spark += stat.totalRewardsReceived.spark
currentTotalRewards.voyager += stat.totalRewardsReceived.voyager
stat.totalRewardsReceived.spark = currentTotalRewards.spark
stat.totalRewardsReceived.voyager = currentTotalRewards.voyager
}

return stats
Expand Down
Loading

0 comments on commit c65eb09

Please sign in to comment.