Merge branch 'main' into automated-market-resolution
This commit is contained in:
commit
26b7ec9f66
|
@ -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 },
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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(
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue
Block a user