update lending script

This commit is contained in:
2025-12-22 14:12:50 +08:00
parent 682552bfe6
commit 0024e7adb1
25 changed files with 797 additions and 1108 deletions

View File

@@ -33,26 +33,21 @@ async function main() {
console.log(" Lending Impl:", deployments.lendingImpl, "\n");
const configurator = await ethers.getContractAt("Configurator", deployments.configuratorProxy);
const lendingFactory = await ethers.getContractAt("LendingFactory", deployments.lendingFactory);
// ========== 第一阶段:配置外部代币和价格源 ==========
console.log("⚙️ Phase 1: 配置外部代币和价格源");
// 这里使用示例地址,实际部署时需要替换为真实地址
// 如果你已有 WUSD 等合约,请从部署文件中读取
const USDC = {
address: "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48", // Mainnet USDC (示例)
address: "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48",
decimals: 6
};
const WETH = {
address: "0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2", // Mainnet WETH (示例)
address: "0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2",
decimals: 18
};
// 价格预言机地址(需要部署或使用 Chainlink
const usdcPriceFeed = "0x8fFfFfd4AfB6115b954Bd326cbe7B4BA576818f6"; // Chainlink USDC/USD (示例)
const ethPriceFeed = "0x5f4eC3Df9cbd43714FE2740f5E3616155c5b8419"; // Chainlink ETH/USD (示例)
const usdcPriceFeed = "0x8fFfFfd4AfB6115b954Bd326cbe7B4BA576818f6";
const ethPriceFeed = "0x5f4eC3Df9cbd43714FE2740f5E3616155c5b8419";
console.log(" 基础资产 (USDC):", USDC.address);
console.log(" 抵押资产 (WETH):", WETH.address);
@@ -141,23 +136,6 @@ async function main() {
const lendingImplAddress = await upgrades.erc1967.getImplementationAddress(lendingProxyAddress);
console.log(" ✅ Lending Implementation (验证):", lendingImplAddress, "\n");
// ========== 第五阶段:验证部署 ==========
console.log("✨ Phase 5: 验证部署");
console.log(" Lending Owner:", await lending.owner());
console.log(" Lending Paused:", await lending.paused());
console.log(" Base Token:", await lending.baseToken());
console.log(" Total Supply:", ethers.formatUnits(await lending.totalSupply(), USDC.decimals));
console.log(" Total Borrow:", ethers.formatUnits(await lending.totalBorrow(), USDC.decimals));
const supplyRate = await lending.getSupplyRate();
const borrowRate = await lending.getBorrowRate();
// 注意:返回的是每秒利率,需要乘以一年的秒数得到 APY
const SECONDS_PER_YEAR = 365 * 24 * 60 * 60;
console.log(" Supply Rate (per second):", ethers.formatUnits(supplyRate, 18));
console.log(" Supply APY:", ethers.formatUnits(BigInt(supplyRate) * BigInt(SECONDS_PER_YEAR), 18));
console.log(" Borrow Rate (per second):", ethers.formatUnits(borrowRate, 18));
console.log(" Borrow APY:", ethers.formatUnits(BigInt(borrowRate) * BigInt(SECONDS_PER_YEAR), 18), "\n");
// ========== 保存部署信息 ==========
deployments.lendingProxy = lendingProxyAddress;
deployments.configTimestamp = new Date().toISOString();
@@ -178,14 +156,6 @@ async function main() {
console.log("Borrow Kink: ", "80%");
console.log("Min Borrow: ", "100 USDC");
console.log("=====================================\n");
console.log("✅ Lending 借贷池已完全配置完成!");
console.log("📝 后续步骤:");
console.log(" 1. 用户可以调用 supply() 存入 USDC");
console.log(" 2. 用户可以调用 supplyCollateral() 存入 WETH");
console.log(" 3. 用户可以调用 borrow() 借出 USDC");
console.log(" 4. 清算人可以调用 absorb() 清算不良贷款");
console.log(" 5. 清算人可以调用 buyCollateral() 购买清算抵押品\n");
}
main()