@ballkidz/defifa 0.0.12 → 0.0.14

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.
Files changed (44) hide show
  1. package/ADMINISTRATION.md +3 -3
  2. package/ARCHITECTURE.md +3 -2
  3. package/AUDIT_INSTRUCTIONS.md +5 -5
  4. package/CHANGE_LOG.md +62 -5
  5. package/CRYPTO_ECON.md +506 -271
  6. package/CRYPTO_ECON.pdf +0 -0
  7. package/CRYPTO_ECON.tex +438 -241
  8. package/RISKS.md +13 -1
  9. package/SKILLS.md +5 -3
  10. package/USER_JOURNEYS.md +4 -3
  11. package/package.json +6 -6
  12. package/src/DefifaDeployer.sol +128 -130
  13. package/src/DefifaGovernor.sol +304 -83
  14. package/src/DefifaHook.sol +184 -171
  15. package/src/enums/DefifaScorecardState.sol +1 -0
  16. package/src/interfaces/IDefifaGovernor.sol +42 -2
  17. package/src/libraries/DefifaHookLib.sol +69 -62
  18. package/src/structs/DefifaAttestations.sol +3 -3
  19. package/src/structs/DefifaLaunchProjectData.sol +1 -0
  20. package/src/structs/DefifaScorecard.sol +2 -0
  21. package/test/BWAFunctionComparison.t.sol +1320 -0
  22. package/test/DefifaAdversarialQuorum.t.sol +52 -37
  23. package/test/DefifaAuditLowGuards.t.sol +9 -5
  24. package/test/DefifaFeeAccounting.t.sol +2 -1
  25. package/test/DefifaGovernanceHardening.t.sol +1315 -0
  26. package/test/DefifaGovernor.t.sol +8 -4
  27. package/test/DefifaHookRegressions.t.sol +2 -1
  28. package/test/DefifaMintCostInvariant.t.sol +2 -1
  29. package/test/DefifaNoContest.t.sol +3 -2
  30. package/test/DefifaSecurity.t.sol +55 -47
  31. package/test/DefifaUSDC.t.sol +3 -2
  32. package/test/Fork.t.sol +37 -32
  33. package/test/TestAuditGaps.sol +6 -4
  34. package/test/TestQALastMile.t.sol +6 -3
  35. package/test/audit/{CodexAttestationDoubleCount.t.sol → AttestationDoubleCount.t.sol} +3 -2
  36. package/test/audit/FixPendingReserveDilution.t.sol +366 -0
  37. package/test/audit/PendingReserveDilution.t.sol +298 -0
  38. package/test/audit/PendingReserveQuorumGrief.t.sol +355 -0
  39. package/test/audit/PendingReserveSnapshotBypass.t.sol +279 -0
  40. package/test/regression/AttestationDelegateBeneficiary.t.sol +2 -1
  41. package/test/regression/FulfillmentBlocksRatification.t.sol +2 -1
  42. package/test/regression/GracePeriodBypass.t.sol +2 -1
  43. package/test/SVG.t.sol +0 -164
  44. package/test/deployScript.t.sol +0 -144
