From 4ad5485988fbb7ccf5789812845dd355cd6ec255 Mon Sep 17 00:00:00 2001 From: mantikoros Date: Sat, 29 Jan 2022 21:52:26 -0600 Subject: [PATCH] rename MKT to PROB; show resolved probability; move format utilities to common --- {web/lib => common}/util/format.ts | 0 functions/src/emails.ts | 7 +++++-- web/components/amount-input.tsx | 2 +- web/components/bet-panel.tsx | 2 +- web/components/bets-list.tsx | 2 +- web/components/contract-card.tsx | 4 ++-- web/components/contract-feed.tsx | 2 +- web/components/create-fold-button.tsx | 2 +- web/components/edit-fold-button.tsx | 2 +- web/components/outcome-label.tsx | 2 +- web/components/profile-menu.tsx | 2 +- web/components/resolution-panel.tsx | 4 ++-- web/components/yes-no-selector.tsx | 4 ++-- web/pages/fold/[...slugs]/index.tsx | 2 +- web/pages/leaderboards.tsx | 3 ++- 15 files changed, 22 insertions(+), 18 deletions(-) rename {web/lib => common}/util/format.ts (100%) diff --git a/web/lib/util/format.ts b/common/util/format.ts similarity index 100% rename from web/lib/util/format.ts rename to common/util/format.ts diff --git a/functions/src/emails.ts b/functions/src/emails.ts index 8650d981..971c51e7 100644 --- a/functions/src/emails.ts +++ b/functions/src/emails.ts @@ -1,5 +1,7 @@ +import { getProbability } from '../../common/calculate' import { Contract } from '../../common/contract' import { User } from '../../common/user' +import { formatPercent } from '../../common/util/format' import { sendTemplateEmail } from './send-email' import { getPrivateUser, getUser } from './utils' @@ -31,7 +33,8 @@ export const sendMarketResolutionEmail = async ( const user = await getUser(userId) if (!user) return - const outcome = toDisplayResolution[resolution] + const prob = formatPercent(getProbability(contract.totalShares)) + const outcome = toDisplayResolution[resolution].replace('PROB', prob) const subject = `Resolved ${outcome}: ${contract.question}` @@ -57,4 +60,4 @@ export const sendMarketResolutionEmail = async ( ) } -const toDisplayResolution = { YES: 'YES', NO: 'NO', CANCEL: 'N/A', MKT: 'MKT' } +const toDisplayResolution = { YES: 'YES', NO: 'NO', CANCEL: 'N/A', MKT: 'PROB' } diff --git a/web/components/amount-input.tsx b/web/components/amount-input.tsx index 9968a132..f01ae418 100644 --- a/web/components/amount-input.tsx +++ b/web/components/amount-input.tsx @@ -1,6 +1,6 @@ import clsx from 'clsx' import { useUser } from '../hooks/use-user' -import { formatMoney } from '../lib/util/format' +import { formatMoney } from '../../common/util/format' import { AddFundsButton } from './add-funds-button' import { Col } from './layout/col' import { Row } from './layout/row' diff --git a/web/components/bet-panel.tsx b/web/components/bet-panel.tsx index 12a094fb..5fd9b1f4 100644 --- a/web/components/bet-panel.tsx +++ b/web/components/bet-panel.tsx @@ -11,7 +11,7 @@ import { formatMoney, formatPercent, formatWithCommas, -} from '../lib/util/format' +} from '../../common/util/format' import { Title } from './title' import { getProbability, diff --git a/web/components/bets-list.tsx b/web/components/bets-list.tsx index 85a4fe71..5af4bb0d 100644 --- a/web/components/bets-list.tsx +++ b/web/components/bets-list.tsx @@ -11,7 +11,7 @@ import { formatMoney, formatPercent, formatWithCommas, -} from '../lib/util/format' +} from '../../common/util/format' import { Col } from './layout/col' import { Spacer } from './layout/spacer' import { diff --git a/web/components/contract-card.tsx b/web/components/contract-card.tsx index 9f91d272..e682c12a 100644 --- a/web/components/contract-card.tsx +++ b/web/components/contract-card.tsx @@ -1,7 +1,7 @@ import clsx from 'clsx' import Link from 'next/link' import { Row } from '../components/layout/row' -import { formatMoney } from '../lib/util/format' +import { formatMoney } from '../../common/util/format' import { UserLink } from './user-page' import { Contract, @@ -74,7 +74,7 @@ export function ResolutionOrChance(props: { const resolutionText = { YES: 'YES', NO: 'NO', - MKT: 'MKT', + MKT: probPercent, CANCEL: 'N/A', '': '', }[resolution || ''] diff --git a/web/components/contract-feed.tsx b/web/components/contract-feed.tsx index c8618691..c5ae3ee5 100644 --- a/web/components/contract-feed.tsx +++ b/web/components/contract-feed.tsx @@ -27,7 +27,7 @@ import { Linkify } from './linkify' import { Row } from './layout/row' import { createComment } from '../lib/firebase/comments' import { useComments } from '../hooks/use-comments' -import { formatMoney } from '../lib/util/format' +import { formatMoney } from '../../common/util/format' import { ResolutionOrChance } from './contract-card' import { SiteLink } from './site-link' import { Col } from './layout/col' diff --git a/web/components/create-fold-button.tsx b/web/components/create-fold-button.tsx index c68f1223..794ed8ab 100644 --- a/web/components/create-fold-button.tsx +++ b/web/components/create-fold-button.tsx @@ -4,7 +4,7 @@ import { useState } from 'react' import { parseWordsAsTags } from '../../common/util/parse' import { createFold } from '../lib/firebase/api-call' import { foldPath } from '../lib/firebase/folds' -import { toCamelCase } from '../lib/util/format' +import { toCamelCase } from '../../common/util/format' import { ConfirmationButton } from './confirmation-button' import { Col } from './layout/col' import { Spacer } from './layout/spacer' diff --git a/web/components/edit-fold-button.tsx b/web/components/edit-fold-button.tsx index 64ffc2fe..3019f3a1 100644 --- a/web/components/edit-fold-button.tsx +++ b/web/components/edit-fold-button.tsx @@ -6,7 +6,7 @@ import { PencilIcon } from '@heroicons/react/outline' import { Fold } from '../../common/fold' import { parseWordsAsTags } from '../../common/util/parse' import { deleteFold, updateFold } from '../lib/firebase/folds' -import { toCamelCase } from '../lib/util/format' +import { toCamelCase } from '../../common/util/format' import { Spacer } from './layout/spacer' import { TagsList } from './tags-list' import { useRouter } from 'next/router' diff --git a/web/components/outcome-label.tsx b/web/components/outcome-label.tsx index 1eb8ac4f..c8831c89 100644 --- a/web/components/outcome-label.tsx +++ b/web/components/outcome-label.tsx @@ -22,5 +22,5 @@ export function CancelLabel() { } export function MarketLabel() { - return MKT + return PROB } diff --git a/web/components/profile-menu.tsx b/web/components/profile-menu.tsx index 94f2c3f6..327b389b 100644 --- a/web/components/profile-menu.tsx +++ b/web/components/profile-menu.tsx @@ -1,5 +1,5 @@ import { firebaseLogout, User } from '../lib/firebase/users' -import { formatMoney } from '../lib/util/format' +import { formatMoney } from '../../common/util/format' import { Avatar } from './avatar' import { Col } from './layout/col' import { MenuButton } from './menu' diff --git a/web/components/resolution-panel.tsx b/web/components/resolution-panel.tsx index 64e643a3..25ca650e 100644 --- a/web/components/resolution-panel.tsx +++ b/web/components/resolution-panel.tsx @@ -82,8 +82,8 @@ export function ResolutionPanel(props: { <>The pool will be returned to traders with no fees. ) : outcome === 'MKT' ? ( <> - Traders will be paid out at the current implied probability. You - earn 1% of the pool. + Traders will be paid out at the probability you specify. You earn 1% + of the pool. ) : ( <>Resolving this market will immediately pay out traders. diff --git a/web/components/yes-no-selector.tsx b/web/components/yes-no-selector.tsx index 8073ffe4..91cf6358 100644 --- a/web/components/yes-no-selector.tsx +++ b/web/components/yes-no-selector.tsx @@ -1,6 +1,6 @@ import clsx from 'clsx' import React from 'react' -import { formatMoney } from '../lib/util/format' +import { formatMoney } from '../../common/util/format' import { Col } from './layout/col' import { Row } from './layout/row' @@ -78,7 +78,7 @@ export function YesNoCancelSelector(props: { onClick={() => onSelect('MKT')} className={clsx(btnClassName, 'btn-sm')} > - MKT + PROB