22pragma solidity ^ 0.8.20 ;
33
44import "forge-std/Script.sol " ;
5+ import "forge-std/StdJson.sol " ;
56
67import "../src/authority/Authority.sol " ;
78import "../src/VSPToken.sol " ;
@@ -11,24 +12,21 @@ import "../src/StakeEngine.sol";
1112import "../src/ScoreEngine.sol " ;
1213import "../src/ProtocolViews.sol " ;
1314
14- /// @notice Mainnet deployment script.
15- /// @dev Reads GOVERNANCE_MULTISIG from env and sets it as the authority owner.
1615contract DeployMainnet is Script {
16+ using stdJson for string ;
17+
1718 function run () external {
1819 uint256 deployerPrivateKey = vm.envUint ("PRIVATE_KEY " );
1920 address governanceMultisig = vm.envAddress ("GOVERNANCE_MULTISIG " );
2021
2122 vm.startBroadcast (deployerPrivateKey);
2223
23- // Authority is permanently owned by the governance multisig
2424 Authority authority = new Authority (governanceMultisig);
2525 VSPToken token = new VSPToken (address (authority));
2626
27- // Grant mint/burn roles to governance multisig
2827 authority.setMinter (governanceMultisig, true );
2928 authority.setBurner (governanceMultisig, true );
3029
31- // Core protocol contracts
3230 PostRegistry registry = new PostRegistry ();
3331 LinkGraph graph = new LinkGraph (governanceMultisig);
3432 StakeEngine stake = new StakeEngine (address (token));
@@ -44,23 +42,49 @@ contract DeployMainnet is Script {
4442 address (score)
4543 );
4644
47- // CRITICAL: StakeEngine must be allowed to mint/burn for epoch settlement
4845 authority.setMinter (address (stake), true );
4946 authority.setBurner (address (stake), true );
5047
51- // Wire registry <-> graph
5248 graph.setRegistry (address (registry));
5349 registry.setLinkGraph (address (graph));
5450
55- console2.log ("Authority: " , address (authority));
56- console2.log ("VSPToken: " , address (token));
57- console2.log ("PostRegistry: " , address (registry));
58- console2.log ("LinkGraph: " , address (graph));
59- console2.log ("StakeEngine: " , address (stake));
60- console2.log ("ScoreEngine: " , address (score));
61- console2.log ("ProtocolViews: " , address (views_));
62-
6351 vm.stopBroadcast ();
52+
53+ _writeJson (
54+ "deployments/mainnet.json " ,
55+ "avalanche-mainnet " ,
56+ authority,
57+ token,
58+ registry,
59+ graph,
60+ stake,
61+ score,
62+ views_
63+ );
64+ }
65+
66+ function _writeJson (
67+ string memory path ,
68+ string memory chain ,
69+ Authority authority ,
70+ VSPToken token ,
71+ PostRegistry registry ,
72+ LinkGraph graph ,
73+ StakeEngine stake ,
74+ ScoreEngine score ,
75+ ProtocolViews views_
76+ ) internal {
77+ string memory json;
78+ json = json.serialize ("chain " , chain);
79+ json = json.serialize ("Authority " , address (authority));
80+ json = json.serialize ("VSPToken " , address (token));
81+ json = json.serialize ("PostRegistry " , address (registry));
82+ json = json.serialize ("LinkGraph " , address (graph));
83+ json = json.serialize ("StakeEngine " , address (stake));
84+ json = json.serialize ("ScoreEngine " , address (score));
85+ json = json.serialize ("ProtocolViews " , address (views_));
86+
87+ vm.writeJson (json, path);
6488 }
6589}
6690
0 commit comments