@rev-net/core-v6 0.0.32 → 0.0.34

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/ADMINISTRATION.md CHANGED
@@ -1,237 +1,73 @@
1
1
  # Administration
2
2
 
3
- Admin privileges and their scope in revnet-core-v6. Revnets are designed to be autonomous Juicebox projects with no traditional owner. This document covers what privileged operations exist, who can perform them, and -- critically -- what is intentionally made impossible.
4
-
5
3
  ## At A Glance
6
4
 
7
5
  | Item | Details |
8
- |------|---------|
9
- | Scope | Autonomous revnet deployment, split-operator powers, loan metadata ownership, hidden token management, and the boundaries imposed by revnet immutability. |
10
- | Operators | The per-revnet split operator, the global `REVLoans` owner for metadata cosmetics, the protocol-owned `REVDeployer`, loan NFT holders (or operators with `REPAY_LOAN`/`REALLOCATE_LOAN`/`OPEN_LOAN` permissions), `REVHiddenTokens` callers (or operators with `HIDE_TOKENS`/`REVEAL_TOKENS` permissions), and permissionless callers for open lifecycle actions. |
11
- | Highest-risk actions | Converting an existing project into a revnet, changing or burning the split operator, and configuring buyback, router, price-feed, or sucker permissions inside the narrow allowed operator surface. |
12
- | Recovery posture | Revnet economics are intentionally not admin-recoverable. A bad deployment generally means abandoning the revnet and deploying a new one. |
13
-
14
- ## Routine Operations
6
+ | --- | --- |
7
+ | Scope | Revnet deployment shape, bounded runtime operators, loan-owner cosmetics, and optional integration control surfaces |
8
+ | Control posture | Intentionally narrow and mostly deployment-defined |
9
+ | Highest-risk actions | Bad stage design, wrong split-operator assignment, and misunderstanding which runtime surfaces stay live after launch |
10
+ | Recovery posture | Usually replacement, not patching; the design intentionally avoids easy admin escape hatches |
15
11
 
16
- - Use the split operator only for the limited post-launch surfaces the protocol deliberately leaves mutable: reserved-token split routing, selected hook metadata, router selection, and related operator-scoped settings.
17
- - Keep `REVLoans` owner actions limited to URI resolver maintenance; that role should never be treated as an economic admin.
18
- - Treat `deploySuckersFor`, buyback configuration, and router-terminal changes as operational extensions around a fixed revnet, not as tools to rewrite the revnet's stage economics.
19
- - If autonomy is the goal, consider relinquishing the split operator to `address(0)` only after all intended mutable integrations are finalized.
12
+ ## Purpose
20
13
 
21
- ## One-Way Or High-Risk Actions
14
+ `revnet-core-v6` is designed to collapse ordinary post-launch governance into deployment-time decisions plus a small set of bounded runtime roles. The main administration task is understanding which power still exists and which power was intentionally removed.
22
15
 
23
- - Deploying a revnet or converting an existing project into one is irreversible from an ownership and stage-design perspective.
24
- - Setting the split operator to `address(0)` permanently burns the human-controlled role.
25
- - Stage schedules, issuance curves, cash-out tax rates, and core economic parameters are fixed at deployment.
16
+ ## Control Model
26
17
 
27
- ## Recovery Notes
28
-
29
- - There is no admin escape hatch for broken revnet stage design. The recovery path is a new revnet deployment with corrected parameters.
30
- - If an auxiliary integration such as a buyback hook or sucker is wrong but the split operator still has the relevant scoped power, fix that integration without expecting to change the underlying revnet economics.
18
+ - `REVDeployer` holds the project NFT and therefore remains part of the ownership model.
19
+ - Revnet economics are mainly fixed at deployment through staged rulesets.
20
+ - `REVOwner` provides live runtime policy, but not broad human governance.
21
+ - Split operators can hold narrow powers depending on stage and deployment config.
22
+ - `REVLoans` has a cosmetic global owner surface, but loan economics are still bounded by revnet logic.
31
23
 
32
24
  ## Roles
33
25
 
