@rev-net/core-v6 0.0.37 → 0.0.39
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 +60 -65
- package/src/REVHiddenTokens.sol +2 -2
- package/src/REVLoans.sol +17 -10
- package/src/REVOwner.sol +121 -14
- package/src/interfaces/IREVDeployer.sol +2 -1
- package/src/interfaces/IREVHiddenTokens.sol +4 -1
- package/src/interfaces/IREVOwner.sol +5 -0
- 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/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.
|