Skip to content

Commit ba155fa

Browse files
committed
fixed parallel twab caching
1 parent 0421e33 commit ba155fa

1 file changed

Lines changed: 3 additions & 3 deletions

File tree

utils/params.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import type { Address } from "viem"
66

77
export const getAllParams = async (chainId: number, rpcUrl: string, prizePoolAddress: Address, vaultAddress: Address, userAddresses: Address[], options?: { multicallBatchSize?: number }) => {
88
const params: { [tier: number]: `0x${string}` } = {}
9-
const cachedTwabs: { [startTimestamp: number]: Awaited<ReturnType<typeof getTwabs>> } = {}
9+
const cachedTwabs: { [startTimestamp: number]: ReturnType<typeof getTwabs> } = {}
1010

1111
const client = getClient(chainId, rpcUrl, options)
1212

@@ -19,9 +19,9 @@ export const getAllParams = async (chainId: number, rpcUrl: string, prizePoolAdd
1919

2020
const startTwabTimestamp = tierInfo[tier].startTwabTimestamp
2121
if(cachedTwabs[startTwabTimestamp] === undefined) {
22-
cachedTwabs[startTwabTimestamp] = await getTwabs(client, prizePoolInfo.twabControllerAddress, vaultAddress, userAddresses, { start: startTwabTimestamp, end: prizePoolInfo.lastAwardedDrawClosedAt })
22+
cachedTwabs[startTwabTimestamp] = getTwabs(client, prizePoolInfo.twabControllerAddress, vaultAddress, userAddresses, { start: startTwabTimestamp, end: prizePoolInfo.lastAwardedDrawClosedAt })
2323
}
24-
const { vaultTwab, userTwabs } = cachedTwabs[startTwabTimestamp]
24+
const { vaultTwab, userTwabs } = await cachedTwabs[startTwabTimestamp]
2525

2626
const encodedParams = encodeParams({
2727
winningRandomNumber: prizePoolInfo.randomNumber,

0 commit comments

Comments
 (0)