34
- ### Split Operator
35
-
36
- - **How assigned:** Specified at deployment via `REVConfig.splitOperator`. After deployment, only the current split operator can transfer the role to a new address by calling `setSplitOperatorOf()`.
37
- - **Scope:** Per-revnet. Each revnet has at most one split operator. The operator is the only human-controlled role in a deployed revnet.
38
- - **Can be permanently relinquished:** The split operator can transfer the role to `address(0)` via `setSplitOperatorOf()`, which permanently relinquishes operator powers. Permissions are granted to the zero address (which cannot execute transactions), effectively burning them. This is irreversible.
39
-
40
- ### REVLoans Owner (Ownable)
41
-
42
- - **How assigned:** Set at `REVLoans` contract deployment via the `owner` constructor parameter. Transferable via OpenZeppelin `Ownable.transferOwnership()`.
43
- - **Scope:** Global across all revnets using this loans contract. Controls only the loan NFT metadata URI resolver -- has no power over loan parameters, collateral, or funds.
44
-
45
- ### REVDeployer (as Juicebox project owner)
46
-
47
- - **How assigned:** Automatic. When a revnet is deployed, the `REVDeployer` contract becomes the permanent owner of the Juicebox project NFT. If initializing an existing project, the caller's project NFT is irreversibly transferred to `REVDeployer`.
48
- - **Scope:** The deployer holds the project NFT and uses its owner authority to enforce revnet rules. It acts as a protocol-level constraint layer, not as a discretionary admin. No human can exercise this ownership.
26
+ | Role | How Assigned | Scope | Notes |
27
+ | --- | --- | --- | --- |
28
+ | `REVDeployer` | Deployed singleton | Global launcher and project-NFT holder | Part of the ownership model |
29
+ | Split operator | Deployment config | Per revnet | Holds only the allowed operator envelope |
30
+ | Auto-issuance beneficiary | Deployment config | Per stage | Can receive preconfigured stage issuance |
31
+ | Borrower or delegated loan operator | Token holder plus permission | Per holder or loan | Can open or manage loans within loan rules |
32
+ | `REVLoans` owner | Constructor owner | Global cosmetic/admin surface | Does not turn Revnets back into ordinary governed projects |
49
33
 
50
- ### Loan NFT Owner
34
+ ## Privileged Surfaces
51
35
 
52
- - **How assigned:** The `holder` specified in `borrowFrom()` receives the loan ERC-721. When no operator delegation is used, the caller passes themselves as `holder`. Transferable like any ERC-721.
53
- - **Scope:** Per-loan. The current NFT owner — or an operator with the relevant `JBPermissionIds` (`REPAY_LOAN`, `REALLOCATE_LOAN`) — can repay the loan, return collateral, or reallocate collateral to a new loan.
36
+ - `deployFor(...)` defines the revnet's long-lived shape
37
+ - split-operator paths can manage only the permissions left open by deployment
38
+ - `autoIssueFor(...)` consumes preconfigured stage issuance
39
+ - loan operators can redirect borrowed value if a holder delegates loan permissions
40
+ - hidden-token flows require the holder's permission grant and mint permission wiring through `REVOwner`
54
41
 
55
- ### Anyone (Permissionless)
42
+ ## Immutable And One-Way
56
43
 
57
- - **Scope:** Several functions are callable by any address with no access control, as documented in the Privileged Functions tables below.
44
+ - Stage configuration is effectively permanent after deployment.
45
+ - The deployer-held project NFT is not a normal owner-recovery tool.
46
+ - Loan collateral is burned at borrow time and only reminted through repayment or documented flows.
47
+ - Hidden-token balances change visible supply until reveal.
58
48
 
59
- ## Privileged Functions
49
+ ## Operational Notes
60
50
 
61
- ### REVDeployer
51
+ - Treat revnet launch as the real governance decision.
52
+ - Validate stage timing, split-operator scope, and optional integrations before deployment.
53
+ - Review cash-out delay, hidden-token semantics, and loan permissions together.
54
+ - Do not assume there is a broad admin override for bad economics after launch.
62
55
 
