@ballkidz/defifa 0.0.26 → 0.0.28

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": "@ballkidz/defifa",
3
- "version": "0.0.26",
3
+ "version": "0.0.28",
4
4
  "license": "MIT",
5
5
  "engines": {
6
6
  "node": "25.9.0"
@@ -41,7 +41,11 @@ import {DefifaLaunchProjectData} from "./structs/DefifaLaunchProjectData.sol";
41
41
  import {DefifaOpsData} from "./structs/DefifaOpsData.sol";
42
42
  import {DefifaTierParams} from "./structs/DefifaTierParams.sol";
43
43
 
44
- /// @notice Deploys and manages Defifa games.
44
+ /// @notice Deploys and manages Defifa games — prediction-market-style contests built on Juicebox. Each game has
45
+ /// tiers representing outcomes (teams, players, events). Players mint tier NFTs during the mint phase, then after
46
+ /// the event concludes, a scorecard assigns cash-out weights to each tier. The treasury is distributed proportionally
47
+ /// to winning NFT holders. Games progress through phases: COUNTDOWN → MINT → REFUND → SCORING → COMPLETE (or
48
+ /// NO_CONTEST if minimum participation isn't met or scorecard ratification times out).
45
49
  contract DefifaDeployer is IDefifaDeployer, IDefifaGamePhaseReporter, IDefifaGamePotReporter, IERC721Receiver {
46
50
  using Strings for uint256;
47
51
  using SafeERC20 for IERC20;
@@ -95,13 +99,13 @@ contract DefifaDeployer is IDefifaDeployer, IDefifaGamePhaseReporter, IDefifaGam
95
99
  /// @notice The default Defifa token URI resolver.
96
100
  IJB721TokenUriResolver public immutable override TOKEN_URI_RESOLVER;
97
101
 
98
- /// @notice The Defifa governor.
102
+ /// @notice The governance contract that ratifies scorecards for each game.
99
103
  IDefifaGovernor public immutable override GOVERNOR;
100
104
 
101
105
  /// @notice The controller with which new projects should be deployed.
102
106
  IJBController public immutable override CONTROLLER;
103
107
 
104
- /// @notice The hooks registry.
108
+ /// @notice The Juicebox 721 tiers hook registry used to register deployed games.
105
109
  IJBAddressRegistry public immutable REGISTRY;
106
110
 
107
111
  /// @notice The 721 tiers hook store used by all games.
@@ -137,7 +141,7 @@ contract DefifaDeployer is IDefifaDeployer, IDefifaGamePhaseReporter, IDefifaGam
137
141
  // ------------------------- external views -------------------------- //
138
142
  //*********************************************************************//
139
143
 
140
- /// @notice The current pot the game is being played with.
144
+ /// @notice The current pot the game is played with.
141
145
  /// @param gameId The ID of the game for which the pot applies.
142
146
  /// @param includeCommitments A flag indicating if the portion of the pot committed to fulfill preprogrammed
143
147
  /// obligations should be included.
@@ -199,7 +203,7 @@ contract DefifaDeployer is IDefifaDeployer, IDefifaGamePhaseReporter, IDefifaGam
199
203
  return (ops.minParticipation, ops.scorecardTimeout);
200
204
  }
201
205
 
202
- /// @notice The game times.
206
+ /// @notice Get the countdown, minting, and refund deadline timestamps for a game.
203
207
  /// @param gameId The ID of the game for which the game times apply.
204
208
  /// @return The game's start time, as a unix timestamp.
205
209
  /// @return The game's minting period duration, in seconds.
@@ -209,7 +213,7 @@ contract DefifaDeployer is IDefifaDeployer, IDefifaGamePhaseReporter, IDefifaGam
209
213
  return (ops.start, ops.mintPeriodDuration, ops.refundPeriodDuration);
210
214
  }
211
215
 
212
- /// @notice The token of a game.
216
+ /// @notice Get the ERC-20 token address associated with a given game.
213
217
  /// @param gameId The ID of the game to get the token of.
214
218
  /// @return The game's token.
