Skip to content

YoneCode/MneMe

Repository files navigation

MNEME

Semantic Drift Derivative Protocol on GenLayer.

MNEME lets people trade on how the meaning of a concept drifts over time. Instead of referencing a price feed or a deterministic oracle, it asks a committee of AI validators to read a concept's source and reach consensus on how far its interpretation has moved. That consensus value, the Semantic Drift Index (SDI), is what derivatives settle against. The whole thing runs on GenLayer's Bradbury testnet, where non-deterministic LLM evaluation is itself the consensus mechanism.

The idea in plain terms

  • An anchor pins a concept (a definition, a domain, and a reference URL) on-chain.
  • Each epoch, validators independently fetch the source, run a sanitized prompt, and score the concept's Semantic Drift Index (0 to 100%). They agree through GenLayer's equivalence principle (numerical tolerance plus semantic checks), not byte equality.
  • A Semantic Drift Swap (SDS) is a bilateral contract on an anchor: a buyer pays premium, a seller underwrites and locks collateral, and the swap pays out if the anchor's SDI crosses the buyer's strike.
  • Every evaluation appends a node to the anchor's Semantic Memory Tree (SMT), so the full history of how a meaning moved is auditable on-chain.

Lifecycle

  1. Register anchor. Pin a concept plus a reference URL. The contract seeds an SMT root and records you as creator.
  2. Evaluate epoch. Five validators fetch the URL, run sanitized LLM prompts, and reach equivalence-principle consensus on the SDI. The result is written as a new SMT node.
  3. Open and underwrite. A buyer opens a swap with a strike SDI; a seller underwrites it, locking collateral. Premium accrues each epoch.
  4. Settle. When the SDI crosses the strike, the swap auto-triggers. Anyone can call settle to compute the payout (linear, quadratic, or binary).

Why it needs GenLayer

Semantic drift is a judgment, not a fact you can look up. There is no external oracle for "has the meaning of stablecoin shifted," because producing that judgment is the work itself. GenLayer makes the LLM evaluation the consensus, with equivalence defined by semantic tolerance rather than exact match, so the contract can store, replay, and build on accumulated semantic state across epochs. That is not expressible on a deterministic VM.

Anchors currently tracked

Live state read from the deployed contract. An SDI of 0% means no drift has been recorded yet (the concept has not been evaluated, or the validators found no meaningful shift this round).

Anchor Concept Domain SDI Evals
anchor:1 stablecoin DeFi 6.00% 2
anchor:2 NFT Web3 0.00% 0
anchor:3 artificial intelligence AI 2.00% 1
anchor:4 equivalence principle GenLayer 5.00% 2
anchor:5 intelligent contract GenLayer 0.00% 1

Tech stack

Intelligent contract (contracts/Mneme.py)

  • Python GenLayer contract running in the GenVM.
  • Non-deterministic evaluation via gl.nondet.web.render (fetch the source) and gl.nondet.exec_prompt (score the drift), wrapped in gl.vm.run_nondet_unsafe(leader_fn, validator_fn) so validators apply numeric tolerance and semantic boundary checks instead of byte equality.
  • Storage in native GenLayer types only (TreeMap, DynArray); the SMT is an append-only tree of evaluation nodes.
  • u256 everywhere for cross-chain interop: basis points (0 to 10,000) for SDI/strike/drift, atto-units (value times 10^18) for money.
  • Greybox prompt sanitization before every LLM call, and prefixed error classes ([EXPECTED], [EXTERNAL], [TRANSIENT], [LLM_ERROR]) so validators converge on failure paths.

Network

  • GenLayer Bradbury testnet.

Frontend (frontend/)

  • Next.js 16 (App Router) and React 19, TypeScript.
  • Tailwind CSS v4 for styling, with an OKLCH token system.
  • genlayer-js for all contract reads and writes (built on viem), every value is fetched live from chain with no mock state.
  • Wallet layer: Privy (@privy-io/react-auth) embedded wallets plus MetaMask, pinned to the Bradbury chain.
  • TanStack Query for client state, Radix UI primitives, sonner toasts, lucide-react icons.

Contracts tooling

  • GenLayer CLI for deployment.
  • gltest (Python) for end-to-end contract tests in tests/.

Project structure

contracts/   GenLayer intelligent contracts (Mneme.py)
config/      Network configuration
deploy/      Deployment scripts
frontend/    Next.js app (components, lib/contracts client, lib/genlayer wallet)
tests/       gltest end-to-end tests

Getting started

Prerequisites: Node.js, the GenLayer CLI (npm install -g genlayer), and a GenLayer Studio or testnet endpoint.

  1. Deploy the contract. Select the network with genlayer network, then genlayer deploy (runs deploy/deployScript.ts).
  2. Configure the frontend. Copy frontend/.env.example to frontend/.env and set NEXT_PUBLIC_CONTRACT_ADDRESS to your deployed address plus the Bradbury RPC values.
  3. Run the frontend.
    cd frontend
    npm install
    npm run dev
    Open the local URL printed by the dev server.
  4. Run contract tests. With a GenLayer Studio running, execute gltest from the repo root.

Links

License

See LICENSE.

About

Semantic Drift Derivative Protocol on GenLayer Bradbury. Register anchors, open swaps, settle on validator-consensus meaning shifts.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors