diff --git a/common/antes.ts b/common/antes.ts index 6a0c0946..a443f508 100644 --- a/common/antes.ts +++ b/common/antes.ts @@ -5,6 +5,9 @@ import { User } from './user' import { LiquidityProvision } from './liquidity-provision' import { noFees } from './fees' +export const FIXED_ANTE = 100 + +// deprecated export const PHANTOM_ANTE = 0.001 export const MINIMUM_ANTE = 50 diff --git a/common/calculate.ts b/common/calculate.ts index 361606e4..4adecb54 100644 --- a/common/calculate.ts +++ b/common/calculate.ts @@ -1,4 +1,4 @@ -import _ from 'lodash' +import * as _ from 'lodash' import { Bet } from './bet' import { calculateCpmmSale, diff --git a/functions/src/create-contract.ts b/functions/src/create-contract.ts index 85bc211d..16a416b1 100644 --- a/functions/src/create-contract.ts +++ b/functions/src/create-contract.ts @@ -19,6 +19,7 @@ import { slugify } from '../../common/util/slugify' import { randomString } from '../../common/util/random' import { getNewContract } from '../../common/new-contract' import { + FIXED_ANTE, getAnteBets, getCpmmInitialLiquidity, getFreeAnswerAnte, @@ -47,7 +48,7 @@ export const createContract = functions const creator = await getUser(userId) if (!creator) return { status: 'error', message: 'User not found' } - let { question, description, initialProb, ante, closeTime, tags } = data + let { question, description, initialProb, closeTime, tags } = data if (!question || typeof question != 'string') return { status: 'error', message: 'Missing or invalid question field' } @@ -71,6 +72,8 @@ export const createContract = functions ) return { status: 'error', message: 'Invalid initial probability' } + const ante = FIXED_ANTE // data.ante + if ( ante === undefined || ante < MINIMUM_ANTE || diff --git a/web/pages/create.tsx b/web/pages/create.tsx index 4092e97e..e5a295af 100644 --- a/web/pages/create.tsx +++ b/web/pages/create.tsx @@ -9,7 +9,7 @@ import { useUser } from '../hooks/use-user' import { Contract, contractPath } from '../lib/firebase/contracts' import { createContract } from '../lib/firebase/api-call' import { BuyAmountInput } from '../components/amount-input' -import { MINIMUM_ANTE } from '../../common/antes' +import { FIXED_ANTE, MINIMUM_ANTE } from '../../common/antes' import { InfoTooltip } from '../components/info-tooltip' import { CREATOR_FEE } from '../../common/fees' import { Page } from '../components/page' @@ -19,6 +19,7 @@ import { parseWordsAsTags } from '../../common/util/parse' import { TagsList } from '../components/tags-list' import { Row } from '../components/layout/row' import { MAX_DESCRIPTION_LENGTH, outcomeType } from '../../common/contract' +import { formatMoney } from '../../common/util/format' export default function Create() { const [question, setQuestion] = useState('') @@ -69,15 +70,15 @@ export function NewContract(props: { question: string; tag?: string }) { const [tagText, setTagText] = useState(tag ?? '') const tags = parseWordsAsTags(tagText) - const [ante, setAnte] = useState(null) - useEffect(() => { - if (ante === null && creator) { - const initialAnte = creator.balance < 100 ? MINIMUM_ANTE : 100 - setAnte(initialAnte) - } - }, [ante, creator]) + const [ante, setAnte] = useState(FIXED_ANTE) + // useEffect(() => { + // if (ante === null && creator) { + // const initialAnte = creator.balance < 100 ? MINIMUM_ANTE : 100 + // setAnte(initialAnte) + // } + // }, [ante, creator]) - const [anteError, setAnteError] = useState() + // const [anteError, setAnteError] = useState() // By default, close the market a week from today const weekFromToday = dayjs().add(7, 'day').format('YYYY-MM-DDT23:59') const [closeDate, setCloseDate] = useState(weekFromToday) @@ -236,12 +237,27 @@ export function NewContract(props: { question: string; tag?: string }) {
- {formatMoney(ante)}
+ + {ante > balance && ( +
+ Insufficient balance + +
+ )} + + {/* + /> */}