diff --git a/common/antes.ts b/common/antes.ts index b9914451..d4e624b1 100644 --- a/common/antes.ts +++ b/common/antes.ts @@ -11,11 +11,8 @@ import { import { User } from './user' import { LiquidityProvision } from './liquidity-provision' import { noFees } from './fees' -import { ENV_CONFIG } from './envs/constants' import { Answer } from './answer' -export const FIXED_ANTE = ENV_CONFIG.fixedAnte ?? 100 - export const HOUSE_LIQUIDITY_PROVIDER_ID = 'IPTOzEqrpkWmEzh6hwvAyY9PqFb2' // @ManifoldMarkets' id export const DEV_HOUSE_LIQUIDITY_PROVIDER_ID = '94YYTk1AFWfbWMpfYcvnnwI1veP2' // @ManifoldMarkets' id diff --git a/common/economy.ts b/common/economy.ts new file mode 100644 index 00000000..cd40f87c --- /dev/null +++ b/common/economy.ts @@ -0,0 +1,16 @@ +import { ENV_CONFIG } from './envs/constants' + +const econ = ENV_CONFIG.economy + +export const FIXED_ANTE = econ?.FIXED_ANTE ?? 100 + +export const STARTING_BALANCE = econ?.STARTING_BALANCE ?? 1000 +// for sus users, i.e. multiple sign ups for same person +export const SUS_STARTING_BALANCE = econ?.SUS_STARTING_BALANCE ?? 10 +export const REFERRAL_AMOUNT = econ?.REFERRAL_AMOUNT ?? 500 + +export const UNIQUE_BETTOR_BONUS_AMOUNT = econ?.UNIQUE_BETTOR_BONUS_AMOUNT ?? 10 +export const BETTING_STREAK_BONUS_AMOUNT = + econ?.BETTING_STREAK_BONUS_AMOUNT ?? 5 +export const BETTING_STREAK_BONUS_MAX = econ?.BETTING_STREAK_BONUS_MAX ?? 100 +export const BETTING_STREAK_RESET_HOUR = econ?.BETTING_STREAK_RESET_HOUR ?? 0 diff --git a/common/envs/prod.ts b/common/envs/prod.ts index 5bd12095..033d050f 100644 --- a/common/envs/prod.ts +++ b/common/envs/prod.ts @@ -19,10 +19,22 @@ export type EnvConfig = { navbarLogoPath?: string newQuestionPlaceholders: string[] - // Currency controls - fixedAnte?: number - startingBalance?: number - referralBonus?: number + economy?: Economy +} + +export type Economy = { + FIXED_ANTE?: number + + STARTING_BALANCE?: number + SUS_STARTING_BALANCE?: number + + REFERRAL_AMOUNT?: number + + UNIQUE_BETTOR_BONUS_AMOUNT?: number + + BETTING_STREAK_BONUS_AMOUNT?: number + BETTING_STREAK_BONUS_MAX?: number + BETTING_STREAK_RESET_HOUR?: number } type FirebaseConfig = { diff --git a/common/numeric-constants.ts b/common/numeric-constants.ts index 3e5af0d3..ef364b74 100644 --- a/common/numeric-constants.ts +++ b/common/numeric-constants.ts @@ -3,7 +3,3 @@ export const NUMERIC_FIXED_VAR = 0.005 export const NUMERIC_GRAPH_COLOR = '#5fa5f9' export const NUMERIC_TEXT_COLOR = 'text-blue-500' -export const UNIQUE_BETTOR_BONUS_AMOUNT = 10 -export const BETTING_STREAK_BONUS_AMOUNT = 5 -export const BETTING_STREAK_BONUS_MAX = 100 -export const BETTING_STREAK_RESET_HOUR = 0 diff --git a/common/user.ts b/common/user.ts index 4b21fe2d..dee1413f 100644 --- a/common/user.ts +++ b/common/user.ts @@ -1,5 +1,3 @@ -import { ENV_CONFIG } from './envs/constants' - export type User = { id: string createdTime: number @@ -46,11 +44,6 @@ export type User = { currentBettingStreak?: number } -export const STARTING_BALANCE = ENV_CONFIG.startingBalance ?? 1000 -// for sus users, i.e. multiple sign ups for same person -export const SUS_STARTING_BALANCE = ENV_CONFIG.startingBalance ?? 10 -export const REFERRAL_AMOUNT = ENV_CONFIG.referralBonus ?? 500 - export type PrivateUser = { id: string // same as User.id username: string // denormalized from User diff --git a/functions/src/create-market.ts b/functions/src/create-market.ts index 5b0d1daf..c3780a1f 100644 --- a/functions/src/create-market.ts +++ b/functions/src/create-market.ts @@ -18,8 +18,8 @@ import { randomString } from '../../common/util/random' import { chargeUser, getContract } from './utils' import { APIError, newEndpoint, validate, zTimestamp } from './api' +import { FIXED_ANTE } from 'common/economy' import { - FIXED_ANTE, getCpmmInitialLiquidity, getFreeAnswerAnte, getMultipleChoiceAntes, diff --git a/functions/src/create-user.ts b/functions/src/create-user.ts index f42fb5c3..54e37d62 100644 --- a/functions/src/create-user.ts +++ b/functions/src/create-user.ts @@ -6,8 +6,6 @@ import { MANIFOLD_AVATAR_URL, MANIFOLD_USERNAME, PrivateUser, - STARTING_BALANCE, - SUS_STARTING_BALANCE, User, } from '../../common/user' import { getUser, getUserByUsername, getValues, isProd } from './utils' @@ -29,6 +27,7 @@ import { DEV_HOUSE_LIQUIDITY_PROVIDER_ID, HOUSE_LIQUIDITY_PROVIDER_ID, } from '../../common/antes' +import { SUS_STARTING_BALANCE, STARTING_BALANCE } from 'common/economy' const bodySchema = z.object({ deviceToken: z.string().optional(), diff --git a/functions/src/on-create-bet.ts b/functions/src/on-create-bet.ts index 45adade5..ff6cf9d9 100644 --- a/functions/src/on-create-bet.ts +++ b/functions/src/on-create-bet.ts @@ -17,7 +17,7 @@ import { BETTING_STREAK_BONUS_MAX, BETTING_STREAK_RESET_HOUR, UNIQUE_BETTOR_BONUS_AMOUNT, -} from '../../common/numeric-constants' +} from '../../common/economy' import { DEV_HOUSE_LIQUIDITY_PROVIDER_ID, HOUSE_LIQUIDITY_PROVIDER_ID, diff --git a/functions/src/on-update-user.ts b/functions/src/on-update-user.ts index a76132b5..3dc09a1b 100644 --- a/functions/src/on-update-user.ts +++ b/functions/src/on-update-user.ts @@ -1,6 +1,6 @@ import * as functions from 'firebase-functions' import * as admin from 'firebase-admin' -import { REFERRAL_AMOUNT, User } from '../../common/user' +import { User } from '../../common/user' import { HOUSE_LIQUIDITY_PROVIDER_ID } from '../../common/antes' import { createReferralNotification } from './create-notification' import { ReferralTxn } from '../../common/txn' @@ -8,6 +8,7 @@ import { Contract } from '../../common/contract' import { LimitBet } from 'common/bet' import { QuerySnapshot } from 'firebase-admin/firestore' import { Group } from 'common/group' +import { REFERRAL_AMOUNT } from 'common/economy' const firestore = admin.firestore() export const onUpdateUser = functions.firestore diff --git a/functions/src/reset-betting-streaks.ts b/functions/src/reset-betting-streaks.ts index e1c3af8f..c781aba2 100644 --- a/functions/src/reset-betting-streaks.ts +++ b/functions/src/reset-betting-streaks.ts @@ -4,7 +4,7 @@ import * as functions from 'firebase-functions' import * as admin from 'firebase-admin' import { User } from '../../common/user' import { DAY_MS } from '../../common/util/time' -import { BETTING_STREAK_RESET_HOUR } from '../../common/numeric-constants' +import { BETTING_STREAK_RESET_HOUR } from '../../common/economy' const firestore = admin.firestore() export const resetBettingStreaksForUsers = functions.pubsub diff --git a/functions/src/scripts/create-private-users.ts b/functions/src/scripts/create-private-users.ts index 9b0c4096..acce446e 100644 --- a/functions/src/scripts/create-private-users.ts +++ b/functions/src/scripts/create-private-users.ts @@ -3,7 +3,8 @@ import * as admin from 'firebase-admin' import { initAdmin } from './script-init' initAdmin() -import { PrivateUser, STARTING_BALANCE, User } from '../../../common/user' +import { PrivateUser, User } from 'common/user' +import { STARTING_BALANCE } from 'common/economy' const firestore = admin.firestore() diff --git a/web/components/challenges/create-challenge-modal.tsx b/web/components/challenges/create-challenge-modal.tsx index b1ac7704..6f91a6d4 100644 --- a/web/components/challenges/create-challenge-modal.tsx +++ b/web/components/challenges/create-challenge-modal.tsx @@ -21,7 +21,7 @@ import { AmountInput } from '../amount-input' import { getProbability } from 'common/calculate' import { createMarket } from 'web/lib/firebase/api' import { removeUndefinedProps } from 'common/util/object' -import { FIXED_ANTE } from 'common/antes' +import { FIXED_ANTE } from 'common/economy' import Textarea from 'react-expanding-textarea' import { useTextEditor } from 'web/components/editor' import { LoadingIndicator } from 'web/components/loading-indicator' diff --git a/web/components/contract/share-modal.tsx b/web/components/contract/share-modal.tsx index e1805364..2c74a5a4 100644 --- a/web/components/contract/share-modal.tsx +++ b/web/components/contract/share-modal.tsx @@ -14,9 +14,10 @@ import { Button } from '../button' import { copyToClipboard } from 'web/lib/util/copy' import { track } from 'web/lib/service/analytics' import { ENV_CONFIG } from 'common/envs/constants' -import { REFERRAL_AMOUNT, User } from 'common/user' +import { User } from 'common/user' import { SiteLink } from '../site-link' import { formatMoney } from 'common/util/format' +import { REFERRAL_AMOUNT } from 'common/economy' export function ShareModal(props: { contract: Contract diff --git a/web/components/profile/betting-streak-modal.tsx b/web/components/profile/betting-streak-modal.tsx index 732292f1..694a0193 100644 --- a/web/components/profile/betting-streak-modal.tsx +++ b/web/components/profile/betting-streak-modal.tsx @@ -3,7 +3,7 @@ import { Col } from 'web/components/layout/col' import { BETTING_STREAK_BONUS_AMOUNT, BETTING_STREAK_BONUS_MAX, -} from 'common/numeric-constants' +} from 'common/economy' import { formatMoney } from 'common/util/format' export function BettingStreakModal(props: { diff --git a/web/components/user-page.tsx b/web/components/user-page.tsx index dc68898f..92404f89 100644 --- a/web/components/user-page.tsx +++ b/web/components/user-page.tsx @@ -29,8 +29,8 @@ import { formatMoney } from 'common/util/format' import { ShareIconButton } from 'web/components/share-icon-button' import { ENV_CONFIG } from 'common/envs/constants' import { BettingStreakModal } from 'web/components/profile/betting-streak-modal' +import { REFERRAL_AMOUNT } from 'common/economy' import { LoansModal } from './profile/loans-modal' -import { REFERRAL_AMOUNT } from 'common/user' export function UserLink(props: { name: string diff --git a/web/pages/create.tsx b/web/pages/create.tsx index d7422ff1..52f2a373 100644 --- a/web/pages/create.tsx +++ b/web/pages/create.tsx @@ -7,7 +7,7 @@ import { Spacer } from 'web/components/layout/spacer' import { getUserAndPrivateUser } from 'web/lib/firebase/users' import { Contract, contractPath } from 'web/lib/firebase/contracts' import { createMarket } from 'web/lib/firebase/api' -import { FIXED_ANTE } from 'common/antes' +import { FIXED_ANTE } from 'common/economy' import { InfoTooltip } from 'web/components/info-tooltip' import { Page } from 'web/components/page' import { Row } from 'web/components/layout/row' diff --git a/web/pages/group/[...slugs]/index.tsx b/web/pages/group/[...slugs]/index.tsx index 20b1a8ce..8926d0ab 100644 --- a/web/pages/group/[...slugs]/index.tsx +++ b/web/pages/group/[...slugs]/index.tsx @@ -34,7 +34,6 @@ import { Modal } from 'web/components/layout/modal' import { ChoicesToggleGroup } from 'web/components/choices-toggle-group' import { toast } from 'react-hot-toast' import { useCommentsOnGroup } from 'web/hooks/use-comments' -import { REFERRAL_AMOUNT } from 'common/user' import { ContractSearch } from 'web/components/contract-search' import { FollowList } from 'web/components/follow-list' import { SearchIcon } from '@heroicons/react/outline' @@ -48,6 +47,7 @@ import { Button } from 'web/components/button' import { listAllCommentsOnGroup } from 'web/lib/firebase/comments' import { GroupComment } from 'common/comment' import { GroupChat } from 'web/components/groups/group-chat' +import { REFERRAL_AMOUNT } from 'common/economy' export const getStaticProps = fromPropz(getStaticPropz) export async function getStaticPropz(props: { params: { slugs: string[] } }) { diff --git a/web/pages/links.tsx b/web/pages/links.tsx index 351abefb..6f57dc14 100644 --- a/web/pages/links.tsx +++ b/web/pages/links.tsx @@ -25,8 +25,8 @@ import { redirectIfLoggedOut } from 'web/lib/firebase/server-auth' import { ManalinkCardFromView } from 'web/components/manalink-card' import { Pagination } from 'web/components/pagination' import { Manalink } from 'common/manalink' -import { REFERRAL_AMOUNT } from 'common/user' import { SiteLink } from 'web/components/site-link' +import { REFERRAL_AMOUNT } from 'common/economy' const LINKS_PER_PAGE = 24 diff --git a/web/pages/notifications.tsx b/web/pages/notifications.tsx index 7ec5e1ea..ccfcf1b3 100644 --- a/web/pages/notifications.tsx +++ b/web/pages/notifications.tsx @@ -34,7 +34,7 @@ import { groupPath } from 'web/lib/firebase/groups' import { BETTING_STREAK_BONUS_AMOUNT, UNIQUE_BETTOR_BONUS_AMOUNT, -} from 'common/numeric-constants' +} from 'common/economy' import { groupBy, sum, uniq } from 'lodash' import { track } from '@amplitude/analytics-browser' import { Pagination } from 'web/components/pagination' diff --git a/web/pages/referrals.tsx b/web/pages/referrals.tsx index c30418cf..2e330980 100644 --- a/web/pages/referrals.tsx +++ b/web/pages/referrals.tsx @@ -5,11 +5,11 @@ import { useUser } from 'web/hooks/use-user' import { Page } from 'web/components/page' import { useTracking } from 'web/hooks/use-tracking' import { redirectIfLoggedOut } from 'web/lib/firebase/server-auth' -import { REFERRAL_AMOUNT } from 'common/user' import { CopyLinkButton } from 'web/components/copy-link-button' import { ENV_CONFIG } from 'common/envs/constants' import { InfoBox } from 'web/components/info-box' import { QRCode } from 'web/components/qr-code' +import { REFERRAL_AMOUNT } from 'common/economy' export const getServerSideProps = redirectIfLoggedOut('/')