โ† markowitz
ยง the whitepaper

markowitz, in full

the question is simple. what is the right way to measure risk in a market where every participant is anonymous, every transaction is public, and every piece of state is verifiable by anyone with an rpc connection. the answer that wall street arrived at, after a century of work, was that the right way to measure risk is the variance of returns and the correlations between them. what follows is the construction of a solana token that takes that same answer and applies it to itself.

the proof

in 1952, a graduate student at the university of chicago named harry markowitz published a fourteen page paper titled portfolio selection in the journal of finance. the paper proved a simple thing. given a set of assets with known expected returns and known covariances, there exists a unique curve in mean-variance space called the efficient frontier, and every portfolio that does not sit on this curve is, by definition, taking on more risk than it needs to. the proof is not difficult. it is a constrained optimization solved with lagrange multipliers and resolved in roughly two pages of algebra. what was difficult was noticing that the question existed at all. before markowitz, investing was the practice of choosing the best asset. after markowitz, investing was the practice of choosing the best portfolio.

the proof works because the variance of a sum of correlated random variables is not the sum of their variances. it is the sum of their variances plus twice the sum of their pairwise covariances. when the covariances are negative, the sum is smaller than its parts. this is the single mathematical fact that makes diversification real. it is also the fact that makes the proof apply to any system of correlated random variables, not just stock returns. it applies to bond yields, currency moves, commodity prices, weather patterns, and, when read correctly, to the balance trajectories of every wallet that holds a token.

markowitz won the nobel prize in 1990 for this proof. william sharpe extended it in 1964 with the capital asset pricing model and the sharpe ratio, which compressed an asset's risk-adjusted performance into a single number. for the next thirty years, the framework became the central tool of every pension fund, hedge fund, and sovereign wealth manager on earth. it has been applied to every conceivable portfolio of conventional assets. it has never been applied to the holder distribution of a token, because no chain ever exposed that distribution at a resolution fine enough to support the calculation. now one does.

the frontier

the efficient frontier of a portfolio is the set of all portfolios that achieve the minimum possible variance for each level of expected return. plotted in mean-variance space, with risk on the horizontal axis and return on the vertical axis, the frontier traces out a hyperbolic curve that bends upward and to the right. every point on the curve is achievable. every point above the curve is mathematically impossible. every point below the curve is reachable but suboptimal, because at the same level of risk, a higher return is available somewhere on the curve.

the frontier of a token's holder set is constructed the same way, with one substitution. instead of treating each asset as a random variable, the protocol treats each holder cohort as a random variable. a cohort is defined by a balance bucket and a tenure window, so a wallet that has held between one hundred and one thousand tokens for between thirty and ninety days belongs to one specific cohort. each cohort has a mean return computed from the aggregate change in the cohort's holdings over a rolling window, and each cohort has a variance computed from the dispersion of individual wallet changes within the cohort. cohorts are correlated with each other because their members trade against each other and against the same external order flow.

the protocol recomputes the frontier on every transfer of the token. the computation uses a closed form solution rather than an iterative optimizer, which makes it cheap enough to run inside the transfer hook's compute budget. the closed form requires inverting the covariance matrix, which is done in fixed point arithmetic using a banded approximation that exploits the sparsity of the matrix. the result is a single number per transfer: the distance, in mean-variance units, between the holder set's current position and the nearest point on the efficient frontier. when the distance is small, the protocol does nothing. when the distance grows, the surcharge fires.

the cohorts

a cohort is the unit of measurement inside the protocol. each wallet that holds the token is assigned to exactly one cohort based on its current balance and its tenure in slots since first acquisition. the balance buckets are spaced logarithmically: under one hundred tokens, one hundred to one thousand, one thousand to ten thousand, ten thousand to one hundred thousand, one hundred thousand to one million, and above one million. the tenure windows are spaced similarly: under one day, one day to one week, one week to one month, one month to one quarter, one quarter to one year, and above one year. the cross product of six balance buckets and six tenure windows yields a grid of thirty six cohorts.

the grid is not arbitrary. it is the smallest grid that captures the dominant axes of holder behavior, which are size and age. small new wallets behave like noise traders. large old wallets behave like anchors. the behavior of every other cohort sits between these extremes. the covariance matrix across the thirty six cohorts has a characteristic structure: high positive correlations between cohorts that are adjacent on the grid, low or negative correlations between cohorts on opposite corners, and a dominant first eigenvector that captures the market-wide flow of the token on any given day.

