diff --git a/src/lib/contest.ts b/src/lib/contest.ts index 103a837..4e62f65 100644 --- a/src/lib/contest.ts +++ b/src/lib/contest.ts @@ -167,16 +167,25 @@ export async function fetchSeasons( client: PublicClient, startBlock?: number, ): Promise { - const logs = await getContestLogs( - client, [ - 'SeasonStarted', - 'SeasonClosed', - 'SeasonRevealed', - 'WinnerDeclared', - 'PrizeClaimed', - ], - startBlock, - ); + const [logs, [currentPrize, currentSeasonIdx]] = await Promise.all([ + getContestLogs( + client, [ + 'SeasonStarted', + 'SeasonClosed', + 'SeasonRevealed', + 'WinnerDeclared', + 'PrizeClaimed', + ], + startBlock, + ), + multiReadContestContract({ + client, + calls: [ + { fn: 'currentSeasonPrize' }, + { fn: 'currentSeasonIdx' }, + ], + }), + ]); const seasonsByIdx = {} as { [idx: number]: SeasonInfo }; for (const log of logs) { const { args } = log; @@ -215,6 +224,9 @@ export async function fetchSeasons( szn.unclaimedPrize = 0n; } } + if (seasonsByIdx[currentSeasonIdx]) { + seasonsByIdx[currentSeasonIdx].prize = currentPrize; + } // Get block times. const uniqueBlocks = Object.values(Object.assign({}, ...Object.values(seasonsByIdx)