package/test/SVG.t.sol DELETED
@@ -1,164 +0,0 @@
1
- // SPDX-License-Identifier: MIT
2
- pragma solidity 0.8.28;
3
- //
4
- // import "forge-std/Test.sol";
5
- //
6
- // import {IERC20} from "@openzeppelin/contracts/token/ERC20/IERC20.sol";
7
- // import "@openzeppelin/contracts/proxy/Clones.sol";
8
- // import "../src/DefifaHook.sol";
9
- // import "../src/DefifaDeployer.sol";
10
- // import "../src/DefifaTokenUriResolver.sol";
11
- // import "../src/interfaces/IDefifaGamePhaseReporter.sol";
12
- // import "../src/interfaces/IDefifaGamePhaseReporter.sol";
13
- // import "../src/interfaces/IDefifaHook.sol";
14
- //
15
- // // import {CapsulesTypeface} from "../lib/capsules/contracts/CapsulesTypeface.sol";
16
- //
17
- // contract GamePhaseReporter is IDefifaGamePhaseReporter {
18
- // function currentGamePhaseOf(uint256 _gameId) external pure returns (DefifaGamePhase) {
19
- // _gameId;
20
- // return DefifaGamePhase.COUNTDOWN;
21
- // }
22
- // }
23
- //
24
- // contract GamePotReporter is IDefifaGamePotReporter {
25
- // function fulfilledCommitmentsOf(uint256 _gameId) external pure returns (uint256) {
26
- // _gameId;
27
- // return 0;
28
- // }
29
- //
30
- // function currentGamePotOf(uint256 _gameId, bool _includeCommitments)
31
- // external
32
- // pure
33
- // returns (uint256, address, uint256)
34
- // {
35
- // _gameId;
36
- // _includeCommitments;
37
- // return (106900000000000000, JBConstants.NATIVE_TOKEN, 18);
38
- // }
39
- // }
40
- //
41
- // contract SVGTest is Test {
42
- // IJBController _controller;
43
- // IJBDirectory _directory;
44
- // IJBRulesets _fundingCycleStore;
45
- // IJBTiered721DelegateStore _store;
46
- // ITypeface _typeface;
47
- //
48
- // address delegateRegistry = address(0);
49
- //
50
- // function setUp() public {
51
- // vm.createSelectFork("https://rpc.ankr.com/eth");
52
- // _controller = IJBController(0xFFdD70C318915879d5192e8a0dcbFcB0285b3C98);
53
- // _directory = IJBDirectory(0x65572FB928b46f9aDB7cfe5A4c41226F636161ea);
54
- // _fundingCycleStore = IJBFundingCycleStore(0x6f18cF9173136c0B5A6eBF45f19D58d3ff2E17e6);
55
- // _store = IJBTiered721DelegateStore(0x67C31B9557201A341312CF78d315542b5AD83074);
56
- // _typeface = ITypeface(0xA77b7D93E79f1E6B4f77FaB29d9ef85733A3D44A);
57
- // }
58
- //
59
- // event K(bytes4 k);
60
- //
61
- // function testWithTierImage() public {
62
- // emit K(type(IDefifaHook).interfaceId);
63
- // IDefifaHook _hook =
64
- // DefifaHook(Clones.clone(address(new DefifaHook(IERC20(address(0)), IERC20(address(0))))));
65
- // IJB721TokenUriResolver _resolver = new DefifaTokenUriResolver(_typeface);
66
- // IDefifaGamePhaseReporter _gamePhaseReporter = new GamePhaseReporter();
67
- // IDefifaGamePotReporter _gamePotReporter = new GamePotReporter();
68
- //
69
- // JB721TierParams[] memory _tiers = new JB721TierParams[](1);
70
- // _tiers[0] = JB721TierParams({
71
- // price: 1e18,
72
- // initialQuantity: 100,
73
- // votingUnits: 1,
74
- // reservedRate: 0,
75
- // reservedTokenBeneficiary: address(0),
76
- // encodedIPFSUri: bytes32(0xfb17901b2b08444d2bbe92ca39bdd64eab27b0481e841fcd9f14aeb56e28513b),
77
- // category: 0,
78
- // allowManualMint: false,
79
- // shouldUseReservedTokenBeneficiaryAsDefault: false,
80
- // transfersPausable: false,
81
- // useVotingUnits: true
82
- // });
83
- // string[] memory _tierNames = new string[](1);
84
- // _tierNames[0] = "lakers win. no one scores over 40pts.";
85
- //
86
- // _hook.initialize({
87
- // gameId: 12345,
88
- // directory: _directory,
89
- // name: "Example collection",
90
- // symbol: "EX",
91
- // fundingCycleStore: _fundingCycleStore,
92
- // baseUri: "",
93
- // tokenUriResolver: _resolver,
94
- // contractUri: "",
95
- // tiers: _tiers,
96
- // currency: 1,
97
- // store: _store,
98
- // gamePhaseReporter: _gamePhaseReporter,
99
- // gamePotReporter: _gamePotReporter,
100
- // defaultAttestationDelegate: address(0),
101
- // tierNames: _tierNames
102
- // });
103
- //
104
- // string[] memory inputs = new string[](3);
105
- // inputs[0] = "node";
106
- // inputs[1] = "./open.js";
107
- // inputs[2] = _resolver.tokenUriOf(address(_hook), 1000000001);
108
- // bytes memory res = vm.ffi(inputs);
109
- // res;
110
- // vm.ffi(inputs);
111
- // }
112
- //
113
- // function testWithOutTierImage() public {
114
- // IDefifaHook _hook =
115
- // DefifaHook(Clones.clone(address(new DefifaHook(IERC20(address(0)), IERC20(address(0))))));
116
- // DefifaTokenUriResolver _resolver = new DefifaTokenUriResolver(_typeface);
117
- // IDefifaGamePhaseReporter _gamePhaseReporter = new GamePhaseReporter();
118
- // IDefifaGamePotReporter _gamePotReporter = new GamePotReporter();
119
- //
120
- // JB721TierParams[] memory _tiers = new JB721TierParams[](1);
121
- // _tiers[0] = JB721TierParams({
122
- // price: 1e18,
123
- // initialQuantity: 100,
124
- // votingUnits: 0,
125
- // reservedRate: 0,
126
- // reservedTokenBeneficiary: address(0),
127
- // encodedIPFSUri: bytes32(""),
128
- // category: 0,
129
- // allowManualMint: false,
130
- // shouldUseReservedTokenBeneficiaryAsDefault: false,
131
- // transfersPausable: false,
132
- // useVotingUnits: true
133
- // });
134
- //
135
- // string[] memory _tierNames = new string[](1);
136
- // _tierNames[0] = "D in 4";
137
- //
138
- // _hook.initialize({
139
- // gameId: 123,
140
- // directory: _directory,
141
- // name: "NBA Finals (1)",
142
- // symbol: "DEFIFA: EXAMPLE",
143
- // fundingCycleStore: _fundingCycleStore,
144
- // baseUri: "",
145
- // tokenUriResolver: _resolver,
146
- // contractUri: "",
147
- // tiers: _tiers,
148
- // currency: 1,
149
- // store: _store,
150
- // gamePhaseReporter: _gamePhaseReporter,
151
- // gamePotReporter: _gamePotReporter,
152
- // defaultAttestationDelegate: address(0),
153
- // tierNames: _tierNames
154
- // });
155
- //
156
- // string[] memory inputs = new string[](3);
157
- // inputs[0] = "node";
158
- // inputs[1] = "./open.js";
159
- // inputs[2] = _resolver.tokenUriOf(address(_hook), 1000000000);
160
- // bytes memory res = vm.ffi(inputs);
161
- // res;
162
- // vm.ffi(inputs);
163
- // }
164
- // }
@@ -1,144 +0,0 @@
1
- // SPDX-License-Identifier: UNLICENSED
2
- pragma solidity 0.8.28;
3
-
4
- // import '@jbx-protocol/juice-contracts-v3/contracts/libraries/JBTokens.sol';
5
- // import '@jbx-protocol/juice-contracts-v3/contracts/libraries/JBOperations.sol';
6
- // import '@jbx-protocol/juice-contracts-v3/contracts/structs/JBOperatorData.sol';
7
- // import '@jbx-protocol/juice-contracts-v3/contracts/interfaces/IJBOperatable.sol';
8
-
9
- // import '@jbx-protocol/juice-721-delegate/contracts/interfaces/IJBTiered721DelegateStore.sol';
10
-
11
- // import '../DefifaDeployer.sol';
12
- // import '../DefifaGovernor.sol';
13
- // import 'forge-std/Test.sol';
14
-
15
- // // contract DeployMainnet is Script {
16
- // // IJBController jbController = IJBController(0xFFdD70C318915879d5192e8a0dcbFcB0285b3C98);
17
- // // IJBOperatorStore jbOperatorStore = IJBOperatorStore(0x6F3C5afCa0c9eDf3926eF2dDF17c8ae6391afEfb);
18
- // // JBTiered721DelegateDeployer delegateDeployer;
19
- // // JBTiered721DelegateProjectDeployer projectDeployer;
20
- // // JBTiered721DelegateStore store;
21
- // // function run() external {
22
- // // vm.startBroadcast();
23
- // // JBTiered721Delegate noGovernance = new JBTiered721Delegate();
24
- // // JB721GlobalGovernance globalGovernance = new JB721GlobalGovernance();
25
- // // JB721TieredGovernance tieredGovernance = new JB721TieredGovernance();
26
- // // delegateDeployer = new JBTiered721DelegateDeployer(
27
- // // globalGovernance,
28
- // // tieredGovernance,
29
- // // noGovernance
30
- // // );
31
- // // store = new JBTiered721DelegateStore();
32
- // // projectDeployer = new JBTiered721DelegateProjectDeployer(
33
- // // jbController,
34
- // // delegateDeployer,
35
- // // jbOperatorStore
36
- // // );
37
- // // console.log(address(projectDeployer));
38
- // // console.log(address(store));
39
- // // }
40
- // // }
41
- // contract DeployGoerli is Test {
42
- // // V3 goerli controller.
43
- // IJBController controller = IJBController(0x7Cb86D43B665196BC719b6974D320bf674AFb395);
44
- // // goerli 721 store.
45
- // IJBTiered721DelegateStore store = IJBTiered721DelegateStore(0x32bb71C6DbD6A1b3A37394565872D0eB7fF3846D);
46
- // // V3 goerli Payment terminal.
47
- // IJBPaymentTerminal terminal = IJBPaymentTerminal(0x55d4dfb578daA4d60380995ffF7a706471d7c719);
48
-
49
- // DefifaDeployer defifaDeployer;
50
- // DefifaGovernor defifaGovernor;
51
-
52
- // // Tier standard params.
53
- // uint80 _contributionFloor = 0.022 ether;
54
- // uint40 _maxInitialQuantity = 1_000_000_000 - 1;
55
- // uint16 _votingUnits = 1;
56
-
57
- // // Game params.
58
- // uint256 _mustStartAtOrAfter = 0;
59
- // uint48 _mintDuration = 0;
60
- // uint48 _start = 0;
61
- // uint48 _tradeDeadline = 0;
62
- // uint48 _end = 0;
63
-
64
- // function test_deployGoerli() external {
65
- // //vm.startBroadcast();
66
-
67
- // JB721TierParams[] memory _tiers = new JB721TierParams[](1);
68
- // _tiers[0] = JB721TierParams({
69
- // contributionFloor: _contributionFloor,
70
- // lockedUntil: 0,
71
- // initialQuantity: _maxInitialQuantity,
72
- // votingUnits: _votingUnits,
73
- // reservedRate: 0,
74
- // reservedTokenBeneficiary: address(0),
75
- // encodedIPFSUri: bytes32(''),
76
- // allowManualMint: false,
77
- // shouldUseBeneficiaryAsDefault: true,
78
- // transfersPausable: true
79
- // });
80
-
81
- // DefifaHookData memory _delegateData =
82
- // DefifaHookData({
83
- // name: 'Defifa: FIFA World Cup 2022',
84
- // symbol: 'DEFIFA',
85
- // // TODO: Need a base URI.
86
- // baseUri: '',
87
- // // TODO: Need a contract URI.
88
- // contractUri: '',
89
- // tiers: _tiers,
90
- // store: store,
91
- // // TODO: set owner as the Governor that is being deployed.
92
- // owner: address(0)
93
- // });
94
-
95
- // DefifaLaunchProjectData memory _launchProjectData =
96
- // DefifaLaunchProjectData({
97
- // projectMetadata: JBProjectMetadata({
98
- // content: '',
99
- // domain: 0
100
- // }),
101
- // mustStartAtOrAfter: _mustStartAtOrAfter,
102
- // mintDuration: _mintDuration,
103
- // start: _start,
104
- // tradeDeadline: _tradeDeadline,
105
- // holdFees: false,
106
- // splits: new JBSplit[](0),
107
- // distributionLimit: 0,
108
- // terminal: terminal
109
- // });
110
-
111
- // // Deploy the codeOrigin for the hook
112
- // DefifaHook _defifaHookCodeOrigin = new DefifaHook();
113
-
114
- // // Deploy the deployer.
115
- // defifaDeployer = new DefifaDeployer(address(_defifaHookCodeOrigin), controller, JBTokens.ETH);
116
-
117
- // uint256[] memory _permissionIndexes = new uint256[](1);
118
- // _permissionIndexes[0] = JBOperations.SET_SPLITS;
119
-
120
- // vm.startPrank(0x46D623731E179FAF971CdA04fF8c499C95461b3c);
121
- // IJBOperatable(address(terminal)).operatorStore().setOperator(JBOperatorData({operator: address(defifaDeployer),
122
- // domain: 1, permissionIndexes: _permissionIndexes})); vm.stopPrank();
123
-
124
- // // Set the owner as the governor (done here to easily count future nonces)
125
- // _delegateData.owner = computeCreateAddress(address(this), vm.getNonce(address(this)) + 1);
126
- // console.log(_delegateData.owner);
127
-
128
- // // Launch the game - initialNonce
129
- // uint256 _projectId = defifaDeployer.launchGameWith(_delegateData, _launchProjectData);
130
- // // initialNonce + 1
131
-
132
- // // Get a reference to the latest configured funding cycle's data source, which should be the hook that was
133
- // deployed and attached to the project. (, JBFundingCycleMetadata memory _metadata,) =
134
- // controller.latestConfiguredFundingCycleOf(_projectId);
135
- // // initialNonce + 1 (view function)
136
-
137
- // // Deploy the governor
138
- // defifaGovernor = new DefifaGovernor(DefifaHook(_metadata.dataSource), 0);
139
-
140
- // console.log(address(defifaDeployer));
141
- // console.log(address(store));
142
- // }
143
-
144
- // }