Switch to pool size instead of volume for creator leaderboard.
This commit is contained in:
parent
0641db1f2d
commit
693652935d
|
@ -22,10 +22,11 @@ export const updateUserMetrics = functions.pubsub
|
|||
contracts.map((contract) => [contract.id, contract])
|
||||
)
|
||||
|
||||
for (const user of users) {
|
||||
await Promise.all(
|
||||
users.map(async (user) => {
|
||||
const [investmentValue, creatorVolume] = await Promise.all([
|
||||
computeInvestmentValue(user, contractsDict),
|
||||
computeTotalVolume(user, contractsDict),
|
||||
computeTotalPool(user, contractsDict),
|
||||
])
|
||||
|
||||
const totalValue = user.balance + investmentValue
|
||||
|
@ -35,7 +36,8 @@ export const updateUserMetrics = functions.pubsub
|
|||
totalPnLCached: totalPnL,
|
||||
creatorVolumeCached: creatorVolume,
|
||||
})
|
||||
}
|
||||
})
|
||||
)
|
||||
})
|
||||
|
||||
const computeInvestmentValue = async (
|
||||
|
@ -54,15 +56,17 @@ const computeInvestmentValue = async (
|
|||
})
|
||||
}
|
||||
|
||||
const computeTotalVolume = async (
|
||||
const computeTotalPool = async (
|
||||
user: User,
|
||||
contractsDict: _.Dictionary<Contract>
|
||||
) => {
|
||||
const creatorContracts = Object.values(contractsDict).filter(
|
||||
(contract) => contract.creatorId === user.id
|
||||
)
|
||||
const volumes = await Promise.all(creatorContracts.map(computeVolume))
|
||||
return _.sum(volumes)
|
||||
const pools = creatorContracts.map((contract) =>
|
||||
_.sum(Object.values(contract.pool))
|
||||
)
|
||||
return _.sum(pools)
|
||||
}
|
||||
|
||||
const computeVolume = async (contract: Contract) => {
|
||||
|
|
Loading…
Reference in New Issue
Block a user