Fix one bug and change script name

This commit is contained in:
jahooma 2022-01-01 18:52:32 -06:00
parent 87e7a2a6d1
commit 1f57ea371d
2 changed files with 4 additions and 3 deletions

View File

@ -43,7 +43,7 @@ async function recalculateContract(contractRef: DocRef, contract: Contract) {
console.log() console.log()
} }
async function migrateContracts() { async function recalculateContractTotals() {
console.log('Recalculating contract info') console.log('Recalculating contract info')
const snapshot = await firestore.collection('contracts').get() const snapshot = await firestore.collection('contracts').get()
@ -58,4 +58,5 @@ async function migrateContracts() {
} }
} }
if (require.main === module) migrateContracts().then(() => process.exit()) if (require.main === module)
recalculateContractTotals().then(() => process.exit())

View File

@ -51,7 +51,7 @@ export function calculatePayout(
const startPool = contract.startPool.YES + contract.startPool.NO const startPool = contract.startPool.YES + contract.startPool.NO
const truePool = contract.pool.YES + contract.pool.NO - startPool const truePool = contract.pool.YES + contract.pool.NO - startPool
if (totalBets[outcome] <= truePool) if (totalBets[outcome] >= truePool)
return (amount / totalBets[outcome]) * truePool return (amount / totalBets[outcome]) * truePool
const total = totalShares[outcome] - totalBets[outcome] const total = totalShares[outcome] - totalBets[outcome]