Use getNumericBets in bet panel calc

This commit is contained in:
James Grugett 2022-05-06 16:17:21 -04:00
parent 3c55843030
commit be2ce4fd4b
2 changed files with 13 additions and 6 deletions

View File

@ -41,7 +41,7 @@ export function getNumericBets(
) { ) {
const { bucketCount } = contract const { bucketCount } = contract
const bucketNumber = parseInt(bucket) const bucketNumber = parseInt(bucket)
const buckets = _.range(0, bucketNumber) const buckets = _.range(0, bucketCount)
const mean = bucketNumber / bucketCount const mean = bucketNumber / bucketCount

View File

@ -1,5 +1,5 @@
import clsx from 'clsx' import clsx from 'clsx'
import { useState, useEffect } from 'react' import { useState } from 'react'
import { Bet } from '../../common/bet' import { Bet } from '../../common/bet'
import { import {
getOutcomeProbabilityAfterBet, getOutcomeProbabilityAfterBet,
@ -7,6 +7,7 @@ import {
calculatePayoutAfterCorrectBet, calculatePayoutAfterCorrectBet,
getOutcomeProbability, getOutcomeProbability,
} from '../../common/calculate' } from '../../common/calculate'
import { getNumericBets } from '../../common/calculate-dpm'
import { NumericContract } from '../../common/contract' import { NumericContract } from '../../common/contract'
import { formatPercent, formatMoney } from '../../common/util/format' import { formatPercent, formatMoney } from '../../common/util/format'
import { useUser } from '../hooks/use-user' import { useUser } from '../hooks/use-user'
@ -99,13 +100,19 @@ function NumericBuyPanel(props: {
const initialProb = bucketChoice const initialProb = bucketChoice
? getOutcomeProbability(contract, bucketChoice) ? getOutcomeProbability(contract, bucketChoice)
: 0 : 0
const outcomeProb = bucketChoice const numericBets =
? getOutcomeProbabilityAfterBet(contract, bucketChoice, betAmount ?? 0) bucketChoice && betAmount
: 0 ? getNumericBets(contract, bucketChoice, betAmount)
: []
const outcomeBet = numericBets.find(([choice]) => choice === bucketChoice)
const outcomeProb =
bucketChoice && outcomeBet
? getOutcomeProbabilityAfterBet(contract, bucketChoice, outcomeBet[1])
: initialProb
const shares = bucketChoice const shares = bucketChoice
? calculateShares(contract, betAmount ?? 0, bucketChoice) ? calculateShares(contract, betAmount ?? 0, bucketChoice)
: 0 : initialProb
const currentPayout = const currentPayout =
betAmount && bucketChoice betAmount && bucketChoice