create: fixed ante of $100
This commit is contained in:
parent
ab41404d07
commit
2fe71731e4
|
@ -5,6 +5,9 @@ import { User } from './user'
|
||||||
import { LiquidityProvision } from './liquidity-provision'
|
import { LiquidityProvision } from './liquidity-provision'
|
||||||
import { noFees } from './fees'
|
import { noFees } from './fees'
|
||||||
|
|
||||||
|
export const FIXED_ANTE = 100
|
||||||
|
|
||||||
|
// deprecated
|
||||||
export const PHANTOM_ANTE = 0.001
|
export const PHANTOM_ANTE = 0.001
|
||||||
export const MINIMUM_ANTE = 50
|
export const MINIMUM_ANTE = 50
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
import _ from 'lodash'
|
import * as _ from 'lodash'
|
||||||
import { Bet } from './bet'
|
import { Bet } from './bet'
|
||||||
import {
|
import {
|
||||||
calculateCpmmSale,
|
calculateCpmmSale,
|
||||||
|
|
|
@ -19,6 +19,7 @@ import { slugify } from '../../common/util/slugify'
|
||||||
import { randomString } from '../../common/util/random'
|
import { randomString } from '../../common/util/random'
|
||||||
import { getNewContract } from '../../common/new-contract'
|
import { getNewContract } from '../../common/new-contract'
|
||||||
import {
|
import {
|
||||||
|
FIXED_ANTE,
|
||||||
getAnteBets,
|
getAnteBets,
|
||||||
getCpmmInitialLiquidity,
|
getCpmmInitialLiquidity,
|
||||||
getFreeAnswerAnte,
|
getFreeAnswerAnte,
|
||||||
|
@ -47,7 +48,7 @@ export const createContract = functions
|
||||||
const creator = await getUser(userId)
|
const creator = await getUser(userId)
|
||||||
if (!creator) return { status: 'error', message: 'User not found' }
|
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')
|
if (!question || typeof question != 'string')
|
||||||
return { status: 'error', message: 'Missing or invalid question field' }
|
return { status: 'error', message: 'Missing or invalid question field' }
|
||||||
|
@ -71,6 +72,8 @@ export const createContract = functions
|
||||||
)
|
)
|
||||||
return { status: 'error', message: 'Invalid initial probability' }
|
return { status: 'error', message: 'Invalid initial probability' }
|
||||||
|
|
||||||
|
const ante = FIXED_ANTE // data.ante
|
||||||
|
|
||||||
if (
|
if (
|
||||||
ante === undefined ||
|
ante === undefined ||
|
||||||
ante < MINIMUM_ANTE ||
|
ante < MINIMUM_ANTE ||
|
||||||
|
|
|
@ -9,7 +9,7 @@ import { useUser } from '../hooks/use-user'
|
||||||
import { Contract, contractPath } from '../lib/firebase/contracts'
|
import { Contract, contractPath } from '../lib/firebase/contracts'
|
||||||
import { createContract } from '../lib/firebase/api-call'
|
import { createContract } from '../lib/firebase/api-call'
|
||||||
import { BuyAmountInput } from '../components/amount-input'
|
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 { InfoTooltip } from '../components/info-tooltip'
|
||||||
import { CREATOR_FEE } from '../../common/fees'
|
import { CREATOR_FEE } from '../../common/fees'
|
||||||
import { Page } from '../components/page'
|
import { Page } from '../components/page'
|
||||||
|
@ -19,6 +19,7 @@ import { parseWordsAsTags } from '../../common/util/parse'
|
||||||
import { TagsList } from '../components/tags-list'
|
import { TagsList } from '../components/tags-list'
|
||||||
import { Row } from '../components/layout/row'
|
import { Row } from '../components/layout/row'
|
||||||
import { MAX_DESCRIPTION_LENGTH, outcomeType } from '../../common/contract'
|
import { MAX_DESCRIPTION_LENGTH, outcomeType } from '../../common/contract'
|
||||||
|
import { formatMoney } from '../../common/util/format'
|
||||||
|
|
||||||
export default function Create() {
|
export default function Create() {
|
||||||
const [question, setQuestion] = useState('')
|
const [question, setQuestion] = useState('')
|
||||||
|
@ -69,15 +70,15 @@ export function NewContract(props: { question: string; tag?: string }) {
|
||||||
const [tagText, setTagText] = useState<string>(tag ?? '')
|
const [tagText, setTagText] = useState<string>(tag ?? '')
|
||||||
const tags = parseWordsAsTags(tagText)
|
const tags = parseWordsAsTags(tagText)
|
||||||
|
|
||||||
const [ante, setAnte] = useState<number | undefined | null>(null)
|
const [ante, setAnte] = useState(FIXED_ANTE)
|
||||||
useEffect(() => {
|
// useEffect(() => {
|
||||||
if (ante === null && creator) {
|
// if (ante === null && creator) {
|
||||||
const initialAnte = creator.balance < 100 ? MINIMUM_ANTE : 100
|
// const initialAnte = creator.balance < 100 ? MINIMUM_ANTE : 100
|
||||||
setAnte(initialAnte)
|
// setAnte(initialAnte)
|
||||||
}
|
// }
|
||||||
}, [ante, creator])
|
// }, [ante, creator])
|
||||||
|
|
||||||
const [anteError, setAnteError] = useState<string | undefined>()
|
// const [anteError, setAnteError] = useState<string | undefined>()
|
||||||
// By default, close the market a week from today
|
// By default, close the market a week from today
|
||||||
const weekFromToday = dayjs().add(7, 'day').format('YYYY-MM-DDT23:59')
|
const weekFromToday = dayjs().add(7, 'day').format('YYYY-MM-DDT23:59')
|
||||||
const [closeDate, setCloseDate] = useState<undefined | string>(weekFromToday)
|
const [closeDate, setCloseDate] = useState<undefined | string>(weekFromToday)
|
||||||
|
@ -236,12 +237,27 @@ export function NewContract(props: { question: string; tag?: string }) {
|
||||||
|
|
||||||
<div className="form-control mb-1 items-start">
|
<div className="form-control mb-1 items-start">
|
||||||
<label className="label mb-1 gap-2">
|
<label className="label mb-1 gap-2">
|
||||||
<span>Market subsidy</span>
|
<span>Cost</span>
|
||||||
<InfoTooltip
|
<InfoTooltip
|
||||||
text={`Provide liquidity to encourage traders to participate.`}
|
text={`Cost to create your market. This amount is used to subsidize trading.`}
|
||||||
/>
|
/>
|
||||||
</label>
|
</label>
|
||||||
<BuyAmountInput
|
|
||||||
|
<div className="label-text text-neutral pl-1">{formatMoney(ante)}</div>
|
||||||
|
|
||||||
|
{ante > balance && (
|
||||||
|
<div className="mb-2 mt-2 mr-auto self-center whitespace-nowrap text-xs font-medium tracking-wide">
|
||||||
|
<span className="mr-2 text-red-500">Insufficient balance</span>
|
||||||
|
<button
|
||||||
|
className="btn btn-xs btn-primary"
|
||||||
|
onClick={() => (window.location.href = '/add-funds')}
|
||||||
|
>
|
||||||
|
Add funds
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
|
||||||
|
{/* <BuyAmountInput
|
||||||
amount={ante ?? undefined}
|
amount={ante ?? undefined}
|
||||||
minimumAmount={MINIMUM_ANTE}
|
minimumAmount={MINIMUM_ANTE}
|
||||||
onChange={setAnte}
|
onChange={setAnte}
|
||||||
|
@ -249,7 +265,7 @@ export function NewContract(props: { question: string; tag?: string }) {
|
||||||
setError={setAnteError}
|
setError={setAnteError}
|
||||||
disabled={isSubmitting}
|
disabled={isSubmitting}
|
||||||
contractIdForLoan={undefined}
|
contractIdForLoan={undefined}
|
||||||
/>
|
/> */}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<Spacer h={4} />
|
<Spacer h={4} />
|
||||||
|
|
Loading…
Reference in New Issue
Block a user