ergodic

CA 6yQrDVHxc1V7UZhTBLkSPn7sJ6hbpb7jC3HqZToypump copied
return space — Γ(t)
live projection of the protocol's 512-slot return-space embedding. ergodic particles (warm) explore the full accessible manifold. non-ergodic particles (cool) collapse into low-dimensional attractors. the shaded region between the two populations is the surcharge the hook would charge in expectation against the recent history.
ε(t) ≈ 0.034
ergodicity gap
λ_max ≈ −0.271
max lyapunov
τ_mix ≈ 418
mixing time (slots)
S(t) ≈ 4.72
boltzmann entropy

on the name

ludwig boltzmann was an austrian physicist who spent the last three decades of the nineteenth century trying to answer a question that should not have been difficult. the laws of mechanics, as newton had written them, are reversible. a billiard ball rolling east obeys the same equations as a billiard ball rolling west. run the film backward and nothing in the mathematics complains. yet the world is not reversible. heat flows from hot to cold. cream mixes into coffee and does not unmix. ice melts and does not spontaneously freeze. boltzmann wanted to know where the asymmetry came from, and his answer was statistical. it was not that any single particle violated time reversal. it was that the number of disordered arrangements of a system's particles vastly exceeds the number of ordered ones, so a system left to itself will almost certainly move from order to disorder, not because disorder is required but because disorder is overwhelmingly more probable. the insight required a new quantity, which boltzmann called the entropy, and a new hypothesis, which he called the ergodic hypothesis: that a system evolving long enough will visit every accessible state in proportion to its probability. his contemporaries rejected both. ernst zermelo argued that the recurrence theorem made the entropy increase illusory. loschmidt argued that the reversibility of the underlying dynamics contradicted any statistical arrow. boltzmann defended the hypothesis for twenty years. in 1906, during a holiday in duino near trieste, he hanged himself. his wife and daughter found him. he was sixty two.

the ergodic hypothesis was proven in restricted form by birkhoff in 1931 and von neumann in 1932. it became the foundation of statistical mechanics, thermodynamics, and every branch of physics that treats large systems probabilistically. but the hypothesis carried a subtlety that physics absorbed and economics ignored. in an ergodic system, the time average of a quantity measured along a single trajectory equals the ensemble average of that quantity measured across many trajectories at a single instant. this equivalence is what makes the hypothesis powerful and what makes it dangerous when applied to domains where it does not hold. ole peters, working at the london mathematical laboratory a century after boltzmann's death, demonstrated that the central models of economic theory, expected utility, portfolio theory, the efficient market hypothesis, all implicitly assume ergodicity. they treat the average outcome across a population of bettors as identical to the average outcome of a single bettor over time. for ergodic processes this is correct. for the multiplicative, path dependent, ruin susceptible processes that describe actual wealth dynamics, it is not correct. the distinction is not academic. it is the difference between a model that says a bet is favorable and a reality in which the bettor goes bankrupt.

on ergodicity

consider a room full of traders, each with the same starting capital, each making the same sequence of bets. in the first round every trader flips a coin. heads multiplies their wealth by 1.5. tails multiplies it by 0.6. the expected value of a single flip is positive: half of 1.5 plus half of 0.6 equals 1.05, a five percent gain in expectation. an economist computing the ensemble average across the room after one flip will find that the average wealth has grown. after ten flips the average has grown further. after a hundred flips the average is enormous, because a handful of traders who flipped mostly heads now hold astronomical sums. but the median trader, the typical trader, the trader whose experience represents what it actually feels like to play the game, is broke. the time average growth rate is not five percent. it is the geometric mean of 1.5 and 0.6, which is the square root of 0.9, which is approximately 0.949, a five percent loss per round. the ensemble says the game is good. the trajectory says the game is lethal. this divergence between the two averages is not a paradox. it is the definition of non-ergodicity.

the ergodicity gap is the difference between the ensemble-average growth rate and the time-average growth rate of a process. for an ergodic process the gap is zero by definition. for the multiplicative coin flip above the gap is ten percent per round. for real markets the gap is variable, fluctuating as the distribution of returns shifts between additive regimes where the gap closes and multiplicative regimes where it opens. the kelly criterion, derived by john kelly at bell labs in 1956 and largely ignored by mainstream economics for the next fifty years, is the optimal strategy for a non-ergodic multiplicative process. it maximizes the time-average growth rate rather than the expected value, and it does so precisely by accounting for the gap that expected utility theory assumes away. the protocol called ergodic exists because the gap is not merely a theoretical quantity. it is an observable. it can be measured on chain, in real time, from the divergence between individual wallet trajectories and the aggregate pool trajectory. and what can be measured can be priced.

on the gap

the program maintains a 512-entry circular buffer in a program-derived address seeded with ["returns", mint_pubkey]. each entry is a tuple of (slot, wallet_return, pool_return), where wallet_return is the log return of the transferring wallet since its entry price and pool_return is the log return of the aggregate pool over the same window. the entry price for each wallet is stored in a per-wallet pda written on first acquisition and reset on full disposal. the buffer advances on every transfer, and the program maintains running sums of both the individual return series and the pool return series across the window.

