Revert "Put sale value above quick bet button"
This reverts commit 9ee7173305.
			
			
This commit is contained in:
		
							parent
							
								
									9ee7173305
								
							
						
					
					
						commit
						18815caed4
					
				|  | @ -23,11 +23,26 @@ export default function BetButton(props: { | ||||||
| 
 | 
 | ||||||
|   const user = useUser() |   const user = useUser() | ||||||
|   const userBets = useUserContractBets(user?.id, contract.id) |   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 ( |   return ( | ||||||
|     <> |     <> | ||||||
|       <Col className={clsx('items-center', className)}> |       <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 ? ( |         {user ? ( | ||||||
|           <Button |           <Button | ||||||
|             size="lg" |             size="lg" | ||||||
|  |  | ||||||
|  | @ -38,7 +38,7 @@ const BetWidget = (props: { contract: CPMMContract }) => { | ||||||
|   const user = useUser() |   const user = useUser() | ||||||
|   return ( |   return ( | ||||||
|     <Col className={'justify-center'}> |     <Col className={'justify-center'}> | ||||||
|       <Row className={'items-end gap-4'}> |       <Row className={'gap-4'}> | ||||||
|         {contract.outcomeType === 'BINARY' && |         {contract.outcomeType === 'BINARY' && | ||||||
|           user && |           user && | ||||||
|           QuickBetButtons({ |           QuickBetButtons({ | ||||||
|  |  | ||||||
|  | @ -18,7 +18,6 @@ import { useUnfilledBets } from 'web/hooks/use-bets' | ||||||
| import { getBinaryProb } from 'common/contract-details' | import { getBinaryProb } from 'common/contract-details' | ||||||
| import { quickOutcome } from 'web/components/contract/quick-bet-arrows' | import { quickOutcome } from 'web/components/contract/quick-bet-arrows' | ||||||
| import { Button } from 'web/components/button' | import { Button } from 'web/components/button' | ||||||
| import { Col } from 'web/components/layout/col' |  | ||||||
| 
 | 
 | ||||||
| const BET_SIZE = 10 | const BET_SIZE = 10 | ||||||
| 
 | 
 | ||||||
|  | @ -35,16 +34,15 @@ export function QuickBetButtons(props: { | ||||||
| 
 | 
 | ||||||
|   const userBets = useUserContractBets(user.id, contract.id) |   const userBets = useUserContractBets(user.id, contract.id) | ||||||
|   const unfilledBets = useUnfilledBets(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) { |   if (oppositeShares > 0.01) { | ||||||
|     sellOutcome = side === 'YES' ? 'NO' : 'YES' |     sellOutcome = side === 'YES' ? 'NO' : 'YES' | ||||||
| 
 | 
 | ||||||
|     const prob = getProb(contract) |     const prob = getProb(contract) | ||||||
|     const maxSharesSold = |     const maxSharesSold = | ||||||
|       (BET_SIZE + 1) / (sellOutcome === 'YES' ? prob : 1 - prob) |       (BET_SIZE + 0.05) / (sellOutcome === 'YES' ? prob : 1 - prob) | ||||||
|     sharesSold = Math.min(oppositeShares, maxSharesSold) |     sharesSold = Math.min(oppositeShares, maxSharesSold) | ||||||
| 
 | 
 | ||||||
|     const { saleValue } = calculateCpmmSale( |     const { saleValue } = calculateCpmmSale( | ||||||
|  | @ -55,16 +53,6 @@ export function QuickBetButtons(props: { | ||||||
|     ) |     ) | ||||||
|     saleAmount = saleValue |     saleAmount = saleValue | ||||||
|   } |   } | ||||||
|   const getValueOfShares = () => { |  | ||||||
|     const { saleValue } = calculateCpmmSale( |  | ||||||
|       contract, |  | ||||||
|       side === 'YES' ? yesShares : noShares, |  | ||||||
|       side, |  | ||||||
|       unfilledBets |  | ||||||
|     ) |  | ||||||
|     return saleValue |  | ||||||
|   } |  | ||||||
|   const saleValueOfShares = getValueOfShares() |  | ||||||
| 
 | 
 | ||||||
|   async function placeQuickBet() { |   async function placeQuickBet() { | ||||||
|     const betPromise = async () => { |     const betPromise = async () => { | ||||||
|  | @ -103,19 +91,6 @@ export function QuickBetButtons(props: { | ||||||
|   } |   } | ||||||
| 
 | 
 | ||||||
|   return ( |   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 |     <Button | ||||||
|       size={'lg'} |       size={'lg'} | ||||||
|       onClick={() => placeQuickBet()} |       onClick={() => placeQuickBet()} | ||||||
|  | @ -124,7 +99,6 @@ export function QuickBetButtons(props: { | ||||||
|     > |     > | ||||||
|       {side === 'YES' ? 'Yes' : 'No'} |       {side === 'YES' ? 'Yes' : 'No'} | ||||||
|     </Button> |     </Button> | ||||||
|     </Col> |  | ||||||
|   ) |   ) | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
		Loading…
	
		Reference in New Issue
	
	Block a user