@bananapus/distributor-v6 0.0.38 → 0.0.43
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 +31 -21
- package/package.json +6 -6
- package/references/operations.md +3 -3
- package/references/runtime.md +1 -1
- package/src/JB721Distributor.sol +198 -166
- package/src/JBDistributor.sol +110 -51
- package/src/JBTokenDistributor.sol +135 -82
- package/src/interfaces/IJB721Distributor.sol +27 -21
- package/src/interfaces/IJBDistributor.sol +60 -34
- package/src/interfaces/IJBTokenDistributor.sol +4 -3
- package/src/libraries/JBVestingMath.sol +1 -1
- package/src/structs/JBRewardRoundData.sol +2 -2
|
@@ -148,36 +148,45 @@ interface IJBDistributor {
|
|
|
148
148
|
|
|
149
149
|
/// @notice The number of seconds after a reward round becomes claimable before unclaimed rewards expire.
|
|
150
150
|
/// @dev A zero duration means reward rounds do not expire.
|
|
151
|
-
|
|
151
|
+
/// @return claimDuration The claim duration, in seconds.
|
|
152
|
+
function CLAIM_DURATION() external view returns (uint48 claimDuration);
|
|
152
153
|
|
|
153
154
|
/// @notice The JB controller used for token registry lookups and revnet loan permissions.
|
|
154
|
-
|
|
155
|
+
/// @return controller The JB controller.
|
|
156
|
+
function CONTROLLER() external view returns (IJBController controller);
|
|
155
157
|
|
|
156
158
|
/// @notice The duration of each round, specified in seconds.
|
|
157
|
-
|
|
159
|
+
/// @return roundDuration The round duration, in seconds.
|
|
160
|
+
function ROUND_DURATION() external view returns (uint256 roundDuration);
|
|
158
161
|
|
|
159
162
|
/// @notice The Revnet loans contract used to borrow against vesting revnet rewards.
|
|
160
|
-
|
|
163
|
+
/// @return revLoans The Revnet loans contract.
|
|
164
|
+
function REV_LOANS() external view returns (IREVLoans revLoans);
|
|
161
165
|
|
|
162
166
|
/// @notice The REVOwner contract that must own a reward token's project to enable loan-backed collection.
|
|
163
|
-
|
|
167
|
+
/// @return revOwner The REVOwner contract.
|
|
168
|
+
function REV_OWNER() external view returns (IREVOwner revOwner);
|
|
164
169
|
|
|
165
170
|
/// @notice The starting timestamp of the distributor.
|
|
166
|
-
|
|
171
|
+
/// @return startingTimestamp The starting timestamp.
|
|
172
|
+
function STARTING_TIMESTAMP() external view returns (uint256 startingTimestamp);
|
|
167
173
|
|
|
168
174
|
/// @notice The number of rounds until tokens are fully vested.
|
|
169
|
-
|
|
175
|
+
/// @return vestingRounds The number of rounds until tokens are fully vested.
|
|
176
|
+
function VESTING_ROUNDS() external view returns (uint256 vestingRounds);
|
|
170
177
|
|
|
171
178
|
/// @notice The balance of a token held for a specific hook's stakers.
|
|
172
179
|
/// @param hook The hook whose balance to check.
|
|
173
180
|
/// @param token The token to check the balance of.
|
|
174
|
-
|
|
181
|
+
/// @return balance The token balance held for the hook.
|
|
182
|
+
function balanceOf(address hook, IERC20 token) external view returns (uint256 balance);
|
|
175
183
|
|
|
176
184
|
/// @notice The active Revnet loan using one token ID's vesting rewards as collateral.
|
|
177
185
|
/// @param hook The hook the token ID belongs to.
|
|
178
186
|
/// @param groupId The reward group (0 = the default group).
|
|
179
187
|
/// @param tokenId The token ID whose vesting rewards are collateralized.
|
|
180
188
|
/// @param token The reward token used as loan collateral.
|
|
189
|
+
/// @return loanId The active Revnet loan NFT ID, or 0 if none is active.
|
|
181
190
|
function activeVestingLoanIdOf(
|
|
182
191
|
address hook,
|
|
183
192
|
uint256 groupId,
|
|
@@ -186,52 +195,60 @@ interface IJBDistributor {
|
|
|
186
195
|
)
|
|
187
196
|
external
|
|
188
197
|
view
|
|
189
|
-
returns (uint256);
|
|
198
|
+
returns (uint256 loanId);
|
|
190
199
|
|
|
191
200
|
/// @notice Calculate how much of the token has been claimed for the given tokenId in the default group.
|
|
192
201
|
/// @param hook The hook the tokenId belongs to.
|
|
193
202
|
/// @param tokenId The ID of the token to calculate the token amount for.
|
|
194
203
|
/// @param token The address of the token to check.
|
|
195
|
-
|
|
204
|
+
/// @return tokenAmount The claimed token amount.
|
|
205
|
+
function claimedFor(address hook, uint256 tokenId, IERC20 token) external view returns (uint256 tokenAmount);
|
|
196
206
|
|
|
197
|
-
/// @notice Calculate
|
|
198
|
-
/// default group.
|
|
207
|
+
/// @notice Calculate the collectible token amount for a token ID in the default group.
|
|
199
208
|
/// @param hook The hook the tokenId belongs to.
|
|
200
209
|
/// @param tokenId The ID of the token to calculate the token amount for.
|
|
201
210
|
/// @param token The address of the token to check.
|
|
202
|
-
|
|
211
|
+
/// @return tokenAmount The currently collectable token amount.
|
|
212
|
+
function collectableFor(address hook, uint256 tokenId, IERC20 token) external view returns (uint256 tokenAmount);
|
|
203
213
|
|
|
204
214
|
/// @notice The number of the current round.
|
|
205
|
-
|
|
215
|
+
/// @return round The current round number.
|
|
216
|
+
function currentRound() external view returns (uint256 round);
|
|
206
217
|
|
|
207
218
|
/// @notice The block number recorded as the snapshot point for a round.
|
|
208
219
|
/// @dev Returns 0 if no snapshot block has been recorded yet for this round.
|
|
209
220
|
/// @param round The round to get the snapshot block of.
|
|
210
|
-
|
|
221
|
+
/// @return snapshotBlock The snapshot block recorded for the round.
|
|
222
|
+
function roundSnapshotBlock(uint256 round) external view returns (uint256 snapshotBlock);
|
|
211
223
|
|
|
212
224
|
/// @notice The timestamp at which a round started.
|
|
213
225
|
/// @param round The round to get the start timestamp of.
|
|
214
|
-
|
|
226
|
+
/// @return timestamp The round's start timestamp.
|
|
227
|
+
function roundStartTimestamp(uint256 round) external view returns (uint256 timestamp);
|
|
215
228
|
|
|
216
229
|
/// @notice The amount of a token that is currently vesting for a hook's stakers.
|
|
217
230
|
/// @param hook The hook whose vesting amount to check.
|
|
218
231
|
/// @param token The address of the token that is vesting.
|
|
219
|
-
|
|
232
|
+
/// @return tokenAmount The amount of the token currently vesting.
|
|
233
|
+
function totalVestingAmountOf(address hook, IERC20 token) external view returns (uint256 tokenAmount);
|
|
220
234
|
|
|
221
235
|
/// @notice The amount of vesting inventory currently collateralized in Revnet loans.
|
|
222
236
|
/// @param hook The hook whose loaned vesting amount to check.
|
|
223
237
|
/// @param token The reward token used as collateral.
|
|
224
|
-
|
|
238
|
+
/// @return tokenAmount The amount of the token currently collateralized in loans.
|
|
239
|
+
function totalLoanedVestingAmountOf(address hook, IERC20 token) external view returns (uint256 tokenAmount);
|
|
225
240
|
|
|
226
241
|
/// @notice The vesting position collateralized by a Revnet loan.
|
|
227
242
|
/// @param loanId The Revnet loan NFT ID.
|
|
228
|
-
|
|
243
|
+
/// @return vestingLoan The vesting loan data.
|
|
244
|
+
function vestingLoanOf(uint256 loanId) external view returns (JBVestingLoan memory vestingLoan);
|
|
229
245
|
|
|
230
246
|
//*********************************************************************//
|
|
231
247
|
// ---------------------------- transactions ------------------------- //
|
|
232
248
|
//*********************************************************************//
|
|
233
249
|
|
|
234
250
|
/// @notice Claims tokens and begins vesting from the default group.
|
|
251
|
+
/// @dev Permissionless. No reward tokens leave the distributor.
|
|
235
252
|
/// @param hook The hook whose stakers are vesting.
|
|
236
253
|
/// @param tokenIds The IDs to claim rewards for.
|
|
237
254
|
/// @param tokens The tokens to claim.
|
|
@@ -260,6 +277,8 @@ interface IJBDistributor {
|
|
|
260
277
|
returns (uint256 loanId, uint256 collateralCount);
|
|
261
278
|
|
|
262
279
|
/// @notice Collect vested tokens from the default group.
|
|
280
|
+
/// @dev Authorized holders can collect to any beneficiary. Helpers can collect only to the canonical beneficiary
|
|
281
|
+
/// of every token ID they do not control.
|
|
263
282
|
/// @param hook The hook whose stakers are collecting.
|
|
264
283
|
/// @param tokenIds The IDs of the tokens to collect for.
|
|
265
284
|
/// @param tokens The addresses of the tokens to collect.
|
|
@@ -279,29 +298,24 @@ interface IJBDistributor {
|
|
|
279
298
|
/// @param amount The amount to fund.
|
|
280
299
|
function fund(address hook, IERC20 token, uint256 amount) external payable;
|
|
281
300
|
|
|
301
|
+
/// @notice Record the snapshot block for the current round. Callable by anyone (keepers, frontends).
|
|
302
|
+
function poke() external;
|
|
303
|
+
|
|
282
304
|
/// @notice Recycle unclaimed rewards from expired default-group reward rounds into the current reward round.
|
|
283
305
|
/// @param hook The hook whose expired reward rounds should be recycled.
|
|
284
306
|
/// @param token The reward token to recycle.
|
|
285
307
|
/// @param rounds The reward rounds to recycle.
|
|
286
308
|
/// @return amount The total amount recycled.
|
|
287
|
-
function
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
/// @notice Repay a distributor-held Revnet loan and restore its collateral to the original vesting schedule.
|
|
293
|
-
/// @param loanId The Revnet loan NFT ID to repay.
|
|
294
|
-
/// @param maxRepayBorrowAmount The maximum amount of source token the caller is willing to repay.
|
|
295
|
-
/// @return paidOffLoanId The paid-off loan ID returned by Revnet loans.
|
|
296
|
-
function repayVestingLoan(
|
|
297
|
-
uint256 loanId,
|
|
298
|
-
uint256 maxRepayBorrowAmount
|
|
309
|
+
function recycleExpiredRewards(
|
|
310
|
+
address hook,
|
|
311
|
+
IERC20 token,
|
|
312
|
+
uint256[] calldata rounds
|
|
299
313
|
)
|
|
300
314
|
external
|
|
301
|
-
|
|
302
|
-
returns (uint256 paidOffLoanId);
|
|
315
|
+
returns (uint256 amount);
|
|
303
316
|
|
|
304
|
-
/// @notice Recycle
|
|
317
|
+
/// @notice Recycle rewards from burned tokens in the default group into the current reward round as they unlock.
|
|
318
|
+
/// @dev Unclaimed historical reward shares are materialized before the unlocked forfeited amount is recycled.
|
|
305
319
|
/// @param hook The hook whose tokens were burned.
|
|
306
320
|
/// @param tokenIds The IDs of the burned tokens.
|
|
307
321
|
/// @param tokens The reward tokens to recycle.
|
|
@@ -314,6 +328,18 @@ interface IJBDistributor {
|
|
|
314
328
|
)
|
|
315
329
|
external;
|
|
316
330
|
|
|
331
|
+
/// @notice Repay a distributor-held Revnet loan and restore its collateral to the original vesting schedule.
|
|
332
|
+
/// @param loanId The Revnet loan NFT ID to repay.
|
|
333
|
+
/// @param maxRepayBorrowAmount The maximum amount of source token the caller is willing to repay.
|
|
334
|
+
/// @return paidOffLoanId The paid-off loan ID returned by Revnet loans.
|
|
335
|
+
function repayVestingLoan(
|
|
336
|
+
uint256 loanId,
|
|
337
|
+
uint256 maxRepayBorrowAmount
|
|
338
|
+
)
|
|
339
|
+
external
|
|
340
|
+
payable
|
|
341
|
+
returns (uint256 paidOffLoanId);
|
|
342
|
+
|
|
317
343
|
/// @notice Write off a distributor-held Revnet loan after Revnet liquidation permanently destroys its collateral.
|
|
318
344
|
/// @param loanId The liquidated Revnet loan NFT ID.
|
|
319
345
|
/// @return collateralCount The amount of vesting rewards forfeited by liquidation.
|
|
@@ -6,11 +6,12 @@ import {IJBSplitHook} from "@bananapus/core-v6/src/interfaces/IJBSplitHook.sol";
|
|
|
6
6
|
|
|
7
7
|
import {IJBDistributor} from "./IJBDistributor.sol";
|
|
8
8
|
|
|
9
|
-
/// @notice A singleton distributor that distributes ERC-20 rewards to IVotes-compatible token
|
|
10
|
-
/// vesting.
|
|
9
|
+
/// @notice A singleton distributor that distributes ERC-20 rewards to IVotes-compatible token holders with delegated
|
|
10
|
+
/// voting power and linear vesting.
|
|
11
11
|
/// @dev Also implements `IJBSplitHook` to receive tokens from payout splits.
|
|
12
12
|
/// @dev Projects configure their split with `hook = distributor` and `beneficiary = their IVotes token`.
|
|
13
13
|
interface IJBTokenDistributor is IJBDistributor, IJBSplitHook {
|
|
14
14
|
/// @notice The JB directory used to verify terminal/controller callers.
|
|
15
|
-
|
|
15
|
+
/// @return directory The JB directory.
|
|
16
|
+
function DIRECTORY() external view returns (IJBDirectory directory);
|
|
16
17
|
}
|
|
@@ -55,7 +55,7 @@ library JBVestingMath {
|
|
|
55
55
|
}
|
|
56
56
|
}
|
|
57
57
|
|
|
58
|
-
/// @notice The amount remaining after the
|
|
58
|
+
/// @notice The amount remaining after the already claimed share is deducted.
|
|
59
59
|
/// @dev Computing `amount - paid` releases any floor-division dust on the final unlock.
|
|
60
60
|
/// @param amount The original vesting entry amount.
|
|
61
61
|
/// @param shareClaimed The cumulative share already claimed.
|
|
@@ -5,8 +5,8 @@ pragma solidity ^0.8.0;
|
|
|
5
5
|
/// @custom:member amount The reward amount assigned to the round.
|
|
6
6
|
/// @custom:member snapshotBlock The block used for per-account historical stake lookups.
|
|
7
7
|
/// @custom:member claimedAmount The reward amount already materialized into vesting.
|
|
8
|
-
/// @custom:member claimDeadline The timestamp
|
|
9
|
-
/// @custom:member totalStake The aggregate stake
|
|
8
|
+
/// @custom:member claimDeadline The timestamp used by distributor-specific expiration logic. Zero means no expiration.
|
|
9
|
+
/// @custom:member totalStake The aggregate stake denominator used to split the round.
|
|
10
10
|
struct JBRewardRoundData {
|
|
11
11
|
uint208 amount;
|
|
12
12
|
uint48 snapshotBlock;
|