> For the complete documentation index, see [llms.txt](https://myorg-41.gitbook.io/myorg-docs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://myorg-41.gitbook.io/myorg-docs/documentation.md).

# DOCUMENTATION

RightsRouter is a wallet-native, DeFi-first infrastructure platform designed to handle the complex lifecycle of tokenized assets on Robinhood Chain L2. It bridges economic exposure with on-chain governance and yield mechanics, ensuring that tokenized assets can execute protocol-level events—rebases, yields, and governance—natively on-chain without relying on traditional finance rails.

***

## Core Architecture

### The Network: Robinhood Chain L2

RightsRouter is deployed on **Robinhood Chain L2 (Chain ID: 50402)**, an Ethereum Layer-2 scaling solution. The protocol benefits from sub-second settlement times and near-zero gas fees, making micro-yield distributions through Smart DRIP mathematically viable on-chain.

### The Standard: ERC-8056 (Scaled UI Amount Extension)

A critical innovation of RightsRouter is its adoption of the ERC-8056 token standard for Token Rebases, traditionally known as stock splits.

* **The Problem:** Traditional rebasing mechanisms mutate `balanceOf(user)` by iterating over every holder or modifying global state in a way that breaks Automated Market Makers (AMMs) and triggers impermanent loss.
* **The Solution:** The underlying `rawBalance` of a user's wallet is completely immutable. Instead, the smart contract maintains a global `uiMultiplier()`.
* **Implementation:** When a 10-for-1 token rebase occurs, the raw balances do not change. The `uiMultiplier()` updates from `1.0` to `10.0`. DApps and wallets query `toUIAmount()` to display the effective token balance to the user. Chainlink oracles automatically adjust to this multiplier to ensure accurate USD pricing.

***

## Frontend Structure & Tech Stack

The application is built using a modern React stack optimized for Web3 integration:

* **Framework:** Next.js 14 (App Router)
* **UI/Styling:** Tailwind CSS, configured for a dark, glowing Web3 aesthetic
* **Icons:** `lucide-react`, fully open-source generic iconography avoiding corporate trademarks
* **State Management:** React Context API (`RightsContext.tsx`)

### Directory Layout

```
src/
├── app/
│   ├── api/trend/route.ts       # Serverless function fetching live price trends
│   ├── layout.tsx               # Root layout & context providers
│   ├── page.tsx                 # Main application interface and tab routing
│   └── globals.css              # Global styles, ambient glows, web3 styling
├── components/
│   ├── common/                  # Shared UI (AccountModal, NotificationDrawer, StockLogo)
│   ├── dashboard/               # PortfolioOverview, TrendSparkline
│   ├── dividends/               # Yield Drop Manager & DRIP mechanics
│   ├── issuer/                  # Protocol Admin / Transfer Desk interface
│   ├── layout/                  # Navbar, TickerTape
│   ├── splits/                  # ERC-8056 Token Rebase interface
│   ├── tender/                  # Liquidity Buybacks & Escrow management
│   └── voting/                  # DAO Governance and EIP-712 ballot signing
├── context/
│   └── RightsContext.tsx        # Global state for protocol events and user balances
├── data/
│   ├── mockData.ts              # Simulated on-chain state for the demo
│   └── stockLogos.ts            # Helper configurations for generic asset logos
└── types/
    └── index.ts                 # TypeScript interfaces for the protocol
```

***

## Protocol Modules

### Yield Drops & Smart DRIP (`DividendManager.tsx`)

Handles the distribution of protocol revenue or yield to token holders.

* **Cash Drops (USDC):** Direct airdrops of USDC to token holder wallets based on block-precise snapshots.
* **Smart DRIP (Dividend Reinvestment Plan):** A zero-slippage vault mechanism. Instead of receiving USDC, the smart contract automatically routes the user's USDC yield into a decentralized exchange (DEX) router to market-buy fractional amounts of the underlying token, compounding the user's position automatically.

### Token Rebases (`StockSplitManager.tsx`)

Manages the dilution and consolidation of token supply.

* Integrates directly with the ERC-8056 `uiMultiplier()`.
* Displays the delta between the immutable “Raw On-Chain Balance” and the “Effective Balance” post-rebase.

### Liquidity Buybacks (`TenderOfferManager.tsx`)

Facilitates decentralized liquidity events where the protocol treasury buys back tokens at a premium.

* **Escrow Mechanics:** Users deposit tokens into a time-locked escrow contract.
* **Revocability:** Users can withdraw their tokens before the expiration block.
* **Proration:** If the buyback is oversubscribed, the smart contract calculates exact pro-rata distributions and returns unsold tokens to the user's wallet automatically.

### DAO Governance (`ProxyVotingManager.tsx`)

Secures decentralized decision-making using snapshot logic.

* **Snapshot Blocks:** Voting power is mathematically locked to the user's balance at a specific historical block, preventing flash-loan voting attacks.
* **EIP-712 Signatures:** Votes are cast by signing a structured message off-chain. This costs zero gas for the user. The signatures are bundled into a Merkle tree and verified on-chain by the `GovernanceVault`.

***

## Live Data Integration

### Real-Time Trends (`/api/trend`)

To provide real-world context for the assets, the protocol uses a Next.js Edge API Route (`src/app/api/trend/route.ts`) to fetch live 7-day historical pricing data from the Yahoo Finance v8 API.

* **CORS Safe:** By routing the request through the Next.js server, the application bypasses strict browser CORS policies.
* **Visualization:** The data is piped into `TrendSparkline.tsx`, which dynamically constructs an SVG path representing the asset's price action over the last week.

***

## Security & Legal Considerations

* **Generic Asset Identifiers:** To comply with standard copyright and trademark laws, the platform utilizes generic SVG icons (`lucide-react`) combined with ticker text rather than hotlinking copyrighted corporate logos. This ensures the UI is 100% safe for commercial deployment on standard web hosts like Vercel.
* **No Direct Private Key Handling:** The frontend is strictly built to integrate with injected Web3 providers, such as MetaMask or WalletConnect. It does not, and should never, parse local `.env` files for private keys in the client bundle.

***

## Future Expansion (Roadmap)

{% stepper %}
{% step %}

### WalletConnect / Wagmi Integration

Swap out the simulated `RightsContext` state with a live `viem` or `ethers.js` provider to interact with the deployed Robinhood Chain contracts.
{% endstep %}

{% step %}

### The Graph Subgraph

Index ERC-8056 multiplier updates and DAO voting receipts using a dedicated subgraph for faster UI loading times.
{% endstep %}

{% step %}

### Cross-Chain Yield

Implement LayerZero bridging to allow users to collect USDC yield drops on alternate Layer 2 networks, such as Base or Optimism, while holding the underlying asset on Robinhood Chain.
{% endstep %}
{% endstepper %}


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://myorg-41.gitbook.io/myorg-docs/documentation.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
