Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore:(test) Make deploy tests great again! #362

Merged
merged 4 commits into from
Jul 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
78 changes: 48 additions & 30 deletions script/Deployer.sol
Original file line number Diff line number Diff line change
Expand Up @@ -42,65 +42,83 @@ contract Deployer is Script {
bytes32 salt = vm.envOr(
"DEPLOYMENT_SALT", keccak256(abi.encodePacked(string(abi.encodePacked(blockhash(block.number - 1)))))
);
escrow = new Escrow{salt: salt}(deployer);
root = new Root{salt: salt}(address(escrow), delay, deployer);

uint64 messageCost = uint64(vm.envOr("MESSAGE_COST", uint256(20000000000000000))); // in Weight
uint64 proofCost = uint64(vm.envOr("PROOF_COST", uint256(20000000000000000))); // in Weigth
uint128 gasPrice = uint128(vm.envOr("GAS_PRICE", uint256(2500000000000000000))); // Centrifuge Chain
uint256 tokenPrice = vm.envOr("TOKEN_PRICE", uint256(178947400000000)); // CFG/ETH

escrow = new Escrow{salt: keccak256(abi.encodePacked(salt, "escrow1"))}(deployer);
routerEscrow = new Escrow{salt: keccak256(abi.encodePacked(salt, "escrow2"))}(deployer);
root = new Root{salt: salt}(address(escrow), delay, deployer);
vaultFactory = address(new ERC7540VaultFactory(address(root)));
restrictionManager = address(new RestrictionManager{salt: salt}(address(root), deployer));
trancheFactory = address(new TrancheFactory{salt: salt}(address(root), deployer));
investmentManager = new InvestmentManager(address(root), address(escrow));
poolManager = new PoolManager(address(escrow), vaultFactory, trancheFactory);
transferProxyFactory = address(new TransferProxyFactory{salt: salt}(address(poolManager)));

// TODO THESE VALUES NEEDS TO BE CHECKED
gasService = new GasService(20000000000000000, 20000000000000000, 2500000000000000000, 178947400000000);
gasService.rely(address(root));

gasService = new GasService(messageCost, proofCost, gasPrice, tokenPrice);
gateway = new Gateway(address(root), address(poolManager), address(investmentManager), address(gasService));
routerEscrow = new Escrow(deployer);
router = new CentrifugeRouter(address(routerEscrow), address(gateway), address(poolManager));
IAuth(address(routerEscrow)).rely(address(router));
guardian = new Guardian(adminSafe, address(root), address(gateway));

_endorse();
_rely();
_file();
}

function _endorse() internal {
root.endorse(address(router));
root.endorse(address(escrow));
}

function _rely() internal {
// Rely on PoolManager
gasService.rely(address(poolManager));
escrow.rely(address(poolManager));
IAuth(vaultFactory).rely(address(poolManager));
IAuth(trancheFactory).rely(address(poolManager));
IAuth(restrictionManager).rely(address(poolManager));

// Rely on Root
router.rely(address(root));
poolManager.rely(address(root));
investmentManager.rely(address(root));
gateway.rely(address(root));
gasService.rely(address(root));
escrow.rely(address(root));
routerEscrow.rely(address(root));
IAuth(vaultFactory).rely(address(root));
IAuth(trancheFactory).rely(address(root));
IAuth(restrictionManager).rely(address(root));

guardian = new Guardian(adminSafe, address(root), address(gateway));
}

function wire(address adapter) public {
adapters.push(adapter);

// Wire guardian
// Rely on guardian
root.rely(address(guardian));
gateway.rely(address(guardian));

// Wire gateway
gateway.file("adapters", adapters);
// Rely on gateway
root.rely(address(gateway));
investmentManager.file("poolManager", address(poolManager));
investmentManager.rely(address(gateway));
poolManager.rely(address(gateway));

// Rely on others
IAuth(address(routerEscrow)).rely(address(router));
investmentManager.rely(address(vaultFactory));
}

function _file() public {
poolManager.file("investmentManager", address(investmentManager));
poolManager.file("gasService", address(gasService));
poolManager.file("gateway", address(gateway));

router.rely(address(root));
investmentManager.file("poolManager", address(poolManager));
investmentManager.file("gateway", address(gateway));
poolManager.file("gateway", address(gateway));
investmentManager.rely(address(root));
investmentManager.rely(address(gateway));
investmentManager.rely(address(vaultFactory));
poolManager.rely(address(root));
poolManager.rely(address(gateway));
gateway.rely(address(root));
}

function wire(address adapter) public {
adapters.push(adapter);
gateway.file("adapters", adapters);
IAuth(adapter).rely(address(root));
IAuth(address(escrow)).rely(address(root));
IAuth(address(routerEscrow)).rely(address(root));
IAuth(address(escrow)).rely(address(poolManager));
}

function removeDeployerAccess(address adapter, address deployer) public {
Expand Down
2 changes: 1 addition & 1 deletion src/gateway/GasService.sol
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ contract GasService is IGasService, Auth {
/// @inheritdoc IGasService
uint256 public tokenPrice;

constructor(uint64 proofCost_, uint64 messageCost_, uint128 gasPrice_, uint256 tokenPrice_) {
constructor(uint64 messageCost_, uint64 proofCost_, uint128 gasPrice_, uint256 tokenPrice_) {
messageCost = messageCost_;
proofCost = proofCost_;
gasPrice = gasPrice_;
Expand Down
Loading
Loading