Skip to content

Commit

Permalink
added spice as mana to net worth
Browse files Browse the repository at this point in the history
  • Loading branch information
ingawei committed Sep 17, 2024
1 parent a91f50d commit bf9399b
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions web/components/portfolio/twomba-portfolio-graph.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -304,6 +304,7 @@ function usePortfolioPointsFromHistory(
const investmentPoints: HistoryPoint<Partial<PortfolioMetrics>>[] = []
const balancePoints: HistoryPoint<Partial<PortfolioMetrics>>[] = []
const networthPoints: HistoryPoint<Partial<PortfolioMetrics>>[] = []
const spicePoints: HistoryPoint<Partial<PortfolioMetrics>>[] = []

const cashProfitPoints: HistoryPoint<Partial<PortfolioMetrics>>[] = []
const cashInvestmentPoints: HistoryPoint<Partial<PortfolioMetrics>>[] = []
Expand All @@ -319,8 +320,16 @@ function usePortfolioPointsFromHistory(
return balance + investment - totalDeposits - firstProfit
}

function getNetworth(balance: number, investment: number) {
return balance + investment
function getNetworth(
balance: number,
investment: number,
spiceBalance?: number
) {
return (
balance +
investment +
(spiceBalance ?? 0) * SPICE_TO_MANA_CONVERSION_RATE
)
}

portfolioHistory.forEach((p) => {
Expand All @@ -346,7 +355,7 @@ function usePortfolioPointsFromHistory(
})
networthPoints.push({
x: p.timestamp,
y: getNetworth(p.balance, p.investmentValue),
y: getNetworth(p.balance, p.investmentValue, p.spiceBalance),
obj: p,
})
cashProfitPoints.push({
Expand Down

0 comments on commit bf9399b

Please sign in to comment.