the ergodicity gap at time t is computed as the absolute difference between the ensemble-average log return, which is the arithmetic mean of all individual wallet log returns in the buffer, and the time-average log return, which is the geometric mean of the sequential pool returns over the same window. for ergodic processes these converge. for non-ergodic processes they diverge, and the rate of divergence is characterized by the maximum lyapunov exponent of the return-space dynamical system. the program estimates this exponent using the rosenstein method adapted for fixed-point arithmetic: it identifies nearest neighbors in the embedded return space at five embedding dimensions, tracks the divergence of those neighbors over lag windows of 8, 16, 32, 64, and 128 slots, and fits a line through the log of the average divergence versus lag. the slope is the maximum lyapunov exponent. a negative exponent means trajectories are converging, the system is mixing, the gap is closing. a positive exponent means trajectories are diverging, someone is extracting, the gap is opening. zero is the boundary, and the boundary is what the protocol defends.

on the mechanism

ergodic is deployed as a token-2022 transfer hook on the ergodic mint, registered through the mint's extra account metas list at initialization. the token-2022 program invokes the hook's execute instruction via cross-program invocation on every transfer of the underlying token, regardless of which program initiates the transfer. the hook receives the transfer amount, the source and destination token accounts, the mint, and the extra accounts declared at registration, which include the circular buffer pda, the source wallet's entry-price pda, the destination wallet's entry-price pda, the oracle price account, and the redistribution vault.

on each invocation the program performs the following sequence in a single atomic transaction. it reads the current price from the oracle account, a pyth pull-based feed for the ergodic/sol pair refreshed by the keeper network at sub-second granularity. it computes the source wallet's log return as the natural logarithm of the ratio of the current price to the wallet's stored entry price, using a precomputed sixteen-entry log table and linear interpolation in i128 fixed-point arithmetic. it appends the (slot, wallet_log_return, pool_log_return) tuple to the circular buffer, advancing the head pointer with wraparound at 512. it updates the running lyapunov exponent estimate using the incremental rosenstein method described above, carrying forward the cached nearest-neighbor indices and divergence sums from the previous invocation so the per-transfer computation is bounded at approximately two hundred twenty thousand compute units. it computes the ergodicity gap as the absolute difference between ensemble and time averages. it cubes the gap, multiplies by a fixed scaling constant baked into the program at deployment, and returns the product as the surcharge to be withheld from the transfer amount. the token-2022 program respects this return value atomically, deducting the surcharge before the balance update settles and routing the withheld tokens to the redistribution vault specified in the extra account metas.

on the lattice

the redistribution vault is a program-derived address controlled exclusively by the hook program, holding an immutable allocation function that cannot be modified after deployment. when the vault's token balance exceeds a threshold set at initialization, the program distributes the accumulated surcharges according to a boltzmann distribution over the holder population. in statistical mechanics the boltzmann distribution assigns to each microstate a probability proportional to e raised to the negative energy of that state divided by the product of the boltzmann constant and the temperature. the protocol's analog replaces energy with a quantity it calls the thermodynamic participation score, a composite of three observables computed for each holder wallet from its on-chain history.

the first component is holding duration, measured in slots since the wallet's entry-price pda was first written. a wallet that has held for two million slots contributes more than a wallet that has held for fifty thousand, and the contribution scales logarithmically, so early holders are rewarded but the advantage of being first diminishes with time. the second component is transaction frequency entropy, the shannon entropy of the distribution of intervals between the wallet's successive transfers. a wallet that transfers at perfectly regular intervals has zero entropy. a wallet that transfers at perfectly random intervals has maximum entropy. the protocol rewards entropy, because regular intervals are the signature of automated extraction and random intervals are the signature of organic participation. the third component is path-return alignment, the cosine similarity between the wallet's individual log-return vector and the time-average log-return vector of the aggregate pool over the same window. a wallet whose returns closely track the collective time average has high alignment. a wallet whose returns systematically diverge, whether through front-running, sandwich extraction, or wash trading, has low alignment. the three components are combined into a single score, and the boltzmann distribution assigns to each wallet a share of the vault proportional to e raised to the negative score divided by a temperature parameter fixed at deployment. wallets with high scores, meaning long holding, high entropy, and high alignment, receive the largest share. wallets with low scores receive almost nothing. the distribution is computed entirely on chain, in a single instruction, using the per-wallet pdas as the population registry.

on the invariant

there is one constant inside the program: the natural ergodicity gap ε₀ = 0. there is one observable computed on every transfer: ε(t), the running gap between ensemble-average and time-average growth rates. when ε(t) approaches zero, the market is ergodic. individual trajectories are exploring the return space in proportion to their probability. no class of participant is systematically gaining at the expense of another. the protocol charges nothing beyond the base transfer cost, because there is nothing to correct. when ε(t) diverges from zero, the market is non-ergodic. some population of wallets is experiencing returns that diverge from the time average, which means some other population is experiencing returns that converge faster than the average, which means value is being transferred from the first population to the second through a mechanism that the ensemble average conceals. the protocol charges the cube of the divergence and pays the proceeds to the wallets whose trajectories most closely resemble what an ergodic participant's trajectory would look like.

the program is deployed through the bpf upgradeable loader with its upgrade authority set to none, which makes the on-chain bytecode immutable. there is no admin key. there is no multisig. there is no governance token, no dao, no snapshot vote, no timelock, no proxy pattern, no migration function. the scaling constant is fixed. the temperature parameter is fixed. the buffer size is fixed. the threshold is fixed. the only variable is ε(t), and ε(t) is determined by the transfers that the chain produces. the protocol does not know what the gap should be. it knows only what the gap is, and it acts on the difference between what is and what would be if every participant's path through the return space were, in boltzmann's original sense, ergodic. the protocol is the measurement. the measurement is the chain. the chain is whatever its participants make of it, and the protocol is the consequence of that making, applied retroactively, atomically, without appeal, on every transfer, forever.