63
- | Function | Required Role | Permission ID | What It Does |
64
- |----------|--------------|---------------|-------------|
65
- | `deployFor()` | Anyone (new revnet) or Juicebox project owner (existing project) | None | Deploys a new revnet or irreversibly converts an existing Juicebox project into a revnet. Both variants deploy a tiered ERC-721 hook: the 4-arg variant deploys a default empty hook; the 6-arg variant deploys a hook with pre-configured tiers and optional croptop posting rules. |
66
- | `deploySuckersFor()` | Split Operator | Checked via `_checkIfIsSplitOperatorOf()` | Deploys new cross-chain suckers for an existing revnet. Also requires the current ruleset's `extraMetadata` bit 2 to be set (allows deploying suckers). |
67
- | `setSplitOperatorOf()` | Split Operator | Checked via `_checkIfIsSplitOperatorOf()` | Replaces the current split operator with a new address. Revokes all operator permissions from the caller and grants them to the new address. |
68
- | `autoIssueFor()` | Anyone | None | Mints pre-configured auto-issuance tokens for a beneficiary once the relevant stage has started. Amounts are set at deployment and can only be claimed once. |
69
- | `burnHeldTokensOf()` | Anyone | None | Burns any of a revnet's tokens held by the `REVDeployer` contract (e.g., from reserved token splits that did not sum to 100%). |
70
- | `afterCashOutRecordedWith()` | Anyone (called by terminal) | None | **Note: This function lives on REVOwner, not REVDeployer.** Processes cash-out fees. No caller validation needed because a non-terminal caller would only be donating their own funds. |
56
+ ## Machine Notes
71
57
 
72
- ### Split Operator Permissions (granted via JBPermissions)
58
+ - Do not describe Revnets as fully adminless if the deployer-held NFT still matters for the trust model.
59
+ - Also do not describe them as ordinary owner-controlled projects. The point is that the available control surface is intentionally narrow.
60
+ - If a question is about runtime cash-outs, buybacks, or mint permissions, inspect `REVOwner` before inferring behavior from deployment prose.
73
61
 
74
- The split operator receives the following Juicebox permission IDs, scoped to its revnet:
62
+ ## Recovery
75
63
 
