Skip to content

Commit

Permalink
Merge pull request #128 from ankurdubey521/main
Browse files Browse the repository at this point in the history
feat: Update Deployment Scripts
  • Loading branch information
corddry authored Nov 14, 2024
2 parents 91808ad + 7d06922 commit f8d7882
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 2 deletions.
4 changes: 3 additions & 1 deletion foundry.toml
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,6 @@ quote_style = "double"
ignore = ["libs/*", "*.t.sol"]

[etherscan]
mainnet = { key = "${EXPLORER_KEY_1}" }
1 = { key = "${EXPLORER_KEY_1}" }
42161 = { key = "${EXPLORER_KEY_42161}" }
8453 = { key = "${EXPLORER_KEY_8453}" }
30 changes: 29 additions & 1 deletion script/Deploy.Determinstic.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ address constant CREATE2_FACTORY_ADDRESS = 0x4e59b44847b379578588920cA78FbF26c0B

// Deployment Salts
string constant POINTS_FACTORY_SALT = "ROYCO_POINTS_FACTORY_458371a243a7299e99f3fbfb67799eaaf734ccaf"; // 0x19112AdBDAfB465ddF0b57eCC07E68110Ad09c50
string constant WRAPPED_VAULT_FACTORY_SALT = "ROYCO_WRAPPED_VAULT_FACTORY_153a5c1e619a98ec578748451a879136baf2d345"; // 0xb316D165D01aC68d31B297F847533D671c965662
string constant WRAPPED_VAULT_FACTORY_SALT = "ROYCO_WRAPPED_VAULT_FACTORY_91808adcb7fa5a62d0f432799a66eb39c7306733"; // 0xBFaC50C6b2c91AB756c1e5EFab699438992cc1b2
string constant WEIROLL_WALLET_SALT = "ROYCO_WEIROLL_WALLET_458371a243a7299e99f3fbfb67799eaaf734ccaf"; // 0x40a1c08084671E9A799B73853E82308225309Dc0
string constant VAULT_MARKET_HUB_SALT = "ROYCO_VAULT_MARKET_HUB_458371a243a7299e99f3fbfb67799eaaf734ccaf"; // 0x52341389BE638A5B8083d2B70a421f9D4C87EBcd
string constant RECIPE_MARKET_HUB_SALT = "ROYCO_RECIPE_MARKET_HUB_458371a243a7299e99f3fbfb67799eaaf734ccaf"; // 0x76953A612c256fc497bBb49ed14147f24C4feB71
Expand All @@ -33,12 +33,20 @@ address constant PROTOCOL_FEE_RECIPIENT = 0x85De42e5697D16b853eA24259C42290DaCe3
uint256 constant PROTOCOL_FEE = 0;
uint256 constant MINIMUM_FRONTEND_FEE = 0.005e18;

// Expected Deployment Addresses
address constant EXPECTED_POINTS_FACTORY_ADDRESS = 0x19112AdBDAfB465ddF0b57eCC07E68110Ad09c50;
address constant EXPECTED_WRAPPED_VAULT_FACTORY_ADDRESS = 0xBFaC50C6b2c91AB756c1e5EFab699438992cc1b2;
address constant EXPECTED_WEIROLL_WALLET_ADDRESS = 0x40a1c08084671E9A799B73853E82308225309Dc0;
address constant EXPECTED_VAULT_MARKET_HUB_ADDRESS = 0x52341389BE638A5B8083d2B70a421f9D4C87EBcd;
address constant EXPECTED_RECIPE_MARKET_HUB_ADDRESS = 0x76953A612c256fc497bBb49ed14147f24C4feB71;

