@ballkidz/defifa 0.0.6 → 0.0.8

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 (47) hide show
  1. package/ADMINISTRATION.md +3 -3
  2. package/AUDIT_INSTRUCTIONS.md +422 -0
  3. package/CRYPTO_ECON.md +5 -5
  4. package/RISKS.md +38 -335
  5. package/SKILLS.md +1 -1
  6. package/STYLE_GUIDE.md +14 -1
  7. package/USER_JOURNEYS.md +691 -0
  8. package/package.json +7 -5
  9. package/script/Deploy.s.sol +26 -13
  10. package/script/helpers/DefifaDeploymentLib.sol +30 -14
  11. package/src/DefifaDeployer.sol +225 -187
  12. package/src/DefifaGovernor.sol +291 -281
  13. package/src/DefifaHook.sol +81 -42
  14. package/src/DefifaProjectOwner.sol +27 -4
  15. package/src/DefifaTokenUriResolver.sol +137 -134
  16. package/src/enums/DefifaGamePhase.sol +1 -1
  17. package/src/enums/DefifaScorecardState.sol +1 -1
  18. package/src/interfaces/IDefifaDeployer.sol +52 -50
  19. package/src/interfaces/IDefifaGamePhaseReporter.sol +2 -2
  20. package/src/interfaces/IDefifaGamePotReporter.sol +1 -1
  21. package/src/interfaces/IDefifaGovernor.sol +53 -54
  22. package/src/interfaces/IDefifaHook.sol +104 -103
  23. package/src/interfaces/IDefifaTokenUriResolver.sol +2 -2
  24. package/src/libraries/DefifaFontImporter.sol +11 -9
  25. package/src/libraries/DefifaHookLib.sol +68 -53
  26. package/src/structs/DefifaAttestations.sol +1 -1
  27. package/src/structs/DefifaDelegation.sol +1 -1
  28. package/src/structs/DefifaLaunchProjectData.sol +4 -4
  29. package/src/structs/DefifaOpsData.sol +1 -1
  30. package/src/structs/DefifaScorecard.sol +1 -1
  31. package/src/structs/DefifaTierCashOutWeight.sol +1 -1
  32. package/src/structs/DefifaTierParams.sol +2 -1
  33. package/test/DefifaAdversarialQuorum.t.sol +602 -0
  34. package/test/DefifaAuditLowGuards.t.sol +304 -0
  35. package/test/DefifaFeeAccounting.t.sol +37 -16
  36. package/test/DefifaGovernor.t.sol +37 -11
  37. package/test/DefifaHookRegressions.t.sol +14 -12
  38. package/test/DefifaMintCostInvariant.t.sol +31 -12
  39. package/test/DefifaNoContest.t.sol +33 -13
  40. package/test/DefifaSecurity.t.sol +45 -25
  41. package/test/DefifaUSDC.t.sol +44 -34
  42. package/test/Fork.t.sol +42 -40
  43. package/test/SVG.t.sol +2 -2
  44. package/test/TestAuditGaps.sol +982 -0
  45. package/test/TestQALastMile.t.sol +511 -0
  46. package/test/regression/FulfillmentBlocksRatification.t.sol +36 -30
  47. package/test/regression/GracePeriodBypass.t.sol +15 -10
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ballkidz/defifa",
3
- "version": "0.0.6",
3
+ "version": "0.0.8",
4
4
  "license": "MIT",
5
5
  "engines": {
6
6
  "node": ">=20.0.0"
@@ -13,12 +13,14 @@
13
13
  "url": "https://github.com/BallKidz/defifa-collection-deployer"
14
14
  },
15
15
  "dependencies": {
16
- "@bananapus/721-hook-v6": "^0.0.14",
17
- "@bananapus/address-registry-v6": "^0.0.8",
18
- "@bananapus/core-v6": "^0.0.15",
19
- "@bananapus/permission-ids-v6": "^0.0.8",
16
+ "@bananapus/721-hook-v6": "^0.0.17",
17
+ "@bananapus/address-registry-v6": "^0.0.10",
18
+ "@bananapus/core-v6": "^0.0.17",
19
+ "@bananapus/permission-ids-v6": "^0.0.10",
20
+ "@croptop/core-v6": "^0.0.18",
20
21
  "@openzeppelin/contracts": "^5.6.1",
21
22
  "@prb/math": "^4.1.1",
23
+ "@rev-net/core-v6": "^0.0.13",
22
24
  "scripty.sol": "^2.1.1"
23
25
  },
