-
Notifications
You must be signed in to change notification settings - Fork 7
Feat/l2deployment #24
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
Merged
Merged
Changes from 6 commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
2f8dd40
Merge pull request #23 from agglayer/staging
ZeroEkkusu b1b4e90
feat: start work on LayerY deployment
simonDos 5aabba4
feat: deployLayerY WETH
simonDos fcec405
fix: allow claim on address(0)
simonDos 23e8c89
chore: prepare Katana deployment
simonDos c557e58
chore: fmt
simonDos 1eb9663
chore: corrections from review, docs
simonDos 2ec1745
feat: script RegisterNativeConverters
simonDos 575108d
fix: input.json corrections
simonDos cb188cb
chore: revert vbETH name change
simonDos File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,101 @@ | ||
| // SPDX-License-Identifier: LicenseRef-PolygonLabs-Open-Attribution OR LicenseRef-PolygonLabs-Source-Available | ||
| pragma solidity ^0.8.29; | ||
|
|
||
| import "forge-std/Script.sol"; | ||
| import "../src/custom-tokens/GenericCustomToken.sol"; | ||
| import "../src/custom-tokens/GenericNativeConverter.sol"; | ||
| import {TransparentUpgradeableProxy} from "@openzeppelin/contracts/proxy/transparent/TransparentUpgradeableProxy.sol"; | ||
| import {ERC1967Proxy, ERC1967Utils} from "@openzeppelin/contracts/proxy/ERC1967/ERC1967Proxy.sol"; | ||
|
|
||
| contract DeployLayerY is Script { | ||
| using stdJson for string; | ||
|
|
||
| uint256 deployerPrivateKey = uint256(uint160(address(this))); // default placeholder for tests | ||
|
|
||
| function run() public { | ||
| deployerPrivateKey = vm.promptSecretUint("PRIVATE_KEY"); | ||
|
|
||
| deployLayerY(); | ||
| } | ||
|
|
||
| function deployLayerY() public { | ||
| vm.startBroadcast(deployerPrivateKey); | ||
|
|
||
| string memory input = vm.readFile("script/input.json"); | ||
|
|
||
| string memory slug = string(abi.encodePacked('["', vm.toString(block.chainid), '"]')); | ||
|
|
||
| address polygonEngineeringMultisig = input.readAddress(string.concat(slug, ".polygonEngineeringMultisig")); | ||
| address migrationManagerAddress = input.readAddress(string.concat(slug, ".migrationManager")); | ||
| address lxlyBridge = input.readAddress(string.concat(slug, ".lxlyBridge")); | ||
|
|
||
| GenericNativeConverter[] memory nativeConverters = new GenericNativeConverter[](5); | ||
|
|
||
| string[] memory vbTokens = new string[](4); | ||
| vbTokens[0] = "vbUSDC"; | ||
| vbTokens[1] = "vbUSDT"; | ||
| vbTokens[2] = "vbWBTC"; | ||
| vbTokens[3] = "vbUSDS"; | ||
|
|
||
| // deploy token impl | ||
| GenericCustomToken customTokenImpl = new GenericCustomToken(); | ||
| GenericNativeConverter nativeConverterImpl = new GenericNativeConverter(); | ||
|
|
||
| for (uint256 i = 0; i < vbTokens.length; i++) { | ||
| string memory vbSlug = | ||
| string(abi.encodePacked('["', vm.toString(block.chainid), '"]', '.["', vbTokens[i], '"]')); | ||
|
|
||
| address customToken = input.readAddress(string.concat(vbSlug, ".customToken")); | ||
| address underlyingToken = input.readAddress(string.concat(vbSlug, ".underlyingToken")); | ||
| string memory name = input.readString(string.concat(vbSlug, ".name")); | ||
| string memory symbol = input.readString(string.concat(vbSlug, ".symbol")); | ||
| uint8 decimals = uint8(input.readUint(string.concat(vbSlug, ".decimals"))); | ||
| uint256 nonMigratableBackingPercentage = | ||
| input.readUint(string.concat(vbSlug, ".nonMigratableBackingPercentage")); | ||
|
|
||
| bytes memory initNativeConverter = abi.encodeCall( | ||
| GenericNativeConverter.initialize, | ||
| ( | ||
| polygonEngineeringMultisig, | ||
| decimals, | ||
| customToken, | ||
| underlyingToken, | ||
| lxlyBridge, | ||
| 0, | ||
| nonMigratableBackingPercentage, | ||
| migrationManagerAddress | ||
| ) | ||
| ); | ||
| address nativeConverter = | ||
| _proxify(address(nativeConverterImpl), polygonEngineeringMultisig, initNativeConverter); | ||
|
|
||
| nativeConverters[i] = GenericNativeConverter(nativeConverter); | ||
|
|
||
| console.log("Native converter ", vbTokens[i], " deployed at: ", nativeConverter); | ||
|
|
||
| // update custom token | ||
| bytes memory data = abi.encodeCall( | ||
| GenericCustomToken.reinitialize, | ||
| (polygonEngineeringMultisig, name, symbol, decimals, lxlyBridge, nativeConverter) | ||
| ); | ||
|
|
||
| IERC1967Proxy customTokenProxy = IERC1967Proxy(payable(customToken)); | ||
| bytes memory payload = abi.encodeCall(customTokenProxy.upgradeToAndCall, (address(customTokenImpl), data)); | ||
|
|
||
| console.log("Payload for upgrading custom token", vbTokens[i]); | ||
| console.logBytes(payload); | ||
| } | ||
|
|
||
| console.log("Use this multisig: ", polygonEngineeringMultisig); | ||
|
|
||
| vm.stopBroadcast(); | ||
| } | ||
|
|
||
| function _proxify(address logic, address admin, bytes memory initData) internal returns (address payable proxy) { | ||
| proxy = payable(new TransparentUpgradeableProxy(logic, admin, initData)); | ||
| } | ||
| } | ||
|
|
||
| interface IERC1967Proxy { | ||
| function upgradeToAndCall(address newImplementation, bytes calldata data) external; | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,88 @@ | ||
| // SPDX-License-Identifier: LicenseRef-PolygonLabs-Open-Attribution OR LicenseRef-PolygonLabs-Source-Available | ||
| pragma solidity ^0.8.29; | ||
|
|
||
| import "forge-std/Script.sol"; | ||
| import "../src/custom-tokens/WETH/WETH.sol"; | ||
| import "../src/custom-tokens/WETH/WETHNativeConverter.sol"; | ||
| import {TransparentUpgradeableProxy} from "@openzeppelin/contracts/proxy/transparent/TransparentUpgradeableProxy.sol"; | ||
| import {ERC1967Proxy, ERC1967Utils} from "@openzeppelin/contracts/proxy/ERC1967/ERC1967Proxy.sol"; | ||
|
|
||
| contract DeployLayerY_WETH is Script { | ||
| using stdJson for string; | ||
|
|
||
| uint256 deployerPrivateKey = uint256(uint160(address(this))); // default placeholder for tests | ||
|
|
||
| function run() public { | ||
| deployerPrivateKey = vm.promptSecretUint("PRIVATE_KEY"); | ||
|
|
||
| deployLayerY_WETH(); | ||
| } | ||
|
|
||
| function deployLayerY_WETH() public { | ||
| vm.startBroadcast(deployerPrivateKey); | ||
|
|
||
| string memory input = vm.readFile("script/input.json"); | ||
|
|
||
| string memory slug = string(abi.encodePacked('["', vm.toString(block.chainid), '"]')); | ||
|
|
||
| address polygonEngineeringMultisig = input.readAddress(string.concat(slug, ".polygonEngineeringMultisig")); | ||
| address migrationManagerAddress = input.readAddress(string.concat(slug, ".migrationManager")); | ||
| address lxlyBridge = input.readAddress(string.concat(slug, ".lxlyBridge")); | ||
|
|
||
| string memory vbETHSlug = string(abi.encodePacked('["', vm.toString(block.chainid), '"]', '.["vbETH"]')); | ||
|
|
||
| address vbWETH = input.readAddress(string.concat(vbETHSlug, ".customToken")); | ||
| address wETH = input.readAddress(string.concat(vbETHSlug, ".underlyingToken")); | ||
| string memory name = input.readString(string.concat(vbETHSlug, ".name")); | ||
| string memory symbol = input.readString(string.concat(vbETHSlug, ".symbol")); | ||
| uint8 decimals = uint8(input.readUint(string.concat(vbETHSlug, ".decimals"))); | ||
| uint256 nonMigratableGasBackingPercentage = | ||
| input.readUint(string.concat(vbETHSlug, ".nonMigratableGasBackingPercentage")); | ||
|
|
||
| WETHNativeConverter nativeConverterImpl = new WETHNativeConverter(); | ||
|
|
||
| bytes memory initNativeConverter = abi.encodeCall( | ||
| WETHNativeConverter.initialize, | ||
| ( | ||
| polygonEngineeringMultisig, | ||
| decimals, | ||
| vbWETH, | ||
| wETH, | ||
| lxlyBridge, | ||
| 0, | ||
| nonMigratableGasBackingPercentage, | ||
| migrationManagerAddress, | ||
| 0 | ||
simonDos marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| ) | ||
| ); | ||
| address wethNativeConverter = | ||
| _proxify(address(nativeConverterImpl), polygonEngineeringMultisig, initNativeConverter); | ||
|
|
||
| // deploy vbWETH impl | ||
| WETH wethImpl = new WETH(); | ||
|
|
||
| // update vbWETH | ||
| bytes memory data = abi.encodeCall( | ||
| WETH.reinitialize, (polygonEngineeringMultisig, name, symbol, decimals, lxlyBridge, wethNativeConverter) | ||
| ); | ||
|
|
||
| IERC1967Proxy vbWethProxy = IERC1967Proxy(payable(vbWETH)); | ||
| bytes memory payload = abi.encodeCall(vbWethProxy.upgradeToAndCall, (address(wethImpl), data)); | ||
|
|
||
| console.log("Payload for upgrading vbWETH", "use this multisig: ", polygonEngineeringMultisig); | ||
| console.logBytes(payload); | ||
|
|
||
| /* bytes32 implementation = vm.load(vbWETH, 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc); | ||
| vm.assertEq(implementation, bytes32(uint256(uint160(address(wethImpl))))); */ | ||
|
|
||
| vm.stopBroadcast(); | ||
| } | ||
|
|
||
| function _proxify(address logic, address admin, bytes memory initData) internal returns (address payable proxy) { | ||
| proxy = payable(new TransparentUpgradeableProxy(logic, admin, initData)); | ||
| } | ||
| } | ||
|
|
||
| interface IERC1967Proxy { | ||
| function upgradeToAndCall(address newImplementation, bytes calldata data) external; | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,31 @@ | ||
| // SPDX-License-Identifier: LicenseRef-PolygonLabs-Open-Attribution OR LicenseRef-PolygonLabs-Source-Available | ||
| pragma solidity ^0.8.29; | ||
|
|
||
| import "forge-std/Script.sol"; | ||
| import "../src/vault-bridge-tokens/vbETH/VbETH.sol"; | ||
|
|
||
| contract DepositAndBridge is Script { | ||
simonDos marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| using stdJson for string; | ||
|
|
||
| uint256 deployerPrivateKey = uint256(uint160(address(this))); // default placeholder for tests | ||
|
|
||
| uint256 depositAmount = 0.001 ether; | ||
| uint32 NETWORK_ID_L2 = 20; | ||
| address receiver = 0x32bdc6A4e8C654dF65503CBb0eDc82B4Ce9158e6; | ||
|
|
||
| function run() public { | ||
| deployerPrivateKey = vm.promptSecretUint("PRIVATE_KEY"); | ||
|
|
||
| vm.startBroadcast(deployerPrivateKey); | ||
|
|
||
| console.log(receiver); | ||
|
|
||
| VbETH vbETH = VbETH(payable(0x2DC70fb75b88d2eB4715bc06E1595E6D97c34DFF)); | ||
|
|
||
| uint256 shares = vbETH.depositGasTokenAndBridge{value: depositAmount}(receiver, NETWORK_ID_L2, true); | ||
|
|
||
| console.log(shares); | ||
|
|
||
| vm.stopBroadcast(); | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Recommended to Use CustomToken and underlying token. Using vbETH for W-vbETH and WETH for W-WETH is misleading.