76
- | Permission ID | What It Allows |
77
- |---------------|----------------|
78
- | `SET_SPLIT_GROUPS` | Change how reserved tokens are distributed among split recipients. |
79
- | `SET_BUYBACK_POOL` | Configure which Uniswap V4 pool is used for the buyback hook. |
80
- | `SET_BUYBACK_TWAP` | Adjust the TWAP window for the buyback hook. |
81
- | `SET_PROJECT_URI` | Update the revnet's metadata URI. |
82
- | `ADD_PRICE_FEED` | Add a new price feed for the revnet. |
83
- | `SUCKER_SAFETY` | Manage sucker safety settings (e.g., emergency hatch). |
84
- | `SET_BUYBACK_HOOK` | Configure the buyback hook. |
85
- | `SET_ROUTER_TERMINAL` | Set the router terminal. |
86
- | `SET_TOKEN_METADATA` | Update the revnet token's name and symbol. |
87
-
88
- Optional 721 permissions (granted only if enabled at deployment via `REVDeploy721TiersHookConfig`):
89
-
90
- | Permission ID | Deployment Flag | What It Allows |
91
- |---------------|----------------|----------------|
92
- | `ADJUST_721_TIERS` | `preventSplitOperatorAdjustingTiers` | Add or remove ERC-721 tiers. Allowed unless prevented. |
93
- | `SET_721_METADATA` | `preventSplitOperatorUpdatingMetadata` | Update ERC-721 tier metadata. Allowed unless prevented. |
94
- | `MINT_721` | `preventSplitOperatorMinting` | Mint ERC-721s without payment from tiers with `allowOwnerMint`. Allowed unless prevented. |
95
- | `SET_721_DISCOUNT_PERCENT` | `preventSplitOperatorIncreasingDiscountPercent` | Increase the discount percentage of a tier. Allowed unless prevented. |
96
-
97
- ### REVLoans
98
-
99
- | Function | Required Role | Access Control | What It Does |
100
- |----------|--------------|----------------|-------------|
101
- | `borrowFrom()` | Holder or operator with `OPEN_LOAN` | `PERMISSIONS.hasPermission` if caller ≠ holder | Opens a loan against revnet token collateral. The `holder` parameter specifies whose tokens are burned; the loan NFT is minted to `holder`. |
102
- | `repayLoan()` | Loan NFT Owner or operator with `REPAY_LOAN` | `PERMISSIONS.hasPermission` if caller ≠ owner | Repays a loan (partially or fully) and returns collateral. Replacement loans are minted to the original loan owner. |
103
- | `reallocateCollateralFromLoan()` | Loan NFT Owner or operator with `REALLOCATE_LOAN` | `PERMISSIONS.hasPermission` if caller ≠ owner | Splits excess collateral from an existing loan into a new loan. Returned collateral and replacement loans go to the original loan owner. |
104
- | `liquidateExpiredLoansFrom()` | Anyone | None | Liquidates loans that have exceeded the 10-year liquidation duration. Permanently destroys collateral. |
105
- | `setTokenUriResolver()` | REVLoans Owner | `onlyOwner` (OpenZeppelin Ownable) | Sets the contract that resolves loan NFT metadata URIs. |
106
-
107
- ### Constructor-Level Permissions (set once at deployment)
108
-
109
- These permissions are granted in the `REVDeployer` constructor and apply globally (wildcard `projectId = 0`):
110
-
111
- | Grantee | Permission ID | Purpose |
112
- |---------|---------------|---------|
113
- | `SUCKER_REGISTRY` | `MAP_SUCKER_TOKEN` | Allows the sucker registry to map tokens for all revnets. |
114
- | `LOANS` | `USE_ALLOWANCE` | Allows the loans contract to use surplus allowance from all revnets to fund loans. |
115
- | `BUYBACK_HOOK` | `SET_BUYBACK_POOL` | Allows the buyback hook registry to configure Uniswap V4 pools for all revnets. |
116
-
117
- ## Autonomous Design
118
-
119
- Revnets are designed to operate without a traditional project owner. The following mechanisms enforce autonomy:
120
-
121
- - **Ownership transfer is permanent.** When a revnet is deployed, the Juicebox project NFT is transferred to the `REVDeployer` contract. No human holds the project NFT. There is no function to transfer it back.
122
- - **No ruleset queuing.** The `REVDeployer` does not expose any function to queue new rulesets after deployment. The stage progression is fully determined at deploy time. Nobody -- not the split operator, not the deployer, not anyone -- can change the issuance schedule, cash-out tax rates, or stage timing after deployment.
123
- - **No approval hooks.** All rulesets are deployed with `approvalHook = address(0)`. There is no mechanism to block or delay stage transitions.
124
- - **Cash outs cannot be fully disabled.** The deployer enforces `cashOutTaxRate < MAX_CASH_OUT_TAX_RATE` for every stage, guaranteeing that token holders always retain some ability to cash out.
125
- - **Data hook is REVOwner.** `REVOwner` is set as the data hook (`metadata.dataHook = address(OWNER())`) for all rulesets, ensuring consistent fee and sucker logic without external admin control. REVOwner stores `cashOutDelayOf` and `tiered721HookOf` in its own storage (set by REVDeployer via DEPLOYER-restricted setters during deployment).
126
- - **Mint permission is restricted.** Only the loans contract, the hidden tokens contract, the buyback hook (and its delegates), and registered suckers can mint tokens (as determined by `REVOwner.hasMintPermissionFor`). The split operator cannot mint fungible revnet tokens.
127
- - **No held fee manipulation.** The deployer has no function to process or return held fees arbitrarily.
128
- - **Owner minting is constrained.** While `allowOwnerMinting = true` is set in ruleset metadata, the "owner" is the `REVDeployer` contract. It only uses this to mint auto-issuance tokens (amounts fixed at deployment) and to return loan collateral.
129
-
130
- ## Loan Administration
131
-
132
- The `REVLoans` contract has minimal admin surface by design:
133
-
134
- - **All economic parameters are constants.** Loan liquidation duration (10 years), fee percentages (MIN 2.5%, MAX 50%), and the REV fee (1%) are hardcoded as immutable constants. No admin can change them.
135
- - **The only admin function is `setTokenUriResolver()`**, which controls how loan NFTs render their metadata. This is purely cosmetic and has no effect on loan economics, collateral, or fund flows.
136
- - **Loan management is permissioned to NFT holders or delegated operators.** Repayment requires loan NFT ownership or `REPAY_LOAN` permission. Collateral reallocation requires loan NFT ownership or `REALLOCATE_LOAN` permission. Borrowing on behalf of another holder requires `OPEN_LOAN` permission. In all delegated cases, collateral and loan NFTs flow to the original holder/owner, not the operator.
137
- - **Liquidation is permissionless.** Anyone can call `liquidateExpiredLoansFrom()` for loans past the 10-year duration.
138
-
139
- ## Hidden Tokens Administration
140
-
141
- The `REVHiddenTokens` contract inherits `JBPermissioned` for operator delegation but has no admin surface:
142
-
143
- - **Operations are holder-initiated or operator-delegated.** Any token holder can hide or reveal their own tokens. An operator with `HIDE_TOKENS` permission can hide tokens on behalf of a holder; an operator with `REVEAL_TOKENS` permission can reveal on their behalf.
144
- - **No owner or admin role.** The contract has no `Ownable` or privileged functions.
145
- - **Mint permission is granted via REVOwner.** `REVHiddenTokens` is listed in `REVOwner.hasMintPermissionFor` so it can re-mint tokens on reveal. This is a global immutable set at REVOwner deployment.
146
- - **BURN_TOKENS permission is per-user.** Each user must individually grant `BURN_TOKENS` permission to the `REVHiddenTokens` contract before hiding tokens.
147
-
148
- ## Immutable Configuration
149
-
150
- The following parameters are set at deployment and can never be changed:
151
-
152
- ### REVDeployer (per-revnet, set at `deployFor` time)
153
- - Stage schedule (start times, issuance rates, cut frequencies, cut percentages)
154
- - Cash-out tax rates per stage
155
- - Split percentages per stage
156
- - Auto-issuance amounts and beneficiaries
157
- - Base currency
158
- - ERC-20 token name and symbol
159
- - Encoded configuration hash (used for cross-chain sucker deployment verification)
160
-
161
- ### REVDeployer (global, set at contract deployment)
162
- - `CONTROLLER` -- the Juicebox controller
163
- - `DIRECTORY` -- the Juicebox directory
164
- - `PROJECTS` -- the Juicebox projects NFT contract
165
- - `PERMISSIONS` -- the Juicebox permissions contract
166
- - `SUCKER_REGISTRY` -- the sucker registry
167
- - `BUYBACK_HOOK` -- the buyback hook / data hook
168
- - `HOOK_DEPLOYER` -- the 721 tiers hook deployer
169
- - `PUBLISHER` -- the croptop publisher
170
- - `LOANS` -- the loans contract address
171
- - `FEE_REVNET_ID` -- the project ID that receives cash-out fees
172
- - `FEE` -- the cash-out fee (2.5%)
173
- - `CASH_OUT_DELAY` -- 30 days for cross-chain deployments
174
- - `DEFAULT_BUYBACK_POOL_FEE` -- 10,000 (1% Uniswap V4 fee tier)
175
- - `DEFAULT_BUYBACK_TICK_SPACING` -- 200
176
- - `DEFAULT_BUYBACK_TWAP_WINDOW` -- 2 days
177
- - `OWNER()` -- view returning the REVOwner address
178
-
179
- ### REVOwner (global, set at contract deployment)
180
- - `BUYBACK_HOOK` -- the buyback hook (shared immutable with REVDeployer)
181
- - `DIRECTORY` -- the Juicebox directory (shared immutable with REVDeployer)
182
- - `FEE_REVNET_ID` -- the project ID that receives cash-out fees (shared immutable)
183
- - `HIDDEN_TOKENS` -- the hidden tokens contract address (shared immutable)
184
- - `SUCKER_REGISTRY` -- the sucker registry (shared immutable)
185
- - `LOANS` -- the loans contract address (shared immutable)
186
- - `FEE` -- the cash-out fee constant (2.5%)
187
- - `DEPLOYER` -- the REVDeployer address (storage variable, set once by the REVOwner initializer account using the precomputed canonical deployer address)
188
-
189
- ### REVLoans (global, set at contract deployment)
190
- - `CONTROLLER`, `DIRECTORY`, `PRICES`, `PROJECTS` -- protocol infrastructure
191
- - `REV_ID` -- the REV revnet that receives loan fees
192
- - `PERMIT2` -- the permit2 contract
193
- - `LOAN_LIQUIDATION_DURATION` -- 10 years (3650 days)
194
- - `MIN_PREPAID_FEE_PERCENT` -- 2.5% (`25` out of `MAX_FEE = 1000`)
195
- - `MAX_PREPAID_FEE_PERCENT` -- 50% (`500` out of `MAX_FEE = 1000`)
196
- - `REV_PREPAID_FEE_PERCENT` -- 1% (`10` out of `MAX_FEE = 1000`)
64
+ - If launch-time economics are wrong, recovery usually means replacement, not in-place repair.
65
+ - If optional integrations are misconfigured, fix only where the code still exposes a valid path.
66
+ - If the design intentionally omitted a recovery path, do not invent one in documentation or ops guidance.
197
67
 
