@rev-net/core-v6 0.0.39 → 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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rev-net/core-v6",
3
- "version": "0.0.39",
3
+ "version": "0.0.40",
4
4
  "license": "MIT",
5
5
  "repository": {
6
6
  "type": "git",
@@ -43,8 +43,15 @@ import {REVDeploy721TiersHookConfig} from "./structs/REVDeploy721TiersHookConfig
43
43
  import {REVStageConfig} from "./structs/REVStageConfig.sol";
44
44
  import {REVSuckerDeploymentConfig} from "./structs/REVSuckerDeploymentConfig.sol";
45
45
 
46
- /// @notice `REVDeployer` deploys, manages, and operates Revnets.
47
- /// @dev Revnets are unowned Juicebox projects which operate autonomously after deployment.
46
+ /// @notice Deploys and configures Revnets autonomous Juicebox projects with pre-programmed tokenomics that cannot
47
+ /// be
48
+ /// changed after launch. Each revnet progresses through stages that define issuance rate, decay schedule, cash-out tax,
49
+ /// split allocations, and auto-issuances. The deployer translates these stage configurations into Juicebox rulesets,
50
+ /// sets up a buyback hook for secondary market routing, deploys a tiered 721 hook, optionally configures Croptop
51
+ /// posting, and can deploy cross-chain suckers. Once deployed, the project NFT is held by this contract — no single
52
+ /// address can modify the revnet's rules.
53
+ /// @dev Revnets are unowned Juicebox projects which operate autonomously after deployment. Runtime data hook logic
54
+ /// (pay/cash-out callbacks) is handled by the separate `REVOwner` contract to stay within EIP-170 size limits.
48
55
  contract REVDeployer is ERC2771Context, IREVDeployer, IERC721Receiver {
49
56
  //*********************************************************************//
50
57
  // --------------------------- custom errors ------------------------- //
package/src/REVLoans.sol CHANGED
@@ -35,18 +35,15 @@ import {IREVOwner} from "./interfaces/IREVOwner.sol";
35
35
  import {REVLoan} from "./structs/REVLoan.sol";
36
36
  import {REVLoanSource} from "./structs/REVLoanSource.sol";
37
37
 
38
- /// @notice A contract for borrowing from revnets.
39
- /// @dev Tokens used as collateral are burned, and reminted when the loan is paid off. This keeps the revnet's token
40
- /// structure orderly.
41
- /// @dev The borrowable amount is the same as the cash out amount.
42
- /// @dev An upfront fee is taken when a loan is created. 2.5% is charged by the underlying protocol, 2.5% is charged
43
- /// by the
44
- /// revnet issuing the loan, and a variable amount charged by the revnet that receives the fees. This variable amount is
45
- /// chosen by the borrower, the more paid upfront, the longer the prepaid duration. The loan can be repaid anytime
46
- /// within the prepaid duration without additional fees.
47
- /// After the prepaid duration, the loan will increasingly cost more to pay off. After 10 years, the loan collateral
48
- /// cannot be
49
- /// recouped.
38
+ /// @notice Allows revnet token holders to borrow against their tokens instead of cashing out. The borrowable amount
39
+ /// equals what a cash-out would return. Collateral tokens are burned on borrow and re-minted on repayment, keeping the
40
+ /// revnet's token structure orderly. Each loan is represented as an ERC-721 NFT that can be transferred.
41
+ /// @dev Fee structure: an upfront fee is taken at borrow time. 2.5% goes to the source revnet
42
+ /// (MIN_PREPAID_FEE_PERCENT), 1% goes to the $REV revnet (REV_PREPAID_FEE_PERCENT), and a variable amount chosen by the
43
+ /// borrower determines the
44
+ /// prepaid duration the more paid upfront, the longer the borrower can hold without additional cost. After the
45
+ /// prepaid duration expires, the repayment cost increases linearly until the loan liquidates at 10 years
46
+ /// (LOAN_LIQUIDATION_DURATION), at which point the collateral is permanently lost.
50
47
  /// @dev The loaned amounts include the fees taken, meaning the amount paid back is the amount borrowed plus the fees.
51
48
  contract REVLoans is ERC721, ERC2771Context, JBPermissioned, Ownable, IREVLoans {
52
49
  // A library that parses the packed ruleset metadata into a friendlier format.
package/src/REVOwner.sol CHANGED
@@ -28,9 +28,13 @@ import {IREVHiddenTokens} from "./interfaces/IREVHiddenTokens.sol";
28
28
  import {IREVLoans} from "./interfaces/IREVLoans.sol";
29
29
  import {REVLoanSource} from "./structs/REVLoanSource.sol";
30
30
 
31
- /// @notice Handles the runtime data hook and cash out hook behavior for revnets.
32
- /// @dev Separated from `REVDeployer` to stay within the EIP-170 contract size limit.
33
- /// This contract is set as the `dataHook` in each revnet's ruleset metadata.
31
+ /// @notice The runtime hook for all revnets set as every revnet's `dataHook` in ruleset metadata. At pay time, it
32
+ /// coordinates the 721 hook (NFT tier minting) with the buyback hook (secondary market swap routing) and scales weight
33
+ /// for split deductions. At cash-out time, it aggregates cross-chain total supply and surplus (including outstanding
34
+ /// loan debt and collateral), grants suckers 0% tax, splits a 2.5% fee from non-sucker cash outs, and routes fee
35
+ /// proceeds to the fee revnet via `afterCashOutRecordedWith`.
36
+ /// @dev Separated from `REVDeployer` to stay within the EIP-170 contract size limit. Also implements
37
+ /// `IJBPeerChainAdjustedAccounts` to expose loan state to peer-chain supply/surplus snapshots.
34
38
  contract REVOwner is IJBRulesetDataHook, IJBCashOutHook, IJBPeerChainAdjustedAccounts {
35
39
  // A library that adds default safety checks to ERC20 functionality.
36
40
  using SafeERC20 for IERC20;
@@ -130,13 +134,14 @@ contract REVOwner is IJBRulesetDataHook, IJBCashOutHook, IJBPeerChainAdjustedAcc
130
134
  // ------------------------- external views -------------------------- //
131
135
  //*********************************************************************//
132
136
 
133
- /// @notice Determine how a cash out from a revnet should be processed.
134
- /// @dev This function is part of `IJBRulesetDataHook`, and gets called before the revnet processes a cash out.
135
- /// @dev If a sucker is cashing out, no taxes or fees are imposed.
136
- /// @dev REVOwner is intentionally not registered as a feeless address. The protocol fee (2.5%) applies on top
137
- /// of the rev fee this is by design. The fee hook spec amount sent to `afterCashOutRecordedWith` will have the
138
- /// protocol fee deducted by the terminal before reaching this contract, so the rev fee is computed on the
139
- /// post-protocol-fee amount.
137
+ /// @notice Called before a cash out is recorded. Suckers get 0% tax (bridged tokens redeem at face value). For
138
+ /// regular holders, aggregates cross-chain total supply and surplus (including outstanding loan debt/collateral),
139
+ /// splits a 2.5% fee from the cashed-out token count, computes bonding curve reclaims for both the holder's portion
140
+ /// and the fee portion, then delegates to the buyback hook for potential swap routing.
141
+ /// @dev Part of `IJBRulesetDataHook`. REVOwner is intentionally not registered as a feeless address the
142
+ /// protocol
143
+ /// fee (2.5%) applies on top of the rev fee. The fee hook spec amount sent to `afterCashOutRecordedWith` will have
144
+ /// the protocol fee deducted by the terminal before reaching this contract.
140
145
  /// @param context Standard Juicebox cash out context. See `JBBeforeCashOutRecordedContext`.
141
146
  /// @return cashOutTaxRate The cash out tax rate, which influences the amount of terminal tokens which get cashed
142
147
  /// out.
@@ -289,8 +294,11 @@ contract REVOwner is IJBRulesetDataHook, IJBCashOutHook, IJBPeerChainAdjustedAcc
289
294
  return (cashOutTaxRate, cashOutCount, totalSupply, effectiveSurplusValue, hookSpecifications);
290
295
  }
291
296
 
292
- /// @notice Before a revnet processes an incoming payment, determine the weight and pay hooks to use.
293
- /// @dev This function is part of `IJBRulesetDataHook`, and gets called before the revnet processes a payment.
297
+ /// @notice Called before a payment is recorded. Coordinates the 721 hook (NFT tier minting with split deductions)
298
+ /// with the buyback hook (which may route funds through a Uniswap pool for a better token price). Merges their hook
299
+ /// specifications and scales the minting weight so payers only receive tokens proportional to funds entering the
300
+ /// project (not the split portion).
301
+ /// @dev Part of `IJBRulesetDataHook`. The 721 hook spec comes first in the returned array.
294
302
  /// @param context Standard Juicebox payment context. See `JBBeforePayRecordedContext`.
295
303
  /// @return weight The weight which revnet tokens are minted relative to. This can be used to customize how many
296
304
  /// tokens get minted by a payment.
@@ -347,8 +355,11 @@ contract REVOwner is IJBRulesetDataHook, IJBCashOutHook, IJBPeerChainAdjustedAcc
347
355
  if (usesBuybackHook) hookSpecifications[usesTiered721Hook ? 1 : 0] = buybackHookSpecs[0];
348
356
  }
349
357
 
350
- /// @notice A flag indicating whether an address has permission to mint a revnet's tokens on-demand.
351
- /// @dev Required by the `IJBRulesetDataHook` interface.
358
+ /// @notice Returns whether an address may mint a revnet's tokens on-demand. Grants permission to: the loans
359
+ /// contract (re-mints collateral on repayment), hidden tokens contract (re-mints on reveal), buyback hook and its
360
+ /// delegates
361
+ /// (mints tokens from pool swaps), and suckers (mints bridged tokens on the destination chain).
362
+ /// @dev Part of `IJBRulesetDataHook`.
352
363
  /// @param revnetId The ID of the revnet to check permissions for.
353
364
  /// @param ruleset The ruleset to check the mint permission for.
354
365
  /// @param addr The address to check the mint permission of.
@@ -1,8 +1,10 @@
1
1
  // SPDX-License-Identifier: MIT
2
2
  pragma solidity ^0.8.0;
3
3
 
4
- /// @custom:member chainId The ID of the chain on which the mint should be honored.
5
- /// @custom:member count The number of tokens that should be minted.
4
+ /// @notice A per-stage token mint that happens without any payment think of it as a scheduled premint. Each auto
5
+ /// issuance specifies a chain, beneficiary, and token count. Can be claimed once per stage via `autoIssueFor`.
6
+ /// @custom:member chainId The chain ID where this auto-issuance should be honored (only mints on the matching chain).
7
+ /// @custom:member count The number of tokens to mint for the beneficiary.
6
8
  /// @custom:member beneficiary The address that will receive the minted tokens.
7
9
  struct REVAutoIssuance {
8
10
  uint32 chainId;
@@ -4,11 +4,14 @@ pragma solidity ^0.8.0;
4
4
  import {REVDescription} from "./REVDescription.sol";
5
5
  import {REVStageConfig} from "./REVStageConfig.sol";
6
6
 
7
- /// @custom:member description The description of the revnet.
8
- /// @custom:member baseCurrency The currency that the issuance is based on.
9
- /// @custom:member splitOperator The address that will receive the token premint and initial production split,
10
- /// and who is allowed to change who the operator is. Only the operator can replace itself after deployment.
11
- /// @custom:member stageConfigurations The periods of changing constraints.
7
+ /// @notice Top-level configuration for deploying a revnet. Defines the revnet's identity, base currency for issuance
8
+ /// pricing, the split operator (who receives production splits and can reassign that role), and the ordered list of
9
+ /// stages that govern the revnet's lifecycle.
10
+ /// @custom:member description The revnet's name, ticker, metadata URI, and deployment salt.
11
+ /// @custom:member baseCurrency The currency that issuance pricing is denominated in (e.g. ETH or USD).
12
+ /// @custom:member splitOperator The address that receives production splits and can reassign the operator role.
13
+ /// Only the current operator can replace itself after deployment.
14
+ /// @custom:member stageConfigurations The ordered stages that define how the revnet's tokenomics evolve over time.
12
15
  struct REVConfig {
13
16
  REVDescription description;
14
17
  uint32 baseCurrency;
@@ -1,11 +1,12 @@
1
1
  // SPDX-License-Identifier: MIT
2
2
  pragma solidity ^0.8.0;
3
3
 
4
- /// @custom:member name The name of the ERC-20 token being create for the revnet.
5
- /// @custom:member ticker The ticker of the ERC-20 token being created for the revnet.
6
- /// @custom:member uri The metadata URI containing revnet's info.
7
- /// @custom:member salt Revnets deployed across chains by the same address with the same salt will have the same
8
- /// address.
4
+ /// @notice Identity and metadata for a revnet deployment.
5
+ /// @custom:member name The name of the ERC-20 token created for the revnet.
6
+ /// @custom:member ticker The ticker symbol of the ERC-20 token created for the revnet.
7
+ /// @custom:member uri The metadata URI containing the revnet's off-chain info (logo, description, links).
8
+ /// @custom:member salt A deployment salt — revnets deployed across chains by the same address with the same salt get
9
+ /// deterministic matching addresses.
9
10
  struct REVDescription {
10
11
  string name;
11
12
  string ticker;
@@ -3,12 +3,15 @@ pragma solidity ^0.8.0;
3
3
 
4
4
  import {REVLoanSource} from "./REVLoanSource.sol";
5
5
 
6
- /// @custom:member borrowedAmount The amount that is being borrowed.
7
- /// @custom:member collateralTokenCount The number of collateral tokens currently accounted for.
6
+ /// @notice An active loan against a revnet. The borrower locked collateral tokens (which were burned) and received
7
+ /// funds from the revnet's terminal. The loan can be repaid within the prepaid duration at no extra cost; after that,
8
+ /// repayment cost increases linearly until liquidation at 10 years.
9
+ /// @custom:member amount The amount borrowed (includes fees taken at creation).
10
+ /// @custom:member collateral The number of revnet tokens burned as collateral.
8
11
  /// @custom:member createdAt The timestamp when the loan was created.
9
- /// @custom:member prepaidFeePercent The percentage of the loan's fees that were prepaid.
10
- /// @custom:member prepaidDuration The duration that the loan was prepaid for.
11
- /// @custom:member source The source of the loan.
12
+ /// @custom:member prepaidFeePercent The percentage of fees prepaid at creation (determines prepaid duration).
13
+ /// @custom:member prepaidDuration The duration (seconds) during which repayment costs nothing beyond the original
14
+ /// amount. @custom:member source The terminal and token from which funds were drawn.
12
15
  struct REVLoan {
13
16
  uint112 amount;
14
17
  uint112 collateral;
@@ -5,22 +5,20 @@ import {JBSplit} from "@bananapus/core-v6/src/structs/JBSplit.sol";
5
5
 
6
6
  import {REVAutoIssuance} from "./REVAutoIssuance.sol";
7
7
 
8
- /// @custom:member startsAtOrAfter The timestamp to start a stage at the given rate at or after.
9
- /// @custom:member autoIssuances The configurations of mints during this stage.
10
- /// @custom:member splitPercent The percentage of newly issued tokens that should be split with the operator, out
11
- /// of 10_000 (JBConstants.MAX_RESERVED_PERCENT).
12
- /// @custom:member splits The splits for the revnet.
13
- /// @custom:member initialIssuance The number of revnet tokens that one unit of the revnet's base currency will buy, as
14
- /// a fixed point number
15
- /// with 18 decimals.
16
- /// @custom:member issuanceCutFrequency The number of seconds between applied issuance decreases. This
17
- /// should be at least 24 hours.
18
- /// @custom:member issuanceCutPercent The percent that issuance should decrease over time. This percentage is out
19
- /// of 1_000_000_000 (JBConstants.MAX_CUT_PERCENT). 0% corresponds to no issuance increase.
20
- /// @custom:member cashOutTaxRate The factor determining how much each token can cash out from the revnet once
21
- /// cashed out. This rate is out of 10_000 (JBConstants.MAX_CASH_OUT_TAX_RATE). 0% corresponds to no tax when cashing
22
- /// out.
23
- /// @custom:member extraMetadata Extra info to attach set into this stage that may affect hooks.
8
+ /// @notice A stage in a revnet's lifecycle. Each stage defines the token issuance rate, how quickly it decays, what
9
+ /// percentage goes to splits, and the cash-out tax rate. Stages are processed in order — each one activates at or
10
+ /// after
11
+ /// its `startsAtOrAfter` timestamp.
12
+ /// @custom:member startsAtOrAfter The earliest timestamp this stage can begin. Must be strictly increasing across
13
+ /// stages. @custom:member autoIssuances Tokens to mint without payment during this stage (per-chain, per-beneficiary).
14
+ /// @custom:member splitPercent The percentage of newly issued tokens routed to splits, out of 10,000.
15
+ /// @custom:member splits The split recipients for this stage's production allocation.
16
+ /// @custom:member initialIssuance Tokens per unit of base currency at stage start (18-decimal fixed point).
17
+ /// @custom:member issuanceCutFrequency Seconds between each issuance reduction. Should be >= 24 hours.
18
+ /// @custom:member issuanceCutPercent How much issuance decreases each period, out of 1,000,000,000. 0 = no decay.
19
+ /// @custom:member cashOutTaxRate The tax on cash outs, out of 10,000. 0 = no tax (full reclaim). Higher = more tax
20
+ /// retained by the treasury.
21
+ /// @custom:member extraMetadata Additional metadata bits passed to hooks for stage-specific behavior.
24
22
  struct REVStageConfig {
25
23
  uint48 startsAtOrAfter;
26
24
  REVAutoIssuance[] autoIssuances;