Merge branch 'main' into automated-market-resolution

This commit is contained in:
Milli 2022-05-28 16:03:13 +02:00
commit 26b7ec9f66
3 changed files with 19 additions and 7 deletions

View File

@ -131,9 +131,13 @@ export function getContractBetMetrics(contract: Contract, yourBets: Bet[]) {
let loan = 0
let saleValue = 0
let redeemed = 0
const totalShares: { [outcome: string]: number } = {}
for (const bet of yourBets) {
const { isSold, sale, amount, loanAmount, isRedemption } = bet
const { isSold, sale, amount, loanAmount, isRedemption, shares, outcome } =
bet
totalShares[outcome] = (totalShares[outcome] ?? 0) + shares
if (isSold) {
totalInvested += amount
} else if (sale) {
@ -165,6 +169,7 @@ export function getContractBetMetrics(contract: Contract, yourBets: Bet[]) {
netPayout,
profit,
profitPercent,
totalShares,
}
}
@ -175,6 +180,7 @@ export function getContractBetNullMetrics() {
netPayout: 0,
profit: 0,
profitPercent: 0,
totalShares: {} as { [outcome: string]: number },
}
}

View File

@ -125,13 +125,13 @@ export function BetsList(props: { user: User }) {
.filter((c) => {
if (filter === 'all') return true
const metrics = contractsMetrics[c.id]
const { totalShares } = contractsMetrics[c.id]
const hasSoldAll = Object.values(totalShares).every(
(shares) => shares === 0
)
// Filter for contracts you sold out of.
if (filter === 'sold') return metrics.payout === 0
// Filter for contracts where you currently have shares.
return metrics.payout > 0
if (filter === 'sold') return hasSoldAll
return !hasSoldAll
})
const [settled, unsettled] = partition(

View File

@ -16,6 +16,7 @@ import { formatMoney } from 'common/util/format'
import { Avatar } from '../avatar'
import clsx from 'clsx'
import { useRouter } from 'next/router'
import { useIsIframe } from 'web/hooks/use-is-iframe'
function getNavigation(username: string) {
return [
@ -43,6 +44,11 @@ export function BottomNavBar() {
const user = useUser()
const isIframe = useIsIframe()
if (isIframe) {
return null
}
const navigationOptions =
user === null
? signedOutNavigation