89 lines
3.2 KiB
Solidity
89 lines
3.2 KiB
Solidity
|
|
// SPDX-License-Identifier: MIT
|
||
|
|
pragma solidity ^0.8.20;
|
||
|
|
|
||
|
|
import "forge-std/Script.sol";
|
||
|
|
import "../../contracts/registry/UniversalAssetRegistry.sol";
|
||
|
|
import "../../contracts/sync/TokenlistGovernanceSync.sol";
|
||
|
|
|
||
|
|
/**
|
||
|
|
* @title Migrate Existing Assets
|
||
|
|
* @notice Migrate tokens from existing system to universal bridge
|
||
|
|
*/
|
||
|
|
contract MigrateExistingAssets is Script {
|
||
|
|
function run() external {
|
||
|
|
uint256 deployerPrivateKey = vm.envUint("PRIVATE_KEY");
|
||
|
|
|
||
|
|
address registry = vm.envAddress("UNIVERSAL_ASSET_REGISTRY");
|
||
|
|
address tokenlistSync = vm.envAddress("TOKENLIST_GOVERNANCE_SYNC");
|
||
|
|
|
||
|
|
console.log("Migrating existing assets...");
|
||
|
|
console.log("");
|
||
|
|
|
||
|
|
vm.startBroadcast(deployerPrivateKey);
|
||
|
|
|
||
|
|
UniversalAssetRegistry assetRegistry = UniversalAssetRegistry(registry);
|
||
|
|
|
||
|
|
// Migrate existing tokens from tokenlist
|
||
|
|
// Example: WETH9
|
||
|
|
console.log("1. Migrating WETH9...");
|
||
|
|
bytes32 weth9Proposal = assetRegistry.proposeAsset(
|
||
|
|
0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2,
|
||
|
|
UniversalAssetRegistry.AssetType.ERC20Standard,
|
||
|
|
UniversalAssetRegistry.ComplianceLevel.Public,
|
||
|
|
"Wrapped Ether",
|
||
|
|
"WETH",
|
||
|
|
18,
|
||
|
|
"Global",
|
||
|
|
30, // Low-medium volatility
|
||
|
|
1e15,
|
||
|
|
1000000e18
|
||
|
|
);
|
||
|
|
console.log(" Proposal ID:", vm.toString(weth9Proposal));
|
||
|
|
|
||
|
|
// Example: LINK
|
||
|
|
console.log("2. Migrating LINK...");
|
||
|
|
bytes32 linkProposal = assetRegistry.proposeAsset(
|
||
|
|
0x362E9a45Ef6e554760f9671938235Cbc9b6E80Ed,
|
||
|
|
UniversalAssetRegistry.AssetType.ERC20Standard,
|
||
|
|
UniversalAssetRegistry.ComplianceLevel.Public,
|
||
|
|
"Chainlink Token",
|
||
|
|
"LINK",
|
||
|
|
18,
|
||
|
|
"Global",
|
||
|
|
50, // Medium volatility
|
||
|
|
1e15,
|
||
|
|
1000000e18
|
||
|
|
);
|
||
|
|
console.log(" Proposal ID:", vm.toString(linkProposal));
|
||
|
|
|
||
|
|
// Vote and execute (if admin mode)
|
||
|
|
console.log("3. Voting on proposals...");
|
||
|
|
assetRegistry.voteOnProposal(weth9Proposal, true);
|
||
|
|
assetRegistry.voteOnProposal(linkProposal, true);
|
||
|
|
console.log(" Voted");
|
||
|
|
|
||
|
|
// Fast-forward time for testing (remove in production)
|
||
|
|
if (block.chainid == 31337 || block.chainid == 138) { // Local or test chain
|
||
|
|
vm.warp(block.timestamp + 2 days);
|
||
|
|
|
||
|
|
console.log("4. Executing proposals...");
|
||
|
|
assetRegistry.executeProposal(weth9Proposal);
|
||
|
|
assetRegistry.executeProposal(linkProposal);
|
||
|
|
console.log(" Executed");
|
||
|
|
}
|
||
|
|
|
||
|
|
vm.stopBroadcast();
|
||
|
|
|
||
|
|
console.log("");
|
||
|
|
console.log("================================");
|
||
|
|
console.log("Migration Complete!");
|
||
|
|
console.log("================================");
|
||
|
|
console.log("");
|
||
|
|
console.log("Migrated Assets:");
|
||
|
|
console.log("- WETH9: 0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2");
|
||
|
|
console.log("- LINK: 0x362E9a45Ef6e554760f9671938235Cbc9b6E80Ed");
|
||
|
|
console.log("");
|
||
|
|
console.log("Note: On mainnet, wait for timelock before executing");
|
||
|
|
}
|
||
|
|
}
|