Remove s from property, replace prob with outcome
This commit is contained in:
parent
dfd6831717
commit
5d48530421
|
@ -16,13 +16,13 @@ export type Challenge = {
|
|||
creatorAmount: number
|
||||
|
||||
// YES or NO for now
|
||||
creatorsOutcome: string
|
||||
creatorOutcome: string
|
||||
|
||||
// Different than the creator
|
||||
yourOutcome: string
|
||||
|
||||
// The probability the challenger thinks
|
||||
creatorsOutcomeProb: number
|
||||
creatorOutcomeProb: number
|
||||
|
||||
contractId: string
|
||||
contractSlug: string
|
||||
|
|
|
@ -50,17 +50,17 @@ export const acceptchallenge = newEndpoint({}, async (req, auth) => {
|
|||
if (!creatorSnap.exists) throw new APIError(400, 'User not found.')
|
||||
const creator = creatorSnap.data() as User
|
||||
|
||||
const { creatorAmount, yourOutcome, creatorsOutcome, creatorsOutcomeProb } =
|
||||
const { creatorAmount, yourOutcome, creatorOutcome, creatorOutcomeProb } =
|
||||
challenge
|
||||
|
||||
const yourCost =
|
||||
((1 - creatorsOutcomeProb) / creatorsOutcomeProb) * creatorAmount
|
||||
((1 - creatorOutcomeProb) / creatorOutcomeProb) * creatorAmount
|
||||
|
||||
if (user.balance < yourCost)
|
||||
throw new APIError(400, 'Insufficient balance.')
|
||||
|
||||
const contract = anyContract as CPMMBinaryContract
|
||||
const shares = (1 / creatorsOutcomeProb) * creatorAmount
|
||||
const shares = (1 / creatorOutcomeProb) * creatorAmount
|
||||
const createdTime = Date.now()
|
||||
|
||||
log(
|
||||
|
@ -70,7 +70,7 @@ export const acceptchallenge = newEndpoint({}, async (req, auth) => {
|
|||
yourOutcome,
|
||||
'shares',
|
||||
'at',
|
||||
formatPercent(creatorsOutcomeProb),
|
||||
formatPercent(creatorOutcomeProb),
|
||||
'for',
|
||||
formatMoney(yourCost)
|
||||
)
|
||||
|
@ -82,8 +82,8 @@ export const acceptchallenge = newEndpoint({}, async (req, auth) => {
|
|||
isCancelled: false,
|
||||
contractId: contract.id,
|
||||
outcome: yourOutcome,
|
||||
probBefore: creatorsOutcomeProb,
|
||||
probAfter: creatorsOutcomeProb,
|
||||
probBefore: creatorOutcomeProb,
|
||||
probAfter: creatorOutcomeProb,
|
||||
loanAmount: 0,
|
||||
createdTime,
|
||||
fees: noFees,
|
||||
|
@ -104,9 +104,9 @@ export const acceptchallenge = newEndpoint({}, async (req, auth) => {
|
|||
shares: shares,
|
||||
isCancelled: false,
|
||||
contractId: contract.id,
|
||||
outcome: creatorsOutcome,
|
||||
probBefore: creatorsOutcomeProb,
|
||||
probAfter: creatorsOutcomeProb,
|
||||
outcome: creatorOutcome,
|
||||
probBefore: creatorOutcomeProb,
|
||||
probAfter: creatorOutcomeProb,
|
||||
loanAmount: 0,
|
||||
createdTime,
|
||||
fees: noFees,
|
||||
|
|
|
@ -21,9 +21,9 @@ export function AcceptChallengeButton(props: {
|
|||
const [open, setOpen] = useState(false)
|
||||
const [errorText, setErrorText] = useState('')
|
||||
const [loading, setLoading] = useState(false)
|
||||
const { creatorsOutcomeProb, creatorAmount } = challenge
|
||||
const { creatorOutcomeProb, creatorAmount } = challenge
|
||||
const yourCost =
|
||||
((1 - creatorsOutcomeProb) / creatorsOutcomeProb) * creatorAmount
|
||||
((1 - creatorOutcomeProb) / creatorOutcomeProb) * creatorAmount
|
||||
useEffect(() => {
|
||||
setErrorText('')
|
||||
}, [open])
|
||||
|
|
|
@ -53,9 +53,9 @@ export async function createChallenge(data: {
|
|||
creatorAmount: amount,
|
||||
contractSlug: contract.slug,
|
||||
contractId: contract.id,
|
||||
creatorsOutcome: outcome.toString(),
|
||||
creatorOutcome: outcome.toString(),
|
||||
yourOutcome: outcome === 'YES' ? 'NO' : 'YES',
|
||||
creatorsOutcomeProb: prob,
|
||||
creatorOutcomeProb: prob,
|
||||
createdTime: Date.now(),
|
||||
expiresTime,
|
||||
maxUses: 1,
|
||||
|
|
|
@ -100,7 +100,7 @@ export default function ChallengePage(props: {
|
|||
ogCardProps.creatorAvatarUrl = challenge.creatorAvatarUrl
|
||||
ogCardProps.question = 'I challenge you to a bet: ' + contract.question
|
||||
ogCardProps.probability =
|
||||
Math.round(challenge.creatorsOutcomeProb * 100) + '%'
|
||||
formatMoney(challenge.creatorAmount) + ' on ' + challenge.creatorOutcome
|
||||
|
||||
return (
|
||||
<Page>
|
||||
|
@ -156,8 +156,8 @@ function ClosedChallengeContent(props: {
|
|||
const {
|
||||
acceptances,
|
||||
creatorAmount,
|
||||
creatorsOutcome,
|
||||
creatorsOutcomeProb,
|
||||
creatorOutcome,
|
||||
creatorOutcomeProb,
|
||||
yourOutcome,
|
||||
} = challenge
|
||||
|
||||
|
@ -169,10 +169,10 @@ function ClosedChallengeContent(props: {
|
|||
if (acceptances[0].createdTime > Date.now() - 1000 * 60)
|
||||
setShowConfetti(true)
|
||||
}, [acceptances])
|
||||
const creatorWon = resolution === creatorsOutcome
|
||||
const creatorWon = resolution === creatorOutcome
|
||||
const amountWon = creatorWon ? acceptances[0].amount : creatorAmount
|
||||
const yourCost =
|
||||
((1 - creatorsOutcomeProb) / creatorsOutcomeProb) * creatorAmount
|
||||
((1 - creatorOutcomeProb) / creatorOutcomeProb) * creatorAmount
|
||||
|
||||
if (!user) return <LoadingIndicator />
|
||||
|
||||
|
@ -275,12 +275,12 @@ function ClosedChallengeContent(props: {
|
|||
>
|
||||
{userCol(
|
||||
creator,
|
||||
creatorsOutcome,
|
||||
creatorsOutcomeProb,
|
||||
creatorOutcome,
|
||||
creatorOutcomeProb,
|
||||
creatorAmount
|
||||
)}
|
||||
<Col className="items-center justify-center py-4 text-xl">VS</Col>
|
||||
{userCol(user, yourOutcome, 1 - creatorsOutcomeProb, yourCost)}
|
||||
{userCol(user, yourOutcome, 1 - creatorOutcomeProb, yourCost)}
|
||||
</Col>
|
||||
)}
|
||||
<Spacer h={3} />
|
||||
|
@ -328,8 +328,8 @@ function OpenChallengeContent(props: {
|
|||
const {
|
||||
creatorAmount,
|
||||
creatorId,
|
||||
creatorsOutcome,
|
||||
creatorsOutcomeProb,
|
||||
creatorOutcome,
|
||||
creatorOutcomeProb,
|
||||
yourOutcome,
|
||||
} = challenge
|
||||
|
||||
|
@ -354,7 +354,7 @@ function OpenChallengeContent(props: {
|
|||
const isBinary = contract.outcomeType === 'BINARY'
|
||||
const isPseudoNumeric = contract.outcomeType === 'PSEUDO_NUMERIC'
|
||||
const yourCost =
|
||||
((1 - creatorsOutcomeProb) / creatorsOutcomeProb) * creatorAmount
|
||||
((1 - creatorOutcomeProb) / creatorOutcomeProb) * creatorAmount
|
||||
|
||||
const userColumn = (
|
||||
challenger: User | null | undefined,
|
||||
|
@ -364,9 +364,9 @@ function OpenChallengeContent(props: {
|
|||
) => {
|
||||
const lastPortfolioMetrics = last(portfolioHistory)
|
||||
const prob =
|
||||
(outcome === creatorsOutcome
|
||||
? creatorsOutcomeProb
|
||||
: 1 - creatorsOutcomeProb) * 100
|
||||
(outcome === creatorOutcome
|
||||
? creatorOutcomeProb
|
||||
: 1 - creatorOutcomeProb) * 100
|
||||
|
||||
return (
|
||||
<Col className="w-full items-start justify-center gap-1">
|
||||
|
@ -436,7 +436,7 @@ function OpenChallengeContent(props: {
|
|||
{userColumn(
|
||||
creator,
|
||||
creatorPortfolioHistory,
|
||||
creatorsOutcome,
|
||||
creatorOutcome,
|
||||
creatorAmount
|
||||
)}
|
||||
<Col className="items-center justify-center py-4 text-4xl">VS</Col>
|
||||
|
|
Loading…
Reference in New Issue
Block a user