@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 +1 -1
- package/src/REVDeployer.sol +9 -2
- package/src/REVLoans.sol +9 -12
- package/src/REVOwner.sol +25 -14
- 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/package.json
CHANGED
package/src/REVDeployer.sol
CHANGED
|
@@ -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
|
|
47
|
-
///
|
|
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
|
|
39
|
-
///
|
|
40
|
-
/// structure orderly.
|
|
41
|
-
/// @dev
|
|
42
|
-
///
|
|
43
|
-
///
|
|
44
|
-
///
|
|
45
|
-
///
|
|
46
|
-
///
|
|
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
|
|
32
|
-
///
|
|
33
|
-
///
|
|
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
|
|
134
|
-
///
|
|
135
|
-
///
|
|
136
|
-
///
|
|
137
|
-
///
|
|
138
|
-
/// protocol
|
|
139
|
-
///
|
|
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
|
|
293
|
-
///
|
|
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
|
|
351
|
-
///
|
|
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
|
-
/// @
|
|
5
|
-
///
|
|
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
|
-
/// @
|
|
8
|
-
///
|
|
9
|
-
///
|
|
10
|
-
///
|
|
11
|
-
/// @custom:member
|
|
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
|
-
/// @
|
|
5
|
-
/// @custom:member
|
|
6
|
-
/// @custom:member
|
|
7
|
-
/// @custom:member
|
|
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;
|
package/src/structs/REVLoan.sol
CHANGED
|
@@ -3,12 +3,15 @@ pragma solidity ^0.8.0;
|
|
|
3
3
|
|
|
4
4
|
import {REVLoanSource} from "./REVLoanSource.sol";
|
|
5
5
|
|
|
6
|
-
/// @
|
|
7
|
-
///
|
|
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
|
|
10
|
-
/// @custom:member prepaidDuration The duration
|
|
11
|
-
/// @custom:member source The
|
|
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
|
-
/// @
|
|
9
|
-
///
|
|
10
|
-
///
|
|
11
|
-
///
|
|
12
|
-
/// @custom:member
|
|
13
|
-
/// @custom:member
|
|
14
|
-
///
|
|
15
|
-
///
|
|
16
|
-
/// @custom:member
|
|
17
|
-
///
|
|
18
|
-
/// @custom:member issuanceCutPercent
|
|
19
|
-
/// of
|
|
20
|
-
///
|
|
21
|
-
///
|
|
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;
|