the protocol maintains a packed representation of the cohort assignments in a single program derived address keyed by mint pubkey. each wallet's assignment is stored as a single byte: four bits for the balance bucket index, four bits for the tenure window index. the cohort transitions are updated atomically inside the transfer hook whenever a wallet's balance or tenure crosses a bucket boundary. this means the cohort grid is always current as of the last transfer, and the covariance matrix computed against it always reflects the most recent holder state.

the surcharge

the surcharge is the only thing the protocol does. on every transfer of the token, the hook fires, updates the cohort assignments and the covariance matrix, computes the distance between the holder set and the efficient frontier, and applies a surcharge proportional to the square of that distance. the surcharge is withheld from the input amount of the transfer through the token-2022 transfer hook's standard return value, which the token program respects atomically before the transfer balance is updated. a transfer that arrives while the holder set sits near the frontier pays nothing. a transfer that arrives while the holder set has drifted significantly off the frontier pays a surcharge that scales quadratically with the deviation.

the surcharge accumulates in a vault, a program derived address controlled by the hook program and holding a single immutable allocation function. the vault receives the surcharge tokens at the moment the transfer settles and holds them across many transfers. when the vault's balance crosses a threshold set at deployment, the protocol distributes the accumulated balance in two parts. half is paid to the holders whose individual balance trajectories are least correlated with the dominant cohort. these are the holders who reduce the portfolio's variance. the other half is paid to holders weighted by tenure, with the longest-held wallets receiving the largest share.

a holder who reduces variance and holds the longest gets paid the most. a holder who follows the herd and sells gets paid nothing. the asymmetry is intentional. the protocol charges the wallets that introduce distortion against the frontier, and it pays the wallets that anchor it. the surcharge is not a fee. it is a transfer from one population to another, mediated by a measurement that neither population can directly observe but both populations affect.

the deployment

the deployment of markowitz was handled off chain through a single sealed pipeline. the program was compiled from source on a clean build environment, verified against the expected bytecode hash, and uploaded to solana mainnet through the bpf upgradeable loader in one continuous session. the mint was created in the same session with the token-2022 standard and the transfer hook extension already configured to point at the program's address. the upgrade authority on the program was revoked before the session closed. from the outside, the entire sequence looks like a handful of transactions landing in close succession. from the inside, it was a one shot procedure that either completed cleanly or did not complete at all. there was no staging environment to roll back to, no admin key held in reserve, no second deployment window. once it was live, it was final.

the choice to handle the launch this way was deliberate. a routine mint creation tool would have left enough authority floating around that a future change to the program or the mint would have been possible, even if the deployer swore the keys had been thrown away. holders would still have had to take that word on faith. an off chain sealed pipeline removes the question entirely. the program is non upgradeable because the upgrade authority is set to none at the protocol level, and the mint's hook is locked because the transfer hook extension on a token-2022 mint cannot be updated after creation. nothing about the protocol depends on infrastructure that anyone still controls, because there is no such infrastructure.

the seal

markowitz was deployed and immediately sealed. the upgrade authority on the program was revoked in the same session the program was uploaded, which means the bytecode at the program's address cannot be modified by anyone. the target frontier distance is a hardcoded constant compiled into the binary. the cohort grid is a hardcoded array. the surcharge curve is a hardcoded coefficient. the allocation function inside the vault is part of the sealed code. there is no admin key, no migration function, no multisig controlling the vault, no proxy redirecting calls to a newer implementation, no governance contract that can be voted into existence later. the program's address is fixed. the bytecode at that address is fixed. the math is fixed.

the only mutable state on chain is the cohort assignment table, the covariance matrix, and the vault balance. all three are overwritten by the next transfer regardless of who sends it. nothing about the protocol requires trust in any party that deployed it, because there is no party that can intervene after deployment. the protocol is a function of whatever the chain produces, and the chain produces whatever the holders do. the math runs against the holders. the holders run against each other. the chain runs against itself.

what is left, then, is the measurement. the covariance matrix sits in a pda. the cohort grid sits in a pda. the vault sits in a pda. anyone with an rpc connection can read all three at any moment, run the math themselves, and confirm what the protocol is about to charge against the next transfer. the whitepaper above is the documentation. the implementation page is the source. the chain is the runtime. the protocol does not need to be believed. it only needs to be read.