From c7c76ee0adb74601bec46ce30ddf7e496770ec9b Mon Sep 17 00:00:00 2001 From: Bot Date: Mon, 31 Aug 2026 00:21:06 +0800 Subject: [PATCH] feat: complete robinhood testnet deployment and export --- scripts/deploy.js | 35 ++++++++++++++++++++++++++--------- 1 file changed, 26 insertions(+), 9 deletions(-) diff --git a/scripts/deploy.js b/scripts/deploy.js index 63ca1d0..73c1e61 100644 --- a/scripts/deploy.js +++ b/scripts/deploy.js @@ -26,10 +26,10 @@ async function main() { // 2. 部署 PowerLDACurveV2 联合曲线引擎 console.log("Deploying PowerLDACurveV2 Engine..."); - // 曲线标准参数 (18位精度定点数) + // 曲线标准参数 (18位精度定点数,start 必须 >= 1.1e18 以满足 LogExpMath.LN_36_UPPER_BOUND 要求) const c1 = hre.ethers.parseUnits("1", 18); const c2 = hre.ethers.parseUnits("1", 18); - const start = 0; + const start = hre.ethers.parseUnits("1.1", 18); const timeKinkStart = 0; const timeKinkEnd = 86400 * 7; const rateBaseMin = hre.ethers.parseUnits("0.001", 18); @@ -48,8 +48,19 @@ async function main() { console.log(`PowerLDACurveV2 Deployed at: ${curveAddress}`); // 3. 部署 Registry 库与 WTFControllerV2 实现合约 - console.log("Deploying Registry Library & WTFControllerV2 Implementation..."); - const WTFControllerV2 = await hre.ethers.getContractFactory("WTFControllerV2"); + console.log("Deploying Registry Library..."); + const RegistryLib = await hre.ethers.getContractFactory("main/src/controllerv2/Registry.sol:Registry"); + const registryLib = await RegistryLib.deploy(); + await registryLib.waitForDeployment(); + const registryLibAddress = await registryLib.getAddress(); + console.log(`Registry Library Deployed at: ${registryLibAddress}`); + + console.log("Deploying WTFControllerV2 Implementation..."); + const WTFControllerV2 = await hre.ethers.getContractFactory("main/src/controllerv2/WTFControllerV2.sol:WTFControllerV2", { + libraries: { + "@wtf/src/controllerv2/Registry.sol:Registry": registryLibAddress + } + }); const controllerImpl = await WTFControllerV2.deploy(); await controllerImpl.waitForDeployment(); const implAddress = await controllerImpl.getAddress(); @@ -57,13 +68,13 @@ async function main() { // 4. 部署 TestProxy 代理并初始化 Controller console.log("Deploying Proxy Contract..."); - const TestProxy = await hre.ethers.getContractFactory("TestProxy"); + const TestProxy = await hre.ethers.getContractFactory("main/src/mock/TestProxy.sol:TestProxy"); const proxy = await TestProxy.deploy(implAddress); await proxy.waitForDeployment(); const proxyAddress = await proxy.getAddress(); console.log(`WTFControllerV2 Proxy Deployed at: ${proxyAddress}`); - const controller = await hre.ethers.getContractAt("WTFControllerV2", proxyAddress); + const controller = await hre.ethers.getContractAt("main/src/controllerv2/WTFControllerV2.sol:WTFControllerV2", proxyAddress); // 初始化参数 const admin = deployer.address; @@ -76,13 +87,19 @@ async function main() { await initTx.wait(); console.log("WTFControllerV2 Proxy Initialized!"); - // 5. 治理初始化:白名单与标准档位 + // 5. 治理初始化:角色授权、白名单与标准档位 + console.log("Granting OPERATOR_ROLE to Admin..."); + const OPERATOR_ROLE = hre.ethers.keccak256(hre.ethers.toUtf8Bytes("OPERATOR_ROLE")); + const grantTx = await controller.grantRole(OPERATOR_ROLE, admin); + await grantTx.wait(); + console.log("OPERATOR_ROLE granted!"); + console.log("Whitelisting Collateral & Curve in Controller..."); const seedMin = hre.ethers.parseUnits("1", 18); - const wlCollateralTx = await controller.setCollateralWhitelisted(collateralAddress, true, seedMin); + const wlCollateralTx = await controller.setWhitelistedCollateral(collateralAddress, true, seedMin); await wlCollateralTx.wait(); - const wlCurveTx = await controller.setCurveWhitelisted(curveAddress, true); + const wlCurveTx = await controller.setWhitelistedCurve(curveAddress, true); await wlCurveTx.wait(); console.log("Setting Standard Market Tiers (Tier 1/2/3)...");