@rev-net/core-v6 0.0.78 → 0.0.80

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/README.md CHANGED
@@ -2,13 +2,19 @@
2
2
 
3
3
  `@rev-net/core-v6` deploys and operates Revnets: Juicebox project shapes with staged economics, optional tiered NFTs, cross-chain support, buyback integration, and token-collateralized loans.
4
4
 
5
- Docs: <https://docs.juicebox.money>
6
- Architecture: [ARCHITECTURE.md](./ARCHITECTURE.md)
7
- User journeys: [USER_JOURNEYS.md](./USER_JOURNEYS.md)
8
- Skills: [SKILLS.md](./SKILLS.md)
9
- Risks: [RISKS.md](./RISKS.md)
10
- Administration: [ADMINISTRATION.md](./ADMINISTRATION.md)
11
- Audit instructions: [AUDIT_INSTRUCTIONS.md](./AUDIT_INSTRUCTIONS.md)
5
+
6
+ ## Documentation
7
+
8
+ - [INVARIANTS.md](./INVARIANTS.md) — Per-contract guarantees + operation inventory
9
+ - [ARBITRAGE.md](./ARBITRAGE.md) — The three intentional protocol-beneficial arbitrage paths
10
+ - [ARCHITECTURE.md](./ARCHITECTURE.md) — Module layout
11
+ - [ADMINISTRATION.md](./ADMINISTRATION.md) — Admin surface (REVOwner + REVLoans ownable)
12
+ - [RISKS.md](./RISKS.md) — Threat model
13
+ - [USER_JOURNEYS.md](./USER_JOURNEYS.md) — Example flows
14
+ - [AUDIT_INSTRUCTIONS.md](./AUDIT_INSTRUCTIONS.md) — Auditor scope and orientation
15
+ - [SKILLS.md](./SKILLS.md) — Agent-oriented navigation map
16
+ - [STYLE_GUIDE.md](./STYLE_GUIDE.md) — Solidity conventions across the V6 ecosystem
17
+ - [CHANGELOG.md](./CHANGELOG.md) — Version history
12
18
 
13
19
  ## Overview
14
20
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rev-net/core-v6",
3
- "version": "0.0.78",
3
+ "version": "0.0.80",
4
4
  "license": "MIT",
