Skip to content

Commit

Permalink
feat: deployment versions
Browse files Browse the repository at this point in the history
  • Loading branch information
kyriediculous committed Jan 29, 2024
1 parent c09b988 commit 32c2afd
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 12 deletions.
18 changes: 10 additions & 8 deletions script/Tenderize_Deploy.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,13 @@ import { Renderer } from "core/unlocks/Renderer.sol";
import { Unlocks } from "core/unlocks/Unlocks.sol";
import { Factory } from "core/factory/Factory.sol";

uint256 constant VERSION = 1;

contract Tenderize_Deploy is Script {
// Contracts are deployed deterministically.
// e.g. `foo = new Foo{salt: salt}(constructorArgs)`
// The presence of the salt argument tells forge to use https://github.com/Arachnid/deterministic-deployment-proxy
bytes32 private constant salt = bytes32(uint256(1));
bytes32 private constant salt = bytes32(VERSION);

function run() public {
string memory json_output;
Expand All @@ -38,38 +40,38 @@ contract Tenderize_Deploy is Script {

// 1. Deploy Registry (without initialization)
// - Deploy Registry Implementation
Registry registry = new Registry{salt: salt}();
Registry registry = new Registry{ salt: salt }();
vm.serializeAddress(json_output, "registry_implementation", address(registry));
// - Deploy Registry UUPS Proxy
address registryProxy = address(new ERC1967Proxy{salt: salt}(address(registry), ""));
address registryProxy = address(new ERC1967Proxy{ salt: salt }(address(registry), ""));
vm.serializeAddress(json_output, "registry_proxy", registryProxy);
console2.log("Registry Implementation: ", address(registry));
console2.log("Registry Proxy: ", registryProxy);

// 2. Deploy Unlocks
// - Deploy Renderer Implementation
Renderer renderer = new Renderer{salt: salt}();
Renderer renderer = new Renderer{ salt: salt }();
vm.serializeAddress(json_output, "renderer_implementation", address(renderer));
// - Deploy Renderer UUPS Proxy
ERC1967Proxy rendererProxy = new ERC1967Proxy{salt: salt}(address(renderer), abi.encodeCall(renderer.initialize, ()));
ERC1967Proxy rendererProxy = new ERC1967Proxy{ salt: salt }(address(renderer), abi.encodeCall(renderer.initialize, ()));
vm.serializeAddress(json_output, "renderer_proxy", address(rendererProxy));
// - Deploy Unlocks
Unlocks unlocks = new Unlocks{salt: salt}(address(registryProxy), address(rendererProxy));
Unlocks unlocks = new Unlocks{ salt: salt }(address(registryProxy), address(rendererProxy));
vm.serializeAddress(json_output, "unlocks", address(unlocks));
console2.log("Renderer Implementation: ", address(renderer));
console2.log("Renderer Proxy: ", address(rendererProxy));
console2.log("Unlocks: ", address(unlocks));

// 3. Deploy Tenderizer Implementation
Tenderizer tenderizer = new Tenderizer{salt: salt}(registryProxy, address(unlocks));
Tenderizer tenderizer = new Tenderizer{ salt: salt }(registryProxy, address(unlocks));
vm.serializeAddress(json_output, "tenderizer_implementation", address(tenderizer));
console2.log("Tenderizer Implementation: ", address(tenderizer));

// 4. Initialize Registry
Registry(registryProxy).initialize(address(tenderizer), address(unlocks));

// 5. Deploy Factory
Factory factory = new Factory{salt: salt}(address(registryProxy));
Factory factory = new Factory{ salt: salt }(address(registryProxy));
vm.serializeAddress(json_output, "factory", address(factory));
// - Grant Factory role to Factory
Registry(registryProxy).grantRole(FACTORY_ROLE, address(factory));
Expand Down
10 changes: 6 additions & 4 deletions script/XYZ_Deploy.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,10 @@ import { Registry } from "core/registry/Registry.sol";

import { Factory } from "core/factory/Factory.sol";

uint256 constant VERSION = 1;

contract XYZ_Deploy is Script {
bytes32 private constant salt = bytes32(uint256(1));
bytes32 private constant salt = bytes32(VERSION);

function run() public {
address registry = vm.envAddress("REGISTRY");
Expand All @@ -39,13 +41,13 @@ contract XYZ_Deploy is Script {
vm.startBroadcast(privKey);
address me = vm.addr(privKey);

MockERC20 XYZ = new MockERC20{salt: salt}(name, symbol, 18);
MockERC20 XYZ = new MockERC20{ salt: salt }(name, symbol, 18);
console2.log(string.concat(symbol, " Token: "), address(XYZ));
// mint supply
XYZ.mint(me, totalSupply);
StakingXYZ stakingXYZ = new StakingXYZ{salt: salt}(address(XYZ), unlockTime, baseAPR);
StakingXYZ stakingXYZ = new StakingXYZ{ salt: salt }(address(XYZ), unlockTime, baseAPR);
console2.log(string.concat(symbol, " Staking :"), address(stakingXYZ));
XYZAdapter adapter = new XYZAdapter{salt: salt}(address(stakingXYZ), address(XYZ));
XYZAdapter adapter = new XYZAdapter{ salt: salt }(address(stakingXYZ), address(XYZ));
console2.log(string.concat(symbol, " Adapter: "), address(adapter));
// Register XYZ adapter
Registry(registry).registerAdapter(address(XYZ), address(adapter));
Expand Down

0 comments on commit 32c2afd

Please sign in to comment.