@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 +13 -7
- package/package.json +1 -1
- package/src/REVOwner.sol +42 -12
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
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
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
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
|
|
169
|
-
///
|
|
170
|
-
///
|
|
171
|
-
///
|
|
172
|
-
///
|
|
173
|
-
///
|
|
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
|
|
206
|
-
// to this chain's local backing. Do not add remote supply/surplus here, even for
|
|
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
|
|
462
|
-
/// @dev
|
|
463
|
-
///
|
|
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.
|