@ballkidz/defifa 0.0.1
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/.gas-snapshot +2 -0
- package/CRYPTO_ECON.md +955 -0
- package/CRYPTO_ECON.pdf +0 -0
- package/CRYPTO_ECON.tex +800 -0
- package/README.md +119 -0
- package/SKILLS.md +177 -0
- package/deployments/defifa-v5/arbitrum_sepolia/DefifaDelegate.json +4867 -0
- package/deployments/defifa-v5/arbitrum_sepolia/DefifaDeployer.json +1719 -0
- package/deployments/defifa-v5/arbitrum_sepolia/DefifaGovernor.json +1535 -0
- package/deployments/defifa-v5/arbitrum_sepolia/DefifaTokenUriResolver.json +295 -0
- package/deployments/defifa-v5/base_sepolia/DefifaDelegate.json +4875 -0
- package/deployments/defifa-v5/base_sepolia/DefifaDeployer.json +1725 -0
- package/deployments/defifa-v5/base_sepolia/DefifaGovernor.json +1543 -0
- package/deployments/defifa-v5/base_sepolia/DefifaTokenUriResolver.json +301 -0
- package/deployments/defifa-v5/optimism_sepolia/DefifaDelegate.json +4875 -0
- package/deployments/defifa-v5/optimism_sepolia/DefifaDeployer.json +1725 -0
- package/deployments/defifa-v5/optimism_sepolia/DefifaGovernor.json +1543 -0
- package/deployments/defifa-v5/optimism_sepolia/DefifaTokenUriResolver.json +301 -0
- package/deployments/defifa-v5/sepolia/DefifaDelegate.json +4875 -0
- package/deployments/defifa-v5/sepolia/DefifaDeployer.json +1725 -0
- package/deployments/defifa-v5/sepolia/DefifaGovernor.json +1543 -0
- package/deployments/defifa-v5/sepolia/DefifaTokenUriResolver.json +301 -0
- package/foundry.lock +17 -0
- package/foundry.toml +35 -0
- package/package.json +33 -0
- package/remappings.txt +6 -0
- package/script/Deploy.s.sol +109 -0
- package/script/helpers/DefifaDeploymentLib.sol +83 -0
- package/slither-ci.config.json +10 -0
- package/sphinx.lock +521 -0
- package/src/DefifaDeployer.sol +894 -0
- package/src/DefifaGovernor.sol +490 -0
- package/src/DefifaHook.sol +1056 -0
- package/src/DefifaProjectOwner.sol +63 -0
- package/src/DefifaTokenUriResolver.sol +312 -0
- package/src/enums/DefifaGamePhase.sol +11 -0
- package/src/enums/DefifaScorecardState.sol +10 -0
- package/src/interfaces/IDefifaDeployer.sol +108 -0
- package/src/interfaces/IDefifaGamePhaseReporter.sol +8 -0
- package/src/interfaces/IDefifaGamePotReporter.sol +8 -0
- package/src/interfaces/IDefifaGovernor.sol +132 -0
- package/src/interfaces/IDefifaHook.sol +228 -0
- package/src/interfaces/IDefifaTokenUriResolver.sol +10 -0
- package/src/libraries/DefifaFontImporter.sol +19 -0
- package/src/libraries/DefifaHookLib.sol +358 -0
- package/src/structs/DefifaAttestations.sol +9 -0
- package/src/structs/DefifaDelegation.sol +9 -0
- package/src/structs/DefifaLaunchProjectData.sol +59 -0
- package/src/structs/DefifaOpsData.sol +20 -0
- package/src/structs/DefifaScorecard.sol +9 -0
- package/src/structs/DefifaTierCashOutWeight.sol +9 -0
- package/src/structs/DefifaTierParams.sol +16 -0
- package/test/DefifaFeeAccounting.t.sol +559 -0
- package/test/DefifaGovernor.t.sol +1333 -0
- package/test/DefifaMintCostInvariant.t.sol +299 -0
- package/test/DefifaNoContest.t.sol +922 -0
- package/test/DefifaSecurity.t.sol +717 -0
- package/test/SVG.t.sol +164 -0
- package/test/deployScript.t.sol +144 -0
package/foundry.lock
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
{
|
|
2
|
+
"lib/base64": {
|
|
3
|
+
"branch": {
|
|
4
|
+
"name": "v1.1.0",
|
|
5
|
+
"rev": "dcbf852ba545b3d15de0ac0ef88dce934c090c8e"
|
|
6
|
+
}
|
|
7
|
+
},
|
|
8
|
+
"lib/capsules": {
|
|
9
|
+
"rev": "7432ba95ac69ba4902076660b0dc9a90aeb26706"
|
|
10
|
+
},
|
|
11
|
+
"lib/forge-std": {
|
|
12
|
+
"rev": "8bbcf6e3f8f62f419e5429a0bd89331c85c37824"
|
|
13
|
+
},
|
|
14
|
+
"lib/typeface": {
|
|
15
|
+
"rev": "edd52e2f7c8adc44e75b207bd279710f9b72f5e9"
|
|
16
|
+
}
|
|
17
|
+
}
|
package/foundry.toml
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
[profile.default]
|
|
2
|
+
solc = '0.8.26'
|
|
3
|
+
evm_version = 'paris'
|
|
4
|
+
src = 'src'
|
|
5
|
+
out = 'out'
|
|
6
|
+
test = 'test'
|
|
7
|
+
libs = ["node_modules", "lib"]
|
|
8
|
+
optimizer_runs = 200
|
|
9
|
+
via-ir = true
|
|
10
|
+
build_info = true
|
|
11
|
+
extra_output = ['storageLayout']
|
|
12
|
+
fs_permissions = [{ access = "read-write", path = "./"}]
|
|
13
|
+
|
|
14
|
+
[rpc_endpoints]
|
|
15
|
+
ethereum = "${RPC_ETHEREUM_MAINNET}"
|
|
16
|
+
optimism = "${RPC_OPTIMISM_MAINNET}"
|
|
17
|
+
arbitrum = "${RPC_ARBITRUM_MAINNET}"
|
|
18
|
+
base = "${RPC_BASE_MAINNET}"
|
|
19
|
+
arbitrum_sepolia = "${RPC_ARBITRUM_SEPOLIA}"
|
|
20
|
+
ethereum_sepolia = "${RPC_ETHEREUM_SEPOLIA}"
|
|
21
|
+
optimism_sepolia = "${RPC_OPTIMISM_SEPOLIA}"
|
|
22
|
+
base_sepolia = "${RPC_BASE_SEPOLIA}"
|
|
23
|
+
|
|
24
|
+
[invariant]
|
|
25
|
+
runs = 256
|
|
26
|
+
depth = 50
|
|
27
|
+
fail_on_revert = false
|
|
28
|
+
|
|
29
|
+
[lint]
|
|
30
|
+
lint_on_build = false
|
|
31
|
+
|
|
32
|
+
[fmt]
|
|
33
|
+
number_underscore = "thousands"
|
|
34
|
+
multiline_func_header = "all"
|
|
35
|
+
wrap_comments = true
|
package/package.json
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@ballkidz/defifa",
|
|
3
|
+
"version": "0.0.1",
|
|
4
|
+
"license": "MIT",
|
|
5
|
+
"engines": {
|
|
6
|
+
"node": ">=20.0.0"
|
|
7
|
+
},
|
|
8
|
+
"bugs": {
|
|
9
|
+
"url": "https://github.com/BallKidz/defifa-collection-deployer/issues"
|
|
10
|
+
},
|
|
11
|
+
"repository": {
|
|
12
|
+
"type": "git",
|
|
13
|
+
"url": "https://github.com/BallKidz/defifa-collection-deployer"
|
|
14
|
+
},
|
|
15
|
+
"dependencies": {
|
|
16
|
+
"@bananapus/721-hook-v6": "^0.0.8",
|
|
17
|
+
"@bananapus/address-registry-v6": "^0.0.3",
|
|
18
|
+
"@bananapus/core-v6": "^0.0.6",
|
|
19
|
+
"@bananapus/permission-ids-v6": "^0.0.3",
|
|
20
|
+
"@openzeppelin/contracts": "5.2.0",
|
|
21
|
+
"@prb/math": "^4.1.1",
|
|
22
|
+
"scripty.sol": "^2.1.1"
|
|
23
|
+
},
|
|
24
|
+
"devDependencies": {
|
|
25
|
+
"@sphinx-labs/plugins": "^0.33.1"
|
|
26
|
+
},
|
|
27
|
+
"scripts": {
|
|
28
|
+
"test": "forge test",
|
|
29
|
+
"coverage": "forge coverage",
|
|
30
|
+
"deploy:mainnets": "source ./.env && npx sphinx propose ./script/Deploy.s.sol --networks mainnets",
|
|
31
|
+
"deploy:testnets": "source ./.env && npx sphinx propose ./script/Deploy.s.sol --networks testnets"
|
|
32
|
+
}
|
|
33
|
+
}
|
package/remappings.txt
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
@openzeppelin/=node_modules/@openzeppelin/
|
|
2
|
+
@prb/math/=node_modules/@prb/math/
|
|
3
|
+
@bananapus/=node_modules/@bananapus/
|
|
4
|
+
@sphinx-labs/contracts/=node_modules/@sphinx-labs/contracts/contracts/foundry/
|
|
5
|
+
forge-std/=lib/forge-std/src/
|
|
6
|
+
scripty.sol/=node_modules/scripty.sol/
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
// SPDX-License-Identifier: MIT
|
|
2
|
+
pragma solidity 0.8.26;
|
|
3
|
+
|
|
4
|
+
import {Script} from "forge-std/Script.sol";
|
|
5
|
+
import {ITypeface} from "lib/typeface/contracts/interfaces/ITypeface.sol";
|
|
6
|
+
import {IERC20} from "@openzeppelin/contracts/token/ERC20/IERC20.sol";
|
|
7
|
+
import {DefifaHook} from "../src/DefifaHook.sol";
|
|
8
|
+
import {DefifaDeployer} from "../src/DefifaDeployer.sol";
|
|
9
|
+
import {DefifaGovernor} from "../src/DefifaGovernor.sol";
|
|
10
|
+
import {DefifaProjectOwner} from "../src/DefifaProjectOwner.sol";
|
|
11
|
+
import {DefifaTokenUriResolver} from "../src/DefifaTokenUriResolver.sol";
|
|
12
|
+
import {Sphinx} from "@sphinx-labs/contracts/SphinxPlugin.sol";
|
|
13
|
+
|
|
14
|
+
import {CoreDeployment, CoreDeploymentLib} from "@bananapus/core-v6/script/helpers/CoreDeploymentLib.sol";
|
|
15
|
+
import {
|
|
16
|
+
AddressRegistryDeployment,
|
|
17
|
+
AddressRegistryDeploymentLib
|
|
18
|
+
} from "@bananapus/address-registry-v6/script/helpers/AddressRegistryDeploymentLib.sol";
|
|
19
|
+
|
|
20
|
+
contract DeployMainnet is Script, Sphinx {
|
|
21
|
+
/// @notice tracks the deployment of the core contracts for the chain we are deploying to.
|
|
22
|
+
CoreDeployment core;
|
|
23
|
+
/// @notice tracks the deployment of the address registry for the chain we are deploying to.
|
|
24
|
+
AddressRegistryDeployment registry;
|
|
25
|
+
|
|
26
|
+
// NOTE: This id is revnet, this is temporary until we have a defifa revnet.
|
|
27
|
+
uint256 _defifaProjectId = 3;
|
|
28
|
+
uint256 _baseProtocolProjectId = 1;
|
|
29
|
+
|
|
30
|
+
bytes32 _salt = bytes32(keccak256("0.0.2"));
|
|
31
|
+
|
|
32
|
+
ITypeface _typeface = ITypeface(0xA77b7D93E79f1E6B4f77FaB29d9ef85733A3D44A);
|
|
33
|
+
|
|
34
|
+
IERC20 defifaToken;
|
|
35
|
+
IERC20 baseProtocolToken;
|
|
36
|
+
|
|
37
|
+
function configureSphinx() public override {
|
|
38
|
+
sphinxConfig.projectName = "defifa-v5";
|
|
39
|
+
sphinxConfig.mainnets = ["ethereum", "optimism", "base", "arbitrum"];
|
|
40
|
+
sphinxConfig.testnets = ["ethereum_sepolia", "optimism_sepolia", "base_sepolia", "arbitrum_sepolia"];
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
function run() external {
|
|
44
|
+
// Get the deployment addresses for the nana CORE for this chain.
|
|
45
|
+
// We want to do this outside of the `sphinx` modifier.
|
|
46
|
+
core = CoreDeploymentLib.getDeployment(
|
|
47
|
+
vm.envOr("NANA_CORE_DEPLOYMENT_PATH", string("node_modules/@bananapus/core-v6/deployments/"))
|
|
48
|
+
);
|
|
49
|
+
|
|
50
|
+
registry = AddressRegistryDeploymentLib.getDeployment(
|
|
51
|
+
vm.envOr(
|
|
52
|
+
"NANA_ADDRESS_REGISTRY_DEPLOYMENT_PATH",
|
|
53
|
+
string("node_modules/@bananapus/address-registry-v6/deployments/")
|
|
54
|
+
)
|
|
55
|
+
);
|
|
56
|
+
|
|
57
|
+
defifaToken = IERC20(address(core.tokens.tokenOf(_defifaProjectId)));
|
|
58
|
+
baseProtocolToken = IERC20(address(core.tokens.tokenOf(_baseProtocolProjectId)));
|
|
59
|
+
|
|
60
|
+
if (defifaToken == IERC20(address(0))) {
|
|
61
|
+
revert("Defifa token is invalid, does this project id exist?");
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
if (baseProtocolToken == IERC20(address(0))) {
|
|
65
|
+
revert("Base protocol token is invalid, does this project id exist?");
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
// Sepolia.
|
|
69
|
+
if (block.chainid == 11_155_111) {
|
|
70
|
+
_typeface = ITypeface(0x8C420d3388C882F40d263714d7A6e2c8DB93905F);
|
|
71
|
+
|
|
72
|
+
// Optimism sepolia.
|
|
73
|
+
} else if (block.chainid == 11_155_420) {
|
|
74
|
+
_typeface = ITypeface(0xe160e47928907894F97a0DC025c61D64E862fEAa);
|
|
75
|
+
|
|
76
|
+
// Base sepolia.
|
|
77
|
+
} else if (block.chainid == 84_532) {
|
|
78
|
+
_typeface = ITypeface(0xEb269d9F0850CEf5e3aB0F9718fb79c466720784);
|
|
79
|
+
|
|
80
|
+
// Arb sepolia.
|
|
81
|
+
} else if (block.chainid == 421_614) {
|
|
82
|
+
_typeface = ITypeface(0x431C35e9fA5152A906A38390910d0Cfcba0Fb43b);
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
// Check that the typeface is set and that the address contains code.
|
|
86
|
+
require(address(_typeface) != address(0), "Typeface address is not configured for this chain");
|
|
87
|
+
require(address(_typeface).code.length > 0, "Typeface address is not deployed to this address for this chain");
|
|
88
|
+
|
|
89
|
+
// Perform the deployment transactions.
|
|
90
|
+
deploy();
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
function deploy() public sphinx {
|
|
94
|
+
DefifaHook hook = new DefifaHook{salt: _salt}(core.directory, defifaToken, baseProtocolToken);
|
|
95
|
+
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
|
+
);
|
|
106
|
+
|
|
107
|
+
governor.transferOwnership(address(deployer));
|
|
108
|
+
}
|
|
109
|
+
}
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
// SPDX-License-Identifier: MIT
|
|
2
|
+
pragma solidity 0.8.26;
|
|
3
|
+
|
|
4
|
+
import {stdJson} from "forge-std/Script.sol";
|
|
5
|
+
import {Vm} from "forge-std/Vm.sol";
|
|
6
|
+
|
|
7
|
+
import {DefifaHook} from "../../src/DefifaHook.sol";
|
|
8
|
+
import {DefifaDeployer} from "../../src/DefifaDeployer.sol";
|
|
9
|
+
import {DefifaGovernor} from "../../src/DefifaGovernor.sol";
|
|
10
|
+
import {DefifaTokenUriResolver} from "../../src/DefifaTokenUriResolver.sol";
|
|
11
|
+
|
|
12
|
+
import {SphinxConstants, NetworkInfo} from "@sphinx-labs/contracts/SphinxConstants.sol";
|
|
13
|
+
|
|
14
|
+
struct DefifaDeployment {
|
|
15
|
+
DefifaHook hook;
|
|
16
|
+
DefifaDeployer deployer;
|
|
17
|
+
DefifaGovernor governor;
|
|
18
|
+
DefifaTokenUriResolver tokenUriResolver;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
library DefifaDeploymentLib {
|
|
22
|
+
// Cheat code address, 0x7109709ECfa91a80626fF3989D68f67F5b1DD12D.
|
|
23
|
+
address internal constant VM_ADDRESS = address(uint160(uint256(keccak256("hevm cheat code"))));
|
|
24
|
+
Vm internal constant vm = Vm(VM_ADDRESS);
|
|
25
|
+
string constant PROJECT_NAME = "defifa-v5";
|
|
26
|
+
|
|
27
|
+
function getDeployment(string memory path) internal returns (DefifaDeployment memory deployment) {
|
|
28
|
+
// Get chainId for which we need to get the deployment.
|
|
29
|
+
uint256 chainId = block.chainid;
|
|
30
|
+
|
|
31
|
+
// Deploy to get the constants.
|
|
32
|
+
SphinxConstants sphinxConstants = new SphinxConstants();
|
|
33
|
+
NetworkInfo[] memory networks = sphinxConstants.getNetworkInfoArray();
|
|
34
|
+
|
|
35
|
+
for (uint256 _i; _i < networks.length; _i++) {
|
|
36
|
+
if (networks[_i].chainId == chainId) {
|
|
37
|
+
return getDeployment(path, networks[_i].name);
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
revert("ChainID is not (currently) supported by Sphinx.");
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
function getDeployment(
|
|
45
|
+
string memory path,
|
|
46
|
+
string memory network_name
|
|
47
|
+
)
|
|
48
|
+
internal
|
|
49
|
+
view
|
|
50
|
+
returns (DefifaDeployment memory deployment)
|
|
51
|
+
{
|
|
52
|
+
deployment.hook = DefifaHook(_getDeploymentAddress(path, PROJECT_NAME, network_name, "DefifaHook"));
|
|
53
|
+
|
|
54
|
+
deployment.deployer = DefifaDeployer(_getDeploymentAddress(path, PROJECT_NAME, network_name, "DefifaDeployer"));
|
|
55
|
+
|
|
56
|
+
deployment.governor = DefifaGovernor(_getDeploymentAddress(path, PROJECT_NAME, network_name, "DefifaGovernor"));
|
|
57
|
+
|
|
58
|
+
deployment.tokenUriResolver =
|
|
59
|
+
DefifaTokenUriResolver(_getDeploymentAddress(path, PROJECT_NAME, network_name, "DefifaTokenUriResolver"));
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
/// @notice Get the address of a contract that was deployed by the Deploy script.
|
|
63
|
+
/// @dev Reverts if the contract was not found.
|
|
64
|
+
/// @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.
|
|
67
|
+
/// @param contractName The name of the contract to get the address of.
|
|
68
|
+
/// @return The address of the contract.
|
|
69
|
+
function _getDeploymentAddress(
|
|
70
|
+
string memory path,
|
|
71
|
+
string memory project_name,
|
|
72
|
+
string memory network_name,
|
|
73
|
+
string memory contractName
|
|
74
|
+
)
|
|
75
|
+
internal
|
|
76
|
+
view
|
|
77
|
+
returns (address)
|
|
78
|
+
{
|
|
79
|
+
string memory deploymentJson =
|
|
80
|
+
vm.readFile(string.concat(path, project_name, "/", network_name, "/", contractName, ".json"));
|
|
81
|
+
return stdJson.readAddress(deploymentJson, ".address");
|
|
82
|
+
}
|
|
83
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
{
|
|
2
|
+
"detectors_to_exclude": "timestamp,uninitialized-local,naming-convention,solc-version,shadowing-local",
|
|
3
|
+
"exclude_informational": true,
|
|
4
|
+
"exclude_low": false,
|
|
5
|
+
"exclude_medium": false,
|
|
6
|
+
"exclude_high": false,
|
|
7
|
+
"disable_color": false,
|
|
8
|
+
"filter_paths": "(mocks/|test/|node_modules/|lib/)",
|
|
9
|
+
"legacy_ast": false
|
|
10
|
+
}
|