Merge branch 'manifoldmarkets:main' into main
This commit is contained in:
commit
e204b336b3
|
@ -13,7 +13,6 @@ import { addObjects } from './util/object'
|
||||||
export const getDpmCancelPayouts = (contract: DPMContract, bets: Bet[]) => {
|
export const getDpmCancelPayouts = (contract: DPMContract, bets: Bet[]) => {
|
||||||
const { pool } = contract
|
const { pool } = contract
|
||||||
const poolTotal = sum(Object.values(pool))
|
const poolTotal = sum(Object.values(pool))
|
||||||
console.log('resolved N/A, pool M$', poolTotal)
|
|
||||||
|
|
||||||
const betSum = sumBy(bets, (b) => b.amount)
|
const betSum = sumBy(bets, (b) => b.amount)
|
||||||
|
|
||||||
|
@ -58,17 +57,6 @@ export const getDpmStandardPayouts = (
|
||||||
liquidityFee: 0,
|
liquidityFee: 0,
|
||||||
})
|
})
|
||||||
|
|
||||||
console.log(
|
|
||||||
'resolved',
|
|
||||||
outcome,
|
|
||||||
'pool',
|
|
||||||
poolTotal,
|
|
||||||
'profits',
|
|
||||||
profits,
|
|
||||||
'creator fee',
|
|
||||||
creatorFee
|
|
||||||
)
|
|
||||||
|
|
||||||
return {
|
return {
|
||||||
payouts: payouts.map(({ userId, payout }) => ({ userId, payout })),
|
payouts: payouts.map(({ userId, payout }) => ({ userId, payout })),
|
||||||
creatorPayout: creatorFee,
|
creatorPayout: creatorFee,
|
||||||
|
@ -110,17 +98,6 @@ export const getNumericDpmPayouts = (
|
||||||
liquidityFee: 0,
|
liquidityFee: 0,
|
||||||
})
|
})
|
||||||
|
|
||||||
console.log(
|
|
||||||
'resolved numeric bucket: ',
|
|
||||||
outcome,
|
|
||||||
'pool',
|
|
||||||
poolTotal,
|
|
||||||
'profits',
|
|
||||||
profits,
|
|
||||||
'creator fee',
|
|
||||||
creatorFee
|
|
||||||
)
|
|
||||||
|
|
||||||
return {
|
return {
|
||||||
payouts: payouts.map(({ userId, payout }) => ({ userId, payout })),
|
payouts: payouts.map(({ userId, payout }) => ({ userId, payout })),
|
||||||
creatorPayout: creatorFee,
|
creatorPayout: creatorFee,
|
||||||
|
@ -163,17 +140,6 @@ export const getDpmMktPayouts = (
|
||||||
liquidityFee: 0,
|
liquidityFee: 0,
|
||||||
})
|
})
|
||||||
|
|
||||||
console.log(
|
|
||||||
'resolved MKT',
|
|
||||||
p,
|
|
||||||
'pool',
|
|
||||||
pool,
|
|
||||||
'profits',
|
|
||||||
profits,
|
|
||||||
'creator fee',
|
|
||||||
creatorFee
|
|
||||||
)
|
|
||||||
|
|
||||||
return {
|
return {
|
||||||
payouts: payouts.map(({ userId, payout }) => ({ userId, payout })),
|
payouts: payouts.map(({ userId, payout }) => ({ userId, payout })),
|
||||||
creatorPayout: creatorFee,
|
creatorPayout: creatorFee,
|
||||||
|
@ -216,16 +182,6 @@ export const getPayoutsMultiOutcome = (
|
||||||
liquidityFee: 0,
|
liquidityFee: 0,
|
||||||
})
|
})
|
||||||
|
|
||||||
console.log(
|
|
||||||
'resolved',
|
|
||||||
resolutions,
|
|
||||||
'pool',
|
|
||||||
poolTotal,
|
|
||||||
'profits',
|
|
||||||
profits,
|
|
||||||
'creator fee',
|
|
||||||
creatorFee
|
|
||||||
)
|
|
||||||
return {
|
return {
|
||||||
payouts: payouts.map(({ userId, payout }) => ({ userId, payout })),
|
payouts: payouts.map(({ userId, payout }) => ({ userId, payout })),
|
||||||
creatorPayout: creatorFee,
|
creatorPayout: creatorFee,
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
import { sum } from 'lodash'
|
|
||||||
|
|
||||||
import { Bet } from './bet'
|
import { Bet } from './bet'
|
||||||
import { getProbability } from './calculate'
|
import { getProbability } from './calculate'
|
||||||
|
@ -43,18 +42,6 @@ export const getStandardFixedPayouts = (
|
||||||
|
|
||||||
const { collectedFees } = contract
|
const { collectedFees } = contract
|
||||||
const creatorPayout = collectedFees.creatorFee
|
const creatorPayout = collectedFees.creatorFee
|
||||||
|
|
||||||
console.log(
|
|
||||||
'resolved',
|
|
||||||
outcome,
|
|
||||||
'pool',
|
|
||||||
contract.pool[outcome],
|
|
||||||
'payouts',
|
|
||||||
sum(payouts),
|
|
||||||
'creator fee',
|
|
||||||
creatorPayout
|
|
||||||
)
|
|
||||||
|
|
||||||
const liquidityPayouts = getLiquidityPoolPayouts(
|
const liquidityPayouts = getLiquidityPoolPayouts(
|
||||||
contract,
|
contract,
|
||||||
outcome,
|
outcome,
|
||||||
|
@ -98,18 +85,6 @@ export const getMktFixedPayouts = (
|
||||||
|
|
||||||
const { collectedFees } = contract
|
const { collectedFees } = contract
|
||||||
const creatorPayout = collectedFees.creatorFee
|
const creatorPayout = collectedFees.creatorFee
|
||||||
|
|
||||||
console.log(
|
|
||||||
'resolved PROB',
|
|
||||||
p,
|
|
||||||
'pool',
|
|
||||||
p * contract.pool.YES + (1 - p) * contract.pool.NO,
|
|
||||||
'payouts',
|
|
||||||
sum(payouts),
|
|
||||||
'creator fee',
|
|
||||||
creatorPayout
|
|
||||||
)
|
|
||||||
|
|
||||||
const liquidityPayouts = getLiquidityPoolProbPayouts(contract, p, liquidities)
|
const liquidityPayouts = getLiquidityPoolProbPayouts(contract, p, liquidities)
|
||||||
|
|
||||||
return { payouts, creatorPayout, liquidityPayouts, collectedFees }
|
return { payouts, creatorPayout, liquidityPayouts, collectedFees }
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
import clsx from 'clsx'
|
import clsx from 'clsx'
|
||||||
import React, { useEffect, useRef, useState } from 'react'
|
import React, { useState } from 'react'
|
||||||
import { XIcon } from '@heroicons/react/solid'
|
import { XIcon } from '@heroicons/react/solid'
|
||||||
|
|
||||||
import { Answer } from 'common/answer'
|
import { Answer } from 'common/answer'
|
||||||
|
@ -25,7 +25,6 @@ import {
|
||||||
import { Bet } from 'common/bet'
|
import { Bet } from 'common/bet'
|
||||||
import { track } from 'web/lib/service/analytics'
|
import { track } from 'web/lib/service/analytics'
|
||||||
import { BetSignUpPrompt } from '../sign-up-prompt'
|
import { BetSignUpPrompt } from '../sign-up-prompt'
|
||||||
import { isIOS } from 'web/lib/util/device'
|
|
||||||
import { WarningConfirmationButton } from '../warning-confirmation-button'
|
import { WarningConfirmationButton } from '../warning-confirmation-button'
|
||||||
|
|
||||||
export function AnswerBetPanel(props: {
|
export function AnswerBetPanel(props: {
|
||||||
|
@ -44,12 +43,6 @@ export function AnswerBetPanel(props: {
|
||||||
const [error, setError] = useState<string | undefined>()
|
const [error, setError] = useState<string | undefined>()
|
||||||
const [isSubmitting, setIsSubmitting] = useState(false)
|
const [isSubmitting, setIsSubmitting] = useState(false)
|
||||||
|
|
||||||
const inputRef = useRef<HTMLElement>(null)
|
|
||||||
useEffect(() => {
|
|
||||||
if (isIOS()) window.scrollTo(0, window.scrollY + 200)
|
|
||||||
inputRef.current && inputRef.current.focus()
|
|
||||||
}, [])
|
|
||||||
|
|
||||||
async function submitBet() {
|
async function submitBet() {
|
||||||
if (!user || !betAmount) return
|
if (!user || !betAmount) return
|
||||||
|
|
||||||
|
@ -117,7 +110,7 @@ export function AnswerBetPanel(props: {
|
||||||
const bankrollFraction = (betAmount ?? 0) / (user?.balance ?? 1e9)
|
const bankrollFraction = (betAmount ?? 0) / (user?.balance ?? 1e9)
|
||||||
|
|
||||||
const warning =
|
const warning =
|
||||||
(betAmount ?? 0) > 10 && bankrollFraction >= 0.5 && bankrollFraction <= 1
|
(betAmount ?? 0) >= 100 && bankrollFraction >= 0.5 && bankrollFraction <= 1
|
||||||
? `You might not want to spend ${formatPercent(
|
? `You might not want to spend ${formatPercent(
|
||||||
bankrollFraction
|
bankrollFraction
|
||||||
)} of your balance on a single bet. \n\nCurrent balance: ${formatMoney(
|
)} of your balance on a single bet. \n\nCurrent balance: ${formatMoney(
|
||||||
|
@ -153,7 +146,6 @@ export function AnswerBetPanel(props: {
|
||||||
error={error}
|
error={error}
|
||||||
setError={setError}
|
setError={setError}
|
||||||
disabled={isSubmitting}
|
disabled={isSubmitting}
|
||||||
inputRef={inputRef}
|
|
||||||
showSliderOnMobile
|
showSliderOnMobile
|
||||||
/>
|
/>
|
||||||
|
|
||||||
|
|
|
@ -194,7 +194,7 @@ function OpenAnswer(props: {
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Col className={'border-base-200 bg-base-200 flex-1 rounded-md px-2'}>
|
<Col className={'border-base-200 bg-base-200 flex-1 rounded-md px-2'}>
|
||||||
<Modal open={open} setOpen={setOpen}>
|
<Modal open={open} setOpen={setOpen} position="center">
|
||||||
<AnswerBetPanel
|
<AnswerBetPanel
|
||||||
answer={answer}
|
answer={answer}
|
||||||
contract={contract}
|
contract={contract}
|
||||||
|
|
|
@ -60,7 +60,7 @@ export default function BetButton(props: {
|
||||||
)}
|
)}
|
||||||
</Col>
|
</Col>
|
||||||
|
|
||||||
<Modal open={open} setOpen={setOpen}>
|
<Modal open={open} setOpen={setOpen} position="center">
|
||||||
<SimpleBetPanel
|
<SimpleBetPanel
|
||||||
className={betPanelClassName}
|
className={betPanelClassName}
|
||||||
contract={contract}
|
contract={contract}
|
||||||
|
|
|
@ -271,7 +271,7 @@ function BuyPanel(props: {
|
||||||
const bankrollFraction = (betAmount ?? 0) / (user?.balance ?? 1e9)
|
const bankrollFraction = (betAmount ?? 0) / (user?.balance ?? 1e9)
|
||||||
|
|
||||||
const warning =
|
const warning =
|
||||||
(betAmount ?? 0) > 10 && bankrollFraction >= 0.5 && bankrollFraction <= 1
|
(betAmount ?? 0) >= 100 && bankrollFraction >= 0.5 && bankrollFraction <= 1
|
||||||
? `You might not want to spend ${formatPercent(
|
? `You might not want to spend ${formatPercent(
|
||||||
bankrollFraction
|
bankrollFraction
|
||||||
)} of your balance on a single trade. \n\nCurrent balance: ${formatMoney(
|
)} of your balance on a single trade. \n\nCurrent balance: ${formatMoney(
|
||||||
|
|
|
@ -8,9 +8,10 @@ export function Modal(props: {
|
||||||
open: boolean
|
open: boolean
|
||||||
setOpen: (open: boolean) => void
|
setOpen: (open: boolean) => void
|
||||||
size?: 'sm' | 'md' | 'lg' | 'xl'
|
size?: 'sm' | 'md' | 'lg' | 'xl'
|
||||||
|
position?: 'center' | 'top' | 'bottom'
|
||||||
className?: string
|
className?: string
|
||||||
}) {
|
}) {
|
||||||
const { children, open, setOpen, size = 'md', className } = props
|
const { children, position, open, setOpen, size = 'md', className } = props
|
||||||
|
|
||||||
const sizeClass = {
|
const sizeClass = {
|
||||||
sm: 'max-w-sm',
|
sm: 'max-w-sm',
|
||||||
|
@ -19,6 +20,12 @@ export function Modal(props: {
|
||||||
xl: 'max-w-5xl',
|
xl: 'max-w-5xl',
|
||||||
}[size]
|
}[size]
|
||||||
|
|
||||||
|
const positionClass = {
|
||||||
|
center: 'items-center',
|
||||||
|
top: 'items-start',
|
||||||
|
bottom: 'items-end',
|
||||||
|
}[position ?? 'bottom']
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Transition.Root show={open} as={Fragment}>
|
<Transition.Root show={open} as={Fragment}>
|
||||||
<Dialog
|
<Dialog
|
||||||
|
@ -26,7 +33,12 @@ export function Modal(props: {
|
||||||
className="fixed inset-0 z-50 overflow-y-auto"
|
className="fixed inset-0 z-50 overflow-y-auto"
|
||||||
onClose={setOpen}
|
onClose={setOpen}
|
||||||
>
|
>
|
||||||
<div className="flex min-h-screen items-end justify-center px-4 pt-4 pb-20 text-center sm:p-0">
|
<div
|
||||||
|
className={clsx(
|
||||||
|
'flex min-h-screen justify-center px-4 pt-4 pb-20 text-center sm:p-0',
|
||||||
|
positionClass
|
||||||
|
)}
|
||||||
|
>
|
||||||
<Transition.Child
|
<Transition.Child
|
||||||
as={Fragment}
|
as={Fragment}
|
||||||
enter="ease-out duration-300"
|
enter="ease-out duration-300"
|
||||||
|
|
|
@ -147,7 +147,7 @@ export default function TournamentPage(props: { sections: SectionInfo[] }) {
|
||||||
{sections.map(({ tourney, slug, numPeople }) => (
|
{sections.map(({ tourney, slug, numPeople }) => (
|
||||||
<div key={slug}>
|
<div key={slug}>
|
||||||
<SectionHeader
|
<SectionHeader
|
||||||
url={groupPath(slug)}
|
url={groupPath(slug, 'about')}
|
||||||
title={tourney.title}
|
title={tourney.title}
|
||||||
ppl={numPeople}
|
ppl={numPeople}
|
||||||
award={tourney.award}
|
award={tourney.award}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user