contract DeployDeterministic is Script {
error Create2DeployerNotDeployed();

error DeploymentFailed(bytes reason);
error NotDeployedToExpectedAddress(address expected, address actual);
error AddressDoesNotContainBytecode(address addr);
error UnexpectedDeploymentAddress(address expected, address actual);

error PointsFactoryOwnerIncorrect(address expected, address actual);

Expand Down Expand Up @@ -106,10 +114,17 @@ contract DeployDeterministic is Script {
}

function _verifyPointsFactoryDeployment(PointsFactory _pointsFactory) internal view {
if (address(_pointsFactory) != EXPECTED_POINTS_FACTORY_ADDRESS) {
revert UnexpectedDeploymentAddress(EXPECTED_POINTS_FACTORY_ADDRESS, address(_pointsFactory));
}

if (_pointsFactory.owner() != ROYCO_OWNER) revert PointsFactoryOwnerIncorrect(ROYCO_OWNER, _pointsFactory.owner());
}

function _verifyWrappedVaultFactoryDeployment(WrappedVaultFactory _wrappedVaultFactory, PointsFactory _pointsFactory) internal view {
if (address(_wrappedVaultFactory) != EXPECTED_WRAPPED_VAULT_FACTORY_ADDRESS) {
revert UnexpectedDeploymentAddress(EXPECTED_WRAPPED_VAULT_FACTORY_ADDRESS, address(_wrappedVaultFactory));
}
if (_wrappedVaultFactory.protocolFeeRecipient() != PROTOCOL_FEE_RECIPIENT) {
revert WrappedVaultFactoryProtocolFeeRecipientIncorrect(PROTOCOL_FEE_RECIPIENT, _wrappedVaultFactory.protocolFeeRecipient());
}
Expand All @@ -127,11 +142,23 @@ contract DeployDeterministic is Script {
}
}

function _verifyWeirollWalletDeployment(WeirollWallet _weirollWallet) internal pure {
if (address(_weirollWallet) != EXPECTED_WEIROLL_WALLET_ADDRESS) {
revert UnexpectedDeploymentAddress(EXPECTED_WEIROLL_WALLET_ADDRESS, address(_weirollWallet));
}
}

function _verifyVaultMarketHubDeployment(VaultMarketHub _vaultMarketHub) internal view {
if (address(_vaultMarketHub) != EXPECTED_VAULT_MARKET_HUB_ADDRESS) {
revert UnexpectedDeploymentAddress(EXPECTED_VAULT_MARKET_HUB_ADDRESS, address(_vaultMarketHub));
}
if (_vaultMarketHub.owner() != ROYCO_OWNER) revert VaultMarketHubOwnerIncorrect(ROYCO_OWNER, _vaultMarketHub.owner());
}

function _verifyRecipeMarketHubDeployment(RecipeMarketHub _recipeMarketHub, WeirollWallet _weirollWallet, PointsFactory _pointsFactory) internal view {
if (address(_recipeMarketHub) != EXPECTED_RECIPE_MARKET_HUB_ADDRESS) {
revert UnexpectedDeploymentAddress(EXPECTED_RECIPE_MARKET_HUB_ADDRESS, address(_recipeMarketHub));
}
if (_recipeMarketHub.WEIROLL_WALLET_IMPLEMENTATION() != address(_weirollWallet)) {
revert RecipeMarketHubWeirollWalletImplementationIncorrect(address(_weirollWallet), _recipeMarketHub.WEIROLL_WALLET_IMPLEMENTATION());
}
Expand Down Expand Up @@ -182,6 +209,7 @@ contract DeployDeterministic is Script {
console2.log("Deploying WeirollWallet");
bytes memory weirollWalletCreationCode = abi.encodePacked(vm.getCode("WeirollWallet"));
WeirollWallet weirollWallet = WeirollWallet(payable(_deployWithSanityChecks(WEIROLL_WALLET_SALT, weirollWalletCreationCode)));
_verifyWeirollWalletDeployment(weirollWallet);
console2.log("WeirollWallet deployed at: ", address(weirollWallet), "\n");

// Deploy VaultMarketHub
Expand Down

0 comments on commit f8d7882

Please sign in to comment.