198
68
  ## Admin Boundaries
199
69
 
200
- What admins **cannot** do -- this is the most important section for understanding revnet security guarantees:
201
-
202
- ### The Split Operator Cannot:
203
- - Change issuance rates, schedules, or weight decay
204
- - Modify cash-out tax rates
205
- - Queue new rulesets or stages
206
- - Pause or disable cash outs
207
- - Mint fungible revnet tokens (only 721 minting if explicitly enabled at deploy)
208
- - Access or redirect treasury funds (no payout limit control)
209
- - Upgrade or migrate the revnet's controller
210
- - Change the revnet's terminals
211
- - Transfer the project NFT
212
- - Modify fund access limits or surplus allowances
213
- - Change the data hook or approval hook
214
- - Affect loan parameters or collateral
215
-
216
- ### The REVLoans Owner Cannot:
217
- - Change loan interest rates, fees, or liquidation timing
218
- - Access or redirect collateral or borrowed funds
219
- - Prevent loan creation, repayment, or liquidation
220
- - Mint or burn tokens
221
- - Affect any revnet's configuration
222
-
223
- ### The REVDeployer Contract Cannot (even though it holds the project NFT):
224
- - Queue new rulesets (no public or internal function exists for this)
225
- - Transfer the project NFT to any other address
226
- - Change terminals or the controller
227
- - Modify fund access limits after deployment
228
- - Override the data hook logic
229
- - Selectively block cash outs (beyond the time-limited `CASH_OUT_DELAY` for cross-chain deployments)
230
-
231
- ### Nobody Can:
232
- - Change a revnet's stage schedule after deployment
233
- - Prevent token holders from eventually cashing out
234
- - Extract funds from the treasury without going through the bonding curve
235
- - Modify the fee structure (2.5% cash-out fee, loan fees)
236
- - Change which contract is the data hook for a revnet (always REVOwner)
237
- - Alter auto-issuance amounts after deployment (they can only be claimed, not changed)
70
+ - No ordinary owner can casually rewrite staged economics after launch.
71
+ - Split operators are not general-purpose governors.
72
+ - Loan mechanics, hidden-token mechanics, and cash-out policy remain bounded by the deployed revnet logic.
73
+ - This repo should not be documented as if it had a normal mutable project-owner model.
package/ARCHITECTURE.md CHANGED
@@ -2,39 +2,51 @@
2
2
 
