0.2.44: bitcoin terms value paid-in capital call by call

The LP portal's 'In bitcoin terms' box converted ALL paid-in capital at
the fund close date's BTC price, mispricing every mid-life capital call.
It now walks the statement history: the first statement's contributions
at the close-date entry mark, each later quarter's new contributions at
that statement date's price, and distributions at the price when
received. A dollar called later is no longer credited with bitcoin it
could never have bought. Funds with a single statement (and files
predating the uploaded price range) fall back to the close-date price.
Frontend only; shared by the LP portal and the admin Investor View.
This commit is contained in:
Jonathan Kirkwood
2026-08-11 12:52:01 -05:00
parent ebafcf19d9
commit 1dabbc3073
6 changed files with 61 additions and 21 deletions
+1 -1
View File
@@ -1,6 +1,6 @@
{ {
"name": "ten31portal-startos", "name": "ten31portal-startos",
"version": "0.2.43", "version": "0.2.44",
"private": true, "private": true,
"scripts": { "scripts": {
"build": "npm run check && rm -rf ./javascript && ncc build startos/index.ts -o ./javascript", "build": "npm run check && rm -rf ./javascript && ncc build startos/index.ts -o ./javascript",
+3 -2
View File
@@ -1,8 +1,9 @@
export { v_0_2_43 as current } from './v_0_2_43' export { v_0_2_44 as current } from './v_0_2_44'
import { v_0_1_0 } from './v_0_1_0' import { v_0_1_0 } from './v_0_1_0'
import { v_0_2_40 } from './v_0_2_40' import { v_0_2_40 } from './v_0_2_40'
import { v_0_2_41 } from './v_0_2_41' import { v_0_2_41 } from './v_0_2_41'
import { v_0_2_42 } from './v_0_2_42' import { v_0_2_42 } from './v_0_2_42'
import { v_0_2_43 } from './v_0_2_43'
import { v_0_2_0 } from './v_0_2_0' import { v_0_2_0 } from './v_0_2_0'
import { v_0_2_1 } from './v_0_2_1' import { v_0_2_1 } from './v_0_2_1'
import { v_0_2_3 } from './v_0_2_3' import { v_0_2_3 } from './v_0_2_3'
@@ -42,4 +43,4 @@ import { v_0_2_36 } from './v_0_2_36'
import { v_0_2_37 } from './v_0_2_37' import { v_0_2_37 } from './v_0_2_37'
import { v_0_2_38 } from './v_0_2_38' import { v_0_2_38 } from './v_0_2_38'
import { v_0_2_39 } from './v_0_2_39' import { v_0_2_39 } from './v_0_2_39'
export const other = [v_0_1_0, v_0_2_0, v_0_2_1, v_0_2_3, v_0_2_4, v_0_2_5, v_0_2_6, v_0_2_7, v_0_2_8, v_0_2_9, v_0_2_10, v_0_2_11, v_0_2_12, v_0_2_13, v_0_2_14, v_0_2_15, v_0_2_16, v_0_2_17, v_0_2_18, v_0_2_19, v_0_2_20, v_0_2_21, v_0_2_22, v_0_2_23, v_0_2_24, v_0_2_25, v_0_2_26, v_0_2_27, v_0_2_28, v_0_2_29, v_0_2_30, v_0_2_31, v_0_2_32, v_0_2_33, v_0_2_34, v_0_2_35, v_0_2_36, v_0_2_37, v_0_2_38, v_0_2_39, v_0_2_40, v_0_2_41, v_0_2_42] export const other = [v_0_1_0, v_0_2_0, v_0_2_1, v_0_2_3, v_0_2_4, v_0_2_5, v_0_2_6, v_0_2_7, v_0_2_8, v_0_2_9, v_0_2_10, v_0_2_11, v_0_2_12, v_0_2_13, v_0_2_14, v_0_2_15, v_0_2_16, v_0_2_17, v_0_2_18, v_0_2_19, v_0_2_20, v_0_2_21, v_0_2_22, v_0_2_23, v_0_2_24, v_0_2_25, v_0_2_26, v_0_2_27, v_0_2_28, v_0_2_29, v_0_2_30, v_0_2_31, v_0_2_32, v_0_2_33, v_0_2_34, v_0_2_35, v_0_2_36, v_0_2_37, v_0_2_38, v_0_2_39, v_0_2_40, v_0_2_41, v_0_2_42, v_0_2_43]
@@ -0,0 +1,18 @@
import { VersionInfo } from '@start9labs/start-sdk'
export const v_0_2_44 = VersionInfo.of({
version: '0.2.44:0',
releaseNotes: {
en_US:
"Bitcoin-terms accuracy for funds with capital calls: paid-in capital is now " +
"converted to bitcoin call by call — the initial funding at the fund's close-date " +
"price and each later quarter's new contributions at that quarter's price — " +
"instead of marking every dollar at the close date. Distributions convert at the " +
"price when received. Requires the quarterly statement history (see the Import " +
"page's history backfill) for funds that called capital over time.",
},
migrations: {
up: async ({ effects }) => {},
down: async ({ effects }) => {},
},
})
+1 -1
View File
@@ -3,7 +3,7 @@
// - content-hashed /assets/* are cache-first (immutable, safe forever) // - content-hashed /assets/* are cache-first (immutable, safe forever)
// - /api/* is never cached // - /api/* is never cached
// Bump CACHE on each release so old entries are purged. // Bump CACHE on each release so old entries are purged.
const CACHE = 'ten31-portal-0.2.43' const CACHE = 'ten31-portal-0.2.44'
self.addEventListener('install', () => self.skipWaiting()) self.addEventListener('install', () => self.skipWaiting())
+37 -16
View File
@@ -5,13 +5,16 @@ import CapitalChart, { type CapitalPoint } from "../components/CapitalChart";
const pct = (p: number) => `${p >= 0 ? "+" : ""}${Math.abs(p).toFixed(1)}%`; const pct = (p: number) => `${p >= 0 ? "+" : ""}${Math.abs(p).toFixed(1)}%`;
// Dollars-at-cents ÷ BTC-price-at-cents, formatted to a sensible precision for the size. // A BTC amount formatted to a sensible precision for the size.
const formatBtc = (usdCents: number, priceCents: number) => { const formatBtcAmount = (btc: number) => {
const btc = usdCents / priceCents;
const dp = btc >= 10 ? 2 : btc >= 1 ? 3 : 4; const dp = btc >= 10 ? 2 : btc >= 1 ? 3 : 4;
return `${btc.toLocaleString(undefined, { minimumFractionDigits: dp, maximumFractionDigits: dp })}`; return `${btc.toLocaleString(undefined, { minimumFractionDigits: dp, maximumFractionDigits: dp })}`;
}; };
// Dollars-at-cents ÷ BTC-price-at-cents.
const formatBtc = (usdCents: number, priceCents: number) =>
formatBtcAmount(usdCents / priceCents);
// The investor-facing portal, rendered purely from data. Used by the investor's own home // The investor-facing portal, rendered purely from data. Used by the investor's own home
// (InvestorHome) and by the admin read-only Investor View, so both show exactly the same thing. // (InvestorHome) and by the admin read-only Investor View, so both show exactly the same thing.
export default function InvestorPortalView({ export default function InvestorPortalView({
@@ -418,24 +421,44 @@ function CapitalBlock({
</p> </p>
)} )}
<BtcTerms latest={latest} /> <BtcTerms latest={latest} history={history} />
<HistorySection history={history} /> <HistorySection history={history} />
</div> </div>
); );
} }
// The bitcoin-denominated view: paid-in capital valued at the BTC price on the fund's close // The bitcoin-denominated view. Paid-in is valued CALL BY CALL: the first statement's
// (the entry mark set by the admin), current value at the newest statement's price. Hidden // contributions at the fund-close price (the entry mark set by the admin), and each later
// quarter's new contributions at that statement date's price — a fund that calls capital
// over time isn't credited with bitcoin it could never have bought. Distributions convert
// at the price when received; current value at the newest statement's price. Hidden
// entirely until the admin has uploaded prices and set the fund's close date. // entirely until the admin has uploaded prices and set the fund's close date.
function BtcTerms({ latest }: { latest: CapitalAccount }) { function BtcTerms({ latest, history }: { latest: CapitalAccount; history: CapitalAccount[] }) {
const closePrice = latest.btc_close_price_cents; const closePrice = latest.btc_close_price_cents;
const asofPrice = latest.btc_price_cents; const asofPrice = latest.btc_price_cents;
if (!closePrice || !asofPrice || latest.contributions_cents <= 0) return null; if (!closePrice || !asofPrice || latest.contributions_cents <= 0) return null;
const paidInBtc = latest.contributions_cents / closePrice; // history is oldest-first; walk the cumulative figures and value each period's flows
const totalNowBtc = (latest.ending_balance_cents + latest.distributions_cents) / asofPrice; // at that period's price (falling back to the close mark when a date predates the
// uploaded price range).
let paidInBtc = 0;
let distributedBtc = 0;
let prevContrib = 0;
let prevDistrib = 0;
history.forEach((s, i) => {
const price = (i === 0 ? closePrice : s.btc_price_cents) ?? closePrice;
const dContrib = s.contributions_cents - prevContrib;
const dDistrib = s.distributions_cents - prevDistrib;
if (dContrib > 0) paidInBtc += dContrib / price;
if (dDistrib > 0) distributedBtc += dDistrib / price;
prevContrib = Math.max(prevContrib, s.contributions_cents);
prevDistrib = Math.max(prevDistrib, s.distributions_cents);
});
const totalNowBtc = latest.ending_balance_cents / asofPrice + distributedBtc;
const btcPct = paidInBtc > 0 ? (totalNowBtc / paidInBtc - 1) * 100 : null; const btcPct = paidInBtc > 0 ? (totalNowBtc / paidInBtc - 1) * 100 : null;
if (paidInBtc <= 0) return null;
return ( return (
<div className="mt-4 border border-accent-100 bg-accent-50/50 rounded p-3"> <div className="mt-4 border border-accent-100 bg-accent-50/50 rounded p-3">
@@ -443,16 +466,14 @@ function BtcTerms({ latest }: { latest: CapitalAccount }) {
<div className="flex flex-wrap items-baseline gap-x-6 gap-y-1 mt-1.5"> <div className="flex flex-wrap items-baseline gap-x-6 gap-y-1 mt-1.5">
<span className="text-sm text-gray-600"> <span className="text-sm text-gray-600">
Paid-in{" "} Paid-in{" "}
<span className="font-medium text-gray-900"> <span className="font-medium text-gray-900">{formatBtcAmount(paidInBtc)}</span>{" "}
{formatBtc(latest.contributions_cents, closePrice)} <span className="text-xs text-gray-400">
</span>{" "} {history.length > 1 ? "at call dates" : "at close"}
<span className="text-xs text-gray-400">at close</span> </span>
</span> </span>
<span className="text-sm text-gray-600"> <span className="text-sm text-gray-600">
Now{" "} Now{" "}
<span className="font-medium text-gray-900"> <span className="font-medium text-gray-900">{formatBtcAmount(totalNowBtc)}</span>
{formatBtc(latest.ending_balance_cents + latest.distributions_cents, asofPrice)}
</span>
</span> </span>
{btcPct != null && ( {btcPct != null && (
<span className={`text-sm font-medium ${btcPct >= 0 ? "text-accent-600" : "text-red-600"}`}> <span className={`text-sm font-medium ${btcPct >= 0 ? "text-accent-600" : "text-red-600"}`}>
+1 -1
View File
@@ -1,4 +1,4 @@
// Bumped each release so the running build is visible in the UI. // Bumped each release so the running build is visible in the UI.
// If the number shown in the app doesn't match the installed s9pk version, // If the number shown in the app doesn't match the installed s9pk version,
// the new frontend isn't actually being served. // the new frontend isn't actually being served.
export const APP_VERSION = "0.2.43"; export const APP_VERSION = "0.2.44";