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])
|
contracts.map((contract) => [contract.id, contract])
|
||||||
)
|
)
|
||||||
|
|
||||||
for (const user of users) {
|
await Promise.all(
|
||||||
|
users.map(async (user) => {
|
||||||
const [investmentValue, creatorVolume] = await Promise.all([
|
const [investmentValue, creatorVolume] = await Promise.all([
|
||||||
computeInvestmentValue(user, contractsDict),
|
computeInvestmentValue(user, contractsDict),
|
||||||
computeTotalVolume(user, contractsDict),
|
computeTotalPool(user, contractsDict),
|
||||||
])
|
])
|
||||||
|
|
||||||
const totalValue = user.balance + investmentValue
|
const totalValue = user.balance + investmentValue
|
||||||
|
@ -35,7 +36,8 @@ export const updateUserMetrics = functions.pubsub
|
||||||
totalPnLCached: totalPnL,
|
totalPnLCached: totalPnL,
|
||||||
creatorVolumeCached: creatorVolume,
|
creatorVolumeCached: creatorVolume,
|
||||||
})
|
})
|
||||||
}
|
})
|
||||||
|
)
|
||||||
})
|
})
|
||||||
|
|
||||||
const computeInvestmentValue = async (
|
const computeInvestmentValue = async (
|
||||||
|
@ -54,15 +56,17 @@ const computeInvestmentValue = async (
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
const computeTotalVolume = async (
|
const computeTotalPool = async (
|
||||||
user: User,
|
user: User,
|
||||||
contractsDict: _.Dictionary<Contract>
|
contractsDict: _.Dictionary<Contract>
|
||||||
) => {
|
) => {
|
||||||
const creatorContracts = Object.values(contractsDict).filter(
|
const creatorContracts = Object.values(contractsDict).filter(
|
||||||
(contract) => contract.creatorId === user.id
|
(contract) => contract.creatorId === user.id
|
||||||
)
|
)
|
||||||
const volumes = await Promise.all(creatorContracts.map(computeVolume))
|
const pools = creatorContracts.map((contract) =>
|
||||||
return _.sum(volumes)
|
_.sum(Object.values(contract.pool))
|
||||||
|
)
|
||||||
|
return _.sum(pools)
|
||||||
}
|
}
|
||||||
|
|
||||||
const computeVolume = async (contract: Contract) => {
|
const computeVolume = async (contract: Contract) => {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user