3
3
  ## Purpose
4
4
 
5
- `revnet-core-v6` defines an autonomous Juicebox project pattern with staged, precommitted economics and token-collateralized loans. A revnet is intentionally ownerless after deployment: project behavior follows its queued stages and integrated hooks rather than ongoing governance.
5
+ `revnet-core-v6` defines an autonomous Juicebox project pattern with staged, precommitted economics and token-collateralized loans. A revnet is intentionally ownerless after deployment in the human sense: behavior follows staged configuration and constrained runtime hooks instead of ongoing governance.
6
6
 
7
- ## Boundaries
7
+ ## System Overview
8
8
 
9
- - `REVDeployer` owns launch-time configuration and runtime wrapper behavior.
10
- - `REVOwner` owns owner-like data-hook behavior for revnet projects.
11
- - `REVLoans` owns the loan lifecycle.
12
- - `REVHiddenTokens` owns temporary token hiding and supply exclusion.
13
- - The repo composes several sibling repos instead of reimplementing them.
9
+ `REVDeployer` handles launch-time shape, staged rulesets, hook wiring, and runtime wrapper behavior. `REVOwner` provides the owner-like runtime policy surface for pay and cash-out hooks after launch. `REVLoans` manages burn-collateral loan positions represented as NFTs. `REVHiddenTokens` lets holders burn tokens to exclude them from visible supply until they reveal them again.
14
10
 
