ytLending supports USDC as the base token
This commit is contained in:
@@ -29,16 +29,74 @@ async function main() {
|
||||
}
|
||||
|
||||
console.log("📋 当前部署的合约:");
|
||||
console.log(" LendingPriceFeed Proxy:", deployments.lendingPriceFeed);
|
||||
if (deployments.lendingPriceFeedImpl) {
|
||||
console.log(" LendingPriceFeed Impl:", deployments.lendingPriceFeedImpl);
|
||||
}
|
||||
console.log(" Configurator Proxy:", deployments.configuratorProxy);
|
||||
console.log(" Configurator Impl:", deployments.configuratorImpl);
|
||||
console.log(" Lending Proxy:", deployments.lendingProxy);
|
||||
console.log(" Lending Impl:", deployments.lendingImpl, "\n");
|
||||
|
||||
// ========== 选择要升级的合约 ==========
|
||||
// 修改这里来选择升级 Lending 或 Configurator
|
||||
const UPGRADE_LENDING = true; // true = 升级 Lending, false = 升级 Configurator
|
||||
// 修改这里来选择升级哪个合约
|
||||
// 1 = LendingPriceFeed, 2 = Configurator, 3 = Lending
|
||||
const UPGRADE_CONTRACT = 1; // 修改这个数字来选择要升级的合约
|
||||
|
||||
if (UPGRADE_LENDING) {
|
||||
if (UPGRADE_CONTRACT === 1) {
|
||||
// ========== 升级 LendingPriceFeed ==========
|
||||
console.log("🔄 Phase 1: 升级 LendingPriceFeed 合约");
|
||||
|
||||
if (!deployments.lendingPriceFeed) {
|
||||
throw new Error("未找到 LendingPriceFeed Proxy 地址,请先运行部署脚本");
|
||||
}
|
||||
|
||||
console.log(" 当前 LendingPriceFeed Proxy:", deployments.lendingPriceFeed);
|
||||
if (deployments.lendingPriceFeedImpl) {
|
||||
console.log(" 当前 LendingPriceFeed Implementation:", deployments.lendingPriceFeedImpl);
|
||||
}
|
||||
|
||||
// 获取新的 LendingPriceFeed 合约工厂
|
||||
const LendingPriceFeedV2 = await ethers.getContractFactory("LendingPriceFeed");
|
||||
|
||||
console.log("\n 正在验证新实现合约...");
|
||||
const upgradedPriceFeed = await upgrades.upgradeProxy(
|
||||
deployments.lendingPriceFeed,
|
||||
LendingPriceFeedV2,
|
||||
{
|
||||
kind: "uups"
|
||||
}
|
||||
);
|
||||
await upgradedPriceFeed.waitForDeployment();
|
||||
|
||||
console.log(" ✅ LendingPriceFeed 已升级!");
|
||||
|
||||
// 获取新的实现合约地址
|
||||
const upgradedPriceFeedAddress = await upgradedPriceFeed.getAddress();
|
||||
const newPriceFeedImplAddress = await upgrades.erc1967.getImplementationAddress(upgradedPriceFeedAddress);
|
||||
console.log(" 新 LendingPriceFeed Implementation:", newPriceFeedImplAddress);
|
||||
|
||||
// 验证升级
|
||||
console.log("\n 验证升级结果:");
|
||||
console.log(" LendingPriceFeed Proxy (不变):", upgradedPriceFeedAddress);
|
||||
console.log(" Owner:", await upgradedPriceFeed.owner());
|
||||
console.log(" USDC Address:", await upgradedPriceFeed.usdcAddress());
|
||||
|
||||
// 保存新的实现地址
|
||||
deployments.lendingPriceFeedImpl = newPriceFeedImplAddress;
|
||||
deployments.lastUpgradeTime = new Date().toISOString();
|
||||
|
||||
const allDeployments = JSON.parse(fs.readFileSync(deploymentsPath, "utf-8"));
|
||||
allDeployments[chainId] = deployments;
|
||||
fs.writeFileSync(deploymentsPath, JSON.stringify(allDeployments, null, 2));
|
||||
|
||||
console.log("\n✅ LendingPriceFeed 升级完成!");
|
||||
console.log("=====================================");
|
||||
console.log("旧实现:", deployments.lendingPriceFeedImpl || "未记录");
|
||||
console.log("新实现:", newPriceFeedImplAddress);
|
||||
console.log("=====================================\n");
|
||||
|
||||
} else if (UPGRADE_CONTRACT === 3) {
|
||||
// ========== 升级 Lending ==========
|
||||
console.log("🔄 Phase 1: 升级 Lending 合约");
|
||||
|
||||
@@ -81,7 +139,7 @@ async function main() {
|
||||
deployments.lendingImpl = newLendingImplAddress;
|
||||
deployments.lendingUpgradeTimestamp = new Date().toISOString();
|
||||
|
||||
} else {
|
||||
} else if (UPGRADE_CONTRACT === 2) {
|
||||
// ========== 升级 Configurator ==========
|
||||
console.log("🔄 Phase 1: 升级 Configurator 合约");
|
||||
|
||||
@@ -117,34 +175,33 @@ async function main() {
|
||||
// 保存新的实现地址
|
||||
deployments.configuratorImpl = newConfiguratorImplAddress;
|
||||
deployments.configuratorUpgradeTimestamp = new Date().toISOString();
|
||||
|
||||
const allDeployments2 = JSON.parse(fs.readFileSync(deploymentsPath, "utf-8"));
|
||||
allDeployments2[chainId] = deployments;
|
||||
fs.writeFileSync(deploymentsPath, JSON.stringify(allDeployments2, null, 2));
|
||||
|
||||
console.log("\n✅ Configurator 升级完成!");
|
||||
console.log("=====================================");
|
||||
console.log("旧实现:", deployments.configuratorImpl);
|
||||
console.log("新实现:", newConfiguratorImplAddress);
|
||||
console.log("=====================================\n");
|
||||
} else {
|
||||
throw new Error(`无效的升级选项: ${UPGRADE_CONTRACT}。请设置 UPGRADE_CONTRACT 为 1 (LendingPriceFeed), 2 (Configurator), 或 3 (Lending)`);
|
||||
}
|
||||
|
||||
// ========== 保存部署信息 ==========
|
||||
// ========== 保存部署信息(最终)==========
|
||||
const allDeployments = JSON.parse(fs.readFileSync(deploymentsPath, "utf-8"));
|
||||
allDeployments[chainId] = deployments;
|
||||
fs.writeFileSync(deploymentsPath, JSON.stringify(allDeployments, null, 2));
|
||||
|
||||
console.log("\n💾 升级信息已保存到:", deploymentsPath);
|
||||
|
||||
// ========== 升级总结 ==========
|
||||
console.log("\n🎉 升级总结:");
|
||||
console.log("=====================================");
|
||||
if (UPGRADE_LENDING) {
|
||||
console.log("升级合约: Lending");
|
||||
console.log("Lending Proxy: ", deployments.lendingProxy);
|
||||
console.log("新 Lending Implementation:", deployments.lendingImpl);
|
||||
} else {
|
||||
console.log("升级合约: Configurator");
|
||||
console.log("Configurator Proxy: ", deployments.configuratorProxy);
|
||||
console.log("新 Configurator Impl: ", deployments.configuratorImpl);
|
||||
}
|
||||
console.log("=====================================\n");
|
||||
|
||||
console.log("✅ 升级完成!");
|
||||
console.log("\n✅ 升级流程全部完成!");
|
||||
console.log("⚠️ 重要提示:");
|
||||
console.log(" 1. 代理地址保持不变,用户无需更改合约地址");
|
||||
console.log(" 2. 所有状态数据已保留");
|
||||
console.log(" 3. 建议在测试网充分测试后再升级主网\n");
|
||||
console.log(" 3. 建议在测试网充分测试后再升级主网");
|
||||
console.log(" 4. 当前升级的合约:", UPGRADE_CONTRACT === 1 ? "LendingPriceFeed" : (UPGRADE_CONTRACT === 2 ? "Configurator" : "Lending"), "\n");
|
||||
}
|
||||
|
||||
main()
|
||||
|
||||
Reference in New Issue
Block a user