Fix initial point on graph

This commit is contained in:
James Grugett 2022-03-10 15:58:44 -06:00
parent 864b4420ad
commit c1a800f4c6
2 changed files with 11 additions and 9 deletions

View File

@ -28,9 +28,12 @@ export function getProbability(contract: FullContract<DPM | CPMM, Binary>) {
export function getInitialProbability( export function getInitialProbability(
contract: FullContract<DPM | CPMM, Binary> contract: FullContract<DPM | CPMM, Binary>
) { ) {
return contract.initialProbability ?? contract.mechanism === 'cpmm-1' return (
? getCpmmProbability(contract.pool) contract.initialProbability ??
: getDpmProbability(contract.phantomShares ?? contract.totalShares) (contract.mechanism === 'cpmm-1'
? getCpmmProbability(contract.pool)
: getDpmProbability(contract.phantomShares ?? contract.totalShares))
)
} }
export function getOutcomeProbability(contract: Contract, outcome: string) { export function getOutcomeProbability(contract: Contract, outcome: string) {

View File

@ -20,12 +20,11 @@ export function ContractProbGraph(props: {
const startProb = getInitialProbability(contract) const startProb = getInitialProbability(contract)
const times = bets const times = [
? [contract.createdTime, ...bets.map((bet) => bet.createdTime)].map( contract.createdTime,
(time) => new Date(time) ...bets.map((bet) => bet.createdTime),
) ].map((time) => new Date(time))
: [] const probs = [startProb, ...bets.map((bet) => bet.probAfter)]
const probs = bets ? [startProb, ...bets.map((bet) => bet.probAfter)] : []
const isClosed = !!closeTime && Date.now() > closeTime const isClosed = !!closeTime && Date.now() > closeTime
const latestTime = dayjs( const latestTime = dayjs(