@ballkidz/defifa 0.0.29 → 0.0.30
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/ARCHITECTURE.md +2 -2
- package/CHANGELOG.md +2 -2
- package/CRYPTO_ECON.md +1 -1
- package/README.md +3 -3
- package/RISKS.md +1 -1
- package/SKILLS.md +1 -1
- package/STYLE_GUIDE.md +2 -50
- package/package.json +2 -2
- package/src/DefifaDeployer.sol +62 -50
- package/src/DefifaGovernor.sol +74 -63
- package/src/DefifaHook.sol +127 -183
- package/src/DefifaProjectOwner.sol +4 -2
- package/src/DefifaTokenUriResolver.sol +15 -13
- package/src/interfaces/IDefifaDeployer.sol +0 -16
- package/src/interfaces/IDefifaHook.sol +0 -4
- package/src/libraries/DefifaHookLib.sol +261 -151
package/src/DefifaGovernor.sol
CHANGED
|
@@ -29,18 +29,17 @@ contract DefifaGovernor is Ownable, IDefifaGovernor {
|
|
|
29
29
|
// --------------------------- custom errors ------------------------- //
|
|
30
30
|
//*********************************************************************//
|
|
31
31
|
|
|
32
|
-
error DefifaGovernor_AlreadyAttested();
|
|
33
|
-
error DefifaGovernor_AlreadyInitialized();
|
|
34
|
-
error DefifaGovernor_AlreadyRatified();
|
|
35
|
-
error DefifaGovernor_DuplicateScorecard();
|
|
36
|
-
error DefifaGovernor_GameNotFound();
|
|
37
|
-
error DefifaGovernor_GracePeriodTooShort();
|
|
38
|
-
error
|
|
39
|
-
error
|
|
40
|
-
error
|
|
41
|
-
error
|
|
42
|
-
error
|
|
43
|
-
error DefifaGovernor_UnownedProposedCashoutValue();
|
|
32
|
+
error DefifaGovernor_AlreadyAttested(uint256 gameId, uint256 scorecardId, address account);
|
|
33
|
+
error DefifaGovernor_AlreadyInitialized(uint256 gameId);
|
|
34
|
+
error DefifaGovernor_AlreadyRatified(uint256 gameId, uint256 scorecardId);
|
|
35
|
+
error DefifaGovernor_DuplicateScorecard(uint256 gameId, uint256 scorecardId);
|
|
36
|
+
error DefifaGovernor_GameNotFound(uint256 gameId);
|
|
37
|
+
error DefifaGovernor_GracePeriodTooShort(uint256 gracePeriod, uint256 minGracePeriod);
|
|
38
|
+
error DefifaGovernor_NotAllowed(uint256 gameId, uint256 scorecardId, address caller);
|
|
39
|
+
error DefifaGovernor_NotAttested(uint256 gameId, uint256 scorecardId, address account);
|
|
40
|
+
error DefifaGovernor_Uint48Overflow(uint256 value, uint256 max);
|
|
41
|
+
error DefifaGovernor_UnknownProposal(uint256 gameId, uint256 scorecardId);
|
|
42
|
+
error DefifaGovernor_UnownedProposedCashoutValue(uint256 gameId, uint256 tierId, uint256 cashOutWeight);
|
|
44
43
|
|
|
45
44
|
//*********************************************************************//
|
|
46
45
|
// ------------------------- public constants ------------------------ //
|
|
@@ -135,12 +134,11 @@ contract DefifaGovernor is Ownable, IDefifaGovernor {
|
|
|
135
134
|
/// @return weight The attestation weight that was applied.
|
|
136
135
|
function attestToScorecardFrom(uint256 gameId, uint256 scorecardId) external override returns (uint256 weight) {
|
|
137
136
|
// Get the game's current funding cycle along with its metadata.
|
|
138
|
-
// slither-disable-next-line unused-return
|
|
139
137
|
(, JBRulesetMetadata memory metadata) = CONTROLLER.currentRulesetOf(gameId);
|
|
140
138
|
|
|
141
139
|
// Make sure the game is in its scoring phase.
|
|
142
140
|
if (IDefifaHook(metadata.dataHook).gamePhaseReporter().currentGamePhaseOf(gameId) != DefifaGamePhase.SCORING) {
|
|
143
|
-
revert DefifaGovernor_NotAllowed();
|
|
141
|
+
revert DefifaGovernor_NotAllowed({gameId: gameId, scorecardId: scorecardId, caller: msg.sender});
|
|
144
142
|
}
|
|
145
143
|
|
|
146
144
|
// Keep a reference to the scorecard being attested to.
|
|
@@ -154,14 +152,16 @@ contract DefifaGovernor is Ownable, IDefifaGovernor {
|
|
|
154
152
|
state != DefifaScorecardState.ACTIVE && state != DefifaScorecardState.SUCCEEDED
|
|
155
153
|
&& state != DefifaScorecardState.QUEUED
|
|
156
154
|
) {
|
|
157
|
-
revert DefifaGovernor_NotAllowed();
|
|
155
|
+
revert DefifaGovernor_NotAllowed({gameId: gameId, scorecardId: scorecardId, caller: msg.sender});
|
|
158
156
|
}
|
|
159
157
|
|
|
160
158
|
// Keep a reference to the attestations for the scorecard.
|
|
161
159
|
DefifaAttestations storage attestations = _scorecardAttestationsOf[gameId][scorecardId];
|
|
162
160
|
|
|
163
161
|
// Make sure the account isn't attesting to the same scorecard again.
|
|
164
|
-
if (attestations.attestedWeightOf[msg.sender] != 0)
|
|
162
|
+
if (attestations.attestedWeightOf[msg.sender] != 0) {
|
|
163
|
+
revert DefifaGovernor_AlreadyAttested({gameId: gameId, scorecardId: scorecardId, account: msg.sender});
|
|
164
|
+
}
|
|
165
165
|
|
|
166
166
|
// Get a reference to the BWA-adjusted attestation weight, snapshotted at one second before
|
|
167
167
|
// `attestationsBegin`. Using `attestationsBegin - 1` ensures the checkpoint is from before the
|
|
@@ -172,7 +172,9 @@ contract DefifaGovernor is Ownable, IDefifaGovernor {
|
|
|
172
172
|
|
|
173
173
|
// Revert if BWA reduces this account's power to zero (e.g. 100% beneficiary of the scorecard).
|
|
174
174
|
// Without this guard, zero-weight attestors could call repeatedly since attestedWeightOf stays 0.
|
|
175
|
-
if (weight == 0)
|
|
175
|
+
if (weight == 0) {
|
|
176
|
+
revert DefifaGovernor_NotAllowed({gameId: gameId, scorecardId: scorecardId, caller: msg.sender});
|
|
177
|
+
}
|
|
176
178
|
|
|
177
179
|
// Increase the attestation count.
|
|
178
180
|
attestations.count += weight;
|
|
@@ -185,7 +187,7 @@ contract DefifaGovernor is Ownable, IDefifaGovernor {
|
|
|
185
187
|
// Store the BWA weight that was added (used for accurate subtraction on revoke).
|
|
186
188
|
attestations.attestedWeightOf[msg.sender] = weight;
|
|
187
189
|
|
|
188
|
-
emit ScorecardAttested(gameId, scorecardId, weight, msg.sender);
|
|
190
|
+
emit ScorecardAttested({gameId: gameId, scorecardId: scorecardId, weight: weight, caller: msg.sender});
|
|
189
191
|
}
|
|
190
192
|
|
|
191
193
|
/// @notice Ratifies a scorecard that has been approved.
|
|
@@ -201,10 +203,11 @@ contract DefifaGovernor is Ownable, IDefifaGovernor {
|
|
|
201
203
|
returns (uint256 scorecardId)
|
|
202
204
|
{
|
|
203
205
|
// Make sure a scorecard hasn't been ratified yet.
|
|
204
|
-
if (ratifiedScorecardIdOf[gameId] != 0)
|
|
206
|
+
if (ratifiedScorecardIdOf[gameId] != 0) {
|
|
207
|
+
revert DefifaGovernor_AlreadyRatified({gameId: gameId, scorecardId: ratifiedScorecardIdOf[gameId]});
|
|
208
|
+
}
|
|
205
209
|
|
|
206
210
|
// Get the game's current funding cycle along with its metadata.
|
|
207
|
-
// slither-disable-next-line unused-return
|
|
208
211
|
(, JBRulesetMetadata memory metadata) = CONTROLLER.currentRulesetOf(gameId);
|
|
209
212
|
|
|
210
213
|
// Build the calldata to the target.
|
|
@@ -215,7 +218,7 @@ contract DefifaGovernor is Ownable, IDefifaGovernor {
|
|
|
215
218
|
|
|
216
219
|
// Make sure the proposal being ratified has succeeded.
|
|
217
220
|
if (stateOf({gameId: gameId, scorecardId: scorecardId}) != DefifaScorecardState.SUCCEEDED) {
|
|
218
|
-
revert DefifaGovernor_NotAllowed();
|
|
221
|
+
revert DefifaGovernor_NotAllowed({gameId: gameId, scorecardId: scorecardId, caller: msg.sender});
|
|
219
222
|
}
|
|
220
223
|
|
|
221
224
|
// Set the ratified scorecard.
|
|
@@ -223,15 +226,13 @@ contract DefifaGovernor is Ownable, IDefifaGovernor {
|
|
|
223
226
|
|
|
224
227
|
// Execute the scorecard via low-level call since the governor is the delegate's owner.
|
|
225
228
|
(bool success, bytes memory returndata) = metadata.dataHook.call(scorecardCalldata);
|
|
226
|
-
// slither-disable-next-line unused-return
|
|
227
229
|
Address.verifyCallResult({success: success, returndata: returndata});
|
|
228
230
|
|
|
229
231
|
// Fulfill any commitments for the game. The internal try-catch in fulfillCommitmentsOf
|
|
230
232
|
// handles sendPayoutsOf failures, ensuring the final ruleset is always queued.
|
|
231
233
|
IDefifaDeployer(CONTROLLER.PROJECTS().ownerOf(gameId)).fulfillCommitmentsOf(gameId);
|
|
232
234
|
|
|
233
|
-
|
|
234
|
-
emit ScorecardRatified(gameId, scorecardId, msg.sender);
|
|
235
|
+
emit ScorecardRatified({gameId: gameId, scorecardId: scorecardId, caller: msg.sender});
|
|
235
236
|
}
|
|
236
237
|
|
|
237
238
|
/// @notice Revoke a previously submitted attestation. Only allowed during the ACTIVE phase.
|
|
@@ -242,14 +243,16 @@ contract DefifaGovernor is Ownable, IDefifaGovernor {
|
|
|
242
243
|
function revokeAttestationFrom(uint256 gameId, uint256 scorecardId) external virtual override {
|
|
243
244
|
// Only allow revocation during ACTIVE phase.
|
|
244
245
|
if (stateOf({gameId: gameId, scorecardId: scorecardId}) != DefifaScorecardState.ACTIVE) {
|
|
245
|
-
revert DefifaGovernor_NotAllowed();
|
|
246
|
+
revert DefifaGovernor_NotAllowed({gameId: gameId, scorecardId: scorecardId, caller: msg.sender});
|
|
246
247
|
}
|
|
247
248
|
|
|
248
249
|
DefifaAttestations storage attestations = _scorecardAttestationsOf[gameId][scorecardId];
|
|
249
250
|
uint256 weight = attestations.attestedWeightOf[msg.sender];
|
|
250
251
|
|
|
251
252
|
// Must have previously attested.
|
|
252
|
-
if (weight == 0)
|
|
253
|
+
if (weight == 0) {
|
|
254
|
+
revert DefifaGovernor_NotAttested({gameId: gameId, scorecardId: scorecardId, account: msg.sender});
|
|
255
|
+
}
|
|
253
256
|
|
|
254
257
|
// Subtract the weight and clear the attestation.
|
|
255
258
|
attestations.count -= weight;
|
|
@@ -261,7 +264,7 @@ contract DefifaGovernor is Ownable, IDefifaGovernor {
|
|
|
261
264
|
_quorumReachedAtOf[gameId][scorecardId] = 0;
|
|
262
265
|
}
|
|
263
266
|
|
|
264
|
-
emit AttestationRevoked(gameId, scorecardId, msg.sender, weight);
|
|
267
|
+
emit AttestationRevoked({gameId: gameId, scorecardId: scorecardId, account: msg.sender, weight: weight});
|
|
265
268
|
}
|
|
266
269
|
|
|
267
270
|
/// @notice Submits a scorecard to be attested to.
|
|
@@ -277,32 +280,32 @@ contract DefifaGovernor is Ownable, IDefifaGovernor {
|
|
|
277
280
|
returns (uint256 scorecardId)
|
|
278
281
|
{
|
|
279
282
|
// Make sure a proposal hasn't yet been ratified.
|
|
280
|
-
if (ratifiedScorecardIdOf[gameId] != 0)
|
|
283
|
+
if (ratifiedScorecardIdOf[gameId] != 0) {
|
|
284
|
+
revert DefifaGovernor_AlreadyRatified({gameId: gameId, scorecardId: ratifiedScorecardIdOf[gameId]});
|
|
285
|
+
}
|
|
281
286
|
|
|
282
287
|
// Make sure the game has been initialized.
|
|
283
|
-
|
|
284
|
-
if (_packedScorecardInfoOf[gameId] == 0) revert DefifaGovernor_GameNotFound();
|
|
288
|
+
if (_packedScorecardInfoOf[gameId] == 0) revert DefifaGovernor_GameNotFound({gameId: gameId});
|
|
285
289
|
|
|
286
290
|
// Keep a reference to the number of tier weights in the proposed scorecard.
|
|
287
291
|
uint256 numberOfTierWeights = tierWeights.length;
|
|
288
292
|
|
|
289
293
|
// Get the game's current funding cycle along with its metadata.
|
|
290
|
-
// slither-disable-next-line unused-return
|
|
291
294
|
(, JBRulesetMetadata memory metadata) = CONTROLLER.currentRulesetOf(gameId);
|
|
292
295
|
|
|
293
296
|
// Make sure the game is in its scoring phase.
|
|
294
297
|
if (IDefifaHook(metadata.dataHook).gamePhaseReporter().currentGamePhaseOf(gameId) != DefifaGamePhase.SCORING) {
|
|
295
|
-
revert DefifaGovernor_NotAllowed();
|
|
298
|
+
revert DefifaGovernor_NotAllowed({gameId: gameId, scorecardId: 0, caller: msg.sender});
|
|
296
299
|
}
|
|
297
300
|
|
|
298
301
|
// If there's a weight assigned to the tier, make sure there is a token backed by it.
|
|
299
|
-
// slither-disable-next-line calls-loop
|
|
300
302
|
for (uint256 i; i < numberOfTierWeights;) {
|
|
301
303
|
// A nonzero cashout weight is only valid once that tier has live ownership.
|
|
302
|
-
// slither-disable-next-line calls-loop
|
|
303
304
|
uint256 currentTierSupply = IDefifaHook(metadata.dataHook).currentSupplyOfTier(tierWeights[i].id);
|
|
304
305
|
if (tierWeights[i].cashOutWeight > 0 && currentTierSupply == 0) {
|
|
305
|
-
revert DefifaGovernor_UnownedProposedCashoutValue(
|
|
306
|
+
revert DefifaGovernor_UnownedProposedCashoutValue({
|
|
307
|
+
gameId: gameId, tierId: tierWeights[i].id, cashOutWeight: tierWeights[i].cashOutWeight
|
|
308
|
+
});
|
|
306
309
|
}
|
|
307
310
|
unchecked {
|
|
308
311
|
++i;
|
|
@@ -314,7 +317,6 @@ contract DefifaGovernor is Ownable, IDefifaGovernor {
|
|
|
314
317
|
|
|
315
318
|
// Run the same structural validation the hook will apply at ratification time so malformed
|
|
316
319
|
// scorecards fail on submission instead of reaching a misleading SUCCEEDED state first.
|
|
317
|
-
// slither-disable-next-line unused-return
|
|
318
320
|
DefifaHookLib.validateAndBuildWeights({tierWeights: tierWeights, hookStore: hookStore, hook: metadata.dataHook});
|
|
319
321
|
|
|
320
322
|
// Hash the scorecard.
|
|
@@ -323,7 +325,9 @@ contract DefifaGovernor is Ownable, IDefifaGovernor {
|
|
|
323
325
|
|
|
324
326
|
// Store the scorecard.
|
|
325
327
|
DefifaScorecard storage scorecard = _scorecardOf[gameId][scorecardId];
|
|
326
|
-
if (scorecard.attestationsBegin != 0)
|
|
328
|
+
if (scorecard.attestationsBegin != 0) {
|
|
329
|
+
revert DefifaGovernor_DuplicateScorecard({gameId: gameId, scorecardId: scorecardId});
|
|
330
|
+
}
|
|
327
331
|
|
|
328
332
|
uint256 attestationStartTime = attestationStartTimeOf(gameId);
|
|
329
333
|
|
|
@@ -340,7 +344,9 @@ contract DefifaGovernor is Ownable, IDefifaGovernor {
|
|
|
340
344
|
// This prevents the grace period from expiring before attestations even start
|
|
341
345
|
// when a scorecard is submitted early.
|
|
342
346
|
uint256 gracePeriodEnds = uint256(attestationsBegin) + attestationGracePeriodOf(gameId);
|
|
343
|
-
if (gracePeriodEnds > type(uint48).max)
|
|
347
|
+
if (gracePeriodEnds > type(uint48).max) {
|
|
348
|
+
revert DefifaGovernor_Uint48Overflow({value: gracePeriodEnds, max: type(uint48).max});
|
|
349
|
+
}
|
|
344
350
|
// Safe after the explicit max check above.
|
|
345
351
|
// forge-lint: disable-next-line(unsafe-typecast)
|
|
346
352
|
scorecard.gracePeriodEnds = uint48(gracePeriodEnds);
|
|
@@ -360,16 +366,12 @@ contract DefifaGovernor is Ownable, IDefifaGovernor {
|
|
|
360
366
|
{
|
|
361
367
|
// Cache the number of tiers to avoid re-reading from storage.
|
|
362
368
|
uint256 numberOfTiers = hookStore.maxTierIdOf(metadata.dataHook);
|
|
363
|
-
// slither-disable-next-line calls-loop
|
|
364
369
|
for (uint256 i; i < numberOfTiers;) {
|
|
365
370
|
uint256 tierId = i + 1;
|
|
366
|
-
// slither-disable-next-line calls-loop
|
|
367
371
|
JB721Tier memory tier =
|
|
368
372
|
hookStore.tierOf({hook: metadata.dataHook, id: tierId, includeResolvedUri: false});
|
|
369
373
|
// Use adjusted pending reserves that account for refund-phase burns.
|
|
370
|
-
// slither-disable-next-line calls-loop
|
|
371
374
|
uint256 pendingReserves = IDefifaHook(metadata.dataHook).adjustedPendingReservesFor(tierId);
|
|
372
|
-
// slither-disable-next-line calls-loop
|
|
373
375
|
uint256 submittedTierAttestationUnits =
|
|
374
376
|
IDefifaHook(metadata.dataHook).currentSupplyOfTier(tierId) * tier.votingUnits;
|
|
375
377
|
_pendingReservesSnapshotOf[gameId][scorecardId][tierId] = pendingReserves;
|
|
@@ -421,7 +423,13 @@ contract DefifaGovernor is Ownable, IDefifaGovernor {
|
|
|
421
423
|
defaultAttestationDelegateProposalOf[gameId] = scorecardId;
|
|
422
424
|
}
|
|
423
425
|
|
|
424
|
-
emit ScorecardSubmitted(
|
|
426
|
+
emit ScorecardSubmitted({
|
|
427
|
+
gameId: gameId,
|
|
428
|
+
scorecardId: scorecardId,
|
|
429
|
+
tierWeights: tierWeights,
|
|
430
|
+
isDefaultAttestationDelegate: msg.sender == defaultAttestationDelegate,
|
|
431
|
+
caller: msg.sender
|
|
432
|
+
});
|
|
425
433
|
}
|
|
426
434
|
|
|
427
435
|
//*********************************************************************//
|
|
@@ -483,18 +491,28 @@ contract DefifaGovernor is Ownable, IDefifaGovernor {
|
|
|
483
491
|
onlyOwner
|
|
484
492
|
{
|
|
485
493
|
// Make sure the game hasn't already been initialized.
|
|
486
|
-
if (_packedScorecardInfoOf[gameId] != 0) revert DefifaGovernor_AlreadyInitialized();
|
|
494
|
+
if (_packedScorecardInfoOf[gameId] != 0) revert DefifaGovernor_AlreadyInitialized({gameId: gameId});
|
|
487
495
|
|
|
488
496
|
// Set a default attestation start time if needed.
|
|
489
497
|
if (attestationStartTime == 0) attestationStartTime = block.timestamp;
|
|
490
498
|
|
|
491
499
|
// Enforce a minimum grace period to prevent instant ratification.
|
|
492
|
-
if (attestationGracePeriod < MIN_ATTESTATION_GRACE_PERIOD)
|
|
500
|
+
if (attestationGracePeriod < MIN_ATTESTATION_GRACE_PERIOD) {
|
|
501
|
+
revert DefifaGovernor_GracePeriodTooShort({
|
|
502
|
+
gracePeriod: attestationGracePeriod, minGracePeriod: MIN_ATTESTATION_GRACE_PERIOD
|
|
503
|
+
});
|
|
504
|
+
}
|
|
493
505
|
|
|
494
506
|
// Ensure values fit within their allocated 48-bit widths before packing.
|
|
495
|
-
if (attestationStartTime > type(uint48).max)
|
|
496
|
-
|
|
497
|
-
|
|
507
|
+
if (attestationStartTime > type(uint48).max) {
|
|
508
|
+
revert DefifaGovernor_Uint48Overflow({value: attestationStartTime, max: type(uint48).max});
|
|
509
|
+
}
|
|
510
|
+
if (attestationGracePeriod > type(uint48).max) {
|
|
511
|
+
revert DefifaGovernor_Uint48Overflow({value: attestationGracePeriod, max: type(uint48).max});
|
|
512
|
+
}
|
|
513
|
+
if (timelockDuration > type(uint48).max) {
|
|
514
|
+
revert DefifaGovernor_Uint48Overflow({value: timelockDuration, max: type(uint48).max});
|
|
515
|
+
}
|
|
498
516
|
|
|
499
517
|
// Pack the values.
|
|
500
518
|
uint256 packed;
|
|
@@ -508,7 +526,13 @@ contract DefifaGovernor is Ownable, IDefifaGovernor {
|
|
|
508
526
|
// Store the packed value.
|
|
509
527
|
_packedScorecardInfoOf[gameId] = packed;
|
|
510
528
|
|
|
511
|
-
emit GameInitialized(
|
|
529
|
+
emit GameInitialized({
|
|
530
|
+
gameId: gameId,
|
|
531
|
+
attestationStartTime: attestationStartTime,
|
|
532
|
+
attestationGracePeriod: attestationGracePeriod,
|
|
533
|
+
timelockDuration: timelockDuration,
|
|
534
|
+
caller: msg.sender
|
|
535
|
+
});
|
|
512
536
|
}
|
|
513
537
|
|
|
514
538
|
//*********************************************************************//
|
|
@@ -555,7 +579,6 @@ contract DefifaGovernor is Ownable, IDefifaGovernor {
|
|
|
555
579
|
returns (uint256 attestationPower)
|
|
556
580
|
{
|
|
557
581
|
// Get the game's current funding cycle along with its metadata.
|
|
558
|
-
// slither-disable-next-line unused-return
|
|
559
582
|
(, JBRulesetMetadata memory metadata) = CONTROLLER.currentRulesetOf(gameId);
|
|
560
583
|
|
|
561
584
|
// Get a reference to the hook and its store.
|
|
@@ -570,12 +593,10 @@ contract DefifaGovernor is Ownable, IDefifaGovernor {
|
|
|
570
593
|
uint256 tierId = i + 1;
|
|
571
594
|
|
|
572
595
|
// Get this account's attestation units within the tier (snapshot at timestamp).
|
|
573
|
-
// slither-disable-next-line calls-loop
|
|
574
596
|
uint256 tierAttestationUnitsForAccount =
|
|
575
597
|
hook.getPastTierAttestationUnitsOf({account: account, tier: tierId, timestamp: timestamp});
|
|
576
598
|
|
|
577
599
|
// Get the total attestation units for this tier (snapshot at timestamp).
|
|
578
|
-
// slither-disable-next-line calls-loop
|
|
579
600
|
uint256 tierTotalAttestationUnits =
|
|
580
601
|
hook.getPastTierTotalAttestationUnitsOf({tier: tierId, timestamp: timestamp});
|
|
581
602
|
|
|
@@ -585,10 +606,8 @@ contract DefifaGovernor is Ownable, IDefifaGovernor {
|
|
|
585
606
|
// pending reserves decrease by the same amount — so no one's voting power shifts.
|
|
586
607
|
{
|
|
587
608
|
// Use adjusted pending reserves that account for refund-phase burns.
|
|
588
|
-
// slither-disable-next-line calls-loop
|
|
589
609
|
uint256 pendingReserves = IDefifaHook(metadata.dataHook).adjustedPendingReservesFor(tierId);
|
|
590
610
|
if (pendingReserves != 0) {
|
|
591
|
-
// slither-disable-next-line calls-loop
|
|
592
611
|
JB721Tier memory tier =
|
|
593
612
|
store.tierOf({hook: metadata.dataHook, id: tierId, includeResolvedUri: false});
|
|
594
613
|
tierTotalAttestationUnits += pendingReserves * tier.votingUnits;
|
|
@@ -634,7 +653,6 @@ contract DefifaGovernor is Ownable, IDefifaGovernor {
|
|
|
634
653
|
returns (uint256 bwaAttestationPower)
|
|
635
654
|
{
|
|
636
655
|
// Get the game's current funding cycle along with its metadata.
|
|
637
|
-
// slither-disable-next-line unused-return
|
|
638
656
|
(, JBRulesetMetadata memory metadata) = CONTROLLER.currentRulesetOf(gameId);
|
|
639
657
|
|
|
640
658
|
// Get a reference to the hook and its store.
|
|
@@ -652,7 +670,6 @@ contract DefifaGovernor is Ownable, IDefifaGovernor {
|
|
|
652
670
|
uint256 tierId = i + 1;
|
|
653
671
|
|
|
654
672
|
// Get this account's attestation units within the tier (snapshot at timestamp).
|
|
655
|
-
// slither-disable-next-line calls-loop
|
|
656
673
|
uint256 tierAttestationUnitsForAccount =
|
|
657
674
|
hook.getPastTierAttestationUnitsOf({account: account, tier: tierId, timestamp: timestamp});
|
|
658
675
|
|
|
@@ -660,7 +677,6 @@ contract DefifaGovernor is Ownable, IDefifaGovernor {
|
|
|
660
677
|
// Start from the checkpointed tier total at the requested timestamp.
|
|
661
678
|
// If reserve mints happened after submission, clamp them out before adding the
|
|
662
679
|
// pending-reserve snapshot back in so each reserve unit is counted exactly once.
|
|
663
|
-
// slither-disable-next-line calls-loop
|
|
664
680
|
uint256 tierTotalAttestationUnits =
|
|
665
681
|
hook.getPastTierTotalAttestationUnitsOf({tier: tierId, timestamp: timestamp});
|
|
666
682
|
uint256 submittedTierAttestationUnits = _submittedTierAttestationUnitsOf[gameId][scorecardId][tierId];
|
|
@@ -672,7 +688,6 @@ contract DefifaGovernor is Ownable, IDefifaGovernor {
|
|
|
672
688
|
// Add back the snapshotted pending reserves.
|
|
673
689
|
uint256 pendingReserves = _pendingReservesSnapshotOf[gameId][scorecardId][tierId];
|
|
674
690
|
if (pendingReserves != 0) {
|
|
675
|
-
// slither-disable-next-line calls-loop
|
|
676
691
|
JB721Tier memory tier =
|
|
677
692
|
store.tierOf({hook: metadata.dataHook, id: tierId, includeResolvedUri: false});
|
|
678
693
|
tierTotalAttestationUnits += pendingReserves * tier.votingUnits;
|
|
@@ -709,7 +724,6 @@ contract DefifaGovernor is Ownable, IDefifaGovernor {
|
|
|
709
724
|
/// @return The quorum number of attestations.
|
|
710
725
|
function quorum(uint256 gameId) public view override returns (uint256) {
|
|
711
726
|
// Get the game's current funding cycle along with its metadata.
|
|
712
|
-
// slither-disable-next-line unused-return
|
|
713
727
|
(, JBRulesetMetadata memory metadata) = CONTROLLER.currentRulesetOf(gameId);
|
|
714
728
|
|
|
715
729
|
// Get a reference to the hook and its store.
|
|
@@ -729,10 +743,8 @@ contract DefifaGovernor is Ownable, IDefifaGovernor {
|
|
|
729
743
|
// Pending reserves still belong economically to the reserve beneficiary, even after the
|
|
730
744
|
// last paid token in the tier is burned during REFUND, so excluding them would let a
|
|
731
745
|
// burner erase another participant's quorum contribution without erasing their claim.
|
|
732
|
-
// slither-disable-next-line calls-loop
|
|
733
746
|
uint256 currentTierSupply = hook.currentSupplyOfTier(tierId);
|
|
734
747
|
// Use adjusted pending reserves that account for refund-phase burns.
|
|
735
|
-
// slither-disable-next-line calls-loop
|
|
736
748
|
uint256 pendingReserves = hook.adjustedPendingReservesFor(tierId);
|
|
737
749
|
if (currentTierSupply != 0 || pendingReserves != 0) {
|
|
738
750
|
eligibleTierWeights += MAX_ATTESTATION_POWER_TIER;
|
|
@@ -769,9 +781,8 @@ contract DefifaGovernor is Ownable, IDefifaGovernor {
|
|
|
769
781
|
DefifaScorecard memory scorecard = _scorecardOf[gameId][scorecardId];
|
|
770
782
|
|
|
771
783
|
// Make sure the proposal is known.
|
|
772
|
-
// slither-disable-next-line incorrect-equality
|
|
773
784
|
if (scorecard.attestationsBegin == 0) {
|
|
774
|
-
revert DefifaGovernor_UnknownProposal();
|
|
785
|
+
revert DefifaGovernor_UnknownProposal({gameId: gameId, scorecardId: scorecardId});
|
|
775
786
|
}
|
|
776
787
|
|
|
777
788
|
// If the scorecard has attestations beginning in the future, the state is PENDING.
|