Skip to content
Merged
Show file tree
Hide file tree
Changes from 6 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
1 change: 1 addition & 0 deletions foundry.toml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ polygon_pos = "https://polygon-mainnet.infura.io/v3/${INFURA_TOKEN}"
polygon_zkevm = "https://zkevm-rpc.com"
polygon_zkevm_testnet = "https://rpc.public.zkevm-test.net"
tatara = "https://rpc.tatara.katanarpc.com/${TATARA_TOKEN}"
katana = "https://rpc.katanarpc.com/${KATANA_TOKEN}"

[etherscan]
mainnet = { key = "${API_KEY}" }
Expand Down
101 changes: 101 additions & 0 deletions script/DeployLayerY.s.sol
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;
}
88 changes: 88 additions & 0 deletions script/DeployLayerY_WETH.s.sol
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"));

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.

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
)
);
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;
}
31 changes: 31 additions & 0 deletions script/DepositAndBridge.s.sol
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 {
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();
}
}
49 changes: 48 additions & 1 deletion script/input.json
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,54 @@
}
},
"747474": {

"vbETH": {
"customToken": "0xEE7D8BCFb72bC1880D0Cf19822eB0A2e6577aB62",
"underlyingToken": "0x815955d051C6262C16c720b19D735426254Bec5B",
"owner": "0x2De242e27386e224E5fbF110EA8406d5B70740ec",
"name": "Vault Bridge ETH",
"symbol": "vbETH",
"decimals": 18,
"nonMigratableGasBackingPercentage": 0
},
"vbUSDC": {
"customToken": "0x203A662b0BD271A6ed5a60EdFbd04bFce608FD36",
"underlyingToken": "0xfd415D011FfaA8e6f17fa753CdB080d1dE266784",
"owner": "0x2De242e27386e224E5fbF110EA8406d5B70740ec",
"name": "Vault Bridge USDC",
"symbol": "vbUSDC",
"decimals": 6,
"nonMigratableBackingPercentage": 2
},
"vbUSDT": {
"customToken": "0x2DCa96907fde857dd3D816880A0df407eeB2D2F2",
"underlyingToken": "0xf44e3BCB7A2461CC08185E127B324f2486a74E20",
"owner": "0x2De242e27386e224E5fbF110EA8406d5B70740ec",
"name": "Vault Bridge USDT",
"symbol": "vbUSDT",
"decimals": 6,
"nonMigratableBackingPercentage": 2
},
"vbWBTC": {
"customToken": "0x0913DA6Da4b42f538B445599b46Bb4622342Cf52",
"underlyingToken": "0xB33e43A3F276e8e75792b941bccC996EcB2c0bBD",
"owner": "0x2De242e27386e224E5fbF110EA8406d5B70740ec",
"name": "Vault Bridge WBTC",
"symbol": "vbWBTC",
"decimals": 8,
"nonMigratableBackingPercentage": 1
},
"vbUSDS": {
"customToken": "0x62D6A123E8D19d06d68cf0d2294F9A3A0362c6b3",
"underlyingToken": "0x2134866886ce784fE2E0DE819118E4D32b4Be32C",
"owner": "0x2De242e27386e224E5fbF110EA8406d5B70740ec",
"name": "Vault Bridge USDS",
"symbol": "vbUSDS",
"decimals": 18,
"nonMigratableBackingPercentage": 1
},
"migrationManager": "0x417d01B64Ea30C4E163873f3a1f77b727c689e02",
"polygonEngineeringMultisig": "0x4e981bAe8E3cd06Ca911ffFE5504B2653ac1C38a",
"lxlyBridge": "0x2a3DD3EB832aF982ec71669E178424b10Dca2EDe"
},
"31337": {
"proxyAdmin": "0x0000c6A4e8C654dF65503CBb0eDc82B4Ce9158e6",
Expand Down
4 changes: 4 additions & 0 deletions src/CustomToken.sol
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,10 @@ abstract contract CustomToken is
onlyLxlyBridgeAndNativeConverter
nonReentrant
{
// When we migrate backing to Lx, we end up sending tokens to address(0) here.
// These need to be claimable so the bridge accounting is correct and we allow it here by not reverting.
if (account == address(0)) return;

_mint(account, value);
}

Expand Down