From cf74a195b2c731f2c2e4071f082f7a4886bd5ebb Mon Sep 17 00:00:00 2001 From: James Grugett Date: Thu, 8 Sep 2022 22:57:02 -0500 Subject: [PATCH 01/10] Redeem shares: pay back a smaller frac of your loan --- common/redeem.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/common/redeem.ts b/common/redeem.ts index e0839ff8..f786a1c2 100644 --- a/common/redeem.ts +++ b/common/redeem.ts @@ -13,7 +13,10 @@ export const getRedeemableAmount = (bets: RedeemableBet[]) => { const yesShares = sumBy(yesBets, (b) => b.shares) const noShares = sumBy(noBets, (b) => b.shares) const shares = Math.max(Math.min(yesShares, noShares), 0) - const soldFrac = shares > 0 ? Math.min(yesShares, noShares) / shares : 0 + const soldFrac = + shares > 0 + ? Math.min(yesShares, noShares) / Math.max(yesShares, noShares) + : 0 const loanAmount = sumBy(bets, (bet) => bet.loanAmount ?? 0) const loanPayment = loanAmount * soldFrac const netAmount = shares - loanPayment From 987ebccdfd7488222b41ead9ee122a30ae455696 Mon Sep 17 00:00:00 2001 From: James Grugett Date: Thu, 8 Sep 2022 23:45:26 -0500 Subject: [PATCH 02/10] Contract tabs: used passed in bets --- web/components/contract/contract-tabs.tsx | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/web/components/contract/contract-tabs.tsx b/web/components/contract/contract-tabs.tsx index 40fa9da0..d63d3963 100644 --- a/web/components/contract/contract-tabs.tsx +++ b/web/components/contract/contract-tabs.tsx @@ -13,7 +13,6 @@ import { Tabs } from '../layout/tabs' import { Col } from '../layout/col' import { tradingAllowed } from 'web/lib/firebase/contracts' import { CommentTipMap } from 'web/hooks/use-tip-txns' -import { useBets } from 'web/hooks/use-bets' import { useComments } from 'web/hooks/use-comments' import { useLiquidity } from 'web/hooks/use-liquidity' import { BetSignUpPrompt } from '../sign-up-prompt' @@ -27,24 +26,23 @@ export function ContractTabs(props: { comments: ContractComment[] tips: CommentTipMap }) { - const { contract, user, tips } = props + const { contract, user, bets, tips } = props const { outcomeType } = contract - const bets = useBets(contract.id) ?? props.bets - const lps = useLiquidity(contract.id) ?? [] + const lps = useLiquidity(contract.id) const userBets = user && bets.filter((bet) => !bet.isAnte && bet.userId === user.id) const visibleBets = bets.filter( (bet) => !bet.isAnte && !bet.isRedemption && bet.amount !== 0 ) - const visibleLps = lps.filter((l) => !l.isAnte && l.amount > 0) + const visibleLps = lps?.filter((l) => !l.isAnte && l.amount > 0) // Load comments here, so the badge count will be correct const updatedComments = useComments(contract.id) const comments = updatedComments ?? props.comments - const betActivity = ( + const betActivity = visibleLps && ( Date: Thu, 8 Sep 2022 23:55:33 -0500 Subject: [PATCH 03/10] slider: smarter step increments; disable clicking on track --- web/components/amount-input.tsx | 20 ++++++++++++++++---- web/tailwind.config.js | 12 ++++++++++++ 2 files changed, 28 insertions(+), 4 deletions(-) diff --git a/web/components/amount-input.tsx b/web/components/amount-input.tsx index 9eff26ef..2ad745a8 100644 --- a/web/components/amount-input.tsx +++ b/web/components/amount-input.tsx @@ -122,6 +122,18 @@ export function BuyAmountInput(props: { } } + const parseRaw = (x: number) => { + if (x <= 100) return x + if (x <= 130) return 100 + (x - 100) * 5 + return 250 + (x - 130) * 10 + } + + const getRaw = (x: number) => { + if (x <= 100) return x + if (x <= 250) return 100 + (x - 100) / 5 + return 130 + (x - 250) / 10 + } + return ( <> onAmountChange(parseInt(e.target.value))} - className="range range-lg z-40 mb-2 xl:hidden" + max="205" + value={getRaw(amount ?? 0)} + onChange={(e) => onAmountChange(parseRaw(parseInt(e.target.value)))} + className="range range-lg only-thumb z-40 mb-2 xl:hidden" step="5" /> )} diff --git a/web/tailwind.config.js b/web/tailwind.config.js index 566404fa..eb411216 100644 --- a/web/tailwind.config.js +++ b/web/tailwind.config.js @@ -60,6 +60,18 @@ module.exports = { 'overflow-wrap': 'anywhere', 'word-break': 'break-word', // for Safari }, + '.only-thumb': { + 'pointer-events': 'none', + '&::-webkit-slider-thumb': { + 'pointer-events': 'auto !important', + }, + '&::-moz-range-thumb': { + 'pointer-events': 'auto !important', + }, + '&::-ms-thumb': { + 'pointer-events': 'auto !important', + }, + }, }) }), ], From 2ebb83418c430864b0d0c1510f9a5637ed60eec0 Mon Sep 17 00:00:00 2001 From: mantikoros Date: Fri, 9 Sep 2022 00:02:06 -0500 Subject: [PATCH 04/10] bet panel: disable input focus on mobile --- web/components/bet-panel.tsx | 13 +++++-------- web/lib/util/device.ts | 4 ++++ 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/web/components/bet-panel.tsx b/web/components/bet-panel.tsx index a59d56f2..ce36cdf9 100644 --- a/web/components/bet-panel.tsx +++ b/web/components/bet-panel.tsx @@ -41,6 +41,7 @@ import { PillButton } from './buttons/pill-button' import { YesNoSelector } from './yes-no-selector' import { PlayMoneyDisclaimer } from './play-money-disclaimer' import { AlertBox } from './alert-box' +import { isAndroid, isIOS } from 'web/lib/util/device' export function BetPanel(props: { contract: CPMMBinaryContract | PseudoNumericContract @@ -184,17 +185,13 @@ function BuyPanel(props: { const [inputRef, focusAmountInput] = useFocus() - // useEffect(() => { - // if (selected) { - // if (isIOS()) window.scrollTo(0, window.scrollY + 200) - // focusAmountInput() - // } - // }, [selected, focusAmountInput]) - function onBetChoice(choice: 'YES' | 'NO') { setOutcome(choice) setWasSubmitted(false) - focusAmountInput() + + if (!isIOS() && !isAndroid()) { + focusAmountInput() + } } function onBetChange(newAmount: number | undefined) { diff --git a/web/lib/util/device.ts b/web/lib/util/device.ts index 20eabf75..8251d06c 100644 --- a/web/lib/util/device.ts +++ b/web/lib/util/device.ts @@ -12,3 +12,7 @@ export function isIOS() { (navigator.userAgent.includes('Mac') && 'ontouchend' in document) ) } + +export function isAndroid() { + return navigator.userAgent.includes('Android') +} \ No newline at end of file From 0dbb42aa6974c86247115d6f73e5cfec3f0156be Mon Sep 17 00:00:00 2001 From: mantikoros Date: Fri, 9 Sep 2022 05:03:05 +0000 Subject: [PATCH 05/10] Auto-prettification --- web/lib/util/device.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/web/lib/util/device.ts b/web/lib/util/device.ts index 8251d06c..8c54b731 100644 --- a/web/lib/util/device.ts +++ b/web/lib/util/device.ts @@ -15,4 +15,4 @@ export function isIOS() { export function isAndroid() { return navigator.userAgent.includes('Android') -} \ No newline at end of file +} From cd1d8ecd8a9d3d1c3f3855271b489a1e9a9730fb Mon Sep 17 00:00:00 2001 From: mantikoros Date: Fri, 9 Sep 2022 01:02:22 -0500 Subject: [PATCH 06/10] WarningConfirmationButton for bets --- web/components/answers/answer-bet-panel.tsx | 39 +++++----- web/components/bet-panel.tsx | 42 ++++------- web/components/confirmation-button.tsx | 6 +- .../warning-confirmation-button.tsx | 74 +++++++++++++++++++ 4 files changed, 109 insertions(+), 52 deletions(-) create mode 100644 web/components/warning-confirmation-button.tsx diff --git a/web/components/answers/answer-bet-panel.tsx b/web/components/answers/answer-bet-panel.tsx index 6e54b3b8..f84ff1a3 100644 --- a/web/components/answers/answer-bet-panel.tsx +++ b/web/components/answers/answer-bet-panel.tsx @@ -26,7 +26,7 @@ import { Bet } from 'common/bet' import { track } from 'web/lib/service/analytics' import { BetSignUpPrompt } from '../sign-up-prompt' import { isIOS } from 'web/lib/util/device' -import { AlertBox } from '../alert-box' +import { WarningConfirmationButton } from '../warning-confirmation-button' export function AnswerBetPanel(props: { answer: Answer @@ -116,6 +116,15 @@ export function AnswerBetPanel(props: { const bankrollFraction = (betAmount ?? 0) / (user?.balance ?? 1e9) + const warning = + (betAmount ?? 0) > 10 && bankrollFraction >= 0.5 && bankrollFraction <= 1 + ? `You might not want to spend ${formatPercent( + bankrollFraction + )} of your balance on a single bet. \n\nCurrent balance: ${formatMoney( + user?.balance ?? 0 + )}` + : undefined + return ( @@ -148,21 +157,6 @@ export function AnswerBetPanel(props: { showSliderOnMobile /> - {(betAmount ?? 0) > 10 && - bankrollFraction >= 0.5 && - bankrollFraction <= 1 ? ( - - ) : ( - '' - )} -
Probability
@@ -198,16 +192,17 @@ export function AnswerBetPanel(props: { {user ? ( - + /> ) : ( )} diff --git a/web/components/bet-panel.tsx b/web/components/bet-panel.tsx index ce36cdf9..2dca328a 100644 --- a/web/components/bet-panel.tsx +++ b/web/components/bet-panel.tsx @@ -40,8 +40,8 @@ import { LimitBets } from './limit-bets' import { PillButton } from './buttons/pill-button' import { YesNoSelector } from './yes-no-selector' import { PlayMoneyDisclaimer } from './play-money-disclaimer' -import { AlertBox } from './alert-box' import { isAndroid, isIOS } from 'web/lib/util/device' +import { WarningConfirmationButton } from './warning-confirmation-button' export function BetPanel(props: { contract: CPMMBinaryContract | PseudoNumericContract @@ -271,25 +271,15 @@ function BuyPanel(props: { const bankrollFraction = (betAmount ?? 0) / (user?.balance ?? 1e9) const warning = - (betAmount ?? 0) > 10 && - bankrollFraction >= 0.5 && - bankrollFraction <= 1 ? ( - 10 && bankrollFraction >= 0.5 && bankrollFraction <= 1 + ? `You might not want to spend ${formatPercent( bankrollFraction )} of your balance on a single trade. \n\nCurrent balance: ${formatMoney( user?.balance ?? 0 - )}`} - /> - ) : (betAmount ?? 0) > 10 && probChange >= 0.3 && bankrollFraction <= 1 ? ( - - ) : ( - <> - ) + )}` + : (betAmount ?? 0) > 10 && probChange >= 0.3 && bankrollFraction <= 1 + ? `Are you sure you want to move the market by ${displayedDifference}?` + : undefined return ( @@ -322,8 +312,6 @@ function BuyPanel(props: { showSliderOnMobile /> - {warning} -
@@ -364,20 +352,20 @@ function BuyPanel(props: { {user && ( - + /> )} {wasSubmitted &&
Trade submitted!
} diff --git a/web/components/confirmation-button.tsx b/web/components/confirmation-button.tsx index bc014902..8dbe90c2 100644 --- a/web/components/confirmation-button.tsx +++ b/web/components/confirmation-button.tsx @@ -47,13 +47,13 @@ export function ConfirmationButton(props: { {children}
updateOpen(false)} > {cancelBtn?.label ?? 'Cancel'}
@@ -69,7 +69,7 @@ export function ConfirmationButton(props: {
updateOpen(true)} > {openModalBtn.icon} diff --git a/web/components/warning-confirmation-button.tsx b/web/components/warning-confirmation-button.tsx new file mode 100644 index 00000000..7b707098 --- /dev/null +++ b/web/components/warning-confirmation-button.tsx @@ -0,0 +1,74 @@ +import clsx from 'clsx' +import React from 'react' + +import { Row } from './layout/row' +import { ConfirmationButton } from './confirmation-button' +import { ExclamationIcon } from '@heroicons/react/solid' + +export function WarningConfirmationButton(props: { + warning?: string + onSubmit: () => void + disabled?: boolean + isSubmitting: boolean + openModalButtonClass?: string + submitButtonClassName?: string +}) { + const { + onSubmit, + warning, + disabled, + isSubmitting, + openModalButtonClass, + submitButtonClassName, + } = props + + if (!warning) { + return ( + + ) + } + + return ( + + + + +

{warning}

+
+ ) +} From 1408908959ef9d91f1ebe48febce48fa83788fca Mon Sep 17 00:00:00 2001 From: Austin Chen Date: Fri, 9 Sep 2022 01:46:25 -0700 Subject: [PATCH 07/10] List the Manifold F2P tournament --- web/pages/tournaments/index.tsx | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/web/pages/tournaments/index.tsx b/web/pages/tournaments/index.tsx index b308ee7f..6bb65d23 100644 --- a/web/pages/tournaments/index.tsx +++ b/web/pages/tournaments/index.tsx @@ -77,13 +77,21 @@ const Salem = { const tourneys: Tourney[] = [ { - title: 'Cause Exploration Prizes', + title: 'Manifold F2P Tournament', blurb: - 'Which new charity ideas will Open Philanthropy find most promising?', - award: 'M$100k', - endTime: toDate('Sep 9, 2022'), - groupId: 'cMcpBQ2p452jEcJD2SFw', + 'Who can amass the most mana starting from a free-to-play (F2P) account?', + award: 'Poem', + endTime: toDate('Sep 15, 2022'), + groupId: '6rrIja7tVW00lUVwtsYS', }, + // { + // title: 'Cause Exploration Prizes', + // blurb: + // 'Which new charity ideas will Open Philanthropy find most promising?', + // award: 'M$100k', + // endTime: toDate('Sep 9, 2022'), + // groupId: 'cMcpBQ2p452jEcJD2SFw', + // }, { title: 'Fantasy Football Stock Exchange', blurb: 'How many points will each NFL player score this season?', From e639cb654e1cc91b3e89fc94a1bd82b9d1657a71 Mon Sep 17 00:00:00 2001 From: Ian Philips Date: Fri, 9 Sep 2022 07:22:31 -0600 Subject: [PATCH 08/10] Add group endpoint note in api docs --- docs/docs/api.md | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/docs/docs/api.md b/docs/docs/api.md index e284abdf..64e26de8 100644 --- a/docs/docs/api.md +++ b/docs/docs/api.md @@ -60,23 +60,27 @@ Parameters: Requires no authorization. -### `GET /v0/groups/[slug]` +### `GET /v0/group/[slug]` Gets a group by its slug. -Requires no authorization. +Requires no authorization. +Note: group is singular in the URL. ### `GET /v0/group/by-id/[id]` Gets a group by its unique ID. -Requires no authorization. +Requires no authorization. +Note: group is singular in the URL. ### `GET /v0/group/by-id/[id]/markets` Gets a group's markets by its unique ID. -Requires no authorization. +Requires no authorization. +Note: group is singular in the URL. + ### `GET /v0/markets` From aa5876fe0d522af86f04f09c1326ac1f6c0628bb Mon Sep 17 00:00:00 2001 From: marsteralex Date: Fri, 9 Sep 2022 09:51:20 -0700 Subject: [PATCH 09/10] added difficulty rating (#864) * fix https * add beasts * Remove extra file * Prettier-ify code * Prettier-ify * add basic land guesser also added fetcher to filter all cards instead of only unique art * default to original makes basic better * added set symbol to basics added set symbol to the basics game mode. Changed name to "How Basic" * cleanup * changed some pixels * only load set data if needed * hacked fix for removing image from name * removed check from original * remove check from original * sort names by set instead of by set symbol * include battlebond * update cards for categories update for dominaria united * added commander category commander category * update basic land art * can use double feature * removing racist cards upstream this way we don't have to store the cards in the json * remove generated cards from digital commanders * fix counterspell setting default * added difficulty rating * updated padding Co-authored-by: Austin Chen --- web/public/mtg/index.html | 181 ++++++++++++++++++++++++-------------- 1 file changed, 113 insertions(+), 68 deletions(-) diff --git a/web/public/mtg/index.html b/web/public/mtg/index.html index 15599eee..38aeb9f7 100644 --- a/web/public/mtg/index.html +++ b/web/public/mtg/index.html @@ -113,6 +113,18 @@ list-style: none; text-align: right; } + + .option-row { + display: flex; + align-items: flex-end; + padding-left: 65px; + } + .level-badge { + display: block; + width: 65px; + padding-left: 8px; + padding-bottom: 2px; + } @@ -133,83 +145,116 @@ action="guess.html" style="display: flex; flex-direction: column; align-items: center" > - -
- - -
- - - +

- - + + +

- -
+ + +
+
+ +
+ + + +
+
+ +
+ + + +
+
From 6a69f44f07aa9322e7e3ad9a1db441532cb8e4ac Mon Sep 17 00:00:00 2001 From: Austin Chen Date: Fri, 9 Sep 2022 09:49:16 -0700 Subject: [PATCH 10/10] Tweak padding on /tournaments --- web/pages/tournaments/index.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/web/pages/tournaments/index.tsx b/web/pages/tournaments/index.tsx index 6bb65d23..1494786b 100644 --- a/web/pages/tournaments/index.tsx +++ b/web/pages/tournaments/index.tsx @@ -143,7 +143,7 @@ export default function TournamentPage(props: { sections: SectionInfo[] }) { title="Tournaments" description="Win money by betting in forecasting touraments on current events, sports, science, and more" /> - + {sections.map(({ tourney, slug, numPeople }) => (