z³
the oldest theorem in mathematics, written into a solana z token.
around 530 bc, on the greek island of samos, a man named Pythagoras proved that the square of the hypotenuse of a right triangle equals the sum of the squares of the other two sides. the proof is the oldest mathematical theorem still taught in every school. it survived the collapse of three civilizations, the loss of every original document attributed to its author, and the rise of every formal system that followed it. it is the simplest non-trivial statement about distance, and every measurement of distance ever made since has been a generalization of it.
the theorem in its original form is a statement about triangles. in its modern form it is the definition of length in any space where length is meaningful. the distance between two points in a plane is the square root of the sum of the squared differences of their coordinates. the distance between two points in three dimensions is the square root of the sum of three squared differences. the distance between two points in n dimensions is the square root of the sum of n squared differences. the theorem is a recipe. it is also a constraint.
the constraint is that the natural notion of length in any euclidean space must satisfy the theorem. anything that does not is not a length. this is why the theorem has outlived everything else from its era. it is not a theorem about a particular triangle, it is a theorem about what it means for something to be measured. it is also why the theorem can be applied to objects that look nothing like triangles.
a market can be measured the same way. the recent trades on a token, written as a sequence of (slot, amount, price) tuples, are points in a high-dimensional space. the distance between any two points is given by the theorem. the centroid of a cloud of points is the point that minimizes the sum of squared distances to every other point. the distance from the centroid to the farthest outlier is a single number that captures how concentrated or how dispersed the recent trading activity has been.
pythagorean is a solana z mainnet program deployed as a token-2022 transfer hook on the pythagorean mint. on every transfer of the token, the hook fires and appends the most recent trade to a 256 entry circular buffer stored in a program derived address. the buffer encodes each trade as a fixed-length tuple. the program then computes the centroid of the buffer, the squared euclidean distance from the centroid to the new trade, and updates a running pythagorean distance estimate stored alongside the buffer.
the entire computation is done in solana z's i128 fixed point arithmetic. the centroid is updated incrementally using welford's online algorithm, so the per-transfer cost is constant rather than proportional to the buffer length. the distance is computed by summing the squared coordinate differences and taking an integer square root. the result is a single i128 value representing how far the new trade sits from the recent center of activity, normalized to the interval [0, 1].
fig. 1 — the surcharge function σ(P) = α · (P − 1.414)². transfers that arrive while the distance estimate sits at the natural reference pay nothing extra. transfers that drift either above or below pay a quadratically growing surcharge.
the protocol compares the new pythagorean distance to a natural reference of 1.414, which is the square root of two and the average distance an independent participant would produce in an unmanipulated market. when the actual distance drops well below this reference, the recent trades have become clustered, which means coordinated activity is concentrating around a small region of the trading space. when the distance climbs well above this reference, the trades have become scattered in a way that suggests forced movement.
the surcharge applied to each transfer is proportional to the squared deviation between the current distance and the reference. when the deviation is small, the surcharge is zero. when the deviation grows, the surcharge grows quadratically. the surcharge is taken from the input amount of the transfer through the token-2022 hook's standard return value and routed to a vault program derived address.
the vault accumulates surcharges across many transfers. when its balance crosses a threshold set at deployment, the program distributes the accumulated balance to the holders whose individual trade vectors contribute the most to expanding the pythagorean distance of the buffer. these are the holders who introduce independent geometry, who trade in directions the rest of the cloud does not. the protocol charges the wallets that collapse the cloud and pays the wallets that spread it.
fig. 2 — the 256-entry circular buffer of recent trades (left) and the displacement vectors that define the pythagorean distance of the buffer (right). when the vectors point in coherent directions, the cloud is collapsing and the surcharge fires.
pythagorean was deployed and immediately sealed. the upgrade authority on the program was revoked in the same session as the deployment. the natural reference distance of 1.414 is a hardcoded constant compiled into the binary. the buffer size, the welford update parameters, the surcharge curve, and the vault address are all 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. the only mutable state on chain is the circular buffer, the running centroid and distance estimate, and the vault balance. all four are overwritten by the next transfer regardless of who sends it. the protocol is a function of whatever the chain produces.