15
- ## Main Components
11
+ ## Core Invariants
16
12
 
17
- | Component | Responsibility |
18
- | --- | --- |
19
- | `REVDeployer` | Launches revnets, queues staged rulesets, wires hooks, grants operator permissions, and exposes runtime wrapper behavior |
20
- | `REVOwner` | Ownerless policy surface plugged into revnet rulesets |
21
- | `REVLoans` | Burn-collateral borrow/repay/liquidate flow represented as ERC-721 loans |
22
- | `REVHiddenTokens` | Temporary token hiding: burn to exclude from totalSupply, re-mint on reveal |
23
- | config structs | Stage, auto-issuance, loan source, and 721-hook configuration surfaces |
13
+ - Revnets are intended to be ownerless after deployment; easy admin recovery paths would violate the product model.
14
+ - Stage configuration is effectively permanent once queued.
15
+ - Loan collateral is burned, not escrowed.
16
+ - Hidden tokens are burned, not escrowed, and reduce visible supply until revealed.
17
+ - `REVOwner` and `REVDeployer` are tightly coupled; their setup order matters.
18
+ - Cash-out delay affects both exits and borrowing power.
19
+ - Cross-chain supply and surplus are part of revnet economics. Local payouts and loans must not ignore remote sucker snapshots.
20
+
21
+ ## Modules
22
+
23
+ | Module | Responsibility | Notes |
24
+ | --- | --- | --- |
25
+ | `REVDeployer` | Launch, staged rulesets, hook wiring, permissions, runtime wrapper behavior | Launch-time and runtime wrapper |
26
+ | `REVOwner` | Runtime owner-like policy surface | Hook-facing policy |
27
+ | `REVLoans` | Borrow, repay, and liquidate burned-collateral loan positions | Economic core |
28
+ | `REVHiddenTokens` | Temporary supply exclusion through burn and reveal | Supply-sensitive utility |
29
+ | config structs | Stage, loan-source, auto-issuance, and hook config | Launch-time inputs |
30
+
31
+ ## Trust Boundaries
24
32
 
25
- ## Runtime Model
33
+ - Treasury and ruleset mechanics remain rooted in `nana-core-v6`.
34
+ - Optional integrations come from `nana-buyback-hook-v6`, `nana-router-terminal-v6`, `nana-suckers-v6`, and `nana-721-hook-v6`.
35
+ - This repo composes those systems into an ownerless product shape instead of reimplementing them.
36
+
37
+ ## Critical Flows
26
38
 
27
39
  ### Revnet Lifecycle
28
40
 
29
41
  ```text
30
42
  creator
31
- -> deploys a revnet with a fixed sequence of stages
43
+ -> deploys a revnet with a fixed stage sequence
32
44
  stage transitions
33
- -> happen automatically over time through ruleset activation
45
+ -> activate automatically over time through rulesets
34
46
  participants
35
- -> pay in, receive tokens, cash out, and interact with downstream hooks
47
+ -> pay in, receive tokens, cash out, and interact with enabled integrations
36
48
  operators or permissionless callers
37
- -> perform bounded maintenance actions such as auto-issuance claims
49
+ -> perform bounded maintenance such as auto-issuance claims
38
50
  ```
39
51
 
40
52
  ### Loan Lifecycle
@@ -42,35 +54,49 @@ operators or permissionless callers
42
54
  ```text
43
55
  borrower
44
56
  -> burns revnet tokens as collateral
45
- -> receives funds from the treasury through REVLoans
57
+ -> borrowability is computed from the current stage, omnichain supply/surplus, and local liquidity caps
58
+ -> receives treasury-backed funds through REVLoans
46
59
  -> later repays to remint collateral
47
- -> or gets liquidated after the long expiration window
60
+ -> or is liquidated after the expiration window
48
61
  ```