24
26
  "devDependencies": {
@@ -7,7 +7,6 @@ import {IERC20} from "@openzeppelin/contracts/token/ERC20/IERC20.sol";
7
7
  import {DefifaHook} from "../src/DefifaHook.sol";
8
8
  import {DefifaDeployer} from "../src/DefifaDeployer.sol";
9
9
  import {DefifaGovernor} from "../src/DefifaGovernor.sol";
10
- import {DefifaProjectOwner} from "../src/DefifaProjectOwner.sol";
11
10
  import {DefifaTokenUriResolver} from "../src/DefifaTokenUriResolver.sol";
12
11
  import {Sphinx} from "@sphinx-labs/contracts/contracts/foundry/SphinxPlugin.sol";
13
12
 
@@ -35,7 +34,7 @@ contract DeployMainnet is Script, Sphinx {
35
34
  IERC20 baseProtocolToken;
36
35
 
37
36
  function configureSphinx() public override {
38
- sphinxConfig.projectName = "defifa-v5";
37
+ sphinxConfig.projectName = "defifa-v6";
39
38
  sphinxConfig.mainnets = ["ethereum", "optimism", "base", "arbitrum"];
40
39
  sphinxConfig.testnets = ["ethereum_sepolia", "optimism_sepolia", "base_sepolia", "arbitrum_sepolia"];
41
40
  }
@@ -69,14 +68,26 @@ contract DeployMainnet is Script, Sphinx {
69
68
  if (block.chainid == 11_155_111) {
70
69
  _typeface = ITypeface(0x8C420d3388C882F40d263714d7A6e2c8DB93905F);
71
70
 
71
+ // Optimism.
72
+ } else if (block.chainid == 10) {
73
+ _typeface = ITypeface(0xe160e47928907894F97a0DC025c61D64E862fEAa);
74
+
72
75
  // Optimism sepolia.
73
76
  } else if (block.chainid == 11_155_420) {
74
77
  _typeface = ITypeface(0xe160e47928907894F97a0DC025c61D64E862fEAa);
75
78
 
79
+ // Base.
80
+ } else if (block.chainid == 8453) {
81
+ _typeface = ITypeface(0x3DE45A14ea0fe24037D6363Ae71Ef18F336D1C27);
82
+
76
83
  // Base sepolia.
77
84
  } else if (block.chainid == 84_532) {
78
85
  _typeface = ITypeface(0xEb269d9F0850CEf5e3aB0F9718fb79c466720784);
79
86
 
87
+ // Arbitrum.
88
+ } else if (block.chainid == 42_161) {
89
+ _typeface = ITypeface(0x431C35e9fA5152A906A38390910d0Cfcba0Fb43b);
90
+
80
91
  // Arb sepolia.
81
92
  } else if (block.chainid == 421_614) {
82
93
  _typeface = ITypeface(0x431C35e9fA5152A906A38390910d0Cfcba0Fb43b);
@@ -91,18 +102,20 @@ contract DeployMainnet is Script, Sphinx {
91
102
  }
92
103
 
93
104
  function deploy() public sphinx {
94
- DefifaHook hook = new DefifaHook{salt: _salt}(core.directory, defifaToken, baseProtocolToken);
105
+ DefifaHook hook = new DefifaHook{salt: _salt}({
106
+ _directory: core.directory, _defifaToken: defifaToken, _baseProtocolToken: baseProtocolToken
107
+ });
95
108
  DefifaTokenUriResolver tokenUriResolver = new DefifaTokenUriResolver{salt: _salt}(_typeface);
96
- DefifaGovernor governor = new DefifaGovernor{salt: _salt}(core.controller, safeAddress());
97
- DefifaDeployer deployer = new DefifaDeployer{salt: _salt}(
98
- address(hook),
99
- tokenUriResolver,
100
- governor,
101
- core.controller,
102
- registry.registry,
103
- _defifaProjectId,
104
- _baseProtocolProjectId
105
- );
109
+ DefifaGovernor governor = new DefifaGovernor{salt: _salt}({controller: core.controller, owner: safeAddress()});
110
+ DefifaDeployer deployer = new DefifaDeployer{salt: _salt}({
111
+ _hookCodeOrigin: address(hook),
112
+ _tokenUriResolver: tokenUriResolver,
113
+ _governor: governor,
114
+ _controller: core.controller,
115
+ _registry: registry.registry,
116
+ _defifaProjectId: _defifaProjectId,
117
+ _baseProtocolProjectId: _baseProtocolProjectId
118
+ });
106
119
 
107
120
  governor.transferOwnership(address(deployer));
108
121
  }
@@ -21,7 +21,7 @@ struct DefifaDeployment {
21
21
  library DefifaDeploymentLib {
22
22
  // Cheat code address, 0x7109709ECfa91a80626fF3989D68f67F5b1DD12D.
23
23
  address internal constant VM_ADDRESS = address(uint160(uint256(keccak256("hevm cheat code"))));
24
- Vm internal constant vm = Vm(VM_ADDRESS);
24
+ Vm internal constant VM = Vm(VM_ADDRESS);
25
25
  string constant PROJECT_NAME = "defifa-v5";
26
26
 
27
27
  function getDeployment(string memory path) internal returns (DefifaDeployment memory deployment) {
@@ -34,7 +34,7 @@ library DefifaDeploymentLib {
34
34
 
35
35
  for (uint256 _i; _i < networks.length; _i++) {
36
36
  if (networks[_i].chainId == chainId) {
37
- return getDeployment(path, networks[_i].name);
37
+ return getDeployment({path: path, networkName: networks[_i].name});
38
38
  }
39
39
  }
40
40
 
@@ -43,33 +43,48 @@ library DefifaDeploymentLib {
43
43
 
44
44
  function getDeployment(
45
45
  string memory path,
46
- string memory network_name
46
+ string memory networkName
47
47
  )
48
48
  internal
49
49
  view
50
50
  returns (DefifaDeployment memory deployment)
51
51
  {
52
- deployment.hook = DefifaHook(_getDeploymentAddress(path, PROJECT_NAME, network_name, "DefifaHook"));
52
+ deployment.hook = DefifaHook(
53
+ _getDeploymentAddress({
54
+ path: path, projectName: PROJECT_NAME, networkName: networkName, contractName: "DefifaHook"
55
+ })
56
+ );
53
57
 
54
- deployment.deployer = DefifaDeployer(_getDeploymentAddress(path, PROJECT_NAME, network_name, "DefifaDeployer"));
58
+ deployment.deployer = DefifaDeployer(
59
+ _getDeploymentAddress({
60
+ path: path, projectName: PROJECT_NAME, networkName: networkName, contractName: "DefifaDeployer"
61
+ })
62
+ );
55
63
 
56
- deployment.governor = DefifaGovernor(_getDeploymentAddress(path, PROJECT_NAME, network_name, "DefifaGovernor"));
64
+ deployment.governor = DefifaGovernor(
65
+ _getDeploymentAddress({
66
+ path: path, projectName: PROJECT_NAME, networkName: networkName, contractName: "DefifaGovernor"
67
+ })
68
+ );
57
69
 
58
- deployment.tokenUriResolver =
59
- DefifaTokenUriResolver(_getDeploymentAddress(path, PROJECT_NAME, network_name, "DefifaTokenUriResolver"));
70
+ deployment.tokenUriResolver = DefifaTokenUriResolver(
71
+ _getDeploymentAddress({
72
+ path: path, projectName: PROJECT_NAME, networkName: networkName, contractName: "DefifaTokenUriResolver"
73
+ })
74
+ );
60
75
  }
61
76
 
62
77
  /// @notice Get the address of a contract that was deployed by the Deploy script.
63
78
  /// @dev Reverts if the contract was not found.
64
79
  /// @param path The path to the deployment file.
65
- /// @param project_name The name of the project.
66
- /// @param network_name The name of the network.
80
+ /// @param projectName The name of the project.
81
+ /// @param networkName The name of the network.
67
82
  /// @param contractName The name of the contract to get the address of.
68
83
  /// @return The address of the contract.
69
84
  function _getDeploymentAddress(
70
85
  string memory path,
71
- string memory project_name,
72
- string memory network_name,
86
+ string memory projectName,
87
+ string memory networkName,
73
88
  string memory contractName
74
89
  )
75
90
  internal
@@ -77,7 +92,8 @@ library DefifaDeploymentLib {
77
92
  returns (address)
78
93
  {
79
94
  string memory deploymentJson =
80
- vm.readFile(string.concat(path, project_name, "/", network_name, "/", contractName, ".json"));
81
- return stdJson.readAddress(deploymentJson, ".address");
95
+ // forge-lint: disable-next-line(unsafe-cheatcode)
96
+ VM.readFile(string.concat(path, projectName, "/", networkName, "/", contractName, ".json"));
97
+ return stdJson.readAddress({json: deploymentJson, key: ".address"});
82
98
  }
83
99
  }