contract: remove startPool, add phantomShares
This commit is contained in:
parent
51a69cb916
commit
2d1d4dd58b
|
@ -15,10 +15,10 @@ export const calcStartPool = (initialProbInt: number, ante = 0) => {
|
|||
const poolYes = p * ante
|
||||
const poolNo = (1 - p) * ante
|
||||
|
||||
const startYes = Math.sqrt(p) * PHANTOM_ANTE
|
||||
const startNo = Math.sqrt(1 - p) * PHANTOM_ANTE
|
||||
const phantomYes = Math.sqrt(p) * PHANTOM_ANTE
|
||||
const phantomNo = Math.sqrt(1 - p) * PHANTOM_ANTE
|
||||
|
||||
return { sharesYes, sharesNo, poolYes, poolNo, startYes, startNo }
|
||||
return { sharesYes, sharesNo, poolYes, poolNo, phantomYes, phantomNo }
|
||||
}
|
||||
|
||||
export function getAnteBets(
|
||||
|
|
|
@ -120,7 +120,7 @@ export function calculateStandardPayout(
|
|||
const { amount, outcome: betOutcome, shares } = bet
|
||||
if (betOutcome !== outcome) return 0
|
||||
|
||||
const { totalShares, totalBets, startPool } = contract
|
||||
const { totalShares, totalBets, phantomShares } = contract
|
||||
if (totalShares[outcome] === 0) return 0
|
||||
|
||||
const truePool = contract.pool.YES + contract.pool.NO
|
||||
|
@ -128,7 +128,8 @@ export function calculateStandardPayout(
|
|||
if (totalBets[outcome] >= truePool)
|
||||
return (amount / totalBets[outcome]) * truePool
|
||||
|
||||
const total = totalShares[outcome] - startPool[outcome] - totalBets[outcome]
|
||||
const total =
|
||||
totalShares[outcome] - phantomShares[outcome] - totalBets[outcome]
|
||||
const winningsPool = truePool - totalBets[outcome]
|
||||
|
||||
return (1 - FEES) * (amount + ((shares - amount) / total) * winningsPool)
|
||||
|
@ -178,10 +179,12 @@ function calculateMktPayout(contract: Contract, bet: Bet) {
|
|||
const weightedShareTotal =
|
||||
p *
|
||||
(contract.totalShares.YES -
|
||||
contract.startPool.YES -
|
||||
contract.phantomShares.YES -
|
||||
contract.totalBets.YES) +
|
||||
(1 - p) *
|
||||
(contract.totalShares.NO - contract.startPool.NO - contract.totalBets.NO)
|
||||
(contract.totalShares.NO -
|
||||
contract.phantomShares.NO -
|
||||
contract.totalBets.NO)
|
||||
|
||||
return (
|
||||
(1 - FEES) *
|
||||
|
|
|
@ -12,7 +12,7 @@ export type Contract = {
|
|||
// outcomes: ['YES', 'NO']
|
||||
|
||||
mechanism: 'dpm-2'
|
||||
startPool: { YES: number; NO: number }
|
||||
phantomShares: { YES: number; NO: number }
|
||||
pool: { YES: number; NO: number }
|
||||
totalShares: { YES: number; NO: number }
|
||||
totalBets: { YES: number; NO: number }
|
||||
|
|
|
@ -13,7 +13,7 @@ export function getNewContract(
|
|||
ante?: number,
|
||||
closeTime?: number
|
||||
) {
|
||||
const { sharesYes, sharesNo, poolYes, poolNo, startYes, startNo } =
|
||||
const { sharesYes, sharesNo, poolYes, poolNo, phantomYes, phantomNo } =
|
||||
calcStartPool(initialProb, ante)
|
||||
|
||||
const contract: Contract = {
|
||||
|
@ -29,7 +29,7 @@ export function getNewContract(
|
|||
description: description.trim(),
|
||||
|
||||
mechanism: 'dpm-2',
|
||||
startPool: { YES: startYes, NO: startNo },
|
||||
phantomShares: { YES: phantomYes, NO: phantomNo },
|
||||
pool: { YES: poolYes, NO: poolNo },
|
||||
totalShares: { YES: sharesYes, NO: sharesNo },
|
||||
totalBets: { YES: poolYes, NO: poolNo },
|
||||
|
|
|
@ -8,12 +8,12 @@ import { Contract } from '../lib/firebase/contracts'
|
|||
|
||||
export function ContractProbGraph(props: { contract: Contract }) {
|
||||
const { contract } = props
|
||||
const { id, startPool, resolutionTime } = contract
|
||||
const { id, phantomShares, resolutionTime } = contract
|
||||
|
||||
let bets = useBets(id)
|
||||
if (bets === 'loading') bets = []
|
||||
|
||||
const startProb = getProbability(startPool)
|
||||
const startProb = getProbability(phantomShares)
|
||||
|
||||
const times = [
|
||||
contract.createdTime,
|
||||
|
|
|
@ -29,7 +29,7 @@ export function contractPath(contract: Contract) {
|
|||
export function contractMetrics(contract: Contract) {
|
||||
const {
|
||||
pool,
|
||||
startPool,
|
||||
phantomShares,
|
||||
totalShares,
|
||||
createdTime,
|
||||
resolutionTime,
|
||||
|
@ -40,7 +40,7 @@ export function contractMetrics(contract: Contract) {
|
|||
const prob = getProbability(totalShares)
|
||||
const probPercent = Math.round(prob * 100) + '%'
|
||||
|
||||
const startProb = getProbability(startPool)
|
||||
const startProb = getProbability(phantomShares)
|
||||
|
||||
const createdDate = dayjs(createdTime).format('MMM D')
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user