49
62
 
50
- ## Critical Invariants
51
-
52
- - The project is designed to be ownerless after deployment. "Easy" admin recovery paths would break the product thesis.
53
- - Stage configuration is effectively permanent once queued.
54
- - Loan collateral is burned, not escrowed. Supply-sensitive logic must treat that as real destruction until repayment.
55
- - Hidden tokens are burned, not escrowed. They reduce totalSupply until revealed. This interacts with bonding curve valuations.
56
- - `REVOwner` and `REVDeployer` are tightly coupled. Their setup order is part of correctness.
63
+ ## Accounting Model
57
64
 
58
- ## Where Complexity Lives
65
+ The repo does not replace core treasury accounting. Its critical economic logic is the interaction between staged revnet config, burned-collateral loan state, hidden-token supply exclusion, and omnichain revnet state imported from suckers.
59
66
 
60
- - Revnets span deployment-time guarantees, runtime hook behavior, and loan-state transitions.
61
- - The most subtle risks sit where treasury state, stage economics, and loan borrowability interact.
62
- - Ownerlessness is a feature, but it also removes easy operational recovery from misconfiguration.
67
+ `REVOwner` also composes payment and cash-out hooks. On pay, it can merge 721-tier split forwarding with buyback-hook behavior and scale mint weight so the terminal only mints against the share that actually enters the project. On cash out, it can use omnichain supply and surplus for reclaim math, exempt trusted suckers, and append fee-hook specs.
63
68
 
64
- ## Dependencies
69
+ ## Security Model
65
70
 
66
- - `nana-core-v6` for treasury and ruleset mechanics
67
- - `nana-buyback-hook-v6`, `nana-suckers-v6`, `nana-router-terminal-v6`, and optionally `nana-721-hook-v6` for composed features
68
- - `croptop-core-v6` and other product repos when revnets are used as economic backends
71
+ - The highest-risk interactions sit where stage economics, treasury state, and loan borrowability meet.
72
+ - Ownerlessness removes convenient recovery from misconfiguration.
73
+ - Hidden-token and burned-collateral semantics materially affect supply-sensitive pricing.
74
+ - `REVOwner` is a live runtime policy surface, not just a launch helper.
75
+ - Rev cash-out fees stack on top of protocol-fee behavior rather than replacing it.
69
76
 
70
77
  ## Safe Change Guide
71
78
 
72
- - Treat deployer-time behavior and runtime wrapper behavior as one system.
73
- - Any change to stage semantics should be checked against loan math, cash-out semantics, and downstream fee-project expectations.
79
+ - Review deploy-time behavior and runtime wrapper behavior together.
80
+ - If stage semantics change, inspect loan math, cash-out behavior, and downstream fee expectations together.
74
81
  - Do not casually add mutable admin escape hatches.
75
- - Flash-loan and surplus-sensitive logic deserves adversarial review whenever loan calculations change.
76
- - If a change affects borrowability or repayment, test both sourced and unsourced loan paths.
82
+ - If you change borrowability, re-check cash-out-delay gating, omnichain surplus inputs, and local-surplus caps together.
83
+ - If you change hook composition, re-check 721 split handling, buyback assumptions, and mint-permission flows.
84
+
85
+ ## Canonical Checks
86
+
87
+ - cash-out-delay interaction with loans:
88
+ `test/TestLoansCashOutDelay.t.sol`
89
+ - stage transitions and borrowability drift:
90
+ `test/TestStageTransitionBorrowable.t.sol`
91
+ - omnichain or phantom-surplus edge cases:
92
+ `test/audit/CodexPhantomSurplusTerminal.t.sol`
93
+
94
+ ## Source Map
95
+
96
+ - `src/REVDeployer.sol`
97
+ - `src/REVOwner.sol`
98
+ - `src/REVLoans.sol`
99
+ - `src/REVHiddenTokens.sol`
100
+ - `test/TestLoansCashOutDelay.t.sol`
101
+ - `test/TestStageTransitionBorrowable.t.sol`
102
+ - `test/audit/CodexPhantomSurplusTerminal.t.sol`