Conversation
Adds the arithmetic for an inventory charge built on the certainty-equivalent
cost of the pool's payout book under exponential utility, weighted by the
risk-neutral probability of each settlement price:
D(W) = b * ln( sum q(S) * exp(W(S)/b) ) - sum q(S) * W(S)
Nothing calls it. The module owns the statistic and its incremental fold; the
accumulators and the range reads they need are a separate change.
The shape is chosen for two properties the mean-plus-standard-deviation form
cannot have. Adding a payout at every settlement price raises the certainty
equivalent and the fair value by the same amount, so buying every outcome is
free — asserted exactly, not within a tolerance. And because a trade's total is a
convex combination of the fair value and the certainty equivalent, both monotone,
no rate in [0, 1] can price a strictly worse book lower; the deviation form
admits no such rate once the settlement ladder is fine, because its monotonicity
bound is set by the smallest bucket on it.
The statistic is a difference of two independently floored terms and Jensen puts
the true difference at or above zero, so a book that owes the same everywhere can
leave the logarithm a unit short. That case clamps rather than aborts, and the
clamp can only bind within the rounding error of a book carrying no unevenness.
`exp` cannot return a value outside `u64`, so the exponent is bounded well inside
its input ceiling. Deriving the risk tolerance from the market's allocation keeps
the ratio inside that bound by construction rather than by hoping, which is the
wiring the next change owes.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Closing this. Two independent checks came back and both go against it.The measure does not earn its placeScored on the same 17,082 books settled on real BTC paths as the other candidates:
It never beats the probability-weighted spread at any risk tolerance — the sweep is a strict tradeoff with no interior win. Its one real gain is exactly the bucketed design's gain, at the same magnitude, and their rank correlation is 0.972. At small tolerance this is a smoothed version of #1252. The theory held up completely: zero monotonicity violations across 9.6M charge evaluations, and the deviation form's ceiling And the implementation is not soundThe formula, the sign convention and the fold algebra are correct — verified against the entropic risk measure definition and brute-forced over ~960 random books with no structural error. The integer implementation is another matter. Both fold directions floor, so the charge decays to zero under churn. A round trip permanently removes 1–2 raw units of The exponent guard bounds the trade, not the book. Nothing bounds cumulative The headline property is not what it appears. There is also a dead zone below What is worth keepingThe rounding fix is real and general: floor the add, ceiling the remove, which biases dust to the protocol per this repo's own rounding policy rather than to the trader. That applies to any multiplicative fold, not only this one. And the reason this branch existed is unchanged — the deviation form used by both open designs is not monotone, and its ceiling vanishes as the ladder refines. That finding stands and belongs in the design record regardless of which measure ships. Closing rather than iterating: the measure would have to beat the probability-weighted spread to be worth the multiplicative index this needs, and it does not. |
|
Superseded by the measurement — see above. |
Summary
inventory_entropic, the arithmetic for an inventory charge on the certainty-equivalent cost of the pool's payout book, weighted by where settlement is actually likely.W(S)is what the pool owes if the market settles at tickS;qis the risk-neutral probability of settling there, frozen at market creation;bis the risk tolerance.Dis zero when the pool owes the same at every price and grows with how unevenly the book sits, weighted by likelihood.Why this shape
Two properties the mean-plus-standard-deviation form cannot have.
Buying every outcome is free, exactly. Adding a payout at every settlement price raises the certainty equivalent and the fair value by the same amount, so the difference is unchanged. Asserted as an equality, not within a tolerance.
No rate can misprice a strictly worse book. A trade's total is
(1 - rate) * fair value + rate * certainty equivalent, a convex combination of two monotone functions, so it is monotone for any rate in[0, 1]with no dependence on the ladder. The deviation form admits no such rate once the ladder is fine: its monotonicity bound israte <= sqrt(q_min / (1 - q_min)), set by the smallest bucket, which collapses toward zero as the ladder refines. Standard deviation is also positively homogeneous, so worst-case loss is unbounded; here it is bounded byb * ln(1/q_min).The large-
blimit of this statistic is the probability-weighted variance over2b, so the deviation form is its leading term. The square root is what buys positive homogeneity, and positive homogeneity is what forfeits the bound.Key decisions
exp(payout/b)and leaves the rest alone, so the read a trade needs is the range's own share rather than anything about the whole book.exp's input ceiling.expcannot return a value outsideu64and aborts rather than wrapping. Derivingbfrom the market's allocation keepsW/binside the bound by construction; that wiring is owed by the next change and the module asserts the bound in the meantime.Scope / Descoped
StrikeExposure, the range read from the payout index (a multiplicative monoid over boundaries, not the additive one that exists), the frozen surface snapshot at market creation, the config knob derivingbfrom the allocation, and the charge wiring into mint and close.Test plan
sui move test --path packages/predict --gas-limit 100000000000— 492 pass, noMove.lockdrift.sui move build --path packages/predict --warnings-are-errors— clean.adding_the_same_payout_everywhere_leaves_the_statistic_at_zero— the property the design rests on, asserted exactly.a_range_opened_and_closed_returns_the_totals— a round trip returns both accumulators, so it collects nothing.an_empty_book_owes_the_same_everywhere_and_scores_zero.a_half_covered_book_carries_the_gap_between_cost_and_value— expected value derived independently frommath.log/math.exp. Asserted within a granularity-derived bound rather than exactly, because this repository does not document the precision of its fixed-pointexpandln; every mathematically exact property is pinned by the tests above.Risk / Rollout
Unreachable — no caller. The module is inert until the follow-up wires it, and any charge it eventually feeds would ship at a zero rate like the two mechanisms already open.
An empirical comparison of this statistic against the two open designs, on real BTC price paths, is in progress and will be posted here. If it does not beat them this branch should be closed rather than continued.