215
219
  function tokenOf(uint256 gameId) external view override returns (address) {
@@ -20,7 +20,10 @@ import {DefifaScorecard} from "./structs/DefifaScorecard.sol";
20
20
  import {DefifaTierCashOutWeight} from "./structs/DefifaTierCashOutWeight.sol";
21
21
  import {DefifaHookLib} from "./libraries/DefifaHookLib.sol";
22
22
 
23
- /// @notice Manages the ratification of Defifa scorecards.
23
+ /// @notice Manages the ratification of Defifa scorecards through token-weighted attestation. After a game ends,
24
+ /// anyone can submit a scorecard proposing cash-out weights for each tier. NFT holders attest to scorecards using
25
+ /// their voting power (proportional to NFTs held). A scorecard is ratified once it reaches quorum and survives the
26
+ /// grace period, after which the deployer applies the weights to the game's treasury.
24
27
  contract DefifaGovernor is Ownable, IDefifaGovernor {
25
28
  //*********************************************************************//
26
29
  // --------------------------- custom errors ------------------------- //
@@ -126,7 +129,7 @@ contract DefifaGovernor is Ownable, IDefifaGovernor {
126
129
  // ---------------------- external transactions ---------------------- //
127
130
  //*********************************************************************//
128
131
 
129
- /// @notice Attests to a scorecard.
132
+ /// @notice Cast an attestation supporting a proposed scorecard, weighted by the caller's tier voting power.
130
133
  /// @param gameId The ID of the game to which the scorecard belongs.
131
134
  /// @param scorecardId The scorecard ID.
132
135
  /// @return weight The attestation weight that was applied.
@@ -443,7 +446,7 @@ contract DefifaGovernor is Ownable, IDefifaGovernor {
443
446
  }
444
447
 
445
448
  /// @notice The ID of a scorecard representing the provided tier weights.
446
- /// @param gameHook The address where the game is being played.
449
+ /// @param gameHook The address where the game is played.
447
450
  /// @param tierWeights The weights of each tier in the scorecard.
448
451
  function scorecardIdOf(
449
452
  address gameHook,
@@ -462,10 +465,10 @@ contract DefifaGovernor is Ownable, IDefifaGovernor {
462
465
  // ----------------------- public transactions ----------------------- //
463
466
  //*********************************************************************//
464
467
 
465
- /// @notice Initializes a game.
468
+ /// @notice Initialize governance for a newly deployed game, setting the initial block number for vote accounting.
466
469
  /// @param gameId The ID of the game.
467
- /// @param attestationStartTime The amount of time between a scorecard being submitted and attestations to it being
468
- /// enabled, measured in seconds.
470
+ /// @param attestationStartTime The amount of time between a scorecard submission and attestations becoming enabled,
471
+ /// measured in seconds.
469
472
  /// @param attestationGracePeriod The amount of time that must go by before a scorecard can be ratified.
470
473
  /// @param timelockDuration The cooling period after quorum is met before a scorecard can be ratified.
471
474
  function initializeGame(
@@ -520,9 +523,8 @@ contract DefifaGovernor is Ownable, IDefifaGovernor {
520
523
  return uint256(uint48(_packedScorecardInfoOf[gameId] >> 48));
521
524
  }
522
525
 
523
- /// @notice The amount of time between a scorecard being submitted and attestations to it being enabled, measured in
524
- /// seconds.
525
- /// @dev This can be increased to leave time for users to acquire attestation power, or delegate it, before
526
+ /// @notice The amount of time between a scorecard submission and attestations becoming enabled, measured in
527
+ /// seconds. @dev This can be increased to leave time for users to acquire attestation power, or delegate it, before
526
528
  /// a scorecard becomes live.
527
529
  /// @param gameId The ID of the game to get the attestation delay of.
528
530
  /// @return The delay, in seconds.
@@ -538,7 +540,7 @@ contract DefifaGovernor is Ownable, IDefifaGovernor {
538
540
  /// MAX_ATTESTATION_POWER_TIER; a holder of 1-of-100 gets MAX_ATTESTATION_POWER_TIER / 100.
539
541
  /// This ensures each game outcome (tier) has equal governance weight — the scorecard reflects
540
542
  /// consensus across outcomes, not dominance by whichever outcome sold the most tokens.
541
- /// @param gameId The ID of the game for which attestations are being counted.
543
+ /// @param gameId The ID of the game to count attestations for.
542
544
  /// @param account The account to get attestations for.
543
545
  /// @param timestamp The timestamp to measure attestations from.
544
546
  /// @return attestationPower The amount of attestation power of an account.
@@ -745,7 +747,7 @@ contract DefifaGovernor is Ownable, IDefifaGovernor {
745
747
  return eligibleTierWeights / 2;
746
748
  }
747
749
 
748
- /// @notice The state of a proposal.
750
+ /// @notice Get the current governance state (pending, active, defeated, succeeded) of a scorecard proposal.
749
751
  /// @param gameId The ID of the game to get a proposal state of.
750
752
  /// @param scorecardId The ID of the proposal to get the state of.
751
753
  /// @return The state.
@@ -836,7 +838,7 @@ contract DefifaGovernor is Ownable, IDefifaGovernor {
836
838
  }
837
839
 
838
840
  /// @notice A value representing the contents of a scorecard.
839
- /// @param gameHook The address where the game is being played.
841
+ /// @param gameHook The address where the game is played.
840
842
  /// @param calldataBytes The calldata that will be sent if the scorecard is ratified.
841
843
  function _hashScorecardOf(address gameHook, bytes memory calldataBytes) internal pure virtual returns (uint256) {
842
844
  return uint256(keccak256(abi.encode(gameHook, calldataBytes)));
@@ -36,7 +36,10 @@ import {DefifaTierCashOutWeight} from "./structs/DefifaTierCashOutWeight.sol";
36
36
  import {DefifaGamePhase} from "./enums/DefifaGamePhase.sol";
37
37
  import {DefifaHookLib} from "./libraries/DefifaHookLib.sol";
38
38
 
39
- /// @notice A hook that transforms Juicebox treasury interactions into a Defifa game.
39
+ /// @notice The 721 hook that powers Defifa games. Extends JB721Hook to enforce game phase rules on minting and
40
+ /// cashing out, track per-tier voting power via checkpoints, and apply scorecard-determined cash-out weights after
41
+ /// ratification. Mints are only allowed during the MINT phase, refunds during the REFUND phase, and cash outs
42
+ /// with scoring weights only after a scorecard is ratified in the COMPLETE phase.
40
43
  contract DefifaHook is JB721Hook, Ownable, IDefifaHook {
41
44
  using Checkpoints for Checkpoints.Trace208;
42
45
 
@@ -79,16 +82,16 @@ contract DefifaHook is JB721Hook, Ownable, IDefifaHook {
79
82
 
80
83
  /// @notice The delegation status for each address and for each tier.
81
84
  /// _delegator The delegator.
82
- /// _tierId The ID of the tier being delegated.
85
+ /// _tierId The ID of the tier to delegate.
83
86
  mapping(address => mapping(uint256 => address)) internal _tierDelegation;
84
87
 
85
88
  /// @notice The delegation checkpoints for each address and for each tier.
86
89
  /// _delegator The delegator.
87
- /// _tierId The ID of the tier being checked.
90
+ /// _tierId The ID of the tier to check.
88
91
  mapping(address => mapping(uint256 => Checkpoints.Trace208)) internal _delegateTierCheckpoints;
89
92
 
90
93
  /// @notice The total delegation status for each tier.
91
- /// _tierId The ID of the tier being checked.
94
+ /// _tierId The ID of the tier to check.
92
95
  mapping(uint256 => Checkpoints.Trace208) internal _totalTierCheckpoints;
93
96
 
94
97
  /// @notice The first owner of each token ID, stored on first transfer out.
@@ -129,7 +132,7 @@ contract DefifaHook is JB721Hook, Ownable, IDefifaHook {
129
132
  /// @notice The address of the origin 'DefifaHook', used to check in the init if the contract is the original or not
130
133
  address public immutable override CODE_ORIGIN;
131
134
 
132
- /// @notice Contract metadata uri.
135
+ /// @notice The contract-level metadata URI used by marketplaces to display collection information.
133
136
  string public override contractURI;
134
137
 
135
138
  /// @notice The address that'll be set as the attestation delegate by default.
@@ -849,7 +852,7 @@ contract DefifaHook is JB721Hook, Ownable, IDefifaHook {
849
852
  emit TierCashOutWeightsSet(tierWeights, msg.sender);
850
853
  }
851
854
 
852
- /// @notice Delegate attestations.
855
+ /// @notice Delegate this account's voting power for a single tier to a specified delegate.
853
856
  /// @param delegatee The account to delegate tier attestation units to.
854
857
  /// @param tierId The ID of the tier to delegate attestation units for.
855
858
  function setTierDelegateTo(address delegatee, uint256 tierId) public virtual override {
@@ -864,7 +867,7 @@ contract DefifaHook is JB721Hook, Ownable, IDefifaHook {
864
867
  _delegateTier({account: msg.sender, delegatee: delegatee, tierId: tierId});
865
868
  }
866
869
 
867
- /// @notice Delegate attestations.
870
+ /// @notice Delegate this account's voting power across multiple tiers to specified delegates.
868
871
  /// @param delegations An array of tiers to set delegates for.
869
872
  function setTierDelegatesTo(DefifaDelegation[] memory delegations) external virtual override {
870
873
  // Make sure the current game phase is the minting phase.
@@ -946,7 +949,7 @@ contract DefifaHook is JB721Hook, Ownable, IDefifaHook {
946
949
  /// @notice Delegate all attestation units for the specified tier.
947
950
  /// @param account The account delegating tier attestation units.
948
951
  /// @param delegatee The account to delegate tier attestation units to.
949
- /// @param tierId The ID of the tier for which attestation units are being transferred.
952
+ /// @param tierId The ID of the tier to transfer attestation units for.
950
953
  function _delegateTier(address account, address delegatee, uint256 tierId) internal virtual {
951
954
  // Get the current delegatee
952
955
  address oldDelegate = _tierDelegation[account][tierId];
@@ -1033,7 +1036,7 @@ contract DefifaHook is JB721Hook, Ownable, IDefifaHook {
1033
1036
  /// @notice Moves delegated tier attestations from one delegate to another.
1034
1037
  /// @param from The account to transfer tier attestation units from.
1035
1038
  /// @param to The account to transfer tier attestation units to.
1036
- /// @param tierId The ID of the tier for which attestation units are being transferred.
1039
+ /// @param tierId The ID of the tier to transfer attestation units for.
1037
1040
  /// @param amount The amount of attestation units to delegate.
1038
1041
  function _moveTierDelegateAttestations(address from, address to, uint256 tierId, uint256 amount) internal {
1039
1042
  // Nothing to do if moving to the same account, or no amount is being moved.
@@ -1142,7 +1145,7 @@ contract DefifaHook is JB721Hook, Ownable, IDefifaHook {
1142
1145
  /// register a burn, `to` should be zero. Total supply of attestation units will be adjusted with mints and burns.
1143
1146
  /// @param from The account to transfer tier attestation units from.
1144
1147
  /// @param to The account to transfer tier attestation units to.
1145
- /// @param tierId The ID of the tier for which attestation units are being transferred.
1148
+ /// @param tierId The ID of the tier to transfer attestation units for.
1146
1149
  /// @param amount The amount of attestation units to delegate.
1147
1150
  function _transferTierAttestationUnits(address from, address to, uint256 tierId, uint256 amount) internal virtual {
1148
1151
  if (from == address(0) || to == address(0)) {
@@ -1190,8 +1193,8 @@ contract DefifaHook is JB721Hook, Ownable, IDefifaHook {
1190
1193
  }
1191
1194
 
1192
1195
  /// @notice Before transferring an NFT, register its first owner (if necessary).
1193
- /// @param to The address the NFT is being transferred to.
1194
- /// @param tokenId The token ID of the NFT being transferred.
1196
+ /// @param to The address to transfer the NFT to.
1197
+ /// @param tokenId The token ID of the NFT to transfer.
1195
1198
  /// @param auth The address authorizing the transfer.
1196
1199
  /// @return from The address the token was transferred from.
1197
1200
  function _update(address to, uint256 tokenId, address auth) internal virtual override returns (address from) {
@@ -8,9 +8,10 @@ import {IERC721Receiver} from "@openzeppelin/contracts/token/ERC721/IERC721Recei
8
8
 
9
9
  import {DefifaDeployer} from "./DefifaDeployer.sol";
10
10
 
11
- /// @notice A contract that can be sent a project to be burned, while still allowing defifa permissions.
12
- /// @dev Once the project NFT is transferred here, it cannot be recovered. This contract permanently
13
- /// holds the project NFT and grants SET_SPLIT_GROUPS permission to the Defifa deployer.
11
+ /// @notice A dead-end owner for Defifa project NFTs. When the project NFT is transferred here, this contract
12
+ /// permanently holds it and grants SET_SPLIT_GROUPS permission to the Defifa deployer allowing the deployer to
13
+ /// manage splits without any human having project ownership.
14
+ /// @dev Once the project NFT is transferred here, it cannot be recovered.
14
15
  contract DefifaProjectOwner is IERC721Receiver {
15
16
  //*********************************************************************//
16
17
  // --------------------------- custom errors ------------------------- //
@@ -19,7 +19,8 @@ import {DefifaGamePhase} from "./enums/DefifaGamePhase.sol";
19
19
  import {IDefifaHook} from "./interfaces/IDefifaHook.sol";
20
20
  import {IDefifaTokenUriResolver} from "./interfaces/IDefifaTokenUriResolver.sol";
21
21
 
22
- /// @notice Standard Token URIs for Defifa games.
22
+ /// @notice Generates on-chain SVG token URIs for Defifa game NFTs. Each NFT image shows the tier name, game phase,
23
+ /// and current cash-out value. Uses an on-chain typeface for rendering text within the SVG.
23
24
  contract DefifaTokenUriResolver is IDefifaTokenUriResolver, IJB721TokenUriResolver {
24
25
  using Strings for uint256;
25
26
 
@@ -1,6 +1,12 @@
1
1
  // SPDX-License-Identifier: MIT
2
2
  pragma solidity ^0.8.0;
3
3
 
4
+ /// @notice The lifecycle phases of a Defifa game.
5
+ /// COUNTDOWN — before minting opens. MINT — players can mint tier NFTs. REFUND — minting closed but refunds
6
+ /// allowed.
7
+ /// SCORING — event has ended, scorecards can be submitted and attested. COMPLETE — scorecard ratified, cash outs
8
+ /// open.
9
+ /// NO_CONTEST — game voided (minimum participation not met or scorecard timed out), full refunds available.
4
10
  enum DefifaGamePhase {
5
11
  COUNTDOWN,
6
12
  MINT,
@@ -1,6 +1,10 @@
1
1
  // SPDX-License-Identifier: MIT
2
2
  pragma solidity ^0.8.0;
3
3
 
4
+ /// @notice The governance lifecycle of a submitted scorecard.
5
+ /// PENDING — submitted but attestation period hasn't started. ACTIVE — accepting attestations.
6
+ /// DEFEATED — failed to reach quorum. SUCCEEDED — reached quorum, in grace period.
7
+ /// QUEUED — grace period passed, awaiting application. RATIFIED — applied to the game's cash-out weights.
4
8
  enum DefifaScorecardState {
5
9
  PENDING,
6
10
  ACTIVE,
@@ -15,7 +15,7 @@ import {IDefifaHook} from "./IDefifaHook.sol";
15
15
  /// and commitment fulfillment.
16
16
  interface IDefifaDeployer {
17
17
  /// @notice Emitted when a commitment payout fails during fulfillment.
18
- /// @param gameId The ID of the game being fulfilled.
18
+ /// @param gameId The ID of the game that was fulfilled.
19
19
  /// @param amount The amount that failed to pay out.
20
20
  /// @param reason The revert reason bytes from the failed payout.
21
21
  event CommitmentPayoutFailed(uint256 indexed gameId, uint256 amount, bytes reason);
@@ -81,7 +81,7 @@ interface IDefifaDeployer {
81
81
  /// @return The project ID.
82
82
  function DEFIFA_PROJECT_ID() external view returns (uint256);
83
83
 
84
- /// @notice The governor contract used for scorecard governance.
84
+ /// @notice The governor contract responsible for scorecard submission and attestation-based ratification.
85
85
  /// @return The governor contract.
86
86
  function GOVERNOR() external view returns (IDefifaGovernor);
87
87
 
@@ -116,12 +116,12 @@ interface IDefifaDeployer {
116
116
  /// @return scorecardTimeout The scorecard timeout duration.
117
117
  function safetyParamsOf(uint256 gameId) external view returns (uint256 minParticipation, uint32 scorecardTimeout);
118
118
 
119
- /// @notice The timing parameters for a game.
119
+ /// @notice The timing parameters for a game (start time, mint duration, and refund period).
120
120
  /// @param gameId The ID of the game.
121
121
  /// @return The mint duration, start time, and refund period.
122
122
  function timesFor(uint256 gameId) external view returns (uint48, uint24, uint24);
123
123
 
124
- /// @notice The token address for a game.
124
+ /// @notice The token address used for payments and cash outs in a specific game.
125
125
  /// @param gameId The ID of the game.
126
126
  /// @return The token address.
127
127
  function tokenOf(uint256 gameId) external view returns (address);
@@ -3,6 +3,10 @@ pragma solidity ^0.8.0;
3
3
 
4
4
  import {DefifaGamePhase} from "../enums/DefifaGamePhase.sol";
5
5
 
6
+ /// @notice Reports the current lifecycle phase of a Defifa game.
6
7
  interface IDefifaGamePhaseReporter {
8
+ /// @notice The current phase of a game (COUNTDOWN, MINT, REFUND, SCORING, COMPLETE, or NO_CONTEST).
9
+ /// @param gameId The ID of the game.
10
+ /// @return The current game phase.
7
11
  function currentGamePhaseOf(uint256 gameId) external view returns (DefifaGamePhase);
8
12
  }
@@ -1,8 +1,18 @@
1
1
  // SPDX-License-Identifier: MIT
2
2
  pragma solidity ^0.8.0;
3
3
 
4
+ /// @notice Reports the treasury pot size and commitment status of a Defifa game.
4
5
  interface IDefifaGamePotReporter {
6
+ /// @notice The total amount already distributed from a game's pot to commitment splits.
7
+ /// @param gameId The ID of the game.
8
+ /// @return The fulfilled commitment amount.
5
9
  function fulfilledCommitmentsOf(uint256 gameId) external view returns (uint256);
6
10
 
11
+ /// @notice The current pot size for a game, optionally including unfulfilled commitments.
12
+ /// @param gameId The ID of the game.
13
+ /// @param includeCommitments Whether to include unfulfilled commitment amounts.
14
+ /// @return pot The current pot amount.
15
+ /// @return token The token address.
16
+ /// @return decimals The token's decimal precision.
7
17
  function currentGamePotOf(uint256 gameId, bool includeCommitments) external view returns (uint256, address, uint256);
8
18
  }
@@ -24,7 +24,7 @@ interface IDefifaGovernor {
24
24
 
25
25
  /// @notice Emitted when an account attests to a scorecard.
26
26
  /// @param gameId The ID of the game.
27
- /// @param scorecardId The ID of the scorecard being attested to.
27
+ /// @param scorecardId The ID of the scorecard attested to.
28
28
  /// @param weight The attestation weight applied.
29
29
  /// @param caller The address that submitted the attestation.
30
30
  event ScorecardAttested(uint256 indexed gameId, uint256 indexed scorecardId, uint256 weight, address caller);
@@ -143,7 +143,8 @@ interface IDefifaGovernor {
143
143
  /// @return The scorecard ID.
144
144
  function scorecardIdOf(address gameHook, DefifaTierCashOutWeight[] calldata tierWeights) external returns (uint256);
145
145
 
146
- /// @notice The state of a scorecard.
146
+ /// @notice The governance state of a submitted scorecard (PENDING, ACTIVE, DEFEATED, SUCCEEDED, QUEUED, or
147
+ /// RATIFIED).
147
148
  /// @param gameId The ID of the game.
148
149
  /// @param scorecardId The ID of the scorecard.
149
150
  /// @return The scorecard state.
@@ -154,13 +155,14 @@ interface IDefifaGovernor {
154
155
  /// @return The timelock duration in seconds.
155
156
  function timelockDurationOf(uint256 gameId) external view returns (uint256);
156
157
 
157
- /// @notice Attest to a submitted scorecard.
158
+ /// @notice Attest to a submitted scorecard using your NFT voting power, adding your weight toward ratification.
158
159
  /// @param gameId The ID of the game.
159
160
  /// @param scorecardId The ID of the scorecard to attest to.
160
161
  /// @return weight The attestation weight applied.
161
162
  function attestToScorecardFrom(uint256 gameId, uint256 scorecardId) external returns (uint256 weight);
162
163
 
163
- /// @notice Initialize a game's governance parameters.
164
+ /// @notice Initialize governance parameters for a game sets when attestation begins, the grace period, and
165
+ /// timelock duration.
164
166
  /// @param gameId The ID of the game.
165
167
  /// @param attestationStartTime The timestamp when attestation begins.
166
168
  /// @param attestationGracePeriod The grace period duration in seconds.
@@ -100,7 +100,7 @@ interface IDefifaHook is IJB721Hook {
100
100
  /// @return The code origin address.
101
101
  function CODE_ORIGIN() external view returns (address);
102
102
 
103
- /// @notice The contract-level metadata URI.
103
+ /// @notice The contract-level metadata URI (used by marketplaces for collection-level info).
104
104
  /// @return The contract URI string.
105
105
  function contractURI() external view returns (string memory);
106
106
 
@@ -257,12 +257,12 @@ interface IDefifaHook is IJB721Hook {
257
257
  /// @param tierWeights The tier cash out weights to set.
258
258
  function setTierCashOutWeightsTo(DefifaTierCashOutWeight[] memory tierWeights) external;
259
259
 
260
- /// @notice Set the attestation delegate for a specific tier.
260
+ /// @notice Delegate your attestation voting power for a specific tier to another address.
261
261
  /// @param delegatee The address to delegate to.
262
262
  /// @param tierId The tier ID.
263
263
  function setTierDelegateTo(address delegatee, uint256 tierId) external;
264
264
 
265
- /// @notice Set attestation delegates for multiple tiers at once.
265
+ /// @notice Delegate your attestation voting power for multiple tiers to other addresses in a single call.
266
266
  /// @param delegations The delegation assignments.
267
267
  function setTierDelegatesTo(DefifaDelegation[] memory delegations) external;
268
268
  }
@@ -3,6 +3,9 @@ pragma solidity ^0.8.0;
3
3
 
4
4
  import {ITypeface} from "lib/typeface/contracts/interfaces/ITypeface.sol";
5
5
 
6
+ /// @notice Resolves on-chain SVG token URIs for Defifa game NFTs using an on-chain typeface.
6
7
  interface IDefifaTokenUriResolver {
8
+ /// @notice The on-chain typeface contract used for rendering text in token SVGs.
9
+ /// @return The typeface contract.
7
10
  function TYPEFACE() external view returns (ITypeface);
8
11
  }
@@ -3,7 +3,7 @@ pragma solidity 0.8.28;
3
3
 
4
4
  import {ITypeface, Font} from "lib/typeface/contracts/interfaces/ITypeface.sol";
5
5
 
6
- /// @notice Summon fonts.
6
+ /// @notice Helpers for loading on-chain Capsules typeface font sources used in Defifa SVG rendering.
7
7
  library DefifaFontImporter {
8
8
  /// @notice Gets the Base64 encoded Capsules-500.otf typeface.
9
9
  /// @param typeface The typeface contract to query.
@@ -244,7 +244,7 @@ library DefifaHookLib {
244
244
 
245
245
  /// @notice Compute the cash out count for the beforeCashOutRecorded hook.
246
246
  /// @param gamePhase The current game phase.
247
- /// @param cumulativeMintPrice The cumulative mint price of the tokens being cashed out.
247
+ /// @param cumulativeMintPrice The cumulative mint price of the tokens to cash out.
248
248
  /// @param surplusValue The surplus value from the context.
249
249
  /// @param totalAmountRedeemed The amount already redeemed.
250
250
  /// @param cumulativeCashOutWeight The cumulative cash out weight of the tokens.
@@ -294,7 +294,7 @@ library DefifaHookLib {
294
294
 
295
295
  /// @notice Computes the attestation units for tiers during payment processing.
296
296
  /// @dev Returns parallel arrays: tier IDs, cumulative attestation units per tier, and whether to switch delegate.
297
- /// @param tierIdsToMint The tier IDs being minted (must be in ascending order).
297
+ /// @param tierIdsToMint The tier IDs to mint (must be in ascending order).
298
298
  /// @param hookStore The 721 tiers hook store.
299
299
  /// @param hook The hook address.
300
300
  /// @return tierIds The unique tier IDs.
@@ -1,8 +1,9 @@
1
1
  // SPDX-License-Identifier: MIT
2
2
  pragma solidity ^0.8.0;
3
3
 
4
- /// @custom:param count A count of attestation weight.
5
- /// @custom:param attestedWeightOf The BWA weight each account attested with (0 = not attested).
4
+ /// @notice Tracks cumulative attestation weight for a scorecard and which accounts have attested.
5
+ /// @custom:member count The total attestation weight accumulated so far.
6
+ /// @custom:member attestedWeightOf The voting weight each account attested with (0 = has not attested).
6
7
  struct DefifaAttestations {
7
8
  uint256 count;
8
9
  mapping(address => uint256) attestedWeightOf;
@@ -1,6 +1,7 @@
1
1
  // SPDX-License-Identifier: MIT
2
2
  pragma solidity ^0.8.0;
3
3
 
4
+ /// @notice A delegation of a player's voting power for a specific tier to another address.
4
5
  /// @custom:member delegatee The account to delegate tier voting units to.
5
6
  /// @custom:member tierId The ID of the tier to delegate voting units for.
6
7
  struct DefifaDelegation {
@@ -8,7 +8,9 @@ import {JBSplit} from "@bananapus/core-v6/src/structs/JBSplit.sol";
8
8
 
9
9
  import {DefifaTierParams} from "./DefifaTierParams.sol";
10
10
 
11
- /// @custom:member name The name of the game being created.
11
+ /// @notice All parameters needed to launch a new Defifa game the name, tiers, timing, splits, and governance
12
+ /// configuration.
13
+ /// @custom:member name The name of the game to create.
12
14
  /// @custom:member projectUri Metadata to associate with the project.
13
15
  /// @custom:member contractUri The URI to associate with the 721.
14
16
  /// @custom:member baseUri The URI base to prepend onto any tier token URIs.
@@ -1,7 +1,8 @@
1
1
  // SPDX-License-Identifier: MIT
2
2
  pragma solidity ^0.8.0;
3
3
 
4
- /// @custom:member token The token being used by the game.
4
+ /// @notice Operational parameters stored for a deployed game — the token, timing, and contest rules.
5
+ /// @custom:member token The token used by the game.
5
6
  /// @custom:member start The time at which the game should start, measured in seconds.
6
7
  /// @custom:member mintPeriodDuration The duration of the game's mint phase, measured in seconds.
7
8
  /// @custom:member refundPeriodDuration The time between the mint phase and the start time when mint's are no longer
@@ -1,6 +1,8 @@
1
1
  // SPDX-License-Identifier: MIT
2
2
  pragma solidity ^0.8.0;
3
3
 
4
+ /// @notice A submitted scorecard's governance state — when attestations begin, when the grace period ends, and the
5
+ /// quorum threshold needed for ratification.
4
6
  /// @custom:member attestationsBegin The block at which attestations to the scorecard become allowed.
5
7
  /// @custom:member gracePeriodEnds The block at which the scorecard can become ratified.
6
8
  /// @custom:member quorumSnapshot The HHI-adjusted quorum threshold snapshotted at submission time.
@@ -1,8 +1,10 @@
1
1
  // SPDX-License-Identifier: MIT
2
2
  pragma solidity ^0.8.0;
3
3
 
4
+ /// @notice A tier's share of the treasury pot after scoring. Tiers with higher weight let their NFT holders cash out
5
+ /// for more of the treasury.
4
6
  /// @custom:member id The tier's ID.
5
- /// @custom:member cashOutWeight The weight that all tokens of this tier can be cashed out for.
7
+ /// @custom:member cashOutWeight The cash-out weight assigned to this tier (relative to all other tiers' weights).
6
8
  struct DefifaTierCashOutWeight {
7
9
  uint256 id;
8
10
  uint256 cashOutWeight;
@@ -1,6 +1,7 @@
1
1
  // SPDX-License-Identifier: MIT
2
2
  pragma solidity ^0.8.0;
3
3
 
4
+ /// @notice Parameters for creating a tier (outcome) in a Defifa game.
4
5
  /// @custom:member name The name of the tier.
5
6
  /// @custom:member reservedRate The number of minted tokens needed in the tier to allow for minting another reserved
6
7
  /// token. @custom:member reservedRateBeneficiary The beneficiary of the reserved tokens for this tier.