-
Notifications
You must be signed in to change notification settings - Fork 5
/
Deploy.s.sol
120 lines (104 loc) · 5.37 KB
/
Deploy.s.sol
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
// SPDX-License-Identifier: MIT
pragma solidity 0.8.23;
import "@sphinx-labs/contracts/SphinxPlugin.sol";
import {Script, stdJson, VmSafe} from "forge-std/Script.sol";
import {CoreDeploymentLib} from "./helpers/CoreDeploymentLib.sol";
import {IPermit2} from "@uniswap/permit2/src/interfaces/IPermit2.sol";
import {JBPermissions} from "src/JBPermissions.sol";
import {JBProjects} from "src/JBProjects.sol";
import {JBPrices} from "src/JBPrices.sol";
import {JBRulesets} from "src/JBRulesets.sol";
import {JBDirectory} from "src/JBDirectory.sol";
import {JBERC20} from "src/JBERC20.sol";
import {JBTokens} from "src/JBTokens.sol";
import {JBSplits} from "src/JBSplits.sol";
import {JBFeelessAddresses} from "src/JBFeelessAddresses.sol";
import {JBFundAccessLimits} from "src/JBFundAccessLimits.sol";
import {JBController} from "src/JBController.sol";
import {JBTerminalStore} from "src/JBTerminalStore.sol";
import {JBMultiTerminal} from "src/JBMultiTerminal.sol";
contract Deploy is Script, Sphinx {
/// @notice The universal PERMIT2 address.
IPermit2 private constant _PERMIT2 = IPermit2(0x000000000022D473030F116dDEE9F6B43aC78BA3);
/// @notice The address that is allowed to forward calls to the terminal and controller on a users behalf.
address private constant TRUSTED_FORWARDER = 0xB2b5841DBeF766d4b521221732F9B618fCf34A87;
/// @notice The address that will manage the few privileged functions of the protocol.
address private MANAGER;
/// @notice The address that will own the fee-project.
address private FEE_PROJECT_OWNER;
/// @notice The nonce that gets used across all chains to sync deployment addresses and allow for new deployments of
/// the same bytecode.
uint256 private CORE_DEPLOYMENT_NONCE = 12;
function configureSphinx() public override {
// TODO: Update to contain JB Emergency Developers
sphinxConfig.projectName = "nana-core-testnet";
sphinxConfig.mainnets = ["ethereum", "optimism", "base", "arbitrum"];
sphinxConfig.testnets = ["ethereum_sepolia", "optimism_sepolia", "base_sepolia", "arbitrum_sepolia"];
}
/// @notice Deploys the protocol.
function run() public sphinx {
// Set the manager, this can be changed and won't affect deployment addresses.
MANAGER = safeAddress();
// NOTICE: THIS IS FOR TESTNET ONLY! REPLACE!
// TEMP set to be the *testing* safe for the nana-fee-project
FEE_PROJECT_OWNER = 0x67AB04E9a0D2cc7cD63527D8013f0B1E4b1FA2BB;
// Deploy the protocol.
deploy();
}
function deploy() public sphinx {
JBPermissions permissions = new JBPermissions{salt: keccak256(abi.encode(CORE_DEPLOYMENT_NONCE))}();
JBProjects projects =
new JBProjects{salt: keccak256(abi.encode(CORE_DEPLOYMENT_NONCE))}(safeAddress(), safeAddress());
JBDirectory directory =
new JBDirectory{salt: keccak256(abi.encode(CORE_DEPLOYMENT_NONCE))}(permissions, projects, safeAddress());
JBSplits splits = new JBSplits{salt: keccak256(abi.encode(CORE_DEPLOYMENT_NONCE))}(directory);
JBRulesets rulesets = new JBRulesets{salt: keccak256(abi.encode(CORE_DEPLOYMENT_NONCE))}(directory);
JBPrices prices = new JBPrices{salt: keccak256(abi.encode(CORE_DEPLOYMENT_NONCE))}(
directory, permissions, projects, safeAddress()
);
directory.setIsAllowedToSetFirstController(
address(
new JBController{salt: keccak256(abi.encode(CORE_DEPLOYMENT_NONCE))}({
directory: directory,
fundAccessLimits: new JBFundAccessLimits{salt: keccak256(abi.encode(CORE_DEPLOYMENT_NONCE))}(directory),
prices: prices,
permissions: permissions,
projects: projects,
rulesets: rulesets,
splits: splits,
tokens: new JBTokens{salt: keccak256(abi.encode(CORE_DEPLOYMENT_NONCE))}(
directory, new JBERC20{salt: keccak256(abi.encode(CORE_DEPLOYMENT_NONCE))}()
),
trustedForwarder: TRUSTED_FORWARDER
})
),
true
);
JBFeelessAddresses feeless =
new JBFeelessAddresses{salt: keccak256(abi.encode(CORE_DEPLOYMENT_NONCE))}(safeAddress());
new JBMultiTerminal{salt: keccak256(abi.encode(CORE_DEPLOYMENT_NONCE))}({
permissions: permissions,
projects: projects,
splits: splits,
store: new JBTerminalStore{salt: keccak256(abi.encode(CORE_DEPLOYMENT_NONCE))}({
directory: directory,
rulesets: rulesets,
prices: prices
}),
feelessAddresses: feeless,
permit2: _PERMIT2,
trustedForwarder: TRUSTED_FORWARDER
});
// If the manager is not the deployer we transfer all ownership to it.
if (MANAGER != safeAddress() && MANAGER != address(0)) {
directory.transferOwnership(MANAGER);
feeless.transferOwnership(MANAGER);
prices.transferOwnership(MANAGER);
projects.transferOwnership(MANAGER);
}
// Transfer ownership to the fee project owner.
if (FEE_PROJECT_OWNER != safeAddress() && FEE_PROJECT_OWNER != address(0)) {
projects.safeTransferFrom(safeAddress(), FEE_PROJECT_OWNER, 1);
}
}
}