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 loan = 0
|
||||||
let saleValue = 0
|
let saleValue = 0
|
||||||
let redeemed = 0
|
let redeemed = 0
|
||||||
|
const totalShares: { [outcome: string]: number } = {}
|
||||||
|
|
||||||
for (const bet of yourBets) {
|
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) {
|
if (isSold) {
|
||||||
totalInvested += amount
|
totalInvested += amount
|
||||||
} else if (sale) {
|
} else if (sale) {
|
||||||
|
@ -165,6 +169,7 @@ export function getContractBetMetrics(contract: Contract, yourBets: Bet[]) {
|
||||||
netPayout,
|
netPayout,
|
||||||
profit,
|
profit,
|
||||||
profitPercent,
|
profitPercent,
|
||||||
|
totalShares,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -175,6 +180,7 @@ export function getContractBetNullMetrics() {
|
||||||
netPayout: 0,
|
netPayout: 0,
|
||||||
profit: 0,
|
profit: 0,
|
||||||
profitPercent: 0,
|
profitPercent: 0,
|
||||||
|
totalShares: {} as { [outcome: string]: number },
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -125,13 +125,13 @@ export function BetsList(props: { user: User }) {
|
||||||
.filter((c) => {
|
.filter((c) => {
|
||||||
if (filter === 'all') return true
|
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 hasSoldAll
|
||||||
if (filter === 'sold') return metrics.payout === 0
|
return !hasSoldAll
|
||||||
|
|
||||||
// Filter for contracts where you currently have shares.
|
|
||||||
return metrics.payout > 0
|
|
||||||
})
|
})
|
||||||
|
|
||||||
const [settled, unsettled] = partition(
|
const [settled, unsettled] = partition(
|
||||||
|
|
|
@ -16,6 +16,7 @@ import { formatMoney } from 'common/util/format'
|
||||||
import { Avatar } from '../avatar'
|
import { Avatar } from '../avatar'
|
||||||
import clsx from 'clsx'
|
import clsx from 'clsx'
|
||||||
import { useRouter } from 'next/router'
|
import { useRouter } from 'next/router'
|
||||||
|
import { useIsIframe } from 'web/hooks/use-is-iframe'
|
||||||
|
|
||||||
function getNavigation(username: string) {
|
function getNavigation(username: string) {
|
||||||
return [
|
return [
|
||||||
|
@ -43,6 +44,11 @@ export function BottomNavBar() {
|
||||||
|
|
||||||
const user = useUser()
|
const user = useUser()
|
||||||
|
|
||||||
|
const isIframe = useIsIframe()
|
||||||
|
if (isIframe) {
|
||||||
|
return null
|
||||||
|
}
|
||||||
|
|
||||||
const navigationOptions =
|
const navigationOptions =
|
||||||
user === null
|
user === null
|
||||||
? signedOutNavigation
|
? signedOutNavigation
|
||||||
|
|
Loading…
Reference in New Issue
Block a user