getOutcomeProbabilityAfterBet
This commit is contained in:
parent
f40a65cc88
commit
a7e7fc0c90
|
@ -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(
|
||||
|
|
|
@ -19,7 +19,7 @@ export function getDpmOutcomeProbability(
|
|||
return shares ** 2 / squareSum
|
||||
}
|
||||
|
||||
export function getDpmProbabilityAfterBet(
|
||||
export function getDpmOutcomeProbabilityAfterBet(
|
||||
totalShares: {
|
||||
[outcome: string]: number
|
||||
},
|
||||
|
|
|
@ -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(
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue
Block a user