5
5
  "repository": {
6
6
  "type": "git",
package/src/REVOwner.sol CHANGED
@@ -165,12 +165,31 @@ contract REVOwner is IREVOwner, IJBRulesetDataHook, IJBCashOutHook, IJBPeerChain
165
165
  // ------------------------- external views -------------------------- //
166
166
  //*********************************************************************//
167
167
 
168
- /// @notice Called before a cash-out is recorded. Suckers get 0% tax (bridged tokens redeem at face value). For
169
- /// regular holders, aggregates cross-chain total supply and surplus (including outstanding loan debt/collateral),
170
- /// splits a 2.5% fee from the cashed-out token count when cash-out tax is non-zero, computes bonding curve
171
- /// reclaims for both the holder's portion and the fee portion, then delegates to the buyback hook for potential
172
- /// swap routing.
173
- /// @dev Part of `IJBRulesetDataHook`. In the non-zero-tax fee path, REVOwner is intentionally not registered as a
168
+ /// @notice Hook called by the JBTerminalStore during cash-out to enforce revnet-specific tax/fee/aggregation logic.
169
+ /// @dev This function is the policy boundary between three distinct cash-out semantics:
170
+ ///
171
+ /// 1. **Sucker cash-outs (registered bridge contracts):** returns tax=0 and uses LOCAL supply/surplus only.
172
+ /// Lines 209-211. Bridges cash out tokens at the originating chain's local backing rate to move value
173
+ /// across chains. This is the bridge accounting primitive keep value moving out of this chain
174
+ /// proportional to this chain's local backing, regardless of cross-chain aggregation. This deliberate
175
+ /// asymmetry vs. ordinary cash-outs is what enables the cross-chain rebalancing arbitrage path described
176
+ /// in ARBITRAGE.md (Path 1). See also INVARIANTS.md Section D2 at the monorepo root.
177
+ ///
178
+ /// 2. **Ordinary cash-outs during the cash-out delay window:** revert. Lines around 217-220. The delay
179
+ /// blocks direct exits (cash-out/borrow) on new chains so they can prime via bridges before users
180
+ /// start drawing value. Note the delay does NOT apply to sucker cash-outs (item 1) — priming requires
181
+ /// bridges to remain open.
182
+ ///
183
+ /// 3. **Ordinary cash-outs after delay:** aggregate cross-chain state when `scopeCashOutsToLocalBalances`
184
+ /// is false, then route through the buyback hook to potentially settle via AMM (Path 2 floor arb in
185
+ /// ARBITRAGE.md) or pass through to bonding curve. The buyback hook auto-applies floor arbitrage for
186
+ /// users who would otherwise underpay themselves.
187
+ ///
188
+ /// The interaction of these three semantics — together with the buyback hook's pay-side ceiling arbitrage
189
+ /// (Path 3, in nana-buyback-hook-v6) — is what makes a multi-chain revnet self-equilibrating. See
190
+ /// ARBITRAGE.md for the full taxonomy.
191
+ ///
192
+ /// Part of `IJBRulesetDataHook`. In the non-zero-tax fee path, REVOwner is intentionally not registered as a
174
193
  /// feeless address — the protocol fee (2.5%) applies on top of the rev fee. The fee hook spec amount sent to
175
194
  /// `afterCashOutRecordedWith` will have the protocol fee deducted by the terminal before reaching this contract.
176
195
  /// @param context Standard Juicebox cash-out context. See `JBBeforeCashOutRecordedContext`.
@@ -202,8 +221,11 @@ contract REVOwner is IREVOwner, IJBRulesetDataHook, IJBCashOutHook, IJBPeerChain
202
221
  effectiveSurplusValue = context.surplus.value + totalBorrowed;
203
222
 
204
223
  // If the cash-out is from a sucker, return the full cash-out amount without taxes or fees.
205
- // Sucker cash-outs are the bridge accounting path: the value moving out of this chain must stay proportional
206
- // to this chain's local backing. Do not add remote supply/surplus here, even for unscoped revnets.
224
+ // Sucker cash-outs are the bridge accounting path: the value moving out of this chain must stay
225
+ // proportional to this chain's local backing. Do not add remote supply/surplus here, even for
226
+ // unscoped revnets. This is deliberate — the asymmetry vs. ordinary cash-outs (which aggregate
227
+ // cross-chain) is what enables the cross-chain rebalancing arbitrage that primes new chains and
228
+ // equalizes per-chain backing divergence. See ARBITRAGE.md (Path 1).
207
229
  // This relies on the sucker registry to only contain trusted sucker contracts deployed via
208
230
  // the registry's own deploySuckersFor flow — external addresses cannot register as suckers.
209
231
  if (_isSuckerOf({revnetId: context.projectId, addr: context.holder})) {
@@ -213,7 +235,10 @@ contract REVOwner is IREVOwner, IJBRulesetDataHook, IJBCashOutHook, IJBPeerChain
213
235
  // Keep a reference to the cash-out delay of the revnet.
214
236
  uint256 cashOutDelay = cashOutDelayOf[context.projectId];
215
237
 
216
- // Enforce the cash-out delay.
238
+ // Enforce the cash-out delay on ordinary cash-outs.
239
+ // Note: the sucker branch above returns BEFORE this check by design — bridges remain open during
240
+ // the delay so a new chain can prime its local backing via inbound bridges before any holder can
241
+ // directly exit. See ARBITRAGE.md (Path 1) and INVARIANTS.md Section D2 for the rationale.
217
242
  // forge-lint: disable-next-line(block-timestamp)
218
243
  if (cashOutDelay > block.timestamp) {
219
244
  revert REVOwner_CashOutDelayNotFinished({cashOutDelay: cashOutDelay, blockTimestamp: block.timestamp});
@@ -458,9 +483,14 @@ contract REVOwner is IREVOwner, IJBRulesetDataHook, IJBCashOutHook, IJBPeerChain
458
483
  || _isSuckerOf({revnetId: revnetId, addr: addr});
459
484
  }
460
485
 
461
- /// @notice Additional revnet accounts that peer-chain snapshots should include.
462
- /// @dev Outstanding loan debt is counted as both surplus and balance:
463
- /// it is value owed back to this chain's revnet and should travel to peer snapshots with the collateral supply.
486
+ /// @notice Adjusts local accounts for outstanding loans when reporting peer-chain state.
487
+ /// @dev Used by remote chains' aggregate cash-out math to correctly account for value temporarily
488
+ /// held outside this chain's terminal (in active REVLoans). Critical for the conservation invariant
489
+ /// described in INVARIANTS.md Section D2.5 — without this adjustment, outstanding-loan ETH would
490
+ /// silently inflate apparent surplus on the peer-chain side.
491
+ ///
492
+ /// Outstanding loan debt is counted as both surplus and balance: it is value owed back to this
493
+ /// chain's revnet and should travel to peer snapshots with the collateral supply.
464
494
  /// @param revnetId The ID of the revnet to snapshot.
465
495
  /// @param decimals The decimals to use for the returned surplus.
466
496
  /// @param currency The currency to denominate the returned surplus in.