@rev-net/core-v6 0.0.37 → 0.0.40
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/CHANGELOG.md +2 -2
- package/README.md +6 -7
- package/foundry.toml +1 -1
- package/package.json +23 -16
- package/references/operations.md +1 -1
- package/references/runtime.md +1 -1
- package/script/Deploy.s.sol +12 -9
- package/src/REVDeployer.sol +69 -67
- package/src/REVHiddenTokens.sol +2 -2
- package/src/REVLoans.sol +26 -22
- package/src/REVOwner.sol +147 -29
- package/src/interfaces/IREVDeployer.sol +2 -1
- package/src/interfaces/IREVHiddenTokens.sol +4 -1
- package/src/interfaces/IREVOwner.sol +5 -0
- package/src/structs/REVAutoIssuance.sol +4 -2
- package/src/structs/REVConfig.sol +8 -5
- package/src/structs/REVDescription.sol +6 -5
- package/src/structs/REVLoan.sol +8 -5
- package/src/structs/REVStageConfig.sol +14 -16
- package/ADMINISTRATION.md +0 -73
- package/ARCHITECTURE.md +0 -116
- package/AUDIT_INSTRUCTIONS.md +0 -90
- package/RISKS.md +0 -107
- package/SKILLS.md +0 -46
- package/STYLE_GUIDE.md +0 -610
- package/USER_JOURNEYS.md +0 -195
- package/foundry.lock +0 -11
- package/slither-ci.config.json +0 -10
- package/sphinx.lock +0 -507
- package/test/REV.integrations.t.sol +0 -573
- package/test/REVAutoIssuanceFuzz.t.sol +0 -328
- package/test/REVDeployerRegressions.t.sol +0 -396
- package/test/REVInvincibility.t.sol +0 -1371
- package/test/REVInvincibilityHandler.sol +0 -387
- package/test/REVLifecycle.t.sol +0 -420
- package/test/REVLoans.invariants.t.sol +0 -724
- package/test/REVLoansAttacks.t.sol +0 -816
- package/test/REVLoansFeeRecovery.t.sol +0 -783
- package/test/REVLoansFindings.t.sol +0 -711
- package/test/REVLoansRegressions.t.sol +0 -364
- package/test/REVLoansSourceFeeRecovery.t.sol +0 -517
- package/test/REVLoansSourced.t.sol +0 -1839
- package/test/REVLoansUnSourced.t.sol +0 -409
- package/test/TestAuditFixVerification.t.sol +0 -675
- package/test/TestBurnHeldTokens.t.sol +0 -394
- package/test/TestCEIPattern.t.sol +0 -508
- package/test/TestCashOutCallerValidation.t.sol +0 -452
- package/test/TestConversionDocumentation.t.sol +0 -365
- package/test/TestCrossCurrencyReclaim.t.sol +0 -610
- package/test/TestCrossSourceReallocation.t.sol +0 -361
- package/test/TestERC2771MetaTx.t.sol +0 -585
- package/test/TestEmptyBuybackSpecs.t.sol +0 -300
- package/test/TestFlashLoanSurplus.t.sol +0 -365
- package/test/TestHiddenTokens.t.sol +0 -474
- package/test/TestHookArrayOOB.t.sol +0 -278
- package/test/TestLiquidationBehavior.t.sol +0 -398
- package/test/TestLoanSourceRotation.t.sol +0 -553
- package/test/TestLoansCashOutDelay.t.sol +0 -493
- package/test/TestLongTailEconomics.t.sol +0 -677
- package/test/TestLowFindings.t.sol +0 -677
- package/test/TestMixedFixes.t.sol +0 -593
- package/test/TestPermit2Signatures.t.sol +0 -683
- package/test/TestReallocationSandwich.t.sol +0 -412
- package/test/TestRevnetRegressions.t.sol +0 -350
- package/test/TestSplitWeightAdjustment.t.sol +0 -527
- package/test/TestSplitWeightE2E.t.sol +0 -605
- package/test/TestSplitWeightFork.t.sol +0 -855
- package/test/TestStageTransitionBorrowable.t.sol +0 -301
- package/test/TestSwapTerminalPermission.t.sol +0 -262
- package/test/TestTerminalEncodingInHash.t.sol +0 -326
- package/test/TestUint112Overflow.t.sol +0 -311
- package/test/TestZeroAmountLoanGuard.t.sol +0 -378
- package/test/TestZeroRepayment.t.sol +0 -354
- package/test/audit/CrossChainBuybackRouteMismatch.t.sol +0 -184
- package/test/audit/HiddenSupplyCashout.t.sol +0 -61
- package/test/audit/LoanIdOverflowGuard.t.sol +0 -523
- package/test/audit/NemesisVerification.t.sol +0 -97
- package/test/audit/OperatorDelegation.t.sol +0 -356
- package/test/audit/PhantomSurplusTerminal.t.sol +0 -367
- package/test/audit/REVOwnerCurrencyMismatch.t.sol +0 -188
- package/test/audit/REVOwnerRemoteSurplusCurrencyMismatch.t.sol +0 -140
- package/test/audit/ReallocatePermission.t.sol +0 -363
- package/test/audit/RemoteLoanAccountingGap.t.sol +0 -74
- package/test/audit/SupportsInterfaceTest.t.sol +0 -51
- package/test/audit/TestFeeAllowanceLeak.t.sol +0 -197
- package/test/audit/TestLoansAndDeployerFixes.t.sol +0 -576
- package/test/fork/ForkTestBase.sol +0 -727
- package/test/fork/TestAutoIssuanceFork.t.sol +0 -148
- package/test/fork/TestCashOutFork.t.sol +0 -253
- package/test/fork/TestIssuanceDecayFork.t.sol +0 -158
- package/test/fork/TestLoanAdversarialFork.t.sol +0 -744
- package/test/fork/TestLoanBorrowFork.t.sol +0 -163
- package/test/fork/TestLoanCrossRulesetFork.t.sol +0 -308
- package/test/fork/TestLoanERC20Fork.t.sol +0 -459
- package/test/fork/TestLoanLiquidationFork.t.sol +0 -135
- package/test/fork/TestLoanReallocateFork.t.sol +0 -113
- package/test/fork/TestLoanRepayFork.t.sol +0 -188
- package/test/fork/TestLoanTransferFork.t.sol +0 -143
- package/test/fork/TestPermit2PaymentFork.t.sol +0 -300
- package/test/fork/TestSplitWeightFork.t.sol +0 -189
- package/test/helpers/MaliciousContracts.sol +0 -247
- package/test/helpers/REVEmpty721Config.sol +0 -45
- package/test/mock/MockBuybackCashOutRecorder.sol +0 -84
- package/test/mock/MockBuybackDataHook.sol +0 -112
- package/test/mock/MockBuybackDataHookMintPath.sol +0 -68
- package/test/mock/MockSuckerRegistry.sol +0 -17
- package/test/regression/TestBurnPermissionRequired.t.sol +0 -294
- package/test/regression/TestCashOutBuybackFeeLeak.t.sol +0 -232
- package/test/regression/TestCrossRevnetLiquidation.t.sol +0 -255
- package/test/regression/TestCumulativeLoanCounter.t.sol +0 -361
- package/test/regression/TestLiquidateGapHandling.t.sol +0 -394
- package/test/regression/TestZeroPriceFeed.t.sol +0 -422
package/ARCHITECTURE.md
DELETED
|
@@ -1,116 +0,0 @@
|
|
|
1
|
-
# Architecture
|
|
2
|
-
|
|
3
|
-
## Purpose
|
|
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 in the human sense: behavior follows staged configuration and constrained runtime hooks instead of ongoing governance.
|
|
6
|
-
|
|
7
|
-
## System Overview
|
|
8
|
-
|
|
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.
|
|
10
|
-
|
|
11
|
-
## Core Invariants
|
|
12
|
-
|
|
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
|
|
32
|
-
|
|
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
|
|
38
|
-
|
|
39
|
-
### Revnet Lifecycle
|
|
40
|
-
|
|
41
|
-
```text
|
|
42
|
-
creator
|
|
43
|
-
-> deploys a revnet with a fixed stage sequence
|
|
44
|
-
stage transitions
|
|
45
|
-
-> activate automatically over time through rulesets
|
|
46
|
-
participants
|
|
47
|
-
-> pay in, receive tokens, cash out, and interact with enabled integrations
|
|
48
|
-
operators or permissionless callers
|
|
49
|
-
-> perform bounded maintenance such as auto-issuance claims
|
|
50
|
-
```
|
|
51
|
-
|
|
52
|
-
### Loan Lifecycle
|
|
53
|
-
|
|
54
|
-
```text
|
|
55
|
-
borrower
|
|
56
|
-
-> burns revnet tokens as collateral
|
|
57
|
-
-> borrowability is computed from the current stage, omnichain supply/surplus, and local liquidity caps
|
|
58
|
-
-> receives treasury-backed funds through REVLoans
|
|
59
|
-
-> later repays to remint collateral
|
|
60
|
-
-> or is liquidated after the expiration window
|
|
61
|
-
```
|
|
62
|
-
|
|
63
|
-
## Accounting Model
|
|
64
|
-
|
|
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.
|
|
66
|
-
|
|
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.
|
|
68
|
-
|
|
69
|
-
## Security Model
|
|
70
|
-
|
|
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.
|
|
76
|
-
|
|
77
|
-
## Safe Change Guide
|
|
78
|
-
|
|
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.
|
|
81
|
-
- Do not casually add mutable admin escape hatches.
|
|
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
|
-
## Cross-Chain Configuration Hash
|
|
86
|
-
|
|
87
|
-
`REVDeployer` produces an `encodedConfigurationHash` for each revnet that determines sucker deployment salts. This hash commits the revnet's identity across chains. It includes:
|
|
88
|
-
|
|
89
|
-
- `baseCurrency`, `description.name`, `description.ticker`, `description.salt`
|
|
90
|
-
- Terminal addresses (order-sensitive)
|
|
91
|
-
- Stage parameters (timing, issuance, splits, tax rates, auto-issuances)
|
|
92
|
-
|
|
93
|
-
Terminal addresses are included because they are deployed deterministically at the same address across chains. Accounting contexts (token addresses) are excluded because tokens like USDC legitimately differ per chain.
|
|
94
|
-
|
|
95
|
-
This means a revnet can only expand to a new chain if it uses the exact same terminal contract it used on the host chain. Different terminal addresses produce a different hash, preventing accidental cross-chain mismatches in sucker deployments.
|
|
96
|
-
|
|
97
|
-
## Canonical Checks
|
|
98
|
-
|
|
99
|
-
- cash-out-delay interaction with loans:
|
|
100
|
-
`test/TestLoansCashOutDelay.t.sol`
|
|
101
|
-
- stage transitions and borrowability drift:
|
|
102
|
-
`test/TestStageTransitionBorrowable.t.sol`
|
|
103
|
-
- omnichain or phantom-surplus edge cases:
|
|
104
|
-
`test/audit/CodexPhantomSurplusTerminal.t.sol`
|
|
105
|
-
- terminal encoding in configuration hash:
|
|
106
|
-
`test/TestTerminalEncodingInHash.t.sol`
|
|
107
|
-
|
|
108
|
-
## Source Map
|
|
109
|
-
|
|
110
|
-
- `src/REVDeployer.sol`
|
|
111
|
-
- `src/REVOwner.sol`
|
|
112
|
-
- `src/REVLoans.sol`
|
|
113
|
-
- `src/REVHiddenTokens.sol`
|
|
114
|
-
- `test/TestLoansCashOutDelay.t.sol`
|
|
115
|
-
- `test/TestStageTransitionBorrowable.t.sol`
|
|
116
|
-
- `test/audit/CodexPhantomSurplusTerminal.t.sol`
|
package/AUDIT_INSTRUCTIONS.md
DELETED
|
@@ -1,90 +0,0 @@
|
|
|
1
|
-
# Audit Instructions
|
|
2
|
-
|
|
3
|
-
Revnet is a staged, owner-minimized product layer on top of Juicebox core. Audit it as an economic system, not just a deployer plus a loan contract.
|
|
4
|
-
|
|
5
|
-
## Audit Objective
|
|
6
|
-
|
|
7
|
-
Find issues that:
|
|
8
|
-
|
|
9
|
-
- break stage progression or let users act under the wrong stage assumptions
|
|
10
|
-
- overstate or understate borrowability
|
|
11
|
-
- mis-handle hidden tokens or burned-collateral accounting
|
|
12
|
-
- give operators or integrations more power than the revnet model intends
|
|
13
|
-
- make omnichain supply, surplus, or sucker assumptions drift from runtime behavior
|
|
14
|
-
|
|
15
|
-
## Scope
|
|
16
|
-
|
|
17
|
-
In scope:
|
|
18
|
-
|
|
19
|
-
- `src/REVDeployer.sol`
|
|
20
|
-
- `src/REVOwner.sol`
|
|
21
|
-
- `src/REVLoans.sol`
|
|
22
|
-
- `src/REVHiddenTokens.sol`
|
|
23
|
-
- structs, interfaces, and deployment helpers
|
|
24
|
-
|
|
25
|
-
## Start Here
|
|
26
|
-
|
|
27
|
-
1. `src/REVDeployer.sol`
|
|
28
|
-
2. `src/REVOwner.sol`
|
|
29
|
-
3. `src/REVLoans.sol`
|
|
30
|
-
4. `src/REVHiddenTokens.sol`
|
|
31
|
-
|
|
32
|
-
## Security Model
|
|
33
|
-
|
|
34
|
-
Revnet composes several sensitive systems:
|
|
35
|
-
|
|
36
|
-
- staged rulesets and launch-time immutability
|
|
37
|
-
- runtime pay and cash-out policy in `REVOwner`
|
|
38
|
-
- burned-collateral lending in `REVLoans`
|
|
39
|
-
- hidden-token supply exclusion in `REVHiddenTokens`
|
|
40
|
-
|
|
41
|
-
The main audit mindset is composition:
|
|
42
|
-
|
|
43
|
-
- stage economics affect borrowability
|
|
44
|
-
- hidden supply affects cash-out math
|
|
45
|
-
- omnichain state can affect reclaim and borrowing power
|
|
46
|
-
- optional integrations can widen the effective trust surface
|
|
47
|
-
|
|
48
|
-
## Roles And Privileges
|
|
49
|
-
|
|
50
|
-
| Role | Powers | How constrained |
|
|
51
|
-
|------|--------|-----------------|
|
|
52
|
-
| Revnet deployer path | Define long-lived stage and operator shape | Must not retain unexpected mutable governance |
|
|
53
|
-
| Split operator | Use the allowed runtime envelope | Must stay within deployment-defined permissions |
|
|
54
|
-
| Borrower or delegated operator | Open or manage loans | Must not escape collateral, delay, or source limits |
|
|
55
|
-
| Hidden-token user or delegate | Burn and reveal visible supply | Must not create extra supply or break accounting |
|
|
56
|
-
|
|
57
|
-
## Integration Assumptions
|
|
58
|
-
|
|
59
|
-
| Dependency | Assumption | What breaks if wrong |
|
|
60
|
-
|------------|------------|----------------------|
|
|
61
|
-
| `nana-core-v6` | Rulesets, reclaim math, and surplus views stay coherent | Stage and cash-out behavior drift |
|
|
62
|
-
| `nana-suckers-v6` | Remote supply/surplus snapshots are authentic | Omnichain reclaim and borrowability drift |
|
|
63
|
-
| Buyback and 721 integrations | Hook composition remains consistent with revnet expectations | Pay-path and mint-permission behavior drift |
|
|
64
|
-
|
|
65
|
-
## Critical Invariants
|
|
66
|
-
|
|
67
|
-
1. Stage progression stays monotonic and follows deployed timing.
|
|
68
|
-
2. Borrowability respects cash-out delay, surplus, supply, and source limits.
|
|
69
|
-
3. Burned collateral is not accidentally treated like escrowed collateral.
|
|
70
|
-
4. Hidden-token accounting preserves total claims while changing visible supply intentionally.
|
|
71
|
-
5. Optional integrations do not silently widen revnet authority or mint rights.
|
|
72
|
-
|
|
73
|
-
## Attack Surfaces
|
|
74
|
-
|
|
75
|
-
- stage-transition boundaries
|
|
76
|
-
- live borrowability and cross-currency debt aggregation
|
|
77
|
-
- hidden-token burn and reveal flows
|
|
78
|
-
- omnichain surplus and sucker exemptions
|
|
79
|
-
- payment and cash-out hook composition in `REVOwner`
|
|
80
|
-
|
|
81
|
-
## Accepted Risks Or Behaviors
|
|
82
|
-
|
|
83
|
-
- Revnets intentionally trade recoverability for predictable launch-time economics.
|
|
84
|
-
- Some economic surfaces are conservative by design and may refuse otherwise-valid actions rather than risk an unsafe result.
|
|
85
|
-
|
|
86
|
-
## Verification
|
|
87
|
-
|
|
88
|
-
- `npm install`
|
|
89
|
-
- `forge build`
|
|
90
|
-
- `forge test`
|
package/RISKS.md
DELETED
|
@@ -1,107 +0,0 @@
|
|
|
1
|
-
# Revnet Core Risk Register
|
|
2
|
-
|
|
3
|
-
This file focuses on the staged-economics, runtime-hook, hidden-supply, and loan risks that matter in Revnets. The main question is whether the deployed economic shape still holds under real runtime behavior.
|
|
4
|
-
|
|
5
|
-
## How to use this file
|
|
6
|
-
|
|
7
|
-
- Read `Priority risks` first.
|
|
8
|
-
- Use the detailed sections to separate stage design, hook composition, hidden supply, and loan accounting.
|
|
9
|
-
- Treat `Accepted Behaviors` and `Invariants to Verify` as the line between intended product tradeoffs and defects.
|
|
10
|
-
|
|
11
|
-
## Priority risks
|
|
12
|
-
|
|
13
|
-
| Priority | Risk | Why it matters | Primary controls |
|
|
14
|
-
|----------|------|----------------|------------------|
|
|
15
|
-
| P0 | Borrowability drift from live surplus or cross-chain state | Loans can overextend or under-credit if revnet state is read incorrectly. | Borrowability tests, omnichain-state checks, and cash-out-delay gating. |
|
|
16
|
-
| P1 | Stage configuration mistakes | Revnet economics are hard to change after launch, so bad stages are expensive. | Deployment review, stage-transition tests, and launch-time validation. |
|
|
17
|
-
| P1 | Hidden-supply and burned-collateral misunderstandings | Hidden tokens and loans both change visible supply in non-obvious ways. | Explicit supply invariants and product-level review. |
|
|
18
|
-
|
|
19
|
-
## 1. Trust Assumptions
|
|
20
|
-
|
|
21
|
-
- **`REVDeployer` and `REVOwner` are one design.** Misreading them independently is a review hazard.
|
|
22
|
-
- **Core protocol state is still upstream truth.** Revnet economics sit on top of `nana-core-v6`, not outside it.
|
|
23
|
-
- **Optional integrations matter.** Buybacks, 721 hooks, and suckers can materially change runtime behavior.
|
|
24
|
-
- **Price feeds and source accounting matter for loans.** Cross-currency debt aggregation depends on working feed assumptions.
|
|
25
|
-
|
|
26
|
-
## 2. Economic Risks
|
|
27
|
-
|
|
28
|
-
- **Stage immutability cuts both ways.** A bad stage schedule or bad cash-out tax choice is expensive to unwind.
|
|
29
|
-
- **Borrowability depends on live economics.** If surplus, supply, or cross-chain state are wrong, loan capacity becomes wrong.
|
|
30
|
-
- **Zero or degraded price feeds can undercount debt.** If a source becomes invisible to debt aggregation, later borrowing can become too permissive. Specifically, `_debtOf` skips sources where `pricePerUnitOf` returns zero, treating them as if the borrower has no debt in that source. If a feed breaks or returns zero, existing debt in that currency is effectively invisible, inflating the borrower's apparent borrowable amount.
|
|
31
|
-
- **Hidden-token mechanics change visible supply.** That affects per-token cash-out value and can change the economics seen by other holders.
|
|
32
|
-
- **Auto-issuance dilutes holders predictably but still materially.** Timing is permissionless, even if the amounts are fixed at deployment.
|
|
33
|
-
- **Omnichain expansion can corrupt surplus aggregation.** Since borrowability aggregates surplus from all registered terminals across chains, a compromised or misconfigured terminal on a remote chain affects global surplus accounting.
|
|
34
|
-
|
|
35
|
-
## 3. Loan Risks
|
|
36
|
-
|
|
37
|
-
- **Burned collateral is not escrow.** Reviewers and integrators who model it as escrow will misread liquidation and repayment behavior.
|
|
38
|
-
- **No short-term liquidation model.** Under-collateralized loans can persist until the long expiry model allows cleanup.
|
|
39
|
-
- **Loan sources grow over time.** Debt aggregation cost and complexity increase as new source pairs are used.
|
|
40
|
-
- **Reallocation still depends on live state.** Reallocate flows can change outcomes around stage boundaries.
|
|
41
|
-
|
|
42
|
-
## 4. Hidden-Token Risks
|
|
43
|
-
|
|
44
|
-
- **Visible-supply manipulation is intentional.** Hiding tokens changes visible supply and therefore changes redemption economics.
|
|
45
|
-
- **Hidden tokens are not usable collateral while hidden.** They must be revealed before borrowing.
|
|
46
|
-
- **Reveal is restoration, not fresh issuance.** It intentionally bypasses reserved-percent behavior.
|
|
47
|
-
|
|
48
|
-
## 5. Hook-Composition Risks
|
|
49
|
-
|
|
50
|
-
- **`REVOwner` is a real runtime authority surface.** It composes pay hooks, cash-out hooks, sucker exemptions, and fee logic.
|
|
51
|
-
- **Suckers can bypass tax and fee paths by design.** That privilege is safe only if registry and deployer assumptions are correct.
|
|
52
|
-
- **Mint-permission surfaces are broad enough to matter.** Loans, hidden tokens, buyback flows, and suckers all touch mint authority in some deployments.
|
|
53
|
-
|
|
54
|
-
## 6. Access-Control Risks
|
|
55
|
-
|
|
56
|
-
- **The deployer-held project NFT can be misunderstood.** Revnets are owner-minimized, but the deployer path still matters for the trust model.
|
|
57
|
-
- **Split operator mistakes are high-impact.** Narrow powers like price-feed installation, split updates, sucker deployment, or router setup still matter.
|
|
58
|
-
- **There is intentionally no broad admin recovery path.** Operational teams may try to reach for powers the design never intended to leave available.
|
|
59
|
-
|
|
60
|
-
## 7. Invariants to Verify
|
|
61
|
-
|
|
62
|
-
- Collateral and debt conservation across all active loans.
|
|
63
|
-
- Stage immutability after deployment.
|
|
64
|
-
- Borrowability dropping to zero when cash-out delay should still block borrowing.
|
|
65
|
-
- Hidden-balance conservation across hide and reveal flows.
|
|
66
|
-
- Sucker-only privileges staying restricted to real registered suckers.
|
|
67
|
-
- Mint permission remaining limited to the documented runtime surfaces.
|
|
68
|
-
|
|
69
|
-
## 8. Accepted Behaviors
|
|
70
|
-
|
|
71
|
-
### 8.1 Suckers receive 0% cash-out tax
|
|
72
|
-
|
|
73
|
-
Trusted suckers are intentionally exempt so bridged value preserves its economic meaning across chains.
|
|
74
|
-
|
|
75
|
-
### 8.2 There is no short-horizon liquidation model
|
|
76
|
-
|
|
77
|
-
Revnet loans are designed more like long-dated economic positions than instantly mark-to-market margin loans.
|
|
78
|
-
|
|
79
|
-
### 8.3 Auto-issuance dilution is permissionless but predictable
|
|
80
|
-
|
|
81
|
-
Anyone can trigger a valid auto-issuance once a stage is live, but the amount was fixed at deployment.
|
|
82
|
-
|
|
83
|
-
### 8.4 Surplus manipulation by pure donation is economically self-defeating
|
|
84
|
-
|
|
85
|
-
The model assumes that attempts to inflate surplus through donations are not profitable once the surrounding bonding-curve math is considered.
|
|
86
|
-
|
|
87
|
-
### 8.5 Omnichain terminal expansion inherits remote-chain trust
|
|
88
|
-
|
|
89
|
-
A project that expands to a new chain can register additional terminals on that chain. Because borrowability calculations aggregate surplus from all registered terminals across all chains, a compromised or misconfigured terminal on a remote chain can corrupt the project's surplus accounting globally. This is mitigated by including terminal addresses in the `encodedConfigurationHash` — cross-chain expansions via suckers must use the exact same terminal address as the host chain. Terminal addresses are deterministic across chains (same CREATE2 deployment), so this prevents expansions from silently using a different terminal. Project operators should still treat each chain expansion as a trust-boundary decision since bridge integrity and network assumptions remain outside protocol control.
|
|
90
|
-
|
|
91
|
-
### 8.6 Cross-chain surplus staleness
|
|
92
|
-
|
|
93
|
-
`REVLoans._borrowableAmountFrom` and `REVOwner.beforeCashOutRecordedWith` add `remoteSurplusOf()` and `remoteTotalSupplyOf()` to local values. These remote values update only when `toRemote()` is called on the peer chain -- no heartbeat or staleness check. Stale data can inflate per-token borrowable amounts when remote supply has grown since the last bridge message. Primary safeguard: borrowable is capped at `localSurplus` (REVLoans line 386-387), preventing extraction beyond what the local terminal holds.
|
|
94
|
-
|
|
95
|
-
### 8.7 REVLoans CEI violation in `_adjust`
|
|
96
|
-
|
|
97
|
-
In `REVLoans._adjust`, `totalCollateralOf[revnetId]` is incremented after external calls (`useAllowanceOf`, fee payment). A reentrant `borrowFrom` would see a lower `totalCollateralOf`. This is documented inline (lines 1128-1132) and requires an adversarial pay hook on the revnet's own terminal -- a trust-level configuration that is not realistic in standard deployments.
|
|
98
|
-
|
|
99
|
-
### 8.8 Remote loan corrections not reflected in local borrowability
|
|
100
|
-
|
|
101
|
-
`_borrowableAmountFrom` adds back local `totalBorrowed` and `totalCollateral` to reconstitute pre-loan economic state for the bonding curve. However, remote chain snapshots (built by `JBSuckerLib.buildSnapshotMessage`) capture raw surplus/supply WITHOUT loan corrections from the remote chain. This is accepted because:
|
|
102
|
-
|
|
103
|
-
1. Suckers are a general-purpose bridging layer and should not need knowledge of revnet-specific loan mechanics.
|
|
104
|
-
2. The `localSurplus` cap (REVLoans line 386-387) prevents extraction beyond what the local terminal actually holds.
|
|
105
|
-
3. The over-lending exposure is bounded by the difference between corrected and uncorrected remote values, which is proportional to remote outstanding loans — typically a small fraction of total surplus.
|
|
106
|
-
|
|
107
|
-
Project operators deploying cross-chain revnets with active loan markets on multiple chains should understand that local borrowability calculations do not account for remote outstanding loans.
|
package/SKILLS.md
DELETED
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
# Revnet Core
|
|
2
|
-
|
|
3
|
-
## Use This File For
|
|
4
|
-
|
|
5
|
-
- Use this file when the task involves revnet deployment, staged issuance, split-operator logic, auto-issuance, hidden tokens, or the revnet loan system.
|
|
6
|
-
- Start here, then decide whether the issue is really in `REVDeployer`, `REVOwner`, `REVLoans`, or `REVHiddenTokens`.
|
|
7
|
-
|
|
8
|
-
## Read This Next
|
|
9
|
-
|
|
10
|
-
| If you need... | Open this next |
|
|
11
|
-
|---|---|
|
|
12
|
-
| Repo overview and operator flow | [`README.md`](./README.md), [`ARCHITECTURE.md`](./ARCHITECTURE.md) |
|
|
13
|
-
| Deployment and stage config | [`src/REVDeployer.sol`](./src/REVDeployer.sol), [`script/Deploy.s.sol`](./script/Deploy.s.sol) |
|
|
14
|
-
| Runtime owner and data-hook behavior | [`src/REVOwner.sol`](./src/REVOwner.sol), [`references/runtime.md`](./references/runtime.md) |
|
|
15
|
-
| Loan accounting and liquidation behavior | [`src/REVLoans.sol`](./src/REVLoans.sol) |
|
|
16
|
-
| Temporary token hiding and supply exclusion | [`src/REVHiddenTokens.sol`](./src/REVHiddenTokens.sol) |
|
|
17
|
-
| Types and helpers | [`src/structs/`](./src/structs/), [`src/interfaces/`](./src/interfaces/), [`test/helpers/`](./test/helpers/) |
|
|
18
|
-
| Lifecycle, loans, and economic proofs | [`test/REVLifecycle.t.sol`](./test/REVLifecycle.t.sol), [`test/REVLoansRegressions.t.sol`](./test/REVLoansRegressions.t.sol), [`test/REVLoans.invariants.t.sol`](./test/REVLoans.invariants.t.sol), [`test/TestLongTailEconomics.t.sol`](./test/TestLongTailEconomics.t.sol) |
|
|
19
|
-
|
|
20
|
-
## Repo Map
|
|
21
|
-
|
|
22
|
-
| Area | Where to look |
|
|
23
|
-
|---|---|
|
|
24
|
-
| Main contracts | [`src/`](./src/) |
|
|
25
|
-
| Scripts | [`script/`](./script/) |
|
|
26
|
-
| Types | [`src/structs/`](./src/structs/), [`src/interfaces/`](./src/interfaces/) |
|
|
27
|
-
| Tests | [`test/`](./test/) |
|
|
28
|
-
|
|
29
|
-
## Purpose
|
|
30
|
-
|
|
31
|
-
Deploy and manage Revnets: autonomous Juicebox project shapes with staged issuance schedules, optional buyback pools, cross-chain suckers, hidden-token mechanics, and token-collateralized lending.
|
|
32
|
-
|
|
33
|
-
## Reference Files
|
|
34
|
-
|
|
35
|
-
- Open [`references/runtime.md`](./references/runtime.md) for contract roles, deploy/runtime entrypoints, integration points, and key structs.
|
|
36
|
-
- Open [`references/operations.md`](./references/operations.md) for events, errors, constants, storage, gotchas, and state-reading recipes.
|
|
37
|
-
|
|
38
|
-
## Working Rules
|
|
39
|
-
|
|
40
|
-
- Start in `REVDeployer` for launch-time behavior, `REVOwner` for runtime hook behavior, `REVLoans` for debt accounting, and `REVHiddenTokens` for supply exclusion.
|
|
41
|
-
- Revnets are intentionally ownerless after deployment. Treat any admin-recovery instinct as suspect unless the code proves it.
|
|
42
|
-
- `REVOwner` is not a minor helper; it is a live runtime policy surface.
|
|
43
|
-
- Loan collateral is burned and re-minted, not escrowed. Any change that assumes escrow semantics is likely wrong.
|
|
44
|
-
- Cash-out delay is enforced in both runtime cash-outs and loan borrowing. If one path changes without the other, the protection is broken.
|
|
45
|
-
- Hidden tokens are supply exclusion, not a side balance.
|
|
46
|
-
- Loan behavior, stage transitions, hidden supply, and split-weight adjustments interact. Do not treat them as independent subsystems.
|