Revert "Put sale value above quick bet button"

This reverts commit 9ee7173305.
This commit is contained in:
mantikoros 2022-09-10 21:57:35 -05:00
parent 9ee7173305
commit 18815caed4
3 changed files with 28 additions and 39 deletions

View File

@ -23,11 +23,26 @@ export default function BetButton(props: {
const user = useUser()
const userBets = useUserContractBets(user?.id, contract.id)
const { hasYesShares, hasNoShares } = useSaveBinaryShares(contract, userBets)
const { yesShares, noShares, hasYesShares, hasNoShares } =
useSaveBinaryShares(contract, userBets)
const { outcomeType } = contract
const isPseudoNumeric = outcomeType === 'PSEUDO_NUMERIC'
return (
<>
<Col className={clsx('items-center', className)}>
{user && (
<div className={'mb-1 w-24 text-center text-sm text-gray-500'}>
{hasYesShares
? `(${Math.floor(yesShares)} ${
isPseudoNumeric ? 'HIGHER' : 'YES'
})`
: hasNoShares
? `(${Math.floor(noShares)} ${isPseudoNumeric ? 'LOWER' : 'NO'})`
: ''}
</div>
)}
{user ? (
<Button
size="lg"

View File

@ -38,7 +38,7 @@ const BetWidget = (props: { contract: CPMMContract }) => {
const user = useUser()
return (
<Col className={'justify-center'}>
<Row className={'items-end gap-4'}>
<Row className={'gap-4'}>
{contract.outcomeType === 'BINARY' &&
user &&
QuickBetButtons({

View File

@ -18,7 +18,6 @@ import { useUnfilledBets } from 'web/hooks/use-bets'
import { getBinaryProb } from 'common/contract-details'
import { quickOutcome } from 'web/components/contract/quick-bet-arrows'
import { Button } from 'web/components/button'
import { Col } from 'web/components/layout/col'
const BET_SIZE = 10
@ -35,16 +34,15 @@ export function QuickBetButtons(props: {
const userBets = useUserContractBets(user.id, contract.id)
const unfilledBets = useUnfilledBets(contract.id) ?? []
const { hasYesShares, hasNoShares, yesShares, noShares } =
useSaveBinaryShares(contract, userBets)
const oppositeShares = side === 'YES' ? noShares : yesShares
const { yesShares, noShares } = useSaveBinaryShares(contract, userBets)
const oppositeShares = side === 'YES' ? noShares : yesShares
if (oppositeShares > 0.01) {
sellOutcome = side === 'YES' ? 'NO' : 'YES'
const prob = getProb(contract)
const maxSharesSold =
(BET_SIZE + 1) / (sellOutcome === 'YES' ? prob : 1 - prob)
(BET_SIZE + 0.05) / (sellOutcome === 'YES' ? prob : 1 - prob)
sharesSold = Math.min(oppositeShares, maxSharesSold)
const { saleValue } = calculateCpmmSale(
@ -55,16 +53,6 @@ export function QuickBetButtons(props: {
)
saleAmount = saleValue
}
const getValueOfShares = () => {
const { saleValue } = calculateCpmmSale(
contract,
side === 'YES' ? yesShares : noShares,
side,
unfilledBets
)
return saleValue
}
const saleValueOfShares = getValueOfShares()
async function placeQuickBet() {
const betPromise = async () => {
@ -103,19 +91,6 @@ export function QuickBetButtons(props: {
}
return (
<Col>
{user && (
<div className={'min-w-sm mb-1 text-center text-sm text-gray-500'}>
{saleValueOfShares > 0.1 &&
hasYesShares &&
side === 'YES' &&
`${formatMoney(saleValueOfShares)}`}
{saleValueOfShares > 0.1 &&
hasNoShares &&
side === 'NO' &&
`${formatMoney(saleValueOfShares)}`}
</div>
)}
<Button
size={'lg'}
onClick={() => placeQuickBet()}
@ -124,7 +99,6 @@ export function QuickBetButtons(props: {
>
{side === 'YES' ? 'Yes' : 'No'}
</Button>
</Col>
)
}