feat: multi-index refactor (shared AssetRegistry, per-vault curated constituents)#5
Merged
Merged
Conversation
…onstituents) Make the protocol a multi-index platform rather than a single index. The registry was doing two jobs at once: the global asset catalog and one index's membership. For a single index those collapse, which is why the separation read as ceremony. Split them. AssetRegistry (was ComponentRegistry): - Re-scoped to a shared global catalog of registerable assets, not an index. It is the eligible universe any index draws from; a token is registered once and any index may include it. - Renamed surface: registerAsset/removeAsset/getAsset/getAssets/assetCount, MAX_ASSETS=250 as a catalog cap (distinct from a per-index size cap), and AssetRegistry_* errors. Price reads and health checks unchanged. IndexVault now owns its curated constituents: - Holds its own _constituents set with setConstituents, validating each token is registered in the catalog, rejecting duplicates, capping at MAX_CONSTITUENTS=100, and caching decimals so the NAV loop makes no external decimals call. - NAV loops over the vault's own constituents, not the whole registry. - New public reads: getConstituents, constituentCount, isConstituent, and getHoldings (per-constituent balance, USD value, weight in bps, plus idle USD and total NAV) for transparency. - Membership is admin-curated because category membership (L1, DEX, AI, ...) is definitional, not rank-derived; weighting over the set stays autonomous. The timelock/forced-removal/rate-limit guardrails are a later stage. MarketCapMethodology points at AssetRegistry; it already took constituents as arguments. Adds 7 tests including two index vaults sharing one registry with independent NAV (the multi-index property), getHoldings value/weight checks, and setConstituents validation. 83 tests pass.
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.
What
Turns the protocol from a single index into a multi-index platform. The registry was conflating two jobs, the global asset catalog and one index's membership, which for a single index collapse into each other and made the separation look like ceremony. This splits them.
AssetRegistry (was ComponentRegistry)
Re-scoped to a shared global catalog of registerable assets, not an index. It is the eligible universe any index draws from: a token is registered once and any index vault may then include it.
registerAsset/removeAsset/getAsset/getAssets/assetCount,MAX_ASSETS = 250as a catalog cap (distinct from a per-index size cap), andAssetRegistry_*errors.IndexVault now owns its curated constituents
_constituentsset withsetConstituents, which validates each token is registered in the catalog, rejects duplicates, caps atMAX_CONSTITUENTS = 100, and caches decimals so the NAV loop makes no external decimals call.getConstituents,constituentCount,isConstituent, andgetHoldings, which returns each constituent's balance, USD value, and weight in bps plus the idle USD and total NAV. This is the transparency surface for "what is in the index and in what proportion."MarketCapMethodologypoints atAssetRegistry; it already took constituents as arguments, so no other change.Scope note
setConstituentsis intentionally a simple owner-gated wholesale setter here. The timelock, forced-versus-discretionary removal, rate-limit, and minimum-count guardrails (spec Section 16) are a later stage, as is the deposit cap.Testing
Adds 7 tests, including two index vaults sharing one registry with fully independent NAV (the multi-index property),
getHoldingsvalue and weight checks, idle-in-weights accounting, andsetConstituentsvalidation (unregistered asset, duplicate, set replacement). 83 tests pass; noComponentRegistryreference remains anywhere.