Skip to content

Add query tokenizer contract - #43

Merged
viatrix merged 6 commits into
devfrom
feat-query-token
Sep 2, 2026
Merged

viatrix merged 6 commits into
devfrom
feat-query-token

Conversation

@viatrix

@viatrix viatrix commented Aug 20, 2026

Copy link
Copy Markdown
Collaborator

Implements #16

@viatrix
viatrix requested review from Xaleee and a lite review from Copilot September 1, 2026 14:49

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds a new “Query Tokenizer” protocol surface to let users prepay oracle query fees by minting/burning per-universe ERC20 query-right tokens, and wires the Multiverse + deploy flow to support tokenizer-priced query creation.

Changes:

  • Introduces QueryTokenizer + per-universe QueryToken contracts, along with IQueryTokenizer/IQueryToken and an IMultiverse subset contract.
  • Extends Multiverse with tokenizer-specific query creation (createQueryFromTokenizer) and one-call mint pricing (getMintPricing), plus refactors volume cache rolling.
  • Adds comprehensive unit + fuzz tests and updates existing test suites/fixtures to account for the new constructor arg and fork-threshold unit conversions.

Reviewed changes

Copilot reviewed 19 out of 19 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
test/unit/QueryTokenizer.t.sol New unit tests for QueryTokenizer mint pricing, mint, redeem, and token ownership behaviors.
test/unit/QueryTokenizer.fixtures.sol New fixtures wiring QueryTokenizer ↔ Multiverse and providing mint/redeem helpers.
test/unit/Multiverse.tokenizer.t.sol New tests for Multiverse’s tokenizer-facing surfaces.
test/unit/Multiverse.report.t.sol Updates fork-threshold assertions to use wREP-converted threshold helper.
test/unit/Multiverse.queryFee.t.sol Updates cap/threshold assertions to use wREP-converted cap helper.
test/unit/Multiverse.profits.t.sol Updates Multiverse harness deployment for new constructor arg.
test/unit/Multiverse.fixtures.sol Adds tokenizer stub + wREP threshold/cap helpers; updates Multiverse deployment signature.
test/unit/Multiverse.constructor.t.sol Updates constructor tests for new QUERY_TOKENIZER immutable and zero-address check.
test/invariant/Multiverse.invariant.t.sol Updates invariant fork-threshold logic to use wREP-converted threshold helper.
test/fuzz/QueryTokenizer.fuzz.t.sol New fuzz properties for pool accounting and mint price formula/cap.
test/fuzz/Multiverse.resolve.fuzz.t.sol Updates fuzz bounds to use wREP cap helper.
test/fuzz/Multiverse.createQuery.fuzz.t.sol Updates fuzz cap computation to use wREP cap helper.
src/QueryTokenizer.sol New core tokenizer contract implementing mint/redeem and pricing via Multiverse.
src/QueryToken.sol New per-universe ERC20 controlled by the tokenizer (owner-only mint/burn).
src/Multiverse.sol Implements IMultiverse, adds tokenizer query creation + mint pricing surface, adjusts fee cap units, refactors volume-cache logic, and clamps first-report bond behavior.
src/interfaces/IQueryTokenizer.sol New tokenizer interface.
src/interfaces/IQueryToken.sol New per-universe query token interface.
src/interfaces/IMultiverse.sol New Multiverse subset interface needed by tokenizer + deploy script.
script/Deploy.s.sol Updates deploy order to include QueryTokenizer and wires it to Multiverse.
Suppressed comments (1)

src/QueryTokenizer.sol:109

  • _mintPrice will perform an external call on multiverse_ even when the tokenizer hasn’t been wired yet, which currently results in a low-level revert against address(0). Add an explicit guard so callers get a deterministic, self-explanatory revert.
    function _mintPrice(IMultiverse multiverse_, uint248 universeId) internal view returns (uint256, ILituusRep) {
        (uint256 uncappedFee, uint256 cap, ILituusRep repToken) = multiverse_.getMintPricing(universeId);
        uint256 price = uncappedFee * PREMIUM_NUMERATOR / PREMIUM_DENOMINATOR;
        return (price > cap ? cap : price, repToken);
    }

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread src/Multiverse.sol
Comment thread src/QueryTokenizer.sol
Comment thread test/unit/Multiverse.tokenizer.t.sol
Comment thread test/unit/QueryTokenizer.t.sol Outdated
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
@viatrix
viatrix marked this pull request as ready for review September 1, 2026 15:00
@viatrix
viatrix merged commit 056857a into dev Sep 2, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants