@ballkidz/defifa 0.0.26 → 0.0.27
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/DefifaDeployer.sol +5 -1
- package/src/DefifaGovernor.sol +4 -1
- package/src/DefifaHook.sol +4 -1
- package/src/DefifaProjectOwner.sol +4 -3
- package/src/DefifaTokenUriResolver.sol +2 -1
- package/src/enums/DefifaGamePhase.sol +6 -0
- package/src/enums/DefifaScorecardState.sol +4 -0
- package/src/interfaces/IDefifaGamePhaseReporter.sol +4 -0
- package/src/interfaces/IDefifaGamePotReporter.sol +10 -0
- package/src/interfaces/IDefifaTokenUriResolver.sol +3 -0
- package/src/libraries/DefifaFontImporter.sol +1 -1
- package/src/structs/DefifaAttestations.sol +3 -2
- package/src/structs/DefifaDelegation.sol +1 -0
- package/src/structs/DefifaLaunchProjectData.sol +2 -0
- package/src/structs/DefifaOpsData.sol +1 -0
- package/src/structs/DefifaScorecard.sol +2 -0
- package/src/structs/DefifaTierCashOutWeight.sol +3 -1
- package/src/structs/DefifaTierParams.sol +1 -0
package/package.json
CHANGED
package/src/DefifaDeployer.sol
CHANGED
|
@@ -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;
|
package/src/DefifaGovernor.sol
CHANGED
|
@@ -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 ------------------------- //
|
package/src/DefifaHook.sol
CHANGED
|
@@ -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
|
|
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
|
|
|
@@ -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
|
|
12
|
-
///
|
|
13
|
-
///
|
|
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
|
|
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,
|
|
@@ -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
|
}
|
|
@@ -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
|
|
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.
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
// SPDX-License-Identifier: MIT
|
|
2
2
|
pragma solidity ^0.8.0;
|
|
3
3
|
|
|
4
|
-
/// @
|
|
5
|
-
/// @custom:
|
|
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,6 +8,8 @@ import {JBSplit} from "@bananapus/core-v6/src/structs/JBSplit.sol";
|
|
|
8
8
|
|
|
9
9
|
import {DefifaTierParams} from "./DefifaTierParams.sol";
|
|
10
10
|
|
|
11
|
+
/// @notice All parameters needed to launch a new Defifa game — the name, tiers, timing, splits, and governance
|
|
12
|
+
/// configuration.
|
|
11
13
|
/// @custom:member name The name of the game being created.
|
|
12
14
|
/// @custom:member projectUri Metadata to associate with the project.
|
|
13
15
|
/// @custom:member contractUri The URI to associate with the 721.
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
// SPDX-License-Identifier: MIT
|
|
2
2
|
pragma solidity ^0.8.0;
|
|
3
3
|
|
|
4
|
+
/// @notice Operational parameters stored for a deployed game — the token, timing, and contest rules.
|
|
4
5
|
/// @custom:member token The token being 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.
|
|
@@ -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
|
|
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.
|