diff --git a/functions/src/create-contract.ts b/functions/src/create-contract.ts index ec81ba6e..71d778b3 100644 --- a/functions/src/create-contract.ts +++ b/functions/src/create-contract.ts @@ -22,7 +22,6 @@ import { getCpmmInitialLiquidity, getFreeAnswerAnte, getNumericAnte, - HOUSE_LIQUIDITY_PROVIDER_ID, } from '../../common/antes' import { getNoneAnswer } from '../../common/answer' import { getNewContract } from '../../common/new-contract' @@ -64,31 +63,16 @@ export const createmarket = newEndpoint(['POST'], async (req, auth) => { ;({ initialProb } = validate(binarySchema, req.body)) } - // Uses utc time on server: - const today = new Date() - let freeMarketResetTime = new Date().setUTCHours(16, 0, 0, 0) - if (today.getTime() < freeMarketResetTime) { - freeMarketResetTime = freeMarketResetTime - 24 * 60 * 60 * 1000 - } - const userDoc = await firestore.collection('users').doc(auth.uid).get() if (!userDoc.exists) { throw new APIError(400, 'No user exists with the authenticated user ID.') } const user = userDoc.data() as User - const userContractsCreatedTodaySnapshot = await firestore - .collection(`contracts`) - .where('creatorId', '==', auth.uid) - .where('createdTime', '>=', freeMarketResetTime) - .get() - console.log('free market reset time: ', freeMarketResetTime) - const isFree = userContractsCreatedTodaySnapshot.size === 0 - const ante = FIXED_ANTE // TODO: this is broken because it's not in a transaction - if (ante > user.balance && !isFree) + if (ante > user.balance) throw new APIError(400, `Balance must be at least ${ante}.`) const slug = await getSlug(question) @@ -140,11 +124,11 @@ export const createmarket = newEndpoint(['POST'], async (req, auth) => { max ?? 0 ) - if (!isFree && ante) await chargeUser(user.id, ante, true) + if (ante) await chargeUser(user.id, ante, true) await contractRef.create(contract) - const providerId = isFree ? HOUSE_LIQUIDITY_PROVIDER_ID : user.id + const providerId = user.id if (outcomeType === 'BINARY') { const liquidityDoc = firestore diff --git a/web/components/nav/sidebar.tsx b/web/components/nav/sidebar.tsx index 5716e5cd..0f8d59eb 100644 --- a/web/components/nav/sidebar.tsx +++ b/web/components/nav/sidebar.tsx @@ -181,28 +181,8 @@ export default function Sidebar(props: { className?: string }) { const { className } = props const router = useRouter() const currentPage = router.pathname - const [countdown, setCountdown] = useState('...') - useEffect(() => { - const nextUtcResetTime = getUtcFreeMarketResetTime({ previousTime: false }) - const interval = setInterval(() => { - const now = new Date().getTime() - const timeUntil = nextUtcResetTime - now - const hoursUntil = timeUntil / 1000 / 60 / 60 - const minutesUntil = (hoursUntil * 60) % 60 - const secondsUntil = Math.round((hoursUntil * 60 * 60) % 60) - const timeString = - hoursUntil < 1 && minutesUntil < 1 - ? `${secondsUntil}s` - : hoursUntil < 1 - ? `${Math.round(minutesUntil)}m` - : `${Math.floor(hoursUntil)}h` - setCountdown(timeString) - }, 1000) - return () => clearInterval(interval) - }, []) const user = useUser() - const mustWaitForFreeMarketStatus = useHasCreatedContractToday(user) const navigationOptions = !user ? signedOutNavigation : getNavigation(user?.username || 'error') @@ -306,27 +286,6 @@ export default function Sidebar(props: { className?: string }) { /> - - {user && - mustWaitForFreeMarketStatus != 'loading' && - mustWaitForFreeMarketStatus ? ( - - - Next free question in {countdown} - - - ) : ( - user && - mustWaitForFreeMarketStatus != 'loading' && - !mustWaitForFreeMarketStatus && ( - - - Daily free question - - - ) - )} ) } diff --git a/web/pages/create.tsx b/web/pages/create.tsx index c032b2d0..53b73c7e 100644 --- a/web/pages/create.tsx +++ b/web/pages/create.tsx @@ -93,11 +93,6 @@ export function NewContract(props: { question: string; groupId?: string }) { }, [creator, groupId]) const [ante, _setAnte] = useState(FIXED_ANTE) - const mustWaitForDailyFreeMarketStatus = useHasCreatedContractToday(creator) - const isFree = - mustWaitForDailyFreeMarketStatus != 'loading' && - !mustWaitForDailyFreeMarketStatus - // useEffect(() => { // if (ante === null && creator) { // const initialAnte = creator.balance < 100 ? MINIMUM_ANTE : 100 @@ -138,9 +133,7 @@ export function NewContract(props: { question: string; groupId?: string }) { ante !== undefined && ante !== null && ante >= MINIMUM_ANTE && - (ante <= balance || - (mustWaitForDailyFreeMarketStatus != 'loading' && - !mustWaitForDailyFreeMarketStatus)) && + ante <= balance && // closeTime must be in the future closeTime && closeTime > Date.now() && @@ -181,7 +174,7 @@ export function NewContract(props: { question: string; groupId?: string }) { slug: result.slug, initialProb, selectedGroup: selectedGroup?.id, - isFree, + isFree: false, }) if (result && selectedGroup) { await updateGroup(selectedGroup, { @@ -369,41 +362,26 @@ export function NewContract(props: { question: string; groupId?: string }) {
- {mustWaitForDailyFreeMarketStatus != 'loading' && - !mustWaitForDailyFreeMarketStatus ? ( -
- - {formatMoney(ante)} - {' '} - FREE + +
+ {formatMoney(ante)} +
+ + {ante > balance && ( +
+ Insufficient balance +
- ) : ( - mustWaitForDailyFreeMarketStatus != 'loading' && ( -
- {formatMoney(ante)} -
- ) )} - {mustWaitForDailyFreeMarketStatus != 'loading' && - mustWaitForDailyFreeMarketStatus && - ante > balance && ( -
- Insufficient balance - -
- )}