getOutcomeProbabilityAfterBet

This commit is contained in:
mantikoros 2022-03-03 12:06:24 -05:00
parent f40a65cc88
commit a7e7fc0c90
4 changed files with 11 additions and 10 deletions

View File

@ -8,13 +8,14 @@ export function getCpmmProbability(pool: { [outcome: string]: number }) {
return NO / (YES + NO)
}
export function getCpmmProbabilityAfterBet(
export function getCpmmOutcomeProbabilityAfterBet(
contract: FullContract<CPMM, Binary>,
outcome: string,
bet: number
) {
const { newPool } = calculateCpmmPurchase(contract, bet, outcome)
return getCpmmProbability(newPool)
const p = getCpmmProbability(newPool)
return outcome === 'NO' ? 1 - p : p
}
export function calculateCpmmShares(

View File

@ -19,7 +19,7 @@ export function getDpmOutcomeProbability(
return shares ** 2 / squareSum
}
export function getDpmProbabilityAfterBet(
export function getDpmOutcomeProbabilityAfterBet(
totalShares: {
[outcome: string]: number
},

View File

@ -3,7 +3,7 @@ import {
calculateCpmmShares,
calculateCpmmShareValue,
getCpmmProbability,
getCpmmProbabilityAfterBet,
getCpmmOutcomeProbabilityAfterBet,
getCpmmProbabilityAfterSale,
} from './calculate-cpmm'
import {
@ -13,7 +13,7 @@ import {
calculateDpmShares,
getDpmOutcomeProbability,
getDpmProbability,
getDpmProbabilityAfterBet,
getDpmOutcomeProbabilityAfterBet,
getDpmProbabilityAfterSale,
} from './calculate-dpm'
import {
@ -42,18 +42,18 @@ export function getOutcomeProbability(contract: Contract, outcome: string) {
: getDpmOutcomeProbability(contract.totalShares, outcome)
}
export function getProbabilityAfterBet(
export function getOutcomeProbabilityAfterBet(
contract: Contract,
outcome: string,
bet: number
) {
return contract.mechanism === 'cpmm-1'
? getCpmmProbabilityAfterBet(
? getCpmmOutcomeProbabilityAfterBet(
contract as FullContract<CPMM, Binary>,
outcome,
bet
)
: getDpmProbabilityAfterBet(contract.totalShares, outcome, bet)
: getDpmOutcomeProbabilityAfterBet(contract.totalShares, outcome, bet)
}
export function calculateShares(

View File

@ -23,7 +23,7 @@ import {
calculatePayoutAfterCorrectBet,
calculateShares,
getProbability,
getProbabilityAfterBet,
getOutcomeProbabilityAfterBet,
} from '../../common/calculate'
import { useFocus } from '../hooks/use-focus'
@ -99,7 +99,7 @@ export function BetPanel(props: {
const initialProb = getProbability(contract)
const outcomeProb = getProbabilityAfterBet(
const outcomeProb = getOutcomeProbabilityAfterBet(
contract,
betChoice || 'YES',
betAmount ?? 0