Phase 3: layered supply oracle#1
Merged
Merged
Conversation
The supply oracle is the central trust assumption of autonomous market-cap weighting (SPEC Section 8). Built in three layers behind the ISupplyOracle seam so the methodology never sees how the number was secured. Layer 1, minimize (ExcludedAddressRegistry): - Derives circulating supply on-chain as totalSupply minus the balance of each excluded address, turning trust in a number into trust in a timelocked, publicly auditable list of addresses - totalSupply is a free trustless upper bound; the subtraction fails closed on underflow - Every excluded-set change is timelocked (1 hour to 30 day band) and visible before it can take effect; execution is permissionless once the delay elapses, cancellable before Layers 2 and 3, secure and contain (SupplyOracle): - Free-float = onChainCirculating * freeFloatFactor / 1e18, with the factor in (0, 1e18] so free-float can never exceed the on-chain floor - Multi-source reporter median with a divergence freeze: a commit requires k fresh reports agreeing within tolerance, otherwise it reverts and the constituent stays frozen at last-good - Per-commit rate-limit clamps large moves so a spike is approached gradually over several commits; a hard maxCommitAge fails reads closed; guardian can pause all reads - Interface-shaped so an optimistic oracle can replace the residual source per constituent later without touching the methodology 26 new tests including adversarial divergence, rate-limit convergence, and an end-to-end integration driving MarketCapMethodology through the real oracle. 75 tests passing.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Implements Phase 3 of the build plan (SPEC Section 13): the layered supply oracle. This is the central trust assumption of autonomous market-cap weighting, so it is built in three layers behind the
ISupplyOracleseam, with the methodology engine never seeing how the number was secured.Layer 1, minimize (
ExcludedAddressRegistry)totalSupply - Σ balanceOf(excluded), turning trust in a number into trust in a publicly auditable list of addresses.totalSupplyis a free trustless upper bound; the subtraction fails closed on underflow.Layers 2 and 3, secure and contain (
SupplyOracle)freeFloat = onChainCirculating * freeFloatFactor / 1e18, with the factor capped at1e18, so free-float can never exceed the on-chain floor by construction.kof them to agree within tolerance; otherwise it reverts and the constituent stays frozen at last-good rather than acting on disputed data.maxCommitAgefails reads closed; the guardian can pause all reads.Design notes
ISupplyOracledoc was updated to state this contract.Testing
26 new tests, 75 passing total. Covers the timelock lifecycle, on-chain derivation, the median commit path, adversarial divergence freeze, rate-limit clamp convergence, hard and soft staleness, guardian pause, and an end-to-end integration driving
MarketCapMethodologythrough the real layered oracle (no mock supply source in the path).Two behaviors surfaced and confirmed correct: at
n = 1/capthe capped index saturates to equal weight and every name becomes supply-insensitive (a stronger form of SPEC 8.4), and excluding a name's entire supply can trip theCapInfeasibleguard by dropping the nonzero count below1/cap.